From 0023c4a08645740b5e712e6faeccc0af376012eb Mon Sep 17 00:00:00 2001 From: xawotihs Date: Fri, 25 Apr 2025 18:48:02 +0200 Subject: [PATCH] Fixed compilation with latest mingw64 --- .gitmodules | 3 +++ JGE/include/JSocket.h | 4 ++-- JGE/include/JTypes.h | 1 + JGE/src/JNetwork.cpp | 2 +- JGE/src/JResourceManager.cpp | 2 +- JGE/src/pc/JGfx.cpp | 8 ++++---- projects/mtg/include/config.h | 2 +- projects/mtg/src/GameApp.cpp | 2 +- projects/mtg/src/GameStateDuel.cpp | 13 +++++++++---- projects/mtg/src/MTGPack.cpp | 7 ++++++- thirdparty/curl | 1 + 11 files changed, 30 insertions(+), 15 deletions(-) create mode 160000 thirdparty/curl diff --git a/.gitmodules b/.gitmodules index 0d4cd28b5..0a4a52c45 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "docs/wiki"] path = docs/wiki url = https://github.com/WagicProject/wagic.wiki +[submodule "thirdparty/curl"] + path = thirdparty/curl + url = https://github.com/curl/curl.git diff --git a/JGE/include/JSocket.h b/JGE/include/JSocket.h index ab8bb2934..96d965572 100644 --- a/JGE/include/JSocket.h +++ b/JGE/include/JSocket.h @@ -42,9 +42,9 @@ private: // convert the socket into non-blocking state bool SetNonBlocking(int sock); // socket handle -#ifdef WIN32 +#if (defined WIN32) && (!defined __GNUG__) SOCKET mfd; -#elif LINUX || PSP +#elif LINUX || PSP || __GNUG__ int mfd; #endif }; diff --git a/JGE/include/JTypes.h b/JGE/include/JTypes.h index 5c022c612..56c2c2fd5 100644 --- a/JGE/include/JTypes.h +++ b/JGE/include/JTypes.h @@ -112,6 +112,7 @@ enum { #endif // CONSOLE_CONFIG #if (defined WIN32) && (!defined LINUX) + #define WIN32_LEAN_AND_MEAN #include #endif #if defined(LINUX) && (!defined WIN32) || defined(IOS) || defined (ANDROID) diff --git a/JGE/src/JNetwork.cpp b/JGE/src/JNetwork.cpp index 769764a52..3da363d38 100644 --- a/JGE/src/JNetwork.cpp +++ b/JGE/src/JNetwork.cpp @@ -42,7 +42,7 @@ bool JNetwork::isConnected(){ void JNetwork::getServerIp(string& aString) { -#ifdef WIN32 +#if (defined WIN32) && (!defined __GNUG__) char ac[80]; if (gethostname(ac, sizeof(ac)) == SOCKET_ERROR) { DebugTrace("Error " << WSAGetLastError() << diff --git a/JGE/src/JResourceManager.cpp b/JGE/src/JResourceManager.cpp index c9c64098b..2c2e3573e 100644 --- a/JGE/src/JResourceManager.cpp +++ b/JGE/src/JResourceManager.cpp @@ -16,7 +16,7 @@ #include "../include/JLBFont.h" #include "tinyxml.h" -#if defined (_DEBUG) && defined (WIN32) && (!defined LINUX) +#if defined (_DEBUG) && defined (WIN32) && (!defined LINUX) && (!defined __GNUG__) #include "crtdbg.h" #define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #else diff --git a/JGE/src/pc/JGfx.cpp b/JGE/src/pc/JGfx.cpp index 14716b86b..2bf1c8173 100644 --- a/JGE/src/pc/JGfx.cpp +++ b/JGE/src/pc/JGfx.cpp @@ -35,7 +35,7 @@ extern "C" { #include "../../include/JFileSystem.h" #include "../../include/JAssert.h" -#if (defined WIN32) && (!defined QT_CONFIG) +#if (defined WIN32) && (!defined QT_CONFIG) && (!defined SDL_CONFIG) #ifndef __attribute__ #define __attribute__((a)) #endif @@ -1665,7 +1665,7 @@ static void jpeg_mem_src(j_decompress_ptr cinfo, byte *mem, int len) cinfo->src->resync_to_restart = jpeg_resync_to_restart; cinfo->src->term_source = jpg_null; cinfo->src->bytes_in_buffer = len; - cinfo->src->next_input_byte = mem; + cinfo->src->next_input_byte = (const JOCTET*)mem; } /* @@ -1702,7 +1702,7 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); - jpeg_mem_src(&cinfo, rawdata, rawsize); + jpeg_mem_src(&cinfo, (byte*)rawdata, rawsize); // Process JPEG header jpeg_read_header(&cinfo, true); @@ -1740,7 +1740,7 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode // Pass sizes to output // Allocate Scanline buffer - scanline = (byte *)malloc(cinfo.output_width * 3); + scanline = (BYTE *)malloc(cinfo.output_width * 3); if(!scanline) { //// ri.Con_Printf(PRINT_ALL, "Insufficient RAM for JPEG scanline buffer\n"); diff --git a/projects/mtg/include/config.h b/projects/mtg/include/config.h index 55dcb0e91..d7b644705 100644 --- a/projects/mtg/include/config.h +++ b/projects/mtg/include/config.h @@ -11,7 +11,7 @@ #include "limits.h" -#if defined (_DEBUG) && defined (WIN32) && (!defined LINUX) +#if defined (_DEBUG) && defined (WIN32) && (!defined LINUX) && (!defined __GNUG__) #include "crtdbg.h" #define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #else diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index d029ef4a4..cb7fc9c62 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -91,7 +91,7 @@ void GameApp::Create() { srand((unsigned int) time(0)); // initialize random #if !defined(QT_CONFIG) && !defined(IOS) -#if defined (WIN32) +#if defined (WIN32) && (!defined __GNUG__) _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #elif defined (PSP) pspFpuSetEnable(0); //disable FPU Exceptions until we find where the FPU errors come from diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index 42ee19e94..2d9b12b18 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -16,6 +16,8 @@ #include "ModRules.h" #include "GameApp.h" +#include + #ifdef TESTSUITE #include "TestSuiteAI.h" #endif @@ -2258,7 +2260,10 @@ std::string Tournament::exportTournamentDescription() } void Tournament::enableTournamantMode(int tournamentMode,int player) -{ +{ + std::random_device rd; + std::mt19937 g(rd()); + if (mTournamentMode!=tournamentMode && tournamentMode>0) { @@ -2302,9 +2307,9 @@ void Tournament::enableTournamantMode(int tournamentMode,int player) //shuffle remaining decks // human player is always on first place if (player>0) - std::random_shuffle ( TournamentsDecks.begin()+1, TournamentsDecks.end() ); + std::shuffle ( TournamentsDecks.begin()+1, TournamentsDecks.end(), g ); else - std::random_shuffle ( TournamentsDecks.begin(), TournamentsDecks.end() ); + std::shuffle ( TournamentsDecks.begin(), TournamentsDecks.end(), g ); Deck[0]=TournamentsDecks[0]; Deck[1]=TournamentsDecks[1]; } @@ -2322,7 +2327,7 @@ void Tournament::enableTournamantMode(int tournamentMode,int player) for (unsigned int i=0;i MTGPack MTGPacks::defaultBooster; @@ -47,9 +48,13 @@ int MTGPackSlot::add(WSrcCards * ocean, MTGDeck *to, int carryover) if (!myPool) myPool = ocean; + std::random_device rd; + std::mt19937 g(rd()); + for (int i = 0; i < amt; i++) { - std::random_shuffle(entries.begin(), entries.end()); + //std::random_shuffle(entries.begin(), entries.end()); + std::shuffle(entries.begin(), entries.end(), g); size_t pos = 0; while (pos < entries.size() && entries[pos]->addCard(myPool, to)) pos++; diff --git a/thirdparty/curl b/thirdparty/curl new file mode 160000 index 000000000..339464432 --- /dev/null +++ b/thirdparty/curl @@ -0,0 +1 @@ +Subproject commit 339464432555b9bd71a5e4a4c4e55337cb07118d