Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions core/HalfLife2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,20 +445,25 @@ bool CHalfLife2::FindSendPropInfo(const char *classname, const char *offset, sm_
return false;
}

if (!pInfo->lookup.retrieve(offset, info))
DataTableInfo::SendPropInfo temp;

if (!pInfo->lookup.retrieve(offset, &temp))
{
sm_sendprop_info_t temp_info;
bool found = UTIL_FindInSendTable(pInfo->sc->m_pTable, offset, &temp.info, 0);
temp.name = offset;

pInfo->lookup.insert(offset, temp);

if (!UTIL_FindInSendTable(pInfo->sc->m_pTable, offset, &temp_info, 0))
if (found)
{
return false;
*info = temp.info;
}

pInfo->lookup.insert(offset, temp_info);
*info = temp_info;
return found;
}

return true;

*info = temp.info;
return info->prop != nullptr;
}

SendProp *CHalfLife2::FindInSendTable(const char *classname, const char *offset)
Expand Down Expand Up @@ -492,15 +497,25 @@ bool CHalfLife2::FindDataMapInfo(datamap_t *pMap, const char *offset, sm_datatab
m_Maps.add(i, pMap, new DataMapCache());

DataMapCache *cache = i->value;
DataMapCacheInfo temp;

if (!cache->retrieve(offset, pDataTable))
if (!cache->retrieve(offset, &temp))
{
if (!UTIL_FindDataMapInfo(pMap, offset, pDataTable))
return false;
cache->insert(offset, *pDataTable);
bool found = UTIL_FindDataMapInfo(pMap, offset, &temp.info);
temp.name = offset;

cache->insert(offset, temp);

if (found)
{
*pDataTable = temp.info;
}

return found;
}

return true;
*pDataTable = temp.info;
return pDataTable->prop != nullptr;
}

void CHalfLife2::SetEdictStateChanged(edict_t *pEdict, unsigned short offset)
Expand Down
32 changes: 24 additions & 8 deletions core/HalfLife2.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,24 @@ using namespace SourceMod;

struct DataTableInfo
{
struct SendPropPolicy
struct SendPropInfo
{
static inline bool matches(const char *name, const sm_sendprop_info_t &info)
static inline bool matches(const char *name, const SendPropInfo &info)
{
return strcmp(name, info.prop->GetName()) == 0;
return strcmp(name, info.name.c_str()) == 0;
}
static inline uint32_t hash(const detail::CharsAndLength &key)
{
return key.hash();
}

SendPropInfo()
: name(), info{nullptr, 0}
{
}

std::string name;
sm_sendprop_info_t info;
};

static inline bool matches(const char *name, const DataTableInfo *info)
Expand All @@ -116,22 +124,30 @@ struct DataTableInfo
}

ServerClass *sc;
NameHashSet<sm_sendprop_info_t, SendPropPolicy> lookup;
NameHashSet<SendPropInfo> lookup;
};

struct DataMapCachePolicy
struct DataMapCacheInfo
{
static inline bool matches(const char *name, const sm_datatable_info_t &info)
static inline bool matches(const char *name, const DataMapCacheInfo &info)
{
return strcmp(name, info.prop->fieldName) == 0;
return strcmp(name, info.name.c_str()) == 0;
}
static inline uint32_t hash(const detail::CharsAndLength &key)
{
return key.hash();
}

DataMapCacheInfo()
: name(), info{nullptr, 0}
{
}

std::string name;
sm_datatable_info_t info;
};

typedef NameHashSet<sm_datatable_info_t, DataMapCachePolicy> DataMapCache;
typedef NameHashSet<DataMapCacheInfo> DataMapCache;

struct DelayedFakeCliCmd
{
Expand Down