Commit 618b60f1 authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/Fluorohydride/ygopro into server

parents fd25e6dc 2cfeac47
This diff is collapsed.
...@@ -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;
...@@ -798,14 +782,14 @@ bool Game::Initialize() { ...@@ -798,14 +782,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);
...@@ -1188,22 +1172,26 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cW ...@@ -1188,22 +1172,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);
...@@ -1211,7 +1199,7 @@ void Game::LoadExpansions() { ...@@ -1211,7 +1199,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
...@@ -1320,7 +1308,7 @@ void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const w ...@@ -1320,7 +1308,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,11 +44,16 @@ else ...@@ -44,11 +44,16 @@ 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
includedirs { EVENT_INCLUDE_DIR } includedirs { EVENT_INCLUDE_DIR }
libdirs { EVENT_LIB_DIR } libdirs { EVENT_LIB_DIR }
links { "event_pthreads" }
end end
if BUILD_IRRLICHT then if BUILD_IRRLICHT then
...@@ -100,11 +105,13 @@ end ...@@ -100,11 +105,13 @@ end
end end
filter "system:windows" filter "system:windows"
entrypoint "mainCRTStartup"
defines { "_IRR_WCHAR_FILESYSTEM" } defines { "_IRR_WCHAR_FILESYSTEM" }
files "ygopro.rc" files "ygopro.rc"
if SERVER_PRO2_SUPPORT then if SERVER_PRO2_SUPPORT then
targetname ("AI.Server") targetname ("AI.Server")
end end
links { "ws2_32" }
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
...@@ -116,26 +123,23 @@ end ...@@ -116,26 +123,23 @@ end
filter {} filter {}
end end
end end
if SERVER_MODE then
links { "ws2_32" }
else
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" }
end
filter "not system:windows"
links { "event_pthreads", "dl", "pthread" }
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
buildoptions { "--target=arm64-apple-macos12" }
linkoptions { "-arch arm64" } linkoptions { "-arch arm64" }
end end
if MAC_INTEL then
linkoptions { "-arch x86_64" }
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" }
......
...@@ -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) {
......
...@@ -8,7 +8,17 @@ project "event" ...@@ -8,7 +8,17 @@ 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
files { "evutil_time.c" }
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" }
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 { "WIN32" } -- quirk of old libevent
filter "system:linux"
files { "evthread_pthread.c", "epoll.c", "epoll_sub.c", "poll.c", "select.c" }
filter "system:macosx"
files { "evthread_pthread.c", "kqueue.c", "poll.c", "select.c" }
...@@ -155,10 +155,11 @@ project "irrlicht" ...@@ -155,10 +155,11 @@ project "irrlicht"
filter { "system:windows" } filter { "system:windows" }
defines { "_IRR_WCHAR_FILESYSTEM" } defines { "_IRR_WCHAR_FILESYSTEM" }
includedirs { "$(DXSDK_DIR)Include" } if USE_DXSDK then
includedirs { "$(DXSDK_DIR)Include" }
filter { "system:linux" } else
links { "X11", "Xxf86vm" } defines { "NO_IRR_COMPILE_WITH_DIRECT3D_9_" }
end
filter { "system:macosx" } filter { "system:macosx" }
cppdialect "gnu++14" cppdialect "gnu++14"
......
...@@ -33,12 +33,6 @@ project "miniaudio" ...@@ -33,12 +33,6 @@ project "miniaudio"
"external/opus/celt/rate.c", "external/opus/celt/rate.c",
"external/opus/celt/vq.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.c",
"external/opus/silk/bwexpander_32.c", "external/opus/silk/bwexpander_32.c",
"external/opus/silk/CNG.c", "external/opus/silk/CNG.c",
...@@ -118,14 +112,29 @@ project "miniaudio" ...@@ -118,14 +112,29 @@ project "miniaudio"
"external/vorbis/include", "external/vorbis/include",
} }
defines { defines {
"OPUS_BUILD", "USE_ALLOCA", "HAVE_LRINTF", "OP_HAVE_LRINTF", "OPUS_BUILD",
"OPUS_X86_PRESUME_SSE", "OPUS_X86_PRESUME_SSE2", "USE_ALLOCA",
"OPUS_HAVE_RTCD", "OPUS_X86_MAY_HAVE_SSE", "OPUS_X86_MAY_HAVE_SSE4_1", "OPUS_X86_MAY_HAVE_AVX2", "HAVE_LRINTF",
"OP_HAVE_LRINTF",
} }
if not TARGET_MAC_ARM then
files {
"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",
}
defines {
"OPUS_HAVE_RTCD", "CPU_INFO_BY_ASM",
"OPUS_X86_PRESUME_SSE", "OPUS_X86_PRESUME_SSE2",
"OPUS_X86_MAY_HAVE_SSE", "OPUS_X86_MAY_HAVE_SSE4_1", "OPUS_X86_MAY_HAVE_AVX2",
}
filter "system:linux"
buildoptions { "-mavx", "-mfma" }
filter {}
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",
}
-- default global settings -- Supported systems: Windows, Linux, MacOS
-- Global settings
-- Default: Build Lua, Irrlicht from source on all systems.
-- Don't build event, freetype, sqlite, opus, vorbis on Linux or MacOS, use apt or homebrew,
-- but build them on Windows, due to the lack of package manager on Windows.
BUILD_LUA = true BUILD_LUA = true
LUA_LIB_NAME = "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
BUILD_IRRLICHT = true -- modified Irrlicht is required, can't use the official one
USE_DXSDK = true
USE_AUDIO = false USE_AUDIO = false
AUDIO_LIB = "miniaudio" AUDIO_LIB = "miniaudio" -- can be "miniaudio" or "irrklang"
-- BUILD_MINIAUDIO is always true
MINIAUDIO_SUPPORT_OPUS_VORBIS = true MINIAUDIO_SUPPORT_OPUS_VORBIS = true
MINIAUDIO_BUILD_OPUS_VORBIS = os.istarget("windows") MINIAUDIO_BUILD_OPUS_VORBIS = os.istarget("windows")
-- BUILD_IRRKLANG is impossible because irrKlang is not open source
IRRKLANG_PRO = false IRRKLANG_PRO = false
IRRKLANG_PRO_BUILD_IKPMP3 = false IRRKLANG_PRO_BUILD_IKPMP3 = false
...@@ -20,7 +32,7 @@ SERVER_ZIP_SUPPORT = false ...@@ -20,7 +32,7 @@ SERVER_ZIP_SUPPORT = false
SERVER_PRO2_SUPPORT = false SERVER_PRO2_SUPPORT = false
SERVER_TAG_SURRENDER_CONFIRM = false SERVER_TAG_SURRENDER_CONFIRM = false
-- read settings from command line or environment variables -- Read settings from command line or environment variables
newoption { trigger = "build-lua", category = "YGOPro - lua", description = "" } 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 = "" }
...@@ -48,6 +60,7 @@ newoption { trigger = "build-irrlicht", category = "YGOPro - irrlicht", descript ...@@ -48,6 +60,7 @@ newoption { trigger = "build-irrlicht", category = "YGOPro - irrlicht", descript
newoption { trigger = "no-build-irrlicht", category = "YGOPro - irrlicht", description = "" } newoption { trigger = "no-build-irrlicht", category = "YGOPro - irrlicht", description = "" }
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 = "no-dxsdk", category = "YGOPro - irrlicht", description = "" }
newoption { trigger = "no-audio", category = "YGOPro", description = "" } newoption { trigger = "no-audio", category = "YGOPro", description = "" }
newoption { trigger = "audio-lib", category = "YGOPro", description = "", value = "miniaudio, irrklang", default = AUDIO_LIB } newoption { trigger = "audio-lib", category = "YGOPro", description = "", value = "miniaudio, irrklang", default = AUDIO_LIB }
...@@ -77,7 +90,8 @@ newoption { trigger = "irrklang-pro-debug-lib-dir", category = "YGOPro - irrklan ...@@ -77,7 +90,8 @@ newoption { trigger = "irrklang-pro-debug-lib-dir", category = "YGOPro - irrklan
newoption { trigger = 'build-ikpmp3', category = "YGOPro - irrklang - ikpmp3", description = "" } newoption { trigger = 'build-ikpmp3', category = "YGOPro - irrklang - ikpmp3", description = "" }
newoption { trigger = "winxp-support", category = "YGOPro", description = "" } newoption { trigger = "winxp-support", category = "YGOPro", description = "" }
newoption { trigger = "mac-arm", category = "YGOPro", description = "Cross compile for Apple Silicon" } newoption { trigger = "mac-arm", category = "YGOPro", description = "Compile for Apple Silicon Mac" }
newoption { trigger = "mac-intel", category = "YGOPro", description = "Compile for Intel Mac" }
newoption { trigger = "server-mode", category = "YGOPro - server", description = "" } newoption { trigger = "server-mode", category = "YGOPro - server", description = "" }
newoption { trigger = "server-zip-support", category = "YGOPro - server", description = "" } newoption { trigger = "server-zip-support", category = "YGOPro - server", description = "" }
...@@ -137,9 +151,9 @@ elseif GetParam("no-build-lua") then ...@@ -137,9 +151,9 @@ elseif GetParam("no-build-lua") then
BUILD_LUA = false BUILD_LUA = false
end end
if not BUILD_LUA then if not BUILD_LUA then
-- at most times you need to change this if you change BUILD_LUA to false -- at most times you need to change those if you change BUILD_LUA to false
-- make sure your lua lib is built with C++ and version >= 5.3 -- make sure your lua lib is built with C++ and version >= 5.3
LUA_LIB_NAME = GetParam("lua-lib-name") LUA_LIB_NAME = GetParam("lua-lib-name") or LUA_LIB_NAME
LUA_INCLUDE_DIR = GetParam("lua-include-dir") or os.findheader("lua.h") LUA_INCLUDE_DIR = GetParam("lua-include-dir") or os.findheader("lua.h")
LUA_LIB_DIR = GetParam("lua-lib-dir") or os.findlib(LUA_LIB_NAME) LUA_LIB_DIR = GetParam("lua-lib-dir") or os.findlib(LUA_LIB_NAME)
end end
...@@ -152,7 +166,7 @@ if GetParam("lua-deb") then ...@@ -152,7 +166,7 @@ if GetParam("lua-deb") then
end end
if GetParam("build-event") then if GetParam("build-event") then
BUILD_EVENT = os.istarget("windows") -- only on windows for now BUILD_EVENT = true
elseif GetParam("no-build-event") then elseif GetParam("no-build-event") then
BUILD_EVENT = false BUILD_EVENT = false
end end
...@@ -191,6 +205,16 @@ if not BUILD_IRRLICHT then ...@@ -191,6 +205,16 @@ 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("no-dxsdk") then
USE_DXSDK = false
end
if USE_DXSDK and os.istarget("windows") then
if not os.getenv("DXSDK_DIR") then
print("DXSDK_DIR environment variable not set, it seems you don't have the DirectX SDK installed. DirectX mode will be disabled.")
USE_DXSDK = false
end
end
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
...@@ -265,8 +289,26 @@ end ...@@ -265,8 +289,26 @@ end
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
if GetParam("mac-arm") and os.istarget("macosx") then
MAC_ARM = true if os.istarget("macosx") then
if GetParam("mac-arm") then
MAC_ARM = true
end
if GetParam("mac-intel") then
MAC_INTEL = true
end
if MAC_ARM then
TARGET_MAC_ARM = true
elseif not MAC_INTEL then
-- automatic target arm64, need extra detect
local uname = os.outputof("uname -m")
local proctranslated = os.outputof("sysctl sysctl.proc_translated")
if uname:find("arm") or proctranslated then
print("Detected Apple Silicon Mac")
TARGET_MAC_ARM = true
end
end
end end
if GetParam("server-mode") then if GetParam("server-mode") then
SERVER_MODE = true SERVER_MODE = true
...@@ -298,7 +340,6 @@ workspace "YGOPro" ...@@ -298,7 +340,6 @@ workspace "YGOPro"
end end
filter "system:windows" filter "system:windows"
entrypoint "mainCRTStartup"
systemversion "latest" systemversion "latest"
startproject "YGOPro" startproject "YGOPro"
if WINXP_SUPPORT then if WINXP_SUPPORT then
...@@ -307,15 +348,25 @@ workspace "YGOPro" ...@@ -307,15 +348,25 @@ workspace "YGOPro"
else else
defines { "WINVER=0x0601" } -- WIN7 defines { "WINVER=0x0601" } -- WIN7
end end
platforms { "Win32", "x64" }
filter { "system:windows", "platforms:Win32" }
architecture "x86"
filter { "system:windows", "platforms:x64" }
architecture "x86_64"
filter "system:macosx" filter "system:macosx"
libdirs { "/usr/local/lib" } libdirs { "/usr/local/lib" }
if MAC_ARM then if MAC_ARM then
buildoptions { "--target=arm64-apple-macos12" } buildoptions { "-arch arm64" }
end
if MAC_INTEL then
buildoptions { "-arch x86_64", "-mavx", "-mfma" }
end
if MAC_ARM and MAC_INTEL then
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" }
...@@ -329,6 +380,18 @@ end ...@@ -329,6 +380,18 @@ end
defines "_DEBUG" defines "_DEBUG"
targetdir "bin/debug" targetdir "bin/debug"
filter { "system:windows", "platforms:Win32", "configurations:Release" }
targetdir "bin/release/x86"
filter { "system:windows", "platforms:Win32", "configurations:Debug" }
targetdir "bin/debug/x86"
filter { "system:windows", "platforms:x64", "configurations:Release" }
targetdir "bin/release/x64"
filter { "system:windows", "platforms:x64", "configurations:Debug" }
targetdir "bin/debug/x64"
filter { "configurations:Release", "action:vs*" } filter { "configurations:Release", "action:vs*" }
if linktimeoptimization then if linktimeoptimization then
linktimeoptimization "On" linktimeoptimization "On"
...@@ -339,11 +402,7 @@ end ...@@ -339,11 +402,7 @@ 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"
if not MAC_ARM then
buildoptions "-march=native"
end
filter { "configurations:Debug", "action:vs*" } filter { "configurations:Debug", "action:vs*" }
disablewarnings { "6011", "6031", "6054", "6262" } disablewarnings { "6011", "6031", "6054", "6262" }
...@@ -359,6 +418,9 @@ end ...@@ -359,6 +418,9 @@ end
filter "not action:vs*" filter "not action:vs*"
buildoptions { "-fno-strict-aliasing", "-Wno-multichar", "-Wno-format-security" } buildoptions { "-fno-strict-aliasing", "-Wno-multichar", "-Wno-format-security" }
if not MAC_ARM and not MAC_INTEL then
buildoptions "-march=native"
end
filter {} filter {}
......
Subproject commit 41bf9cd331a8c2b3a9c47629bd25cc1ae138e26c Subproject commit 5d667bfcff5d77bdfb2c7974635352a58eaab110
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