diff --git a/CMakeLists.txt b/CMakeLists.txt index e3594347..7a066532 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,13 +77,13 @@ elseif (UNIX) endif () # don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS - set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -O0 -g3") + set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -O0 -ggdb") # release specific cflags - optimizations beyond the default for both types is mostly just -O flags set(CMAKE_CXX_FLAGS_RELEASE "-DDEBUG_LEVEL=0 -DPRODUCTION=1") # we use fewer, if any, crazy optimizations for profile generation, and likewise release flags for the minsizerel - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE}") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -ggdb") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE}") # Ofast doesn't work with gcc builds diff --git a/engine/server/application/TaskManager/src/shared/GameConnection.cpp b/engine/server/application/TaskManager/src/shared/GameConnection.cpp index baa6adfb..afbbc6cc 100755 --- a/engine/server/application/TaskManager/src/shared/GameConnection.cpp +++ b/engine/server/application/TaskManager/src/shared/GameConnection.cpp @@ -79,7 +79,7 @@ void GameConnection::receive(const Archive::ByteStream & message) { if(! m_pid) { - GenericValueTypeMessage msg(r); + GenericValueTypeMessage msg(r); m_pid = msg.getValue(); #ifndef _WIN32 diff --git a/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp b/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp index 42db2099..d131eff9 100755 --- a/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp +++ b/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp @@ -103,8 +103,8 @@ void ManagerConnection::onReceive(const Archive::ByteStream & message) switch(messageType) { case constcrc("SystemTimeCheck") : { - long const currentTime = static_cast(::time(nullptr)); - GenericValueTypeMessage > msg(r); + int32_t const currentTime = static_cast(::time(nullptr)); + GenericValueTypeMessage > msg(r); if (TaskManager::getNodeLabel() == "node0") { @@ -150,7 +150,7 @@ void ManagerConnection::onReceive(const Archive::ByteStream & message) { LOG("CustomerService", ("system_clock_mismatch:System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), remote TaskManager %s (%s) epoch (%ld). Telling remote TaskManager to terminate.", (std::max(currentTime, t.getCurrentEpochTime()) - std::min(currentTime, t.getCurrentEpochTime())), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), currentTime, t.getCommandLine().c_str(), getRemoteAddress().c_str(), t.getCurrentEpochTime())); - GenericValueTypeMessage > > systemTimeMismatchMessage("SystemTimeMismatchMessage", std::make_pair(TaskManager::getNodeLabel(), std::make_pair(static_cast(currentTime), t.getCurrentEpochTime()))); + GenericValueTypeMessage > > systemTimeMismatchMessage("SystemTimeMismatchMessage", std::make_pair(TaskManager::getNodeLabel(), std::make_pair(static_cast(currentTime), static_cast (t.getCurrentEpochTime())))); send(systemTimeMismatchMessage); } } @@ -166,7 +166,7 @@ void ManagerConnection::onReceive(const Archive::ByteStream & message) } case constcrc("SystemTimeMismatchMessage") : { - GenericValueTypeMessage > > msg(r); + GenericValueTypeMessage > > msg(r); FATAL((msg.getValue().first == "node0"), ("System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), self epoch (%ld)", (std::max(msg.getValue().second.first, msg.getValue().second.second) - std::min(msg.getValue().second.first, msg.getValue().second.second)), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), msg.getValue().second.first, msg.getValue().second.second)); break; } diff --git a/engine/server/application/TaskManager/src/shared/TaskManager.cpp b/engine/server/application/TaskManager/src/shared/TaskManager.cpp index f4a9ec31..356271db 100755 --- a/engine/server/application/TaskManager/src/shared/TaskManager.cpp +++ b/engine/server/application/TaskManager/src/shared/TaskManager.cpp @@ -970,7 +970,7 @@ void TaskManager::update() ManagerConnection * master = Locator::getServer("node0"); if (master) { - GenericValueTypeMessage > msg("SystemTimeCheck", std::make_pair(getNodeLabel(), static_cast(timeNow))); + GenericValueTypeMessage > msg("SystemTimeCheck", std::make_pair(getNodeLabel(), static_cast(timeNow))); master->send(msg); } } diff --git a/engine/server/library/serverUtility/src/shared/PopulationList.cpp b/engine/server/library/serverUtility/src/shared/PopulationList.cpp index 80db4b1e..1209b786 100755 --- a/engine/server/library/serverUtility/src/shared/PopulationList.cpp +++ b/engine/server/library/serverUtility/src/shared/PopulationList.cpp @@ -115,9 +115,9 @@ namespace Archive { void get(ReadIterator & source, PopulationList & target) { - size_t numEntries; + int32_t numEntries; get(source,numEntries); - for (size_t count=0; count < numEntries; ++count) + for (int32_t count=0; count < numEntries; ++count) { std::string scene; int x; @@ -133,7 +133,7 @@ namespace Archive void put(ByteStream & target, const PopulationList & source) { - put(target,source.m_populationMap.size()); + put(target, static_cast (source.m_populationMap.size())); for (PopulationList::PopulationMapType::const_iterator i=source.m_populationMap.begin(); i!=source.m_populationMap.end(); ++i) { put(target,i->first.getScene()); diff --git a/engine/shared/library/sharedNetworkMessages/src/shared/common/GameNetworkMessage.cpp b/engine/shared/library/sharedNetworkMessages/src/shared/common/GameNetworkMessage.cpp index bd1a5db3..651c01ae 100755 --- a/engine/shared/library/sharedNetworkMessages/src/shared/common/GameNetworkMessage.cpp +++ b/engine/shared/library/sharedNetworkMessages/src/shared/common/GameNetworkMessage.cpp @@ -122,7 +122,7 @@ std::string const &GameNetworkMessage::getCmdName() const // ---------------------------------------------------------------------- -std::string const &GameNetworkMessage::getCmdName(unsigned long cmdCrc) // static +std::string const &GameNetworkMessage::getCmdName(uint32_t cmdCrc) // static { std::string &val = s_messageTypes[cmdCrc]; if (val.empty()) diff --git a/engine/shared/library/sharedNetworkMessages/src/shared/common/GameNetworkMessage.h b/engine/shared/library/sharedNetworkMessages/src/shared/common/GameNetworkMessage.h index cac84466..2ee7de9b 100755 --- a/engine/shared/library/sharedNetworkMessages/src/shared/common/GameNetworkMessage.h +++ b/engine/shared/library/sharedNetworkMessages/src/shared/common/GameNetworkMessage.h @@ -39,7 +39,7 @@ public: std::string const &getCmdName() const; static std::vector > const getMessageCount(); - static std::string const &getCmdName(unsigned long cmdCrc); + static std::string const &getCmdName(uint32_t cmdCrc); private: GameNetworkMessage(); diff --git a/external/ours/library/archive/src/shared/Archive.h b/external/ours/library/archive/src/shared/Archive.h index 2921d66f..b47190c1 100755 --- a/external/ours/library/archive/src/shared/Archive.h +++ b/external/ours/library/archive/src/shared/Archive.h @@ -30,42 +30,28 @@ inline void get(ReadIterator & source, float & target) //--------------------------------------------------------------------- -inline void get(ReadIterator & source, unsigned long int & target) +inline void get(ReadIterator & source, uint32_t & target) { source.get(&target, 4); } //--------------------------------------------------------------------- -inline void get(ReadIterator & source, signed long int & target) +inline void get(ReadIterator & source, int32_t & target) { source.get(&target, 4); } //--------------------------------------------------------------------- -inline void get(ReadIterator & source, unsigned int & target) -{ - source.get(&target, 4); -} - -//--------------------------------------------------------------------- - -inline void get(ReadIterator & source, signed int & target) -{ - source.get(&target, 4); -} - -//--------------------------------------------------------------------- - -inline void get(ReadIterator & source, unsigned short int & target) +inline void get(ReadIterator & source, uint16_t & target) { source.get(&target, 2); } //--------------------------------------------------------------------- -inline void get(ReadIterator & source, signed short int & target) +inline void get(ReadIterator & source, int16_t & target) { source.get(&target, 2); } @@ -190,9 +176,9 @@ template inline void get_ptr(ReadIterator & source, std::vector inline void get(ReadIterator & source, std::map & target) { - size_t numKeys; + int32_t numKeys; get(source, numKeys); - size_t i; + int32_t i; for(i = 0; i < numKeys; ++i) { Key k; @@ -229,42 +215,28 @@ inline void put(ByteStream & target, const float & source) //--------------------------------------------------------------------- -inline void put(ByteStream & target, const unsigned long int & source) +inline void put(ByteStream & target, const uint32_t & source) { target.put(&source, 4); } //--------------------------------------------------------------------- -inline void put(ByteStream & target, const signed long int & source) +inline void put(ByteStream & target, const int32_t & source) { target.put(&source, 4); } //--------------------------------------------------------------------- -inline void put(ByteStream & target, const unsigned int & source) -{ - target.put(&source, 4); -} - -//--------------------------------------------------------------------- - -inline void put(ByteStream & target, const signed int & source) -{ - target.put(&source, 4); -} - -//--------------------------------------------------------------------- - -inline void put(ByteStream & target, const unsigned short int & source) +inline void put(ByteStream & target, const uint16_t & source) { target.put(&source, 2); } //--------------------------------------------------------------------- -inline void put(ByteStream & target, const signed short int & source) +inline void put(ByteStream & target, const int16_t & source) { target.put(&source, 2); } @@ -296,12 +268,12 @@ inline void put(ByteStream & target, const std::string & source) { if (source.size() < 65535) { - unsigned short len = static_cast(source.size()); + unsigned short len = static_cast(source.size()); put(target, len); } else { - unsigned short len = static_cast(65535); + unsigned short len = static_cast(65535); put(target, len); unsigned int size = source.size(); put(target, size); @@ -345,7 +317,7 @@ template inline void put(ByteStream & target, const std: template inline void put(ByteStream & target, const std::vector & source) { - signed int length = source.size(); + int32_t length = source.size(); target.put(&length, 4); for(int i = 0; i < length; ++i) { @@ -357,7 +329,7 @@ template inline void put(ByteStream & target, const std::vector & template inline void put(ByteStream & target, const std::set & source) { - signed int length = source.size(); + int32_t length = source.size(); target.put(&length, 4); for (typename std::set::const_iterator i = source.begin(); i != source.end(); ++i) put(target, *i); @@ -367,7 +339,7 @@ template inline void put(ByteStream & target, const std::set & so template inline void put(ByteStream & target, const std::deque & source) { - signed int length = source.size(); + int32_t length = source.size(); target.put(&length, 4); for(int i = 0; i < length; ++i) { @@ -379,7 +351,7 @@ template inline void put(ByteStream & target, const std::deque & template inline void put(ByteStream & target, const std::map & source) { - size_t numKeys = source.size(); + int32_t numKeys = source.size(); put(target, numKeys); for (typename std::map::const_iterator i = source.begin(); i != source.end(); ++i) { diff --git a/external/ours/library/archive/src/shared/AutoDeltaByteStream.h b/external/ours/library/archive/src/shared/AutoDeltaByteStream.h index 53b4d07d..64519aa0 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 size_t size() const = 0; + virtual const int32_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 9256495c..ca223a0f 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 size_t size() const; + const int32_t size() const; void unpack(ReadIterator & source); void unpackDelta(ReadIterator & source); static void pack(ByteStream & target, const std::vector & data); @@ -88,7 +88,7 @@ private: void onSet(const KeyType &, const ValueType &, const ValueType &); MapType container; - size_t baselineCommandCount; + int32_t baselineCommandCount; mutable std::vector changes; std::pair *onEraseCallback; std::pair *onInsertCallback; @@ -349,7 +349,7 @@ template inline void AutoDeltaMap::pack(ByteStream & target) const { typename std::map::const_iterator i; - Archive::put(target, container.size()); + Archive::put(target, static_cast(container.size())); Archive::put(target, baselineCommandCount); unsigned char cmd; for(i = container.begin(); i != container.end(); ++i) @@ -374,8 +374,8 @@ inline void AutoDeltaMap::pack(ByteStream & targ template inline void AutoDeltaMap::pack(ByteStream & target, const std::vector &data) { - Archive::put(target, data.size()); - Archive::put(target, static_cast(0)); // baselineCommandCount + Archive::put(target, static_cast(data.size())); + Archive::put(target, static_cast(0)); // baselineCommandCount for(typename std::vector::const_iterator c(data.begin()); c != data.end(); ++c) { assert(c->cmd == Command::ADD); // only add is valid in packing the whole container @@ -403,7 +403,7 @@ inline void AutoDeltaMap::pack(ByteStream & targ template inline void AutoDeltaMap::packDelta(ByteStream & target) const { - Archive::put(target, changes.size()); + Archive::put(target, static_cast(changes.size())); Archive::put(target, baselineCommandCount); for (typename std::vector::iterator i = changes.begin(); i != changes.end(); ++i) { @@ -435,7 +435,7 @@ inline void AutoDeltaMap::packDelta(ByteStream & @return the number of elements in the map */ template -inline const size_t AutoDeltaMap::size() const +inline const int32_t AutoDeltaMap::size() const { return container.size(); } @@ -514,12 +514,12 @@ inline void AutoDeltaMap::unpack(ReadIterator & clearDelta(); Command c; - size_t commandCount; + int32_t commandCount; Archive::get(source, commandCount); Archive::get(source, baselineCommandCount); - for (size_t i = 0; i < commandCount; ++i) + for (int32_t i = 0; i < commandCount; ++i) { Archive::get(source, c.cmd); assert(c.cmd == Command::ADD); // only add is valid in unpack @@ -548,13 +548,13 @@ inline void AutoDeltaMap::unpack(ReadIterator & // unpacking baseline data Command c; - size_t commandCount; - size_t baselineCommandCount; + int32_t commandCount; + int32_t baselineCommandCount; Archive::get(source, commandCount); Archive::get(source, baselineCommandCount); - for (size_t i = 0; i < commandCount; ++i) + for (int32_t i = 0; i < commandCount; ++i) { Archive::get(source, c.cmd); assert(c.cmd == Command::ADD); // only add is valid in unpack @@ -572,7 +572,7 @@ template inline void AutoDeltaMap::unpackDelta(ReadIterator & source) { Command c; - size_t skipCount, commandCount, targetBaselineCommandCount; + int32_t skipCount, commandCount, targetBaselineCommandCount; Archive::get(source, commandCount); Archive::get(source, targetBaselineCommandCount); @@ -593,7 +593,7 @@ inline void AutoDeltaMap::unpackDelta(ReadIterat if (skipCount > commandCount) skipCount = commandCount; - size_t i; + int32_t i; for (i = 0; i < skipCount; ++i) { Archive::get(source, c.cmd); @@ -647,12 +647,12 @@ template inline void AutoDeltaMap::unpackDelta(ReadIterator & source, std::vector & data) { Command c; - size_t commandCount, targetBaselineCommandCount; + int32_t commandCount, targetBaselineCommandCount; Archive::get(source, commandCount); Archive::get(source, targetBaselineCommandCount); - for (size_t i=0 ; i < commandCount; ++i) + for (int32_t i=0 ; i < commandCount; ++i) { Archive::get(source, c.cmd); switch(c.cmd) diff --git a/external/ours/library/archive/src/shared/AutoDeltaPackedMap.h b/external/ours/library/archive/src/shared/AutoDeltaPackedMap.h index 466bbde3..f6b0539f 100755 --- a/external/ours/library/archive/src/shared/AutoDeltaPackedMap.h +++ b/external/ours/library/archive/src/shared/AutoDeltaPackedMap.h @@ -23,8 +23,8 @@ namespace Archive void get(ReadIterator & source, unsigned __int64 & target); void put(ByteStream & target, const unsigned __int64 & source); #else - void get(ReadIterator & source, unsigned long long int & target); - void put(ByteStream & target, const unsigned long long int & source); + void get(ReadIterator & source, uint64_t & target); + void put(ByteStream & target, const uint64_t & source); #endif /** * An AutoDeltaPackedMap is an AutoDeltaMap that will be packed into @@ -100,7 +100,7 @@ namespace Archive typename AutoDeltaMap::Command c; Archive::put(target, countCharacter(buffer,':')); - Archive::put(target, static_cast(0)); // baselineCommandCount + Archive::put(target, static_cast(0)); // baselineCommandCount int tempPos = 0; for (std::string::const_iterator i=buffer.begin(); i!=buffer.end(); ++i) @@ -127,8 +127,8 @@ namespace Archive char temp[200]; typename AutoDeltaMap::Command c; - size_t commandCount; - size_t baselineCommandCount; + int32_t commandCount; + int32_t baselineCommandCount; Archive::get(source, commandCount); Archive::get(source, baselineCommandCount); @@ -139,7 +139,7 @@ namespace Archive } else { - for (size_t i = 0; i < commandCount; ++i) + for (int32_t i = 0; i < commandCount; ++i) { Archive::get(source, c.cmd); Archive::get(source, c.key); @@ -193,37 +193,25 @@ namespace Archive } template<> - inline void AutoDeltaPackedMap::pack(ByteStream & target, const std::string & buffer) + inline void AutoDeltaPackedMap::pack(ByteStream & target, const std::string & buffer) { internal_pack(target, buffer, "%i %i"); } template<> - inline void AutoDeltaPackedMap::unpack(ReadIterator & source, std::string & buffer) + inline void AutoDeltaPackedMap::unpack(ReadIterator & source, std::string & buffer) { internal_unpack(source, buffer, "%i %i:"); } template<> inline void AutoDeltaPackedMap::pack(ByteStream & target, const std::string & buffer) - { - internal_pack(target, buffer, "%i %i"); - } - - template<> - inline void AutoDeltaPackedMap::unpack(ReadIterator & source, std::string & buffer) - { - internal_unpack(source, buffer, "%i %i:"); - } - - template<> - inline void AutoDeltaPackedMap::pack(ByteStream & target, const std::string & buffer) { internal_pack(target, buffer, "%i %u"); } template<> - inline void AutoDeltaPackedMap::unpack(ReadIterator & source, std::string & buffer) + inline void AutoDeltaPackedMap::unpack(ReadIterator & source, std::string & buffer) { internal_unpack(source, buffer, "%i %u:"); } @@ -254,24 +242,13 @@ namespace Archive #else template<> - inline void AutoDeltaPackedMap::pack(ByteStream & target, const std::string & buffer) + inline void AutoDeltaPackedMap::pack(ByteStream & target, const std::string & buffer) { internal_pack(target, buffer, "%lu %llu"); } template<> - inline void AutoDeltaPackedMap::unpack(ReadIterator & source, std::string & buffer) - { - internal_unpack(source, buffer, "%lu %llu:"); - } - template<> - inline void AutoDeltaPackedMap::pack(ByteStream & target, const std::string & buffer) - { - internal_pack(target, buffer, "%lu %llu"); - } - - template<> - inline void AutoDeltaPackedMap::unpack(ReadIterator & source, std::string & buffer) + inline void AutoDeltaPackedMap::unpack(ReadIterator & source, std::string & buffer) { internal_unpack(source, buffer, "%lu %llu:"); } diff --git a/external/ours/library/archive/src/shared/AutoDeltaQueue.h b/external/ours/library/archive/src/shared/AutoDeltaQueue.h index 5b29aacf..d0305e8c 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 size_t size() const; + const int32_t size() const; void unpack(ReadIterator &source); void unpackDelta(ReadIterator &source); @@ -72,7 +72,7 @@ private: // members }; QueueType container; - size_t baselineCommandCount; + uint32_t baselineCommandCount; mutable std::vector changes; AutoDeltaQueue &operator=(AutoDeltaQueue const &); @@ -251,7 +251,7 @@ template inline void AutoDeltaQueue::pack(ByteStream &target) const { const_iterator i; - Archive::put(target, container.size()); + Archive::put(target, static_cast (container.size())); Archive::put(target, baselineCommandCount); unsigned char cmd; for (i = container.begin(); i != container.end(); ++i) @@ -267,7 +267,7 @@ inline void AutoDeltaQueue::pack(ByteStream &target) const template inline void AutoDeltaQueue::packDelta(ByteStream &target) const { - Archive::put(target, changes.size()); + Archive::put(target, static_cast (changes.size())); Archive::put(target, baselineCommandCount); for (typename std::vector::iterator i = changes.begin(); i != changes.end(); ++i) { @@ -293,7 +293,7 @@ inline void AutoDeltaQueue::packDelta(ByteStream &target) const //----------------------------------------------------------------------- template -inline const size_t AutoDeltaQueue::size() const +inline const int32_t AutoDeltaQueue::size() const { return container.size(); } @@ -324,12 +324,12 @@ inline void AutoDeltaQueue::unpack(ReadIterator &source) clearDelta(); ModifyCommand c; - size_t commandCount; + int32_t commandCount; Archive::get(source, commandCount); Archive::get(source, baselineCommandCount); - for (size_t i = 0; i < commandCount; ++i) + for (int32_t i = 0; i < commandCount; ++i) { Archive::get(source, c.cmd); assert(c.cmd == ModifyCommand::PUSH); // only push valid for pack/unpack @@ -345,7 +345,7 @@ inline void AutoDeltaQueue::unpackDelta(ReadIterator &source) { using Archive::get; ModifyCommand c; - size_t skipCount, commandCount, targetBaselineCommandCount; + int32_t skipCount, commandCount, targetBaselineCommandCount; Archive::get(source, commandCount); Archive::get(source, targetBaselineCommandCount); @@ -359,7 +359,7 @@ inline void AutoDeltaQueue::unpackDelta(ReadIterator &source) if (skipCount > commandCount) skipCount = commandCount; - size_t i; + int32_t i; for (i = 0; i < skipCount; ++i) { Archive::get(source, c.cmd); diff --git a/external/ours/library/archive/src/shared/AutoDeltaSet.h b/external/ours/library/archive/src/shared/AutoDeltaSet.h index e413c21e..14cf1e2d 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 size_t size() const; + const int32_t size() const; bool empty() const; bool contains(ValueType const &t) const; const_iterator find(ValueType const &t) const; @@ -84,7 +84,7 @@ private: private: SetType m_set; - size_t m_baselineCommandCount; + uint32_t m_baselineCommandCount; mutable std::vector m_commands; std::pair *m_onChangedCallback; std::pair *m_onEraseCallback; @@ -301,7 +301,7 @@ inline void AutoDeltaSet::onInsert(ValueType const &value template inline void AutoDeltaSet::pack(ByteStream &target) const { - Archive::put(target, m_set.size()); + Archive::put(target, static_cast (m_set.size())); Archive::put(target, m_baselineCommandCount); for (typename SetType::const_iterator i = m_set.begin(); i != m_set.end(); ++i) put(target, *i); @@ -312,8 +312,8 @@ inline void AutoDeltaSet::pack(ByteStream &target) const template inline void AutoDeltaSet::pack(ByteStream &target, std::set const &data) { - Archive::put(target, data.size()); - Archive::put(target, static_cast(0)); // baselineCommandCount + Archive::put(target, static_cast (data.size())); + Archive::put(target, static_cast (0)); // baselineCommandCount for (typename std::set::const_iterator i = data.begin(); i != data.end(); ++i) put(target, *i); } @@ -323,7 +323,7 @@ inline void AutoDeltaSet::pack(ByteStream &target, std::s template inline void AutoDeltaSet::packDelta(ByteStream &target) const { - Archive::put(target, m_commands.size()); + Archive::put(target, static_cast (m_commands.size())); Archive::put(target, m_baselineCommandCount); for (typename std::vector::iterator i = m_commands.begin(); i != m_commands.end(); ++i) { @@ -402,7 +402,7 @@ inline bool AutoDeltaSet::empty() const //----------------------------------------------------------------------- template -inline const size_t AutoDeltaSet::size() const +inline const int32_t AutoDeltaSet::size() const { return m_set.size(); } @@ -415,13 +415,13 @@ inline void AutoDeltaSet::unpack(ReadIterator &source) m_set.clear(); clearDelta(); - size_t commandCount; + int32_t commandCount; ValueType value; Archive::get(source, commandCount); Archive::get(source, m_baselineCommandCount); using Archive::get; - for (size_t i = 0; i < commandCount; ++i) + for (int32_t i = 0; i < commandCount; ++i) { get(source, value); m_set.insert(value); @@ -436,13 +436,13 @@ template inline void AutoDeltaSet::unpack(ReadIterator &source, std::vector &data) { Command c; - size_t commandCount, targetBaselineCommandCount; + int32_t commandCount, targetBaselineCommandCount; Archive::get(source, commandCount); Archive::get(source, targetBaselineCommandCount); c.cmd = Command::INSERT; - for (size_t i = 0; i < commandCount; ++i) + for (int32_t i = 0; i < commandCount; ++i) { Archive::get(source,c.value); data.push_back(c); @@ -455,12 +455,12 @@ template inline void AutoDeltaSet::unpackDelta(ReadIterator &source, std::vector &data) { Command c; - size_t commandCount, targetBaselineCommandCount; + int32_t commandCount, targetBaselineCommandCount; Archive::get(source, commandCount); Archive::get(source, targetBaselineCommandCount); - for (size_t i = 0 ; i < commandCount; ++i) + for (int32_t i = 0 ; i < commandCount; ++i) { Archive::get(source, c.cmd); switch (c.cmd) @@ -486,7 +486,7 @@ inline void AutoDeltaSet::unpackDelta(ReadIterator &sourc { using Archive::get; Command c; - size_t skipCount, commandCount, targetBaselineCommandCount; + int32_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; - size_t i = 0; + int32_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 5d2d37bf..e7979a41 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(size_t initialSize); + explicit AutoDeltaVector(int32_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 size_t size () const; + const int32_t size () const; bool empty () const; const ValueType & operator[] (const unsigned int element) const; @@ -91,7 +91,7 @@ private: private: std::vector v; - size_t baselineCommandCount; + int32_t baselineCommandCount; mutable std::vector commands; std::pair * onChangedCallback; std::pair * onEraseCallback; @@ -120,7 +120,7 @@ onSetCallback(0) //----------------------------------------------------------------------- template -inline AutoDeltaVector::AutoDeltaVector(size_t initialSize) : +inline AutoDeltaVector::AutoDeltaVector(int32_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, 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, 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, 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 (size_t i = size; i < n; ++i) + for (int32_t i = size; i < n; ++i) set(i, x); } else if (size > n) { // contract the vector - for (size_t i = size - 1; i >= n; --i) + for (int32_t i = size - 1; i >= n; --i) { erase(i); @@ -607,7 +607,7 @@ inline bool AutoDeltaVector::empty() const //----------------------------------------------------------------------- template -inline const size_t AutoDeltaVector::size() const +inline const int32_t AutoDeltaVector::size() const { return v.size(); } @@ -622,13 +622,13 @@ inline void AutoDeltaVector::unpack(ReadIterator & source v.clear(); clearDelta(); - size_t commandCount; + int32_t commandCount; ValueType value; Archive::get(source, commandCount); Archive::get(source, baselineCommandCount); - for (size_t i = 0; i < commandCount; ++i) + for (int32_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 - size_t commandCount; - size_t bcc; + int32_t commandCount; + int32_t bcc; Command c; Archive::get(source, commandCount); Archive::get(source, bcc); - for (size_t i = 0; i < commandCount; ++i) + for (int32_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; - size_t commandCount, targetBaselineCommandCount; + int32_t commandCount, targetBaselineCommandCount; Archive::get(source, commandCount); Archive::get(source, targetBaselineCommandCount); - for (size_t i=0 ; i < commandCount; ++i) + for (int32_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; - size_t skipCount, commandCount, targetBaselineCommandCount; + int32_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; - size_t i; + int32_t i; for (i = 0; i < skipCount; ++i) { Archive::get(source, c.cmd); diff --git a/external/ours/library/archive/src/shared/ByteStream.cpp b/external/ours/library/archive/src/shared/ByteStream.cpp index 4965bc8c..13aab2c1 100755 --- a/external/ours/library/archive/src/shared/ByteStream.cpp +++ b/external/ours/library/archive/src/shared/ByteStream.cpp @@ -5,6 +5,16 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + // ====================================================================== //static volatile int s_dataFreeListLocked; @@ -233,6 +243,31 @@ void ByteStream::get(void *target, ReadIterator &readIterator, const unsigned lo else { static const char * const desc = "Archive::ByteStream - read beyond end of buffer"; + std::cout << "read position: " << readIterator.getReadPosition() << " target size: " << targetSize << " allocated size: " << allocatedSize << std::endl; + std::cout << "I'm being called from: " << program_invocation_name; + std::cout << "======> BUFFER: " << std::endl; + + std::stringstream ss; + ss << std::hex << std::setfill('0'); + for (int i = 0; i < allocatedSize; ++i) + { + ss << std::setw(2) << static_cast(data->buffer[i]); + } + std::cout << ss.str() << std::endl; + + char pid_buf[30]; + sprintf(pid_buf, "%d", getpid()); + char name_buf[512]; + name_buf[readlink("/proc/self/exe", name_buf, 511)]=0; + prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0); + int child_pid = fork(); + if (!child_pid) { + dup2(2,1); // redirect output to stderr - edit: unnecessary? + execl("/usr/bin/gdb", "gdb", "--batch", "-n", "-ex", "thread", "-ex", "bt", name_buf, pid_buf, NULL); + abort(); /* If gdb failed to start */ + } else { + waitpid(child_pid,NULL,0); + } ReadException ex(desc); throw (ex); } diff --git a/external/ours/library/localization/src/shared/StringId.cpp b/external/ours/library/localization/src/shared/StringId.cpp index cb1492e4..3e8c28ba 100755 --- a/external/ours/library/localization/src/shared/StringId.cpp +++ b/external/ours/library/localization/src/shared/StringId.cpp @@ -39,7 +39,7 @@ m_textIndex (0) //---------------------------------------------------------------------- -StringId::StringId (const std::string & table, unsigned long textIndex) : +StringId::StringId (const std::string & table, uint32_t textIndex) : m_table (table), m_text (), m_textIndex (textIndex) @@ -238,7 +238,7 @@ void StringId::setText (const std::string & text) //---------------------------------------------------------------------- -void StringId::setTextIndex (unsigned long textIndex) const +void StringId::setTextIndex (uint32_t textIndex) const { m_textIndex = textIndex; } diff --git a/external/ours/library/localization/src/shared/StringId.h b/external/ours/library/localization/src/shared/StringId.h index 4b4572df..752a2ceb 100755 --- a/external/ours/library/localization/src/shared/StringId.h +++ b/external/ours/library/localization/src/shared/StringId.h @@ -39,12 +39,12 @@ public: StringId (); StringId (const std::string & table, const std::string & text); - StringId (const std::string & table, unsigned long textIndex); + StringId (const std::string & table, uint32_t textIndex); explicit StringId (const std::string & canonicalRepresentation); const std::string & getTable () const; const std::string & getText () const; - unsigned long getTextIndex () const; + uint32_t getTextIndex () const; bool isInvalid () const; bool isValid () const; @@ -60,7 +60,7 @@ public: //-- text index is a mutable property of the StringId //-- it is set the first time a StringId is localized, to speed up future lookups - void setTextIndex (unsigned long textIndex) const; + void setTextIndex (uint32_t textIndex) const; bool localize (LocUnicodeString & result, bool forceEnglish = false) const; LocUnicodeString localize (bool forceEnglish = false) const; @@ -79,7 +79,7 @@ private: std::string m_table; std::string m_text; - mutable unsigned long m_textIndex; //if this number is nonzero, assume it is valid + mutable uint32_t m_textIndex; //if this number is nonzero, assume it is valid }; //---------------------------------------------------------------------- @@ -98,7 +98,7 @@ inline const std::string & StringId::getText() const //---------------------------------------------------------------------- -inline unsigned long StringId::getTextIndex() const +inline uint32_t StringId::getTextIndex() const { return m_textIndex; } diff --git a/external/ours/library/localizationArchive/src/shared/StringIdArchive.cpp b/external/ours/library/localizationArchive/src/shared/StringIdArchive.cpp index b4054a25..028bbfda 100755 --- a/external/ours/library/localizationArchive/src/shared/StringIdArchive.cpp +++ b/external/ours/library/localizationArchive/src/shared/StringIdArchive.cpp @@ -23,7 +23,7 @@ namespace Archive */ void get(ReadIterator & source, StringId & target) { - unsigned long index = 0; + int32_t index = 0; std::string table; std::string name; diff --git a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp index a111e70c..dc9f96fa 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp @@ -331,21 +331,21 @@ void SwgSnapshot::encodeScriptObject(const NetworkId &objectId, Archive::ByteStr void SwgSnapshot::decodeAttributes(const NetworkId &objectId, Archive::ReadIterator &data, bool isBaseline, int offset) { if (isBaseline) { - size_t size, baselineCommandCount; + int32_t size, baselineCommandCount; Archive::get(data, size); Archive::get(data, baselineCommandCount); Attributes::Value temp; - for (size_t i = 0; i < size; ++i) { + for (int32_t i = 0; i < size; ++i) { Archive::get(data, temp); m_creatureObjectBuffer.setAttribute(objectId, i + offset, temp); } } else { typedef Archive::AutoDeltaVector VectorType; - size_t numCommands, baselineCommandCount; + int32_t numCommands, baselineCommandCount; Archive::get(data, numCommands); Archive::get(data, baselineCommandCount); - for (size_t count = 0; count < numCommands; ++count) { + for (int32_t count = 0; count < numCommands; ++count) { unsigned char cmd;// datatype? uint16 index; @@ -386,8 +386,8 @@ void SwgSnapshot::encodeAttributes(const NetworkId &objectId, Archive::ByteStrea std::vector values; m_creatureObjectBuffer.getAttributesForObject(objectId, values, offset, Attributes::NumberOfAttributes); - Archive::put(data, Attributes::NumberOfAttributes); - Archive::put(data, static_cast(0)); // baselineCommandCount + Archive::put(data, static_cast (Attributes::NumberOfAttributes)); + Archive::put(data, static_cast(0)); // baselineCommandCount if (values.size() < static_cast(Attributes::NumberOfAttributes)) { DEBUG_REPORT_LOG(true, ("Object %s did not have valid attribute data in the database. Missing attributes will be set to 100.\n", objectId.getValueString().c_str())); values.resize(Attributes::NumberOfAttributes, 100); @@ -754,21 +754,21 @@ void SwgSnapshot::ignorePersistedFlag(const NetworkId &objectId, Archive::ReadIt void SwgSnapshot::decodeLocationDataList(const NetworkId &objectId, size_t listId, Archive::ReadIterator &data, bool isBaseline) { if (isBaseline) { - size_t size, baselineCommandCount; + int32_t size, baselineCommandCount; Archive::get(data, size); Archive::get(data, baselineCommandCount); LocationData temp; - for (size_t i = 0; i < size; ++i) { + for (int32_t i = 0; i < size; ++i) { Archive::get(data, temp); m_locationBuffer.set(objectId, listId, i, temp); } } else { typedef Archive::AutoDeltaVector VectorType; - size_t numCommands, baselineCommandCount; + int32_t numCommands, baselineCommandCount; Archive::get(data, numCommands); Archive::get(data, baselineCommandCount); - for (size_t count = 0; count < numCommands; ++count) { + for (int32_t count = 0; count < numCommands; ++count) { unsigned char cmd; uint16 index; @@ -813,8 +813,8 @@ void SwgSnapshot::encodeLocationDataList(const NetworkId &objectId, size_t listI std::vector values; m_locationBuffer.getLocationList(objectId, listId, values); - Archive::put(data, values.size()); - Archive::put(data, static_cast(0)); + Archive::put(data, static_cast (values.size())); + Archive::put(data, static_cast(0)); for (std::vector::iterator i = values.begin(); i != values.end(); ++i) { Archive::put(data, *i); } @@ -855,8 +855,8 @@ void SwgSnapshot::encodeExperience(const NetworkId &objectId, Archive::ByteStrea ValuesType values; m_experienceBuffer.getExperienceForObject(objectId, values); - Archive::put(data, values.size()); - Archive::put(data, static_cast(0)); // baselineCommandCount + Archive::put(data, static_cast (values.size())); + Archive::put(data, static_cast (0)); // baselineCommandCount for (ValuesType::const_iterator i = values.begin(); i != values.end(); ++i) { const unsigned char command = 0; //ADD Archive::put(data, command); @@ -901,8 +901,8 @@ void SwgSnapshot::encodeBattlefieldParticipants(const NetworkId &objectId, Archi ValuesType values; m_battlefieldParticipantBuffer.getParticipantsForRegion(objectId, values); - Archive::put(data, values.size()); - Archive::put(data, static_cast(0)); // baselineCommandCount + Archive::put(data, static_cast (values.size())); + Archive::put(data, static_cast (0)); // baselineCommandCount for (ValuesType::const_iterator i = values.begin(); i != values.end(); ++i) { const unsigned char command = 0; //ADD Archive::put(data, command); @@ -945,8 +945,8 @@ void SwgSnapshot::encodeManufactureSchematicAttributes(const NetworkId &objectId ValuesType values; m_manufactureSchematicAttributeBuffer.getDataForObject(objectId, values); - Archive::put(data, values.size()); - Archive::put(data, static_cast(0)); // baselineCommandCount + Archive::put(data, static_cast (values.size())); + Archive::put(data, static_cast (0)); // baselineCommandCount for (ValuesType::const_iterator i = values.begin(); i != values.end(); ++i) { const unsigned char command = 0; //ADD Archive::put(data, command); @@ -1087,8 +1087,8 @@ void SwgSnapshot::encodeWaypoints(const NetworkId &objectId, Archive::ByteStream ValuesType values; m_waypointBuffer.getWaypointsForObject(objectId, values); - Archive::put(data, values.size()); - Archive::put(data, static_cast(0)); // baselineCommandCount + Archive::put(data, static_cast (values.size())); + Archive::put(data, static_cast (0)); // baselineCommandCount for (ValuesType::const_iterator i = values.begin(); i != values.end(); ++i) { const unsigned char command = 0; //ADD Archive::put(data, command);