Commit 945959d2 authored by DailyShana's avatar DailyShana

Merge branch 'server' of https://github.com/moecube/ygopro into server-patch

parents 30d80b7e 35e4eb1a
/expansions
/specials
/obj
/bin
/build
/event
/lua
/sqlite3
/replay
/deck
/.vscode
/gframe/ygopro.ico
/gframe/ygopro.rc
/gframe/ygopro.aps
ygopro
premake5.exe
premake5
[submodule "ocgcore"] [submodule "ocgcore"]
path = ocgcore path = ocgcore
url = git@github.com:Fluorohydride/ygopro-core.git url = https://github.com/mycard/ygopro-core
[submodule "script"] [submodule "script"]
path = script path = script
url = git@github.com:Fluorohydride/ygopro-scripts.git url = https://github.com/mycard/ygopro-scripts
language: cpp
dist: trusty
git:
submodules: false
addons:
ssh_known_hosts:
- github.com
apt:
packages:
- libevent-dev
- libsqlite3-dev
before_install:
- git submodule update --init --recursive
- wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha10/premake-5.0.0-alpha10-linux.tar.gz | tar zfx -
- wget -O - https://www.lua.org/ftp/lua-5.3.4.tar.gz | tar zfx -; cd lua-5.3.4; sudo make linux install; cd ..
script:
- ./premake5 gmake
- cd build
- make config=release
## YGOPro ## YGOPro(Server)
A script engine for "yu-gi-oh!" and sample gui [![Build status](https://ci.appveyor.com/api/projects/status/qgkqi6o0wq7qn922/branch/server?svg=true)](https://ci.appveyor.com/project/zh99998/ygopro/branch/server)
[![Build Status](https://travis-ci.org/moecube/ygopro.svg?branch=server)](https://travis-ci.org/moecube/ygopro)
[中文说明](https://github.com/Fluorohydride/ygopro/wiki/%E4%B8%AD%E6%96%87%E8%AF%B4%E6%98%8E)
一个YGOPro的服务端版本,运行后自动建立主机,并开启端口供YGOPro客户端连接。
### Keys:
* ESC: Minimize the window. 现用于[萌卡](https://mycard.moe/)[YGOPro 233服](http://mercury233.me/ygosrv233/)
* A: Holding down this button will let the system stop at every timing.
* S: Holding down this button will let the system skip every timing. ### Linux下编译
* D: Holding down this button will let the system stop at available timing. * 需要以下组件或工具
* R: Fix the font glitch. * gcc
* F1~F4: Show the cards in your grave, banished zone, extra deck, xyz materials. * premake5
* F5~F8: Show the cards in your opponent's grave, banished zone, extra deck, xyz materials. * libevent
* lua5.3
### Color in card list: * sqlite3
#### Background: * 可参考本项目 [.travis.yml](https://github.com/mycard/ygopro/blob/server/.travis.yml) 中的脚本
* White = your card, Grey = your opponent's card
### Windows下编译
#### Text: * 需要以下组件或工具
Cards in deck, extra deck and banished zone: * Visual Studio
* Black = face-up, Blue = face-down * premake5
* libevent
Xyz materials: * lua5.3
* Black = default, Blue = the owner of the xyz material is different from its controller * sqlite3
* 可参考本项目 [appveyor.yml](https://github.com/mycard/ygopro/blob/server/appveyor.yml) 中的脚本
### Sequence:
* Monster Zone: 1~5, starting from the left hand side. ### 运行
* Spell & Trap Zone: 1~5, starting from the left hand side. * 使用[ygopro-server](https://github.com/mycard/ygopro-server)运行
* Field Zone: 6 * 手动运行的参数是
* Pendulum Zone: 0~1, starting from the left hand side. * ./ygopro 0 0 0 1 F F F 8000 5 1 180 0
* The others: 1~n, starting from the bottom. * 端口(0为随机)
* 禁卡表编号
### Deck edit page: * 卡片允许
* All numeric textboxs: They support >, =, <, >=, <= signs. * 决斗模式
* Card name: Search card names and texts by default, $foo will only search foo in card names, and @foo will search cards of "foo" archetype(due to translation, card name contains "foo" does not mean that card is "foo" card). * 旧规则
* 不检查卡组
### Command-line options: * 不洗切卡组
* `-e foo.cdb`: Load foo.cdb as the extra database. * 初始LP
* `-n nickname`: Set the nickname. * 初始手牌数
* `-h 192.168.0.2`: Set the host to join in LAN mode. * 每回合抽卡
* `-p 7911`: Set the port to join in LAN mode. * 每回合时间
* `-w abc`: Set the password to join in LAN mode. * 录像保存模式
* `-d`: Enter the deck edit page.
* `-d deck`: If used along with `-j` it mean select the deck, or it will open the deck to edit.
* `-c`: Create host with default settings.
* `-j`: Join the host specified in above, or if absent, lasthost in system.conf file.
* `-r`: Enter the replay mode page.
* `-r replay.yrp`: Load the replay.yrp in replay mode.
* `-s`: Enter the single mode page.
* `-s puzzle.lua`: Load the puzzle.lua in single mode.
* `-k`: Keep when duel finished. See below.
#### Note:
* `-c` `-j` `-e` `-r` `-s` shoule be the last parameter, because any parameters after it will get ignored.
* `-d` `-c` `-j` `-e` `-r` `-s` will make YGOPro automatically exit when the duel or deck editing is finished. This is useful for some launchers. If you want to keep it, add `-k` before them.
* `-d` `-r` `-s` support full path of file, or just filename. But remember deck filename should NOT have extension when replay and single filename MUST have extension.
### Directories:
* pics: .jpg card images(177*254).
* pics\thumbnail: .jpg thumbnail images(44*64).
* script: .lua script files.
* textures: Other image files.
* deck: .ydk deck files.
* replay: .yrp replay files.
* expansions: *.cdb will be loaded as extra databases.
version: '{build}'
install:
- git submodule update --init --recursive
# environment and system dependency
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/premake/premake-core/releases/download/v5.0.0-alpha10/premake-5.0.0-alpha10-windows.zip ; exit 0"
- 7z x premake-5.0.0-alpha10-windows.zip
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz ; exit 0"
- tar xf libevent-2.0.22-stable.tar.gz
- move libevent-2.0.22-stable event
- xcopy /E event\WIN32-Code event\include
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://www.lua.org/ftp/lua-5.3.4.tar.gz ; exit 0"
- tar xf lua-5.3.4.tar.gz
- move lua-5.3.4\src lua
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://www.sqlite.org/2017/sqlite-amalgamation-3200000.zip ; exit 0"
- 7z x sqlite-amalgamation-3200000.zip
- move sqlite-amalgamation-3200000 sqlite3
# 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 .
test: off
artifacts:
- path: ygopro.exe
name: ygopro(server)
cache:
- premake-5.0.0-alpha10-windows.zip
- libevent-2.0.22-stable.tar.gz
- lua-5.3.4.tar.gz
- sqlite-amalgamation-3200000.zip
File added
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "config.h" #include "config.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map>
#include <unordered_map> #include <unordered_map>
namespace ygo { namespace ygo {
...@@ -47,6 +48,7 @@ typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer ...@@ -47,6 +48,7 @@ typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer
class ClientCard { class ClientCard {
public: public:
#ifndef YGOPRO_SERVER_MODE
irr::core::matrix4 mTransform; irr::core::matrix4 mTransform;
irr::core::vector3df curPos; irr::core::vector3df curPos;
irr::core::vector3df curRot; irr::core::vector3df curRot;
...@@ -119,6 +121,7 @@ public: ...@@ -119,6 +121,7 @@ public:
static bool deck_sort_atk(code_pointer l1, code_pointer l2); static bool deck_sort_atk(code_pointer l1, code_pointer l2);
static bool deck_sort_def(code_pointer l1, code_pointer l2); static bool deck_sort_def(code_pointer l1, code_pointer l2);
static bool deck_sort_name(code_pointer l1, code_pointer l2); static bool deck_sort_name(code_pointer l1, code_pointer l2);
#endif //YGOPRO_SERVER_MODE
}; };
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "image_manager.h" #include "image_manager.h"
#include "game.h" #include "game.h"
#include "materials.h" #include "materials.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
namespace ygo { namespace ygo {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "config.h" #include "config.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map>
namespace ygo { namespace ygo {
......
...@@ -53,11 +53,13 @@ inline int _wtoi(const wchar_t * s) { ...@@ -53,11 +53,13 @@ inline int _wtoi(const wchar_t * s) {
} }
#endif #endif
#ifndef YGOPRO_SERVER_MODE
#include <irrlicht.h> #include <irrlicht.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#include "CGUITTFont.h" #include "CGUITTFont.h"
#include "CGUIImageButton.h" #include "CGUIImageButton.h"
#endif //YGOPRO_SERVER_MODE
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -68,14 +70,16 @@ inline int _wtoi(const wchar_t * s) { ...@@ -68,14 +70,16 @@ inline int _wtoi(const wchar_t * s) {
#include "mysignal.h" #include "mysignal.h"
#include "mythread.h" #include "mythread.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
#ifndef YGOPRO_SERVER_MODE
using namespace irr; using namespace irr;
using namespace core; using namespace core;
using namespace scene; using namespace scene;
using namespace video; using namespace video;
using namespace io; using namespace io;
using namespace gui; using namespace gui;
#endif //YGOPRO_SERVER_MODE
extern const unsigned short PRO_VERSION; extern const unsigned short PRO_VERSION;
extern int enable_log; extern int enable_log;
......
...@@ -12,7 +12,11 @@ bool DataManager::LoadDB(const char* file) { ...@@ -12,7 +12,11 @@ bool DataManager::LoadDB(const char* file) {
if(sqlite3_open_v2(file, &pDB, SQLITE_OPEN_READONLY, 0) != SQLITE_OK) if(sqlite3_open_v2(file, &pDB, SQLITE_OPEN_READONLY, 0) != SQLITE_OK)
return Error(pDB); return Error(pDB);
sqlite3_stmt* pStmt; sqlite3_stmt* pStmt;
#ifdef YGOPRO_SERVER_MODE
const char* sql = "select * from datas";
#else
const char* sql = "select * from datas,texts where datas.id=texts.id"; 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(sqlite3_prepare_v2(pDB, sql, -1, &pStmt, 0) != SQLITE_OK)
return Error(pDB); return Error(pDB);
CardDataC cd; CardDataC cd;
...@@ -43,6 +47,7 @@ bool DataManager::LoadDB(const char* file) { ...@@ -43,6 +47,7 @@ bool DataManager::LoadDB(const char* file) {
cd.attribute = sqlite3_column_int(pStmt, 9); cd.attribute = sqlite3_column_int(pStmt, 9);
cd.category = sqlite3_column_int(pStmt, 10); cd.category = sqlite3_column_int(pStmt, 10);
_datas.insert(std::make_pair(cd.code, cd)); _datas.insert(std::make_pair(cd.code, cd));
#ifndef YGOPRO_SERVER_MODE
if(const char* text = (const char*)sqlite3_column_text(pStmt, 12)) { if(const char* text = (const char*)sqlite3_column_text(pStmt, 12)) {
BufferIO::DecodeUTF8(text, strBuffer); BufferIO::DecodeUTF8(text, strBuffer);
cs.name = strBuffer; cs.name = strBuffer;
...@@ -58,6 +63,7 @@ bool DataManager::LoadDB(const char* file) { ...@@ -58,6 +63,7 @@ bool DataManager::LoadDB(const char* file) {
} }
} }
_strings.emplace(cd.code, cs); _strings.emplace(cd.code, cs);
#endif //YGOPRO_SERVER_MODE
} }
} while(step != SQLITE_DONE); } while(step != SQLITE_DONE);
sqlite3_finalize(pStmt); sqlite3_finalize(pStmt);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "deck_manager.h" #include "deck_manager.h"
#include "sound_manager.h" #include "sound_manager.h"
#include "duelclient.h" #include "duelclient.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
namespace ygo { namespace ygo {
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
#include "image_manager.h" #include "image_manager.h"
#include "sound_manager.h" #include "sound_manager.h"
#include "single_mode.h" #include "single_mode.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
#include "../ocgcore/duel.h"
#include "game.h" #include "game.h"
#include "replay.h" #include "replay.h"
#include "replay_mode.h" #include "replay_mode.h"
#include <algorithm>
namespace ygo { namespace ygo {
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include "replay_mode.h" #include "replay_mode.h"
#include "single_mode.h" #include "single_mode.h"
#include "materials.h" #include "materials.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
#include <algorithm>
namespace ygo { namespace ygo {
......
#include "config.h" #include "config.h"
#include "game.h" #include "game.h"
#ifdef YGOPRO_SERVER_MODE
#include "data_manager.h"
#include "deck_manager.h"
#include "replay.h"
#else
#include "image_manager.h" #include "image_manager.h"
#include "data_manager.h" #include "data_manager.h"
#include "deck_manager.h" #include "deck_manager.h"
...@@ -9,6 +14,7 @@ ...@@ -9,6 +14,7 @@
#include "duelclient.h" #include "duelclient.h"
#include "netserver.h" #include "netserver.h"
#include "single_mode.h" #include "single_mode.h"
#endif //YGOPRO_SERVER_MODE
#ifndef _WIN32 #ifndef _WIN32
#include <sys/types.h> #include <sys/types.h>
...@@ -26,6 +32,31 @@ namespace ygo { ...@@ -26,6 +32,31 @@ namespace ygo {
Game* mainGame; Game* mainGame;
#ifdef YGOPRO_SERVER_MODE
unsigned short aServerPort;
unsigned short replay_mode;
HostInfo game_info;
void Game::MainServerLoop() {
initUtils();
deckManager.LoadLFList();
LoadExpansionDB();
dataManager.LoadDB("cards.cdb");
aServerPort = NetServer::StartServer(aServerPort);
NetServer::InitDuel();
printf("%u\n", aServerPort);
fflush(stdout);
while(NetServer::net_evbase) {
#ifdef WIN32
Sleep(200);
#else
usleep(200000);
#endif
}
}
#else //YGOPRO_SERVER_MODE
bool Game::Initialize() { bool Game::Initialize() {
srand(time(0)); srand(time(0));
initUtils(); initUtils();
...@@ -847,6 +878,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu ...@@ -847,6 +878,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
dataManager.strBuffer[pbuffer] = 0; dataManager.strBuffer[pbuffer] = 0;
pControl->setText(dataManager.strBuffer); pControl->setText(dataManager.strBuffer);
} }
#endif //YGOPRO_SERVER_MODE
void Game::LoadExpansionDB() { void Game::LoadExpansionDB() {
#ifdef _WIN32 #ifdef _WIN32
char fpath[1000]; char fpath[1000];
...@@ -879,6 +911,7 @@ void Game::LoadExpansionDB() { ...@@ -879,6 +911,7 @@ void Game::LoadExpansionDB() {
} }
#endif #endif
} }
#ifndef YGOPRO_SERVER_MODE
void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) { void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) {
cbDeck->clear(); cbDeck->clear();
#ifdef _WIN32 #ifdef _WIN32
...@@ -1335,8 +1368,12 @@ void Game::ClearChatMsg() { ...@@ -1335,8 +1368,12 @@ void Game::ClearChatMsg() {
chatTiming[i] = 0; chatTiming[i] = 0;
} }
} }
#endif //YGOPRO_SERVER_MODE
void Game::AddDebugMsg(char* msg) void Game::AddDebugMsg(char* msg)
{ {
#ifdef YGOPRO_SERVER_MODE
fprintf(stderr, "%s\n", msg);
#else
if (enable_log & 0x1) { if (enable_log & 0x1) {
wchar_t wbuf[1024]; wchar_t wbuf[1024];
BufferIO::DecodeUTF8(msg, wbuf); BufferIO::DecodeUTF8(msg, wbuf);
...@@ -1353,6 +1390,7 @@ void Game::AddDebugMsg(char* msg) ...@@ -1353,6 +1390,7 @@ void Game::AddDebugMsg(char* msg)
fprintf(fp, "[%s][Script Error]: %s\n", timebuf, msg); fprintf(fp, "[%s][Script Error]: %s\n", timebuf, msg);
fclose(fp); fclose(fp);
} }
#endif //YGOPRO_SERVER_MODE
} }
bool Game::MakeDirectory(const std::string folder) { bool Game::MakeDirectory(const std::string folder) {
std::string folder_builder; std::string folder_builder;
...@@ -1380,6 +1418,10 @@ void Game::initUtils() { ...@@ -1380,6 +1418,10 @@ void Game::initUtils() {
MakeDirectory("replay"); MakeDirectory("replay");
//cards from extra pack //cards from extra pack
MakeDirectory("expansions"); MakeDirectory("expansions");
#ifdef YGOPRO_SERVER_MODE
//special scripts
MakeDirectory("specials");
#else
//files in ygopro-starter-pack //files in ygopro-starter-pack
MakeDirectory("deck"); MakeDirectory("deck");
MakeDirectory("single"); MakeDirectory("single");
...@@ -1401,7 +1443,9 @@ void Game::initUtils() { ...@@ -1401,7 +1443,9 @@ void Game::initUtils() {
//pics //pics
MakeDirectory("pics"); MakeDirectory("pics");
MakeDirectory("pics/field"); MakeDirectory("pics/field");
#endif //YGOPRO_SERVER_MODE
} }
#ifndef YGOPRO_SERVER_MODE
void Game::ClearTextures() { void Game::ClearTextures() {
matManager.mCard.setTexture(0, 0); matManager.mCard.setTexture(0, 0);
imgCard->setImage(imageManager.tCover[0]); imgCard->setImage(imageManager.tCover[0]);
...@@ -1489,5 +1533,6 @@ void Game::SetCursor(ECURSOR_ICON icon) { ...@@ -1489,5 +1533,6 @@ void Game::SetCursor(ECURSOR_ICON icon) {
cursor->setActiveIcon(icon); cursor->setActiveIcon(icon);
} }
} }
#endif //YGOPRO_SERVER_MODE
} }
...@@ -2,15 +2,20 @@ ...@@ -2,15 +2,20 @@
#define GAME_H #define GAME_H
#include "config.h" #include "config.h"
#ifndef YGOPRO_SERVER_MODE
#include "client_field.h" #include "client_field.h"
#include "deck_con.h" #include "deck_con.h"
#include "menu_handler.h" #include "menu_handler.h"
#else
#include "netserver.h"
#endif //YGOPRO_SERVER_MODE
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <list> #include <list>
namespace ygo { namespace ygo {
#ifndef YGOPRO_SERVER_MODE
struct Config { struct Config {
bool use_d3d; bool use_d3d;
bool use_image_scale; bool use_image_scale;
...@@ -95,11 +100,19 @@ struct FadingUnit { ...@@ -95,11 +100,19 @@ struct FadingUnit {
irr::core::vector2di fadingLR; irr::core::vector2di fadingLR;
irr::core::vector2di fadingDiff; irr::core::vector2di fadingDiff;
}; };
#endif //YGOPRO_SERVER_MODE
class Game { class Game {
public: public:
bool Initialize(); bool Initialize();
#ifdef YGOPRO_SERVER_MODE
void MainServerLoop();
void LoadExpansionDB();
void AddDebugMsg(char* msgbuf);
bool MakeDirectory(const std::string folder);
void initUtils();
#else
void MainLoop(); void MainLoop();
void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar); void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar);
void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text); void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text);
...@@ -467,9 +480,15 @@ public: ...@@ -467,9 +480,15 @@ public:
irr::gui::IGUIButton* btnChainWhenAvail; irr::gui::IGUIButton* btnChainWhenAvail;
//cancel or finish //cancel or finish
irr::gui::IGUIButton* btnCancelOrFinish; irr::gui::IGUIButton* btnCancelOrFinish;
#endif //YGOPRO_SERVER_MODE
}; };
extern Game* mainGame; extern Game* mainGame;
#ifdef YGOPRO_SERVER_MODE
extern unsigned short aServerPort;
extern unsigned short replay_mode;
extern HostInfo game_info;
#endif
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#endif #endif
int enable_log = 0; int enable_log = 0;
#ifndef YGOPRO_SERVER_MODE
bool exit_on_return = false; bool exit_on_return = false;
bool open_file = false; bool open_file = false;
wchar_t open_file_name[256] = L""; wchar_t open_file_name[256] = L"";
...@@ -35,6 +36,7 @@ void ClickButton(irr::gui::IGUIElement* btn) { ...@@ -35,6 +36,7 @@ void ClickButton(irr::gui::IGUIElement* btn) {
event.GUIEvent.Caller = btn; event.GUIEvent.Caller = btn;
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
} }
#endif //YGOPRO_SERVER_MODE
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
#ifndef _WIN32 #ifndef _WIN32
...@@ -68,6 +70,53 @@ int main(int argc, char* argv[]) { ...@@ -68,6 +70,53 @@ int main(int argc, char* argv[]) {
evthread_use_pthreads(); evthread_use_pthreads();
#endif //_WIN32 #endif //_WIN32
ygo::Game _game; ygo::Game _game;
#ifdef YGOPRO_SERVER_MODE
enable_log = 1;
ygo::aServerPort = 7911;
ygo::replay_mode = 0;
ygo::game_info.lflist = 0;
ygo::game_info.rule = 0;
ygo::game_info.mode = 0;
ygo::game_info.start_hand = 5;
ygo::game_info.start_lp = 8000;
ygo::game_info.draw_count = 1;
ygo::game_info.no_check_deck = false;
ygo::game_info.no_shuffle_deck = false;
ygo::game_info.duel_rule = DEFAULT_DUEL_RULE;
ygo::game_info.time_limit = 180;
if(argc > 1) {
ygo::aServerPort = atoi(argv[1]);
int lflist = atoi(argv[2]);
if(lflist < 0)
lflist = 999;
ygo::game_info.lflist = lflist;
ygo::game_info.rule = atoi(argv[3]);
int mode = atoi(argv[4]);
if(mode > 2)
mode = 0;
ygo::game_info.mode = mode;
if(argv[5][0] == 'T')
ygo::game_info.duel_rule = DEFAULT_DUEL_RULE - 1;
else
ygo::game_info.duel_rule = DEFAULT_DUEL_RULE;
if(argv[6][0] == 'T')
ygo::game_info.no_check_deck = true;
else
ygo::game_info.no_check_deck = false;
if(argv[7][0] == 'T')
ygo::game_info.no_shuffle_deck = true;
else
ygo::game_info.no_shuffle_deck = false;
ygo::game_info.start_lp = atoi(argv[8]);
ygo::game_info.start_hand = atoi(argv[9]);
ygo::game_info.draw_count = atoi(argv[10]);
ygo::game_info.time_limit = atoi(argv[11]);
ygo::replay_mode = atoi(argv[12]);
}
ygo::mainGame = &_game;
ygo::mainGame->MainServerLoop();
return 0;
#else //YGOPRO_SERVER_MODE
ygo::mainGame = &_game; ygo::mainGame = &_game;
if(!ygo::mainGame->Initialize()) if(!ygo::mainGame->Initialize())
return 0; return 0;
...@@ -182,5 +231,6 @@ int main(int argc, char* argv[]) { ...@@ -182,5 +231,6 @@ int main(int argc, char* argv[]) {
#else #else
#endif //_WIN32 #endif //_WIN32
#endif //YGOPRO_SERVER_MODE
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
...@@ -13,7 +13,52 @@ char NetServer::net_server_read[0x2000]; ...@@ -13,7 +13,52 @@ char NetServer::net_server_read[0x2000];
char NetServer::net_server_write[0x2000]; char NetServer::net_server_write[0x2000];
unsigned short NetServer::last_sent = 0; unsigned short NetServer::last_sent = 0;
#ifdef YGOPRO_SERVER_MODE
extern unsigned short replay_mode;
extern HostInfo game_info;
void NetServer::InitDuel()
{
if(game_info.mode == MODE_SINGLE) {
duel_mode = new SingleDuel(false);
duel_mode->etimer = event_new(net_evbase, 0, EV_TIMEOUT | EV_PERSIST, SingleDuel::SingleTimer, duel_mode);
} else if(game_info.mode == MODE_MATCH) {
duel_mode = new SingleDuel(true);
duel_mode->etimer = event_new(net_evbase, 0, EV_TIMEOUT | EV_PERSIST, SingleDuel::SingleTimer, duel_mode);
} else if(game_info.mode == MODE_TAG) {
duel_mode = new TagDuel();
duel_mode->etimer = event_new(net_evbase, 0, EV_TIMEOUT | EV_PERSIST, TagDuel::TagTimer, duel_mode);
}
CTOS_CreateGame* pkt = new CTOS_CreateGame;
pkt->info.mode = game_info.mode;
pkt->info.start_hand = game_info.start_hand;
pkt->info.start_lp = game_info.start_lp;
pkt->info.draw_count = game_info.draw_count;
pkt->info.no_check_deck = game_info.no_check_deck;
pkt->info.no_shuffle_deck = game_info.no_shuffle_deck;
pkt->info.duel_rule = game_info.duel_rule;
pkt->info.rule = game_info.rule;
pkt->info.time_limit = game_info.time_limit;
if(game_info.lflist == 999)
pkt->info.lflist = 0;
else if(game_info.lflist >= deckManager._lfList.size())
pkt->info.lflist = deckManager._lfList[0].hash;
else
pkt->info.lflist = deckManager._lfList[game_info.lflist].hash;
duel_mode->host_info = pkt->info;
BufferIO::CopyWStr(pkt->name, duel_mode->name, 20);
BufferIO::CopyWStr(pkt->pass, duel_mode->pass, 20);
}
unsigned short NetServer::StartServer(unsigned short port) {
#else
bool NetServer::StartServer(unsigned short port) { bool NetServer::StartServer(unsigned short port) {
#endif //YGOPRO_SERVER_MODE
if(net_evbase) if(net_evbase)
return false; return false;
net_evbase = event_base_new(); net_evbase = event_base_new();
...@@ -34,7 +79,15 @@ bool NetServer::StartServer(unsigned short port) { ...@@ -34,7 +79,15 @@ bool NetServer::StartServer(unsigned short port) {
} }
evconnlistener_set_error_cb(listener, ServerAcceptError); evconnlistener_set_error_cb(listener, ServerAcceptError);
Thread::NewThread(ServerThread, net_evbase); Thread::NewThread(ServerThread, net_evbase);
#ifdef YGOPRO_SERVER_MODE
evutil_socket_t fd = evconnlistener_get_fd(listener);
socklen_t addrlen = sizeof(sockaddr);
sockaddr_in addr;
getsockname(fd, (sockaddr*)&addr, &addrlen);
return ntohs(addr.sin_port);
#else
return true; return true;
#endif //YGOPRO_SERVER_MODE
} }
bool NetServer::StartBroadcast() { bool NetServer::StartBroadcast() {
if(!net_evbase) if(!net_evbase)
...@@ -173,7 +226,11 @@ void NetServer::DisconnectPlayer(DuelPlayer* dp) { ...@@ -173,7 +226,11 @@ void NetServer::DisconnectPlayer(DuelPlayer* dp) {
void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) { void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
char* pdata = data; char* pdata = data;
unsigned char pktType = BufferIO::ReadUInt8(pdata); unsigned char pktType = BufferIO::ReadUInt8(pdata);
#ifdef YGOPRO_SERVER_MODE
if((pktType != CTOS_SURRENDER) && (pktType != CTOS_CHAT) && (pktType != CTOS_REQUEST_FIELD) && (dp->state == 0xff || (dp->state && dp->state != pktType)))
#else
if((pktType != CTOS_SURRENDER) && (pktType != CTOS_CHAT) && (dp->state == 0xff || (dp->state && dp->state != pktType))) if((pktType != CTOS_SURRENDER) && (pktType != CTOS_CHAT) && (dp->state == 0xff || (dp->state && dp->state != pktType)))
#endif
return; return;
switch(pktType) { switch(pktType) {
case CTOS_RESPONSE: { case CTOS_RESPONSE: {
...@@ -303,6 +360,14 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) { ...@@ -303,6 +360,14 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
duel_mode->StartDuel(dp); duel_mode->StartDuel(dp);
break; break;
} }
#ifdef YGOPRO_SERVER_MODE
case CTOS_REQUEST_FIELD: {
if(!dp->game || !duel_mode->pduel)
break;
duel_mode->RequestField(dp);
break;
}
#endif
} }
} }
......
...@@ -14,7 +14,9 @@ class NetServer { ...@@ -14,7 +14,9 @@ class NetServer {
private: private:
static std::unordered_map<bufferevent*, DuelPlayer> users; static std::unordered_map<bufferevent*, DuelPlayer> users;
static unsigned short server_port; static unsigned short server_port;
#ifndef YGOPRO_SERVER_MODE
static event_base* net_evbase; static event_base* net_evbase;
#endif
static event* broadcast_ev; static event* broadcast_ev;
static evconnlistener* listener; static evconnlistener* listener;
static DuelMode* duel_mode; static DuelMode* duel_mode;
...@@ -23,7 +25,13 @@ private: ...@@ -23,7 +25,13 @@ private:
static unsigned short last_sent; static unsigned short last_sent;
public: public:
#ifdef YGOPRO_SERVER_MODE
static event_base* net_evbase;
static void InitDuel();
static unsigned short StartServer(unsigned short port);
#else
static bool StartServer(unsigned short port); static bool StartServer(unsigned short port);
#endif //YGOPRO_SERVER_MODE
static bool StartBroadcast(); static bool StartBroadcast();
static void StopServer(); static void StopServer();
static void StopBroadcast(); static void StopBroadcast();
...@@ -68,6 +76,14 @@ public: ...@@ -68,6 +76,14 @@ public:
if(dp) if(dp)
bufferevent_write(dp->bev, net_server_write, last_sent); bufferevent_write(dp->bev, net_server_write, last_sent);
} }
#ifdef YGOPRO_SERVER_MODE
static void ReSendToPlayers(DuelPlayer* dp1, DuelPlayer* dp2) {
if(dp1)
bufferevent_write(dp1->bev, net_server_write, last_sent);
if(dp2)
bufferevent_write(dp2->bev, net_server_write, last_sent);
}
#endif //YGOPRO_SERVER_MODE
}; };
} }
......
...@@ -134,6 +134,9 @@ public: ...@@ -134,6 +134,9 @@ public:
virtual void Surrender(DuelPlayer* dp) {} virtual void Surrender(DuelPlayer* dp) {}
virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {} virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {}
virtual void TimeConfirm(DuelPlayer* dp) {} virtual void TimeConfirm(DuelPlayer* dp) {}
#ifdef YGOPRO_SERVER_MODE
virtual void RequestField(DuelPlayer* dp) {}
#endif
virtual void EndDuel() {}; virtual void EndDuel() {};
public: public:
...@@ -175,6 +178,9 @@ public: ...@@ -175,6 +178,9 @@ public:
#define CTOS_HS_NOTREADY 0x23 #define CTOS_HS_NOTREADY 0x23
#define CTOS_HS_KICK 0x24 #define CTOS_HS_KICK 0x24
#define CTOS_HS_START 0x25 #define CTOS_HS_START 0x25
#ifdef YGOPRO_SERVER_MODE
#define CTOS_REQUEST_FIELD 0x30
#endif
#define STOC_GAME_MSG 0x1 #define STOC_GAME_MSG 0x1
#define STOC_ERROR_MSG 0x2 #define STOC_ERROR_MSG 0x2
...@@ -196,6 +202,9 @@ public: ...@@ -196,6 +202,9 @@ public:
#define STOC_HS_PLAYER_ENTER 0x20 #define STOC_HS_PLAYER_ENTER 0x20
#define STOC_HS_PLAYER_CHANGE 0x21 #define STOC_HS_PLAYER_CHANGE 0x21
#define STOC_HS_WATCH_CHANGE 0x22 #define STOC_HS_WATCH_CHANGE 0x22
#ifdef YGOPRO_SERVER_MODE
#define STOC_FIELD_FINISH 0x30
#endif
#define PLAYERCHANGE_OBSERVE 0x8 #define PLAYERCHANGE_OBSERVE 0x8
#define PLAYERCHANGE_READY 0x9 #define PLAYERCHANGE_READY 0x9
......
include "lzma/." include "lzma/."
project "ygopro" project "ygopro"
kind "WindowedApp" kind "ConsoleApp"
files { "**.cpp", "**.cc", "**.c", "**.h" } defines { "YGOPRO_SERVER_MODE" }
excludes "lzma/**"
files { "gframe.cpp", "config.h",
"game.cpp", "game.h",
"deck_manager.cpp", "deck_manager.h",
"data_manager.cpp", "data_manager.h",
"replay.cpp", "replay.h",
"netserver.cpp", "netserver.h",
"single_duel.cpp", "single_duel.h",
"tag_duel.cpp", "tag_duel.h" }
includedirs { "../ocgcore" } includedirs { "../ocgcore" }
links { "ocgcore", "clzma", "Irrlicht", "freetype", "sqlite3", "lua" , "event" } links { "ocgcore", "clzma", "sqlite3", "lua" , "event"}
configuration "windows" configuration "windows"
files "ygopro.rc" files "ygopro.rc"
excludes "CGUIButton.cpp" includedirs { "../event/include", "../sqlite3" }
includedirs { "../irrlicht/include", "../freetype/include", "../event/include", "../sqlite3" } links { "ws2_32" }
if USE_IRRKLANG then
defines { "YGOPRO_USE_IRRKLANG" }
links { "irrKlang" }
includedirs { "../irrklang/include" }
libdirs { "../irrklang/lib/Win32-visualStudio" }
if IRRKLANG_PRO then
defines { "IRRKLANG_STATIC" }
links { "ikpmp3" }
end
end
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" }
configuration {"windows", "not vs*"}
includedirs { "/mingw/include/irrlicht", "/mingw/include/freetype2" }
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.3", "/usr/include/lua/5.3", "/usr/include/irrlicht", "/usr/include/freetype2" } includedirs { "/usr/include/lua", "/usr/include/lua5.3", "/usr/include/lua/5.3" }
excludes { "COSOperator.*" } links { "event_pthreads", "dl", "pthread" }
links { "event_pthreads", "GL", "dl", "pthread" }
configuration "linux"
if USE_IRRKLANG then
defines { "YGOPRO_USE_IRRKLANG" }
links { "IrrKlang" }
linkoptions{ "-Wl,-rpath=./irrklang/bin/linux-gcc-64/" }
libdirs { "../irrklang/bin/linux-gcc-64" }
includedirs { "../irrklang/include" }
end
#include "replay.h" #include "replay.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
#include <algorithm> #include <algorithm>
#include "lzma/LzmaLib.h" #include "lzma/LzmaLib.h"
namespace ygo { namespace ygo {
#ifdef YGOPRO_SERVER_MODE
extern unsigned short aServerPort;
extern unsigned short replay_mode;
#endif
Replay::Replay() { Replay::Replay() {
is_recording = false; is_recording = false;
is_replaying = false; is_replaying = false;
...@@ -17,24 +21,53 @@ Replay::~Replay() { ...@@ -17,24 +21,53 @@ Replay::~Replay() {
delete[] comp_data; delete[] comp_data;
} }
void Replay::BeginRecord() { void Replay::BeginRecord() {
#ifdef YGOPRO_SERVER_MODE
if(replay_mode > 0) {
#endif
#ifdef _WIN32 #ifdef _WIN32
if(is_recording) if(is_recording)
CloseHandle(recording_fp); CloseHandle(recording_fp);
#ifdef YGOPRO_SERVER_MODE
time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime);
wchar_t tmppath[80];
wcsftime(tmppath, 80, L"./replay/%Y-%m-%d %H-%M-%S %%u.yrp", localedtime);
wchar_t path[80];
myswprintf(path, tmppath, aServerPort);
recording_fp = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
#else
recording_fp = CreateFileW(L"./replay/_LastReplay.yrp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL); recording_fp = CreateFileW(L"./replay/_LastReplay.yrp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
#endif //YGOPRO_SERVER_MODE
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);
#ifdef YGOPRO_SERVER_MODE
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, aServerPort);
fp = fopen(path, "wb");
#else
fp = fopen("./replay/_LastReplay.yrp", "wb"); fp = fopen("./replay/_LastReplay.yrp", "wb");
#endif //YGOPRO_SERVER_MODE
if(!fp) if(!fp)
return; return;
#endif #endif
#ifdef YGOPRO_SERVER_MODE
}
#endif //YGOPRO_SERVER_MODE
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;
#ifdef YGOPRO_SERVER_MODE
if(replay_mode == 0) return;
#endif
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, &header, sizeof(header), &size, NULL); WriteFile(recording_fp, &header, sizeof(header), &size, NULL);
...@@ -48,6 +81,9 @@ void Replay::WriteData(const void* data, unsigned int length, bool flush) { ...@@ -48,6 +81,9 @@ void Replay::WriteData(const void* data, unsigned int length, bool flush) {
return; return;
memcpy(pdata, data, length); memcpy(pdata, data, length);
pdata += length; pdata += length;
#ifdef YGOPRO_SERVER_MODE
if(replay_mode == 0) return;
#endif
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, data, length, &size, NULL); WriteFile(recording_fp, data, length, &size, NULL);
...@@ -62,6 +98,9 @@ void Replay::WriteInt32(int data, bool flush) { ...@@ -62,6 +98,9 @@ void Replay::WriteInt32(int data, bool flush) {
return; return;
*((int*)(pdata)) = data; *((int*)(pdata)) = data;
pdata += 4; pdata += 4;
#ifdef YGOPRO_SERVER_MODE
if(replay_mode == 0) return;
#endif
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, &data, sizeof(int), &size, NULL); WriteFile(recording_fp, &data, sizeof(int), &size, NULL);
...@@ -76,6 +115,9 @@ void Replay::WriteInt16(short data, bool flush) { ...@@ -76,6 +115,9 @@ void Replay::WriteInt16(short data, bool flush) {
return; return;
*((short*)(pdata)) = data; *((short*)(pdata)) = data;
pdata += 2; pdata += 2;
#ifdef YGOPRO_SERVER_MODE
if(replay_mode == 0) return;
#endif
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, &data, sizeof(short), &size, NULL); WriteFile(recording_fp, &data, sizeof(short), &size, NULL);
...@@ -90,6 +132,9 @@ void Replay::WriteInt8(char data, bool flush) { ...@@ -90,6 +132,9 @@ void Replay::WriteInt8(char data, bool flush) {
return; return;
*pdata = data; *pdata = data;
pdata++; pdata++;
#ifdef YGOPRO_SERVER_MODE
if(replay_mode == 0) return;
#endif
#ifdef _WIN32 #ifdef _WIN32
DWORD size; DWORD size;
WriteFile(recording_fp, &data, sizeof(char), &size, NULL); WriteFile(recording_fp, &data, sizeof(char), &size, NULL);
...@@ -102,6 +147,9 @@ void Replay::WriteInt8(char data, bool flush) { ...@@ -102,6 +147,9 @@ void Replay::WriteInt8(char data, bool flush) {
void Replay::Flush() { void Replay::Flush() {
if(!is_recording) if(!is_recording)
return; return;
#ifdef YGOPRO_SERVER_MODE
if(replay_mode == 0) return;
#endif
#ifdef _WIN32 #ifdef _WIN32
#else #else
fflush(fp); fflush(fp);
...@@ -110,10 +158,16 @@ void Replay::Flush() { ...@@ -110,10 +158,16 @@ void Replay::Flush() {
void Replay::EndRecord() { void Replay::EndRecord() {
if(!is_recording) if(!is_recording)
return; return;
#ifdef YGOPRO_SERVER_MODE
if(replay_mode > 0) {
#endif
#ifdef _WIN32 #ifdef _WIN32
CloseHandle(recording_fp); CloseHandle(recording_fp);
#else #else
fclose(fp); fclose(fp);
#endif
#ifdef YGOPRO_SERVER_MODE
}
#endif #endif
pheader.datasize = pdata - replay_data; pheader.datasize = pdata - replay_data;
pheader.flag |= REPLAY_COMPRESSED; pheader.flag |= REPLAY_COMPRESSED;
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
#include "duelclient.h" #include "duelclient.h"
#include "game.h" #include "game.h"
#include "single_mode.h" #include "single_mode.h"
#include "../ocgcore/duel.h" #include "../ocgcore/common.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
......
This diff is collapsed.
...@@ -27,15 +27,27 @@ public: ...@@ -27,15 +27,27 @@ public:
virtual int Analyze(char* msgbuffer, unsigned int len); virtual int Analyze(char* msgbuffer, unsigned int len);
virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len); virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len);
virtual void TimeConfirm(DuelPlayer* dp); virtual void TimeConfirm(DuelPlayer* dp);
#ifdef YGOPRO_SERVER_MODE
virtual void RequestField(DuelPlayer* dp);
#endif
virtual void EndDuel(); virtual void EndDuel();
void DuelEndProc(); void DuelEndProc();
void WaitforResponse(int playerid); void WaitforResponse(int playerid);
#ifdef YGOPRO_SERVER_MODE
void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshRemoved(int player, int flag = 0x81fff, int use_cache = 1, DuelPlayer* dp = 0);
#else
void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1); void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1);
void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1); void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1);
void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1); void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1);
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1); void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
#endif
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static byte* ScriptReaderEx(const char* script_name, int* slen); static byte* ScriptReaderEx(const char* script_name, int* slen);
...@@ -51,6 +63,13 @@ protected: ...@@ -51,6 +63,13 @@ 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;
#ifdef YGOPRO_SERVER_MODE
DuelPlayer* cache_recorder;
DuelPlayer* replay_recorder;
int lp[2];
unsigned char turn_player;
unsigned short phase;
#endif
Replay last_replay; Replay last_replay;
bool match_mode; bool match_mode;
int match_kill; int match_kill;
......
#include "single_mode.h" #include "single_mode.h"
#include "duelclient.h" #include "duelclient.h"
#include "game.h" #include "game.h"
#include "../ocgcore/duel.h" #include "../ocgcore/common.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
......
This diff is collapsed.
...@@ -27,15 +27,27 @@ public: ...@@ -27,15 +27,27 @@ public:
virtual int Analyze(char* msgbuffer, unsigned int len); virtual int Analyze(char* msgbuffer, unsigned int len);
virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len); virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len);
virtual void TimeConfirm(DuelPlayer* dp); virtual void TimeConfirm(DuelPlayer* dp);
#ifdef YGOPRO_SERVER_MODE
virtual void RequestField(DuelPlayer* dp);
#endif
virtual void EndDuel(); virtual void EndDuel();
void DuelEndProc(); void DuelEndProc();
void WaitforResponse(int playerid); void WaitforResponse(int playerid);
#ifdef YGOPRO_SERVER_MODE
void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1, DuelPlayer* dp = 0);
void RefreshRemoved(int player, int flag = 0x81fff, int use_cache = 1, DuelPlayer* dp = 0);
#else
void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1); void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1);
void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1); void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1);
void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1); void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1);
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1); void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
#endif
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static byte* ScriptReaderEx(const char* script_name, int* slen); static byte* ScriptReaderEx(const char* script_name, int* slen);
...@@ -47,6 +59,13 @@ protected: ...@@ -47,6 +59,13 @@ protected:
DuelPlayer* pplayer[4]; DuelPlayer* pplayer[4];
DuelPlayer* cur_player[2]; DuelPlayer* cur_player[2];
std::set<DuelPlayer*> observers; std::set<DuelPlayer*> observers;
#ifdef YGOPRO_SERVER_MODE
DuelPlayer* cache_recorder;
DuelPlayer* replay_recorder;
int lp[2];
int turn_player;
int phase;
#endif
bool ready[4]; bool ready[4];
Deck pdeck[4]; Deck pdeck[4];
int deck_error[4]; int deck_error[4];
......
Subproject commit 7da0970abec7155fe7de65e86e905a971c56db79 Subproject commit f3fb923b305735f09080866d57f14e2895f55da6
project "event"
kind "StaticLib"
includedirs { "include", "compat" }
files { "event.c", "evthread.c", "buffer.c", "bufferevent.c", "bufferevent_sock.c",
"bufferevent_filter.c", "bufferevent_pair.c", "listener.c", "bufferevent_ratelim.c",
"evmap.c", "log.c", "evutil.c", "evutil_rand.c", "strlcpy.c", "signal.c",
"event_tagging.c", "http.c", "evdns.c", "evrpc.c" }
configuration "windows"
files { "win32select.c", "evthread_win32.c", "buffer_iocp.c", "event_iocp.c", "bufferevent_async.c" }
1 ICON "ygopro.ico"
1 VERSIONINFO
FILEVERSION 1, 0, 33, 12
PRODUCTVERSION 1, 0, 33, 12
FILEOS 0x4
FILETYPE 0x1
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404b0"
BEGIN
VALUE "FileDescription", "YGOPRO Server Mode ver.233"
VALUE "InternalName", "YGOPRO Server Mode"
VALUE "LegalCopyright", "Copyright (C) 2016 Fluorohydride"
VALUE "OriginalFilename", "ygopro.exe"
VALUE "ProductName", "YGOPRO Server Mode"
VALUE "FileVersion", "1.033.C.233"
VALUE "ProductVersion", "1.033.C.233"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200
END
END
project "lua"
kind "StaticLib"
files { "*.c", "*.h" }
removefiles { "luac.c" }
project "sqlite3"
kind "StaticLib"
files { "sqlite3.c", "sqlite3.h" }
solution "ygo"
location "build"
language "C++"
objdir "obj"
configurations { "Release", "Debug" }
configuration "windows"
defines { "WIN32", "_WIN32" }
configuration "linux"
defines { "LUA_USE_LINUX" }
configuration "Release"
targetdir "bin/release"
configuration "Debug"
symbols "On"
defines "_DEBUG"
targetdir "bin/debug"
configuration { "Release", "vs*" }
optimize "Speed"
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 a7ac36907a08e612671914681a808af971290bc9 Subproject commit 8a38d1c2d9b1c7a9415cf1e4e3155ec44d445b39
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