mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
The KeyValues class belongs here. Also reimplemented most loading methods for KeyValues, and adjusted the VPK building code to account for it. Pointers to the engine's implementation of KeyValues have been moved to a separate header ('keyvalues_iface.h'), as this allows external tools code to utilize the standalone KeyValues class implementation. Playlist utilities are completely separated from the KeyValues header; these have nothing to do with KeyValues other than manipulating a global KeyValues object for the playlists, and thus have been named as such and moved to rtech/playlists.
62 lines
855 B
C++
62 lines
855 B
C++
#ifndef KVLEAKTRACE_H
|
|
#define KVLEAKTRACE_H
|
|
#include "tier1/utlvector.h"
|
|
|
|
#ifdef LEAKTRACK
|
|
class CLeakTrack
|
|
{
|
|
public:
|
|
CLeakTrack()
|
|
{
|
|
}
|
|
~CLeakTrack()
|
|
{
|
|
if (keys.Count() != 0)
|
|
{
|
|
Assert(0);
|
|
}
|
|
}
|
|
|
|
struct kve
|
|
{
|
|
KeyValues* kv;
|
|
char name[256];
|
|
};
|
|
|
|
void AddKv(KeyValues* kv, char const* name)
|
|
{
|
|
kve k;
|
|
strncpy(k.name, name ? name : "NULL", sizeof(k.name));
|
|
k.kv = kv;
|
|
|
|
keys.AddToTail(k);
|
|
}
|
|
|
|
void RemoveKv(KeyValues* kv)
|
|
{
|
|
int c = keys.Count();
|
|
for (int i = 0; i < c; i++)
|
|
{
|
|
if (keys[i].kv == kv)
|
|
{
|
|
keys.Remove(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
CUtlVector< kve > keys;
|
|
};
|
|
|
|
static CLeakTrack track;
|
|
|
|
#define TRACK_KV_ADD( ptr, name ) track.AddKv( ptr, name )
|
|
#define TRACK_KV_REMOVE( ptr ) track.RemoveKv( ptr )
|
|
|
|
#else
|
|
|
|
#define TRACK_KV_ADD( ptr, name )
|
|
#define TRACK_KV_REMOVE( ptr )
|
|
|
|
#endif
|
|
#endif // KVLEAKTRACE_H
|