Commit 70b4e71d authored by wind2009's avatar wind2009

Merge remote-tracking branch 'upstream/master'

parents c7adbdf1 bfcb4afc
...@@ -12,6 +12,7 @@ jobs: ...@@ -12,6 +12,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [windows-2019, windows-2022] os: [windows-2019, windows-2022]
audiolib: [miniaudio, irrklang]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
...@@ -90,13 +91,75 @@ jobs: ...@@ -90,13 +91,75 @@ jobs:
7z x ${{ steps.sqlite.outputs.filepath }} 7z x ${{ steps.sqlite.outputs.filepath }}
move sqlite-amalgamation-3490100 sqlite3 move sqlite-amalgamation-3490100 sqlite3
- name: Download miniaudio
if: matrix.audiolib == 'miniaudio'
run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
cd miniaudio
xcopy /Y extras\miniaudio_split\miniaudio.* .
cd ..
- name: Download ogg
if: matrix.audiolib == 'miniaudio'
id: ogg
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/ogg/releases/download/v1.3.5/libogg-1.3.5.tar.gz
- name: Extract ogg
if: matrix.audiolib == 'miniaudio'
run: |
tar xf ${{ steps.ogg.outputs.filepath }}
move libogg-1.3.5 miniaudio/external/ogg
- name: Download opus
if: matrix.audiolib == 'miniaudio'
id: opus
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/opus/releases/download/v1.5.2/opus-1.5.2.tar.gz
- name: Extract opus
if: matrix.audiolib == 'miniaudio'
run: |
tar xf ${{ steps.opus.outputs.filepath }}
move opus-1.5.2 miniaudio/external/opus
- name: Download opusfile
if: matrix.audiolib == 'miniaudio'
id: opusfile
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/opusfile/releases/download/v0.12/opusfile-0.12.tar.gz
- name: Extract opusfile
if: matrix.audiolib == 'miniaudio'
run: |
tar xf ${{ steps.opusfile.outputs.filepath }}
move opusfile-0.12 miniaudio/external/opusfile
- name: Download vorbis
if: matrix.audiolib == 'miniaudio'
id: vorbis
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/xiph/vorbis/releases/download/v1.3.7/libvorbis-1.3.7.tar.gz
- name: Extract vorbis
if: matrix.audiolib == 'miniaudio'
run: |
tar xf ${{ steps.vorbis.outputs.filepath }}
move libvorbis-1.3.7 miniaudio/external/vorbis
- name: Download irrKlang - name: Download irrKlang
if: matrix.audiolib == 'irrklang'
id: irrKlang id: irrKlang
uses: mercury233/action-cache-download-file@v1.0.0 uses: mercury233/action-cache-download-file@v1.0.0
with: with:
url: https://www.ambiera.at/downloads/irrKlang-32bit-1.6.0.zip url: https://www.ambiera.at/downloads/irrKlang-32bit-1.6.0.zip
- name: Extract irrKlang - name: Extract irrKlang
if: matrix.audiolib == 'irrklang'
run: | run: |
7z x ${{ steps.irrKlang.outputs.filepath }} 7z x ${{ steps.irrKlang.outputs.filepath }}
move irrKlang-1.6.0 irrKlang move irrKlang-1.6.0 irrKlang
...@@ -134,16 +197,26 @@ jobs: ...@@ -134,16 +197,26 @@ jobs:
xcopy /E premake\* . xcopy /E premake\* .
xcopy /E resource\* . xcopy /E resource\* .
- name: Use premake to generate Visual Studio solution (2019) - name: Use premake to generate Visual Studio solution (2019, miniaudio)
if: matrix.os == 'windows-2019' if: matrix.os == 'windows-2019' && matrix.audiolib == 'miniaudio'
run: | run: |
.\premake5.exe vs2019 --winxp-support .\premake5.exe vs2019 --winxp-support
- name: Use premake to generate Visual Studio solution (2022) - name: Use premake to generate Visual Studio solution (2022, miniaudio)
if: matrix.os == 'windows-2022' if: matrix.os == 'windows-2022' && matrix.audiolib == 'miniaudio'
run: | run: |
.\premake5.exe vs2022 .\premake5.exe vs2022
- name: Use premake to generate Visual Studio solution (2019, irrKlang)
if: matrix.os == 'windows-2019' && matrix.audiolib == 'irrklang'
run: |
.\premake5.exe vs2019 --winxp-support --audio-lib=irrklang
- name: Use premake to generate Visual Studio solution (2022, irrKlang)
if: matrix.os == 'windows-2022' && matrix.audiolib == 'irrklang'
run: |
.\premake5.exe vs2022 --audio-lib=irrklang
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2 uses: microsoft/setup-msbuild@v2
...@@ -154,7 +227,7 @@ jobs: ...@@ -154,7 +227,7 @@ jobs:
- name: Upload build artifacts - name: Upload build artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: YGOPro-${{ matrix.os }} name: YGOPro-${{ matrix.os }}-${{ matrix.audiolib }}
path: | path: |
bin/release/YGOPro.exe bin/release/YGOPro.exe
...@@ -197,7 +270,7 @@ jobs: ...@@ -197,7 +270,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y libevent-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libsqlite3-dev libxxf86vm-dev sudo apt-get install -y libevent-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libsqlite3-dev libxxf86vm-dev libopusfile-dev libvorbis-dev
- name: Download premake - name: Download premake
id: premake id: premake
...@@ -222,6 +295,13 @@ jobs: ...@@ -222,6 +295,13 @@ jobs:
tar xf ${{ steps.lua.outputs.filepath }} tar xf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua mv lua-5.4.7 lua
- name: Download miniaudio
run: |
git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
cd miniaudio
cp extras/miniaudio_split/miniaudio.* .
cd ..
- name: Download irrlicht - name: Download irrlicht
run: | run: |
git clone --depth=1 https://github.com/mercury233/irrlicht git clone --depth=1 https://github.com/mercury233/irrlicht
...@@ -234,8 +314,8 @@ jobs: ...@@ -234,8 +314,8 @@ jobs:
- name: Use premake to generate make files - name: Use premake to generate make files
run: | run: |
./premake5 gmake \ ./premake5 gmake \
--no-use-irrklang \ --freetype-include-dir="/usr/include/freetype2" \
--freetype-include-dir="/usr/include/freetype2" --opus-include-dir="/usr/include/opus"
- name: Make - name: Make
run: | run: |
...@@ -283,9 +363,9 @@ jobs: ...@@ -283,9 +363,9 @@ jobs:
# git pull origin master # git pull origin master
# cd .. # cd ..
# - name: Install dependencies - name: Install dependencies
# run: | run: |
# brew install freetype libevent libx11 sqlite zlib brew install freetype libevent libx11 sqlite opus opusfile libvorbis
- name: Download premake - name: Download premake
id: premake id: premake
...@@ -310,15 +390,16 @@ jobs: ...@@ -310,15 +390,16 @@ jobs:
tar xf ${{ steps.lua.outputs.filepath }} tar xf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua mv lua-5.4.7 lua
- name: Download irrlicht - name: Download miniaudio
run: | run: |
git clone --depth=1 https://github.com/mercury233/irrlicht git clone --depth=1 --branch 0.11.22 https://github.com/mackron/miniaudio
cd miniaudio
cp extras/miniaudio_split/miniaudio.* .
cd ..
- name: Build irrlicht - name: Download irrlicht
run: | run: |
cd irrlicht/source/Irrlicht/MacOSX git clone --depth=1 https://github.com/mercury233/irrlicht
xcodebuild -project MacOSX.xcodeproj
cd ../../../..
- name: Copy premake files - name: Copy premake files
run: | run: |
...@@ -330,25 +411,26 @@ jobs: ...@@ -330,25 +411,26 @@ jobs:
run: | run: |
./premake5 gmake \ ./premake5 gmake \
--cc=clang \ --cc=clang \
--no-use-irrklang \
--freetype-include-dir="/usr/local/include/freetype2" \ --freetype-include-dir="/usr/local/include/freetype2" \
--irrlicht-include-dir="../irrlicht/include" \ --opus-include-dir="/usr/local/include/opus"
--irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release"
- name: Use premake to generate make files (ARM64) - name: Use premake to generate make files (ARM64)
if: runner.arch == 'ARM64' if: runner.arch == 'ARM64'
run: | run: |
./premake5 gmake \ ./premake5 gmake \
--cc=clang \ --cc=clang \
--no-use-irrklang \
--event-include-dir="/opt/homebrew/include" \ --event-include-dir="/opt/homebrew/include" \
--event-lib-dir="/opt/homebrew/lib" \ --event-lib-dir="/opt/homebrew/lib" \
--freetype-include-dir="/opt/homebrew/include/freetype2" \ --freetype-include-dir="/opt/homebrew/include/freetype2" \
--freetype-lib-dir="/opt/homebrew/lib" \ --freetype-lib-dir="/opt/homebrew/lib" \
--sqlite-include-dir="/opt/homebrew/opt/sqlite/include" \ --sqlite-include-dir="/opt/homebrew/opt/sqlite/include" \
--sqlite-lib-dir="/opt/homebrew/opt/sqlite/lib" \ --sqlite-lib-dir="/opt/homebrew/opt/sqlite/lib" \
--irrlicht-include-dir="../irrlicht/include" \ --miniaudio-include-dir="/opt/homebrew/include" \
--irrlicht-lib-dir="../irrlicht/source/Irrlicht/MacOSX/build/Release" --miniaudio-lib-dir="/opt/homebrew/lib" \
--opus-include-dir="/opt/homebrew/include/opus" \
--opus-lib-dir="/opt/homebrew/lib" \
--vorbis-include-dir="/opt/homebrew/include" \
--vorbis-lib-dir="/opt/homebrew/lib"
- name: Make - name: Make
run: | run: |
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
/pics /pics
/replay /replay
/single /single
/sound
!/sound/files.txt
/WindBot /WindBot
/cards.cdb /cards.cdb
/error.log /error.log
...@@ -30,6 +32,7 @@ ...@@ -30,6 +32,7 @@
/irrklang /irrklang
/ikpmp3 /ikpmp3
/lua /lua
/miniaudio
/sqlite3 /sqlite3
/gframe/*.ico /gframe/*.ico
/gframe/ygopro.rc /gframe/ygopro.rc
......
...@@ -72,6 +72,21 @@ inline FILE* mywfopen(const wchar_t* filename, const char* mode) { ...@@ -72,6 +72,21 @@ inline FILE* mywfopen(const wchar_t* filename, const char* mode) {
return fp; return fp;
} }
#if !defined(_WIN32)
#define myfopen std::fopen
#elif defined(WDK_NTDDI_VERSION) && (WDK_NTDDI_VERSION >= 0x0A000005) // Redstone 4, Version 1803, Build 17134.
#define FOPEN_WINDOWS_SUPPORT_UTF8
#define myfopen std::fopen
#else
inline FILE* myfopen(const char* filename, const char* mode) {
wchar_t wfilename[256]{};
BufferIO::DecodeUTF8(filename, wfilename);
wchar_t wmode[20]{};
BufferIO::CopyCharArray(mode, wmode);
return _wfopen(wfilename, wmode);
}
#endif
#include <irrlicht.h> #include <irrlicht.h>
extern const unsigned short PRO_VERSION; extern const unsigned short PRO_VERSION;
......
...@@ -108,7 +108,7 @@ bool DataManager::LoadDB(const wchar_t* wfile) { ...@@ -108,7 +108,7 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
return ret; return ret;
} }
bool DataManager::LoadStrings(const char* file) { bool DataManager::LoadStrings(const char* file) {
FILE* fp = std::fopen(file, "r"); FILE* fp = myfopen(file, "r");
if(!fp) if(!fp)
return false; return false;
char linebuf[TEXT_LINE_SIZE]{}; char linebuf[TEXT_LINE_SIZE]{};
...@@ -431,9 +431,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl ...@@ -431,9 +431,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
return scriptBuffer; return scriptBuffer;
} }
unsigned char* DataManager::ReadScriptFromFile(const char* script_name, int* slen) { unsigned char* DataManager::ReadScriptFromFile(const char* script_name, int* slen) {
wchar_t fname[256]{}; FILE* fp = myfopen(script_name, "rb");
BufferIO::DecodeUTF8(script_name, fname);
FILE* fp = mywfopen(fname, "rb");
if (!fp) if (!fp)
return nullptr; return nullptr;
size_t len = std::fread(scriptBuffer, 1, sizeof scriptBuffer, fp); size_t len = std::fread(scriptBuffer, 1, sizeof scriptBuffer, fp);
......
...@@ -10,7 +10,7 @@ DeckManager deckManager; ...@@ -10,7 +10,7 @@ DeckManager deckManager;
void DeckManager::LoadLFListSingle(const char* path) { void DeckManager::LoadLFListSingle(const char* path) {
auto cur = _lfList.rend(); auto cur = _lfList.rend();
FILE* fp = std::fopen(path, "r"); FILE* fp = myfopen(path, "r");
char linebuf[256]{}; char linebuf[256]{};
wchar_t strBuffer[256]{}; wchar_t strBuffer[256]{};
char str1[16]{}; char str1[16]{};
...@@ -311,7 +311,7 @@ bool DeckManager::LoadCurrentDeck(int category_index, const wchar_t* category_na ...@@ -311,7 +311,7 @@ bool DeckManager::LoadCurrentDeck(int category_index, const wchar_t* category_na
mainGame->deckBuilder.RefreshPackListScroll(); mainGame->deckBuilder.RefreshPackListScroll();
return res; return res;
} }
bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) { bool DeckManager::SaveDeck(const Deck& deck, const wchar_t* file) {
if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck")) if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck"))
return false; return false;
FILE* fp = OpenDeckFile(file, "w"); FILE* fp = OpenDeckFile(file, "w");
...@@ -319,26 +319,18 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) { ...@@ -319,26 +319,18 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
return false; return false;
std::fprintf(fp, "#created by ...\n#main\n"); std::fprintf(fp, "#created by ...\n#main\n");
for(size_t i = 0; i < deck.main.size(); ++i) for(size_t i = 0; i < deck.main.size(); ++i)
std::fprintf(fp, "%d\n", deck.main[i]->first); std::fprintf(fp, "%u\n", deck.main[i]->first);
std::fprintf(fp, "#extra\n"); std::fprintf(fp, "#extra\n");
for(size_t i = 0; i < deck.extra.size(); ++i) for(size_t i = 0; i < deck.extra.size(); ++i)
std::fprintf(fp, "%d\n", deck.extra[i]->first); std::fprintf(fp, "%u\n", deck.extra[i]->first);
std::fprintf(fp, "!side\n"); std::fprintf(fp, "!side\n");
for(size_t i = 0; i < deck.side.size(); ++i) for(size_t i = 0; i < deck.side.size(); ++i)
std::fprintf(fp, "%d\n", deck.side[i]->first); std::fprintf(fp, "%u\n", deck.side[i]->first);
std::fclose(fp); std::fclose(fp);
return true; return true;
} }
bool DeckManager::DeleteDeck(const wchar_t* file) { bool DeckManager::DeleteDeck(const wchar_t* file) {
#ifdef _WIN32 return FileSystem::RemoveFile(file);
BOOL result = DeleteFileW(file);
return !!result;
#else
char filefn[256];
BufferIO::EncodeUTF8(file, filefn);
int result = unlink(filefn);
return result == 0;
#endif
} }
bool DeckManager::CreateCategory(const wchar_t* name) { bool DeckManager::CreateCategory(const wchar_t* name) {
if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck")) if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck"))
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
static void GetDeckFile(wchar_t* ret, int category_index, const wchar_t* category_name, const wchar_t* deckname); static void GetDeckFile(wchar_t* ret, int category_index, const wchar_t* category_name, const wchar_t* deckname);
static FILE* OpenDeckFile(const wchar_t* file, const char* mode); static FILE* OpenDeckFile(const wchar_t* file, const char* mode);
static irr::io::IReadFile* OpenDeckReader(const wchar_t* file); static irr::io::IReadFile* OpenDeckReader(const wchar_t* file);
static bool SaveDeck(Deck& deck, const wchar_t* file); static bool SaveDeck(const Deck& deck, const wchar_t* file);
static bool DeleteDeck(const wchar_t* file); static bool DeleteDeck(const wchar_t* file);
static bool CreateCategory(const wchar_t* name); static bool CreateCategory(const wchar_t* name);
static bool RenameCategory(const wchar_t* oldname, const wchar_t* newname); static bool RenameCategory(const wchar_t* oldname, const wchar_t* newname);
......
...@@ -3034,6 +3034,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -3034,6 +3034,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
case MSG_CHAIN_DISABLED: { case MSG_CHAIN_DISABLED: {
int ct = BufferIO::ReadUInt8(pbuf); int ct = BufferIO::ReadUInt8(pbuf);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
soundManager.PlaySoundEffect(SOUND_NEGATE);
mainGame->showcardcode = mainGame->dField.chains[ct - 1].code; mainGame->showcardcode = mainGame->dField.chains[ct - 1].code;
mainGame->showcarddif = 0; mainGame->showcarddif = 0;
mainGame->showcard = 3; mainGame->showcard = 3;
...@@ -3868,7 +3869,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -3868,7 +3869,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
break; break;
} }
case MSG_RELOAD_FIELD: { case MSG_RELOAD_FIELD: {
mainGame->gMutex.lock(); if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
mainGame->gMutex.lock();
}
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->dInfo.duel_rule = BufferIO::ReadUInt8(pbuf); mainGame->dInfo.duel_rule = BufferIO::ReadUInt8(pbuf);
int val = 0; int val = 0;
...@@ -3974,7 +3977,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -3974,7 +3977,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code)); myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code));
mainGame->dField.last_chain = true; mainGame->dField.last_chain = true;
} }
mainGame->gMutex.unlock(); if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
mainGame->gMutex.unlock();
}
break; break;
} }
} }
......
...@@ -106,6 +106,9 @@ bool Game::Initialize() { ...@@ -106,6 +106,9 @@ bool Game::Initialize() {
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16); numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
if(!numFont) { if(!numFont) {
const wchar_t* numFontPaths[] = { const wchar_t* numFontPaths[] = {
L"./fonts/numFont.ttf",
L"./fonts/numFont.ttc",
L"./fonts/numFont.otf",
L"C:/Windows/Fonts/arialbd.ttf", L"C:/Windows/Fonts/arialbd.ttf",
L"/usr/share/fonts/truetype/DroidSansFallbackFull.ttf", L"/usr/share/fonts/truetype/DroidSansFallbackFull.ttf",
L"/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", L"/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc",
...@@ -113,9 +116,6 @@ bool Game::Initialize() { ...@@ -113,9 +116,6 @@ bool Game::Initialize() {
L"/usr/share/fonts/noto-cjk/NotoSansCJK-Bold.ttc", L"/usr/share/fonts/noto-cjk/NotoSansCJK-Bold.ttc",
L"/System/Library/Fonts/SFNSTextCondensed-Bold.otf", L"/System/Library/Fonts/SFNSTextCondensed-Bold.otf",
L"/System/Library/Fonts/SFNS.ttf", L"/System/Library/Fonts/SFNS.ttf",
L"./fonts/numFont.ttf",
L"./fonts/numFont.ttc",
L"./fonts/numFont.otf"
}; };
for(const wchar_t* path : numFontPaths) { for(const wchar_t* path : numFontPaths) {
BufferIO::CopyWideString(path, gameConf.numfont); BufferIO::CopyWideString(path, gameConf.numfont);
...@@ -127,6 +127,9 @@ bool Game::Initialize() { ...@@ -127,6 +127,9 @@ bool Game::Initialize() {
textFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize); textFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize);
if(!textFont) { if(!textFont) {
const wchar_t* textFontPaths[] = { const wchar_t* textFontPaths[] = {
L"./fonts/textFont.ttf",
L"./fonts/textFont.ttc",
L"./fonts/textFont.otf",
L"C:/Windows/Fonts/msyh.ttc", L"C:/Windows/Fonts/msyh.ttc",
L"C:/Windows/Fonts/msyh.ttf", L"C:/Windows/Fonts/msyh.ttf",
L"C:/Windows/Fonts/simsun.ttc", L"C:/Windows/Fonts/simsun.ttc",
...@@ -138,9 +141,7 @@ bool Game::Initialize() { ...@@ -138,9 +141,7 @@ bool Game::Initialize() {
L"/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc", L"/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc",
L"/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", L"/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc",
L"/System/Library/Fonts/PingFang.ttc", L"/System/Library/Fonts/PingFang.ttc",
L"./fonts/textFont.ttf", L"/System/Library/Fonts/STHeiti Medium.ttc",
L"./fonts/textFont.ttc",
L"./fonts/textFont.otf"
}; };
for(const wchar_t* path : textFontPaths) { for(const wchar_t* path : textFontPaths) {
BufferIO::CopyWideString(path, gameConf.textfont); BufferIO::CopyWideString(path, gameConf.textfont);
...@@ -158,7 +159,7 @@ bool Game::Initialize() { ...@@ -158,7 +159,7 @@ bool Game::Initialize() {
} }
}); });
if(fpath[0] == 0) { if(fpath[0] == 0) {
ErrorLog("Failed to load font(s)!"); ErrorLog("No fonts found! Please place appropriate font file in the fonts directory, or edit system.conf manually.");
return false; return false;
} }
if(!numFont) { if(!numFont) {
...@@ -170,6 +171,10 @@ bool Game::Initialize() { ...@@ -170,6 +171,10 @@ bool Game::Initialize() {
textFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize); textFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize);
} }
} }
if(!numFont || !textFont) {
ErrorLog("Failed to load font(s)!");
return false;
}
adFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 12); adFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 12);
lpcFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 48); lpcFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 48);
guiFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize); guiFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize);
...@@ -1267,7 +1272,7 @@ void Game::RefreshBot() { ...@@ -1267,7 +1272,7 @@ void Game::RefreshBot() {
if(!gameConf.enable_bot_mode) if(!gameConf.enable_bot_mode)
return; return;
botInfo.clear(); botInfo.clear();
FILE* fp = std::fopen("bot.conf", "r"); FILE* fp = myfopen("bot.conf", "r");
char linebuf[256]{}; char linebuf[256]{};
char strbuf[256]{}; char strbuf[256]{};
if(fp) { if(fp) {
...@@ -1320,7 +1325,7 @@ void Game::RefreshBot() { ...@@ -1320,7 +1325,7 @@ void Game::RefreshBot() {
} }
} }
void Game::LoadConfig() { void Game::LoadConfig() {
FILE* fp = std::fopen("system.conf", "r"); FILE* fp = myfopen("system.conf", "r");
if(!fp) if(!fp)
return; return;
char linebuf[CONFIG_LINE_SIZE]{}; char linebuf[CONFIG_LINE_SIZE]{};
...@@ -1338,14 +1343,6 @@ void Game::LoadConfig() { ...@@ -1338,14 +1343,6 @@ void Game::LoadConfig() {
} else if(!std::strcmp(strbuf, "errorlog")) { } else if(!std::strcmp(strbuf, "errorlog")) {
unsigned int val = std::strtol(valbuf, nullptr, 10); unsigned int val = std::strtol(valbuf, nullptr, 10);
enable_log = val & 0xff; enable_log = val & 0xff;
} else if(!std::strcmp(strbuf, "textfont")) {
int textfontsize = 0;
if (std::sscanf(linebuf, "%63s = %959s %d", strbuf, valbuf, &textfontsize) != 3)
continue;
gameConf.textfontsize = textfontsize;
BufferIO::DecodeUTF8(valbuf, gameConf.textfont);
} else if(!std::strcmp(strbuf, "numfont")) {
BufferIO::DecodeUTF8(valbuf, gameConf.numfont);
} else if(!std::strcmp(strbuf, "serverport")) { } else if(!std::strcmp(strbuf, "serverport")) {
gameConf.serverport = std::strtol(valbuf, nullptr, 10); gameConf.serverport = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "lasthost")) { } else if(!std::strcmp(strbuf, "lasthost")) {
...@@ -1414,7 +1411,7 @@ void Game::LoadConfig() { ...@@ -1414,7 +1411,7 @@ void Game::LoadConfig() {
gameConf.window_height = std::strtol(valbuf, nullptr, 10); gameConf.window_height = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "resize_popup_menu")) { } else if(!std::strcmp(strbuf, "resize_popup_menu")) {
gameConf.resize_popup_menu = std::strtol(valbuf, nullptr, 10) > 0; gameConf.resize_popup_menu = std::strtol(valbuf, nullptr, 10) > 0;
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_AUDIO
} else if(!std::strcmp(strbuf, "enable_sound")) { } else if(!std::strcmp(strbuf, "enable_sound")) {
gameConf.enable_sound = std::strtol(valbuf, nullptr, 10) > 0; gameConf.enable_sound = std::strtol(valbuf, nullptr, 10) > 0;
} else if(!std::strcmp(strbuf, "sound_volume")) { } else if(!std::strcmp(strbuf, "sound_volume")) {
...@@ -1440,7 +1437,18 @@ void Game::LoadConfig() { ...@@ -1440,7 +1437,18 @@ void Game::LoadConfig() {
// options allowing multiple words // options allowing multiple words
if (std::sscanf(linebuf, "%63s = %959[^\n]", strbuf, valbuf) != 2) if (std::sscanf(linebuf, "%63s = %959[^\n]", strbuf, valbuf) != 2)
continue; continue;
if (!std::strcmp(strbuf, "nickname")) { if (!std::strcmp(strbuf, "textfont")) {
char* last_space = std::strrchr(valbuf, ' ');
if (last_space == nullptr)
continue;
int fontsize = std::strtol(last_space + 1, nullptr, 10);
if (fontsize > 0)
gameConf.textfontsize = fontsize;
*last_space = 0;
BufferIO::DecodeUTF8(valbuf, gameConf.textfont);
} else if (!std::strcmp(strbuf, "numfont")) {
BufferIO::DecodeUTF8(valbuf, gameConf.numfont);
} else if (!std::strcmp(strbuf, "nickname")) {
BufferIO::DecodeUTF8(valbuf, gameConf.nickname); BufferIO::DecodeUTF8(valbuf, gameConf.nickname);
} else if (!std::strcmp(strbuf, "gamename")) { } else if (!std::strcmp(strbuf, "gamename")) {
BufferIO::DecodeUTF8(valbuf, gameConf.gamename); BufferIO::DecodeUTF8(valbuf, gameConf.gamename);
...@@ -1458,7 +1466,7 @@ void Game::LoadConfig() { ...@@ -1458,7 +1466,7 @@ void Game::LoadConfig() {
std::fclose(fp); std::fclose(fp);
} }
void Game::SaveConfig() { void Game::SaveConfig() {
FILE* fp = std::fopen("system.conf", "w"); FILE* fp = myfopen("system.conf", "w");
std::fprintf(fp, "#config file\n#nickname & gamename should be less than 20 characters\n"); std::fprintf(fp, "#config file\n#nickname & gamename should be less than 20 characters\n");
char linebuf[CONFIG_LINE_SIZE]; char linebuf[CONFIG_LINE_SIZE];
std::fprintf(fp, "use_d3d = %d\n", gameConf.use_d3d ? 1 : 0); std::fprintf(fp, "use_d3d = %d\n", gameConf.use_d3d ? 1 : 0);
...@@ -1519,7 +1527,7 @@ void Game::SaveConfig() { ...@@ -1519,7 +1527,7 @@ void Game::SaveConfig() {
std::fprintf(fp, "window_width = %d\n", gameConf.window_width); std::fprintf(fp, "window_width = %d\n", gameConf.window_width);
std::fprintf(fp, "window_height = %d\n", gameConf.window_height); std::fprintf(fp, "window_height = %d\n", gameConf.window_height);
std::fprintf(fp, "resize_popup_menu = %d\n", gameConf.resize_popup_menu ? 1 : 0); std::fprintf(fp, "resize_popup_menu = %d\n", gameConf.resize_popup_menu ? 1 : 0);
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_AUDIO
std::fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0)); std::fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0));
std::fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0)); std::fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0));
std::fprintf(fp, "#Volume of sound and music, between 0 and 100\n"); std::fprintf(fp, "#Volume of sound and music, between 0 and 100\n");
...@@ -1711,7 +1719,12 @@ void Game::AddDebugMsg(const char* msg) { ...@@ -1711,7 +1719,12 @@ void Game::AddDebugMsg(const char* msg) {
} }
} }
void Game::ErrorLog(const char* msg) { void Game::ErrorLog(const char* msg) {
FILE* fp = std::fopen("error.log", "a"); #ifdef _WIN32
OutputDebugStringA(msg);
#else
std::fprintf(stderr, "%s\n", msg);
#endif
FILE* fp = myfopen("error.log", "a");
if(!fp) if(!fp)
return; return;
time_t nowtime = std::time(nullptr); time_t nowtime = std::time(nullptr);
......
...@@ -23,8 +23,12 @@ void ClickButton(irr::gui::IGUIElement* btn) { ...@@ -23,8 +23,12 @@ void ClickButton(irr::gui::IGUIElement* btn) {
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
#ifndef _WIN32 #if defined(FOPEN_WINDOWS_SUPPORT_UTF8)
std::setlocale(LC_CTYPE, ".UTF-8");
#elif defined(__APPLE__)
std::setlocale(LC_CTYPE, "UTF-8"); std::setlocale(LC_CTYPE, "UTF-8");
#elif !defined(_WIN32)
std::setlocale(LC_CTYPE, "");
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
CFURLRef bundle_url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFURLRef bundle_url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
......
...@@ -86,6 +86,14 @@ public: ...@@ -86,6 +86,14 @@ public:
return DeleteDir(wdir); return DeleteDir(wdir);
} }
static bool RemoveFile(const wchar_t* wfile) {
return DeleteFileW(wfile);
}
static bool RemoveFile(const char* file) {
return DeleteFileA(file);
}
static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) { static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) {
wchar_t findstr[1024]; wchar_t findstr[1024];
std::swprintf(findstr, sizeof findstr / sizeof findstr[0], L"%ls/*", wpath); std::swprintf(findstr, sizeof findstr / sizeof findstr[0], L"%ls/*", wpath);
...@@ -195,6 +203,16 @@ public: ...@@ -195,6 +203,16 @@ public:
return success; return success;
} }
static bool RemoveFile(const wchar_t* wfile) {
char file[1024];
BufferIO::EncodeUTF8(wfile, file);
return RemoveFile(file);
}
static bool RemoveFile(const char* file) {
return unlink(file) == 0;
}
struct file_unit { struct file_unit {
std::string filename; std::string filename;
bool is_dir; bool is_dir;
......
...@@ -27,7 +27,7 @@ struct HostInfo { ...@@ -27,7 +27,7 @@ struct HostInfo {
uint8_t no_shuffle_deck{}; uint8_t no_shuffle_deck{};
// byte padding[3] // byte padding[3]
uint32_t start_lp{}; int32_t start_lp{};
uint8_t start_hand{}; uint8_t start_hand{};
uint8_t draw_count{}; uint8_t draw_count{};
uint16_t time_limit{}; uint16_t time_limit{};
......
...@@ -10,10 +10,6 @@ project "YGOPro" ...@@ -10,10 +10,6 @@ project "YGOPro"
includedirs { "../ocgcore" } includedirs { "../ocgcore" }
links { "ocgcore", "clzma", "cspmemvfs", LUA_LIB_NAME, "sqlite3", "irrlicht", "freetype", "event" } links { "ocgcore", "clzma", "cspmemvfs", LUA_LIB_NAME, "sqlite3", "irrlicht", "freetype", "event" }
if BUILD_IKPMP3 then
links { "ikpmp3" }
end
if BUILD_EVENT then if BUILD_EVENT then
includedirs { "../event/include" } includedirs { "../event/include" }
else else
...@@ -42,19 +38,38 @@ project "YGOPro" ...@@ -42,19 +38,38 @@ project "YGOPro"
libdirs { SQLITE_LIB_DIR } libdirs { SQLITE_LIB_DIR }
end end
if USE_IRRKLANG then if USE_AUDIO then
defines { "YGOPRO_USE_IRRKLANG" } defines { "YGOPRO_USE_AUDIO" }
includedirs { IRRKLANG_INCLUDE_DIR } if AUDIO_LIB == "miniaudio" then
if not IRRKLANG_PRO then defines { "YGOPRO_USE_MINIAUDIO" }
libdirs { IRRKLANG_LIB_DIR } includedirs { "../miniaudio" }
links { "miniaudio" }
if MINIAUDIO_SUPPORT_OPUS_VORBIS then
defines { "YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS" }
includedirs { "../miniaudio/extras/decoders/libopus", "../miniaudio/extras/decoders/libvorbis" }
if not MINIAUDIO_BUILD_OPUS_VORBIS then
links { "opusfile", "vorbisfile", "opus", "vorbis", "ogg" }
libdirs { OPUS_LIB_DIR, VORBIS_LIB_DIR, OGG_LIBDIR }
end
end
end
if AUDIO_LIB == "irrklang" then
defines { "YGOPRO_USE_IRRKLANG" }
includedirs { IRRKLANG_INCLUDE_DIR }
if not IRRKLANG_PRO then
libdirs { IRRKLANG_LIB_DIR }
end
if IRRKLANG_PRO_BUILD_IKPMP3 then
links { "ikpmp3" }
end
end end
end end
filter "system:windows" filter "system:windows"
defines { "_IRR_WCHAR_FILESYSTEM" } defines { "_IRR_WCHAR_FILESYSTEM" }
files "ygopro.rc" files "ygopro.rc"
libdirs { "$(DXSDK_DIR)Lib/x86" } links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" }
if USE_IRRKLANG then if USE_AUDIO and AUDIO_LIB == "irrklang" then
links { "irrKlang" } links { "irrKlang" }
if IRRKLANG_PRO then if IRRKLANG_PRO then
defines { "IRRKLANG_STATIC" } defines { "IRRKLANG_STATIC" }
...@@ -65,7 +80,6 @@ project "YGOPro" ...@@ -65,7 +80,6 @@ project "YGOPro"
filter {} filter {}
end end
end end
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" }
filter "not system:windows" filter "not system:windows"
links { "event_pthreads", "dl", "pthread" } links { "event_pthreads", "dl", "pthread" }
filter "system:macosx" filter "system:macosx"
...@@ -75,12 +89,12 @@ project "YGOPro" ...@@ -75,12 +89,12 @@ project "YGOPro"
buildoptions { "--target=arm64-apple-macos12" } buildoptions { "--target=arm64-apple-macos12" }
linkoptions { "-arch arm64" } linkoptions { "-arch arm64" }
end end
if USE_IRRKLANG then if USE_AUDIO and AUDIO_LIB == "irrklang" then
links { "irrklang" } links { "irrklang" }
end end
filter "system:linux" filter "system:linux"
links { "GL", "X11", "Xxf86vm" } links { "GL", "X11", "Xxf86vm" }
if USE_IRRKLANG then if USE_AUDIO and AUDIO_LIB == "irrklang" then
links { "IrrKlang" } links { "IrrKlang" }
linkoptions{ IRRKLANG_LINK_RPATH } linkoptions{ IRRKLANG_LINK_RPATH }
end end
...@@ -24,7 +24,7 @@ void Replay::BeginRecord() { ...@@ -24,7 +24,7 @@ void Replay::BeginRecord() {
#else #else
if(is_recording) if(is_recording)
std::fclose(fp); std::fclose(fp);
fp = std::fopen("./replay/_LastReplay.yrp", "wb"); fp = myfopen("./replay/_LastReplay.yrp", "wb");
if(!fp) if(!fp)
return; return;
#endif #endif
...@@ -154,15 +154,7 @@ bool Replay::CheckReplay(const wchar_t* name) { ...@@ -154,15 +154,7 @@ bool Replay::CheckReplay(const wchar_t* name) {
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);
#ifdef _WIN32 return FileSystem::RemoveFile(fname);
BOOL result = DeleteFileW(fname);
return !!result;
#else
char filefn[256];
BufferIO::EncodeUTF8(fname, filefn);
int result = unlink(filefn);
return result == 0;
#endif
} }
bool Replay::RenameReplay(const wchar_t* oldname, const wchar_t* newname) { bool Replay::RenameReplay(const wchar_t* oldname, const wchar_t* newname) {
wchar_t oldfname[256]; wchar_t oldfname[256];
......
...@@ -17,13 +17,13 @@ constexpr int MAX_REPLAY_SIZE = 0x20000; ...@@ -17,13 +17,13 @@ constexpr int MAX_REPLAY_SIZE = 0x20000;
constexpr int MAX_COMP_SIZE = UINT16_MAX + 1; constexpr int MAX_COMP_SIZE = UINT16_MAX + 1;
struct ReplayHeader { struct ReplayHeader {
unsigned int id{}; uint32_t id{};
unsigned int version{}; uint32_t version{};
unsigned int flag{}; uint32_t flag{};
unsigned int seed{}; uint32_t seed{};
unsigned int datasize{}; uint32_t datasize{};
unsigned int start_time{}; uint32_t start_time{};
unsigned char props[8]{}; uint8_t props[8]{};
}; };
class Replay { class Replay {
......
This diff is collapsed.
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
#include "game.h" #include "game.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
#ifdef YGOPRO_USE_MINIAUDIO
#include <miniaudio.h>
#endif
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
#include <irrKlang.h> #include <irrKlang.h>
#endif #endif
...@@ -12,8 +15,19 @@ namespace ygo { ...@@ -12,8 +15,19 @@ namespace ygo {
class SoundManager { class SoundManager {
private: private:
std::vector<std::wstring> BGMList[8]; std::vector<std::wstring> BGMList[8];
int bgm_scene; int bgm_scene{};
mt19937 rnd; mt19937 rnd;
#ifdef YGOPRO_USE_MINIAUDIO
ma_engine_config engineConfig;
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
ma_resource_manager_config resourceManagerConfig;
ma_resource_manager resourceManager;
#endif
ma_engine engineSound;
ma_engine engineMusic;
ma_sound soundBGM;
wchar_t currentPlayingMusic[1024]{};
#endif
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
irrklang::ISoundEngine* engineSound; irrklang::ISoundEngine* engineSound;
irrklang::ISoundEngine* engineMusic; irrklang::ISoundEngine* engineMusic;
...@@ -26,7 +40,8 @@ public: ...@@ -26,7 +40,8 @@ public:
void RefreshBGMList(); void RefreshBGMList();
void PlaySoundEffect(int sound); void PlaySoundEffect(int sound);
void PlayDialogSound(irr::gui::IGUIElement * element); void PlayDialogSound(irr::gui::IGUIElement * element);
void PlayMusic(char* song, bool loop); bool IsPlayingMusic(wchar_t* music = 0);
void PlayMusic(wchar_t* music, bool loop);
void PlayBGM(int scene); void PlayBGM(int scene);
void StopBGM(); void StopBGM();
void SetSoundVolume(double volume); void SetSoundVolume(double volume);
...@@ -45,6 +60,7 @@ extern SoundManager soundManager; ...@@ -45,6 +60,7 @@ extern SoundManager soundManager;
#define SOUND_DESTROYED 108 #define SOUND_DESTROYED 108
#define SOUND_BANISHED 109 #define SOUND_BANISHED 109
#define SOUND_TOKEN 110 #define SOUND_TOKEN 110
#define SOUND_NEGATE 111
#define SOUND_ATTACK 201 #define SOUND_ATTACK 201
#define SOUND_DIRECT_ATTACK 202 #define SOUND_DIRECT_ATTACK 202
......
This diff is collapsed.
...@@ -11,3 +11,4 @@ project "event" ...@@ -11,3 +11,4 @@ project "event"
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" }
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 { "WIN32" } -- quirk of old libevent
defines {
"_IRR_STATIC_LIB_",
"NO_IRR_USE_NON_SYSTEM_BZLIB_",
"NO_IRR_COMPILE_WITH_BZIP2_",
"NO_IRR_COMPILE_WITH_CONSOLE_DEVICE_",
"NO_IRR_COMPILE_WITH_DIRECT3D_8_",
"NO_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_",
"NO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_",
"NO_IRR_COMPILE_WITH_SOFTWARE_",
"NO_IRR_COMPILE_WITH_BURNINGSVIDEO_",
"NO_IRR_COMPILE_WITH_IRR_SCENE_LOADER_",
"NO_IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_",
"NO_IRR_COMPILE_WITH_IRR_MESH_LOADER_",
"NO_IRR_COMPILE_WITH_HALFLIFE_LOADER_",
"NO_IRR_COMPILE_WITH_MD2_LOADER_",
"NO_IRR_COMPILE_WITH_MD3_LOADER_",
"NO_IRR_COMPILE_WITH_3DS_LOADER_",
"NO_IRR_COMPILE_WITH_COLLADA_LOADER_",
"NO_IRR_COMPILE_WITH_CSM_LOADER_",
"NO_IRR_COMPILE_WITH_BSP_LOADER_",
"NO_IRR_COMPILE_WITH_DMF_LOADER_",
"NO_IRR_COMPILE_WITH_LMTS_LOADER_",
"NO_IRR_COMPILE_WITH_MY3D_LOADER_",
"NO_IRR_COMPILE_WITH_OBJ_LOADER_",
"NO_IRR_COMPILE_WITH_OCT_LOADER_",
"NO_IRR_COMPILE_WITH_LWO_LOADER_",
"NO_IRR_COMPILE_WITH_STL_LOADER_",
"NO_IRR_COMPILE_WITH_PLY_LOADER_",
"NO_IRR_COMPILE_WITH_SMF_LOADER_",
"NO_IRR_COMPILE_WITH_IRR_WRITER_",
"NO_IRR_COMPILE_WITH_COLLADA_WRITER_",
"NO_IRR_COMPILE_WITH_STL_WRITER_",
"NO_IRR_COMPILE_WITH_OBJ_WRITER_",
"NO_IRR_COMPILE_WITH_PLY_WRITER_",
"NO_IRR_COMPILE_WITH_PCX_LOADER_",
"NO_IRR_COMPILE_WITH_PPM_LOADER_",
"NO_IRR_COMPILE_WITH_PSD_LOADER_",
"NO_IRR_COMPILE_WITH_TGA_LOADER_",
"NO_IRR_COMPILE_WITH_WAL_LOADER_",
"NO_IRR_COMPILE_WITH_LMP_LOADER_",
"NO_IRR_COMPILE_WITH_RGB_LOADER_",
"NO_IRR_COMPILE_WITH_PCX_WRITER_",
"NO_IRR_COMPILE_WITH_PPM_WRITER_",
"NO_IRR_COMPILE_WITH_PSD_WRITER_",
"NO_IRR_COMPILE_WITH_TGA_WRITER_",
"NO__IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_",
"NO__IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_",
"NO__IRR_COMPILE_WITH_WAD_ARCHIVE_LOADER_",
}
This diff is collapsed.
project "miniaudio"
kind "StaticLib"
files { "miniaudio.c", "miniaudio.h" }
defines { "MA_NO_ENCODING", "MA_NO_GENERATION", "MA_NO_NEON" }
if MINIAUDIO_SUPPORT_OPUS_VORBIS then
files { "extras/decoders/libopus/*", "extras/decoders/libvorbis/*" }
if MINIAUDIO_BUILD_OPUS_VORBIS then
files {
"external/ogg/src/bitwise.c",
"external/ogg/src/framing.c",
"external/opus/src/opus.c",
"external/opus/src/opus_decoder.c",
"external/opus/src/opus_multistream.c",
"external/opus/src/opus_multistream_decoder.c",
"external/opus/celt/bands.c",
"external/opus/celt/celt.c",
"external/opus/celt/celt_decoder.c",
"external/opus/celt/celt_lpc.c",
"external/opus/celt/cwrs.c",
"external/opus/celt/entcode.c",
"external/opus/celt/entdec.c",
"external/opus/celt/entenc.c",
"external/opus/celt/kiss_fft.c",
"external/opus/celt/laplace.c",
"external/opus/celt/mathops.c",
"external/opus/celt/mdct.c",
"external/opus/celt/modes.c",
"external/opus/celt/pitch.c",
"external/opus/celt/quant_bands.c",
"external/opus/celt/rate.c",
"external/opus/celt/vq.c",
"external/opus/celt/x86/pitch_avx.c",
"external/opus/celt/x86/pitch_sse.c",
"external/opus/celt/x86/vq_sse2.c",
"external/opus/celt/x86/x86_celt_map.c",
"external/opus/celt/x86/x86cpu.c",
"external/opus/silk/bwexpander.c",
"external/opus/silk/bwexpander_32.c",
"external/opus/silk/CNG.c",
"external/opus/silk/code_signs.c",
"external/opus/silk/dec_API.c",
"external/opus/silk/decode_core.c",
"external/opus/silk/decode_frame.c",
"external/opus/silk/decode_indices.c",
"external/opus/silk/decode_parameters.c",
"external/opus/silk/decode_pitch.c",
"external/opus/silk/decode_pulses.c",
"external/opus/silk/decoder_set_fs.c",
"external/opus/silk/gain_quant.c",
"external/opus/silk/init_decoder.c",
"external/opus/silk/lin2log.c",
"external/opus/silk/log2lin.c",
"external/opus/silk/LPC_analysis_filter.c",
"external/opus/silk/LPC_fit.c",
"external/opus/silk/LPC_inv_pred_gain.c",
"external/opus/silk/NLSF_decode.c",
"external/opus/silk/NLSF_stabilize.c",
"external/opus/silk/NLSF_unpack.c",
"external/opus/silk/NLSF2A.c",
"external/opus/silk/pitch_est_tables.c",
"external/opus/silk/PLC.c",
"external/opus/silk/resampler.c",
"external/opus/silk/resampler_private_AR2.c",
"external/opus/silk/resampler_private_down_FIR.c",
"external/opus/silk/resampler_private_IIR_FIR.c",
"external/opus/silk/resampler_private_up2_HQ.c",
"external/opus/silk/resampler_rom.c",
"external/opus/silk/shell_coder.c",
"external/opus/silk/sort.c",
"external/opus/silk/stereo_decode_pred.c",
"external/opus/silk/stereo_MS_to_LR.c",
"external/opus/silk/sum_sqr_shift.c",
"external/opus/silk/table_LSF_cos.c",
"external/opus/silk/tables_gain.c",
"external/opus/silk/tables_LTP.c",
"external/opus/silk/tables_NLSF_CB_NB_MB.c",
"external/opus/silk/tables_NLSF_CB_WB.c",
"external/opus/silk/tables_other.c",
"external/opus/silk/tables_pitch_lag.c",
"external/opus/silk/tables_pulses_per_block.c",
"external/opusfile/src/info.c",
"external/opusfile/src/internal.c",
"external/opusfile/src/opusfile.c",
"external/opusfile/src/stream.c",
"external/vorbis/lib/bitrate.c",
"external/vorbis/lib/block.c",
"external/vorbis/lib/codebook.c",
"external/vorbis/lib/envelope.c",
"external/vorbis/lib/floor0.c",
"external/vorbis/lib/floor1.c",
"external/vorbis/lib/info.c",
"external/vorbis/lib/lpc.c",
"external/vorbis/lib/lsp.c",
"external/vorbis/lib/mapping0.c",
"external/vorbis/lib/mdct.c",
"external/vorbis/lib/psy.c",
"external/vorbis/lib/registry.c",
"external/vorbis/lib/res0.c",
"external/vorbis/lib/sharedbook.c",
"external/vorbis/lib/smallft.c",
"external/vorbis/lib/synthesis.c",
"external/vorbis/lib/vorbisfile.c",
"external/vorbis/lib/window.c",
}
includedirs {
"external/ogg/include",
"external/opus/include",
"external/opus/celt",
"external/opus/silk",
"external/opusfile/include",
"external/vorbis/include",
}
defines {
"OPUS_BUILD", "USE_ALLOCA", "HAVE_LRINTF", "OP_HAVE_LRINTF",
"OPUS_X86_PRESUME_SSE", "OPUS_X86_PRESUME_SSE2",
"OPUS_HAVE_RTCD", "OPUS_X86_MAY_HAVE_SSE", "OPUS_X86_MAY_HAVE_SSE4_1", "OPUS_X86_MAY_HAVE_AVX2",
}
else
includedirs { OPUS_INCLUDE_DIR, VORBIS_INCLUDE_DIR, OGG_INCLUDE_DIR }
end
end
filter "system:linux"
links { "dl", "pthread", "m" }
-- default global settings -- default global settings
BUILD_LUA = true BUILD_LUA = true
LUA_LIB_NAME = "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 = not os.istarget("macosx") BUILD_IRRLICHT = true
USE_IRRKLANG = true
USE_AUDIO = true
AUDIO_LIB = "miniaudio"
MINIAUDIO_SUPPORT_OPUS_VORBIS = true
MINIAUDIO_BUILD_OPUS_VORBIS = os.istarget("windows")
IRRKLANG_PRO = false IRRKLANG_PRO = false
LUA_LIB_NAME = "lua" IRRKLANG_PRO_BUILD_IKPMP3 = false
-- read settings from command line or environment variables -- read settings from command line or environment variables
...@@ -15,7 +21,7 @@ newoption { trigger = "build-lua", category = "YGOPro - lua", description = "" } ...@@ -15,7 +21,7 @@ newoption { trigger = "build-lua", category = "YGOPro - lua", description = "" }
newoption { trigger = "no-build-lua", category = "YGOPro - lua", description = "" } 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" } newoption { trigger = "lua-lib-name", category = "YGOPro - lua", description = "", value = "NAME", default = LUA_LIB_NAME }
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 = "" }
...@@ -37,8 +43,24 @@ newoption { trigger = "no-build-irrlicht", category = "YGOPro - irrlicht", descr ...@@ -37,8 +43,24 @@ newoption { trigger = "no-build-irrlicht", category = "YGOPro - irrlicht", descr
newoption { trigger = "irrlicht-include-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" } newoption { trigger = "irrlicht-include-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" }
newoption { trigger = "irrlicht-lib-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" } newoption { trigger = "irrlicht-lib-dir", category = "YGOPro - irrlicht", description = "", value = "PATH" }
newoption { trigger = "use-irrklang", category = "YGOPro - irrklang", description = "" } newoption { trigger = "no-audio", category = "YGOPro", description = "" }
newoption { trigger = "no-use-irrklang", category = "YGOPro - irrklang", description = "" } newoption { trigger = "audio-lib", category = "YGOPro", description = "", value = "miniaudio, irrklang", default = AUDIO_LIB }
newoption { trigger = "miniaudio-include-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "miniaudio-lib-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "miniaudio-support-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "no-miniaudio-support-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "build-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "no-build-opus-vorbis", category = "YGOPro - miniaudio", description = "" }
newoption { trigger = "opus-include-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "opus-lib-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "vorbis-include-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "vorbis-lib-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "ogg-include-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "ogg-lib-dir", category = "YGOPro - miniaudio", description = "", value = "PATH" }
newoption { trigger = "use-irrklang", category = "YGOPro - irrklang", description = "Deprecated, use audio-lib=irrklang" }
newoption { trigger = "no-use-irrklang", category = "YGOPro - irrklang", description = "Deprecated, use no-audio" }
newoption { trigger = "irrklang-include-dir", category = "YGOPro - irrklang", description = "", value = "PATH" } newoption { trigger = "irrklang-include-dir", category = "YGOPro - irrklang", description = "", value = "PATH" }
newoption { trigger = "irrklang-lib-dir", category = "YGOPro - irrklang", description = "", value = "PATH" } newoption { trigger = "irrklang-lib-dir", category = "YGOPro - irrklang", description = "", value = "PATH" }
...@@ -108,37 +130,75 @@ if not BUILD_IRRLICHT then ...@@ -108,37 +130,75 @@ if not BUILD_IRRLICHT then
IRRLICHT_LIB_DIR = GetParam("irrlicht-lib-dir") or os.findlib("irrlicht") IRRLICHT_LIB_DIR = GetParam("irrlicht-lib-dir") or os.findlib("irrlicht")
end end
if GetParam("use-irrklang") then if GetParam("no-audio") then
USE_IRRKLANG = true USE_AUDIO = false
elseif GetParam("no-use-miniaudio") then
print("Warning: --no-use-miniaudio is deprecated, use --no-audio")
USE_AUDIO = false
elseif GetParam("use-miniaudio") then
print("Warning: --use-miniaudio is deprecated, use --audio-lib=miniaudio")
USE_AUDIO = true
AUDIO_LIB = "miniaudio"
elseif GetParam("no-use-irrklang") then elseif GetParam("no-use-irrklang") then
USE_IRRKLANG = false print("Warning: --no-use-irrklang is deprecated, use --no-audio")
end USE_AUDIO = false
if USE_IRRKLANG then elseif GetParam("use-irrklang") then
IRRKLANG_INCLUDE_DIR = GetParam("irrklang-include-dir") or "../irrklang/include" print("Warning: --use-irrklang is deprecated, use --audio-lib=irrklang")
if os.istarget("windows") then USE_AUDIO = true
IRRKLANG_LIB_DIR = "../irrklang/lib/Win32-visualStudio" AUDIO_LIB = "irrklang"
elseif os.istarget("linux") then
IRRKLANG_LIB_DIR = "../irrklang/bin/linux-gcc-64"
IRRKLANG_LINK_RPATH = "-Wl,-rpath=./lib/"
elseif os.istarget("macosx") then
IRRKLANG_LIB_DIR = "../irrklang/bin/macosx-gcc"
end
IRRKLANG_LIB_DIR = GetParam("irrklang-lib-dir") or IRRKLANG_LIB_DIR
end end
if GetParam("irrklang-pro") and os.istarget("windows") then if USE_AUDIO then
IRRKLANG_PRO = true AUDIO_LIB = GetParam("audio-lib") or AUDIO_LIB
elseif GetParam("no-irrklang-pro") then if AUDIO_LIB == "miniaudio" then
IRRKLANG_PRO = false if GetParam("miniaudio-support-opus-vorbis") then
end MINIAUDIO_SUPPORT_OPUS_VORBIS = true
if IRRKLANG_PRO then elseif GetParam("no-miniaudio-support-opus-vorbis") then
-- irrklang pro can't use the pro lib to debug MINIAUDIO_SUPPORT_OPUS_VORBIS = false
IRRKLANG_PRO_RELEASE_LIB_DIR = GetParam("irrklang-pro-release-lib-dir") or "../irrklang/lib/Win32-vs2019" end
IRRKLANG_PRO_DEBUG_LIB_DIR = GetParam("irrklang-pro-debug-lib-dir") or "../irrklang/lib/Win32-visualStudio-debug" if MINIAUDIO_SUPPORT_OPUS_VORBIS then
if GetParam("no-build-opus-vorbis") then
MINIAUDIO_BUILD_OPUS_VORBIS = false
elseif GetParam("build-opus-vorbis") then
MINIAUDIO_BUILD_OPUS_VORBIS = true
end
if not MINIAUDIO_BUILD_OPUS_VORBIS then
OPUS_INCLUDE_DIR = GetParam("opus-include-dir") or os.findheader("opus")
OPUS_LIB_DIR = GetParam("opus-lib-dir") or os.findlib("opusfile")
VORBIS_INCLUDE_DIR = GetParam("vorbis-include-dir") or os.findheader("vorbis")
VORBIS_LIB_DIR = GetParam("vorbis-lib-dir") or os.findlib("vorbis")
OGG_INCLUDE_DIR = GetParam("ogg-include-dir") or os.findheader("ogg")
OCG_LIB_DIR = GetParam("ogg-lib-dir") or os.findlib("ogg")
end
end
elseif AUDIO_LIB == "irrklang" then
print("Warning: irrKlang is deprecated and may be removed in future, please consider switching to miniaudio")
IRRKLANG_INCLUDE_DIR = GetParam("irrklang-include-dir") or "../irrklang/include"
if os.istarget("windows") then
IRRKLANG_LIB_DIR = "../irrklang/lib/Win32-visualStudio"
elseif os.istarget("linux") then
IRRKLANG_LIB_DIR = "../irrklang/bin/linux-gcc-64"
IRRKLANG_LINK_RPATH = "-Wl,-rpath=./irrklang/bin/linux-gcc-64/"
elseif os.istarget("macosx") then
IRRKLANG_LIB_DIR = "../irrklang/bin/macosx-gcc"
end
IRRKLANG_LIB_DIR = GetParam("irrklang-lib-dir") or IRRKLANG_LIB_DIR
if GetParam("irrklang-pro") and os.istarget("windows") then
IRRKLANG_PRO = true
elseif GetParam("no-irrklang-pro") then
IRRKLANG_PRO = false
end
if IRRKLANG_PRO then
-- irrklang pro can't use the pro lib to debug
IRRKLANG_PRO_RELEASE_LIB_DIR = GetParam("irrklang-pro-release-lib-dir") or "../irrklang/lib/Win32-vs2019"
IRRKLANG_PRO_DEBUG_LIB_DIR = GetParam("irrklang-pro-debug-lib-dir") or "../irrklang/lib/Win32-visualStudio-debug"
end
IRRKLANG_PRO_BUILD_IKPMP3 = GetParam("build-ikpmp3") or IRRKLANG_PRO
else
error("Unknown audio library: " .. AUDIO_LIB)
end
end end
BUILD_IKPMP3 = USE_IRRKLANG and (GetParam("build-ikpmp3") or IRRKLANG_PRO)
if GetParam("winxp-support") and os.istarget("windows") then if GetParam("winxp-support") and os.istarget("windows") then
WINXP_SUPPORT = true WINXP_SUPPORT = true
end end
...@@ -158,7 +218,6 @@ workspace "YGOPro" ...@@ -158,7 +218,6 @@ workspace "YGOPro"
configurations { "Release", "Debug" } configurations { "Release", "Debug" }
filter "system:windows" filter "system:windows"
defines { "WIN32", "_WIN32" }
entrypoint "mainCRTStartup" entrypoint "mainCRTStartup"
systemversion "latest" systemversion "latest"
startproject "YGOPro" startproject "YGOPro"
...@@ -171,7 +230,6 @@ workspace "YGOPro" ...@@ -171,7 +230,6 @@ workspace "YGOPro"
filter "system:macosx" filter "system:macosx"
libdirs { "/usr/local/lib" } libdirs { "/usr/local/lib" }
buildoptions { "-stdlib=libc++" }
if MAC_ARM then if MAC_ARM then
buildoptions { "--target=arm64-apple-macos12" } buildoptions { "--target=arm64-apple-macos12" }
end end
...@@ -239,6 +297,11 @@ workspace "YGOPro" ...@@ -239,6 +297,11 @@ workspace "YGOPro"
if BUILD_SQLITE then if BUILD_SQLITE then
include "sqlite3" include "sqlite3"
end end
if BUILD_IKPMP3 then if USE_AUDIO then
include "ikpmp3" if AUDIO_LIB=="miniaudio" then
include "miniaudio"
end
if IRRKLANG_PRO_BUILD_IKPMP3 then
include "ikpmp3"
end
end end
...@@ -8,6 +8,7 @@ equip.wav ...@@ -8,6 +8,7 @@ equip.wav
destroyed.wav destroyed.wav
banished.wav banished.wav
token.wav token.wav
negate.wav
attack.wav attack.wav
directattack.wav directattack.wav
draw.wav draw.wav
......
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