Commit 09ded696 authored by mercury233's avatar mercury233

merge

parent c6c9201d
/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
[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
## 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 @@
* 初始手牌数
* 每回合抽卡
* 每回合时间
* 录像保存模式
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 @@
#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
}
*/
}
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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" }
......@@ -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;
......
This diff is collapsed.
......@@ -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;
......
This diff is collapsed.
......@@ -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];
......
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