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
nanahira
ygopro
Commits
09ded696
Commit
09ded696
authored
Dec 12, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge
parent
c6c9201d
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
548 additions
and
87 deletions
+548
-87
.gitignore
.gitignore
+10
-0
.gitmodules
.gitmodules
+2
-2
README.md
README.md
+7
-4
appveyor.yml
appveyor.yml
+39
-0
cards.cdb
cards.cdb
+0
-0
gframe/game.cpp
gframe/game.cpp
+8
-0
gframe/game.h
gframe/game.h
+4
-3
gframe/gframe.cpp
gframe/gframe.cpp
+4
-1
gframe/network.h
gframe/network.h
+1
-0
gframe/premake4.lua
gframe/premake4.lua
+5
-2
gframe/replay.cpp
gframe/replay.cpp
+66
-45
gframe/single_duel.cpp
gframe/single_duel.cpp
+173
-14
gframe/single_duel.h
gframe/single_duel.h
+1
-0
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+160
-14
gframe/tag_duel.h
gframe/tag_duel.h
+1
-0
ocgcore
ocgcore
+1
-1
premake5.lua
premake5.lua
+65
-0
script
script
+1
-1
No files found.
.gitignore
View file @
09ded696
/expansions
/specials
/obj
/bin
/build
/event
/lua
/sqlite3
/replay
/deck
/.vscode
/gframe/ygopro.ico
/gframe/ygopro.rc
/gframe/ygopro.aps
/gframe/dirent.h
ygopro
premake5.exe
.gitmodules
View file @
09ded696
[submodule "ocgcore"]
path = ocgcore
url = https://github.com/
Fluorohydride/ygopro-core.git
url = https://github.com/
mycard/ygopro-core
[submodule "script"]
path = script
url = https://github.com/
Fluorohydride/ygopro-scripts.git
url = https://github.com/
mycard/ygopro-scripts
README.md
View file @
09ded696
## ygopro(server)
一个linux版的ygopro服务端。
一个linux版的ygopro服务端,基于mycard代码修改。
现用于
[
YGOPRO 233服
](
http://mercury233.me/ygosrv233/
)
。
###编译
*
需要以下组件
*
需要以下组件或工具
*
gcc
*
premake4
*
libevent
*
sqlite3
*
lua5.2
*
gcc
*
可参考 https://github.com/mercury233/ygopro-server/wiki 中的脚本
###运行
*
使用
[
ygopro-server-lite
](
https://github.com/mercury233/ygopro-server
)
运行
*
手动运行的参数是
*
./ygopro 0 0 0 1 F F F 8000 5 1 180
*
./ygopro 0 0 0 1 F F F 8000 5 1 180
0
*
端口(0为随机)
*
禁卡表编号
*
卡片允许
...
...
@@ -25,3 +27,4 @@
*
初始手牌数
*
每回合抽卡
*
每回合时间
*
录像保存模式
appveyor.yml
0 → 100644
View file @
09ded696
version
:
'
{build}'
install
:
-
git submodule update --init --recursive
# environment and system dependency
-
appveyor DownloadFile https://github.com/premake/premake-core/releases/download/v5.0.0-alpha10/premake-5.0.0-alpha10-windows.zip
-
7z x premake-5.0.0-alpha10-windows.zip
-
appveyor DownloadFile https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
-
tar xf libevent-2.0.22-stable.tar.gz
-
move libevent-2.0.22-stable event
-
xcopy /E event\WIN32-Code event\include
-
appveyor DownloadFile https://www.lua.org/ftp/lua-5.2.4.tar.gz
-
tar xf lua-5.2.4.tar.gz
-
move lua-5.2.4\src lua
-
appveyor DownloadFile https://www.sqlite.org/2016/sqlite-amalgamation-3150200.zip
-
7z x sqlite-amalgamation-3150200.zip
-
move sqlite-amalgamation-3150200 sqlite3
-
appveyor DownloadFile https://github.com/tronkko/dirent/raw/master/include/dirent.h
-
move dirent.h gframe\
# let premake happy
-
xcopy /E premake\* .
# premake
-
premake5 vs2015
configuration
:
Release
build
:
project
:
build/ygo.sln
parallel
:
true
after_build
:
-
ps
:
move bin\release\ygopro.exe .
artifacts
:
-
path
:
ygopro.exe
name
:
ygopro(server)
cards.cdb
View file @
09ded696
No preview for this file type
gframe/game.cpp
View file @
09ded696
...
...
@@ -9,6 +9,11 @@
#include "netserver.h"
//#include "single_mode.h"
#ifdef _WIN32
#define strcasecmp _stricmp
#include "dirent.h"
#endif // _WIN32
#ifndef _WIN32
#include <sys/types.h>
#include <dirent.h>
...
...
@@ -30,6 +35,7 @@ bool no_check_deck;
bool
no_shuffle_deck
;
unsigned
int
start_lp
;
unsigned
short
time_limit
;
unsigned
short
replay_mode
;
unsigned
char
start_hand
;
unsigned
char
draw_count
;
...
...
@@ -1204,6 +1210,7 @@ int Game::LocalPlayer(int player) {
const
wchar_t
*
Game
::
LocalName
(
int
local_player
)
{
return
local_player
==
0
?
dInfo
.
hostname
:
dInfo
.
clientname
;
}
/*
void Game::SetWindowsIcon() {
#ifdef _WIN32
HINSTANCE hInstance = (HINSTANCE)GetModuleHandleW(NULL);
...
...
@@ -1224,5 +1231,6 @@ void Game::FlashWindow() {
FlashWindowEx(&fi);
#endif
}
*/
}
gframe/game.h
View file @
09ded696
...
...
@@ -116,10 +116,10 @@ public:
//irr::gui::IGUIElement* focus = env->getFocus();
return focus && focus->hasType(type);
}
void SetWindowsIcon();
void SetWindowsIcon();
void FlashWindow();
*/
*/
Mutex
gMutex
;
Mutex
gBuffer
;
...
...
@@ -423,6 +423,7 @@ 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
;
...
...
gframe/gframe.cpp
View file @
09ded696
...
...
@@ -3,7 +3,7 @@
#include "data_manager.h"
#include <event2/thread.h>
int
enable_log
=
0
;
int
enable_log
=
1
;
bool
exit_on_return
=
false
;
bool
runasserver
=
true
;
...
...
@@ -23,6 +23,7 @@ int main(int argc, char* argv[]) {
ygo
::
aServerPort
=
atoi
(
argv
[
1
]);
ygo
::
lflist
=
atoi
(
argv
[
2
]);
ygo
::
start_hand
=
0
;
ygo
::
replay_mode
=
0
;
if
(
argc
>
2
)
{
ygo
::
rule
=
atoi
(
argv
[
3
]);
ygo
::
mode
=
atoi
(
argv
[
4
]);
...
...
@@ -42,6 +43,8 @@ int main(int argc, char* argv[]) {
ygo
::
start_hand
=
atoi
(
argv
[
9
]);
ygo
::
draw_count
=
atoi
(
argv
[
10
]);
ygo
::
time_limit
=
atoi
(
argv
[
11
]);
if
(
argc
>
12
)
ygo
::
replay_mode
=
atoi
(
argv
[
12
]);
}
ygo
::
mainGame
=
&
_game
;
ygo
::
mainGame
->
MainServerLoop
(
ygo
::
mode
,
ygo
::
lflist
);
...
...
gframe/network.h
View file @
09ded696
...
...
@@ -22,6 +22,7 @@ struct HostInfo {
unsigned
char
start_hand
;
unsigned
char
draw_count
;
unsigned
short
time_limit
;
unsigned
short
replay_mode
;
};
struct
HostPacket
{
unsigned
short
identifier
;
...
...
gframe/premake4.lua
View file @
09ded696
...
...
@@ -12,13 +12,16 @@ project "ygopro"
"single_duel.cpp"
,
"single_duel.h"
,
"tag_duel.cpp"
,
"tag_duel.h"
,
"**.cc"
,
"**.c"
}
excludes
"lzma/**"
includedirs
{
"../ocgcore"
}
links
{
"ocgcore"
,
"clzma"
,
"sqlite3"
,
"lua"
,
"event"
}
configuration
"windows"
files
"ygopro.rc"
includedirs
{
"../event/include"
,
"../sqlite3"
}
links
{
"ws2_32"
}
configuration
"not vs*"
buildoptions
{
"-std=gnu++0x"
,
"-fno-rtti"
}
configuration
"not windows"
includedirs
{
"/usr/include/lua"
,
"/usr/include/lua5.2"
,
"/usr/include/lua/5.2"
}
excludes
{
"COSOperator.*"
}
links
{
"event_pthreads"
,
"dl"
,
"pthread"
}
gframe/replay.cpp
View file @
09ded696
...
...
@@ -8,6 +8,7 @@
namespace
ygo
{
extern
unsigned
short
aServerPort
;
extern
unsigned
short
replay_mode
;
Replay
::
Replay
()
{
is_recording
=
false
;
...
...
@@ -42,115 +43,135 @@ std::wstring SA2W(std::string& strA)
void
Replay
::
BeginRecord
()
{
if
(
ygo
::
replay_mode
>
0
)
{
#ifdef _WIN32
if
(
is_recording
)
CloseHandle
(
recording_fp
);
std
::
stringstream
ss
;
ss
<<
ygo
::
aServerPort
;
std
::
string
ssss
;
ssss
=
ss
.
str
();
if
(
is_recording
)
CloseHandle
(
recording_fp
);
std
::
stringstream
ss
;
ss
<<
ygo
::
aServerPort
;
std
::
string
ssss
;
ssss
=
ss
.
str
();
std
::
wstring
comPrefix
=
L"./replay/"
;
std
::
wstring
comPrefix
=
L"./replay/"
;
std
::
wstring
comID
=
comPrefix
+
SA2W
(
ssss
)
+
L"Replay.yrp"
;
std
::
wstring
comID
=
comPrefix
+
SA2W
(
ssss
)
+
L"Replay.yrp"
;
recording_fp
=
CreateFileW
(
comID
.
c_str
(),
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_WRITE_THROUGH
,
NULL
);
if
(
recording_fp
==
INVALID_HANDLE_VALUE
)
return
;
recording_fp
=
CreateFileW
(
comID
.
c_str
(),
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_WRITE_THROUGH
,
NULL
);
if
(
recording_fp
==
INVALID_HANDLE_VALUE
)
return
;
#else
if
(
is_recording
)
fclose
(
fp
);
char
path
[
20
];
sprintf
(
path
,
"./replay/%u.yrp"
,
ygo
::
aServerPort
);
fp
=
fopen
(
path
,
"wb"
);
if
(
!
fp
)
return
;
if
(
is_recording
)
fclose
(
fp
);
time_t
nowtime
=
time
(
NULL
);
struct
tm
*
localedtime
=
localtime
(
&
nowtime
);
char
tmppath
[
40
];
strftime
(
tmppath
,
40
,
"./replay/%Y-%m-%d %H-%M-%S %%u.yrp"
,
localedtime
);
char
path
[
40
];
sprintf
(
path
,
tmppath
,
ygo
::
aServerPort
);
fp
=
fopen
(
path
,
"wb"
);
if
(
!
fp
)
return
;
#endif
}
pdata
=
replay_data
;
is_recording
=
true
;
}
void
Replay
::
WriteHeader
(
ReplayHeader
&
header
)
{
pheader
=
header
;
if
(
ygo
::
replay_mode
>
0
)
{
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
&
header
,
sizeof
(
header
),
&
size
,
NULL
);
DWORD
size
;
WriteFile
(
recording_fp
,
&
header
,
sizeof
(
header
),
&
size
,
NULL
);
#else
fwrite
(
&
header
,
sizeof
(
header
),
1
,
fp
);
fflush
(
fp
);
fwrite
(
&
header
,
sizeof
(
header
),
1
,
fp
);
fflush
(
fp
);
#endif
}
}
void
Replay
::
WriteData
(
const
void
*
data
,
unsigned
int
length
,
bool
flush
)
{
if
(
!
is_recording
)
return
;
memcpy
(
pdata
,
data
,
length
);
pdata
+=
length
;
if
(
ygo
::
replay_mode
>
0
)
{
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
data
,
length
,
&
size
,
NULL
);
DWORD
size
;
WriteFile
(
recording_fp
,
data
,
length
,
&
size
,
NULL
);
#else
fwrite
(
data
,
length
,
1
,
fp
);
if
(
flush
)
fflush
(
fp
);
fwrite
(
data
,
length
,
1
,
fp
);
if
(
flush
)
fflush
(
fp
);
#endif
}
}
void
Replay
::
WriteInt32
(
int
data
,
bool
flush
)
{
if
(
!
is_recording
)
return
;
*
((
int
*
)(
pdata
))
=
data
;
pdata
+=
4
;
if
(
ygo
::
replay_mode
>
0
)
{
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
int
),
&
size
,
NULL
);
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
int
),
&
size
,
NULL
);
#else
fwrite
(
&
data
,
sizeof
(
int
),
1
,
fp
);
if
(
flush
)
fflush
(
fp
);
fwrite
(
&
data
,
sizeof
(
int
),
1
,
fp
);
if
(
flush
)
fflush
(
fp
);
#endif
}
}
void
Replay
::
WriteInt16
(
short
data
,
bool
flush
)
{
if
(
!
is_recording
)
return
;
*
((
short
*
)(
pdata
))
=
data
;
pdata
+=
2
;
if
(
ygo
::
replay_mode
>
0
)
{
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
short
),
&
size
,
NULL
);
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
short
),
&
size
,
NULL
);
#else
fwrite
(
&
data
,
sizeof
(
short
),
1
,
fp
);
if
(
flush
)
fflush
(
fp
);
fwrite
(
&
data
,
sizeof
(
short
),
1
,
fp
);
if
(
flush
)
fflush
(
fp
);
#endif
}
}
void
Replay
::
WriteInt8
(
char
data
,
bool
flush
)
{
if
(
!
is_recording
)
return
;
*
pdata
=
data
;
pdata
++
;
if
(
ygo
::
replay_mode
>
0
)
{
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
char
),
&
size
,
NULL
);
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
char
),
&
size
,
NULL
);
#else
fwrite
(
&
data
,
sizeof
(
char
),
1
,
fp
);
if
(
flush
)
fflush
(
fp
);
fwrite
(
&
data
,
sizeof
(
char
),
1
,
fp
);
if
(
flush
)
fflush
(
fp
);
#endif
}
}
void
Replay
::
Flush
()
{
if
(
!
is_recording
)
return
;
if
(
ygo
::
replay_mode
>
0
)
{
#ifdef _WIN32
#else
fflush
(
fp
);
fflush
(
fp
);
#endif
}
}
void
Replay
::
EndRecord
()
{
if
(
!
is_recording
)
return
;
if
(
ygo
::
replay_mode
>
0
)
{
#ifdef _WIN32
CloseHandle
(
recording_fp
);
CloseHandle
(
recording_fp
);
#else
fclose
(
fp
);
fclose
(
fp
);
#endif
}
pheader
.
datasize
=
pdata
-
replay_data
;
pheader
.
flag
|=
REPLAY_COMPRESSED
;
size_t
propsize
=
5
;
...
...
gframe/single_duel.cpp
View file @
09ded696
This diff is collapsed.
Click to expand it.
gframe/single_duel.h
View file @
09ded696
...
...
@@ -49,6 +49,7 @@ protected:
unsigned
char
hand_result
[
2
];
unsigned
char
last_response
;
std
::
set
<
DuelPlayer
*>
observers
;
std
::
set
<
DuelPlayer
*>
recorders
;
Replay
last_replay
;
bool
match_mode
;
int
match_kill
;
...
...
gframe/tag_duel.cpp
View file @
09ded696
This diff is collapsed.
Click to expand it.
gframe/tag_duel.h
View file @
09ded696
...
...
@@ -46,6 +46,7 @@ protected:
DuelPlayer
*
pplayer
[
4
];
DuelPlayer
*
cur_player
[
2
];
std
::
set
<
DuelPlayer
*>
observers
;
std
::
set
<
DuelPlayer
*>
recorders
;
bool
ready
[
4
];
Deck
pdeck
[
4
];
unsigned
char
hand_result
[
2
];
...
...
ocgcore
@
dd4bbf6b
Subproject commit
96bbbedb6e828f4a227cf5405ed8e284b0def2cc
Subproject commit
dd4bbf6b6330c492196bafea43d38a04e9e4cbc5
premake5.lua
0 → 100644
View file @
09ded696
solution
"ygo"
location
"build"
language
"C++"
objdir
"obj"
configurations
{
"Debug"
,
"Release"
}
configuration
"windows"
defines
{
"WIN32"
,
"_WIN32"
}
configuration
"bsd"
defines
{
"LUA_USE_POSIX"
}
includedirs
{
"/usr/local/include"
}
libdirs
{
"/usr/local/lib"
}
configuration
"macosx"
defines
{
"LUA_USE_MACOSX"
}
includedirs
{
"/usr/local/include/*"
}
libdirs
{
"/usr/local/lib"
,
"/usr/X11/lib"
}
buildoptions
{
"-stdlib=libc++"
}
links
{
"OpenGL.framework"
,
"Cocoa.framework"
,
"IOKit.framework"
}
configuration
"linux"
defines
{
"LUA_USE_LINUX"
}
configuration
"Release"
flags
{
"OptimizeSpeed"
}
targetdir
"bin/release"
configuration
"Debug"
symbols
"On"
defines
"_DEBUG"
targetdir
"bin/debug"
configuration
{
"Release"
,
"vs*"
}
flags
{
"StaticRuntime"
,
"LinkTimeOptimization"
}
disablewarnings
{
"4244"
,
"4267"
,
"4838"
,
"4577"
,
"4819"
,
"4018"
,
"4996"
,
"4477"
}
configuration
{
"Release"
,
"not vs*"
}
symbols
"On"
defines
"NDEBUG"
buildoptions
"-march=native"
configuration
{
"Debug"
,
"vs*"
}
defines
{
"_ITERATOR_DEBUG_LEVEL=0"
}
configuration
"vs*"
flags
"EnableSSE2"
defines
{
"_CRT_SECURE_NO_WARNINGS"
}
configuration
"not vs*"
buildoptions
{
"-fno-strict-aliasing"
,
"-Wno-multichar"
}
configuration
{
"not vs*"
,
"windows"
}
buildoptions
{
"-static-libgcc"
}
startproject
"ygopro"
include
"ocgcore"
include
"gframe"
if
os
.
is
(
"windows"
)
then
include
"event"
include
"lua"
include
"sqlite3"
end
script
@
6a65f1ba
Subproject commit
5485784eac297306878f20f2c6cd4a0a5169865
3
Subproject commit
6a65f1ba96072e53a6c57efca4817ae6f716f9a
3
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