Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
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
List
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
MobiusMei
ygopro
Commits
0cee78b9
Commit
0cee78b9
authored
Aug 09, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
31b4a96e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
80 additions
and
131 deletions
+80
-131
gframe/game.cpp
gframe/game.cpp
+3
-12
gframe/game.h
gframe/game.h
+4
-11
gframe/gframe.cpp
gframe/gframe.cpp
+29
-19
gframe/netserver.cpp
gframe/netserver.cpp
+20
-9
gframe/netserver.h
gframe/netserver.h
+2
-2
gframe/single_duel.cpp
gframe/single_duel.cpp
+7
-36
gframe/single_duel.h
gframe/single_duel.h
+2
-0
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+11
-42
gframe/tag_duel.h
gframe/tag_duel.h
+2
-0
No files found.
gframe/game.cpp
View file @
0cee78b9
...
...
@@ -30,24 +30,15 @@ Game* mainGame;
#ifdef YGOPRO_SERVER_MODE
unsigned
short
aServerPort
;
unsigned
short
replay_mode
;
unsigned
int
lflist
;
unsigned
char
rule
;
unsigned
char
mode
;
unsigned
char
duel_rule
;
bool
no_check_deck
;
bool
no_shuffle_deck
;
unsigned
int
start_lp
;
unsigned
short
time_limit
;
unsigned
char
start_hand
;
unsigned
char
draw_count
;
HostInfo
game_info
;
void
Game
::
MainServerLoop
(
int
mode
,
int
lflist
)
{
void
Game
::
MainServerLoop
()
{
deckManager
.
LoadLFList
();
LoadExpansionDB
();
dataManager
.
LoadDB
(
"cards.cdb"
);
aServerPort
=
NetServer
::
StartServer
(
aServerPort
);
NetServer
::
InitDuel
(
mode
,
lflist
);
NetServer
::
InitDuel
();
printf
(
"%u
\n
"
,
aServerPort
);
fflush
(
stdout
);
...
...
gframe/game.h
View file @
0cee78b9
...
...
@@ -6,6 +6,8 @@
#include "client_field.h"
#include "deck_con.h"
#include "menu_handler.h"
#else
#include "netserver.h"
#endif //YGOPRO_SERVER_MODE
#include <unordered_map>
#include <vector>
...
...
@@ -87,7 +89,7 @@ class Game {
public:
bool
Initialize
();
#ifdef YGOPRO_SERVER_MODE
void
MainServerLoop
(
int
mode
,
int
lflist
);
void
MainServerLoop
();
void
LoadExpansionDB
();
void
AddDebugMsg
(
char
*
msgbuf
);
#else
...
...
@@ -439,16 +441,7 @@ extern Game* mainGame;
#ifdef YGOPRO_SERVER_MODE
extern
unsigned
short
aServerPort
;
extern
unsigned
short
replay_mode
;
extern
unsigned
int
lflist
;
extern
unsigned
char
rule
;
extern
unsigned
char
mode
;
extern
unsigned
char
duel_rule
;
extern
bool
no_check_deck
;
extern
bool
no_shuffle_deck
;
extern
unsigned
int
start_lp
;
extern
unsigned
short
time_limit
;
extern
unsigned
char
start_hand
;
extern
unsigned
char
draw_count
;
extern
HostInfo
game_info
;
#endif //YGOPRO_SERVER_MODE
}
...
...
gframe/gframe.cpp
View file @
0cee78b9
...
...
@@ -60,34 +60,44 @@ int main(int argc, char* argv[]) {
#ifdef YGOPRO_SERVER_MODE
enable_log
=
1
;
ygo
::
aServerPort
=
7911
;
ygo
::
aServerPort
=
atoi
(
argv
[
1
]);
ygo
::
lflist
=
atoi
(
argv
[
2
]);
ygo
::
start_hand
=
0
;
if
(
argc
>
2
)
{
ygo
::
rule
=
atoi
(
argv
[
3
]);
ygo
::
mode
=
atoi
(
argv
[
4
]);
if
(
ygo
::
mode
>
2
)
ygo
::
mode
=
0
;
ygo
::
replay_mode
=
0
;
ygo
::
game_info
.
lflist
=
0
;
ygo
::
game_info
.
rule
=
0
;
ygo
::
game_info
.
mode
=
0
;
ygo
::
game_info
.
start_hand
=
5
;
ygo
::
game_info
.
start_lp
=
8000
;
ygo
::
game_info
.
draw_count
=
1
;
ygo
::
game_info
.
no_check_deck
=
false
;
ygo
::
game_info
.
no_shuffle_deck
=
false
;
ygo
::
game_info
.
duel_rule
=
DEFAULT_DUEL_RULE
;
ygo
::
game_info
.
time_limit
=
180
;
if
(
argc
>
1
)
{
ygo
::
aServerPort
=
atoi
(
argv
[
1
]);
ygo
::
game_info
.
lflist
=
atoi
(
argv
[
2
]);
ygo
::
game_info
.
rule
=
atoi
(
argv
[
3
]);
ygo
::
game_info
.
mode
=
atoi
(
argv
[
4
]);
if
(
ygo
::
game_info
.
mode
>
2
)
ygo
::
game_info
.
mode
=
0
;
if
(
argv
[
5
][
0
]
==
'T'
)
ygo
::
duel_rule
=
DEFAULT_DUEL_RULE
-
1
;
ygo
::
game_info
.
duel_rule
=
DEFAULT_DUEL_RULE
-
1
;
else
ygo
::
duel_rule
=
DEFAULT_DUEL_RULE
;
ygo
::
game_info
.
duel_rule
=
DEFAULT_DUEL_RULE
;
if
(
argv
[
6
][
0
]
==
'T'
)
ygo
::
no_check_deck
=
true
;
ygo
::
game_info
.
no_check_deck
=
true
;
else
ygo
::
no_check_deck
=
false
;
ygo
::
game_info
.
no_check_deck
=
false
;
if
(
argv
[
7
][
0
]
==
'T'
)
ygo
::
no_shuffle_deck
=
true
;
ygo
::
game_info
.
no_shuffle_deck
=
true
;
else
ygo
::
no_shuffle_deck
=
false
;
ygo
::
start_lp
=
atoi
(
argv
[
8
]);
ygo
::
start_hand
=
atoi
(
argv
[
9
]);
ygo
::
draw_count
=
atoi
(
argv
[
10
]);
ygo
::
time_limit
=
atoi
(
argv
[
11
]);
ygo
::
game_info
.
no_shuffle_deck
=
false
;
ygo
::
game_info
.
start_lp
=
atoi
(
argv
[
8
]);
ygo
::
game_info
.
start_hand
=
atoi
(
argv
[
9
]);
ygo
::
game_info
.
draw_count
=
atoi
(
argv
[
10
]);
ygo
::
game_info
.
time_limit
=
atoi
(
argv
[
11
]);
ygo
::
replay_mode
=
atoi
(
argv
[
12
]);
}
ygo
::
mainGame
=
&
_game
;
ygo
::
mainGame
->
MainServerLoop
(
ygo
::
mode
,
ygo
::
lflist
);
ygo
::
mainGame
->
MainServerLoop
();
return
0
;
#else
ygo
::
mainGame
=
&
_game
;
...
...
gframe/netserver.cpp
View file @
0cee78b9
...
...
@@ -14,29 +14,40 @@ char NetServer::net_server_write[0x2000];
unsigned
short
NetServer
::
last_sent
=
0
;
#ifdef YGOPRO_SERVER_MODE
void
NetServer
::
InitDuel
(
int
mode
,
int
lflist
)
extern
unsigned
short
replay_mode
;
extern
HostInfo
game_info
;
void
NetServer
::
InitDuel
()
{
if
(
mode
==
MODE_SINGLE
)
{
if
(
game_info
.
mode
==
MODE_SINGLE
)
{
duel_mode
=
new
SingleDuel
(
false
);
duel_mode
->
etimer
=
event_new
(
net_evbase
,
0
,
EV_TIMEOUT
|
EV_PERSIST
,
SingleDuel
::
SingleTimer
,
duel_mode
);
}
else
if
(
mode
==
MODE_MATCH
)
{
}
else
if
(
game_info
.
mode
==
MODE_MATCH
)
{
duel_mode
=
new
SingleDuel
(
true
);
duel_mode
->
etimer
=
event_new
(
net_evbase
,
0
,
EV_TIMEOUT
|
EV_PERSIST
,
SingleDuel
::
SingleTimer
,
duel_mode
);
}
else
if
(
mode
==
MODE_TAG
)
{
}
else
if
(
game_info
.
mode
==
MODE_TAG
)
{
duel_mode
=
new
TagDuel
();
duel_mode
->
etimer
=
event_new
(
net_evbase
,
0
,
EV_TIMEOUT
|
EV_PERSIST
,
TagDuel
::
TagTimer
,
duel_mode
);
}
CTOS_CreateGame
*
pkt
=
new
CTOS_CreateGame
;
pkt
->
info
.
mode
=
game_info
.
mode
;
pkt
->
info
.
start_hand
=
game_info
.
start_hand
;
pkt
->
info
.
start_lp
=
game_info
.
start_lp
;
pkt
->
info
.
draw_count
=
game_info
.
draw_count
;
pkt
->
info
.
no_check_deck
=
game_info
.
no_check_deck
;
pkt
->
info
.
no_shuffle_deck
=
game_info
.
no_shuffle_deck
;
pkt
->
info
.
duel_rule
=
game_info
.
duel_rule
;
pkt
->
info
.
rule
=
game_info
.
rule
;
pkt
->
info
.
time_limit
=
game_info
.
time_limit
;
pkt
->
info
.
mode
=
mode
;
if
(
lflist
<
0
)
if
(
game_info
.
lflist
<
0
)
pkt
->
info
.
lflist
=
0
;
else
if
(
lflist
>=
deckManager
.
_lfList
.
size
())
else
if
(
game_info
.
lflist
>=
deckManager
.
_lfList
.
size
())
pkt
->
info
.
lflist
=
deckManager
.
_lfList
[
0
].
hash
;
else
pkt
->
info
.
lflist
=
deckManager
.
_lfList
[
lflist
].
hash
;
pkt
->
info
.
lflist
=
deckManager
.
_lfList
[
game_info
.
lflist
].
hash
;
duel_mode
->
host_info
=
pkt
->
info
;
...
...
gframe/netserver.h
View file @
0cee78b9
...
...
@@ -27,7 +27,7 @@ private:
public:
#ifdef YGOPRO_SERVER_MODE
static
event_base
*
net_evbase
;
static
void
InitDuel
(
int
mode
,
int
lflist
);
static
void
InitDuel
();
static
unsigned
short
StartServer
(
unsigned
short
port
);
#else
static
bool
StartServer
(
unsigned
short
port
);
...
...
@@ -74,7 +74,7 @@ public:
}
static
void
ReSendToPlayer
(
DuelPlayer
*
dp
)
{
if
(
dp
)
bufferevent_write
(
dp
->
bev
,
net_server_write
,
last_sent
);
bufferevent_write
(
dp
->
bev
,
ne
s
t_server_write
,
last_sent
);
}
};
...
...
gframe/single_duel.cpp
View file @
0cee78b9
...
...
@@ -9,18 +9,7 @@
namespace
ygo
{
extern
unsigned
int
lflist
;
extern
unsigned
char
rule
;
extern
unsigned
char
mode
;
extern
unsigned
char
duel_rule
;
extern
bool
no_check_deck
;
extern
bool
no_shuffle_deck
;
extern
unsigned
int
start_lp
;
extern
unsigned
short
time_limit
;
extern
unsigned
short
replay_mode
;
extern
unsigned
char
start_hand
;
extern
unsigned
char
draw_count
;
bool
runasserver
=
true
;
SingleDuel
::
SingleDuel
(
bool
is_match
)
{
game_started
=
false
;
...
...
@@ -46,15 +35,19 @@ void SingleDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
for
(
auto
pit
=
observers
.
begin
();
pit
!=
observers
.
end
();
++
pit
)
if
((
*
pit
)
!=
dp
)
NetServer
::
ReSendToPlayer
(
*
pit
);
#ifdef YGOPRO_SERVER_MODE
/*for(auto pit = recorders.begin(); pit != recorders.end(); ++pit)
if((*pit) != dp)
NetServer::ReSendToPlayer(*pit);*/
#endif //YGOPRO_SERVER_MODE
}
else
{
NetServer
::
SendBufferToPlayer
(
players
[
1
-
dp
->
type
],
STOC_CHAT
,
&
scc
,
4
+
msglen
*
2
);
for
(
auto
pit
=
observers
.
begin
();
pit
!=
observers
.
end
();
++
pit
)
NetServer
::
ReSendToPlayer
(
*
pit
);
#ifdef YGOPRO_SERVER_MODE
/*for(auto pit = recorders.begin(); pit != recorders.end(); ++pit)
NetServer::ReSendToPlayer(*pit);*/
#endif //YGOPRO_SERVER_MODE
}
}
void
SingleDuel
::
JoinGame
(
DuelPlayer
*
dp
,
void
*
pdata
,
bool
is_creater
)
{
...
...
@@ -76,31 +69,9 @@ void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
NetServer
::
DisconnectPlayer
(
dp
);
return
;
}
if
(
runasserver
){
host_info
.
start_hand
=
5
;
host_info
.
start_lp
=
8000
;
host_info
.
draw_count
=
1
;
host_info
.
mode
=
1
;
host_info
.
no_check_deck
=
false
;
host_info
.
no_shuffle_deck
=
false
;
host_info
.
duel_rule
=
DEFAULT_DUEL_RULE
;
host_info
.
rule
=
0
;
host_info
.
time_limit
=
180
;
#ifdef YGOPRO_SERVER_MODE
if
(
ygo
::
start_hand
!=
0
){
host_info
.
start_hand
=
ygo
::
start_hand
;
host_info
.
start_lp
=
ygo
::
start_lp
;
host_info
.
draw_count
=
ygo
::
draw_count
;
host_info
.
mode
=
ygo
::
mode
;
host_info
.
no_check_deck
=
ygo
::
no_check_deck
;
host_info
.
no_shuffle_deck
=
ygo
::
no_shuffle_deck
;
host_info
.
duel_rule
=
ygo
::
duel_rule
;
host_info
.
rule
=
ygo
::
rule
;
host_info
.
time_limit
=
ygo
::
time_limit
;
}
}
else
{
#else
wchar_t
jpass
[
20
];
BufferIO
::
CopyWStr
(
pkt
->
pass
,
jpass
,
20
);
if
(
wcscmp
(
jpass
,
pass
))
{
...
...
@@ -110,7 +81,7 @@ void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
NetServer
::
SendPacketToPlayer
(
dp
,
STOC_ERROR_MSG
,
scem
);
return
;
}
}
#endif //YGOPRO_SERVER_MODE
}
dp
->
game
=
this
;
if
(
!
players
[
0
]
&&
!
players
[
1
]
&&
observers
.
size
()
==
0
)
...
...
gframe/single_duel.h
View file @
0cee78b9
...
...
@@ -49,7 +49,9 @@ protected:
unsigned
char
hand_result
[
2
];
unsigned
char
last_response
;
std
::
set
<
DuelPlayer
*>
observers
;
#ifdef YGOPRO_SERVER_MODE
std
::
set
<
DuelPlayer
*>
recorders
;
#endif //YGOPRO_SERVER_MODE
Replay
last_replay
;
bool
match_mode
;
int
match_kill
;
...
...
gframe/tag_duel.cpp
View file @
0cee78b9
...
...
@@ -9,17 +9,7 @@
namespace
ygo
{
extern
unsigned
int
lflist
;
extern
unsigned
char
rule
;
extern
unsigned
char
mode
;
extern
unsigned
char
duel_rule
;
extern
bool
no_check_deck
;
extern
bool
no_shuffle_deck
;
extern
unsigned
int
start_lp
;
extern
unsigned
short
time_limit
;
extern
unsigned
short
replay_mode
;
extern
unsigned
char
start_hand
;
extern
unsigned
char
draw_count
;
TagDuel
::
TagDuel
()
{
game_started
=
false
;
...
...
@@ -58,40 +48,19 @@ void TagDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
NetServer
::
DisconnectPlayer
(
dp
);
return
;
}
if
(
true
){
host_info
.
start_hand
=
5
;
host_info
.
start_lp
=
8000
;
host_info
.
draw_count
=
1
;
host_info
.
mode
=
3
;
host_info
.
no_check_deck
=
false
;
host_info
.
no_shuffle_deck
=
false
;
host_info
.
duel_rule
=
DEFAULT_DUEL_RULE
;
host_info
.
rule
=
0
;
host_info
.
time_limit
=
180
;
#ifdef YGOPRO_SERVER_MODE
if
(
ygo
::
start_hand
!=
0
){
host_info
.
start_hand
=
ygo
::
start_hand
;
host_info
.
start_lp
=
ygo
::
start_lp
;
host_info
.
draw_count
=
ygo
::
draw_count
;
host_info
.
mode
=
ygo
::
mode
;
host_info
.
no_check_deck
=
ygo
::
no_check_deck
;
host_info
.
no_shuffle_deck
=
ygo
::
no_shuffle_deck
;
host_info
.
duel_rule
=
ygo
::
duel_rule
;
host_info
.
rule
=
ygo
::
rule
;
host_info
.
time_limit
=
ygo
::
time_limit
;
}
}
else
{
wchar_t
jpass
[
20
];
BufferIO
::
CopyWStr
(
pkt
->
pass
,
jpass
,
20
);
if
(
wcscmp
(
jpass
,
pass
))
{
STOC_ErrorMsg
scem
;
scem
.
msg
=
ERRMSG_JOINERROR
;
scem
.
code
=
1
;
NetServer
::
SendPacketToPlayer
(
dp
,
STOC_ERROR_MSG
,
scem
);
return
;
}
#else
wchar_t
jpass
[
20
];
BufferIO
::
CopyWStr
(
pkt
->
pass
,
jpass
,
20
);
if
(
wcscmp
(
jpass
,
pass
))
{
STOC_ErrorMsg
scem
;
scem
.
msg
=
ERRMSG_JOINERROR
;
scem
.
code
=
1
;
NetServer
::
SendPacketToPlayer
(
dp
,
STOC_ERROR_MSG
,
scem
);
return
;
}
#endif //YGOPRO_SERVER_MODE
}
dp
->
game
=
this
;
if
(
!
players
[
0
]
&&
!
players
[
1
]
&&
!
players
[
2
]
&&
!
players
[
3
]
&&
observers
.
size
()
==
0
)
...
...
gframe/tag_duel.h
View file @
0cee78b9
...
...
@@ -46,7 +46,9 @@ protected:
DuelPlayer
*
pplayer
[
4
];
DuelPlayer
*
cur_player
[
2
];
std
::
set
<
DuelPlayer
*>
observers
;
#ifdef YGOPRO_SERVER_MODE
std
::
set
<
DuelPlayer
*>
recorders
;
#endif //YGOPRO_SERVER_MODE
bool
ready
[
4
];
Deck
pdeck
[
4
];
unsigned
char
hand_result
[
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