From f8aaa0efdf60fc29e8383ff9ff1a49fb7d13677d Mon Sep 17 00:00:00 2001 From: Cekis Date: Mon, 24 Jan 2022 23:34:28 -0800 Subject: [PATCH] Addressed several compiler warnings from GCC --- .gitattributes | 1 + CMakeLists.txt | 2 +- .../AuctionTransferGameAPI/Base/Archive.h | 3 +- .../LoginServer/src/shared/LoginServer.cpp | 4 +- .../src/shared/ManagerConnection.cpp | 4 +- .../server/library/codegen/make_packages.pl | 3 +- .../src/shared/DatabaseProcess.cpp | 7 +- .../src/shared/ai/AiCreatureWeaponActions.cpp | 6 +- .../src/shared/command/CommandCppFuncs.cpp | 13 ++- .../src/shared/command/CommandQueue.cpp | 2 +- .../console/ConsoleCommandParserObject.cpp | 5 +- .../src/shared/core/ServerWorld.cpp | 60 +++++++------ .../serverGame/src/shared/network/Chat.cpp | 2 +- .../src/shared/object/CellPermissions.cpp | 2 +- .../src/shared/object/CreatureObject.cpp | 5 +- .../src/shared/object/GroupObject.cpp | 13 ++- .../src/shared/object/GroupObject.h | 4 +- .../src/shared/object/PlayerObject.h | 12 +-- .../src/shared/object/TangibleObject.cpp | 3 +- .../src/shared/TaskConnectionIdMessage.h | 6 +- .../src/shared/GameScriptObject.cpp | 3 +- .../serverScript/src/shared/JavaLibrary.cpp | 5 ++ .../src/shared/core/CollisionProperty.cpp | 24 +++-- .../src/shared/core/CollisionWorld.cpp | 41 +++++---- .../src_oci/OciSession.cpp | 22 ----- .../sharedFile/src/shared/FileManifest.cpp | 5 +- .../src/shared/CommandLine.cpp | 7 +- .../library/sharedNetwork/src/linux/Sock.cpp | 33 +++---- .../sharedObject/src/shared/object/Object.cpp | 4 +- .../src/shared/FastRandomGenerator.h | 16 ++-- .../src/shared/generator/CoordinateHash.cpp | 20 ++--- .../src/shared/generator/CoordinateHash.h | 4 +- .../3rd/library/platform/utils/Base/Archive.h | 3 +- .../soePlatform/CSAssist/utils/Base/Archive.h | 3 +- .../CTServiceGameAPI/Base/Archive.h | 3 +- .../ChatAPI/projects/ChatAPI/ChatAvatar.cpp | 4 +- .../ChatAPI/projects/ChatAPI/ChatAvatar.h | 4 +- .../projects/ChatAPI/ChatAvatarCore.cpp | 14 +-- .../ChatAPI/projects/ChatAPI/ChatAvatarCore.h | 16 ++-- .../ChatAPI/projects/ChatAPI/Response.cpp | 2 +- .../ChatAPI/projects/ChatAPI/Response.h | 4 +- .../soePlatform/ChatAPI/utils/Base/Archive.h | 3 +- .../utils/UdpLibrary/UdpDriverLinux.cpp | 17 ++-- .../utils2.0/utils/Base/serializeClasses.h | 88 ++++++++----------- .../utils2.0/utils/UdpLibrary/UdpLibrary.cpp | 24 +++-- .../3rd/library/udplibrary/UdpLibrary.cpp | 27 +++--- .../archive/src/shared/AutoDeltaByteStream.h | 2 +- .../library/archive/src/shared/AutoDeltaMap.h | 4 +- .../archive/src/shared/AutoDeltaQueue.h | 4 +- .../library/archive/src/shared/AutoDeltaSet.h | 8 +- .../archive/src/shared/AutoDeltaVector.h | 42 ++++----- 51 files changed, 314 insertions(+), 299 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..aecf2503 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* -crlf diff --git a/CMakeLists.txt b/CMakeLists.txt index 2572d9a2..8f0bbc1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -pg -ggdb") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDEBUG_LEVEL=0 -DPRODUCTION=0 -pg -ggdb -no-pie") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DDEBUG_LEVEL=0 -DPRODUCTION=1 -no-pie -flto -fwhole-program-vtables") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1 ") elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "CLang") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -pg -ggdb -g -fprofile-instr-generate -fcoverage-mapping") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDEBUG_LEVEL=0 -DPRODUCTION=0 -Ofast -pg -ggdb") diff --git a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/Archive.h b/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/Archive.h index a15f6cba..00ae65cd 100755 --- a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/Archive.h +++ b/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/Archive.h @@ -724,8 +724,9 @@ const unsigned MAX_ARRAY_SIZE = 1024; Base::get(source, arraySize); ValueType v; - if (arraySize > MAX_ARRAY_SIZE) + if (arraySize > MAX_ARRAY_SIZE) { arraySize = 0; + } for(unsigned int i = 0; i < arraySize; ++i) { diff --git a/engine/server/application/LoginServer/src/shared/LoginServer.cpp b/engine/server/application/LoginServer/src/shared/LoginServer.cpp index bd053af2..869f6b8b 100755 --- a/engine/server/application/LoginServer/src/shared/LoginServer.cpp +++ b/engine/server/application/LoginServer/src/shared/LoginServer.cpp @@ -480,7 +480,9 @@ void LoginServer::receiveMessage(const MessageDispatch::Emitter &source, const M break; } } - DEBUG_REPORT_LOG(!found, ("Tried to remove a connection server that wasn't in our list.\n")); + if(!found) { + DEBUG_REPORT_LOG(true, ("Tried to remove a connection server that wasn't in our list.\n")); + } m_clusterStatusChanged = true; } else { WARNING_STRICT_FATAL(true, ("Programmer bug: Got ConnectionServerDown from a cluster that wasn't on the list. Probably indicates we aren't tracking connections properly.\n")); diff --git a/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp b/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp index 244ee881..b6779882 100755 --- a/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp +++ b/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp @@ -122,8 +122,8 @@ void ManagerConnection::onReceive(const Archive::ByteStream & message) } case constcrc("TaskConnectionIdMessage") : { - static uint32_t const clockDriftFatalTimePeriod = static_cast(TaskManager::getStartTime()) + ConfigTaskManager::getClockDriftFatalIntervalSeconds(); - uint32_t const currentTime = static_cast(::time(nullptr)); + static int32_t const clockDriftFatalTimePeriod = static_cast(TaskManager::getStartTime()) + ConfigTaskManager::getClockDriftFatalIntervalSeconds(); + int32_t const currentTime = static_cast(::time(nullptr)); TaskConnectionIdMessage t(r); WARNING_STRICT_FATAL(t.getServerType() != TaskConnectionIdMessage::TaskManager, ("ManagerConnection received wrong type identifier")); diff --git a/engine/server/library/codegen/make_packages.pl b/engine/server/library/codegen/make_packages.pl index 2b580a3d..65c55c91 100755 --- a/engine/server/library/codegen/make_packages.pl +++ b/engine/server/library/codegen/make_packages.pl @@ -307,8 +307,9 @@ sub makeEncodeFunction } print OUTFILE "\tconst DBSchema::${rowtype} *row=m_\l${buffer}.findConstRowByIndex(objectId);\n"; print OUTFILE "\tWARNING_STRICT_FATAL(row==NULL,(\"Loading object %s, no ${rowtype} in the buffer\\n\",objectId.getValueString().c_str()));\n"; - print OUTFILE "\tif (!row)\n"; + print OUTFILE "\tif (!row) {\n"; print OUTFILE "\t\treturn false;\n"; + print OUTFILE "\t}\n"; print OUTFILE "\n"; foreach $member (@{ $packageMembers{"$classname.$package"} }) diff --git a/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp b/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp index 5b097f2c..69aa99cd 100755 --- a/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp +++ b/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp @@ -195,7 +195,8 @@ DatabaseProcess::~DatabaseProcess() void DatabaseProcess::run(void) { static bool shouldSleep = ConfigServerDatabase::getShouldSleep(); - bool idle=false; + // unused. + // bool idle=false; int loopcount=0; float nextQueryCountTime=0; @@ -261,7 +262,7 @@ void DatabaseProcess::run(void) if (Persister::getInstance().isIdle() && Loader::getInstance().isIdle() && DataLookup::getInstance().isIdle()) { DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes() && !idle,("Database process is idle.\n")); - idle=true; + // idle=true; if (taskService) { ServerIdleMessage msg(true); @@ -270,7 +271,7 @@ void DatabaseProcess::run(void) } else { - idle=false; + // idle=false; if (taskService) { ServerIdleMessage msg(false); diff --git a/engine/server/library/serverGame/src/shared/ai/AiCreatureWeaponActions.cpp b/engine/server/library/serverGame/src/shared/ai/AiCreatureWeaponActions.cpp index 4d5498f8..66e8cb8c 100755 --- a/engine/server/library/serverGame/src/shared/ai/AiCreatureWeaponActions.cpp +++ b/engine/server/library/serverGame/src/shared/ai/AiCreatureWeaponActions.cpp @@ -102,7 +102,7 @@ PersistentCrcString const & AiCreatureWeaponActions::getCombatAction() { unsigned int expiredCount = 0; - for (unsigned int i = 0; i < m_singleUseActionList.size(); ++i) + for (uint32_t i = 0; i < m_singleUseActionList.size(); ++i) { if (m_singleUseActionList[i] != 0) { @@ -133,7 +133,7 @@ PersistentCrcString const & AiCreatureWeaponActions::getCombatAction() // Delayed repeat actions { - for (unsigned int i = 0; i < m_delayRepeatActionList.size(); ++i) + for (uint32_t i = 0; i < m_delayRepeatActionList.size(); ++i) { if (osTime > time_t(m_delayRepeatActionList[i])) { @@ -160,7 +160,7 @@ PersistentCrcString const & AiCreatureWeaponActions::getCombatAction() time_t nextActionTime = 0; unsigned int nextActionIndex = 0; - for (unsigned int i = 0; i < m_instantRepeatActionList.size(); ++i) + for (uint32_t i = 0; i < m_instantRepeatActionList.size(); ++i) { if (osTime >= time_t(m_instantRepeatActionList[i])) { diff --git a/engine/server/library/serverGame/src/shared/command/CommandCppFuncs.cpp b/engine/server/library/serverGame/src/shared/command/CommandCppFuncs.cpp index 7fc71ebd..333d1a2a 100755 --- a/engine/server/library/serverGame/src/shared/command/CommandCppFuncs.cpp +++ b/engine/server/library/serverGame/src/shared/command/CommandCppFuncs.cpp @@ -1800,11 +1800,11 @@ static void commandFuncSpatialChatInternal(Command const &, NetworkId const &act else if (!squelched && (ConfigServerGame::getChatSpamNotifyPlayerWhenLimitedIntervalSeconds() > 0) && obj->getClient()) { // send message telling character he can no longer talk - const int timeNow = static_cast(::time(nullptr)); - const int chatSpamTimeEndInterval = playerObject->getChatSpamTimeEndInterval(); + const int32_t timeNow = static_cast(::time(nullptr)); + const int32_t chatSpamTimeEndInterval = playerObject->getChatSpamTimeEndInterval(); if ((chatSpamTimeEndInterval > timeNow) && (timeNow >= playerObject->getChatSpamNextTimeToNotifyPlayerWhenLimited())) { - GenericValueTypeMessage csl("ChatSpamLimited", (chatSpamTimeEndInterval - timeNow)); + GenericValueTypeMessage csl("ChatSpamLimited", (chatSpamTimeEndInterval - timeNow)); obj->getClient()->send(csl, true); playerObject->setChatSpamNextTimeToNotifyPlayerWhenLimited((timeNow + ConfigServerGame::getChatSpamNotifyPlayerWhenLimitedIntervalSeconds())); @@ -1937,8 +1937,8 @@ static void commandFuncSpatialChat(Command const &, NetworkId const &actor, Netw else if (!squelched && (ConfigServerGame::getChatSpamNotifyPlayerWhenLimitedIntervalSeconds() > 0) && obj->getClient()) { // send message telling character he can no longer talk - const int timeNow = static_cast(::time(nullptr)); - const int chatSpamTimeEndInterval = playerObject->getChatSpamTimeEndInterval(); + const int32_t timeNow = static_cast(::time(nullptr)); + const int32_t chatSpamTimeEndInterval = playerObject->getChatSpamTimeEndInterval(); if ((chatSpamTimeEndInterval > timeNow) && (timeNow >= playerObject->getChatSpamNextTimeToNotifyPlayerWhenLimited())) { GenericValueTypeMessage csl("ChatSpamLimited", (chatSpamTimeEndInterval - timeNow)); @@ -2877,7 +2877,7 @@ static void commandFuncPermissionListModify(Command const &, NetworkId const &ac Unicode::UnicodeStringVector tokens; Unicode::tokenize(params, tokens); Unicode::String temp; - for (int i = 0; i < tokens.size(); i++) + for (uint32_t i = 0; i < tokens.size(); i++) { if(i < tokens.size() - 2) { @@ -2888,7 +2888,6 @@ static void commandFuncPermissionListModify(Command const &, NetworkId const &ac } } } - size_t curpos = 0; const Unicode::String & playerName = temp; const Unicode::String & listName = tokens[tokens.size()-2]; const Unicode::String & action = tokens[tokens.size()-1]; diff --git a/engine/server/library/serverGame/src/shared/command/CommandQueue.cpp b/engine/server/library/serverGame/src/shared/command/CommandQueue.cpp index b80d30b3..0d16fad4 100755 --- a/engine/server/library/serverGame/src/shared/command/CommandQueue.cpp +++ b/engine/server/library/serverGame/src/shared/command/CommandQueue.cpp @@ -684,7 +684,7 @@ void CommandQueue::switchState() m_eventStartTime = s_currentTime; - const unsigned int savedQueueSize = m_queue.size(); + const uint32_t savedQueueSize = m_queue.size(); switch ( m_state.get() ) { case State_Waiting: diff --git a/engine/server/library/serverGame/src/shared/console/ConsoleCommandParserObject.cpp b/engine/server/library/serverGame/src/shared/console/ConsoleCommandParserObject.cpp index dc2fd5f0..26a51317 100755 --- a/engine/server/library/serverGame/src/shared/console/ConsoleCommandParserObject.cpp +++ b/engine/server/library/serverGame/src/shared/console/ConsoleCommandParserObject.cpp @@ -101,10 +101,7 @@ namespace ConsoleCommandParserObjectNamespace //test handler, this should eventually be removed void testConsentHandler(const NetworkId& player, int id, bool response) { - int i = 0; - if (response == true) - i = 1; - DEBUG_REPORT_LOG(true, ("We received a test consent back with values NetworkId:%s Id:%d Response:%d\n", player.getValueString().c_str(), id, i)); + DEBUG_REPORT_LOG(true, ("We received a test consent back with values NetworkId: %s Id: %d Response: %d\n", player.getValueString().c_str(), id, (response ? 1 : 0))); } ServerObjectTemplate const *getObjectTemplateForCreation(std::string const &templateName) diff --git a/engine/server/library/serverGame/src/shared/core/ServerWorld.cpp b/engine/server/library/serverGame/src/shared/core/ServerWorld.cpp index 0a45f4a7..e5b7fb2c 100755 --- a/engine/server/library/serverGame/src/shared/core/ServerWorld.cpp +++ b/engine/server/library/serverGame/src/shared/core/ServerWorld.cpp @@ -320,20 +320,22 @@ void ServerWorldNamespace::issueCollisionNearWarpWarning(Object const &object, V //-- Only issue these for authoritative server objects. Proxy server objects will hit this condition after an intra-planet teleport. // @todo allow proxies to know about a teleport and inform CollisionWorld so that we can always report these. - DEBUG_WARNING(!serverObject || serverObject->isAuthoritative(), - ("CollisionWorld::update() had %d segments for object id=[%s], template=[%s], authority=[%s], game sever id=[%d], start position=[%.2f,%.2f,%.2f], end position=[%.2f,%.2f,%.2f], object probably should have warped but collision system is not warping it.", - segmentCount, - object.getNetworkId().getValueString().c_str(), - object.getObjectTemplateName(), - serverObject ? (serverObject->isAuthoritative() ? "authoritative" : "proxy") : "", - static_cast(GameServer::getInstance().getProcessId()), - oldPosition_w.x, - oldPosition_w.y, - oldPosition_w.z, - newPosition_w.x, - newPosition_w.y, - newPosition_w.z - )); + if(!serverObject || serverObject->isAuthoritative()) { + DEBUG_WARNING(true, + ("CollisionWorld::update() had %d segments for object id=[%s], template=[%s], authority=[%s], game sever id=[%d], start position=[%.2f,%.2f,%.2f], end position=[%.2f,%.2f,%.2f], object probably should have warped but collision system is not warping it.", + segmentCount, + object.getNetworkId().getValueString().c_str(), + object.getObjectTemplateName(), + serverObject ? (serverObject->isAuthoritative() ? "authoritative" : "proxy") : "", + static_cast(GameServer::getInstance().getProcessId()), + oldPosition_w.x, + oldPosition_w.y, + oldPosition_w.z, + newPosition_w.x, + newPosition_w.y, + newPosition_w.z + )); + } } // ---------------------------------------------------------------------- @@ -344,20 +346,22 @@ void ServerWorldNamespace::issueCollisionFarWarpWarning(Object const &object, Ve //-- Only issue these for authoritative server objects. Proxy server objects will hit this condition after an intra-planet teleport. // @todo allow proxies to know about a teleport and inform CollisionWorld so that we can always report these. - DEBUG_WARNING(!serverObject || serverObject->isAuthoritative(), - ("CollisionWorld::update() had %d segments for object id=[%s], template=[%s], authority=[%s], game sever id=[%d], start position=[%.2f,%.2f,%.2f], end position=[%.2f,%.2f,%.2f], collision system will consider this a warp and adjust accordingly.", - segmentCount, - object.getNetworkId().getValueString().c_str(), - object.getObjectTemplateName(), - serverObject ? (serverObject->isAuthoritative() ? "authoritative" : "proxy") : "", - static_cast(GameServer::getInstance().getProcessId()), - oldPosition_w.x, - oldPosition_w.y, - oldPosition_w.z, - newPosition_w.x, - newPosition_w.y, - newPosition_w.z - )); + if(!serverObject || serverObject->isAuthoritative()) { + DEBUG_WARNING(!serverObject || serverObject->isAuthoritative(), + ("CollisionWorld::update() had %d segments for object id=[%s], template=[%s], authority=[%s], game sever id=[%d], start position=[%.2f,%.2f,%.2f], end position=[%.2f,%.2f,%.2f], collision system will consider this a warp and adjust accordingly.", + segmentCount, + object.getNetworkId().getValueString().c_str(), + object.getObjectTemplateName(), + serverObject ? (serverObject->isAuthoritative() ? "authoritative" : "proxy") : "", + static_cast(GameServer::getInstance().getProcessId()), + oldPosition_w.x, + oldPosition_w.y, + oldPosition_w.z, + newPosition_w.x, + newPosition_w.y, + newPosition_w.z + )); + } } // ---------------------------------------------------------------------- diff --git a/engine/server/library/serverGame/src/shared/network/Chat.cpp b/engine/server/library/serverGame/src/shared/network/Chat.cpp index 34549463..319e8214 100755 --- a/engine/server/library/serverGame/src/shared/network/Chat.cpp +++ b/engine/server/library/serverGame/src/shared/network/Chat.cpp @@ -697,7 +697,7 @@ unsigned int Chat::isAllowedToEnterRoom(const CreatureObject & who, const std::s // thus requiring more work from us here bool isMayor = false; std::vector cityId = CityInterface::getCitizenOfCityId(who.getNetworkId()); - for(int i = 0; i < cityId.size(); ++i){ + for(uint32_t i = 0; i < cityId.size(); ++i){ NetworkId leader = CityInterface::getCityInfo(cityId[i]).getLeaderId(); if(playerObject && who.getNetworkId() == leader) { isMayor = true; diff --git a/engine/server/library/serverGame/src/shared/object/CellPermissions.cpp b/engine/server/library/serverGame/src/shared/object/CellPermissions.cpp index 9d1dc0d0..8c7bc82b 100755 --- a/engine/server/library/serverGame/src/shared/object/CellPermissions.cpp +++ b/engine/server/library/serverGame/src/shared/object/CellPermissions.cpp @@ -620,7 +620,7 @@ bool CellPermissions::isOnList(PermissionList const &permList, CreatureObject co } if (name.rfind("account:", 0) == 0) { - if (std::stoi(name.substr(8, name.length())) == stationId) + if (static_cast(std::stoi(name.substr(8, name.length()))) == stationId) { return true; } diff --git a/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp b/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp index 151130db..52082f6d 100755 --- a/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp @@ -485,7 +485,7 @@ namespace CreatureObjectNamespace { bool creatureIsContainedInPOBShip(CreatureObject const * creatureObject); void findAllTargetsForGroup(CreatureObject * const targetObj, std::vector & targets); - bool roomInGroup(GroupObject const * groupObj, int additionalMembers); + bool roomInGroup(GroupObject const * groupObj, uint32_t additionalMembers); GroupMemberParam const buildGroupMemberParam(CreatureObject const * creatureObject); void buildGroupMemberParamsFromCreatures(std::vector const & targets, GroupObject::GroupMemberParamVector & targetMemberParams); } @@ -14996,14 +14996,13 @@ void CreatureObjectNamespace::GroupHelpers::findAllTargetsForGroup(CreatureObjec // ---------------------------------------------------------------------- -bool CreatureObjectNamespace::GroupHelpers::roomInGroup(GroupObject const * groupObj, int additionalMembers) +bool CreatureObjectNamespace::GroupHelpers::roomInGroup(GroupObject const * groupObj, uint32_t additionalMembers) { if (groupObj != 0) { return groupObj->doesGroupHaveRoomFor(additionalMembers); } - additionalMembers = std::max(0, additionalMembers); return additionalMembers < GroupObject::maximumMembersInGroup(); } diff --git a/engine/server/library/serverGame/src/shared/object/GroupObject.cpp b/engine/server/library/serverGame/src/shared/object/GroupObject.cpp index 2aad9328..cfc0795e 100755 --- a/engine/server/library/serverGame/src/shared/object/GroupObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/GroupObject.cpp @@ -55,7 +55,7 @@ namespace GroupObjectNamespace { // ---------------------------------------------------------------------- - unsigned int const cs_maximumNumberInGroup = 8; + const uint32_t cs_maximumNumberInGroup = 8; char const * const DEFAULT_GROUP_TEMPLATE = "object/group/group.iff"; std::map s_leaderMap; static const std::string cs_emptyString; @@ -226,7 +226,7 @@ void GroupObject::createAllGroupChatRooms() // static // ---------------------------------------------------------------------- -int GroupObject::maximumMembersInGroup() +uint32_t GroupObject::maximumMembersInGroup() { return cs_maximumNumberInGroup; } @@ -327,9 +327,8 @@ bool GroupObject::isMemberPC(NetworkId const & memberId) const // ---------------------------------------------------------------------- -bool GroupObject::doesGroupHaveRoomFor(int additionalMembers) const +bool GroupObject::doesGroupHaveRoomFor(uint32_t additionalMembers) const { - additionalMembers = std::max(0, additionalMembers); return (m_groupMembers.size() + additionalMembers) <= cs_maximumNumberInGroup; } @@ -519,7 +518,7 @@ void GroupObject::removeGroupMember(NetworkId const &memberId) else { GroupUpdateObserver updater(this, Archive::ADOO_generic); - for (unsigned int i = 0; i < m_groupMembers.size(); ++i) + for (uint32_t i = 0; i < m_groupMembers.size(); ++i) { GroupMember const & member = m_groupMembers.get(i); if (member.first == memberId) @@ -535,7 +534,7 @@ void GroupObject::removeGroupMember(NetworkId const &memberId) m_groupMemberProfessions.erase(i); calcGroupLevel(); - for (unsigned int j = 0; j < m_groupPOBShipAndOwners.size(); ++j) + for (uint32_t j = 0; j < m_groupPOBShipAndOwners.size(); ++j) { if (m_groupPOBShipAndOwners.get(j).second == memberId) { @@ -603,7 +602,7 @@ void GroupObject::disbandGroup() } else if (!getKill()) { - for (unsigned int i = 0; i < m_groupMembers.size(); ++i) + for (uint32_t i = 0; i < m_groupMembers.size(); ++i) { GroupMember const & member = m_groupMembers.get(i); removeFromGroupVoiceChatRoom(member.first, member.second); diff --git a/engine/server/library/serverGame/src/shared/object/GroupObject.h b/engine/server/library/serverGame/src/shared/object/GroupObject.h index e9e98519..aa143b23 100755 --- a/engine/server/library/serverGame/src/shared/object/GroupObject.h +++ b/engine/server/library/serverGame/src/shared/object/GroupObject.h @@ -47,7 +47,7 @@ public: static void removeFromLeaderMap (NetworkId const &leaderId, NetworkId const &groupId); static NetworkId getGroupIdForLeader (NetworkId const &leaderId); static void createAllGroupChatRooms (); - static int maximumMembersInGroup(); + static uint32_t maximumMembersInGroup(); typedef std::pair GroupMember; typedef std::vector GroupMemberVector; @@ -61,7 +61,7 @@ public: bool isGroupFull () const; int getPCMemberCount () const; bool isMemberPC(NetworkId const & memberId) const; - bool doesGroupHaveRoomFor(int additionalMembers) const; + bool doesGroupHaveRoomFor(uint32_t additionalMembers) const; GroupMemberVector const & getGroupMembers () const; int getGroupLevel () const; uint32 getFormationNameCrc() const; diff --git a/engine/server/library/serverGame/src/shared/object/PlayerObject.h b/engine/server/library/serverGame/src/shared/object/PlayerObject.h index b2f30808..0d669f93 100755 --- a/engine/server/library/serverGame/src/shared/object/PlayerObject.h +++ b/engine/server/library/serverGame/src/shared/object/PlayerObject.h @@ -395,8 +395,8 @@ public: int getChatSpamTimeEndInterval() const; - uint32_t getChatSpamNextTimeToNotifyPlayerWhenLimited() const; - void setChatSpamNextTimeToNotifyPlayerWhenLimited(uint32_t chatSpamNextTimeToNotifyPlayerWhenLimited); + int32_t getChatSpamNextTimeToNotifyPlayerWhenLimited() const; + void setChatSpamNextTimeToNotifyPlayerWhenLimited(int32_t chatSpamNextTimeToNotifyPlayerWhenLimited); // citizenship info void updateCitizenshipInfo(); @@ -585,7 +585,7 @@ private: Archive::AutoDeltaVariable m_aggroImmuneStartTime; ChatLog * const m_chatLog; - uint32_t m_chatLogPurgeTime; + time_t m_chatLogPurgeTime; bool m_isUnsticking; //when asking a player to accept or complete a quest, remember the quest that we asked them about @@ -641,7 +641,7 @@ private: Archive::AutoDeltaVariable m_chatSpamNonSpatialNumCharacters; Archive::AutoDeltaVariable m_chatSpamTimeEndInterval; Archive::AutoDeltaVariable m_chatSpamNextTimeToSyncWithChatServer; - uint32_t m_chatSpamNextTimeToNotifyPlayerWhenLimited; + int32_t m_chatSpamNextTimeToNotifyPlayerWhenLimited; // citizenship info Archive::AutoDeltaVariable m_citizenshipCity; @@ -1053,14 +1053,14 @@ inline int PlayerObject::getChatSpamTimeEndInterval() const // ---------------------------------------------------------------------- -inline uint32_t PlayerObject::getChatSpamNextTimeToNotifyPlayerWhenLimited() const +inline int32_t PlayerObject::getChatSpamNextTimeToNotifyPlayerWhenLimited() const { return m_chatSpamNextTimeToNotifyPlayerWhenLimited; } // ---------------------------------------------------------------------- -inline void PlayerObject::setChatSpamNextTimeToNotifyPlayerWhenLimited(uint32_t chatSpamNextTimeToNotifyPlayerWhenLimited) +inline void PlayerObject::setChatSpamNextTimeToNotifyPlayerWhenLimited(int32_t chatSpamNextTimeToNotifyPlayerWhenLimited) { m_chatSpamNextTimeToNotifyPlayerWhenLimited = chatSpamNextTimeToNotifyPlayerWhenLimited; } diff --git a/engine/server/library/serverGame/src/shared/object/TangibleObject.cpp b/engine/server/library/serverGame/src/shared/object/TangibleObject.cpp index eba9e915..b5eabfa6 100755 --- a/engine/server/library/serverGame/src/shared/object/TangibleObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/TangibleObject.cpp @@ -570,7 +570,8 @@ TangibleObject::~TangibleObject() // look up the caller's file and line if (callStack[callStackOffset]) { - char lib[4 * 1024] = { '\0' }; + // unused. + // char lib[4 * 1024] = { '\0' }; char file[4 * 1024] = { '\0' }; int line = 0; REPORT_LOG(true, ("\tCall stack:")); diff --git a/engine/server/library/serverNetworkMessages/src/shared/TaskConnectionIdMessage.h b/engine/server/library/serverNetworkMessages/src/shared/TaskConnectionIdMessage.h index 9580f607..4ec6ff55 100755 --- a/engine/server/library/serverNetworkMessages/src/shared/TaskConnectionIdMessage.h +++ b/engine/server/library/serverNetworkMessages/src/shared/TaskConnectionIdMessage.h @@ -34,7 +34,7 @@ public: const unsigned char getServerType () const; const std::string & getCommandLine () const; const std::string & getClusterName () const; - const uint32_t getCurrentEpochTime() const; + const int32_t getCurrentEpochTime() const; private: TaskConnectionIdMessage & operator = (const TaskConnectionIdMessage & rhs); TaskConnectionIdMessage(const TaskConnectionIdMessage & source); @@ -42,7 +42,7 @@ private: Archive::AutoVariable serverType; Archive::AutoVariable commandLine; Archive::AutoVariable clusterName; - Archive::AutoVariable currentEpochTime; + Archive::AutoVariable currentEpochTime; }; //----------------------------------------------------------------------- @@ -68,7 +68,7 @@ inline const unsigned char TaskConnectionIdMessage::getServerType() const //----------------------------------------------------------------------- -inline const uint32_t TaskConnectionIdMessage::getCurrentEpochTime() const +inline const int32_t TaskConnectionIdMessage::getCurrentEpochTime() const { return currentEpochTime.get(); } diff --git a/engine/server/library/serverScript/src/shared/GameScriptObject.cpp b/engine/server/library/serverScript/src/shared/GameScriptObject.cpp index ab118b52..5eefb97e 100755 --- a/engine/server/library/serverScript/src/shared/GameScriptObject.cpp +++ b/engine/server/library/serverScript/src/shared/GameScriptObject.cpp @@ -100,8 +100,9 @@ bool GameScriptObject::installScriptEngine(void) ms_scriptDataMap = new GameScriptObject::ScriptDataMap; Scripting::InitScriptFuncHashMap(); JavaLibrary::install(); - if (JavaLibrary::instance() == nullptr) + if (JavaLibrary::instance() == nullptr) { return false; + } enableNewJediTracking(ConfigServerGame::getEnableNewJedi()); return true; } // GameScriptObject::installScriptEngine diff --git a/engine/server/library/serverScript/src/shared/JavaLibrary.cpp b/engine/server/library/serverScript/src/shared/JavaLibrary.cpp index c373980a..f5f415b7 100755 --- a/engine/server/library/serverScript/src/shared/JavaLibrary.cpp +++ b/engine/server/library/serverScript/src/shared/JavaLibrary.cpp @@ -803,6 +803,10 @@ void JavaLibrary::fatalHandler(int signum) void *frameAddressB = nullptr; uint64 frameAddressHigh = (reinterpret_cast(frameAddress) >> 16); crashAddress2a = __builtin_return_address(0); +// Suppress Wframe-address for these lines - we could crash the program calling __builtin_return_address and frame_address +// with non-zero values. However, we likely don't care as we're crashing at this point anyway due to bad Java. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wframe-address" if (crashAddress2a != nullptr) { frameAddressA = __builtin_frame_address(1); @@ -826,6 +830,7 @@ void JavaLibrary::fatalHandler(int signum) } } } +#pragma GCC diagnostic pop bool javaCrash = true; if ((result1 || result2) && strstr(lib1, "libjvm.so") == nullptr && strstr(lib2, "libjvm.so") == nullptr) diff --git a/engine/shared/library/sharedCollision/src/shared/core/CollisionProperty.cpp b/engine/shared/library/sharedCollision/src/shared/core/CollisionProperty.cpp index b8cc9332..3aa8d90f 100755 --- a/engine/shared/library/sharedCollision/src/shared/core/CollisionProperty.cpp +++ b/engine/shared/library/sharedCollision/src/shared/core/CollisionProperty.cpp @@ -549,7 +549,9 @@ BaseExtent * convertToSimpleExtent ( BaseExtent const * sourceExtent ) { Extent const * extent = safe_cast(sourceExtent); - if(!extent) return nullptr; + if(!extent) { + return nullptr; + } return new SimpleExtent( MultiShape( extent->getShape() ) ); } @@ -558,7 +560,9 @@ BaseExtent * convertToSimpleExtent ( BaseExtent const * sourceExtent ) { CylinderExtent const * extent = safe_cast(sourceExtent); - if(!extent) return nullptr; + if(!extent) { + return nullptr; + } return new SimpleExtent( MultiShape( extent->getShape() ) ); } @@ -567,7 +571,9 @@ BaseExtent * convertToSimpleExtent ( BaseExtent const * sourceExtent ) { BoxExtent const * extent = safe_cast(sourceExtent); - if(!extent) return nullptr; + if(!extent) { + return nullptr; + } return new SimpleExtent( MultiShape( extent->getShape() ) ); } @@ -576,7 +582,9 @@ BaseExtent * convertToSimpleExtent ( BaseExtent const * sourceExtent ) { MeshExtent const * extent = safe_cast(sourceExtent); - if(!extent) return nullptr; + if(!extent) { + return nullptr; + } return extent->clone(); } @@ -585,7 +593,9 @@ BaseExtent * convertToSimpleExtent ( BaseExtent const * sourceExtent ) { DetailExtent const * extent = safe_cast(sourceExtent); - if(!extent) return nullptr; + if(!extent) { + return nullptr; + } DetailExtent * newExtent = new DetailExtent(); @@ -603,7 +613,9 @@ BaseExtent * convertToSimpleExtent ( BaseExtent const * sourceExtent ) { ComponentExtent const * extent = safe_cast(sourceExtent); - if(!extent) return nullptr; + if(!extent) { + return nullptr; + } ComponentExtent * newExtent = new ComponentExtent(); diff --git a/engine/shared/library/sharedCollision/src/shared/core/CollisionWorld.cpp b/engine/shared/library/sharedCollision/src/shared/core/CollisionWorld.cpp index 71a06f86..e6973d1b 100755 --- a/engine/shared/library/sharedCollision/src/shared/core/CollisionWorld.cpp +++ b/engine/shared/library/sharedCollision/src/shared/core/CollisionWorld.cpp @@ -1128,27 +1128,30 @@ void CollisionWorld::addObject(Object * object) name = appearance->getAppearanceTemplateName(); } } +#if _DEBUG + if(ConfigSharedCollision::getReportChanges()) { + int index = 0; + switch (query) + { + case SpatialDatabase::Q_Static: + index = 1; + break; + case SpatialDatabase::Q_Dynamic: + index = 2; + break; + case SpatialDatabase::Q_Barriers: + index = 3; + break; + case SpatialDatabase::Q_Doors: + index = 4; + break; + default: + break; + } - int index = 0; - switch (query) - { - case SpatialDatabase::Q_Static: - index = 1; - break; - case SpatialDatabase::Q_Dynamic: - index = 2; - break; - case SpatialDatabase::Q_Barriers: - index = 3; - break; - case SpatialDatabase::Q_Doors: - index = 4; - break; - default: - break; + DEBUG_REPORT_LOG(true, ("Added object %s to collision world [%s] at (%f,%f,%f)\n", name, ms_sptatialDatabaseNames[index], object->getPosition_w().x, object->getPosition_w().y, object->getPosition_w().z)); } - - DEBUG_REPORT_LOG(ConfigSharedCollision::getReportChanges(), ("Added object %s to collision world [%s] at (%f,%f,%f)\n", name, ms_sptatialDatabaseNames[index], object->getPosition_w().x, object->getPosition_w().y, object->getPosition_w().z)); +#endif } } diff --git a/engine/shared/library/sharedDatabaseInterface/src_oci/OciSession.cpp b/engine/shared/library/sharedDatabaseInterface/src_oci/OciSession.cpp index eb6e9d2c..f1fee154 100755 --- a/engine/shared/library/sharedDatabaseInterface/src_oci/OciSession.cpp +++ b/engine/shared/library/sharedDatabaseInterface/src_oci/OciSession.cpp @@ -32,28 +32,6 @@ using namespace DB::OCISessionNamespace; // ====================================================================== -static dvoid *mallocHook(dvoid *, size_t size) -{ - return reinterpret_cast(new char[size]); -} - -// ---------------------------------------------------------------------- - -static dvoid *reallocHook(dvoid *, dvoid *memptr, size_t newsize) -{ - return reinterpret_cast(realloc(memptr, newsize)); -} - -// ---------------------------------------------------------------------- - -static void freeHook(dvoid *, dvoid *memptr) -{ - if (memptr) - delete [] reinterpret_cast(memptr); -} - -// ====================================================================== - DB::OCISession::OCISession(DB::OCIServer *server) : m_server(server), envhp(nullptr), diff --git a/engine/shared/library/sharedFile/src/shared/FileManifest.cpp b/engine/shared/library/sharedFile/src/shared/FileManifest.cpp index c5552775..26117a63 100755 --- a/engine/shared/library/sharedFile/src/shared/FileManifest.cpp +++ b/engine/shared/library/sharedFile/src/shared/FileManifest.cpp @@ -40,10 +40,13 @@ namespace FileManifestNamespace static TransitionVector s_transitionVector; static bool s_installed = false; static bool s_updateManifest = false; + static std::string s_currentSceneId = "none"; + +#if PRODUCTION == 0 static int s_accessThreshold = -1; - static std::string s_currentSceneId = "none"; static bool s_isValidScene = false; static bool s_isTransitionScene = true; +#endif const static std::string s_manifestDataTable = "datatables/manifest/skufree.iff"; diff --git a/engine/shared/library/sharedFoundation/src/shared/CommandLine.cpp b/engine/shared/library/sharedFoundation/src/shared/CommandLine.cpp index 5209d788..8fba42e9 100755 --- a/engine/shared/library/sharedFoundation/src/shared/CommandLine.cpp +++ b/engine/shared/library/sharedFoundation/src/shared/CommandLine.cpp @@ -1385,12 +1385,11 @@ void CommandLine::absorbString(const char *newString) DEBUG_FATAL(!newString, ("nullptr newString arg")); const int stringLength = static_cast(strlen(newString)); - int requiredBufferSpace; + if (absorbedStringCount) - requiredBufferSpace = stringLength + 2; + DEBUG_FATAL(bufferSize + stringLength + 2 >= STATIC_BUFFER_SIZE, ("newString too large by %d bytes", bufferSize + stringLength + 2 - STATIC_BUFFER_SIZE)); else - requiredBufferSpace = stringLength + 1; - DEBUG_FATAL(bufferSize + requiredBufferSpace >= STATIC_BUFFER_SIZE, ("newString too large by %d bytes", bufferSize + requiredBufferSpace - STATIC_BUFFER_SIZE)); + DEBUG_FATAL(bufferSize + stringLength + 1 >= STATIC_BUFFER_SIZE, ("newString too large by %d bytes", bufferSize + stringLength + 1 - STATIC_BUFFER_SIZE)); if (absorbedStringCount) { diff --git a/engine/shared/library/sharedNetwork/src/linux/Sock.cpp b/engine/shared/library/sharedNetwork/src/linux/Sock.cpp index 22b29358..5ff32be6 100755 --- a/engine/shared/library/sharedNetwork/src/linux/Sock.cpp +++ b/engine/shared/library/sharedNetwork/src/linux/Sock.cpp @@ -1,6 +1,12 @@ //--------------------------------------------------------------------- #pragma warning(disable : 4127) +#ifdef NDEBUG +#define SWG_ASSERT(exp) ((void) (exp)) +#else +#define SWG_ASSERT assert +#endif + #include "FirstSharedNetwork.h" #include #include "Sock.h" @@ -28,9 +34,8 @@ Sock::~Sock() { // ensure we don't block, and that pending // data is sent with a graceful shutdown - int err; - err = close(handle); - assert(err == 0); + int err = close(handle); + SWG_ASSERT(err == 0); handle = INVALID_SOCKET; } @@ -55,7 +60,7 @@ bool Sock::bind(const Address & newBindAddress) struct sockaddr_in a; int r; r = getsockname(handle, reinterpret_cast(&a), &namelen); - assert(r == 0); + SWG_ASSERT(r == 0); bindAddress = a; } else @@ -83,9 +88,8 @@ bool Sock::bind() if(err == 0) { result = true; - int r; - r = getsockname(handle, reinterpret_cast(&a), &namelen); - assert(r == 0); + int r = getsockname(handle, reinterpret_cast(&a), &namelen); + SWG_ASSERT(r == 0); bindAddress = a; } assert(err == 0); @@ -144,9 +148,8 @@ bool Sock::canSend() const const unsigned int Sock::getInputBytesPending() const { unsigned long int bytes = 0; - int err; - err = ioctl(handle, FIONREAD, &bytes); //lint !e1924 (I don't know WHAT Microsoft is doing here!) - assert(err == 0); + int err = ioctl(handle, FIONREAD, &bytes); //lint !e1924 (I don't know WHAT Microsoft is doing here!) + SWG_ASSERT(err == 0); return bytes; } @@ -199,9 +202,8 @@ const std::string Sock::getLastError() const void Sock::getPeerName(struct sockaddr_in & target, int s) { socklen_t namelen = sizeof(struct sockaddr_in); - int err; - err = getpeername(s, reinterpret_cast(&(target)), &namelen); - assert(err != -1); + int err = getpeername(s, reinterpret_cast(&(target)), &namelen); + SWG_ASSERT(err != -1); } //----------------------------------------------------------------------- @@ -227,9 +229,8 @@ void Sock::setNonBlocking() const { assert(handle != INVALID_SOCKET); unsigned long int nb = 1; - int err; - err = ioctl(handle, FIONBIO, &nb); //lint !e569 // loss of precision in the FIONBIO macro, beyond my control - assert(err == 0); + int err = ioctl(handle, FIONBIO, &nb); //lint !e569 // loss of precision in the FIONBIO macro, beyond my control + SWG_ASSERT(err == 0); } //--------------------------------------------------------------------- diff --git a/engine/shared/library/sharedObject/src/shared/object/Object.cpp b/engine/shared/library/sharedObject/src/shared/object/Object.cpp index e5922430..04713352 100755 --- a/engine/shared/library/sharedObject/src/shared/object/Object.cpp +++ b/engine/shared/library/sharedObject/src/shared/object/Object.cpp @@ -149,7 +149,9 @@ Object::NotificationList::NotificationList(const NotificationList &otherList, co m_notificationList.push_back(add); } - DEBUG_FATAL(!deletedOtherEntry, ("didn't find notification [0x%08x] in source list for deletion", &otherEntry)); + if(!deletedOtherEntry) { + DEBUG_FATAL(true, ("didn't find notification [0x%08x] in source list for deletion", &otherEntry)); + } DEBUG_FATAL(m_notificationList.size() != otherList.m_notificationList.size() - 1, ("failed to build new notification list correctly")); } diff --git a/engine/shared/library/sharedRandom/src/shared/FastRandomGenerator.h b/engine/shared/library/sharedRandom/src/shared/FastRandomGenerator.h index 7896ca5a..131694e4 100755 --- a/engine/shared/library/sharedRandom/src/shared/FastRandomGenerator.h +++ b/engine/shared/library/sharedRandom/src/shared/FastRandomGenerator.h @@ -16,18 +16,18 @@ class FastRandomGenerator { public: FastRandomGenerator() { m_I=ZERO_ALT; } - FastRandomGenerator(long s) { setSeed(s); } + FastRandomGenerator(uint32 s) { setSeed(s); } - void setSeed(long s) + void setSeed(uint32 s) { - const long ps = s&0x7fffffff; + const uint32 ps = s&0x7fffffff; m_I = (ps==0) ? ZERO_ALT : ps; } // return a random number r where 0<=r<1 float randomFloat() { - long f = (_rand()>>8)|IEEE_FLOAT_BITS; + float f = static_cast((_rand()>>8)|IEEE_FLOAT_BITS); return (*(float *)(void *)&f)-1.0f; } float randomFloat(float range) { return randomFloat()*range; } @@ -49,9 +49,9 @@ protected: ZERO_ALT = 123459876 }; - long _rand() + uint32 _rand() { - long k; + uint32 k; k=m_I/IQ; m_I=IA*(m_I-k*IQ)-IR*k; if (m_I<0) m_I += IM; @@ -59,9 +59,9 @@ protected: return k; } - long _randMax() { return IM-1; } + uint32 _randMax() { return IM-1; } - long m_I; + uint32 m_I; }; // ====================================================================== diff --git a/engine/shared/library/sharedTerrain/src/shared/generator/CoordinateHash.cpp b/engine/shared/library/sharedTerrain/src/shared/generator/CoordinateHash.cpp index e6d8c6f5..d1c9393b 100755 --- a/engine/shared/library/sharedTerrain/src/shared/generator/CoordinateHash.cpp +++ b/engine/shared/library/sharedTerrain/src/shared/generator/CoordinateHash.cpp @@ -183,28 +183,28 @@ namespace //=================================================================== -unsigned long CoordinateHash::hashTuple(float x, float z) +uint32 CoordinateHash::hashTuple(float x, float z) { - const uint32 ix = (*(uint32 *)&x); - const uint32 iz = (*(uint32 *)&z)^0xa5a5a5a5; + const uint32 ix = (*reinterpret_cast(&x)); + const uint32 iz = (*reinterpret_cast(&z)) ^ 0xa5a5a5a5; - const uint32 hx = inthash(ix); - const uint32 hz = inthash(iz); + const uint32 hx = inthash(ix); + const uint32 hz = inthash(iz); - const uint32 h = inthash(hx^hz); + const uint32 h = inthash(hx ^ hz); - return h; + return h; } -float CoordinateHash::makeFloat(unsigned long hash) +float CoordinateHash::makeFloat(uint32 hash) { enum { IEEE_FLOAT_BITS=0x3f800000 }; const uint32 mask = ~uint32(0xff800000); const uint32 maskedHash = (hash + (hash>>9))&mask; - const uint32 iFloat = IEEE_FLOAT_BITS | maskedHash; - const float returnValue = (*(float *)&iFloat) - 1.0f; + uint32 iFloat = static_cast(IEEE_FLOAT_BITS) | maskedHash; + const float returnValue = (*reinterpret_cast(&iFloat)) - 1.0F; return returnValue; } diff --git a/engine/shared/library/sharedTerrain/src/shared/generator/CoordinateHash.h b/engine/shared/library/sharedTerrain/src/shared/generator/CoordinateHash.h index f01d0645..7e70609d 100755 --- a/engine/shared/library/sharedTerrain/src/shared/generator/CoordinateHash.h +++ b/engine/shared/library/sharedTerrain/src/shared/generator/CoordinateHash.h @@ -19,8 +19,8 @@ class CoordinateHash { public: - static unsigned long hashTuple(float x, float z); - static float makeFloat(unsigned long hash); + static uint32 hashTuple(float x, float z); + static float makeFloat(uint32 hash); }; //=================================================================== diff --git a/external/3rd/library/platform/utils/Base/Archive.h b/external/3rd/library/platform/utils/Base/Archive.h index f8f5ef39..1020a05d 100755 --- a/external/3rd/library/platform/utils/Base/Archive.h +++ b/external/3rd/library/platform/utils/Base/Archive.h @@ -656,8 +656,9 @@ const unsigned MAX_ARRAY_SIZE = 1024; Base::get(source, arraySize); ValueType v; - if (arraySize > MAX_ARRAY_SIZE) + if (arraySize > MAX_ARRAY_SIZE) { arraySize = 0; + } using Base::get; for(unsigned int i = 0; i < arraySize; ++i) diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/Archive.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/Archive.h index 21287220..8141f1d6 100755 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/Archive.h +++ b/external/3rd/library/soePlatform/CSAssist/utils/Base/Archive.h @@ -667,8 +667,9 @@ const unsigned MAX_ARRAY_SIZE = 1024; Base::get(source, arraySize); ValueType v; - if (arraySize > MAX_ARRAY_SIZE) + if (arraySize > MAX_ARRAY_SIZE) { arraySize = 0; + } for(unsigned int i = 0; i < arraySize; ++i) { diff --git a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/Archive.h b/external/3rd/library/soePlatform/CTServiceGameAPI/Base/Archive.h index 856dcd95..1cfc696f 100755 --- a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/Archive.h +++ b/external/3rd/library/soePlatform/CTServiceGameAPI/Base/Archive.h @@ -653,8 +653,9 @@ const unsigned MAX_ARRAY_SIZE = 1024; Base::get(source, arraySize); ValueType v; - if (arraySize > MAX_ARRAY_SIZE) + if (arraySize > MAX_ARRAY_SIZE) { arraySize = 0; + } for(unsigned int i = 0; i < arraySize; ++i) { diff --git a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatar.cpp b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatar.cpp index 8ec60bc8..ab25b4b8 100755 --- a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatar.cpp +++ b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatar.cpp @@ -148,7 +148,7 @@ const ChatUnicodeString& ChatAvatar::getStatusMessage() const return m_cStatusMessage; } -void ChatAvatar::setAttributes(unsigned long attributes) +void ChatAvatar::setAttributes(uint32_t attributes) { m_core->setAttributes(attributes); } @@ -158,7 +158,7 @@ void ChatAvatar::setLoginPriority(int loginPriority) m_core->setLoginPriority(loginPriority); } -void ChatAvatar::setInboxLimit(unsigned inboxLimit) +void ChatAvatar::setInboxLimit(uint32_t inboxLimit) { m_core->setInboxLimit(inboxLimit); } diff --git a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatar.h b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatar.h index 998738da..43fbd1e3 100755 --- a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatar.h +++ b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatar.h @@ -61,9 +61,9 @@ namespace ChatSystem const ChatUnicodeString &getForwardingEmail() const; const ChatUnicodeString& getStatusMessage() const; - void setAttributes(unsigned long attributes); + void setAttributes(uint32_t attributes); void setLoginPriority(int loginPriority); - void setInboxLimit(unsigned inboxLimit); + void setInboxLimit(uint32_t inboxLimit); void setForwardingEmail(const ChatUnicodeString &forwardingEmail); void setStatusMessage(const ChatUnicodeString& statusMessage); diff --git a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatarCore.cpp b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatarCore.cpp index 871f63d7..838aaa75 100755 --- a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatarCore.cpp +++ b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatarCore.cpp @@ -17,7 +17,7 @@ namespace ChatSystem { } - ChatAvatarCore::ChatAvatarCore(unsigned avatarID, unsigned userID, const unsigned short *name, const unsigned short *address, const unsigned short *gateway, const unsigned short *server, unsigned gatewayID, unsigned serverID, const unsigned short *loginLocation, unsigned attributes) + ChatAvatarCore::ChatAvatarCore(unsigned avatarID, unsigned userID, const unsigned short *name, const unsigned short *address, const unsigned short *gateway, const unsigned short *server, unsigned gatewayID, unsigned serverID, const unsigned short *loginLocation, uint32_t attributes) : m_name(name), m_address(address), m_server(server), @@ -33,7 +33,7 @@ namespace ChatSystem { } - ChatAvatarCore::ChatAvatarCore(unsigned avatarID, unsigned userID, const ChatUnicodeString &name, const ChatUnicodeString &address, const ChatUnicodeString &gateway, const ChatUnicodeString &server, unsigned gatewayID, unsigned serverID, const ChatUnicodeString &loginLocation, unsigned attributes) + ChatAvatarCore::ChatAvatarCore(unsigned avatarID, unsigned userID, const ChatUnicodeString &name, const ChatUnicodeString &address, const ChatUnicodeString &gateway, const ChatUnicodeString &server, unsigned gatewayID, unsigned serverID, const ChatUnicodeString &loginLocation, uint32_t attributes) : m_name(name.string_data, name.string_length), m_address(address.string_data, address.string_length), m_server(server.string_data, server.string_length), @@ -49,7 +49,7 @@ namespace ChatSystem { } - ChatAvatarCore::ChatAvatarCore(unsigned avatarID, unsigned userID, const String &name, const String &address, const String &gateway, const String &server, unsigned gatewayID, unsigned serverID, const Plat_Unicode::String &loginLocation, unsigned attributes) + ChatAvatarCore::ChatAvatarCore(unsigned avatarID, unsigned userID, const String &name, const String &address, const String &gateway, const String &server, unsigned gatewayID, unsigned serverID, const Plat_Unicode::String &loginLocation, uint32_t attributes) : m_name(name), m_address(address), m_server(server), @@ -71,7 +71,7 @@ namespace ChatSystem get(iter, m_userID); ASSERT_VALID_STRING_LENGTH(get(iter, m_name)); ASSERT_VALID_STRING_LENGTH(get(iter, m_address)); - get(iter, (uint32 &)m_attributes); + get(iter, m_attributes); ASSERT_VALID_STRING_LENGTH(get(iter, m_loginLocation)); ASSERT_VALID_STRING_LENGTH(get(iter, m_server)); ASSERT_VALID_STRING_LENGTH(get(iter, m_gateway)); @@ -153,11 +153,11 @@ namespace ChatSystem put(msg, m_userID); put(msg, m_name); put(msg, m_address); - put(msg, (uint32)m_attributes); + put(msg, m_attributes); put(msg, m_loginLocation); } - void ChatAvatarCore::setAttributes(unsigned long attributes) + void ChatAvatarCore::setAttributes(uint32_t attributes) { m_attributes = attributes; } @@ -172,7 +172,7 @@ namespace ChatSystem m_email = email; } - void ChatAvatarCore::setInboxLimit(unsigned inboxLimit) + void ChatAvatarCore::setInboxLimit(uint32_t inboxLimit) { m_inboxLimit = inboxLimit; } diff --git a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatarCore.h b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatarCore.h index ebd3fc81..e01d6b45 100755 --- a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatarCore.h +++ b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/ChatAvatarCore.h @@ -20,9 +20,9 @@ namespace ChatSystem public: ChatAvatarCore(); ChatAvatarCore(Base::ByteStream::ReadIterator &iter); - ChatAvatarCore(unsigned avatarID, unsigned userID, const unsigned short *name, const unsigned short *address, const unsigned short *gateway, const unsigned short *server, unsigned gatewayID, unsigned serverID, const unsigned short *loginLocation, unsigned attributes); - ChatAvatarCore(unsigned avatarID, unsigned userID, const ChatUnicodeString &name, const ChatUnicodeString &address, const ChatUnicodeString &gateway, const ChatUnicodeString &server, unsigned gatewayID, unsigned serverID, const ChatUnicodeString &loginLocation, unsigned attributes); - ChatAvatarCore(unsigned avatarID, unsigned userID, const Plat_Unicode::String &name, const Plat_Unicode::String &address, const Plat_Unicode::String &gateway, const Plat_Unicode::String &server, unsigned gatewayID, unsigned serverID, const Plat_Unicode::String &loginLocation, unsigned attributes); + ChatAvatarCore(unsigned avatarID, unsigned userID, const unsigned short *name, const unsigned short *address, const unsigned short *gateway, const unsigned short *server, unsigned gatewayID, unsigned serverID, const unsigned short *loginLocation, uint32_t attributes); + ChatAvatarCore(unsigned avatarID, unsigned userID, const ChatUnicodeString &name, const ChatUnicodeString &address, const ChatUnicodeString &gateway, const ChatUnicodeString &server, unsigned gatewayID, unsigned serverID, const ChatUnicodeString &loginLocation, uint32_t attributes); + ChatAvatarCore(unsigned avatarID, unsigned userID, const Plat_Unicode::String &name, const Plat_Unicode::String &address, const Plat_Unicode::String &gateway, const Plat_Unicode::String &server, unsigned gatewayID, unsigned serverID, const Plat_Unicode::String &loginLocation, uint32_t attributes); ChatAvatarCore(const ChatAvatarCore &rhs); @@ -34,9 +34,9 @@ namespace ChatSystem unsigned getAvatarID() const { return m_avatarID; } const Plat_Unicode::String &getLoginLocation() const { return m_loginLocation; } int getLoginPriority() const { return m_loginPriority; } - unsigned getAttributes() const { return m_attributes; } + uint32_t getAttributes() const { return m_attributes; } const Plat_Unicode::String &getEmail() const { return m_email; } - unsigned getInboxLimit() const { return m_inboxLimit; } + uint32_t getInboxLimit() const { return m_inboxLimit; } const Plat_Unicode::String &getServer() const { return m_server; } const Plat_Unicode::String &getGateway() const { return m_gateway; } unsigned getServerID() const { return m_serverID; } @@ -45,7 +45,7 @@ namespace ChatSystem ChatAvatar *getNewChatAvatar() const; - void setAttributes(unsigned long attributes); + void setAttributes(uint32_t attributes); void setLoginPriority(int loginPriority); void setEmail(const Plat_Unicode::String email); void setInboxLimit(unsigned inboxLimit); @@ -63,8 +63,8 @@ namespace ChatSystem Plat_Unicode::String m_email; Plat_Unicode::String m_statusMessage; - unsigned long m_attributes; - unsigned long m_inboxLimit; + uint32_t m_attributes; + uint32_t m_inboxLimit; int m_loginPriority; unsigned m_userID; diff --git a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/Response.cpp b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/Response.cpp index ad089499..ba8e8efb 100755 --- a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/Response.cpp +++ b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/Response.cpp @@ -1471,7 +1471,7 @@ namespace ChatSystem get(iter, m_type); get(iter, m_track); get(iter, m_result); - get(iter, (uint32 &)m_serverVersion); + get(iter, m_serverVersion); } ResAddSnoopAvatar::ResAddSnoopAvatar(void *user, unsigned srcAvatarID, const ChatUnicodeString &destName, const ChatUnicodeString &destAddress) diff --git a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/Response.h b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/Response.h index b1207746..edd3edba 100755 --- a/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/Response.h +++ b/external/3rd/library/soePlatform/ChatAPI/projects/ChatAPI/Response.h @@ -1186,9 +1186,9 @@ namespace ChatSystem virtual void unpack(Base::ByteStream::ReadIterator &iter); - unsigned long getServerVersion() const { return m_serverVersion; } + uint32_t getServerVersion() const { return m_serverVersion; } private: - unsigned long m_serverVersion; + uint32_t m_serverVersion; }; class ResAddSnoopAvatar : public GenericAPI::GenericResponse diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/Archive.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/Archive.h index 8e13f2c0..95c0c6f4 100755 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/Archive.h +++ b/external/3rd/library/soePlatform/ChatAPI/utils/Base/Archive.h @@ -664,8 +664,9 @@ const unsigned MAX_ARRAY_SIZE = 1024; Base::get(source, arraySize); ValueType v; - if (arraySize > MAX_ARRAY_SIZE) + if (arraySize > MAX_ARRAY_SIZE) { arraySize = 0; + } for(unsigned int i = 0; i < arraySize; ++i) { diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/UdpLibrary/UdpDriverLinux.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/UdpLibrary/UdpDriverLinux.cpp index aa11f5cd..9ca24014 100755 --- a/external/3rd/library/soePlatform/ChatAPI/utils/UdpLibrary/UdpDriverLinux.cpp +++ b/external/3rd/library/soePlatform/ChatAPI/utils/UdpLibrary/UdpDriverLinux.cpp @@ -1,6 +1,12 @@ // Copyright 2004 Sony Online Entertainment, all rights reserved. // Author: Jeff Petersen +#ifdef NDEBUG +#define SWG_ASSERT(exp) ((void) (exp)) +#else +#define SWG_ASSERT assert +#endif + #include "UdpDriver.h" #include "UdpHelper.h" @@ -17,7 +23,6 @@ #include // needed by gcc 3.1 for linux #include - namespace UdpLibrary { @@ -80,19 +85,19 @@ bool UdpPlatformDriver::SocketOpen(int port, int incomingBufferSize, int outgoin // open socket stuff unsigned long nb = 1; int err = ioctl(mData->socket, FIONBIO, &nb); - assert(err != -1); + SWG_ASSERT(err != -1); nb = outgoingBufferSize; err = setsockopt(mData->socket, SOL_SOCKET, SO_SNDBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = incomingBufferSize; err = setsockopt(mData->socket, SOL_SOCKET, SO_RCVBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = 0; err = setsockopt(mData->socket, SOL_SOCKET, SO_BSDCOMPAT, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = 1; err = setsockopt(mData->socket, SOL_IP, IP_RECVERR, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); int optLen = sizeof(mData->startTtl); getsockopt(mData->socket, IPPROTO_IP, IP_TTL, &mData->startTtl, (socklen_t *)&optLen); diff --git a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/serializeClasses.h b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/serializeClasses.h index 8e6e3740..7db29d5d 100755 --- a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/serializeClasses.h +++ b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/serializeClasses.h @@ -389,57 +389,45 @@ namespace soe { if (size < sizeof(int64)) return 0; -#if (defined(WIN32) || defined(linux)) - uint32 low = *(uint32_t *) &data; - uint32 high = *((uint32_t *)&data+1); -#elif defined(sparc) - uint32 low = *((uint32 *)&data+1); - uint32 high = *(uint32 *)(&data); -#endif - stream[BYTE1] = (unsigned char)low&0xff; - stream[BYTE2] = (unsigned char)(low>>8)&0xff; - stream[BYTE3] = (unsigned char)(low>>16)&0xff; - stream[BYTE4] = (unsigned char)(low>>24)&0xff; - stream[BYTE5] = (unsigned char)high&0xff; - stream[BYTE6] = (unsigned char)(high>>8)&0xff; - stream[BYTE7] = (unsigned char)(high>>16)&0xff; - stream[BYTE8] = (unsigned char)(high>>24)&0xff; + stream[BYTE1] = data&0xff; + stream[BYTE2] = (data>>8)&0xff; + stream[BYTE3] = (data>>16)&0xff; + stream[BYTE4] = (data>>24)&0xff; + stream[BYTE5] = (data>>32)&0xff; + stream[BYTE6] = (data>>40)&0xff; + stream[BYTE7] = (data>>48)&0xff; + stream[BYTE8] = (data>>56)&0xff; return sizeof(int64); } // 370 ns inline unsigned Write(unsigned char * stream, unsigned size, uint64 data, unsigned version = 0) { - if (size < sizeof(uint64)) + if (size < sizeof(int64)) return 0; -#if (defined(WIN32) || defined(linux)) - uint32 low = *(uint32_t *) &data; - uint32 high = *((uint32_t *)&data+1); -#elif defined(sparc) - uint32 low = *((uint32 *)&data+1); - uint32 high = *(uint32 *)(&data); -#endif - stream[BYTE1] = (unsigned char)low&0xff; - stream[BYTE2] = (unsigned char)(low>>8)&0xff; - stream[BYTE3] = (unsigned char)(low>>16)&0xff; - stream[BYTE4] = (unsigned char)(low>>24)&0xff; - stream[BYTE5] = (unsigned char)high&0xff; - stream[BYTE6] = (unsigned char)(high>>8)&0xff; - stream[BYTE7] = (unsigned char)(high>>16)&0xff; - stream[BYTE8] = (unsigned char)(high>>24)&0xff; - return sizeof(uint64); + stream[BYTE1] = data&0xff; + stream[BYTE2] = (data>>8)&0xff; + stream[BYTE3] = (data>>16)&0xff; + stream[BYTE4] = (data>>24)&0xff; + stream[BYTE5] = (data>>32)&0xff; + stream[BYTE6] = (data>>40)&0xff; + stream[BYTE7] = (data>>48)&0xff; + stream[BYTE8] = (data>>56)&0xff; + return sizeof(int64); } // 360 ns inline unsigned Write(unsigned char * stream, unsigned size, float data, unsigned version = 0) { - uint32 & dataRef = *(uint32_t *)(&data); if (size < sizeof(float)) return 0; - stream[BYTE1] = dataRef&0xff; - stream[BYTE2] = (dataRef>>8)&0xff; - stream[BYTE3] = (dataRef>>16)&0xff; - stream[BYTE4] = (dataRef>>24)&0xff; + unsigned char dataArr[sizeof(float)]; + memcpy(&dataArr, &data, sizeof(float)); + + stream[BYTE1] = dataArr[0]&0xff; + stream[BYTE2] = dataArr[1]&0xff; + stream[BYTE3] = dataArr[2]&0xff; + stream[BYTE4] = dataArr[3]&0xff; return sizeof(float); } @@ -448,21 +436,17 @@ namespace soe { if (size < sizeof(double)) return 0; -#if (defined(WIN32) || defined(linux)) - uint32 low = *(uint32_t *)(&data); - uint32 high = *((uint32_t *)&data+1); -#elif defined(sparc) - uint32 low = *((uint32 *)&data+1); - uint32 high = *(uint32 *)(&data); -#endif - stream[BYTE1] = (unsigned char)low&0xff; - stream[BYTE2] = (unsigned char)(low>>8)&0xff; - stream[BYTE3] = (unsigned char)(low>>16)&0xff; - stream[BYTE4] = (unsigned char)(low>>24)&0xff; - stream[BYTE5] = (unsigned char)high&0xff; - stream[BYTE6] = (unsigned char)(high>>8)&0xff; - stream[BYTE7] = (unsigned char)(high>>16)&0xff; - stream[BYTE8] = (unsigned char)(high>>24)&0xff; + unsigned char dataArr[sizeof(double)]; + memcpy(&dataArr, &data, sizeof(double)); + + stream[BYTE1] = dataArr[0]&0xff; + stream[BYTE2] = dataArr[1]&0xff; + stream[BYTE3] = dataArr[2]&0xff; + stream[BYTE4] = dataArr[3]&0xff; + stream[BYTE5] = dataArr[4]&0xff; + stream[BYTE6] = dataArr[5]&0xff; + stream[BYTE7] = dataArr[6]&0xff; + stream[BYTE8] = dataArr[7]&0xff; return sizeof(double); } diff --git a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/UdpLibrary/UdpLibrary.cpp b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/UdpLibrary/UdpLibrary.cpp index f86f5d7b..c7ca918d 100755 --- a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/UdpLibrary/UdpLibrary.cpp +++ b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/UdpLibrary/UdpLibrary.cpp @@ -1,3 +1,9 @@ +#ifdef NDEBUG +#define SWG_ASSERT(exp) ((void) (exp)) +#else +#define SWG_ASSERT assert +#endif + #include #include #include @@ -443,36 +449,36 @@ void UdpManager::CreateAndBindSocket(int usePort) #elif defined(sparc) ulong nb = 1; int err = ioctl(mUdpSocket, FIONBIO, &nb); - assert(err != -1); + SWG_ASSERT(err != -1); nb = udpMin(256 * 1024, mParams.outgoingBufferSize); err = setsockopt(mUdpSocket, SOL_SOCKET, SO_SNDBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = udpMin(256 * 1024, mParams.incomingBufferSize); err = setsockopt(mUdpSocket, SOL_SOCKET, SO_RCVBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); int optLen = sizeof(mStartTtl); getsockopt(mUdpSocket, IPPROTO_IP, IP_TTL, &mStartTtl, (socklen_t *)&optLen); nb = 1; err = setsockopt(mUdpSocket, SOL_SOCKET, SO_DGRAM_ERRIND, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); #else // linux is to remain the default compile mode unsigned long nb = 1; int err = ioctl(mUdpSocket, FIONBIO, &nb); - assert(err != -1); + SWG_ASSERT(err != -1); nb = mParams.outgoingBufferSize; err = setsockopt(mUdpSocket, SOL_SOCKET, SO_SNDBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = mParams.incomingBufferSize; err = setsockopt(mUdpSocket, SOL_SOCKET, SO_RCVBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = 0; err = setsockopt(mUdpSocket, SOL_SOCKET, SO_BSDCOMPAT, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = 1; err = setsockopt(mUdpSocket, SOL_IP, IP_RECVERR, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); int optLen = sizeof(mStartTtl); getsockopt(mUdpSocket, IPPROTO_IP, IP_TTL, &mStartTtl, (socklen_t *)&optLen); diff --git a/external/3rd/library/udplibrary/UdpLibrary.cpp b/external/3rd/library/udplibrary/UdpLibrary.cpp index 7862e486..7d91ea6c 100755 --- a/external/3rd/library/udplibrary/UdpLibrary.cpp +++ b/external/3rd/library/udplibrary/UdpLibrary.cpp @@ -1,3 +1,9 @@ +#ifdef NDEBUG +#define SWG_ASSERT(exp) ((void) (exp)) +#else +#define SWG_ASSERT assert +#endif + #include #include #include @@ -438,36 +444,36 @@ void UdpManager::CreateAndBindSocket(int usePort) #elif defined(sparc) ulong nb = 1; int err = ioctl(mUdpSocket, FIONBIO, &nb); - assert(err != -1); + SWG_ASSERT(err != -1); nb = udpMin(256 * 1024, mParams.outgoingBufferSize); err = setsockopt(mUdpSocket, SOL_SOCKET, SO_SNDBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = udpMin(256 * 1024, mParams.incomingBufferSize); err = setsockopt(mUdpSocket, SOL_SOCKET, SO_RCVBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); int optLen = sizeof(mStartTtl); getsockopt(mUdpSocket, IPPROTO_IP, IP_TTL, &mStartTtl, (socklen_t *)&optLen); nb = 1; err = setsockopt(mUdpSocket, SOL_SOCKET, SO_DGRAM_ERRIND, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); #else // linux is to remain the default compile mode unsigned long nb = 1; int err = ioctl(mUdpSocket, FIONBIO, &nb); - assert(err != -1); + SWG_ASSERT(err != -1); nb = mParams.outgoingBufferSize; err = setsockopt(mUdpSocket, SOL_SOCKET, SO_SNDBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = mParams.incomingBufferSize; err = setsockopt(mUdpSocket, SOL_SOCKET, SO_RCVBUF, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = 0; err = setsockopt(mUdpSocket, SOL_SOCKET, SO_BSDCOMPAT, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); nb = 1; err = setsockopt(mUdpSocket, SOL_IP, IP_RECVERR, &nb, sizeof(nb)); - assert(err == 0); + SWG_ASSERT(err == 0); int optLen = sizeof(mStartTtl); getsockopt(mUdpSocket, IPPROTO_IP, IP_TTL, &mStartTtl, (socklen_t *)&optLen); @@ -560,7 +566,8 @@ void UdpManager::RemoveConnection(UdpConnection *con) mAddressHashTable->Remove(con, AddressHashValue(con->mIp, con->mPort)); - unsigned int addy = con->mIp.GetAddress(); + // addy is unused + // unsigned int addy = con->mIp.GetAddress(); mConnectCodeHashTable->Remove(con, con->mConnectCode); } diff --git a/external/ours/library/archive/src/shared/AutoDeltaByteStream.h b/external/ours/library/archive/src/shared/AutoDeltaByteStream.h index 64519aa0..ab6f9ed5 100755 --- a/external/ours/library/archive/src/shared/AutoDeltaByteStream.h +++ b/external/ours/library/archive/src/shared/AutoDeltaByteStream.h @@ -726,7 +726,7 @@ public: /** pure virtual */ virtual ~AutoDeltaContainer() = 0; /** pure virtual */ - virtual const int32_t size() const = 0; + virtual const uint32_t size() const = 0; }; //----------------------------------------------------------------------- diff --git a/external/ours/library/archive/src/shared/AutoDeltaMap.h b/external/ours/library/archive/src/shared/AutoDeltaMap.h index ca223a0f..d1fc9018 100755 --- a/external/ours/library/archive/src/shared/AutoDeltaMap.h +++ b/external/ours/library/archive/src/shared/AutoDeltaMap.h @@ -65,7 +65,7 @@ public: // methods void pack(ByteStream & target) const; void packDelta(ByteStream & target) const; void set(const KeyType & key, const ValueType & value); - const int32_t size() const; + const uint32_t size() const; void unpack(ReadIterator & source); void unpackDelta(ReadIterator & source); static void pack(ByteStream & target, const std::vector & data); @@ -435,7 +435,7 @@ inline void AutoDeltaMap::packDelta(ByteStream & @return the number of elements in the map */ template -inline const int32_t AutoDeltaMap::size() const +inline const uint32_t AutoDeltaMap::size() const { return container.size(); } diff --git a/external/ours/library/archive/src/shared/AutoDeltaQueue.h b/external/ours/library/archive/src/shared/AutoDeltaQueue.h index d0305e8c..ad17937e 100755 --- a/external/ours/library/archive/src/shared/AutoDeltaQueue.h +++ b/external/ours/library/archive/src/shared/AutoDeltaQueue.h @@ -46,7 +46,7 @@ public: // methods const bool isDirty() const; void pack(ByteStream &target) const; void packDelta(ByteStream &target) const; - const int32_t size() const; + const uint32_t size() const; void unpack(ReadIterator &source); void unpackDelta(ReadIterator &source); @@ -293,7 +293,7 @@ inline void AutoDeltaQueue::packDelta(ByteStream &target) const //----------------------------------------------------------------------- template -inline const int32_t AutoDeltaQueue::size() const +inline const uint32_t AutoDeltaQueue::size() const { return container.size(); } diff --git a/external/ours/library/archive/src/shared/AutoDeltaSet.h b/external/ours/library/archive/src/shared/AutoDeltaSet.h index 14cf1e2d..67382f16 100644 --- a/external/ours/library/archive/src/shared/AutoDeltaSet.h +++ b/external/ours/library/archive/src/shared/AutoDeltaSet.h @@ -57,7 +57,7 @@ public: void packDelta(ByteStream &target) const; SetType const & get() const; - const int32_t size() const; + const uint32_t size() const; bool empty() const; bool contains(ValueType const &t) const; const_iterator find(ValueType const &t) const; @@ -402,7 +402,7 @@ inline bool AutoDeltaSet::empty() const //----------------------------------------------------------------------- template -inline const int32_t AutoDeltaSet::size() const +inline const uint32_t AutoDeltaSet::size() const { return m_set.size(); } @@ -486,7 +486,7 @@ inline void AutoDeltaSet::unpackDelta(ReadIterator &sourc { using Archive::get; Command c; - int32_t skipCount, commandCount, targetBaselineCommandCount; + uint32_t skipCount, commandCount, targetBaselineCommandCount; Archive::get(source, commandCount); Archive::get(source, targetBaselineCommandCount); @@ -503,7 +503,7 @@ inline void AutoDeltaSet::unpackDelta(ReadIterator &sourc if (skipCount > commandCount) skipCount = commandCount; - int32_t i = 0; + uint32_t i = 0; for ( ; i < skipCount; ++i) { Archive::get(source, c.cmd); diff --git a/external/ours/library/archive/src/shared/AutoDeltaVector.h b/external/ours/library/archive/src/shared/AutoDeltaVector.h index e7979a41..d0115f30 100755 --- a/external/ours/library/archive/src/shared/AutoDeltaVector.h +++ b/external/ours/library/archive/src/shared/AutoDeltaVector.h @@ -39,7 +39,7 @@ public: public: AutoDeltaVector(); - explicit AutoDeltaVector(int32_t initialSize); + explicit AutoDeltaVector(uint32_t initialSize); ~AutoDeltaVector(); const ValueType & back () const; @@ -74,7 +74,7 @@ public: void setOnInsert (ObjectType * owner, void (ObjectType::*onInsert)(const unsigned int, const ValueType &)); void setOnSet (ObjectType * owner, void (ObjectType::*onSet)(const unsigned int, const ValueType &, const ValueType &)); - const int32_t size () const; + const uint32_t size () const; bool empty () const; const ValueType & operator[] (const unsigned int element) const; @@ -91,7 +91,7 @@ private: private: std::vector v; - int32_t baselineCommandCount; + uint32_t baselineCommandCount; mutable std::vector commands; std::pair * onChangedCallback; std::pair * onEraseCallback; @@ -120,7 +120,7 @@ onSetCallback(0) //----------------------------------------------------------------------- template -inline AutoDeltaVector::AutoDeltaVector(int32_t initialSize) : +inline AutoDeltaVector::AutoDeltaVector(uint32_t initialSize) : AutoDeltaContainer(), v(initialSize), baselineCommandCount(0), @@ -366,7 +366,7 @@ inline void AutoDeltaVector::onSet(const unsigned int ele template inline void AutoDeltaVector::pack(ByteStream & target) const { - Archive::put(target, static_cast (v.size())); + Archive::put(target, static_cast (v.size())); Archive::put(target, baselineCommandCount); typename std::vector::const_iterator i; for (i = v.begin(); i != v.end(); ++i) @@ -380,8 +380,8 @@ inline void AutoDeltaVector::pack(ByteStream & target) co template inline void AutoDeltaVector::pack(ByteStream & target, const std::vector & data) { - Archive::put(target, static_cast(data.size())); - Archive::put(target, static_cast(0)); // baselineCommandCount + Archive::put(target, static_cast(data.size())); + Archive::put(target, static_cast(0)); // baselineCommandCount typename std::vector::const_iterator i; for (i = data.begin(); i != data.end(); ++i) { @@ -394,7 +394,7 @@ inline void AutoDeltaVector::pack(ByteStream & target, co template inline void AutoDeltaVector::packDelta(ByteStream & target) const { - Archive::put(target, static_cast(commands.size())); + Archive::put(target, static_cast(commands.size())); Archive::put(target, baselineCommandCount); typename std::vector::iterator i; @@ -483,13 +483,13 @@ inline void AutoDeltaVector::resize(size_type n, ValueTyp { // expand the vector v.resize(n); - for (int32_t i = size; i < n; ++i) + for (uint32_t i = size; i < n; ++i) set(i, x); } else if (size > n) { // contract the vector - for (int32_t i = size - 1; i >= n; --i) + for (uint32_t i = size - 1; i >= n; --i) { erase(i); @@ -607,7 +607,7 @@ inline bool AutoDeltaVector::empty() const //----------------------------------------------------------------------- template -inline const int32_t AutoDeltaVector::size() const +inline const uint32_t AutoDeltaVector::size() const { return v.size(); } @@ -622,13 +622,13 @@ inline void AutoDeltaVector::unpack(ReadIterator & source v.clear(); clearDelta(); - int32_t commandCount; + uint32_t commandCount; ValueType value; Archive::get(source, commandCount); Archive::get(source, baselineCommandCount); - for (int32_t i = 0; i < commandCount; ++i) + for (uint32_t i = 0; i < commandCount; ++i) { get(source, value); v.push_back(value); @@ -644,14 +644,14 @@ inline void AutoDeltaVector::unpack(ReadIterator & source { using Archive::get; // unpacking the whole kazaba - int32_t commandCount; - int32_t bcc; + uint32_t commandCount; + uint32_t bcc; Command c; Archive::get(source, commandCount); Archive::get(source, bcc); - for (int32_t i = 0; i < commandCount; ++i) + for (uint32_t i = 0; i < commandCount; ++i) { get(source,c.value); c.index = static_cast(i); @@ -668,12 +668,12 @@ inline void AutoDeltaVector::unpackDelta(ReadIterator & s { using Archive::get; Command c; - int32_t commandCount, targetBaselineCommandCount; + uint32_t commandCount, targetBaselineCommandCount; Archive::get(source, commandCount); Archive::get(source, targetBaselineCommandCount); - for (int32_t i=0 ; i < commandCount; ++i) + for (uint32_t i=0 ; i < commandCount; ++i) { Archive::get(source, c.cmd); switch (c.cmd) @@ -708,7 +708,7 @@ inline void AutoDeltaVector::unpackDelta(ReadIterator & s { using Archive::get; Command c; - int32_t skipCount, commandCount, targetBaselineCommandCount; + uint32_t skipCount, commandCount, targetBaselineCommandCount; Archive::get(source, commandCount); Archive::get(source, targetBaselineCommandCount); @@ -719,7 +719,7 @@ inline void AutoDeltaVector::unpackDelta(ReadIterator & s if (skipCount > commandCount) skipCount = commandCount; - int32_t i; + uint32_t i; for (i = 0; i < skipCount; ++i) { Archive::get(source, c.cmd); @@ -727,7 +727,7 @@ inline void AutoDeltaVector::unpackDelta(ReadIterator & s Archive::get(source, c.index); if (c.cmd == Command::SETALL) { - for (unsigned int j = 0; j < c.index; ++j) + for (uint32_t j = 0; j < c.index; ++j) { ++i; get(source, c.value);