Addressed several compiler warnings from GCC

This commit is contained in:
Cekis
2022-01-24 23:34:28 -08:00
parent 7957b543fd
commit f8aaa0efdf
51 changed files with 314 additions and 299 deletions
+1
View File
@@ -0,0 +1 @@
* -crlf
+1 -1
View File
@@ -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")
@@ -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)
{
@@ -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"));
@@ -122,8 +122,8 @@ void ManagerConnection::onReceive(const Archive::ByteStream & message)
}
case constcrc("TaskConnectionIdMessage") :
{
static uint32_t const clockDriftFatalTimePeriod = static_cast<uint32_t>(TaskManager::getStartTime()) + ConfigTaskManager::getClockDriftFatalIntervalSeconds();
uint32_t const currentTime = static_cast<uint32_t>(::time(nullptr));
static int32_t const clockDriftFatalTimePeriod = static_cast<int32_t>(TaskManager::getStartTime()) + ConfigTaskManager::getClockDriftFatalIntervalSeconds();
int32_t const currentTime = static_cast<int32_t>(::time(nullptr));
TaskConnectionIdMessage t(r);
WARNING_STRICT_FATAL(t.getServerType() != TaskConnectionIdMessage::TaskManager,
("ManagerConnection received wrong type identifier"));
@@ -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"} })
@@ -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);
@@ -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]))
{
@@ -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<int>(::time(nullptr));
const int chatSpamTimeEndInterval = playerObject->getChatSpamTimeEndInterval();
const int32_t timeNow = static_cast<int32_t>(::time(nullptr));
const int32_t chatSpamTimeEndInterval = playerObject->getChatSpamTimeEndInterval();
if ((chatSpamTimeEndInterval > timeNow) && (timeNow >= playerObject->getChatSpamNextTimeToNotifyPlayerWhenLimited()))
{
GenericValueTypeMessage<int> csl("ChatSpamLimited", (chatSpamTimeEndInterval - timeNow));
GenericValueTypeMessage<uint32_t> 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<int>(::time(nullptr));
const int chatSpamTimeEndInterval = playerObject->getChatSpamTimeEndInterval();
const int32_t timeNow = static_cast<int32_t>(::time(nullptr));
const int32_t chatSpamTimeEndInterval = playerObject->getChatSpamTimeEndInterval();
if ((chatSpamTimeEndInterval > timeNow) && (timeNow >= playerObject->getChatSpamNextTimeToNotifyPlayerWhenLimited()))
{
GenericValueTypeMessage<int> 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];
@@ -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:
@@ -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)
@@ -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") : "<not ServerObject-derived>",
static_cast<int>(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") : "<not ServerObject-derived>",
static_cast<int>(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") : "<not ServerObject-derived>",
static_cast<int>(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") : "<not ServerObject-derived>",
static_cast<int>(GameServer::getInstance().getProcessId()),
oldPosition_w.x,
oldPosition_w.y,
oldPosition_w.z,
newPosition_w.x,
newPosition_w.y,
newPosition_w.z
));
}
}
// ----------------------------------------------------------------------
@@ -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<int> 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;
@@ -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<uint32>(std::stoi(name.substr(8, name.length()))) == stationId)
{
return true;
}
@@ -485,7 +485,7 @@ namespace CreatureObjectNamespace
{
bool creatureIsContainedInPOBShip(CreatureObject const * creatureObject);
void findAllTargetsForGroup(CreatureObject * const targetObj, std::vector<CreatureObject *> & 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<CreatureObject *> 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();
}
@@ -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<NetworkId, NetworkId> 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);
@@ -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<NetworkId, std::string> GroupMember;
typedef std::vector<GroupMember> 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;
@@ -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<uint32_t> 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<int> m_chatSpamNonSpatialNumCharacters;
Archive::AutoDeltaVariable<int> m_chatSpamTimeEndInterval;
Archive::AutoDeltaVariable<int> m_chatSpamNextTimeToSyncWithChatServer;
uint32_t m_chatSpamNextTimeToNotifyPlayerWhenLimited;
int32_t m_chatSpamNextTimeToNotifyPlayerWhenLimited;
// citizenship info
Archive::AutoDeltaVariable<std::string> 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;
}
@@ -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:"));
@@ -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<unsigned char> serverType;
Archive::AutoVariable<std::string> commandLine;
Archive::AutoVariable<std::string> clusterName;
Archive::AutoVariable<uint32_t> currentEpochTime;
Archive::AutoVariable<int32_t> 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();
}
@@ -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
@@ -803,6 +803,10 @@ void JavaLibrary::fatalHandler(int signum)
void *frameAddressB = nullptr;
uint64 frameAddressHigh = (reinterpret_cast<uint64>(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)
@@ -549,7 +549,9 @@ BaseExtent * convertToSimpleExtent ( BaseExtent const * sourceExtent )
{
Extent const * extent = safe_cast<Extent const *>(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<CylinderExtent const *>(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<BoxExtent const *>(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<MeshExtent const *>(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<DetailExtent const *>(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<ComponentExtent const *>(sourceExtent);
if(!extent) return nullptr;
if(!extent) {
return nullptr;
}
ComponentExtent * newExtent = new ComponentExtent();
@@ -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
}
}
@@ -32,28 +32,6 @@ using namespace DB::OCISessionNamespace;
// ======================================================================
static dvoid *mallocHook(dvoid *, size_t size)
{
return reinterpret_cast<dvoid *>(new char[size]);
}
// ----------------------------------------------------------------------
static dvoid *reallocHook(dvoid *, dvoid *memptr, size_t newsize)
{
return reinterpret_cast<dvoid *>(realloc(memptr, newsize));
}
// ----------------------------------------------------------------------
static void freeHook(dvoid *, dvoid *memptr)
{
if (memptr)
delete [] reinterpret_cast<char *>(memptr);
}
// ======================================================================
DB::OCISession::OCISession(DB::OCIServer *server) :
m_server(server),
envhp(nullptr),
@@ -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";
@@ -1385,12 +1385,11 @@ void CommandLine::absorbString(const char *newString)
DEBUG_FATAL(!newString, ("nullptr newString arg"));
const int stringLength = static_cast<int>(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)
{
@@ -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 <cassert>
#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<struct sockaddr *>(&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<struct sockaddr *>(&a), &namelen);
assert(r == 0);
int r = getsockname(handle, reinterpret_cast<struct sockaddr *>(&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<sockaddr *>(&(target)), &namelen);
assert(err != -1);
int err = getpeername(s, reinterpret_cast<sockaddr *>(&(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);
}
//---------------------------------------------------------------------
@@ -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"));
}
@@ -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<float>((_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;
};
// ======================================================================
@@ -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<uint32 *>(&x));
const uint32 iz = (*reinterpret_cast<uint32 *>(&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<uint32>(IEEE_FLOAT_BITS) | maskedHash;
const float returnValue = (*reinterpret_cast<float *>(&iFloat)) - 1.0F;
return returnValue;
}
@@ -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);
};
//===================================================================
+2 -1
View File
@@ -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)
@@ -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)
{
@@ -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)
{
@@ -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);
}
@@ -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);
@@ -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;
}
@@ -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;
@@ -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)
@@ -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
@@ -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)
{
@@ -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 <netinet/ip_icmp.h> // needed by gcc 3.1 for linux
#include <pthread.h>
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);
@@ -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);
}
@@ -1,3 +1,9 @@
#ifdef NDEBUG
#define SWG_ASSERT(exp) ((void) (exp))
#else
#define SWG_ASSERT assert
#endif
#include <assert.h>
#include <time.h>
#include <stdlib.h>
@@ -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);
+17 -10
View File
@@ -1,3 +1,9 @@
#ifdef NDEBUG
#define SWG_ASSERT(exp) ((void) (exp))
#else
#define SWG_ASSERT assert
#endif
#include <assert.h>
#include <time.h>
#include <stdlib.h>
@@ -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);
}
@@ -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;
};
//-----------------------------------------------------------------------
+2 -2
View File
@@ -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<Command> & data);
@@ -435,7 +435,7 @@ inline void AutoDeltaMap<KeyType, ValueType, ObjectType>::packDelta(ByteStream &
@return the number of elements in the map
*/
template<class KeyType, typename ValueType, typename ObjectType>
inline const int32_t AutoDeltaMap<KeyType, ValueType, ObjectType>::size() const
inline const uint32_t AutoDeltaMap<KeyType, ValueType, ObjectType>::size() const
{
return container.size();
}
+2 -2
View File
@@ -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<ValueType>::packDelta(ByteStream &target) const
//-----------------------------------------------------------------------
template<typename ValueType>
inline const int32_t AutoDeltaQueue<ValueType>::size() const
inline const uint32_t AutoDeltaQueue<ValueType>::size() const
{
return container.size();
}
+4 -4
View File
@@ -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<ValueType, ObjectType>::empty() const
//-----------------------------------------------------------------------
template<typename ValueType, typename ObjectType>
inline const int32_t AutoDeltaSet<ValueType, ObjectType>::size() const
inline const uint32_t AutoDeltaSet<ValueType, ObjectType>::size() const
{
return m_set.size();
}
@@ -486,7 +486,7 @@ inline void AutoDeltaSet<ValueType, ObjectType>::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<ValueType, ObjectType>::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);
+21 -21
View File
@@ -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<ValueType> v;
int32_t baselineCommandCount;
uint32_t baselineCommandCount;
mutable std::vector<Command> commands;
std::pair<ObjectType *, void (ObjectType::*)()> * onChangedCallback;
std::pair<ObjectType *, void (ObjectType::*)(const unsigned int, const ValueType &)> * onEraseCallback;
@@ -120,7 +120,7 @@ onSetCallback(0)
//-----------------------------------------------------------------------
template<typename ValueType, typename ObjectType>
inline AutoDeltaVector<ValueType, ObjectType>::AutoDeltaVector(int32_t initialSize) :
inline AutoDeltaVector<ValueType, ObjectType>::AutoDeltaVector(uint32_t initialSize) :
AutoDeltaContainer(),
v(initialSize),
baselineCommandCount(0),
@@ -366,7 +366,7 @@ inline void AutoDeltaVector<ValueType, ObjectType>::onSet(const unsigned int ele
template<typename ValueType, typename ObjectType>
inline void AutoDeltaVector<ValueType, ObjectType>::pack(ByteStream & target) const
{
Archive::put(target, static_cast<int32_t> (v.size()));
Archive::put(target, static_cast<uint32_t> (v.size()));
Archive::put(target, baselineCommandCount);
typename std::vector<ValueType>::const_iterator i;
for (i = v.begin(); i != v.end(); ++i)
@@ -380,8 +380,8 @@ inline void AutoDeltaVector<ValueType, ObjectType>::pack(ByteStream & target) co
template<typename ValueType, typename ObjectType>
inline void AutoDeltaVector<ValueType, ObjectType>::pack(ByteStream & target, const std::vector<ValueType> & data)
{
Archive::put(target, static_cast<int32_t>(data.size()));
Archive::put(target, static_cast<int32_t>(0)); // baselineCommandCount
Archive::put(target, static_cast<uint32_t>(data.size()));
Archive::put(target, static_cast<uint32_t>(0)); // baselineCommandCount
typename std::vector<ValueType>::const_iterator i;
for (i = data.begin(); i != data.end(); ++i)
{
@@ -394,7 +394,7 @@ inline void AutoDeltaVector<ValueType, ObjectType>::pack(ByteStream & target, co
template<typename ValueType, typename ObjectType>
inline void AutoDeltaVector<ValueType, ObjectType>::packDelta(ByteStream & target) const
{
Archive::put(target, static_cast<int32_t>(commands.size()));
Archive::put(target, static_cast<uint32_t>(commands.size()));
Archive::put(target, baselineCommandCount);
typename std::vector<Command>::iterator i;
@@ -483,13 +483,13 @@ inline void AutoDeltaVector<ValueType, ObjectType>::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<ValueType, ObjectType>::empty() const
//-----------------------------------------------------------------------
template<typename ValueType, typename ObjectType>
inline const int32_t AutoDeltaVector<ValueType, ObjectType>::size() const
inline const uint32_t AutoDeltaVector<ValueType, ObjectType>::size() const
{
return v.size();
}
@@ -622,13 +622,13 @@ inline void AutoDeltaVector<ValueType, ObjectType>::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<ValueType, ObjectType>::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<unsigned short int>(i);
@@ -668,12 +668,12 @@ inline void AutoDeltaVector<ValueType, ObjectType>::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<ValueType, ObjectType>::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<ValueType, ObjectType>::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<ValueType, ObjectType>::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);