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
苍蓝
ygopro
Commits
ae3da991
Commit
ae3da991
authored
Dec 09, 2018
by
mercury233
Committed by
GitHub
Dec 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use one ScriptReaderEx (#2165)
parent
c13ed7b6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
36 additions
and
72 deletions
+36
-72
gframe/data_manager.cpp
gframe/data_manager.cpp
+27
-0
gframe/data_manager.h
gframe/data_manager.h
+3
-0
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+3
-18
gframe/replay_mode.h
gframe/replay_mode.h
+0
-1
gframe/single_duel.cpp
gframe/single_duel.cpp
+1
-10
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
-10
gframe/tag_duel.h
gframe/tag_duel.h
+0
-1
No files found.
gframe/data_manager.cpp
View file @
ae3da991
...
@@ -5,6 +5,7 @@ namespace ygo {
...
@@ -5,6 +5,7 @@ namespace ygo {
const
wchar_t
*
DataManager
::
unknown_string
=
L"???"
;
const
wchar_t
*
DataManager
::
unknown_string
=
L"???"
;
wchar_t
DataManager
::
strBuffer
[
4096
];
wchar_t
DataManager
::
strBuffer
[
4096
];
byte
DataManager
::
scriptBuffer
[
0x20000
];
DataManager
dataManager
;
DataManager
dataManager
;
bool
DataManager
::
LoadDB
(
const
char
*
file
)
{
bool
DataManager
::
LoadDB
(
const
char
*
file
)
{
...
@@ -309,5 +310,31 @@ int DataManager::CardReader(int code, void* pData) {
...
@@ -309,5 +310,31 @@ int DataManager::CardReader(int code, void* pData) {
memset
(
pData
,
0
,
sizeof
(
CardData
));
memset
(
pData
,
0
,
sizeof
(
CardData
));
return
0
;
return
0
;
}
}
byte
*
DataManager
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
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 @
ae3da991
...
@@ -49,8 +49,11 @@ public:
...
@@ -49,8 +49,11 @@ public:
wchar_t
lmBuffer
[
32
];
wchar_t
lmBuffer
[
32
];
static
wchar_t
strBuffer
[
4096
];
static
wchar_t
strBuffer
[
4096
];
static
byte
scriptBuffer
[
0x20000
];
static
const
wchar_t
*
unknown_string
;
static
const
wchar_t
*
unknown_string
;
static
int
CardReader
(
int
,
void
*
);
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 @
ae3da991
...
@@ -63,15 +63,9 @@ int ReplayMode::ReplayThread(void* param) {
...
@@ -63,15 +63,9 @@ int ReplayMode::ReplayThread(void* param) {
mainGame
->
dInfo
.
isSingleMode
=
!!
(
rh
.
flag
&
REPLAY_SINGLE_MODE
);
mainGame
->
dInfo
.
isSingleMode
=
!!
(
rh
.
flag
&
REPLAY_SINGLE_MODE
);
mainGame
->
dInfo
.
tag_player
[
0
]
=
false
;
mainGame
->
dInfo
.
tag_player
[
0
]
=
false
;
mainGame
->
dInfo
.
tag_player
[
1
]
=
false
;
mainGame
->
dInfo
.
tag_player
[
1
]
=
false
;
if
(
mainGame
->
dInfo
.
isSingleMode
)
{
set_script_reader
((
script_reader
)
DataManager
::
ScriptReaderEx
);
set_script_reader
((
script_reader
)
SingleMode
::
ScriptReaderEx
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
MessageHandler
);
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
);
}
if
(
!
StartDuel
())
{
if
(
!
StartDuel
())
{
EndDuel
();
EndDuel
();
return
0
;
return
0
;
...
@@ -935,15 +929,6 @@ void ReplayMode::ReplayReload() {
...
@@ -935,15 +929,6 @@ void ReplayMode::ReplayReload() {
/*len = */
query_field_card
(
pduel
,
1
,
LOCATION_REMOVED
,
flag
,
queryBuffer
,
0
);
/*len = */
query_field_card
(
pduel
,
1
,
LOCATION_REMOVED
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_REMOVED
,
(
char
*
)
queryBuffer
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_REMOVED
,
(
char
*
)
queryBuffer
);
}
}
byte
*
ReplayMode
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
default_script_reader
(
sname
,
slen
);
if
(
buffer
)
return
buffer
;
else
return
default_script_reader
(
script_name
,
slen
);
}
int
ReplayMode
::
MessageHandler
(
long
fduel
,
int
type
)
{
int
ReplayMode
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
if
(
!
enable_log
)
return
0
;
return
0
;
...
...
gframe/replay_mode.h
View file @
ae3da991
...
@@ -47,7 +47,6 @@ public:
...
@@ -47,7 +47,6 @@ public:
static
void
ReplayRefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
void
ReplayRefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
void
ReplayReload
();
static
void
ReplayReload
();
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
};
};
...
...
gframe/single_duel.cpp
View file @
ae3da991
...
@@ -406,7 +406,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
...
@@ -406,7 +406,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
}
}
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
1
]
=
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_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
SingleDuel
::
MessageHandler
);
set_message_handler
((
message_handler
)
SingleDuel
::
MessageHandler
);
rnd
.
reset
(
seed
);
rnd
.
reset
(
seed
);
...
@@ -1544,15 +1544,6 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
...
@@ -1544,15 +1544,6 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
NetServer
::
ReSendToPlayer
(
*
pit
);
NetServer
::
ReSendToPlayer
(
*
pit
);
}
}
}
}
byte
*
SingleDuel
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
default_script_reader
(
sname
,
slen
);
if
(
buffer
)
return
buffer
;
else
return
default_script_reader
(
script_name
,
slen
);
}
int
SingleDuel
::
MessageHandler
(
long
fduel
,
int
type
)
{
int
SingleDuel
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
if
(
!
enable_log
)
return
0
;
return
0
;
...
...
gframe/single_duel.h
View file @
ae3da991
...
@@ -38,7 +38,6 @@ public:
...
@@ -38,7 +38,6 @@ public:
void
RefreshExtra
(
int
player
,
int
flag
=
0x81fff
,
int
use_cache
=
1
);
void
RefreshExtra
(
int
player
,
int
flag
=
0x81fff
,
int
use_cache
=
1
);
void
RefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
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
int
MessageHandler
(
long
fduel
,
int
type
);
static
void
SingleTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
static
void
SingleTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
...
...
gframe/single_mode.cpp
View file @
ae3da991
...
@@ -11,8 +11,6 @@ bool SingleMode::is_closing = false;
...
@@ -11,8 +11,6 @@ bool SingleMode::is_closing = false;
bool
SingleMode
::
is_continuing
=
false
;
bool
SingleMode
::
is_continuing
=
false
;
Replay
SingleMode
::
last_replay
;
Replay
SingleMode
::
last_replay
;
static
byte
buffer
[
0x20000
];
bool
SingleMode
::
StartPlay
()
{
bool
SingleMode
::
StartPlay
()
{
Thread
::
NewThread
(
SinglePlayThread
,
0
);
Thread
::
NewThread
(
SinglePlayThread
,
0
);
return
true
;
return
true
;
...
@@ -38,7 +36,7 @@ int SingleMode::SinglePlayThread(void* param) {
...
@@ -38,7 +36,7 @@ int SingleMode::SinglePlayThread(void* param) {
mtrandom
rnd
;
mtrandom
rnd
;
time_t
seed
=
time
(
0
);
time_t
seed
=
time
(
0
);
rnd
.
reset
(
seed
);
rnd
.
reset
(
seed
);
set_script_reader
((
script_reader
)
ScriptReaderEx
);
set_script_reader
((
script_reader
)
DataManager
::
ScriptReaderEx
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
MessageHandler
);
set_message_handler
((
message_handler
)
MessageHandler
);
pduel
=
create_duel
(
rnd
.
rand
());
pduel
=
create_duel
(
rnd
.
rand
());
...
@@ -852,32 +850,6 @@ void SingleMode::SinglePlayReload() {
...
@@ -852,32 +850,6 @@ void SingleMode::SinglePlayReload() {
/*len = */
query_field_card
(
pduel
,
1
,
LOCATION_REMOVED
,
flag
,
queryBuffer
,
0
);
/*len = */
query_field_card
(
pduel
,
1
,
LOCATION_REMOVED
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_REMOVED
,
(
char
*
)
queryBuffer
);
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
)
{
int
SingleMode
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
if
(
!
enable_log
)
return
0
;
return
0
;
...
...
gframe/single_mode.h
View file @
ae3da991
...
@@ -26,8 +26,6 @@ public:
...
@@ -26,8 +26,6 @@ public:
static
void
SinglePlayRefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
void
SinglePlayRefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
void
SinglePlayReload
();
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
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
protected:
protected:
...
...
gframe/tag_duel.cpp
View file @
ae3da991
...
@@ -381,7 +381,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
...
@@ -381,7 +381,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
}
}
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
1
]
=
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_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
TagDuel
::
MessageHandler
);
set_message_handler
((
message_handler
)
TagDuel
::
MessageHandler
);
rnd
.
reset
(
seed
);
rnd
.
reset
(
seed
);
...
@@ -1661,15 +1661,6 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
...
@@ -1661,15 +1661,6 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
}
}
}
}
}
}
byte
*
TagDuel
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
default_script_reader
(
sname
,
slen
);
if
(
buffer
)
return
buffer
;
else
return
default_script_reader
(
script_name
,
slen
);
}
int
TagDuel
::
MessageHandler
(
long
fduel
,
int
type
)
{
int
TagDuel
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
if
(
!
enable_log
)
return
0
;
return
0
;
...
...
gframe/tag_duel.h
View file @
ae3da991
...
@@ -38,7 +38,6 @@ public:
...
@@ -38,7 +38,6 @@ public:
void
RefreshExtra
(
int
player
,
int
flag
=
0x81fff
,
int
use_cache
=
1
);
void
RefreshExtra
(
int
player
,
int
flag
=
0x81fff
,
int
use_cache
=
1
);
void
RefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
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
int
MessageHandler
(
long
fduel
,
int
type
);
static
void
TagTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
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