mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-14 23:07:48 -04:00
c++11, love you... although this may end up duplicating some items on
the tc... - by removing the constructors and destructors for these structs and relying on init lists instead, we allow the compiler to automatically determine how to allocate and deallocate the values and references
This commit is contained in:
@@ -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,7 +329,7 @@ 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)
|
||||
{
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user