mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-27 06:55:54 -04:00
reduced the amount of new in reclists
This commit is contained in:
parent
8565f5ea8f
commit
d0b67cb567
@ -21,24 +21,14 @@ namespace ESMS
|
|||||||
template <typename X>
|
template <typename X>
|
||||||
struct RecListT : RecList
|
struct RecListT : RecList
|
||||||
{
|
{
|
||||||
typedef std::map<std::string,X*> MapType;
|
typedef std::map<std::string,X> MapType;
|
||||||
|
|
||||||
MapType list;
|
MapType list;
|
||||||
|
|
||||||
// Load one object of this type
|
// Load one object of this type
|
||||||
void load(ESMReader &esm, const std::string &id)
|
void load(ESMReader &esm, const std::string &id)
|
||||||
{
|
{
|
||||||
X *ref;
|
list[id].load(esm);
|
||||||
|
|
||||||
if(list.find(id) == list.end())
|
|
||||||
{
|
|
||||||
ref = new X;
|
|
||||||
list[id] = ref;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ref = list[id];
|
|
||||||
|
|
||||||
ref->load(esm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the given object ID, or return NULL if not found.
|
// Find the given object ID, or return NULL if not found.
|
||||||
@ -46,7 +36,7 @@ namespace ESMS
|
|||||||
{
|
{
|
||||||
if(list.find(id) == list.end())
|
if(list.find(id) == list.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
return list.find(id)->second;
|
return &list.find(id)->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSize() { return list.size(); }
|
int getSize() { return list.size(); }
|
||||||
@ -58,24 +48,16 @@ namespace ESMS
|
|||||||
template <typename X>
|
template <typename X>
|
||||||
struct RecIDListT : RecList
|
struct RecIDListT : RecList
|
||||||
{
|
{
|
||||||
typedef std::map<std::string,X*> MapType;
|
typedef std::map<std::string,X> MapType;
|
||||||
|
|
||||||
MapType list;
|
MapType list;
|
||||||
|
|
||||||
void load(ESMReader &esm, const std::string &id)
|
void load(ESMReader &esm, const std::string &id)
|
||||||
{
|
{
|
||||||
X *ref;
|
X& ref = list[id];
|
||||||
|
|
||||||
if(list.find(id) == list.end())
|
ref.id = id;
|
||||||
{
|
ref.load(esm);
|
||||||
ref = new X;
|
|
||||||
list[id] = ref;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ref = list[id];
|
|
||||||
|
|
||||||
ref->id = id;
|
|
||||||
ref->load(esm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSize() { return list.size(); }
|
int getSize() { return list.size(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user