finish removing the SOE memory management

This commit is contained in:
DarthArgus
2016-12-04 00:56:11 +00:00
parent 9f9fed4693
commit f9c0a47a39
113 changed files with 163 additions and 3057 deletions
@@ -165,7 +165,7 @@ include_directories(
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public
@@ -315,7 +315,7 @@ target_link_libraries(SwgDatabaseServer
sharedGame
sharedLog
sharedMath
sharedMemoryManager
sharedMessageDispatch
sharedNetwork
sharedNetworkMessages
@@ -63,7 +63,7 @@ bool ObjvarBuffer::load(DB::Session *session,const DB::TagSet &tags, const std::
break;
}
IndexKey key(row->object_id.getValue(), row->name_id.getValue());
IndexKey key = { row->object_id.getValue(), row->name_id.getValue() };
ObjvarValue value;
value.m_type=row->type.getValue();
@@ -100,7 +100,7 @@ bool ObjvarBuffer::load(DB::Session *session,const DB::TagSet &tags, const std::
break;
}
IndexKey key(row->object_id.getValue(), row->name_id.getValue());
IndexKey key = { row->object_id.getValue(), row->name_id.getValue() };
ObjvarValue value;
value.m_type=row->type.getValue();
@@ -204,7 +204,7 @@ void ObjvarBuffer::getObjvarsForObject(const NetworkId &objectId, std::vector<Dy
// unpacked object variables
{
for (DataType::const_iterator i= m_data.lower_bound(IndexKey(objectId,0)); (i!=m_data.end()) && (i->first.m_objectId==objectId); ++i)
for (DataType::const_iterator i= m_data.lower_bound(IndexKey {objectId,0}); (i!=m_data.end()) && (i->first.m_objectId==objectId); ++i)
{
std::string name;
bool foundName = false;
@@ -234,7 +234,7 @@ void ObjvarBuffer::getObjvarsForObject(const NetworkId &objectId, std::vector<Dy
// The last objvar sent to the game takes precedence, so we want to send the overrides after the values read in through the regular process
{
for (DataType::const_iterator i= m_overrides.lower_bound(IndexKey(objectId,0)); (i!=m_overrides.end()) && (i->first.m_objectId==objectId); ++i)
for (DataType::const_iterator i= m_overrides.lower_bound(IndexKey {objectId,0}); (i!=m_overrides.end()) && (i->first.m_objectId==objectId); ++i)
{
std::string name;
bool foundName = false;
@@ -279,10 +279,10 @@ void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vector<Dy
{
int nameId = ObjvarNameManager::getInstance().getOrAddNameId(i->key);
DataType::iterator row=m_data.find(IndexKey(objectId, nameId));
DataType::iterator row=m_data.find(IndexKey {objectId, nameId});
if (row==m_data.end())
{
row=m_data.insert(std::make_pair(IndexKey(objectId, nameId),ObjvarValue())).first;
row=m_data.insert(std::make_pair(IndexKey{objectId, nameId},ObjvarValue())).first;
if (i->cmd==DynamicVariableList::MapType::Command::ADD || override)
row->second.m_inDatabase=false; // new variable
else
@@ -300,12 +300,12 @@ void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vector<Dy
int nameId = ObjvarNameManager::getInstance().getNameId(i->key);
if (nameId != 0) // It's possible to get an ERASE for a packed objvar where the name was never used in the OBJECT_VARIABLES table. We can safely ignore these.
{
DataType::iterator row=m_data.find(IndexKey(objectId, nameId));
DataType::iterator row=m_data.find(IndexKey {objectId, nameId});
if (row==m_data.end())
{
if (i->value.getPosition() == -1 || override)
{
row=m_data.insert(std::make_pair(IndexKey(objectId, nameId),ObjvarValue())).first;
row=m_data.insert(std::make_pair(IndexKey {objectId, nameId},ObjvarValue())).first;
row->second.m_inDatabase=true; // deleting existing variable
}
// else it was a packed objvar, and no update is necessary
@@ -329,13 +329,10 @@ void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vector<Dy
void ObjvarBuffer::removeObject(const NetworkId &object)
{
DataType::iterator i=m_data.lower_bound(IndexKey(object,0));
DataType::iterator i=m_data.lower_bound(IndexKey {object,0});
while (i!=m_data.end() && i->first.m_objectId==object)
{
DataType::iterator next=i;
++next;
m_data.erase(i);
i=next;
i = m_data.erase(i);
}
}
@@ -57,13 +57,9 @@ public:
private:
struct IndexKey
{
NetworkId m_objectId;
const NetworkId &m_objectId;
int m_nameId;
IndexKey(const NetworkId &objectId, int nameId);
~IndexKey(){
m_nameId = 0;
}
bool operator==(const IndexKey &rhs) const;
bool operator<(const IndexKey &rhs) const;
};
@@ -74,12 +70,6 @@ public:
std::string m_value;
bool m_detached;
bool m_inDatabase;
~ObjvarValue(){
m_type = 0;
m_detached = 0;
m_inDatabase = 0;
m_value.clear();
}
};
typedef std::map<IndexKey,ObjvarValue> DataType;
@@ -92,7 +82,6 @@ public:
// typedef std::map<NetworkId,std::vector<DBSchema::ObjectVariableRow*> > LoadIndexType;
// LoadIndexType m_loadIndex;
private:
ObjvarBuffer(); //disable
ObjvarBuffer(const ObjvarBuffer&); //disable
@@ -101,14 +90,6 @@ public:
// ======================================================================
inline ObjvarBuffer::IndexKey::IndexKey(const NetworkId &objectId, int nameId) :
m_objectId(objectId),
m_nameId(nameId)
{
}
// ----------------------------------------------------------------------
inline bool ObjvarBuffer::IndexKey::operator==(const IndexKey &rhs) const
{
return ((m_objectId == rhs.m_objectId) && (m_nameId == rhs.m_nameId));
@@ -12,7 +12,7 @@
#include "sharedFoundation/FirstSharedFoundation.h"
#include "sharedDebug/FirstSharedDebug.h"
#include "sharedMemoryManager/FirstSharedMemoryManager.h"
#include "sharedFoundation/NetworkIdArchive.h"