Commit 09ded696 authored by mercury233's avatar mercury233

merge

parent c6c9201d
/expansions /expansions
/specials
/obj /obj
/bin /bin
/build /build
/event
/lua
/sqlite3
/replay /replay
/deck /deck
/.vscode
/gframe/ygopro.ico
/gframe/ygopro.rc
/gframe/ygopro.aps
/gframe/dirent.h
ygopro ygopro
premake5.exe
[submodule "ocgcore"] [submodule "ocgcore"]
path = ocgcore path = ocgcore
url = https://github.com/Fluorohydride/ygopro-core.git url = https://github.com/mycard/ygopro-core
[submodule "script"] [submodule "script"]
path = script path = script
url = https://github.com/Fluorohydride/ygopro-scripts.git url = https://github.com/mycard/ygopro-scripts
## ygopro(server) ## ygopro(server)
一个linux版的ygopro服务端。 一个linux版的ygopro服务端,基于mycard代码修改。
现用于[YGOPRO 233服](http://mercury233.me/ygosrv233/)
###编译 ###编译
* 需要以下组件 * 需要以下组件或工具
* gcc
* premake4 * premake4
* libevent * libevent
* sqlite3 * sqlite3
* lua5.2 * lua5.2
* gcc
* 可参考 https://github.com/mercury233/ygopro-server/wiki 中的脚本 * 可参考 https://github.com/mercury233/ygopro-server/wiki 中的脚本
###运行 ###运行
* 使用[ygopro-server-lite](https://github.com/mercury233/ygopro-server)运行 * 使用[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为随机) * 端口(0为随机)
* 禁卡表编号 * 禁卡表编号
* 卡片允许 * 卡片允许
...@@ -25,3 +27,4 @@ ...@@ -25,3 +27,4 @@
* 初始手牌数 * 初始手牌数
* 每回合抽卡 * 每回合抽卡
* 每回合时间 * 每回合时间
* 录像保存模式
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)
No preview for this file type
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
#include "netserver.h" #include "netserver.h"
//#include "single_mode.h" //#include "single_mode.h"
#ifdef _WIN32
#define strcasecmp _stricmp
#include "dirent.h"
#endif // _WIN32
#ifndef _WIN32 #ifndef _WIN32
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <dirent.h>
...@@ -30,6 +35,7 @@ bool no_check_deck; ...@@ -30,6 +35,7 @@ bool no_check_deck;
bool no_shuffle_deck; bool no_shuffle_deck;
unsigned int start_lp; unsigned int start_lp;
unsigned short time_limit; unsigned short time_limit;
unsigned short replay_mode;
unsigned char start_hand; unsigned char start_hand;
unsigned char draw_count; unsigned char draw_count;
...@@ -1204,6 +1210,7 @@ int Game::LocalPlayer(int player) { ...@@ -1204,6 +1210,7 @@ int Game::LocalPlayer(int player) {
const wchar_t* Game::LocalName(int local_player) { const wchar_t* Game::LocalName(int local_player) {
return local_player == 0 ? dInfo.hostname : dInfo.clientname; return local_player == 0 ? dInfo.hostname : dInfo.clientname;
} }
/*
void Game::SetWindowsIcon() { void Game::SetWindowsIcon() {
#ifdef _WIN32 #ifdef _WIN32
HINSTANCE hInstance = (HINSTANCE)GetModuleHandleW(NULL); HINSTANCE hInstance = (HINSTANCE)GetModuleHandleW(NULL);
...@@ -1224,5 +1231,6 @@ void Game::FlashWindow() { ...@@ -1224,5 +1231,6 @@ void Game::FlashWindow() {
FlashWindowEx(&fi); FlashWindowEx(&fi);
#endif #endif
} }
*/
} }
...@@ -116,10 +116,10 @@ public: ...@@ -116,10 +116,10 @@ public:
//irr::gui::IGUIElement* focus = env->getFocus(); //irr::gui::IGUIElement* focus = env->getFocus();
return focus && focus->hasType(type); return focus && focus->hasType(type);
} }
void SetWindowsIcon(); void SetWindowsIcon();
void FlashWindow(); void FlashWindow();
*/ */
Mutex gMutex; Mutex gMutex;
Mutex gBuffer; Mutex gBuffer;
...@@ -423,6 +423,7 @@ extern bool no_check_deck; ...@@ -423,6 +423,7 @@ extern bool no_check_deck;
extern bool no_shuffle_deck; extern bool no_shuffle_deck;
extern unsigned int start_lp; extern unsigned int start_lp;
extern unsigned short time_limit; extern unsigned short time_limit;
extern unsigned short replay_mode;
extern unsigned char start_hand; extern unsigned char start_hand;
extern unsigned char draw_count; extern unsigned char draw_count;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "data_manager.h" #include "data_manager.h"
#include <event2/thread.h> #include <event2/thread.h>
int enable_log = 0; int enable_log = 1;
bool exit_on_return = false; bool exit_on_return = false;
bool runasserver = true; bool runasserver = true;
...@@ -23,6 +23,7 @@ int main(int argc, char* argv[]) { ...@@ -23,6 +23,7 @@ int main(int argc, char* argv[]) {
ygo::aServerPort=atoi(argv[1]); ygo::aServerPort=atoi(argv[1]);
ygo::lflist=atoi(argv[2]); ygo::lflist=atoi(argv[2]);
ygo::start_hand=0; ygo::start_hand=0;
ygo::replay_mode=0;
if (argc>2) { if (argc>2) {
ygo::rule=atoi(argv[3]); ygo::rule=atoi(argv[3]);
ygo::mode=atoi(argv[4]); ygo::mode=atoi(argv[4]);
...@@ -42,6 +43,8 @@ int main(int argc, char* argv[]) { ...@@ -42,6 +43,8 @@ int main(int argc, char* argv[]) {
ygo::start_hand=atoi(argv[9]); ygo::start_hand=atoi(argv[9]);
ygo::draw_count=atoi(argv[10]); ygo::draw_count=atoi(argv[10]);
ygo::time_limit=atoi(argv[11]); ygo::time_limit=atoi(argv[11]);
if (argc>12)
ygo::replay_mode=atoi(argv[12]);
} }
ygo::mainGame = &_game; ygo::mainGame = &_game;
ygo::mainGame->MainServerLoop(ygo::mode, ygo::lflist); ygo::mainGame->MainServerLoop(ygo::mode, ygo::lflist);
......
...@@ -22,6 +22,7 @@ struct HostInfo { ...@@ -22,6 +22,7 @@ struct HostInfo {
unsigned char start_hand; unsigned char start_hand;
unsigned char draw_count; unsigned char draw_count;
unsigned short time_limit; unsigned short time_limit;
unsigned short replay_mode;
}; };
struct HostPacket { struct HostPacket {
unsigned short identifier; unsigned short identifier;
......
...@@ -12,13 +12,16 @@ project "ygopro" ...@@ -12,13 +12,16 @@ project "ygopro"
"single_duel.cpp", "single_duel.h", "single_duel.cpp", "single_duel.h",
"tag_duel.cpp", "tag_duel.h", "tag_duel.cpp", "tag_duel.h",
"**.cc", "**.c"} "**.cc", "**.c"}
excludes "lzma/**"
includedirs { "../ocgcore" } includedirs { "../ocgcore" }
links { "ocgcore", "clzma", "sqlite3", "lua" , "event"} links { "ocgcore", "clzma", "sqlite3", "lua" , "event"}
configuration "windows"
files "ygopro.rc"
includedirs { "../event/include", "../sqlite3" }
links { "ws2_32" }
configuration "not vs*" configuration "not vs*"
buildoptions { "-std=gnu++0x", "-fno-rtti" } buildoptions { "-std=gnu++0x", "-fno-rtti" }
configuration "not windows" configuration "not windows"
includedirs { "/usr/include/lua", "/usr/include/lua5.2", "/usr/include/lua/5.2" } includedirs { "/usr/include/lua", "/usr/include/lua5.2", "/usr/include/lua/5.2" }
excludes { "COSOperator.*" }
links { "event_pthreads", "dl", "pthread" } links { "event_pthreads", "dl", "pthread" }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace ygo { namespace ygo {
extern unsigned short aServerPort; extern unsigned short aServerPort;
extern unsigned short replay_mode;
Replay::Replay() { Replay::Replay() {
is_recording = false; is_recording = false;
...@@ -42,115 +43,135 @@ std::wstring SA2W(std::string& strA) ...@@ -42,115 +43,135 @@ std::wstring SA2W(std::string& strA)
void Replay::BeginRecord() { void Replay::BeginRecord() {
if (ygo::replay_mode>0) {
#ifdef _WIN32 #ifdef _WIN32
if(is_recording) if(is_recording)
CloseHandle(recording_fp); CloseHandle(recording_fp);
std::stringstream ss; std::stringstream ss;
ss<<ygo::aServerPort; ss<<ygo::aServerPort;
std::string ssss; std::string ssss;
ssss=ss.str(); 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); recording_fp = CreateFileW(comID.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
if(recording_fp == INVALID_HANDLE_VALUE) if(recording_fp == INVALID_HANDLE_VALUE)
return; return;
#else #else
if(is_recording) if(is_recording)
fclose(fp); fclose(fp);
char path[20]; time_t nowtime = time(NULL);
sprintf(path, "./replay/%u.yrp", ygo::aServerPort); struct tm *localedtime = localtime(&nowtime);
fp = fopen(path, "wb"); char tmppath[40];
if(!fp) strftime(tmppath, 40, "./replay/%Y-%m-%d %H-%M-%S %%u.yrp", localedtime);
return; char path[40];
sprintf(path, tmppath, ygo::aServerPort);
fp = fopen(path, "wb");
if(!fp)
return;
#endif #endif
}
pdata = replay_data; pdata = replay_data;
is_recording = true; is_recording = true;
} }
void Replay::WriteHeader(ReplayHeader& header) { void Replay::WriteHeader(ReplayHeader& header) {
pheader = header; pheader = header;
if (ygo::replay_mode>0) {
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, &header, sizeof(header), &size, NULL); WriteFile(recording_fp, &header, sizeof(header), &size, NULL);
#else #else
fwrite(&header, sizeof(header), 1, fp); fwrite(&header, sizeof(header), 1, fp);
fflush(fp); fflush(fp);
#endif #endif
}
} }
void Replay::WriteData(const void* data, unsigned int length, bool flush) { void Replay::WriteData(const void* data, unsigned int length, bool flush) {
if(!is_recording) if(!is_recording)
return; return;
memcpy(pdata, data, length); memcpy(pdata, data, length);
pdata += length; pdata += length;
if (ygo::replay_mode>0) {
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, data, length, &size, NULL); WriteFile(recording_fp, data, length, &size, NULL);
#else #else
fwrite(data, length, 1, fp); fwrite(data, length, 1, fp);
if(flush) if(flush)
fflush(fp); fflush(fp);
#endif #endif
}
} }
void Replay::WriteInt32(int data, bool flush) { void Replay::WriteInt32(int data, bool flush) {
if(!is_recording) if(!is_recording)
return; return;
*((int*)(pdata)) = data; *((int*)(pdata)) = data;
pdata += 4; pdata += 4;
if (ygo::replay_mode>0) {
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, &data, sizeof(int), &size, NULL); WriteFile(recording_fp, &data, sizeof(int), &size, NULL);
#else #else
fwrite(&data, sizeof(int), 1, fp); fwrite(&data, sizeof(int), 1, fp);
if(flush) if(flush)
fflush(fp); fflush(fp);
#endif #endif
}
} }
void Replay::WriteInt16(short data, bool flush) { void Replay::WriteInt16(short data, bool flush) {
if(!is_recording) if(!is_recording)
return; return;
*((short*)(pdata)) = data; *((short*)(pdata)) = data;
pdata += 2; pdata += 2;
if (ygo::replay_mode>0) {
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, &data, sizeof(short), &size, NULL); WriteFile(recording_fp, &data, sizeof(short), &size, NULL);
#else #else
fwrite(&data, sizeof(short), 1, fp); fwrite(&data, sizeof(short), 1, fp);
if(flush) if(flush)
fflush(fp); fflush(fp);
#endif #endif
}
} }
void Replay::WriteInt8(char data, bool flush) { void Replay::WriteInt8(char data, bool flush) {
if(!is_recording) if(!is_recording)
return; return;
*pdata = data; *pdata = data;
pdata++; pdata++;
if (ygo::replay_mode>0) {
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, &data, sizeof(char), &size, NULL); WriteFile(recording_fp, &data, sizeof(char), &size, NULL);
#else #else
fwrite(&data, sizeof(char), 1, fp); fwrite(&data, sizeof(char), 1, fp);
if(flush) if(flush)
fflush(fp); fflush(fp);
#endif #endif
}
} }
void Replay::Flush() { void Replay::Flush() {
if(!is_recording) if(!is_recording)
return; return;
if (ygo::replay_mode>0) {
#ifdef _WIN32 #ifdef _WIN32
#else #else
fflush(fp); fflush(fp);
#endif #endif
}
} }
void Replay::EndRecord() { void Replay::EndRecord() {
if(!is_recording) if(!is_recording)
return; return;
if (ygo::replay_mode>0) {
#ifdef _WIN32 #ifdef _WIN32
CloseHandle(recording_fp); CloseHandle(recording_fp);
#else #else
fclose(fp); fclose(fp);
#endif #endif
}
pheader.datasize = pdata - replay_data; pheader.datasize = pdata - replay_data;
pheader.flag |= REPLAY_COMPRESSED; pheader.flag |= REPLAY_COMPRESSED;
size_t propsize = 5; size_t propsize = 5;
......
This diff is collapsed.
...@@ -49,6 +49,7 @@ protected: ...@@ -49,6 +49,7 @@ protected:
unsigned char hand_result[2]; unsigned char hand_result[2];
unsigned char last_response; unsigned char last_response;
std::set<DuelPlayer*> observers; std::set<DuelPlayer*> observers;
std::set<DuelPlayer*> recorders;
Replay last_replay; Replay last_replay;
bool match_mode; bool match_mode;
int match_kill; int match_kill;
......
This diff is collapsed.
...@@ -46,6 +46,7 @@ protected: ...@@ -46,6 +46,7 @@ protected:
DuelPlayer* pplayer[4]; DuelPlayer* pplayer[4];
DuelPlayer* cur_player[2]; DuelPlayer* cur_player[2];
std::set<DuelPlayer*> observers; std::set<DuelPlayer*> observers;
std::set<DuelPlayer*> recorders;
bool ready[4]; bool ready[4];
Deck pdeck[4]; Deck pdeck[4];
unsigned char hand_result[2]; unsigned char hand_result[2];
......
Subproject commit 96bbbedb6e828f4a227cf5405ed8e284b0def2cc Subproject commit dd4bbf6b6330c492196bafea43d38a04e9e4cbc5
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
Subproject commit 5485784eac297306878f20f2c6cd4a0a51698653 Subproject commit 6a65f1ba96072e53a6c57efca4817ae6f716f9a3
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment