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
aa6eddab
Commit
aa6eddab
authored
Sep 24, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'server' of git.mycard.moe:mycard/ygopro into server
parents
833c3e69
71a8c155
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
145 additions
and
25 deletions
+145
-25
.ci/upload-packager.sh
.ci/upload-packager.sh
+4
-0
.gitlab-ci.yml
.gitlab-ci.yml
+5
-4
appveyor.yml
appveyor.yml
+7
-4
gframe/config.h
gframe/config.h
+6
-0
gframe/data_manager.cpp
gframe/data_manager.cpp
+8
-6
gframe/data_manager.h
gframe/data_manager.h
+4
-3
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+3
-0
gframe/game.cpp
gframe/game.cpp
+32
-4
gframe/netserver.cpp
gframe/netserver.cpp
+4
-0
gframe/premake5.lua
gframe/premake5.lua
+14
-1
premake/irrlicht/premake5-only-zipreader.lua
premake/irrlicht/premake5-only-zipreader.lua
+41
-0
premake5.lua
premake5.lua
+17
-3
No files found.
.ci/upload-packager.sh
View file @
aa6eddab
...
...
@@ -10,7 +10,11 @@ token=$(echo $loginInfo | jq '.token' | sed 's/"//g')
header
=
"Authorization:
$token
"
echo
"Login succeeded."
<<<<<<
< HEAD
appName
=
"koishipro"
=======
appName
=
"ygopro"
>>>>>>>
71a8c15521cc6fe09e774c7fa2a62aeb20a0e017
handleErrorMessage
()
{
rawJsonInput
=
"
$1
"
...
...
.gitlab-ci.yml
View file @
aa6eddab
...
...
@@ -49,13 +49,13 @@ mat_linux:
-
linux
script
:
-
apt update; apt -y install git wget tar
#
- git clone --depth=1 https://code.mycard.moe/mycard/irrlicht-new irrlicht
-
git clone --depth=1 https://code.mycard.moe/mycard/irrlicht-new irrlicht
-
wget -O - https://cdn01.moecube.com/ygopro-build-materials/premake-5.0.0-beta2-linux.tar.gz | tar zfx -
-
env PROCESSOR_COUNT=$(nproc) ./.ci/libevent-prebuild.sh
artifacts
:
paths
:
-
premake5
#
- irrlicht
-
irrlicht
-
libevent-stable
mat_windows
:
...
...
@@ -71,11 +71,12 @@ mat_windows:
-
wget -O - https://cdn01.moecube.com/ygopro-build-materials/libevent-2.0.22-stable.tar.gz | tar zfx -
-
mv libevent-2.0.22-stable event
# irrlicht
#
- git clone --depth=1 https://code.mycard.moe/mycard/irrlicht-new irrlicht
-
git clone --depth=1 https://code.mycard.moe/mycard/irrlicht-new irrlicht
artifacts
:
paths
:
-
premake5.exe
-
event
-
irrlicht
._exec_build
:
stage
:
build
...
...
@@ -114,7 +115,7 @@ exec_linux:
-
mat_submodules
script
:
-
apt update; apt -y install git build-essential
-
./premake5 gmake --build-sqlite
-
./premake5 gmake --build-sqlite
--server-zip-support
-
cd build
-
make config=release -j$(nproc)
-
cd ..
...
...
appveyor.yml
View file @
aa6eddab
version
:
'
{build}'
image
:
Visual Studio
2019
environment
:
matrix
:
-
SERVER_MODE
:
true
-
SERVER_PRO2_SUPPORT
:
true
skip_tags
:
true
...
...
@@ -22,11 +26,9 @@ install:
-
bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://www.sqlite.org/2022/sqlite-amalgamation-3390300.zip ; exit 0"
-
7z x -y sqlite-amalgamation-3390300.zip
-
move sqlite-amalgamation-3390300 sqlite3
# let premake happy
before_build
:
-
xcopy /E premake\* .
# premake
-
premake5 vs2019
configuration
:
Release
...
...
@@ -91,5 +93,6 @@ deploy:
cache
:
-
premake-5.0.0-beta2-windows.zip
-
libevent-2.0.22-stable.tar.gz
-
irrlicht-1.8.5.zip
-
lua-5.4.4.tar.gz
-
sqlite-amalgamation-3390300.zip
gframe/config.h
View file @
aa6eddab
...
...
@@ -91,6 +91,12 @@ using namespace io;
using
namespace
gui
;
#endif //YGOPRO_SERVER_MODE
#ifdef SERVER_ZIP_SUPPORT
#include <irrlicht.h>
using
namespace
irr
;
using
namespace
io
;
#endif
extern
unsigned
short
PRO_VERSION
;
extern
int
enable_log
;
extern
bool
exit_on_return
;
...
...
gframe/data_manager.cpp
View file @
aa6eddab
...
...
@@ -6,7 +6,7 @@ namespace ygo {
const
wchar_t
*
DataManager
::
unknown_string
=
L"???"
;
byte
DataManager
::
scriptBuffer
[
0x20000
];
#if
ndef YGOPRO_SERVER_MODE
#if
!defined(YGOPRO_SERVER_MODE) || defined(SERVER_ZIP_SUPPORT)
IFileSystem
*
DataManager
::
FileSystem
;
#endif
DataManager
dataManager
;
...
...
@@ -14,7 +14,7 @@ DataManager dataManager;
bool
DataManager
::
LoadDB
(
const
wchar_t
*
wfile
)
{
char
file
[
256
];
BufferIO
::
EncodeUTF8
(
wfile
,
file
);
#if
def YGOPRO_SERVER_MODE
#if
defined(YGOPRO_SERVER_MODE) && !defined(SERVER_ZIP_SUPPORT)
sqlite3
*
pDB
;
if
(
sqlite3_open_v2
(
file
,
&
pDB
,
SQLITE_OPEN_READONLY
,
0
)
!=
SQLITE_OK
)
return
Error
(
pDB
);
...
...
@@ -45,19 +45,21 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
const
char
*
sql
=
"select * from datas,texts where datas.id=texts.id"
;
#endif
if
(
sqlite3_prepare_v2
(
pDB
,
sql
,
-
1
,
&
pStmt
,
0
)
!=
SQLITE_OK
)
#if
def YGOPRO_SERVER_MODE
#if
defined(YGOPRO_SERVER_MODE) && !defined(SERVER_ZIP_SUPPORT)
return
Error
(
pDB
);
#else
return
Error
(
&
db
);
#endif
CardDataC
cd
;
CardString
cs
;
#ifndef YGOPRO_SERVER_MODE
wchar_t
strBuffer
[
4096
];
#endif
int
step
=
0
;
do
{
step
=
sqlite3_step
(
pStmt
);
if
(
step
==
SQLITE_BUSY
||
step
==
SQLITE_ERROR
||
step
==
SQLITE_MISUSE
)
#if
def YGOPRO_SERVER_MODE
#if
defined(YGOPRO_SERVER_MODE) && !defined(SERVER_ZIP_SUPPORT)
return
Error
(
pDB
,
pStmt
);
#else
return
Error
(
&
db
,
pStmt
);
...
...
@@ -166,7 +168,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
_setnameStrings
[
value
]
=
strBuffer
;
}
}
#if
def YGOPRO_SERVER_MODE
#if
defined(YGOPRO_SERVER_MODE) && !defined(SERVER_ZIP_SUPPORT)
bool
DataManager
::
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
)
{
wchar_t
strBuffer
[
4096
];
BufferIO
::
DecodeUTF8
(
sqlite3_errmsg
(
pDB
),
strBuffer
);
...
...
@@ -417,7 +419,7 @@ byte* DataManager::ScriptReaderExSingle(const char* path, const char* script_nam
return
ScriptReader
(
sname
,
slen
);
}
byte
*
DataManager
::
ScriptReader
(
const
char
*
script_name
,
int
*
slen
)
{
#if
def YGOPRO_SERVER_MODE
#if
defined(YGOPRO_SERVER_MODE) && !defined(SERVER_ZIP_SUPPORT)
FILE
*
fp
=
fopen
(
script_name
,
"rb"
);
if
(
!
fp
)
return
0
;
...
...
gframe/data_manager.h
View file @
aa6eddab
...
...
@@ -3,7 +3,7 @@
#include "config.h"
#include "sqlite3.h"
#if
ndef YGOPRO_SERVER_MODE
#if
!defined(YGOPRO_SERVER_MODE) || defined(SERVER_ZIP_SUPPORT)
#include "spmemvfs/spmemvfs.h"
#endif
#include "client_card.h"
...
...
@@ -18,10 +18,11 @@ public:
bool
LoadStrings
(
const
char
*
file
);
#ifndef YGOPRO_SERVER_MODE
bool
LoadStrings
(
IReadFile
*
reader
);
#endif
void
ReadStringConfLine
(
const
char
*
linebuf
);
#if !defined(YGOPRO_SERVER_MODE) || defined(SERVER_ZIP_SUPPORT)
bool
Error
(
spmemvfs_db_t
*
pDB
,
sqlite3_stmt
*
pStmt
=
0
);
#else
void
ReadStringConfLine
(
const
char
*
linebuf
);
bool
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
=
0
);
#endif //YGOPRO_SERVER_MODE
bool
GetData
(
int
code
,
CardData
*
pData
);
...
...
@@ -64,7 +65,7 @@ public:
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
byte
*
ScriptReaderExSingle
(
const
char
*
path
,
const
char
*
script_name
,
int
*
slen
,
int
pre_len
=
2
);
static
byte
*
ScriptReader
(
const
char
*
script_name
,
int
*
slen
);
#if
ndef YGOPRO_SERVER_MODE
#if
!defined(YGOPRO_SERVER_MODE) || defined(SERVER_ZIP_SUPPORT)
static
IFileSystem
*
FileSystem
;
#endif
};
...
...
gframe/deck_manager.cpp
View file @
aa6eddab
...
...
@@ -52,6 +52,9 @@ void DeckManager::LoadLFListSingle(const char* path) {
}
}
void
DeckManager
::
LoadLFList
()
{
#ifdef SERVER_PRO2_SUPPORT
LoadLFListSingle
(
"config/lflist.conf"
);
#endif
LoadLFListSingle
(
"expansions/lflist.conf"
);
LoadLFListSingle
(
"lflist.conf"
);
LFList
nolimit
;
...
...
gframe/game.cpp
View file @
aa6eddab
...
...
@@ -4,6 +4,15 @@
#include "data_manager.h"
#include "deck_manager.h"
#include "replay.h"
#ifdef SERVER_ZIP_SUPPORT
#include "CFileSystem.h"
namespace
irr
{
namespace
core
{
// taken from Irrlicht.cpp beacuse that file is not included
irr
::
core
::
stringc
LOCALE_DECIMAL_POINTS
(
"."
);
}
}
#endif
#else
#include "image_manager.h"
#include "data_manager.h"
...
...
@@ -31,6 +40,12 @@ unsigned int pre_seed[3];
HostInfo
game_info
;
void
Game
::
MainServerLoop
()
{
#ifdef SERVER_ZIP_SUPPORT
dataManager
.
FileSystem
=
new
irr
::
io
::
CFileSystem
();
#endif
#ifdef SERVER_PRO2_SUPPORT
dataManager
.
FileSystem
->
addFileArchive
(
"data/script.zip"
);
#endif
initUtils
();
deckManager
.
LoadLFList
();
dataManager
.
LoadDB
(
L"cards.cdb"
);
...
...
@@ -1206,20 +1221,29 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth,
}
#endif //YGOPRO_SERVER_MODE
void
Game
::
LoadExpansions
()
{
#ifdef SERVER_PRO2_SUPPORT
FileSystem
::
TraversalDir
(
L"./cdb"
,
[](
const
wchar_t
*
name
,
bool
isdir
)
{
wchar_t
fpath
[
1024
];
myswprintf
(
fpath
,
L"./cdb/%ls"
,
name
);
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".cdb"
,
4
))
{
dataManager
.
LoadDB
(
fpath
);
}
});
#endif // SERVER_PRO2_SUPPORT
FileSystem
::
TraversalDir
(
L"./expansions"
,
[](
const
wchar_t
*
name
,
bool
isdir
)
{
wchar_t
fpath
[
1024
];
myswprintf
(
fpath
,
L"./expansions/%ls"
,
name
);
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".cdb"
,
4
))
{
dataManager
.
LoadDB
(
fpath
);
}
#ifdef YGOPRO_SERVER_MODE
});
#else
#ifndef YGOPRO_SERVER_MODE
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".conf"
,
5
))
{
char
upath
[
1024
];
BufferIO
::
EncodeUTF8
(
fpath
,
upath
);
dataManager
.
LoadStrings
(
upath
);
}
#endif // YGOPRO_SERVER_MODE
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
(
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".zip"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ypk"
,
4
)))
{
#ifdef _WIN32
dataManager
.
FileSystem
->
addFileArchive
(
fpath
,
true
,
false
,
EFAT_ZIP
);
...
...
@@ -1229,7 +1253,9 @@ void Game::LoadExpansions() {
dataManager
.
FileSystem
->
addFileArchive
(
upath
,
true
,
false
,
EFAT_ZIP
);
#endif
}
#endif //SERVER_ZIP_SUPPORT
});
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
for
(
u32
i
=
0
;
i
<
DataManager
::
FileSystem
->
getFileArchiveCount
();
++
i
)
{
const
IFileList
*
archive
=
DataManager
::
FileSystem
->
getFileArchive
(
i
)
->
getFileList
();
for
(
u32
j
=
0
;
j
<
archive
->
getFileCount
();
++
j
)
{
...
...
@@ -1242,6 +1268,7 @@ void Game::LoadExpansions() {
#endif
if
(
wcsrchr
(
fname
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
fname
,
'.'
),
L".cdb"
,
4
))
dataManager
.
LoadDB
(
fname
);
#ifndef YGOPRO_SERVER_MODE
if
(
wcsrchr
(
fname
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
fname
,
'.'
),
L".conf"
,
5
))
{
#ifdef _WIN32
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
fname
);
...
...
@@ -1253,9 +1280,10 @@ void Game::LoadExpansions() {
if
(
wcsrchr
(
fname
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
fname
,
'.'
),
L".ydk"
,
4
))
{
deckBuilder
.
expansionPacks
.
push_back
(
fname
);
}
#endif // YGOPRO_SERVER_MODE
}
}
#endif //
YGOPRO_SERVER_MODE
#endif //
SERVER_ZIP_SUPPORT
}
#ifndef YGOPRO_SERVER_MODE
void
Game
::
RefreshCategoryDeck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
,
bool
selectlastused
)
{
...
...
gframe/netserver.cpp
View file @
aa6eddab
...
...
@@ -93,7 +93,11 @@ bool NetServer::StartServer(unsigned short port) {
memset
(
&
sin
,
0
,
sizeof
(
sin
));
server_port
=
port
;
sin
.
sin_family
=
AF_INET
;
#ifdef SERVER_PRO2_SUPPORT
sin
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
#else
sin
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
#endif
sin
.
sin_port
=
htons
(
port
);
listener
=
evconnlistener_new_bind
(
net_evbase
,
ServerAccept
,
NULL
,
LEV_OPT_CLOSE_ON_FREE
|
LEV_OPT_REUSEABLE
,
-
1
,
(
sockaddr
*
)
&
sin
,
sizeof
(
sin
));
...
...
gframe/premake5.lua
View file @
aa6eddab
include
"lzma/."
if
not
SERVER_MODE
then
if
(
SERVER_ZIP_SUPPORT
or
not
SERVER_MODE
)
then
include
"spmemvfs/."
end
...
...
@@ -19,6 +19,16 @@ if SERVER_MODE then
"tag_duel.cpp"
,
"tag_duel.h"
}
includedirs
{
"../ocgcore"
}
links
{
"ocgcore"
,
"clzma"
,
LUA_LIB_NAME
,
"sqlite3"
,
"event"
}
if
SERVER_ZIP_SUPPORT
then
defines
{
"SERVER_ZIP_SUPPORT"
}
links
{
"irrlicht"
,
"cspmemvfs"
}
if
BUILD_IRRLICHT
then
includedirs
{
"../irrlicht/source/Irrlicht"
}
end
end
if
SERVER_PRO2_SUPPORT
then
defines
{
"SERVER_PRO2_SUPPORT"
}
end
else
kind
"WindowedApp"
...
...
@@ -75,6 +85,9 @@ end
files
"ygopro.rc"
if
not
SERVER_MODE
then
libdirs
{
"$(DXSDK_DIR)Lib/x86"
}
end
if
SERVER_PRO2_SUPPORT
then
targetname
(
"AI.Server"
)
end
if
USE_IRRKLANG
then
links
{
"irrKlang"
}
...
...
premake/irrlicht/premake5-only-zipreader.lua
0 → 100644
View file @
aa6eddab
project
"irrlicht"
kind
"StaticLib"
includedirs
{
"include"
,
"source/Irrlicht"
,
"source/Irrlicht/zlib"
}
defines
{
"_IRR_STATIC_LIB_"
,
"NO_IRR_COMPILE_WITH_ZIP_ENCRYPTION_"
,
"NO_IRR_COMPILE_WITH_BZIP2_"
,
"NO__IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_"
,
"NO__IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_"
,
"NO__IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_"
,
"NO__IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_"
,
"NO__IRR_COMPILE_WITH_WAD_ARCHIVE_LOADER_"
}
exceptionhandling
"Off"
rtti
"Off"
files
{
"source/Irrlicht/os.cpp"
,
"source/Irrlicht/zlib/adler32.c"
,
"source/Irrlicht/zlib/crc32.c"
,
"source/Irrlicht/zlib/inffast.c"
,
"source/Irrlicht/zlib/inflate.c"
,
"source/Irrlicht/zlib/inftrees.c"
,
"source/Irrlicht/zlib/zutil.c"
,
"source/Irrlicht/CAttributes.cpp"
,
"source/Irrlicht/CFileList.cpp"
,
"source/Irrlicht/CFileSystem.cpp"
,
"source/Irrlicht/CLimitReadFile.cpp"
,
"source/Irrlicht/CMemoryFile.cpp"
,
"source/Irrlicht/CReadFile.cpp"
,
"source/Irrlicht/CWriteFile.cpp"
,
"source/Irrlicht/CXMLReader.cpp"
,
"source/Irrlicht/CXMLWriter.cpp"
,
"source/Irrlicht/CZipReader.cpp"
}
filter
{
"system:windows"
}
defines
{
"_IRR_WCHAR_FILESYSTEM"
}
premake5.lua
View file @
aa6eddab
...
...
@@ -10,6 +10,8 @@ IRRKLANG_PRO = false
LUA_LIB_NAME
=
"lua"
SERVER_MODE
=
true
SERVER_ZIP_SUPPORT
=
false
SERVER_PRO2_SUPPORT
=
false
USE_IRRKLANG
=
false
-- read settings from command line or environment variables
...
...
@@ -54,7 +56,10 @@ newoption { trigger = 'build-ikpmp3', category = "YGOPro - irrklang - ikpmp3", d
newoption
{
trigger
=
"winxp-support"
,
category
=
"YGOPro"
,
description
=
""
}
newoption
{
trigger
=
"mac-arm"
,
category
=
"YGOPro"
,
description
=
"M1"
}
newoption
{
trigger
=
"server-mode"
,
category
=
"YGOPro"
,
description
=
""
}
newoption
{
trigger
=
"server-mode"
,
category
=
"YGOPro - server"
,
description
=
""
}
newoption
{
trigger
=
"server-zip-support"
,
category
=
"YGOPro - server"
,
description
=
""
}
newoption
{
trigger
=
"server-pro2-support"
,
category
=
"YGOPro - server"
,
description
=
""
}
-- koishipro specific
...
...
@@ -208,6 +213,14 @@ if os.istarget("macosx") then
end
if
GetParam
(
"server-mode"
)
then
SERVER_MODE
=
true
SERVER_ZIP_SUPPORT
=
false
end
if
GetParam
(
"server-zip-support"
)
then
SERVER_ZIP_SUPPORT
=
true
end
if
GetParam
(
"server-pro2-support"
)
then
SERVER_PRO2_SUPPORT
=
true
SERVER_ZIP_SUPPORT
=
true
end
if
SERVER_MODE
then
...
...
@@ -235,9 +248,7 @@ workspace "YGOPro"
filter
"system:windows"
defines
{
"WIN32"
,
"_WIN32"
}
if
not
SERVER_MODE
then
entrypoint
"mainCRTStartup"
end
systemversion
"latest"
startproject
"YGOPro"
if
WINXP_SUPPORT
then
...
...
@@ -308,6 +319,9 @@ end
if
BUILD_IRRLICHT
and
not
SERVER_MODE
then
include
"irrlicht"
end
if
BUILD_IRRLICHT
and
SERVER_MODE
and
SERVER_ZIP_SUPPORT
then
include
"irrlicht/premake5-only-zipreader.lua"
end
if
BUILD_SQLITE
then
include
"sqlite3"
end
...
...
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