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
REIKAI
ygopro
Commits
8193327f
Commit
8193327f
authored
Dec 09, 2018
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/Fluorohydride/ygopro
into server
parents
f3968ead
ae3da991
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
42 additions
and
105 deletions
+42
-105
gframe/data_manager.cpp
gframe/data_manager.cpp
+33
-0
gframe/data_manager.h
gframe/data_manager.h
+3
-0
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+3
-29
gframe/replay_mode.h
gframe/replay_mode.h
+0
-1
gframe/single_duel.cpp
gframe/single_duel.cpp
+1
-21
gframe/single_duel.h
gframe/single_duel.h
+0
-1
gframe/single_mode.cpp
gframe/single_mode.cpp
+1
-29
gframe/single_mode.h
gframe/single_mode.h
+0
-2
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+1
-21
gframe/tag_duel.h
gframe/tag_duel.h
+0
-1
No files found.
gframe/data_manager.cpp
View file @
8193327f
...
...
@@ -5,6 +5,7 @@ namespace ygo {
const
wchar_t
*
DataManager
::
unknown_string
=
L"???"
;
wchar_t
DataManager
::
strBuffer
[
4096
];
byte
DataManager
::
scriptBuffer
[
0x20000
];
DataManager
dataManager
;
bool
DataManager
::
LoadDB
(
const
char
*
file
)
{
...
...
@@ -315,5 +316,37 @@ int DataManager::CardReader(int code, void* pData) {
memset
(
pData
,
0
,
sizeof
(
CardData
));
return
0
;
}
byte
*
DataManager
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
#ifdef YGOPRO_SERVER_MODE
char
spname
[
256
]
=
"./specials"
;
strcat
(
spname
,
script_name
+
8
);
//default script name: ./script/c%d.lua
if
(
ScriptReader
(
spname
,
slen
))
return
scriptBuffer
;
#endif
char
exname
[
256
]
=
"./expansions"
;
strcat
(
exname
,
script_name
+
1
);
//default script name: ./script/c%d.lua
if
(
ScriptReader
(
exname
,
slen
))
return
scriptBuffer
;
else
return
ScriptReader
(
script_name
,
slen
);
}
byte
*
DataManager
::
ScriptReader
(
const
char
*
script_name
,
int
*
slen
)
{
FILE
*
fp
;
#ifdef _WIN32
wchar_t
fname
[
256
];
BufferIO
::
DecodeUTF8
(
script_name
,
fname
);
fp
=
_wfopen
(
fname
,
L"rb"
);
#else
fp
=
fopen
(
script_name
,
"rb"
);
#endif
if
(
!
fp
)
return
0
;
int
len
=
fread
(
scriptBuffer
,
1
,
sizeof
(
scriptBuffer
),
fp
);
fclose
(
fp
);
if
(
len
>=
sizeof
(
scriptBuffer
))
return
0
;
*
slen
=
len
;
return
scriptBuffer
;
}
}
gframe/data_manager.h
View file @
8193327f
...
...
@@ -49,8 +49,11 @@ public:
wchar_t
lmBuffer
[
32
];
static
wchar_t
strBuffer
[
4096
];
static
byte
scriptBuffer
[
0x20000
];
static
const
wchar_t
*
unknown_string
;
static
int
CardReader
(
int
,
void
*
);
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
byte
*
ScriptReader
(
const
char
*
script_name
,
int
*
slen
);
};
...
...
gframe/replay_mode.cpp
View file @
8193327f
...
...
@@ -63,15 +63,9 @@ int ReplayMode::ReplayThread(void* param) {
mainGame
->
dInfo
.
isSingleMode
=
!!
(
rh
.
flag
&
REPLAY_SINGLE_MODE
);
mainGame
->
dInfo
.
tag_player
[
0
]
=
false
;
mainGame
->
dInfo
.
tag_player
[
1
]
=
false
;
if
(
mainGame
->
dInfo
.
isSingleMode
)
{
set_script_reader
((
script_reader
)
SingleMode
::
ScriptReaderEx
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
MessageHandler
);
}
else
{
set_script_reader
((
script_reader
)
ScriptReaderEx
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
MessageHandler
);
}
set_script_reader
((
script_reader
)
DataManager
::
ScriptReaderEx
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
MessageHandler
);
if
(
!
StartDuel
())
{
EndDuel
();
return
0
;
...
...
@@ -938,26 +932,6 @@ void ReplayMode::ReplayReload() {
/*len = */
query_field_card
(
pduel
,
1
,
LOCATION_REMOVED
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_REMOVED
,
(
char
*
)
queryBuffer
);
}
byte
*
ReplayMode
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
#ifdef YGOPRO_SERVER_MODE
char
sname
[
256
]
=
"./specials"
;
strcat
(
sname
,
script_name
+
8
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
default_script_reader
(
sname
,
slen
);
if
(
!
buffer
)
{
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
buffer
=
default_script_reader
(
sname
,
slen
);
}
#else
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
default_script_reader
(
sname
,
slen
);
#endif
if
(
buffer
)
return
buffer
;
else
return
default_script_reader
(
script_name
,
slen
);
}
int
ReplayMode
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
return
0
;
...
...
gframe/replay_mode.h
View file @
8193327f
...
...
@@ -47,7 +47,6 @@ public:
static
void
ReplayRefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
void
ReplayReload
();
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
};
...
...
gframe/single_duel.cpp
View file @
8193327f
...
...
@@ -527,7 +527,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
}
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
1
]
=
host_info
.
time_limit
;
set_script_reader
((
script_reader
)
ScriptReaderEx
);
set_script_reader
((
script_reader
)
DataManager
::
ScriptReaderEx
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
SingleDuel
::
MessageHandler
);
rnd
.
reset
(
seed
);
...
...
@@ -2117,26 +2117,6 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
#endif
}
}
byte
*
SingleDuel
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
#ifdef YGOPRO_SERVER_MODE
char
sname
[
256
]
=
"./specials"
;
strcat
(
sname
,
script_name
+
8
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
default_script_reader
(
sname
,
slen
);
if
(
!
buffer
)
{
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
buffer
=
default_script_reader
(
sname
,
slen
);
}
#else
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
default_script_reader
(
sname
,
slen
);
#endif
if
(
buffer
)
return
buffer
;
else
return
default_script_reader
(
script_name
,
slen
);
}
int
SingleDuel
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
return
0
;
...
...
gframe/single_duel.h
View file @
8193327f
...
...
@@ -50,7 +50,6 @@ public:
#endif
void
RefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
static
void
SingleTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
...
...
gframe/single_mode.cpp
View file @
8193327f
...
...
@@ -11,8 +11,6 @@ bool SingleMode::is_closing = false;
bool
SingleMode
::
is_continuing
=
false
;
Replay
SingleMode
::
last_replay
;
static
byte
buffer
[
0x20000
];
bool
SingleMode
::
StartPlay
()
{
Thread
::
NewThread
(
SinglePlayThread
,
0
);
return
true
;
...
...
@@ -38,7 +36,7 @@ int SingleMode::SinglePlayThread(void* param) {
mtrandom
rnd
;
time_t
seed
=
time
(
0
);
rnd
.
reset
(
seed
);
set_script_reader
((
script_reader
)
ScriptReaderEx
);
set_script_reader
((
script_reader
)
DataManager
::
ScriptReaderEx
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
MessageHandler
);
pduel
=
create_duel
(
rnd
.
rand
());
...
...
@@ -852,32 +850,6 @@ void SingleMode::SinglePlayReload() {
/*len = */
query_field_card
(
pduel
,
1
,
LOCATION_REMOVED
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_REMOVED
,
(
char
*
)
queryBuffer
);
}
byte
*
SingleMode
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
//default script name: ./script/c%d.lua
if
(
ScriptReader
(
sname
,
slen
))
return
buffer
;
else
return
ScriptReader
(
script_name
,
slen
);
}
byte
*
SingleMode
::
ScriptReader
(
const
char
*
script_name
,
int
*
slen
)
{
FILE
*
fp
;
#ifdef _WIN32
wchar_t
fname
[
256
];
BufferIO
::
DecodeUTF8
(
script_name
,
fname
);
fp
=
_wfopen
(
fname
,
L"rb"
);
#else
fp
=
fopen
(
script_name
,
"rb"
);
#endif
if
(
!
fp
)
return
0
;
int
len
=
fread
(
buffer
,
1
,
sizeof
(
buffer
),
fp
);
fclose
(
fp
);
if
(
len
>=
sizeof
(
buffer
))
return
0
;
*
slen
=
len
;
return
buffer
;
}
int
SingleMode
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
return
0
;
...
...
gframe/single_mode.h
View file @
8193327f
...
...
@@ -26,8 +26,6 @@ public:
static
void
SinglePlayRefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
void
SinglePlayReload
();
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
byte
*
ScriptReader
(
const
char
*
script_name
,
int
*
slen
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
protected:
...
...
gframe/tag_duel.cpp
View file @
8193327f
...
...
@@ -504,7 +504,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
}
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
1
]
=
host_info
.
time_limit
;
set_script_reader
((
script_reader
)
ScriptReaderEx
);
set_script_reader
((
script_reader
)
DataManager
::
ScriptReaderEx
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
TagDuel
::
MessageHandler
);
rnd
.
reset
(
seed
);
...
...
@@ -2248,26 +2248,6 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
}
}
}
byte
*
TagDuel
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
#ifdef YGOPRO_SERVER_MODE
char
sname
[
256
]
=
"./specials"
;
strcat
(
sname
,
script_name
+
8
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
default_script_reader
(
sname
,
slen
);
if
(
!
buffer
)
{
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
buffer
=
default_script_reader
(
sname
,
slen
);
}
#else
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
default_script_reader
(
sname
,
slen
);
#endif
if
(
buffer
)
return
buffer
;
else
return
default_script_reader
(
script_name
,
slen
);
}
int
TagDuel
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
return
0
;
...
...
gframe/tag_duel.h
View file @
8193327f
...
...
@@ -50,7 +50,6 @@ public:
#endif
void
RefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
static
void
TagTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
...
...
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