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
3f2970fa
Commit
3f2970fa
authored
Nov 13, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'server_subdir' into server
parents
f48181e1
e2dd3802
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
219 additions
and
100 deletions
+219
-100
gframe/data_manager.cpp
gframe/data_manager.cpp
+6
-0
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+13
-0
gframe/game.cpp
gframe/game.cpp
+30
-10
gframe/game.h
gframe/game.h
+3
-0
gframe/image_manager.cpp
gframe/image_manager.cpp
+50
-20
gframe/image_manager.h
gframe/image_manager.h
+2
-0
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+26
-15
gframe/replay_mode.h
gframe/replay_mode.h
+3
-2
gframe/single_duel.cpp
gframe/single_duel.cpp
+26
-15
gframe/single_duel.h
gframe/single_duel.h
+3
-4
gframe/single_mode.cpp
gframe/single_mode.cpp
+25
-15
gframe/single_mode.h
gframe/single_mode.h
+2
-1
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+27
-15
gframe/tag_duel.h
gframe/tag_duel.h
+3
-3
No files found.
gframe/data_manager.cpp
View file @
3f2970fa
...
...
@@ -71,7 +71,13 @@ bool DataManager::LoadDB(const char* file) {
return
true
;
}
bool
DataManager
::
LoadStrings
(
const
char
*
file
)
{
#ifdef _WIN32
wchar_t
fname
[
1024
];
BufferIO
::
DecodeUTF8
(
file
,
fname
);
FILE
*
fp
=
_wfopen
(
fname
,
L"r"
);
#else
FILE
*
fp
=
fopen
(
file
,
"r"
);
#endif // _WIN32
if
(
!
fp
)
return
false
;
char
linebuf
[
256
];
...
...
gframe/deck_manager.cpp
View file @
3f2970fa
...
...
@@ -10,7 +10,13 @@ DeckManager deckManager;
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
LFList
*
cur
=
NULL
;
#ifdef _WIN32
wchar_t
fname
[
1024
];
BufferIO
::
DecodeUTF8
(
path
,
fname
);
FILE
*
fp
=
_wfopen
(
fname
,
L"r"
);
#else
FILE
*
fp
=
fopen
(
path
,
"r"
);
#endif // _WIN32
char
linebuf
[
256
];
wchar_t
strBuffer
[
256
];
if
(
fp
)
{
...
...
@@ -51,6 +57,13 @@ void DeckManager::LoadLFListSingle(const char* path) {
}
void
DeckManager
::
LoadLFList
()
{
LoadLFListSingle
(
"expansions/lflist.conf"
);
FileSystem
::
TraversalDir
(
"./expansions"
,
[
this
](
const
char
*
name
,
bool
isdir
)
{
if
(
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
fpath
[
1024
];
sprintf
(
fpath
,
"./expansions/%s/lflist.conf"
,
name
);
LoadLFListSingle
(
fpath
);
}
});
LoadLFListSingle
(
"lflist.conf"
);
LFList
nolimit
;
myswprintf
(
nolimit
.
listName
,
L"N/A"
);
...
...
gframe/game.cpp
View file @
3f2970fa
...
...
@@ -56,17 +56,18 @@ void Game::MainTestLoop(int code) {
NetServer
::
InitTestCard
(
code
);
}
void
Game
::
LoadBetaDB
()
{
LoadExpansionDBDirectry
(
"./beta"
);
#ifdef _WIN32
char
fpath
[
1000
];
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./beta/*
.cdb
"
,
&
fdataw
);
HANDLE
fh
=
FindFirstFileW
(
L"./beta/*"
,
&
fdataw
);
if
(
fh
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
)
{
if
(
wcscmp
(
L"."
,
fdataw
.
cFileName
)
!=
0
&&
wcscmp
(
L".."
,
fdataw
.
cFileName
)
!=
0
&&
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
char
fname
[
780
];
BufferIO
::
EncodeUTF8
(
fdataw
.
cFileName
,
fname
);
sprintf
(
fpath
,
"./beta/%s"
,
fname
);
dataManager
.
LoadDB
(
fpath
);
LoadExpansionDBDirectry
(
fpath
);
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
...
...
@@ -76,12 +77,11 @@ void Game::LoadBetaDB() {
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./beta/"
))
!=
NULL
)
{
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".cdb"
)
!=
0
)
if
(
strcmp
(
"."
,
dirp
->
d_name
)
==
0
||
strcmp
(
".."
,
dirp
->
d_name
)
==
0
||
dirp
->
d_type
!=
DT_DIR
)
continue
;
char
filepath
[
1000
];
sprintf
(
filepath
,
"./beta/%s"
,
dirp
->
d_name
);
dataManager
.
LoadDB
(
filepath
);
sprintf
(
filepath
,
"./beta/%s
/
"
,
dirp
->
d_name
);
LoadExpansionDBDirectry
(
filepath
);
}
closedir
(
dir
);
}
...
...
@@ -159,7 +159,7 @@ bool Game::Initialize() {
ErrorLog
(
"Failed to load strings!"
);
return
false
;
}
dataManager
.
LoadStrings
(
"./expansions/strings.conf"
);
LoadExpansionStrings
(
);
env
=
device
->
getGUIEnvironment
();
numFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
numfont
,
16
);
adFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
numfont
,
12
);
...
...
@@ -1044,15 +1044,35 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
}
#endif //YGOPRO_SERVER_MODE
void
Game
::
LoadExpansionDB
()
{
FileSystem
::
TraversalDir
(
"./expansions"
,
[](
const
char
*
name
,
bool
isdir
)
{
LoadExpansionDBDirectry
(
"./expansions"
);
FileSystem
::
TraversalDir
(
"./expansions"
,
[
this
](
const
char
*
name
,
bool
isdir
)
{
if
(
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
LoadExpansionDBDirectry
(
subdir
);
}
});
}
void
Game
::
LoadExpansionDBDirectry
(
const
char
*
path
)
{
FileSystem
::
TraversalDir
(
path
,
[
path
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
strrchr
(
name
,
'.'
)
&&
!
mystrncasecmp
(
strrchr
(
name
,
'.'
),
".cdb"
,
4
))
{
char
fpath
[
1024
];
sprintf
(
fpath
,
"
./expansions/%s"
,
name
);
sprintf
(
fpath
,
"
%s/%s"
,
path
,
name
);
dataManager
.
LoadDB
(
fpath
);
}
});
}
#ifndef YGOPRO_SERVER_MODE
void
Game
::
LoadExpansionStrings
()
{
dataManager
.
LoadStrings
(
"./expansions/strings.conf"
);
FileSystem
::
TraversalDir
(
"./expansions"
,
[](
const
char
*
name
,
bool
isdir
)
{
if
(
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
fpath
[
1024
];
sprintf
(
fpath
,
"./expansions/%s/strings.conf"
,
name
);
dataManager
.
LoadStrings
(
fpath
);
}
});
}
void
Game
::
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
cbDeck
->
clear
();
FileSystem
::
TraversalDir
(
L"./deck"
,
[
cbDeck
](
const
wchar_t
*
name
,
bool
isdir
)
{
...
...
gframe/game.h
View file @
3f2970fa
...
...
@@ -131,6 +131,7 @@ public:
void
MainServerLoop
();
void
MainTestLoop
(
int
code
);
void
LoadExpansionDB
();
void
LoadExpansionDBDirectry
(
const
char
*
path
);
void
LoadBetaDB
();
void
AddDebugMsg
(
const
char
*
msgbuf
);
void
initUtils
();
...
...
@@ -141,6 +142,8 @@ public:
void
InitStaticText
(
irr
::
gui
::
IGUIStaticText
*
pControl
,
u32
cWidth
,
u32
cHeight
,
irr
::
gui
::
CGUITTFont
*
font
,
const
wchar_t
*
text
);
void
SetStaticText
(
irr
::
gui
::
IGUIStaticText
*
pControl
,
u32
cWidth
,
irr
::
gui
::
CGUITTFont
*
font
,
const
wchar_t
*
text
,
u32
pos
=
0
);
void
LoadExpansionDB
();
void
LoadExpansionDBDirectry
(
const
char
*
path
);
void
LoadExpansionStrings
();
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshReplay
();
void
RefreshSingleplay
();
...
...
gframe/image_manager.cpp
View file @
3f2970fa
...
...
@@ -271,23 +271,30 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
}
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureFromFile
(
char
*
file
,
s32
width
,
s32
height
)
{
#ifdef _WIN32
wchar_t
name
[
1024
];
BufferIO
::
DecodeUTF8
(
file
,
name
);
#else
char
*
name
=
file
;
#endif // _WIN32
if
(
mainGame
->
gameConf
.
use_image_scale
)
{
irr
::
video
::
ITexture
*
texture
;
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
fil
e
);
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
nam
e
);
if
(
srcimg
==
NULL
)
return
NULL
;
if
(
srcimg
->
getDimension
()
==
irr
::
core
::
dimension2d
<
u32
>
(
width
,
height
))
{
texture
=
driver
->
addTexture
(
fil
e
,
srcimg
);
texture
=
driver
->
addTexture
(
nam
e
,
srcimg
);
}
else
{
video
::
IImage
*
destimg
=
driver
->
createImage
(
srcimg
->
getColorFormat
(),
irr
::
core
::
dimension2d
<
u32
>
(
width
,
height
));
imageScaleNNAA
(
srcimg
,
destimg
);
texture
=
driver
->
addTexture
(
fil
e
,
destimg
);
texture
=
driver
->
addTexture
(
nam
e
,
destimg
);
destimg
->
drop
();
}
srcimg
->
drop
();
return
texture
;
}
else
{
return
driver
->
getTexture
(
fil
e
);
return
driver
->
getTexture
(
nam
e
);
}
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureUnknown
(
s32
width
,
s32
height
,
int
index
)
{
...
...
@@ -295,6 +302,29 @@ irr::video::ITexture* ImageManager::GetTextureUnknown(s32 width, s32 height, int
tUnknown
[
index
]
=
GetTextureFromFile
(
"textures/unknown.jpg"
,
width
,
height
);
return
tUnknown
[
index
];
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureExpansions
(
char
*
file
,
s32
width
,
s32
height
)
{
irr
::
video
::
ITexture
*
img
=
GetTextureExpansionsDirectry
(
"./expansions"
,
file
,
width
,
height
);
if
(
img
!=
NULL
)
return
img
;
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
this
,
file
,
width
,
height
,
&
img
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
img
=
GetTextureExpansionsDirectry
(
subdir
,
file
,
width
,
height
);
if
(
img
)
find
=
true
;
}
});
if
(
find
)
return
img
;
return
img
;
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureExpansionsDirectry
(
const
char
*
path
,
char
*
file
,
s32
width
,
s32
height
)
{
char
fpath
[
1000
];
sprintf
(
fpath
,
"%s/%s"
,
path
,
file
);
return
GetTextureFromFile
(
fpath
,
width
,
height
);
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTexture
(
int
code
,
bool
fit
)
{
int
width
=
CARD_IMG_WIDTH
;
int
height
=
CARD_IMG_HEIGHT
;
...
...
@@ -310,11 +340,11 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
auto
tit
=
tMap
[
fit
?
1
:
0
].
find
(
code
);
if
(
tit
==
tMap
[
fit
?
1
:
0
].
end
())
{
char
file
[
256
];
sprintf
(
file
,
"
expansions/
pics/%d.png"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTexture
FromFile
(
file
,
width
,
height
);
sprintf
(
file
,
"pics/%d.png"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTexture
Expansions
(
file
,
width
,
height
);
if
(
img
==
NULL
)
{
sprintf
(
file
,
"
expansions/
pics/%d.jpg"
,
code
);
img
=
GetTexture
FromFile
(
file
,
width
,
height
);
sprintf
(
file
,
"pics/%d.jpg"
,
code
);
img
=
GetTexture
Expansions
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
mainGame
->
GetLocaleDir
(
"pics/%d.png"
),
code
);
...
...
@@ -352,11 +382,11 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
return
GetTextureUnknown
(
width
,
height
,
2
);
if
(
tit
==
tThumb
.
end
())
{
char
file
[
256
];
sprintf
(
file
,
"
expansions/
pics/thumbnail/%d.png"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTexture
FromFile
(
file
,
width
,
height
);
sprintf
(
file
,
"pics/thumbnail/%d.png"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTexture
Expansions
(
file
,
width
,
height
);
if
(
img
==
NULL
)
{
sprintf
(
file
,
"
expansions/
pics/thumbnail/%d.jpg"
,
code
);
img
=
GetTexture
FromFile
(
file
,
width
,
height
);
sprintf
(
file
,
"pics/thumbnail/%d.jpg"
,
code
);
img
=
GetTexture
Expansions
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
mainGame
->
GetLocaleDir
(
"pics/thumbnail/%d.png"
),
code
);
...
...
@@ -375,11 +405,11 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
&&
mainGame
->
gameConf
.
use_image_scale
)
{
sprintf
(
file
,
"
expansions/
pics/%d.png"
,
code
);
img
=
GetTexture
FromFile
(
file
,
width
,
height
);
sprintf
(
file
,
"pics/%d.png"
,
code
);
img
=
GetTexture
Expansions
(
file
,
width
,
height
);
if
(
img
==
NULL
)
{
sprintf
(
file
,
"
expansions/
pics/%d.jpg"
,
code
);
img
=
GetTexture
FromFile
(
file
,
width
,
height
);
sprintf
(
file
,
"pics/%d.jpg"
,
code
);
img
=
GetTexture
Expansions
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
mainGame
->
GetLocaleDir
(
"pics/%d.png"
),
code
);
...
...
@@ -412,11 +442,11 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
auto
tit
=
tFields
.
find
(
code
);
if
(
tit
==
tFields
.
end
())
{
char
file
[
256
];
sprintf
(
file
,
"
expansions/
pics/field/%d.png"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTexture
FromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
sprintf
(
file
,
"pics/field/%d.png"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTexture
Expansions
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
if
(
img
==
NULL
)
{
sprintf
(
file
,
"
expansions/
pics/field/%d.jpg"
,
code
);
img
=
GetTexture
FromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
sprintf
(
file
,
"pics/field/%d.jpg"
,
code
);
img
=
GetTexture
Expansions
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
"pics/field/%d.png"
,
code
);
...
...
gframe/image_manager.h
View file @
3f2970fa
...
...
@@ -23,6 +23,8 @@ public:
void
ResizeTexture
();
irr
::
video
::
ITexture
*
GetTextureFromFile
(
char
*
file
,
s32
width
,
s32
height
);
irr
::
video
::
ITexture
*
GetTextureUnknown
(
s32
width
,
s32
height
,
int
index
);
irr
::
video
::
ITexture
*
GetTextureExpansions
(
char
*
file
,
s32
width
,
s32
height
);
irr
::
video
::
ITexture
*
GetTextureExpansionsDirectry
(
const
char
*
path
,
char
*
file
,
s32
width
,
s32
height
);
irr
::
video
::
ITexture
*
GetTexture
(
int
code
,
bool
fit
=
false
);
irr
::
video
::
ITexture
*
GetTextureThumb
(
int
code
);
irr
::
video
::
ITexture
*
GetTextureField
(
int
code
);
...
...
gframe/replay_mode.cpp
View file @
3f2970fa
...
...
@@ -940,23 +940,34 @@ void ReplayMode::ReplayReload() {
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_REMOVED
,
(
char
*
)
queryBuffer
);
}
byte
*
ReplayMode
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
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
);
}
if
(
!
buffer
)
{
char
sname
[
256
]
=
"./beta"
;
strcat
(
sname
,
script_name
+
1
);
buffer
=
default_script_reader
(
sname
,
slen
);
}
byte
*
buffer
=
ScriptReaderExDirectry
(
"./specials"
,
script_name
,
slen
,
8
);
if
(
buffer
)
return
buffer
;
else
return
default_script_reader
(
script_name
,
slen
);
buffer
=
ScriptReaderExDirectry
(
"./expansions"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
buffer
=
ScriptReaderExDirectry
(
"./beta"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
script_name
,
slen
,
&
buffer
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
buffer
=
ScriptReaderExDirectry
(
subdir
,
script_name
,
slen
);
if
(
buffer
)
find
=
true
;
}
});
if
(
find
)
return
buffer
;
return
default_script_reader
(
script_name
,
slen
);
}
byte
*
ReplayMode
::
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
)
{
char
sname
[
256
];
strcpy
(
sname
,
path
);
strcat
(
sname
,
script_name
+
pre_len
);
//default script name: ./script/c%d.lua
return
default_script_reader
(
sname
,
slen
);
}
int
ReplayMode
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
...
...
gframe/replay_mode.h
View file @
3f2970fa
...
...
@@ -25,7 +25,7 @@ private:
public:
static
Replay
cur_replay
;
public:
static
bool
StartReplay
(
int
skipturn
);
static
void
StopReplay
(
bool
is_exiting
=
false
);
...
...
@@ -38,7 +38,7 @@ public:
static
void
Restart
(
bool
refresh
);
static
void
Undo
();
static
bool
ReplayAnalyze
(
char
*
msg
,
unsigned
int
len
);
static
void
ReplayRefresh
(
int
flag
=
0xf81fff
);
static
void
ReplayRefreshHand
(
int
player
,
int
flag
=
0x781fff
);
static
void
ReplayRefreshGrave
(
int
player
,
int
flag
=
0x181fff
);
...
...
@@ -48,6 +48,7 @@ public:
static
void
ReplayReload
();
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
byte
*
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
=
1
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
};
...
...
gframe/single_duel.cpp
View file @
3f2970fa
...
...
@@ -2123,23 +2123,34 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
}
}
byte
*
SingleDuel
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
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
);
}
if
(
!
buffer
)
{
char
sname
[
256
]
=
"./beta"
;
strcat
(
sname
,
script_name
+
1
);
buffer
=
default_script_reader
(
sname
,
slen
);
}
byte
*
buffer
=
ScriptReaderExDirectry
(
"./specials"
,
script_name
,
slen
,
8
);
if
(
buffer
)
return
buffer
;
else
return
default_script_reader
(
script_name
,
slen
);
buffer
=
ScriptReaderExDirectry
(
"./expansions"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
buffer
=
ScriptReaderExDirectry
(
"./beta"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
script_name
,
slen
,
&
buffer
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
buffer
=
ScriptReaderExDirectry
(
subdir
,
script_name
,
slen
);
if
(
buffer
)
find
=
true
;
}
});
if
(
find
)
return
buffer
;
return
default_script_reader
(
script_name
,
slen
);
}
byte
*
SingleDuel
::
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
)
{
char
sname
[
256
];
strcpy
(
sname
,
path
);
strcat
(
sname
,
script_name
+
pre_len
);
//default script name: ./script/c%d.lua
return
default_script_reader
(
sname
,
slen
);
}
int
SingleDuel
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
...
...
gframe/single_duel.h
View file @
3f2970fa
...
...
@@ -34,7 +34,7 @@ public:
#ifdef YGOPRO_SERVER_MODE
virtual
void
TestCard
(
int
code
);
#endif
void
DuelEndProc
();
void
WaitforResponse
(
int
playerid
);
#ifdef YGOPRO_SERVER_MODE
...
...
@@ -54,10 +54,10 @@ public:
void
RefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
byte
*
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
=
1
);
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
];
...
...
@@ -87,4 +87,3 @@ protected:
}
#endif //SINGLE_DUEL_H
gframe/single_mode.cpp
View file @
3f2970fa
...
...
@@ -860,23 +860,33 @@ void SingleMode::SinglePlayReload() {
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_REMOVED
,
(
char
*
)
queryBuffer
);
}
byte
*
SingleMode
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
char
sname
[
256
]
=
"./specials"
;
strcat
(
sname
,
script_name
+
8
);
//default script name: ./script/c%d.lua
byte
*
buffer
=
ScriptReader
(
sname
,
slen
);
if
(
!
buffer
)
{
char
sname
[
256
]
=
"./expansions"
;
strcat
(
sname
,
script_name
+
1
);
buffer
=
ScriptReader
(
sname
,
slen
);
}
if
(
!
buffer
)
{
char
sname
[
256
]
=
"./beta"
;
strcat
(
sname
,
script_name
+
1
);
buffer
=
ScriptReader
(
sname
,
slen
);
}
byte
*
buffer
=
ScriptReaderExDirectry
(
"./specials"
,
script_name
,
slen
,
8
);
if
(
buffer
)
return
buffer
;
buffer
=
ScriptReaderExDirectry
(
"./expansions"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
else
return
ScriptReader
(
script_name
,
slen
);
buffer
=
ScriptReaderExDirectry
(
"./beta"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
script_name
,
slen
,
&
buffer
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
buffer
=
ScriptReaderExDirectry
(
subdir
,
script_name
,
slen
);
if
(
buffer
)
find
=
true
;
}
});
if
(
find
)
return
buffer
;
return
ScriptReader
(
script_name
,
slen
);
}
byte
*
SingleMode
::
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
)
{
char
sname
[
256
];
sprintf
(
sname
,
"%s%s"
,
path
,
script_name
+
pre_len
);
//default script name: ./script/c%d.lua
return
ScriptReader
(
sname
,
slen
);
}
byte
*
SingleMode
::
ScriptReader
(
const
char
*
script_name
,
int
*
slen
)
{
FILE
*
fp
;
...
...
gframe/single_mode.h
View file @
3f2970fa
...
...
@@ -17,7 +17,7 @@ public:
static
void
SetResponse
(
unsigned
char
*
resp
,
unsigned
int
len
);
static
int
SinglePlayThread
(
void
*
param
);
static
bool
SinglePlayAnalyze
(
char
*
msg
,
unsigned
int
len
);
static
void
SinglePlayRefresh
(
int
flag
=
0xf81fff
);
static
void
SinglePlayRefreshHand
(
int
player
,
int
flag
=
0x781fff
);
static
void
SinglePlayRefreshGrave
(
int
player
,
int
flag
=
0x181fff
);
...
...
@@ -27,6 +27,7 @@ public:
static
void
SinglePlayReload
();
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
byte
*
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
=
1
);
static
byte
*
ScriptReader
(
const
char
*
script_name
,
int
*
slen
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
...
...
gframe/tag_duel.cpp
View file @
3f2970fa
...
...
@@ -2281,24 +2281,36 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
}
}
}
byte
*
TagDuel
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
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
);
}
if
(
!
buffer
)
{
char
sname
[
256
]
=
"./beta"
;
strcat
(
sname
,
script_name
+
1
);
buffer
=
default_script_reader
(
sname
,
slen
);
}
byte
*
buffer
=
ScriptReaderExDirectry
(
"./specials"
,
script_name
,
slen
,
8
);
if
(
buffer
)
return
buffer
;
else
return
default_script_reader
(
script_name
,
slen
);
buffer
=
ScriptReaderExDirectry
(
"./expansions"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
buffer
=
ScriptReaderExDirectry
(
"./beta"
,
script_name
,
slen
);
if
(
buffer
)
return
buffer
;
bool
find
=
false
;
FileSystem
::
TraversalDir
(
"./expansions"
,
[
script_name
,
slen
,
&
buffer
,
&
find
](
const
char
*
name
,
bool
isdir
)
{
if
(
!
find
&&
isdir
&&
strcmp
(
name
,
"."
)
&&
strcmp
(
name
,
".."
))
{
char
subdir
[
1024
];
sprintf
(
subdir
,
"./expansions/%s"
,
name
);
buffer
=
ScriptReaderExDirectry
(
subdir
,
script_name
,
slen
);
if
(
buffer
)
find
=
true
;
}
});
if
(
find
)
return
buffer
;
return
default_script_reader
(
script_name
,
slen
);
}
byte
*
TagDuel
::
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
)
{
char
sname
[
256
];
strcpy
(
sname
,
path
);
strcat
(
sname
,
script_name
+
pre_len
);
//default script name: ./script/c%d.lua
return
default_script_reader
(
sname
,
slen
);
}
int
TagDuel
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
...
...
gframe/tag_duel.h
View file @
3f2970fa
...
...
@@ -31,7 +31,7 @@ public:
virtual
void
RequestField
(
DuelPlayer
*
dp
);
#endif
virtual
void
EndDuel
();
void
DuelEndProc
();
void
WaitforResponse
(
int
playerid
);
#ifdef YGOPRO_SERVER_MODE
...
...
@@ -51,9 +51,10 @@ public:
void
RefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
byte
*
ScriptReaderExDirectry
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
=
1
);
static
int
MessageHandler
(
long
fduel
,
int
type
);
static
void
TagTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
protected:
DuelPlayer
*
players
[
4
];
DuelPlayer
*
pplayer
[
4
];
...
...
@@ -80,4 +81,3 @@ protected:
}
#endif //TAG_DUEL_H
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