From 66761ba7603b55e1f718cb948a6a6a3526ed9122 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 19 Nov 2013 06:42:32 +0000 Subject: [PATCH] - code cleanup based on additional gcc warnings --- source/glest_game/ai/ai.cpp | 2 +- source/glest_game/game/game_settings.h | 4 ++-- source/glest_game/game/script_manager.cpp | 2 +- source/glest_game/game/stats.cpp | 2 +- source/glest_game/graphics/renderer.cpp | 2 +- source/glest_game/network/network_message.h | 2 +- source/glest_game/world/scenario.h | 2 +- source/shared_lib/sources/map/map_preview.cpp | 8 ++++---- .../sources/platform/common/simple_threads.cpp | 2 +- source/shared_lib/sources/platform/posix/socket.cpp | 4 ++-- .../shared_lib/sources/platform/win32/gl_wrap_billy.cpp | 9 +++++++++ 11 files changed, 24 insertions(+), 15 deletions(-) diff --git a/source/glest_game/ai/ai.cpp b/source/glest_game/ai/ai.cpp index 18796a5c8..b7325a0d0 100644 --- a/source/glest_game/ai/ai.cpp +++ b/source/glest_game/ai/ai.cpp @@ -479,7 +479,7 @@ const ResourceType *Ai::getNeededResource(int unitIndex) { const int maxUnitsToHarvestResource = 5; vector unitsGettingResource = findUnitsHarvestingResourceType(rt); - if(unitsGettingResource.size() <= maxUnitsToHarvestResource) { + if((int)unitsGettingResource.size() <= maxUnitsToHarvestResource) { // Now MAKE SURE the unit has a harvest command for this resource // AND that the resource is within eye-sight to avoid units // standing around doing nothing. diff --git a/source/glest_game/game/game_settings.h b/source/glest_game/game/game_settings.h index 96e2b26c6..9a4b7c632 100644 --- a/source/glest_game/game/game_settings.h +++ b/source/glest_game/game/game_settings.h @@ -72,7 +72,7 @@ enum FlagTypes1 { }; inline static bool isFlagType1BitEnabled(uint32 flagValue,FlagTypes1 type) { - return ((flagValue & type) == type); + return ((flagValue & (uint32)type) == (uint32)type); } enum NetworkPlayerStatusType { @@ -359,7 +359,7 @@ public: throw megaglest_runtime_error(szBuf); } - for(unsigned int i =0; i < GameConstants::maxPlayers; ++i) { + for(int i =0; i < GameConstants::maxPlayers; ++i) { if(startLocationIndex[i] == startIndex) { return i; } diff --git a/source/glest_game/game/script_manager.cpp b/source/glest_game/game/script_manager.cpp index ca0f13d10..9306777db 100644 --- a/source/glest_game/game/script_manager.cpp +++ b/source/glest_game/game/script_manager.cpp @@ -3131,7 +3131,7 @@ void ScriptManager::saveGame(XmlNode *rootNode) { // bool gameWon; scriptManagerNode->addAttribute("gameWon",intToStr(gameWon), mapTagReplacements); // PlayerModifiers playerModifiers[GameConstants::maxPlayers]; - for(unsigned int i = 0; i < GameConstants::maxPlayers; ++i) { + for(unsigned int i = 0; i < (unsigned int)GameConstants::maxPlayers; ++i) { PlayerModifiers &player = playerModifiers[i]; player.saveGame(scriptManagerNode); } diff --git a/source/glest_game/game/stats.cpp b/source/glest_game/game/stats.cpp index 635ef6ba1..cf7ffdd79 100644 --- a/source/glest_game/game/stats.cpp +++ b/source/glest_game/game/stats.cpp @@ -171,7 +171,7 @@ void Stats::saveGame(XmlNode *rootNode) { XmlNode *statsNode = rootNode->addChild("Stats"); // PlayerStats playerStats[GameConstants::maxPlayers]; - for(unsigned int i = 0; i < GameConstants::maxPlayers; ++i) { + for(unsigned int i = 0; i < (unsigned int)GameConstants::maxPlayers; ++i) { PlayerStats &stat = playerStats[i]; XmlNode *statsNodePlayer = statsNode->addChild("Player"); diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index b5d956ea9..861f3dcea 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -7403,7 +7403,7 @@ vector Renderer::renderUnitsFast(bool renderingShadows, bool colorPickin assert(game != NULL); //const World *world= game->getWorld(); - assert(world != NULL); + //assert(world != NULL); VisibleQuadContainerCache &qCache = getQuadCache(); if(qCache.visibleQuadUnitList.empty() == false) { diff --git a/source/glest_game/network/network_message.h b/source/glest_game/network/network_message.h index 85feeeb4f..f571d2119 100644 --- a/source/glest_game/network/network_message.h +++ b/source/glest_game/network/network_message.h @@ -363,7 +363,7 @@ private: data_ref.header.messageType = 0; data_ref.header.commandCount = 0; data_ref.header.frameCount = 0; - for(unsigned int index = 0; index < GameConstants::maxPlayers; ++index) { + for(int index = 0; index < GameConstants::maxPlayers; ++index) { data_ref.header.networkPlayerFactionCRC[index] = 0; } } diff --git a/source/glest_game/world/scenario.h b/source/glest_game/world/scenario.h index 58cc564b2..7184274c0 100644 --- a/source/glest_game/world/scenario.h +++ b/source/glest_game/world/scenario.h @@ -48,7 +48,7 @@ class ScenarioInfo { public: ScenarioInfo() { difficulty = 0; - for(unsigned int i = 0; i < GameConstants::maxPlayers; ++i) { + for(unsigned int i = 0; i < (unsigned int)GameConstants::maxPlayers; ++i) { factionControls[i] = ctClosed; teams[i] = 0; factionTypeNames[i] = ""; diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index e2a99ac32..69187e316 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -755,10 +755,10 @@ void toEndianMapFileHeader(MapFileHeader &header) { header.height = Shared::PlatformByteOrder::toCommonEndian(header.height); header.heightFactor = Shared::PlatformByteOrder::toCommonEndian(header.heightFactor); header.waterLevel = Shared::PlatformByteOrder::toCommonEndian(header.waterLevel); - for(unsigned int i =0; i < MAX_TITLE_LENGTH; ++i) { + for(unsigned int i =0; i < (unsigned int)MAX_TITLE_LENGTH; ++i) { header.title[i] = Shared::PlatformByteOrder::toCommonEndian(header.title[i]); } - for(unsigned int i =0; i < MAX_DESCRIPTION_LENGTH; ++i) { + for(unsigned int i =0; i < (unsigned int)MAX_DESCRIPTION_LENGTH; ++i) { header.description[i] = Shared::PlatformByteOrder::toCommonEndian(header.description[i]); } } @@ -769,10 +769,10 @@ void fromEndianMapFileHeader(MapFileHeader &header) { header.height = Shared::PlatformByteOrder::fromCommonEndian(header.height); header.heightFactor = Shared::PlatformByteOrder::fromCommonEndian(header.heightFactor); header.waterLevel = Shared::PlatformByteOrder::fromCommonEndian(header.waterLevel); - for(unsigned int i =0; i < MAX_TITLE_LENGTH; ++i) { + for(unsigned int i =0; i < (unsigned int)MAX_TITLE_LENGTH; ++i) { header.title[i] = Shared::PlatformByteOrder::fromCommonEndian(header.title[i]); } - for(unsigned int i =0; i < MAX_DESCRIPTION_LENGTH; ++i) { + for(unsigned int i =0; i < (unsigned int)MAX_DESCRIPTION_LENGTH; ++i) { header.description[i] = Shared::PlatformByteOrder::fromCommonEndian(header.description[i]); } } diff --git a/source/shared_lib/sources/platform/common/simple_threads.cpp b/source/shared_lib/sources/platform/common/simple_threads.cpp index 507dc8208..ce8f8ad1d 100644 --- a/source/shared_lib/sources/platform/common/simple_threads.cpp +++ b/source/shared_lib/sources/platform/common/simple_threads.cpp @@ -130,7 +130,7 @@ void FileCRCPreCacheThread::execute() { try { unsigned int consumedWorkers = 0; - for(unsigned int workerIdx = 0; workerIdx < MAX_FileCRCPreCacheThread_WORKER_THREADS; ++workerIdx) { + for(unsigned int workerIdx = 0; workerIdx < (unsigned int)MAX_FileCRCPreCacheThread_WORKER_THREADS; ++workerIdx) { if(getQuitStatus() == true) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); break; diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 8a0407964..7727ff12a 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -2863,7 +2863,7 @@ void BroadCastSocketThread::execute() { // Subnet, IP Address std::vector ipSubnetMaskList; - for(unsigned int idx = 0; idx < ipList.size() && idx < MAX_NIC_COUNT; idx++) { + for(unsigned int idx = 0; idx < (unsigned int)ipList.size() && idx < (unsigned int)MAX_NIC_COUNT; idx++) { string broadCastAddress = getNetworkInterfaceBroadcastAddress(ipList[idx]); //printf("idx = %d broadCastAddress [%s]\n",idx,broadCastAddress.c_str()); @@ -2876,7 +2876,7 @@ void BroadCastSocketThread::execute() { port = htons( Socket::getBroadCastPort() ); //for(unsigned int idx = 0; idx < ipList.size() && idx < MAX_NIC_COUNT; idx++) { - for(unsigned int idx = 0; idx < ipSubnetMaskList.size(); idx++) { + for(unsigned int idx = 0; idx < (unsigned int)ipSubnetMaskList.size(); idx++) { // Create the broadcast socket memset( &bcLocal[idx], 0, sizeof( struct sockaddr_in)); bcLocal[idx].sin_family = AF_INET; diff --git a/source/shared_lib/sources/platform/win32/gl_wrap_billy.cpp b/source/shared_lib/sources/platform/win32/gl_wrap_billy.cpp index 84884ca2b..792dc9b02 100644 --- a/source/shared_lib/sources/platform/win32/gl_wrap_billy.cpp +++ b/source/shared_lib/sources/platform/win32/gl_wrap_billy.cpp @@ -27,6 +27,15 @@ using namespace Shared::Util; namespace Shared{ namespace Platform{ +// Example values: +// DEFAULT_CHARSET (English) = 1 +// GB2312_CHARSET (Chinese) = 134 +#ifdef WIN32 +DWORD PlatformContextGl::charSet = DEFAULT_CHARSET; +#else +int PlatformContextGl::charSet = 1; +#endif + // ====================================== // Global Fcs // ======================================