Commit 9da2a4fd authored by nanahira's avatar nanahira

Merge branch 'server' into server-develop

parents 8e7ea6a9 104b1e14
...@@ -13,9 +13,8 @@ jobs: ...@@ -13,9 +13,8 @@ jobs:
matrix: matrix:
name: name:
- windows - windows
- windows-xp # - windows-irrklang
- windows-irrklang # - windows-no-dxsdk
- windows-no-dxsdk
- windows-x64 - windows-x64
# - windows-2025 # - windows-2025
include: include:
...@@ -23,20 +22,15 @@ jobs: ...@@ -23,20 +22,15 @@ jobs:
os: windows-2022 os: windows-2022
vs: vs2022 vs: vs2022
audiolib: miniaudio audiolib: miniaudio
- name: windows-xp # - name: windows-irrklang
os: windows-2019 # os: windows-2022
vs: vs2019 # vs: vs2022
audiolib: miniaudio # audiolib: irrklang
xp: true # - name: windows-no-dxsdk
- name: windows-irrklang # os: windows-2022
os: windows-2022 # vs: vs2022
vs: vs2022 # audiolib: miniaudio
audiolib: irrklang # nodxsdk: true
- name: windows-no-dxsdk
os: windows-2022
vs: vs2022
audiolib: miniaudio
nodxsdk: true
- name: windows-x64 - name: windows-x64
os: windows-2022 os: windows-2022
vs: vs2022 vs: vs2022
...@@ -44,7 +38,7 @@ jobs: ...@@ -44,7 +38,7 @@ jobs:
x64: true x64: true
# - name: windows-2025 # - name: windows-2025
# os: windows-2025 # os: windows-2025
# vs: vs2022 # vs: vs2025 # to be enabled after the release of Visual Studio 2025
# audiolib: miniaudio # audiolib: miniaudio
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
...@@ -88,11 +82,7 @@ jobs: ...@@ -88,11 +82,7 @@ jobs:
- name: Extract libevent - name: Extract libevent
run: | run: |
tar xf ${{ steps.libevent.outputs.filepath }} tar xf ${{ steps.libevent.outputs.filepath }}
<<<<<<< HEAD
move libevent-2.1.12-stable event move libevent-2.1.12-stable event
=======
move libevent-2.0.22-stable event
>>>>>>> 2d86d0c3cbe7c913204cb652b7c8e3faf00b0047
- name: Download freetype - name: Download freetype
id: freetype id: freetype
...@@ -237,7 +227,7 @@ jobs: ...@@ -237,7 +227,7 @@ jobs:
- name: Use premake to generate Visual Studio solution - name: Use premake to generate Visual Studio solution
run: | run: |
.\premake5.exe ${{ matrix.vs }} --audio-lib=${{ matrix.audiolib }} ${{ matrix.xp && '--winxp-support' || '' }} .\premake5.exe ${{ matrix.vs }} --audio-lib=${{ matrix.audiolib }}
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2 uses: microsoft/setup-msbuild@v2
...@@ -470,12 +460,6 @@ jobs: ...@@ -470,12 +460,6 @@ jobs:
make -j 4 config=release make -j 4 config=release
cd .. cd ..
- name: Strip symbols
run: |
cd bin/release
strip YGOPro
cd ../..
- name: Upload build artifacts - name: Upload build artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
...@@ -489,18 +473,18 @@ jobs: ...@@ -489,18 +473,18 @@ jobs:
matrix: matrix:
name: name:
- macos-13-intel - macos-13-intel
- macos-13-arm-cross-compile-static-link # - macos-13-arm-cross-compile-static-link
- macos-13-universal-static-link - macos-13-universal-static-link
- macos-15-arm - macos-15-arm
- macos-15-intel-cross-compile-static-link # - macos-15-intel-cross-compile-static-link
- macos-15-universal-static-link # - macos-15-universal-static-link
include: include:
- name: macos-13-intel - name: macos-13-intel
os: macos-13 os: macos-13
- name: macos-13-arm-cross-compile-static-link # - name: macos-13-arm-cross-compile-static-link
os: macos-13 # os: macos-13
cross-build-arm: true # cross-build-arm: true
static-link: true # static-link: true
- name: macos-13-universal-static-link - name: macos-13-universal-static-link
os: macos-13 os: macos-13
cross-build-intel: true cross-build-intel: true
...@@ -508,15 +492,15 @@ jobs: ...@@ -508,15 +492,15 @@ jobs:
static-link: true static-link: true
- name: macos-15-arm - name: macos-15-arm
os: macos-15 os: macos-15
- name: macos-15-intel-cross-compile-static-link # - name: macos-15-intel-cross-compile-static-link
os: macos-15 # os: macos-15
cross-build-intel: true # cross-build-intel: true
static-link: true # static-link: true
- name: macos-15-universal-static-link # - name: macos-15-universal-static-link
os: macos-15 # os: macos-15
cross-build-intel: true # cross-build-intel: true
cross-build-arm: true # cross-build-arm: true
static-link: true # static-link: true
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
......
name: Automated Test Build (Server Mode)
on:
push:
branches: [ "server" ]
pull_request:
branches: [ "server" ]
jobs:
build-windows:
strategy:
fail-fast: false
matrix:
name:
- windows
- windows-x64
- windows-ygopro2-ai-server
# - windows-2025
include:
- name: windows
os: windows-2022
vs: vs2022
- name: windows-x64
os: windows-2022
vs: vs2022
x64: true
# - name: windows-2025
# os: windows-2025
# vs: vs2025 # to be enabled after the release of Visual Studio 2025
- name: windows-ygopro2-ai-server
os: windows-2022
vs: vs2022
x64: true
ygopro2: true
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
- name: Update submodules
run: |
cd ocgcore
git checkout master
git pull origin master
cd ..
# cd script
# git checkout master
# git pull origin master
# cd ..
- name: Download premake
id: premake
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/premake/premake-core/releases/download/v5.0.0-beta6/premake-5.0.0-beta6-windows.zip
filename: premake5.zip
- name: Extract premake
run: |
7z x ${{ steps.premake.outputs.filepath }}
- name: Download libevent
id: libevent
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
filename: libevent.tar.gz
- name: Extract libevent
run: |
tar xf ${{ steps.libevent.outputs.filepath }}
move libevent-2.0.22-stable event
- name: Download lua
id: lua
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.lua.org/ftp/lua-5.4.7.tar.gz
- name: Extract lua
run: |
tar xf ${{ steps.lua.outputs.filepath }}
move lua-5.4.7 lua
- name: Download sqlite
id: sqlite
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.sqlite.org/2025/sqlite-amalgamation-3490100.zip
- name: Extract sqlite
run: |
7z x ${{ steps.sqlite.outputs.filepath }}
move sqlite-amalgamation-3490100 sqlite3
- name: Download irrlicht
if: matrix.ygopro2 == true
run: |
git clone --depth=1 https://github.com/mercury233/irrlicht
- name: Copy premake files
run: |
xcopy /E premake\* .
xcopy /E resource\* .
- name: Use premake to generate Visual Studio solution
run: |
.\premake5.exe ${{ matrix.vs }} ${{ matrix.ygopro2 && '--server-pro2-support' || '' }}
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build solution
run: |
MSBuild.exe build\YGOPro.sln /m /p:Configuration=Release /p:Platform=${{ matrix.x64 && 'x64' || 'Win32' }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: YGOPro-Server-${{ matrix.name }}
path: |
bin/release/x86/ygopro.exe
bin/release/x64/ygopro.exe
bin/release/x64/AI.Server.exe
build-linux:
strategy:
fail-fast: false
matrix:
name:
- ubuntu-22
- ubuntu-24
- ubuntu-static-link
- ubuntu-zip-support
include:
- name: ubuntu-22
os: ubuntu-22.04
premake-version: 5.0.0-beta4
- name: ubuntu-24
os: ubuntu-24.04
premake-version: 5.0.0-beta6
- name: ubuntu-static-link
os: ubuntu-22.04
premake-version: 5.0.0-beta4
static-link: true
- name: ubuntu-zip-support
os: ubuntu-22.04
premake-version: 5.0.0-beta4
zip-support: true
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
- name: Update submodules
run: |
cd ocgcore
git checkout master
git pull origin master
cd ..
# cd script
# git checkout master
# git pull origin master
# cd ..
- name: Install dependencies
if: matrix.static-link != true
run: |
sudo apt-get update
sudo apt-get install -y libevent-dev libsqlite3-dev
- name: Download premake
id: premake
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/premake/premake-core/releases/download/v${{ matrix.premake-version }}/premake-${{ matrix.premake-version }}-linux.tar.gz
filename: premake5.tar.gz
- name: Extract premake
run: |
tar xf ${{ steps.premake.outputs.filepath }}
chmod +x ./premake5
- name: Download libevent
if: matrix.static-link == true
id: libevent
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
filename: libevent.tar.gz
- name: Extract libevent
if: matrix.static-link == true
run: |
tar xf ${{ steps.libevent.outputs.filepath }}
mv libevent-2.1.12-stable event
- name: Configure libevent
if: matrix.static-link == true
run: |
cd event
./configure --disable-openssl --enable-static=yes --enable-shared=no
sed -f make-event-config.sed < config.h > ./include/event2/event-config.h
cd ..
- name: Download lua
id: lua
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.lua.org/ftp/lua-5.4.7.tar.gz
- name: Extract lua
run: |
tar xf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua
- name: Download sqlite
if: matrix.static-link == true
id: sqlite
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.sqlite.org/2025/sqlite-amalgamation-3490100.zip
- name: Extract sqlite
if: matrix.static-link == true
run: |
7z x ${{ steps.sqlite.outputs.filepath }}
mv sqlite-amalgamation-3490100 sqlite3
- name: Download irrlicht
if: matrix.zip-support == true
run: |
git clone --depth=1 https://github.com/mercury233/irrlicht
- name: Copy premake files
run: |
cp -r premake/* .
cp -r resource/* .
- name: Use premake to generate make files
run: |
./premake5 gmake ${{ matrix.zip-support && '--server-zip-support' || '' }} \
${{ matrix.static-link && '--build-sqlite --build-event' || '' }}
- name: Make
run: |
cd build
make -j 4 config=release
cd ..
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: YGOPro-Server-${{ matrix.name }}
path: |
bin/release/ygopro
publish:
needs: [build-windows]
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: YGOPro-Server-windows-* # the "windows" (no hyphen) artifact is ignored
merge-multiple: true
- name: GitHub Release
uses: salix5/action-automatic-releases@node20
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "server-latest"
prerelease: true
title: "Development Build"
files: |
x64/ygopro.exe
x64/AI.Server.exe
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <windows.h> #include <windows.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#ifdef _MSC_VER #if defined(_MSC_VER) or defined(__MINGW32__)
#define mywcsncasecmp _wcsnicmp #define mywcsncasecmp _wcsnicmp
#define mystrncasecmp _strnicmp #define mystrncasecmp _strnicmp
#else #else
......
...@@ -1305,7 +1305,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1305,7 +1305,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case MSG_SELECT_DISFIELD: { case MSG_SELECT_DISFIELD: {
if (!(hovered_location & LOCATION_ONFIELD)) if (!(hovered_location & LOCATION_ONFIELD))
break; break;
unsigned int flag = 1 << (hovered_sequence + (hovered_controler << 4) + ((hovered_location == LOCATION_MZONE) ? 0 : 8)); unsigned int flag = 0x1U << (hovered_sequence + (hovered_controler << 4) + ((hovered_location == LOCATION_MZONE) ? 0 : 8));
if (flag & selectable_field) { if (flag & selectable_field) {
if (flag & selected_field) { if (flag & selected_field) {
selected_field &= ~flag; selected_field &= ~flag;
......
...@@ -68,22 +68,6 @@ void DuelInfo::Clear() { ...@@ -68,22 +68,6 @@ void DuelInfo::Clear() {
} }
#endif #endif
bool IsExtension(const wchar_t* filename, const wchar_t* extension) {
auto flen = std::wcslen(filename);
auto elen = std::wcslen(extension);
if (!elen || flen < elen)
return false;
return !mywcsncasecmp(filename + (flen - elen), extension, elen);
}
bool IsExtension(const char* filename, const char* extension) {
auto flen = std::strlen(filename);
auto elen = std::strlen(extension);
if (!elen || flen < elen)
return false;
return !mystrncasecmp(filename + (flen - elen), extension, elen);
}
#ifdef YGOPRO_SERVER_MODE #ifdef YGOPRO_SERVER_MODE
unsigned short server_port; unsigned short server_port;
unsigned short replay_mode; unsigned short replay_mode;
...@@ -811,14 +795,14 @@ bool Game::Initialize() { ...@@ -811,14 +795,14 @@ bool Game::Initialize() {
cbAttribute = env->addComboBox(irr::core::rect<irr::s32>(60, 20 + 50 / 6, 195, 40 + 50 / 6), wFilter, COMBOBOX_ATTRIBUTE); cbAttribute = env->addComboBox(irr::core::rect<irr::s32>(60, 20 + 50 / 6, 195, 40 + 50 / 6), wFilter, COMBOBOX_ATTRIBUTE);
cbAttribute->setMaxSelectionRows(10); cbAttribute->setMaxSelectionRows(10);
cbAttribute->addItem(dataManager.GetSysString(1310), 0); cbAttribute->addItem(dataManager.GetSysString(1310), 0);
for(int filter = 0x1; filter != 0x80; filter <<= 1) for (int filter = 0; filter < ATTRIBUTES_COUNT; ++filter)
cbAttribute->addItem(dataManager.FormatAttribute(filter).c_str(), filter); cbAttribute->addItem(dataManager.FormatAttribute(0x1U << filter).c_str(), 0x1U << filter);
stRace = env->addStaticText(dataManager.GetSysString(1321), irr::core::rect<irr::s32>(10, 42 + 75 / 6, 70, 62 + 75 / 6), false, false, wFilter); stRace = env->addStaticText(dataManager.GetSysString(1321), irr::core::rect<irr::s32>(10, 42 + 75 / 6, 70, 62 + 75 / 6), false, false, wFilter);
cbRace = env->addComboBox(irr::core::rect<irr::s32>(60, 40 + 75 / 6, 195, 60 + 75 / 6), wFilter, COMBOBOX_RACE); cbRace = env->addComboBox(irr::core::rect<irr::s32>(60, 40 + 75 / 6, 195, 60 + 75 / 6), wFilter, COMBOBOX_RACE);
cbRace->setMaxSelectionRows(10); cbRace->setMaxSelectionRows(10);
cbRace->addItem(dataManager.GetSysString(1310), 0); cbRace->addItem(dataManager.GetSysString(1310), 0);
for(int filter = 0x1; filter < (1 << RACES_COUNT); filter <<= 1) for (int filter = 0; filter < RACES_COUNT; ++filter)
cbRace->addItem(dataManager.FormatRace(filter).c_str(), filter); cbRace->addItem(dataManager.FormatRace(0x1U << filter).c_str(), 0x1U << filter);
stAttack = env->addStaticText(dataManager.GetSysString(1322), irr::core::rect<irr::s32>(205, 22 + 50 / 6, 280, 42 + 50 / 6), false, false, wFilter); stAttack = env->addStaticText(dataManager.GetSysString(1322), irr::core::rect<irr::s32>(205, 22 + 50 / 6, 280, 42 + 50 / 6), false, false, wFilter);
ebAttack = env->addEditBox(L"", irr::core::rect<irr::s32>(260, 20 + 50 / 6, 340, 40 + 50 / 6), true, wFilter, EDITBOX_INPUTS); ebAttack = env->addEditBox(L"", irr::core::rect<irr::s32>(260, 20 + 50 / 6, 340, 40 + 50 / 6), true, wFilter, EDITBOX_INPUTS);
ebAttack->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER); ebAttack->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
...@@ -1211,22 +1195,26 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cW ...@@ -1211,22 +1195,26 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cW
void Game::LoadExpansions() { void Game::LoadExpansions() {
#ifdef SERVER_PRO2_SUPPORT #ifdef SERVER_PRO2_SUPPORT
FileSystem::TraversalDir(L"./cdb", [](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(L"./cdb", [](const wchar_t* name, bool isdir) {
if (isdir)
return;
wchar_t fpath[1024]; wchar_t fpath[1024];
myswprintf(fpath, L"./cdb/%ls", name); myswprintf(fpath, L"./cdb/%ls", name);
if(!isdir && IsExtension(name, L".cdb")) { if(IsExtension(name, L".cdb")) {
dataManager.LoadDB(fpath); dataManager.LoadDB(fpath);
} }
}); });
#endif // SERVER_PRO2_SUPPORT #endif // SERVER_PRO2_SUPPORT
FileSystem::TraversalDir(L"./expansions", [](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(L"./expansions", [](const wchar_t* name, bool isdir) {
if (isdir)
return;
wchar_t fpath[1024]; wchar_t fpath[1024];
myswprintf(fpath, L"./expansions/%ls", name); myswprintf(fpath, L"./expansions/%ls", name);
if (!isdir && IsExtension(name, L".cdb")) { if (IsExtension(name, L".cdb")) {
dataManager.LoadDB(fpath); dataManager.LoadDB(fpath);
return; return;
} }
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
if (!isdir && IsExtension(name, L".conf")) { if (IsExtension(name, L".conf")) {
char upath[1024]; char upath[1024];
BufferIO::EncodeUTF8(fpath, upath); BufferIO::EncodeUTF8(fpath, upath);
dataManager.LoadStrings(upath); dataManager.LoadStrings(upath);
...@@ -1234,7 +1222,7 @@ void Game::LoadExpansions() { ...@@ -1234,7 +1222,7 @@ void Game::LoadExpansions() {
} }
#endif // YGOPRO_SERVER_MODE #endif // YGOPRO_SERVER_MODE
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE) #if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
if (!isdir && (IsExtension(name, L".zip") || IsExtension(name, L".ypk"))) { if (IsExtension(name, L".zip") || IsExtension(name, L".ypk")) {
#ifdef _WIN32 #ifdef _WIN32
DataManager::FileSystem->addFileArchive(fpath, true, false, irr::io::EFAT_ZIP); DataManager::FileSystem->addFileArchive(fpath, true, false, irr::io::EFAT_ZIP);
#else #else
...@@ -1343,7 +1331,7 @@ void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const w ...@@ -1343,7 +1331,7 @@ void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const w
void Game::RefreshReplay() { void Game::RefreshReplay() {
lstReplayList->clear(); lstReplayList->clear();
FileSystem::TraversalDir(L"./replay", [this](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(L"./replay", [this](const wchar_t* name, bool isdir) {
if (!isdir && IsExtension(name, L".yrp") && Replay::CheckReplay(name)) if (!isdir && IsExtension(name, L".yrp"))
lstReplayList->addItem(name); lstReplayList->addItem(name);
}); });
} }
......
...@@ -36,8 +36,23 @@ constexpr int TEXT_LINE_SIZE = 256; ...@@ -36,8 +36,23 @@ constexpr int TEXT_LINE_SIZE = 256;
namespace ygo { namespace ygo {
bool IsExtension(const wchar_t* filename, const wchar_t* extension); template<size_t N>
bool IsExtension(const char* filename, const char* extension); bool IsExtension(const wchar_t* filename, const wchar_t(&extension)[N]) {
auto flen = std::wcslen(filename);
constexpr size_t elen = N - 1;
if (!elen || flen < elen)
return false;
return !mywcsncasecmp(filename + (flen - elen), extension, elen);
}
template<size_t N>
bool IsExtension(const char* filename, const char(&extension)[N]) {
auto flen = std::strlen(filename);
constexpr size_t elen = N - 1;
if (!elen || flen < elen)
return false;
return !mystrncasecmp(filename + (flen - elen), extension, elen);
}
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
struct Config { struct Config {
......
...@@ -143,8 +143,8 @@ void ImageManager::ResizeTexture() { ...@@ -143,8 +143,8 @@ void ImageManager::ResizeTexture() {
} }
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified // function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) { void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
const irr::core::dimension2d<irr::u32> srcDim = src->getDimension(); const auto& srcDim = src->getDimension();
const irr::core::dimension2d<irr::u32> destDim = dest->getDimension(); const auto& destDim = dest->getDimension();
// Cache scale ratios. // Cache scale ratios.
const double rx = (double)srcDim.Width / destDim.Width; const double rx = (double)srcDim.Width / destDim.Width;
...@@ -157,8 +157,8 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) { ...@@ -157,8 +157,8 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
// Walk each destination image pixel. // Walk each destination image pixel.
#pragma omp for schedule(dynamic) #pragma omp for schedule(dynamic)
for(irr::s32 dy = 0; dy < destDim.Height; dy++) { for(irr::s32 dy = 0; dy < (irr::s32)destDim.Height; dy++) {
for(irr::s32 dx = 0; dx < destDim.Width; dx++) { for(irr::s32 dx = 0; dx < (irr::s32)destDim.Width; dx++) {
// Calculate floating-point source rectangle bounds. // Calculate floating-point source rectangle bounds.
minsx = dx * rx; minsx = dx * rx;
maxsx = minsx + rx; maxsx = minsx + rx;
......
...@@ -523,10 +523,13 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -523,10 +523,13 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
case LISTBOX_REPLAY_LIST: { case LISTBOX_REPLAY_LIST: {
int sel = mainGame->lstReplayList->getSelected(); int sel = mainGame->lstReplayList->getSelected();
if(sel == -1) if(sel < 0)
break;
auto filename = mainGame->lstReplayList->getListItem(sel);
if (!filename)
break; break;
wchar_t replay_path[256]{}; wchar_t replay_path[256]{};
myswprintf(replay_path, L"./replay/%ls", mainGame->lstReplayList->getListItem(sel)); myswprintf(replay_path, L"./replay/%ls", filename);
if (!temp_replay.OpenReplay(replay_path)) { if (!temp_replay.OpenReplay(replay_path)) {
mainGame->stReplayInfo->setText(L"Error"); mainGame->stReplayInfo->setText(L"Error");
break; break;
...@@ -536,8 +539,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -536,8 +539,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
time_t curtime; time_t curtime;
if(temp_replay.pheader.flag & REPLAY_UNIFORM) if(temp_replay.pheader.flag & REPLAY_UNIFORM)
curtime = temp_replay.pheader.start_time; curtime = temp_replay.pheader.start_time;
else else{
curtime = temp_replay.pheader.seed; curtime = temp_replay.pheader.seed;
wchar_t version_info[256]{};
myswprintf(version_info, L"version 0x%X\n", temp_replay.pheader.version);
repinfo.append(version_info);
}
std::wcsftime(infobuf, sizeof infobuf / sizeof infobuf[0], L"%Y/%m/%d %H:%M:%S\n", std::localtime(&curtime)); std::wcsftime(infobuf, sizeof infobuf / sizeof infobuf[0], L"%Y/%m/%d %H:%M:%S\n", std::localtime(&curtime));
repinfo.append(infobuf); repinfo.append(infobuf);
if (temp_replay.pheader.flag & REPLAY_SINGLE_MODE) { if (temp_replay.pheader.flag & REPLAY_SINGLE_MODE) {
......
...@@ -44,6 +44,10 @@ else ...@@ -44,6 +44,10 @@ else
links { "ocgcore", "clzma", "cspmemvfs", LUA_LIB_NAME, "sqlite3", "irrlicht", "freetype", "event" } links { "ocgcore", "clzma", "cspmemvfs", LUA_LIB_NAME, "sqlite3", "irrlicht", "freetype", "event" }
end end
if not BUILD_LUA then
libdirs { LUA_LIB_DIR }
end
if BUILD_EVENT then if BUILD_EVENT then
includedirs { "../event/include" } includedirs { "../event/include" }
else else
...@@ -73,7 +77,7 @@ end ...@@ -73,7 +77,7 @@ end
libdirs { SQLITE_LIB_DIR } libdirs { SQLITE_LIB_DIR }
end end
if USE_AUDIO then if USE_AUDIO and not SERVER_MODE then
defines { "YGOPRO_USE_AUDIO" } defines { "YGOPRO_USE_AUDIO" }
if AUDIO_LIB == "miniaudio" then if AUDIO_LIB == "miniaudio" then
defines { "YGOPRO_USE_MINIAUDIO" } defines { "YGOPRO_USE_MINIAUDIO" }
...@@ -107,7 +111,7 @@ end ...@@ -107,7 +111,7 @@ end
if SERVER_PRO2_SUPPORT then if SERVER_PRO2_SUPPORT then
targetname ("AI.Server") targetname ("AI.Server")
end end
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32", "iphlpapi" } links { "ws2_32", "iphlpapi" }
if USE_AUDIO and AUDIO_LIB == "irrklang" then if USE_AUDIO and AUDIO_LIB == "irrklang" then
links { "irrKlang" } links { "irrKlang" }
if IRRKLANG_PRO then if IRRKLANG_PRO then
...@@ -129,7 +133,7 @@ end ...@@ -129,7 +133,7 @@ end
filter "system:macosx" filter "system:macosx"
if not SERVER_MODE then if not SERVER_MODE then
openmp "Off" openmp "Off"
links { "z" } links { "OpenGL.framework", "Cocoa.framework", "IOKit.framework" }
defines { "GL_SILENCE_DEPRECATION" } defines { "GL_SILENCE_DEPRECATION" }
end end
if MAC_ARM then if MAC_ARM then
...@@ -141,10 +145,14 @@ end ...@@ -141,10 +145,14 @@ end
if USE_AUDIO and AUDIO_LIB == "irrklang" then if USE_AUDIO and AUDIO_LIB == "irrklang" then
links { "irrklang" } links { "irrklang" }
end end
filter "system:linux" filter "system:linux"
if not SERVER_MODE then if not SERVER_MODE then
links { "GL", "X11", "Xxf86vm" } links { "GL", "X11", "Xxf86vm" }
linkoptions { "-fopenmp" } linkoptions { "-fopenmp" }
end
if SERVER_MODE then -- support old gcc
links { "pthread", "dl" }
end end
if USE_AUDIO and AUDIO_LIB == "irrklang" then if USE_AUDIO and AUDIO_LIB == "irrklang" then
links { "IrrKlang" } links { "IrrKlang" }
......
...@@ -126,7 +126,7 @@ void Replay::EndRecord() { ...@@ -126,7 +126,7 @@ void Replay::EndRecord() {
pheader.flag |= REPLAY_COMPRESSED; pheader.flag |= REPLAY_COMPRESSED;
size_t propsize = 5; size_t propsize = 5;
comp_size = MAX_COMP_SIZE; comp_size = MAX_COMP_SIZE;
int ret = LzmaCompress(comp_data, &comp_size, replay_data, replay_size, pheader.props, &propsize, 5, 1 << 24, 3, 0, 2, 32, 1); int ret = LzmaCompress(comp_data, &comp_size, replay_data, replay_size, pheader.props, &propsize, 5, 0x1U << 24, 3, 0, 2, 32, 1);
if (ret != SZ_OK) { if (ret != SZ_OK) {
std::memcpy(comp_data, &ret, sizeof ret); std::memcpy(comp_data, &ret, sizeof ret);
comp_size = sizeof ret; comp_size = sizeof ret;
...@@ -156,7 +156,16 @@ bool Replay::OpenReplay(const wchar_t* name) { ...@@ -156,7 +156,16 @@ bool Replay::OpenReplay(const wchar_t* name) {
return false; return false;
Reset(); Reset();
if(std::fread(&pheader, sizeof pheader, 1, rfp) < 1) { bool correct_header = true;
if (std::fread(&pheader, sizeof pheader, 1, rfp) < 1)
correct_header = false;
else if (pheader.id != 0x31707279)
correct_header = false;
else if (pheader.version < 0x12d0u)
correct_header = false;
else if (pheader.version >= 0x1353u && !(pheader.flag & REPLAY_UNIFORM))
correct_header = false;
if (!correct_header) {
std::fclose(rfp); std::fclose(rfp);
return false; return false;
} }
...@@ -187,17 +196,6 @@ bool Replay::OpenReplay(const wchar_t* name) { ...@@ -187,17 +196,6 @@ bool Replay::OpenReplay(const wchar_t* name) {
data_position = 0; data_position = 0;
return true; return true;
} }
bool Replay::CheckReplay(const wchar_t* name) {
wchar_t fname[256];
myswprintf(fname, L"./replay/%ls", name);
FILE* rfp = mywfopen(fname, "rb");
if(!rfp)
return false;
ReplayHeader rheader;
size_t count = std::fread(&rheader, sizeof rheader, 1, rfp);
std::fclose(rfp);
return count == 1 && rheader.id == 0x31707279 && rheader.version >= 0x12d0u && (rheader.version < 0x1353u || (rheader.flag & REPLAY_UNIFORM));
}
bool Replay::DeleteReplay(const wchar_t* name) { bool Replay::DeleteReplay(const wchar_t* name) {
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./replay/%ls", name); myswprintf(fname, L"./replay/%ls", name);
......
...@@ -59,7 +59,6 @@ public: ...@@ -59,7 +59,6 @@ public:
void SaveReplay(const wchar_t* name); void SaveReplay(const wchar_t* name);
// play // play
static bool CheckReplay(const wchar_t* name);
static bool DeleteReplay(const wchar_t* name); static bool DeleteReplay(const wchar_t* name);
static bool RenameReplay(const wchar_t* oldname, const wchar_t* newname); static bool RenameReplay(const wchar_t* oldname, const wchar_t* newname);
static size_t GetDeckPlayer(size_t deck_index) { static size_t GetDeckPlayer(size_t deck_index) {
......
project "event" project "event"
kind "StaticLib" kind "StaticLib"
local EVENT_VERSION = (io.readfile("configure") or ""):match("NUMERIC_VERSION%s+0x(%x+)")
if not EVENT_VERSION then
print("Warning: Could not determine libevent version from the configure file, assuming 2.1.12.")
EVENT_VERSION = "02010c00" -- 2.1.12
end
EVENT_VERSION = tonumber(EVENT_VERSION, 16)
if EVENT_VERSION>=0x02020000 then
print("Warning: Using libevent version 2.2.x is not supported, please use 2.1.x, otherwise you may encounter issues.")
end
if EVENT_VERSION>=0x02010000 and WINXP_SUPPORT then
print("Warning: libevent 2.1 uses some new APIs which require Windows Vista or later, so WinXP support will be not valid.")
end
includedirs { "include", "compat" } includedirs { "include", "compat" }
files { "event.c", "evthread.c", "buffer.c", "bufferevent.c", "bufferevent_sock.c", files { "event.c", "evthread.c", "buffer.c", "bufferevent.c", "bufferevent_sock.c",
...@@ -8,15 +21,20 @@ project "event" ...@@ -8,15 +21,20 @@ project "event"
"evmap.c", "log.c", "evutil.c", "evutil_rand.c", "strlcpy.c", "signal.c", "evmap.c", "log.c", "evutil.c", "evutil_rand.c", "strlcpy.c", "signal.c",
"event_tagging.c", "http.c", "evdns.c", "evrpc.c" } "event_tagging.c", "http.c", "evdns.c", "evrpc.c" }
if os.isfile("evutil_time.c") then if EVENT_VERSION>=0x02010000 then
files { "evutil_time.c" } files { "evutil_time.c" }
end end
filter "system:windows" filter "system:windows"
prebuildcommands { "xcopy /E /Y $(ProjectDir)..\\event\\WIN32-Code $(ProjectDir)..\\event\\include", prebuildcommands { "xcopy /E /Y $(ProjectDir)..\\event\\WIN32-Code $(ProjectDir)..\\event\\include" }
"xcopy /E /Y $(ProjectDir)..\\event\\WIN32-Code\\nmake $(ProjectDir)..\\event\\include" }
files { "win32select.c", "evthread_win32.c", "buffer_iocp.c", "event_iocp.c", "bufferevent_async.c" } files { "win32select.c", "evthread_win32.c", "buffer_iocp.c", "event_iocp.c", "bufferevent_async.c" }
defines { "UINT32_MAX=0xffffffffui32" } -- quirk of libevent 2.1.2 if EVENT_VERSION>=0x02010000 then
prebuildcommands { "xcopy /E /Y $(ProjectDir)..\\event\\WIN32-Code\\nmake $(ProjectDir)..\\event\\include" }
defines { "UINT32_MAX=0xffffffffU" } -- quirk of libevent 2.1
end
if EVENT_VERSION<0x02010000 then
defines { "WIN32" } -- quirk of old libevent
end
filter "system:linux" filter "system:linux"
files { "evthread_pthread.c", "epoll.c", "epoll_sub.c", "poll.c", "select.c" } files { "evthread_pthread.c", "epoll.c", "epoll_sub.c", "poll.c", "select.c" }
......
...@@ -161,9 +161,6 @@ project "irrlicht" ...@@ -161,9 +161,6 @@ project "irrlicht"
defines { "NO_IRR_COMPILE_WITH_DIRECT3D_9_" } defines { "NO_IRR_COMPILE_WITH_DIRECT3D_9_" }
end end
filter { "system:linux" }
links { "X11", "Xxf86vm" }
filter { "system:macosx" } filter { "system:macosx" }
cppdialect "gnu++14" cppdialect "gnu++14"
defines { "GL_SILENCE_DEPRECATION" } defines { "GL_SILENCE_DEPRECATION" }
......
...@@ -130,11 +130,11 @@ project "miniaudio" ...@@ -130,11 +130,11 @@ project "miniaudio"
"OPUS_X86_PRESUME_SSE", "OPUS_X86_PRESUME_SSE2", "OPUS_X86_PRESUME_SSE", "OPUS_X86_PRESUME_SSE2",
"OPUS_X86_MAY_HAVE_SSE", "OPUS_X86_MAY_HAVE_SSE4_1", "OPUS_X86_MAY_HAVE_AVX2", "OPUS_X86_MAY_HAVE_SSE", "OPUS_X86_MAY_HAVE_SSE4_1", "OPUS_X86_MAY_HAVE_AVX2",
} }
filter "system:linux"
buildoptions { "-mavx", "-mfma" }
filter {}
end end
else else
includedirs { OPUS_INCLUDE_DIR, OPUSFILE_INCLUDE_DIR, VORBIS_INCLUDE_DIR, OGG_INCLUDE_DIR } includedirs { OPUS_INCLUDE_DIR, OPUSFILE_INCLUDE_DIR, VORBIS_INCLUDE_DIR, OGG_INCLUDE_DIR }
end end
end end
filter "system:linux"
links { "dl", "pthread", "m" }
...@@ -2,3 +2,12 @@ project "sqlite3" ...@@ -2,3 +2,12 @@ project "sqlite3"
kind "StaticLib" kind "StaticLib"
files { "sqlite3.c", "sqlite3.h" } files { "sqlite3.c", "sqlite3.h" }
defines {
"SQLITE_DQS=0",
"SQLITE_DEFAULT_MEMSTATUS=0",
"SQLITE_MAX_EXPR_DEPTH=0",
"SQLITE_OMIT_DECLTYPE",
"SQLITE_OMIT_DEPRECATED",
"SQLITE_OMIT_PROGRESS_CALLBACK",
"SQLITE_OMIT_SHARED_CACHE",
}
...@@ -10,8 +10,11 @@ BUILD_LUA = true ...@@ -10,8 +10,11 @@ BUILD_LUA = true
LUA_LIB_NAME = "lua" -- change this if you don't build Lua LUA_LIB_NAME = "lua" -- change this if you don't build Lua
BUILD_EVENT = os.istarget("windows") BUILD_EVENT = os.istarget("windows")
BUILD_FREETYPE = os.istarget("windows") BUILD_FREETYPE = os.istarget("windows")
BUILD_SQLITE = os.istarget("windows") BUILD_SQLITE = os.istarget("windows")
BUILD_IRRLICHT = true -- modified Irrlicht is required, can't use the official one BUILD_IRRLICHT = true -- modified Irrlicht is required, can't use the official one
USE_DXSDK = true USE_DXSDK = true
...@@ -36,7 +39,7 @@ newoption { trigger = "no-build-lua", category = "YGOPro - lua", description = " ...@@ -36,7 +39,7 @@ newoption { trigger = "no-build-lua", category = "YGOPro - lua", description = "
newoption { trigger = "lua-include-dir", category = "YGOPro - lua", description = "", value = "PATH" } newoption { trigger = "lua-include-dir", category = "YGOPro - lua", description = "", value = "PATH" }
newoption { trigger = "lua-lib-dir", category = "YGOPro - lua", description = "", value = "PATH" } newoption { trigger = "lua-lib-dir", category = "YGOPro - lua", description = "", value = "PATH" }
newoption { trigger = "lua-lib-name", category = "YGOPro - lua", description = "", value = "NAME", default = LUA_LIB_NAME } newoption { trigger = "lua-lib-name", category = "YGOPro - lua", description = "", value = "NAME", default = LUA_LIB_NAME }
newoption { trigger = "lua-deb", category = "YGOPro - lua", description = "" } newoption { trigger = "lua-deb", category = "YGOPro - lua", description = "Use Debian lua package" }
newoption { trigger = "build-event", category = "YGOPro - event", description = "" } newoption { trigger = "build-event", category = "YGOPro - event", description = "" }
newoption { trigger = "no-build-event", category = "YGOPro - event", description = "" } newoption { trigger = "no-build-event", category = "YGOPro - event", description = "" }
...@@ -142,6 +145,20 @@ function ApplyNumber(param) ...@@ -142,6 +145,20 @@ function ApplyNumber(param)
end end
end end
if GetParam("server-mode") then
SERVER_MODE = true
end
if GetParam("server-zip-support") then
SERVER_ZIP_SUPPORT = true
end
if GetParam("server-pro2-support") then
SERVER_PRO2_SUPPORT = true
SERVER_ZIP_SUPPORT = true
end
if GetParam("server-tag-surrender-confirm") then
SERVER_TAG_SURRENDER_CONFIRM = true
end
if GetParam("build-lua") then if GetParam("build-lua") then
BUILD_LUA = true BUILD_LUA = true
elseif GetParam("no-build-lua") then elseif GetParam("no-build-lua") then
...@@ -225,7 +242,6 @@ if USE_DXSDK and os.istarget("windows") then ...@@ -225,7 +242,6 @@ if USE_DXSDK and os.istarget("windows") then
end end
end end
USE_AUDIO = not SERVER_MODE and not GetParam("no-audio")
if GetParam("no-audio") then if GetParam("no-audio") then
USE_AUDIO = false USE_AUDIO = false
elseif GetParam("no-use-miniaudio") then elseif GetParam("no-use-miniaudio") then
...@@ -244,7 +260,7 @@ elseif GetParam("use-irrklang") then ...@@ -244,7 +260,7 @@ elseif GetParam("use-irrklang") then
AUDIO_LIB = "irrklang" AUDIO_LIB = "irrklang"
end end
if USE_AUDIO then if USE_AUDIO and not SERVER_MODE then
AUDIO_LIB = GetParam("audio-lib") or AUDIO_LIB AUDIO_LIB = GetParam("audio-lib") or AUDIO_LIB
if AUDIO_LIB == "miniaudio" then if AUDIO_LIB == "miniaudio" then
if GetParam("miniaudio-support-opus-vorbis") then if GetParam("miniaudio-support-opus-vorbis") then
...@@ -321,19 +337,6 @@ if os.istarget("macosx") then ...@@ -321,19 +337,6 @@ if os.istarget("macosx") then
end end
end end
end end
if GetParam("server-mode") then
SERVER_MODE = true
end
if GetParam("server-zip-support") then
SERVER_ZIP_SUPPORT = true
end
if GetParam("server-pro2-support") then
SERVER_PRO2_SUPPORT = true
SERVER_ZIP_SUPPORT = true
end
if GetParam("server-tag-surrender-confirm") then
SERVER_TAG_SURRENDER_CONFIRM = true
end
workspace "YGOPro" workspace "YGOPro"
location "build" location "build"
...@@ -378,9 +381,6 @@ workspace "YGOPro" ...@@ -378,9 +381,6 @@ workspace "YGOPro"
if MAC_ARM and MAC_INTEL then if MAC_ARM and MAC_INTEL then
architecture "universal" architecture "universal"
end end
if not SERVER_MODE then
links { "OpenGL.framework", "Cocoa.framework", "IOKit.framework" }
end
filter "system:linux" filter "system:linux"
buildoptions { "-U_FORTIFY_SOURCE" } buildoptions { "-U_FORTIFY_SOURCE" }
...@@ -416,7 +416,6 @@ end ...@@ -416,7 +416,6 @@ end
disablewarnings { "4244", "4267", "4838", "4996", "6011", "6031", "6054", "6262" } disablewarnings { "4244", "4267", "4838", "4996", "6011", "6031", "6054", "6262" }
filter { "configurations:Release", "not action:vs*" } filter { "configurations:Release", "not action:vs*" }
symbols "On"
defines "NDEBUG" defines "NDEBUG"
filter { "configurations:Debug", "action:vs*" } filter { "configurations:Debug", "action:vs*" }
...@@ -459,7 +458,7 @@ end ...@@ -459,7 +458,7 @@ end
if BUILD_SQLITE then if BUILD_SQLITE then
include "sqlite3" include "sqlite3"
end end
if USE_AUDIO then if USE_AUDIO and not SERVER_MODE then
if AUDIO_LIB=="miniaudio" then if AUDIO_LIB=="miniaudio" then
include "miniaudio" include "miniaudio"
end 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