Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-2pick
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-2pick
Commits
2047b1ec
Commit
2047b1ec
authored
May 12, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test script
parent
d4006081
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
48 additions
and
7 deletions
+48
-7
gframe/game.cpp
gframe/game.cpp
+11
-5
gframe/game.h
gframe/game.h
+1
-0
gframe/gframe.cpp
gframe/gframe.cpp
+8
-1
gframe/netserver.cpp
gframe/netserver.cpp
+4
-0
gframe/netserver.h
gframe/netserver.h
+1
-0
gframe/network.h
gframe/network.h
+3
-0
gframe/premake4.lua
gframe/premake4.lua
+0
-1
gframe/single_duel.cpp
gframe/single_duel.cpp
+16
-0
gframe/single_duel.h
gframe/single_duel.h
+4
-0
No files found.
gframe/game.cpp
View file @
2047b1ec
...
...
@@ -58,6 +58,13 @@ void Game::MainServerLoop() {
#endif
}
}
void
Game
::
MainTestLoop
(
int
code
)
{
LoadBetaDB
();
LoadExpansionDB
();
dataManager
.
LoadDB
(
"cards.cdb"
);
fflush
(
stdout
);
NetServer
::
InitTestCard
(
code
);
}
void
Game
::
LoadBetaDB
()
{
#ifdef _WIN32
char
fpath
[
1000
];
...
...
@@ -1625,11 +1632,10 @@ void Game::ClearChatMsg() {
void
Game
::
AddDebugMsg
(
char
*
msg
)
{
#ifdef YGOPRO_SERVER_MODE
#ifdef YGOPRO_TEST_REDTEXT
fprintf
(
stdout
,
"%s
\n
"
,
msg
);
#else
fprintf
(
stderr
,
"%s
\n
"
,
msg
);
#endif //YGOPRO_TEST_REDTEXT
if
(
aServerPort
<
0
)
fprintf
(
stdout
,
"%s
\n
"
,
msg
);
else
fprintf
(
stderr
,
"%s
\n
"
,
msg
);
#else
if
(
enable_log
&
0x1
)
{
wchar_t
wbuf
[
1024
];
...
...
gframe/game.h
View file @
2047b1ec
...
...
@@ -120,6 +120,7 @@ public:
bool
Initialize
();
#ifdef YGOPRO_SERVER_MODE
void
MainServerLoop
();
void
MainTestLoop
(
int
code
);
void
LoadExpansionDB
();
void
LoadBetaDB
();
void
AddDebugMsg
(
char
*
msgbuf
);
...
...
gframe/gframe.cpp
View file @
2047b1ec
...
...
@@ -84,7 +84,14 @@ int main(int argc, char* argv[]) {
ygo
::
game_info
.
no_shuffle_deck
=
false
;
ygo
::
game_info
.
duel_rule
=
DEFAULT_DUEL_RULE
;
ygo
::
game_info
.
time_limit
=
180
;
if
(
argc
>
1
)
{
if
(
argc
==
2
)
{
ygo
::
aServerPort
=
-
1
;
int
code
=
atoi
(
argv
[
1
]);
ygo
::
mainGame
=
&
_game
;
ygo
::
mainGame
->
MainTestLoop
(
code
);
return
0
;
}
else
if
(
argc
>
2
)
{
ygo
::
aServerPort
=
atoi
(
argv
[
1
]);
int
lflist
=
atoi
(
argv
[
2
]);
if
(
lflist
<
0
)
...
...
gframe/netserver.cpp
View file @
2047b1ec
...
...
@@ -54,6 +54,10 @@ void NetServer::InitDuel()
BufferIO
::
CopyWStr
(
pkt
->
name
,
duel_mode
->
name
,
20
);
BufferIO
::
CopyWStr
(
pkt
->
pass
,
duel_mode
->
pass
,
20
);
}
void
NetServer
::
InitTestCard
(
int
code
)
{
DuelMode
*
test_duel
=
new
SingleDuel
(
false
);
test_duel
->
TestCard
(
code
);
}
unsigned
short
NetServer
::
StartServer
(
unsigned
short
port
)
{
#else
...
...
gframe/netserver.h
View file @
2047b1ec
...
...
@@ -28,6 +28,7 @@ public:
#ifdef YGOPRO_SERVER_MODE
static
event_base
*
net_evbase
;
static
void
InitDuel
();
static
void
InitTestCard
(
int
code
);
static
unsigned
short
StartServer
(
unsigned
short
port
);
#else
static
bool
StartServer
(
unsigned
short
port
);
...
...
gframe/network.h
View file @
2047b1ec
...
...
@@ -135,6 +135,9 @@ public:
virtual
void
GetResponse
(
DuelPlayer
*
dp
,
void
*
pdata
,
unsigned
int
len
)
{}
virtual
void
TimeConfirm
(
DuelPlayer
*
dp
)
{}
virtual
void
EndDuel
()
{};
#ifdef YGOPRO_SERVER_MODE
virtual
void
TestCard
(
int
code
)
{};
#endif
public:
event
*
etimer
;
...
...
gframe/premake4.lua
View file @
2047b1ec
...
...
@@ -4,7 +4,6 @@ project "ygopro"
kind
"ConsoleApp"
defines
{
"YGOPRO_SERVER_MODE"
}
if
os.getenv
(
"YGOPRO_TEST_REDTEXT"
)
then
defines
{
"YGOPRO_TEST_REDTEXT"
}
end
files
{
"gframe.cpp"
,
"config.h"
,
"game.cpp"
,
"game.h"
,
...
...
gframe/single_duel.cpp
View file @
2047b1ec
...
...
@@ -1935,5 +1935,21 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
event_del
(
sd
->
etimer
);
}
}
#ifdef YGOPRO_SERVER_MODE
void
SingleDuel
::
TestCard
(
int
code
)
{
time_t
seed
=
time
(
0
);
mtrandom
rnd
;
rnd
.
reset
(
seed
);
set_script_reader
(
default_script_reader
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
SingleDuel
::
MessageHandler
);
rnd
.
reset
(
seed
);
unsigned
long
tduel
=
create_duel
(
rnd
.
rand
());
set_player_info
(
tduel
,
0
,
8000
,
5
,
1
);
set_player_info
(
tduel
,
1
,
8000
,
5
,
1
);
new_card
(
tduel
,
code
,
0
,
0
,
LOCATION_DECK
,
0
,
POS_FACEUP_ATTACK
);
end_duel
(
tduel
);
}
#endif
}
gframe/single_duel.h
View file @
2047b1ec
...
...
@@ -28,6 +28,9 @@ public:
virtual
void
GetResponse
(
DuelPlayer
*
dp
,
void
*
pdata
,
unsigned
int
len
);
virtual
void
TimeConfirm
(
DuelPlayer
*
dp
);
virtual
void
EndDuel
();
#ifdef YGOPRO_SERVER_MODE
virtual
void
TestCard
(
int
code
);
#endif
void
DuelEndProc
();
void
WaitforResponse
(
int
playerid
);
...
...
@@ -41,6 +44,7 @@ public:
static
int
MessageHandler
(
long
fduel
,
int
type
);
static
void
SingleTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
protected:
DuelPlayer
*
players
[
2
];
DuelPlayer
*
pplayer
[
2
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment