Commit b7700129 authored by nanahira's avatar nanahira

merge

parents dcd83cdb 803929d6
language: cpp language: cpp
os:
- linux
- osx
sudo: required
dist: xenial dist: xenial
osx_image: xcode8 git:
submodules: false
addons: addons:
ssh_known_hosts: ssh_known_hosts:
- github.com - github.com
apt: apt:
# sources:
# - ubuntu-toolchain-r-test
packages: packages:
- libfreetype6-dev # - gcc-6
# - g++-6
- libevent-dev - libevent-dev
- libsqlite3-dev - libsqlite3-dev
- libirrlicht-dev
- libgl1-mesa-dev
- libglu-dev
- p7zip-full
env: env:
- USE_IRRKLANG=1 - DATABASE_FILE=cards.cdb
before_install: before_install:
- git submodule update --init --recursive - git submodule update --init --recursive
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then #- sudo ln -s /usr/bin/gcc-6 /usr/local/bin/gcc
brew update > /dev/null; #- sudo ln -s /usr/bin/g++-6 /usr/local/bin/g++
brew install freetype libevent sqlite p7zip dylibbundler > /dev/null; #- g++ --version
fi - wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-linux.tar.gz | tar zfx -
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
curl --location --retry 5 https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-macosx.tar.gz | tar zfx -;
fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
curl --location --retry 5 https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-linux.tar.gz | tar zfx -;
fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name http://downloads.sourceforge.net/irrlicht/irrlicht-1.8.4.zip; unzip irrlicht-1.8.4.zip ; cd irrlicht-1.8.4/ ; cp ../premake/irrlicht/irrlicht-mac.patch . ; patch -p1 < irrlicht-mac.patch ; cd source/Irrlicht/MacOSX/ ; xcodebuild -project MacOSX.xcodeproj ; cp build/Release/libIrrlicht.a /usr/local/lib/ ; cp -r ../../../include /usr/local/include/irrlicht ; cd ../../../../ ; fi
- git clone --depth=1 https://$NANAHIRA@github.com/purerosefallen/irrklang
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
sudo cp -rf irrklang/bin/macosx-gcc/libirrklang.dylib /usr/local/lib/;
fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
cp -rf irrklang/bin/linux-gcc-64/libIrrKlang.so .;
fi
script: script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./premake5 gmake --cc=clang; fi - ./premake5 gmake
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./premake5 gmake; fi
- cd build - cd build
- make config=release ygopro -j4 - make config=release
- cd ..
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv -f bin/release/ygopro ./; strip ygopro;
fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
mkdir -p ygopro.app/Contents/MacOS;
mv -f bin/release/ygopro ygopro.app/Contents/MacOS;
dylibbundler -x ygopro.app/Contents/MacOS/ygopro -b -d ygopro.app/Contents/Frameworks/ -p @executable_path/../Frameworks/ -cd;
strip ygopro.app/Contents/MacOS/ygopro; mkdir ygopro.app/Contents/Resources;
mv -f premake/gframe/ygopro.icns ygopro.app/Contents/Resources/Icon.icns;
defaults write "$PWD/ygopro.app/Contents/Info.plist" "CFBundleIconFile" "Icon.icns";
defaults write "$PWD/ygopro.app/Contents/Info.plist" "CFBundleIdentifier" "moe.mycard.ygopro";
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
echo $CERTIFICATE | base64 --decode --output cert.p12;
security create-keychain -p "" build.keychain; security unlock-keychain -p "" build.keychain;
security import cert.p12 -k build.keychain -P "$CERTIFICATE_PASSWORD" -T /usr/bin/codesign;
codesign --deep --keychain build.keychain --sign "$(security find-identity -v -p
codesigning build.keychain | head -1 | grep -o '".*"' | tr -d '"')" ygopro.app;
fi
fi
before_deploy:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
7z a -mx9 -xr!.git* KoishiPro-$TRAVIS_OS_NAME-$TRAVIS_TAG.zip ygopro libIrrKlang.so;
fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
7z a -mx9 -xr!.git* KoishiPro-$TRAVIS_OS_NAME-$TRAVIS_TAG.zip ygopro.app;
fi
- curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/HuangYuNan/ygopro222-images/archive/master.zip
- 7z x -y ygopro222-images-master.zip > /dev/null
- mv -f ygopro222-images-master pics
- curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/moecube/ygopro-starter-pack/archive/master.zip
- 7z x -y ygopro-starter-pack-master.zip > /dev/null
- cp -rf ygopro-starter-pack-master/* .
- rm -rf pics/thumbnail pics/*.db
- git clone --depth=1 https://$NANAHIRA@github.com/purerosefallen/fonts
- curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/windbot/releases/download/latest/WindBot.7z
- 7z x -y WindBot.7z > /dev/null
- mv -f WindBot windbot
- curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/windbot/raw/master/BotWrapper/BotWrapper.sh
- mv -f BotWrapper.sh bot
- chmod +x bot
- cd sound
- bash -c "grep '.wav' files.txt | xargs -I {} curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/ygopro-222DIY-data/raw/master/sound/{} ; exit 0"
- cd .. - cd ..
- mv -f ./bin/release/ygopro .
- strip ygopro
- mkdir replay
- git clone --depth=1 https://github.com/purerosefallen/ygopro-database - echo "select id from datas;" | sqlite3 $DATABASE_FILE | xargs -I {} ./ygopro {} 2>&1 | tee ./redtext.txt
- mv -f ygopro-database/locales . - bash -c "exit $(cat ./redtext.txt | wc -l)"
\ No newline at end of file
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
7z a -mx9 -xr!.git* KoishiPro-$TRAVIS_OS_NAME-full-$TRAVIS_TAG.zip ygopro libIrrKlang.so LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures fonts skin deck single pics sound windbot locales bot.conf bot > /dev/null;
fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
7z a -mx9 -xr!.git* KoishiPro-$TRAVIS_OS_NAME-full-$TRAVIS_TAG.zip ygopro.app LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures fonts skin deck single pics sound windbot locales bot.conf bot > /dev/null;
fi
deploy:
provider: releases
file:
- KoishiPro-$TRAVIS_OS_NAME-$TRAVIS_TAG.zip
- KoishiPro-$TRAVIS_OS_NAME-full-$TRAVIS_TAG.zip
skip_cleanup: true
overwrite: true
on:
tags: true
api-key: $NANAHIRA
## 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}' version: '{build}'
environment: skip_tags: true
irrklang_pro: 1
access_token:
secure: EQ9miMjfX/QAoBvgc6D+JLmHatLyxOEKZ/uo68QijxWW5Gp4MzB/pOH9+u2GlDVO
install: install:
- git submodule update --init --recursive - git submodule update --init --recursive
# environment and system dependency # 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-alpha13/premake-5.0.0-alpha13-windows.zip ; exit 0" - 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-alpha13/premake-5.0.0-alpha13-windows.zip ; exit 0"
- 7z x -y premake-5.0.0-alpha13-windows.zip - 7z x premake-5.0.0-alpha13-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" - 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 - tar xf libevent-2.0.22-stable.tar.gz
- move libevent-2.0.22-stable event - move libevent-2.0.22-stable event
- xcopy /E event\WIN32-Code event\include - xcopy /E event\WIN32-Code event\include
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name http://downloads.sourceforge.net/freetype/freetype-2.9.1.tar.bz2 ; exit 0"
- tar xf freetype-2.9.1.tar.bz2
- move freetype-2.9.1 freetype
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name http://downloads.sourceforge.net/irrlicht/irrlicht-1.8.4.zip ; exit 0"
- 7z x -y irrlicht-1.8.4.zip
- md irrlicht
- move irrlicht-1.8.4\source\Irrlicht irrlicht\src
- move irrlicht-1.8.4\include irrlicht\include
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://www.sqlite.org/2018/sqlite-amalgamation-3240000.zip ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://www.sqlite.org/2018/sqlite-amalgamation-3240000.zip ; exit 0"
- 7z x -y sqlite-amalgamation-3240000.zip - 7z x -y sqlite-amalgamation-3240000.zip
- move sqlite-amalgamation-3240000 sqlite3 - move sqlite-amalgamation-3240000 sqlite3
- git clone --depth=1 https://%access_token%@github.com/purerosefallen/irrklang - appveyor DownloadFile https://github.com/tronkko/dirent/raw/master/include/dirent.h
- move dirent.h gframe\
# let premake happy # let premake happy
- cp -rf premake/* . - xcopy /E premake\* .
# patch irrlicht & ikpmp3
- patch -p0 < irrlicht\irrlicht.patch
# premake # premake
- premake5 vs2015 - premake5 vs2015
...@@ -49,51 +34,24 @@ build: ...@@ -49,51 +34,24 @@ build:
parallel: true parallel: true
after_build: after_build:
- mv -f bin/release/ygopro.exe . - ps: move bin\release\ygopro.exe .
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/windbot/releases/download/latest/WindBot.7z ; exit 0"
- 7z x -y WindBot.7z
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/HuangYuNan/ygopro222-images/archive/master.zip ; exit 0"
- 7z x -y ygopro222-images-master.zip
- mv -f ygopro222-images-master pics
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/update-koishipro/archive/master.zip ; exit 0"
- 7z x -y update-koishipro-master.zip
- mv -f update-koishipro-master update-koishipro
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/moecube/ygopro-starter-pack/archive/master.zip ; exit 0"
- 7z x -y ygopro-starter-pack-master.zip
- cp -rf ygopro-starter-pack-master/* .
- cd sound
- bash -c "grep '.wav' files.txt | xargs -I {} curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/ygopro-222DIY-data/raw/master/sound/{} ; exit 0"
- cd ..
- rm -rf pics/thumbnail pics/*.db
- git clone --depth=1 https://github.com/purerosefallen/ygopro-database
- mv -f ygopro-database/locales .
- git clone --depth=1 https://%access_token%@github.com/purerosefallen/fonts
- 7z a -mx9 -xr!.git* KoishiPro-%APPVEYOR_REPO_TAG_NAME%.7z ygopro.exe LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures skin deck single pics sound update-koishipro locales fonts WindBot Bot.exe bot.conf
test: off test: off
artifacts:
- path: ygopro.exe
name: ygopro server mode
deploy: deploy:
release: win
description: 'Automatic build commit $(APPVEYOR_REPO_COMMIT) $(APPVEYOR_REPO_COMMIT_TIMESTAMP)' description: 'Automatic build commit $(APPVEYOR_REPO_COMMIT) $(APPVEYOR_REPO_COMMIT_TIMESTAMP)'
provider: GitHub provider: GitHub
force_update: true force_update: true
auth_token: $(access_token) auth_token:
secure: EQ9miMjfX/QAoBvgc6D+JLmHatLyxOEKZ/uo68QijxWW5Gp4MzB/pOH9+u2GlDVO
on: on:
appveyor_repo_tag: true branch: server
artifacts:
- path: ygopro.exe
name: ygopro client
- path: KoishiPro-$(APPVEYOR_REPO_TAG_NAME).7z
name: ygopro full repack
cache: cache:
- premake-5.0.0-alpha13-windows.zip - premake-5.0.0-alpha13-windows.zip
......
...@@ -48,6 +48,7 @@ typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer ...@@ -48,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;
...@@ -120,6 +121,7 @@ public: ...@@ -120,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
}; };
} }
......
...@@ -1457,25 +1457,10 @@ void ClientField::UpdateDeclarableCodeType(bool enter) { ...@@ -1457,25 +1457,10 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
bool try_cache = false; if((pname[0] == 0 || pname[1] == 0) && !enter)
if(pname[0] == 0 || pname[1] == 0) {
if(!enter)
return; return;
try_cache = true;
}
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
if(try_cache && mainGame->dInfo.announce_cache.size()) {
for(int i = 0; i < mainGame->dInfo.announce_cache.size(); ++i) {
unsigned int cache_code = mainGame->dInfo.announce_cache[i];
if(dataManager.GetString(cache_code, &cstr) && dataManager.GetData(cache_code, &cd) && is_declarable(cd, declarable_type)) {
mainGame->lstANCard->addItem(cstr.name.c_str());
ancard.push_back(cache_code);
}
}
if(ancard.size())
return;
}
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if(cit->second.name.find(pname) != std::wstring::npos) { if(cit->second.name.find(pname) != std::wstring::npos) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
...@@ -1504,25 +1489,10 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) { ...@@ -1504,25 +1489,10 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
bool try_cache = false; if((pname[0] == 0 || pname[1] == 0) && !enter)
if(pname[0] == 0 || pname[1] == 0) {
if(!enter)
return; return;
try_cache = true;
}
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
if(try_cache && mainGame->dInfo.announce_cache.size()) {
for(int i = 0; i < mainGame->dInfo.announce_cache.size(); ++i) {
unsigned int cache_code = mainGame->dInfo.announce_cache[i];
if(dataManager.GetString(cache_code, &cstr) && dataManager.GetData(cache_code, &cd) && is_declarable(cd, opcode)) {
mainGame->lstANCard->addItem(cstr.name.c_str());
ancard.push_back(cache_code);
}
}
if(ancard.size())
return;
}
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
if(cit->second.name.find(pname) != std::wstring::npos) { if(cit->second.name.find(pname) != std::wstring::npos) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
......
...@@ -55,6 +55,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -55,6 +55,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return swprintf(buf, N, fmt, args...); return swprintf(buf, N, fmt, args...);
} }
#ifndef YGOPRO_SERVER_MODE
#include <irrlicht.h> #include <irrlicht.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
...@@ -65,6 +66,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -65,6 +66,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#endif #endif
#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>
...@@ -77,12 +79,14 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -77,12 +79,14 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.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 unsigned short PRO_VERSION; extern 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);
......
...@@ -601,7 +601,6 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -601,7 +601,6 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->RefreshTimeDisplay(); mainGame->RefreshTimeDisplay();
mainGame->dInfo.time_player = 2; mainGame->dInfo.time_player = 2;
mainGame->dInfo.isReplaySwapped = false; mainGame->dInfo.isReplaySwapped = false;
mainGame->dInfo.announce_cache.clear();
mainGame->is_building = false; mainGame->is_building = false;
mainGame->wCardImg->setVisible(true); mainGame->wCardImg->setVisible(true);
mainGame->wInfos->setVisible(true); mainGame->wInfos->setVisible(true);
...@@ -680,7 +679,6 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -680,7 +679,6 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true; mainGame->dInfo.isFinished = true;
mainGame->dInfo.announce_cache.clear();
mainGame->is_building = false; mainGame->is_building = false;
mainGame->wDeckEdit->setVisible(false); mainGame->wDeckEdit->setVisible(false);
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
......
...@@ -349,7 +349,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -349,7 +349,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(sel == -1) if(sel == -1)
break; break;
DuelClient::SetResponseI(ancard[sel]); DuelClient::SetResponseI(ancard[sel]);
mainGame->dInfo.announce_cache.insert(mainGame->dInfo.announce_cache.begin(), ancard[sel]);
mainGame->HideElement(mainGame->wANCard, true); mainGame->HideElement(mainGame->wANCard, true);
break; break;
} }
......
#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"
...@@ -10,6 +15,7 @@ ...@@ -10,6 +15,7 @@
#include "netserver.h" #include "netserver.h"
#include "single_mode.h" #include "single_mode.h"
#include <sstream> #include <sstream>
#endif //YGOPRO_SERVER_MODE
#ifndef _WIN32 #ifndef _WIN32
#include <sys/types.h> #include <sys/types.h>
...@@ -27,6 +33,71 @@ namespace ygo { ...@@ -27,6 +33,71 @@ 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();
LoadBetaDB();
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
}
}
void Game::MainTestLoop(int code) {
LoadBetaDB();
LoadExpansionDB();
dataManager.LoadDB("cards.cdb");
fflush(stdout);
NetServer::InitTestCard(code);
}
void Game::LoadBetaDB() {
#ifdef _WIN32
char fpath[1000];
WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(L"./beta/*.cdb", &fdataw);
if(fh != INVALID_HANDLE_VALUE) {
do {
if(!(fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
char fname[780];
BufferIO::EncodeUTF8(fdataw.cFileName, fname);
sprintf(fpath, "./beta/%s", fname);
dataManager.LoadDB(fpath);
}
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
}
#else
DIR * dir;
struct dirent * dirp;
if((dir = opendir("./beta/")) != NULL) {
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0)
continue;
char filepath[1000];
sprintf(filepath, "./beta/%s", dirp->d_name);
dataManager.LoadDB(filepath);
}
closedir(dir);
}
#endif
}
#else //YGOPRO_SERVER_MODE
bool Game::Initialize() { bool Game::Initialize() {
srand(time(0)); srand(time(0));
initUtils(); initUtils();
...@@ -981,6 +1052,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu ...@@ -981,6 +1052,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() {
LoadExpansionDBDirectry("./expansions"); LoadExpansionDBDirectry("./expansions");
#ifdef _WIN32 #ifdef _WIN32
...@@ -1086,6 +1158,7 @@ void Game::LoadExpansionStringsDirectry(const char* path) { ...@@ -1086,6 +1158,7 @@ void Game::LoadExpansionStringsDirectry(const char* path) {
sprintf(fpath, "%s/strings.conf", path); sprintf(fpath, "%s/strings.conf", path);
dataManager.LoadStrings(fpath); dataManager.LoadStrings(fpath);
} }
#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
...@@ -1797,8 +1870,12 @@ void Game::ClearChatMsg() { ...@@ -1797,8 +1870,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);
...@@ -1809,6 +1886,7 @@ void Game::AddDebugMsg(char* msg) ...@@ -1809,6 +1886,7 @@ void Game::AddDebugMsg(char* msg)
sprintf(msgbuf, "[Script Error]: %s", msg); sprintf(msgbuf, "[Script Error]: %s", msg);
ErrorLog(msgbuf); ErrorLog(msgbuf);
} }
#endif //YGOPRO_SERVER_MODE
} }
void Game::ErrorLog(char* msg) { void Game::ErrorLog(char* msg) {
FILE* fp = fopen("error.log", "at"); FILE* fp = fopen("error.log", "at");
...@@ -1845,9 +1923,14 @@ bool Game::MakeDirectory(const std::string folder) { ...@@ -1845,9 +1923,14 @@ bool Game::MakeDirectory(const std::string folder) {
void Game::initUtils() { void Game::initUtils() {
//user files //user files
MakeDirectory("replay"); MakeDirectory("replay");
MakeDirectory("screenshots");
//cards from extra pack //cards from extra pack
MakeDirectory("expansions"); MakeDirectory("expansions");
#ifdef YGOPRO_SERVER_MODE
//special scripts
MakeDirectory("specials");
MakeDirectory("beta");
#else
MakeDirectory("screenshots");
//files in ygopro-starter-pack //files in ygopro-starter-pack
MakeDirectory("deck"); MakeDirectory("deck");
MakeDirectory("single"); MakeDirectory("single");
...@@ -1884,7 +1967,9 @@ void Game::initUtils() { ...@@ -1884,7 +1967,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]);
...@@ -2287,5 +2372,6 @@ void Game::SetCursor(ECURSOR_ICON icon) { ...@@ -2287,5 +2372,6 @@ void Game::SetCursor(ECURSOR_ICON icon) {
cursor->setActiveIcon(icon); cursor->setActiveIcon(icon);
} }
} }
#endif //YGOPRO_SERVER_MODE
} }
...@@ -2,16 +2,21 @@ ...@@ -2,16 +2,21 @@
#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"
#include "CGUISkinSystem/CGUISkinSystem.h" #include "CGUISkinSystem/CGUISkinSystem.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;
...@@ -92,7 +97,6 @@ struct DuelInfo { ...@@ -92,7 +97,6 @@ struct DuelInfo {
wchar_t str_card_count[2][16]; wchar_t str_card_count[2][16];
video::SColor card_count_color[2]; video::SColor card_count_color[2];
bool isReplaySwapped; bool isReplaySwapped;
std::vector<unsigned int> announce_cache;
}; };
struct BotInfo { struct BotInfo {
...@@ -114,11 +118,21 @@ struct FadingUnit { ...@@ -114,11 +118,21 @@ 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 MainTestLoop(int code);
void LoadExpansionDB();
void LoadBetaDB();
void AddDebugMsg(char* msgbuf);
bool MakeDirectory(const std::string folder);
void initUtils();
#else
void MainLoop(); void MainLoop();
void RefreshTimeDisplay(); void RefreshTimeDisplay();
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);
...@@ -560,9 +574,15 @@ public: ...@@ -560,9 +574,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
} }
...@@ -747,7 +767,9 @@ extern Game* mainGame; ...@@ -747,7 +767,9 @@ extern Game* mainGame;
#define TEXTURE_ATTACK 5 #define TEXTURE_ATTACK 5
#define TEXTURE_ACTIVATE 6 #define TEXTURE_ACTIVATE 6
#ifndef DEFAULT_DUEL_RULE
#define DEFAULT_DUEL_RULE 4 #define DEFAULT_DUEL_RULE 4
#endif
#define CARD_ARTWORK_VERSIONS_OFFSET 10 #define CARD_ARTWORK_VERSIONS_OFFSET 10
#endif // GAME_H #endif // GAME_H
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,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"";
...@@ -20,6 +21,7 @@ void ClickButton(irr::gui::IGUIElement* btn) { ...@@ -20,6 +21,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
...@@ -57,6 +59,59 @@ int main(int argc, char* argv[]) { ...@@ -57,6 +59,59 @@ 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 == 2) {
int code = atoi(argv[1]);
ygo::mainGame = &_game;
ygo::mainGame->MainTestLoop(code);
return 0;
} else
if(argc > 2) {
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;
...@@ -184,5 +239,6 @@ int main(int argc, char* argv[]) { ...@@ -184,5 +239,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,56 @@ char NetServer::net_server_read[0x2000]; ...@@ -13,7 +13,56 @@ 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);
}
void NetServer::InitTestCard(int code) {
DuelMode* test_duel = new SingleDuel(false);
test_duel->TestCard(code);
}
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 +83,15 @@ bool NetServer::StartServer(unsigned short port) { ...@@ -34,7 +83,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 +230,11 @@ void NetServer::DisconnectPlayer(DuelPlayer* dp) { ...@@ -173,7 +230,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 +364,14 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) { ...@@ -303,6 +364,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,14 @@ private: ...@@ -23,7 +25,14 @@ 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 void InitTestCard(int code);
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 +77,14 @@ public: ...@@ -68,6 +77,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,7 +134,13 @@ public: ...@@ -134,7 +134,13 @@ 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() {};
#ifdef YGOPRO_SERVER_MODE
virtual void TestCard(int code) {};
#endif
public: public:
event* etimer; event* etimer;
...@@ -175,6 +181,9 @@ public: ...@@ -175,6 +181,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 +205,9 @@ public: ...@@ -196,6 +205,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/**" local mr=os.getenv("YGOPRO_DEFAULT_DUEL_RULE")
if mr and tonumber(mr) then defines { "DEFAULT_DUEL_RULE="..tonumber(mr) } end
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"}
if USE_IRRKLANG then
defines { "YGOPRO_USE_IRRKLANG" }
links { "ikpmp3" }
includedirs { "../irrklang/include" }
if IRRKLANG_PRO then
defines { "IRRKLANG_STATIC" }
end
end
if os.getenv("YGOPRO_COMPAT_MYCARD") then
defines { "YGOPRO_COMPAT_MYCARD" }
end
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
links { "irrKlang" }
libdirs { "../irrklang/lib/Win32-visualStudio" }
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=c++14", "-fno-rtti" } buildoptions { "-std=c++1y", "-fno-rtti" }
configuration "not windows" configuration "not windows"
includedirs { "/usr/include/irrlicht", "/usr/include/freetype2" } links { "event_pthreads", "dl", "pthread" }
excludes { "COSOperator.*" }
links { "event_pthreads", "GL", "dl", "pthread" }
configuration "linux"
if USE_IRRKLANG then
links { "IrrKlang" }
linkoptions{ "-Wl,-rpath=./" }
libdirs { "../irrklang/bin/linux-gcc-64" }
end
configuration "macosx"
if USE_IRRKLANG then
links { "irrklang" }
libdirs { "../irrklang/bin/macosx-gcc" }
end
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
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;
......
This diff is collapsed.
...@@ -27,15 +27,30 @@ public: ...@@ -27,15 +27,30 @@ 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();
#ifdef YGOPRO_SERVER_MODE
virtual void TestCard(int code);
#endif
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 = 0xe81fff, 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 = 0xe81fff, int use_cache = 1); void RefreshSzone(int player, int flag = 0xe81fff, 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);
...@@ -52,6 +67,12 @@ protected: ...@@ -52,6 +67,12 @@ 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;
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;
......
...@@ -56,7 +56,6 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -56,7 +56,6 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->dInfo.clientname[0] = 0; mainGame->dInfo.clientname[0] = 0;
mainGame->dInfo.player_type = 0; mainGame->dInfo.player_type = 0;
mainGame->dInfo.turn = 0; mainGame->dInfo.turn = 0;
mainGame->dInfo.announce_cache.clear();
char filename[256]; char filename[256];
size_t slen = 0; size_t slen = 0;
if(open_file) { if(open_file) {
......
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 = 0xe81fff, 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 = 0xe81fff, int use_cache = 1); void RefreshSzone(int player, int flag = 0xe81fff, 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);
...@@ -48,6 +60,12 @@ protected: ...@@ -48,6 +60,12 @@ 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 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];
......
premake/gframe/ygopro.ico

159 KB | W: | H:

premake/gframe/ygopro.ico

17.1 KB | W: | H:

premake/gframe/ygopro.ico
premake/gframe/ygopro.ico
premake/gframe/ygopro.ico
premake/gframe/ygopro.ico
  • 2-up
  • Swipe
  • Onion skin
...@@ -11,11 +11,11 @@ BLOCK "StringFileInfo" ...@@ -11,11 +11,11 @@ BLOCK "StringFileInfo"
BEGIN BEGIN
BLOCK "080404b0" BLOCK "080404b0"
BEGIN BEGIN
VALUE "FileDescription", "KoishiPro" VALUE "FileDescription", "YGOPRO Server Mode ver.Koishi"
VALUE "InternalName", "KoishiPro" VALUE "InternalName", "YGOPRO Server Mode"
VALUE "LegalCopyright", "Copyright (C) 2018 Nanahira" VALUE "LegalCopyright", "Copyright (C) 2018 Nanahira"
VALUE "OriginalFilename", "ygopro.exe" VALUE "OriginalFilename", "ygopro.exe"
VALUE "ProductName", "KoishiPro" VALUE "ProductName", "YGOPRO Server Mode"
VALUE "FileVersion", "1.034.6.Koishi" VALUE "FileVersion", "1.034.6.Koishi"
VALUE "ProductVersion", "1.034.6.Koishi" VALUE "ProductVersion", "1.034.6.Koishi"
END END
......
...@@ -2,7 +2,7 @@ solution "ygo" ...@@ -2,7 +2,7 @@ solution "ygo"
location "build" location "build"
language "C++" language "C++"
objdir "obj" objdir "obj"
startproject "ygopro" --startproject "ygopro"
configurations { "Release", "Debug" } configurations { "Release", "Debug" }
defines { "LUA_COMPAT_5_2" } defines { "LUA_COMPAT_5_2" }
...@@ -16,10 +16,10 @@ solution "ygo" ...@@ -16,10 +16,10 @@ solution "ygo"
configuration "macosx" configuration "macosx"
defines { "LUA_USE_MACOSX" } defines { "LUA_USE_MACOSX" }
includedirs { "/usr/local/include/*" } includedirs { "/usr/local/include", "/usr/local/include/*" }
libdirs { "/usr/local/lib", "/usr/X11/lib" } libdirs { "/usr/local/lib", "/usr/X11/lib" }
buildoptions { "-stdlib=libc++" } buildoptions { "-stdlib=libc++" }
links {"OpenGL.framework","Cocoa.framework","IOKit.framework"} links { "OpenGL.framework", "Cocoa.framework", "IOKit.framework" }
configuration "linux" configuration "linux"
defines { "LUA_USE_LINUX" } defines { "LUA_USE_LINUX" }
......
...@@ -2,20 +2,11 @@ solution "ygo" ...@@ -2,20 +2,11 @@ solution "ygo"
location "build" location "build"
language "C++" language "C++"
objdir "obj" objdir "obj"
if os.ishost("windows") or os.getenv("USE_IRRKLANG") then
USE_IRRKLANG = true
if os.getenv("irrklang_pro") then
IRRKLANG_PRO = true
end
end
configurations { "Release", "Debug" } configurations { "Release", "Debug" }
defines { "LUA_COMPAT_5_2" } defines { "LUA_COMPAT_5_2", "LUA_SAFE_MODE" }
configuration "windows" configuration "windows"
defines { "WIN32", "_WIN32", "WINVER=0x0501" } defines { "WIN32", "_WIN32" }
libdirs { "$(DXSDK_DIR)Lib/x86" }
entrypoint "mainCRTStartup"
toolset "v140_xp"
startproject "ygopro" startproject "ygopro"
configuration "bsd" configuration "bsd"
...@@ -35,7 +26,6 @@ solution "ygo" ...@@ -35,7 +26,6 @@ solution "ygo"
buildoptions { "-U_FORTIFY_SOURCE" } buildoptions { "-U_FORTIFY_SOURCE" }
configuration "Release" configuration "Release"
optimize "Speed"
targetdir "bin/release" targetdir "bin/release"
configuration "Debug" configuration "Debug"
...@@ -44,6 +34,7 @@ solution "ygo" ...@@ -44,6 +34,7 @@ solution "ygo"
targetdir "bin/debug" targetdir "bin/debug"
configuration { "Release", "vs*" } configuration { "Release", "vs*" }
optimize "Speed"
flags { "LinkTimeOptimization" } flags { "LinkTimeOptimization" }
staticruntime "On" staticruntime "On"
disablewarnings { "4244", "4267", "4838", "4577", "4819", "4018", "4996", "4477", "4091", "4305", "4828" } disablewarnings { "4244", "4267", "4838", "4577", "4819", "4018", "4996", "4477", "4091", "4305", "4828" }
...@@ -68,15 +59,12 @@ solution "ygo" ...@@ -68,15 +59,12 @@ solution "ygo"
configuration {"not vs*", "windows"} configuration {"not vs*", "windows"}
buildoptions { "-static-libgcc" } buildoptions { "-static-libgcc" }
startproject "ygopro"
include "lua" include "lua"
include "ocgcore" include "ocgcore"
include "gframe" include "gframe"
if os.ishost("windows") then if os.ishost("windows") then
include "event" include "event"
include "freetype"
include "irrlicht"
include "sqlite3" include "sqlite3"
end end
if USE_IRRKLANG then
include "ikpmp3"
end
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