Commit 84eddec4 authored by nanahira's avatar nanahira

Merge branch 'develop' into server-develop

parents f8ad279b 2e299472
Pipeline #36584 passed with stages
in 11 minutes and 37 seconds
...@@ -8,6 +8,8 @@ export EVENT_INCLUDE_DIR=$PWD/libevent-stable/include ...@@ -8,6 +8,8 @@ export EVENT_INCLUDE_DIR=$PWD/libevent-stable/include
export EVENT_LIB_DIR=$PWD/libevent-stable/lib export EVENT_LIB_DIR=$PWD/libevent-stable/lib
export OPUS_INCLUDE_DIR=$PWD/miniaudio/external-built/include/opus export OPUS_INCLUDE_DIR=$PWD/miniaudio/external-built/include/opus
export OPUS_LIB_DIR=$PWD/miniaudio/external-built/lib export OPUS_LIB_DIR=$PWD/miniaudio/external-built/lib
export OPUSFILE_INCLUDE_DIR=$PWD/miniaudio/external-built/include/opus
export OPUSFILE_LIB_DIR=$PWD/miniaudio/external-built/lib
export VORBIS_INCLUDE_DIR=$PWD/miniaudio/external-built/include export VORBIS_INCLUDE_DIR=$PWD/miniaudio/external-built/include
export VORBIS_LIB_DIR=$PWD/miniaudio/external-built/lib export VORBIS_LIB_DIR=$PWD/miniaudio/external-built/lib
export OGG_INCLUDE_DIR=$PWD/miniaudio/external-built/include export OGG_INCLUDE_DIR=$PWD/miniaudio/external-built/include
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
* @brief Copy a C-style string to another C-style string. * @brief Copy a C-style string to another C-style string.
* @param src The source wide string * @param src The source wide string
* @param pstr The destination char string * @param pstr The destination char string
* @param bufsize The size of the destination buffer * @param bufsize The length of the destination buffer
* @return The length of the copied string * @return The length of the copied string
*/ */
template<typename T1, typename T2> template<typename T1, typename T2>
...@@ -68,13 +68,13 @@ public: ...@@ -68,13 +68,13 @@ public:
} }
template<size_t N> template<size_t N>
static void CopyString(const char* src, char(&dst)[N]) { static void CopyString(const char* src, char(&dst)[N]) {
dst[0] = 0; std::strncpy(dst, src, N - 1);
std::strncat(dst, src, N - 1); dst[N - 1] = 0;
} }
template<size_t N> template<size_t N>
static void CopyWideString(const wchar_t* src, wchar_t(&dst)[N]) { static void CopyWideString(const wchar_t* src, wchar_t(&dst)[N]) {
dst[0] = 0; std::wcsncpy(dst, src, N - 1);
std::wcsncat(dst, src, N - 1); dst[N - 1] = 0;
} }
template<typename T> template<typename T>
static bool CheckUTF8Byte(const T* str, int len) { static bool CheckUTF8Byte(const T* str, int len) {
......
...@@ -37,11 +37,17 @@ int main(int argc, char* argv[]) { ...@@ -37,11 +37,17 @@ int main(int argc, char* argv[]) {
#if defined __APPLE__ && !defined YGOPRO_SERVER_MODE #if defined __APPLE__ && !defined YGOPRO_SERVER_MODE
CFURLRef bundle_url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFURLRef bundle_url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFURLRef bundle_base_url = CFURLCreateCopyDeletingLastPathComponent(nullptr, bundle_url); CFURLRef bundle_base_url = CFURLCreateCopyDeletingLastPathComponent(nullptr, bundle_url);
CFStringRef bundle_ext = CFURLCopyPathExtension(bundle_url);
if (bundle_ext) {
char path[PATH_MAX];
if (CFStringCompare(bundle_ext, CFSTR("app"), kCFCompareCaseInsensitive) == kCFCompareEqualTo
&& CFURLGetFileSystemRepresentation(bundle_base_url, true, (UInt8*)path, PATH_MAX)) {
chdir(path);
}
CFRelease(bundle_ext);
}
CFRelease(bundle_url); CFRelease(bundle_url);
CFStringRef path = CFURLCopyFileSystemPath(bundle_base_url, kCFURLPOSIXPathStyle);
CFRelease(bundle_base_url); CFRelease(bundle_base_url);
chdir(CFStringGetCStringPtr(path, kCFStringEncodingUTF8));
CFRelease(path);
#endif //__APPLE__ #endif //__APPLE__
#ifdef _WIN32 #ifdef _WIN32
if (argc == 2 && (ygo::IsExtension(argv[1], ".ydk") || ygo::IsExtension(argv[1], ".yrp"))) { // open file from explorer if (argc == 2 && (ygo::IsExtension(argv[1], ".ydk") || ygo::IsExtension(argv[1], ".yrp"))) { // open file from explorer
......
...@@ -159,7 +159,7 @@ bool ReplayMode::StartDuel() { ...@@ -159,7 +159,7 @@ bool ReplayMode::StartDuel() {
unsigned int seed = rh.seed; unsigned int seed = rh.seed;
std::mt19937 rnd(seed); std::mt19937 rnd(seed);
cur_replay.SkipInfo(); cur_replay.SkipInfo();
if(mainGame->dInfo.isTag) { if(rh.flag & REPLAY_TAG) {
BufferIO::CopyWideString(cur_replay.players[0].c_str(), mainGame->dInfo.hostname); BufferIO::CopyWideString(cur_replay.players[0].c_str(), mainGame->dInfo.hostname);
BufferIO::CopyWideString(cur_replay.players[1].c_str(), mainGame->dInfo.hostname_tag); BufferIO::CopyWideString(cur_replay.players[1].c_str(), mainGame->dInfo.hostname_tag);
BufferIO::CopyWideString(cur_replay.players[2].c_str(), mainGame->dInfo.clientname_tag); BufferIO::CopyWideString(cur_replay.players[2].c_str(), mainGame->dInfo.clientname_tag);
...@@ -849,12 +849,12 @@ bool ReplayMode::ReplayAnalyze(unsigned char* msg, unsigned int len) { ...@@ -849,12 +849,12 @@ bool ReplayMode::ReplayAnalyze(unsigned char* msg, unsigned int len) {
break; break;
} }
case MSG_AI_NAME: { case MSG_AI_NAME: {
int len = BufferIO::ReadInt16(pbuf); int len = buffer_read<uint16_t>(pbuf);
pbuf += len + 1; pbuf += len + 1;
break; break;
} }
case MSG_SHOW_HINT: { case MSG_SHOW_HINT: {
int len = BufferIO::ReadInt16(pbuf); int len = buffer_read<uint16_t>(pbuf);
pbuf += len + 1; pbuf += len + 1;
break; break;
} }
......
...@@ -763,21 +763,25 @@ bool SingleMode::SinglePlayAnalyze(unsigned char* msg, unsigned int len) { ...@@ -763,21 +763,25 @@ bool SingleMode::SinglePlayAnalyze(unsigned char* msg, unsigned int len) {
case MSG_AI_NAME: { case MSG_AI_NAME: {
char namebuf[128]{}; char namebuf[128]{};
wchar_t wname[20]{}; wchar_t wname[20]{};
int len = BufferIO::ReadInt16(pbuf); int name_len = buffer_read<uint16_t>(pbuf);
auto begin = pbuf; if (name_len + 1 <= (int)sizeof namebuf) {
pbuf += len + 1; std::memcpy(namebuf, pbuf, name_len);
std::memcpy(namebuf, begin, len + 1); namebuf[name_len] = 0;
}
pbuf += name_len + 1;
BufferIO::DecodeUTF8(namebuf, wname); BufferIO::DecodeUTF8(namebuf, wname);
BufferIO::CopyCharArray(wname, mainGame->dInfo.clientname); BufferIO::CopyCharArray(wname, mainGame->dInfo.clientname);
break; break;
} }
case MSG_SHOW_HINT: { case MSG_SHOW_HINT: {
char msgbuf[1024]; char msgbuf[1024]{};
wchar_t msg[1024]; wchar_t msg[1024]{};
int len = BufferIO::ReadInt16(pbuf); int msg_len = buffer_read<uint16_t>(pbuf);
auto begin = pbuf; if (msg_len + 1 <= (int)sizeof msgbuf) {
pbuf += len + 1; std::memcpy(msgbuf, pbuf, msg_len);
std::memcpy(msgbuf, begin, len + 1); msgbuf[msg_len] = 0;
}
pbuf += msg_len + 1;
BufferIO::DecodeUTF8(msgbuf, msg); BufferIO::DecodeUTF8(msgbuf, msg);
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stMessage, 310, mainGame->guiFont, msg); mainGame->SetStaticText(mainGame->stMessage, 310, mainGame->guiFont, msg);
......
...@@ -16,6 +16,7 @@ project "irrlicht" ...@@ -16,6 +16,7 @@ project "irrlicht"
"_IRR_STATIC_LIB_", "_IRR_STATIC_LIB_",
"NO_IRR_USE_NON_SYSTEM_BZLIB_", "NO_IRR_USE_NON_SYSTEM_BZLIB_",
"NO_IRR_COMPILE_WITH_BZIP2_", "NO_IRR_COMPILE_WITH_BZIP2_",
"NO_IRR_COMPILE_WITH_LZMA_",
"NO_IRR_COMPILE_WITH_CONSOLE_DEVICE_", "NO_IRR_COMPILE_WITH_CONSOLE_DEVICE_",
"NO_IRR_COMPILE_WITH_DIRECT3D_8_", "NO_IRR_COMPILE_WITH_DIRECT3D_8_",
"NO_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_", "NO_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_",
......
...@@ -133,6 +133,14 @@ function ApplyNumber(param) ...@@ -133,6 +133,14 @@ function ApplyNumber(param)
end end
end end
function FindHeaderWithSubDir(header, subdir)
local result = os.findheader(header)
if result and subdir then
result = path.join(result, subdir)
end
return result
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
...@@ -169,7 +177,7 @@ elseif GetParam("no-build-freetype") then ...@@ -169,7 +177,7 @@ elseif GetParam("no-build-freetype") then
BUILD_FREETYPE = false BUILD_FREETYPE = false
end end
if not BUILD_FREETYPE then if not BUILD_FREETYPE then
FREETYPE_INCLUDE_DIR = GetParam("freetype-include-dir") or os.findheader("freetype2/ft2build.h") .. "/freetype2" FREETYPE_INCLUDE_DIR = GetParam("freetype-include-dir") or FindHeaderWithSubDir("freetype2/ft2build.h", "freetype2")
FREETYPE_LIB_DIR = GetParam("freetype-lib-dir") or os.findlib("freetype") FREETYPE_LIB_DIR = GetParam("freetype-lib-dir") or os.findlib("freetype")
end end
...@@ -227,9 +235,9 @@ if USE_AUDIO then ...@@ -227,9 +235,9 @@ if USE_AUDIO then
MINIAUDIO_BUILD_OPUS_VORBIS = true MINIAUDIO_BUILD_OPUS_VORBIS = true
end end
if not MINIAUDIO_BUILD_OPUS_VORBIS then if not MINIAUDIO_BUILD_OPUS_VORBIS then
OPUS_INCLUDE_DIR = GetParam("opus-include-dir") or os.findheader("opus/opus.h") .. "/opus" OPUS_INCLUDE_DIR = GetParam("opus-include-dir") or FindHeaderWithSubDir("opus/opus.h", "opus")
OPUS_LIB_DIR = GetParam("opus-lib-dir") or os.findlib("opus") OPUS_LIB_DIR = GetParam("opus-lib-dir") or os.findlib("opus")
OPUSFILE_INCLUDE_DIR = GetParam("opusfile-include-dir") or os.findheader("opus/opusfile.h") .. "/opus" OPUSFILE_INCLUDE_DIR = GetParam("opusfile-include-dir") or FindHeaderWithSubDir("opus/opusfile.h", "opus")
OPUSFILE_LIB_DIR = GetParam("opusfile-lib-dir") or os.findlib("opusfile") OPUSFILE_LIB_DIR = GetParam("opusfile-lib-dir") or os.findlib("opusfile")
VORBIS_INCLUDE_DIR = GetParam("vorbis-include-dir") or os.findheader("vorbis/vorbisfile.h") VORBIS_INCLUDE_DIR = GetParam("vorbis-include-dir") or os.findheader("vorbis/vorbisfile.h")
VORBIS_LIB_DIR = GetParam("vorbis-lib-dir") or os.findlib("vorbis") VORBIS_LIB_DIR = GetParam("vorbis-lib-dir") or os.findlib("vorbis")
......
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