cssdm_weapons.cpp
changeset 32 9a3116df1513
parent 7 1107793f4b1c
child 92 52cc55d67b2f
     1.1 --- a/cssdm_weapons.cpp	Wed Jul 25 05:43:07 2007 +0000
     1.2 +++ b/cssdm_weapons.cpp	Tue Nov 13 22:29:35 2007 +0000
     1.3 @@ -27,22 +27,24 @@
     1.4  #include <string.h>
     1.5  #include "cssdm_weapons.h"
     1.6  #include "cssdm_headers.h"
     1.7 -#include "sm_trie.h"
     1.8 +#include <sm_trie_tpl.h>
     1.9  #include <sh_vector.h>
    1.10  
    1.11  using namespace SourceHook;
    1.12  
    1.13 -Trie *g_pWeaponLookup = NULL;
    1.14 +KTrie<dm_weapon_t *> g_WeaponLookup;
    1.15  CVector<dm_weapon_t *> g_Weapons;
    1.16  
    1.17  dm_weapon_t *DM_FindWeapon(const char *name)
    1.18  {
    1.19 -	dm_weapon_t *wp = NULL;
    1.20 -	if (!sm_trie_retrieve(g_pWeaponLookup, name,  (void **)&wp))
    1.21 +	dm_weapon_t **pWp;
    1.22 +
    1.23 +	if ((pWp = g_WeaponLookup.retrieve(name)) == NULL)
    1.24  	{
    1.25  		return NULL;
    1.26  	}
    1.27 -	return wp;
    1.28 +
    1.29 +	return *pWp;
    1.30  }
    1.31  
    1.32  dm_weapon_t *DM_GetWeapon(unsigned int index)
    1.33 @@ -84,8 +86,6 @@
    1.34  		return false;
    1.35  	}
    1.36  
    1.37 -	g_pWeaponLookup = sm_trie_create();
    1.38 -
    1.39  	for (weapons = weapons->GetFirstTrueSubKey(); weapons != NULL; weapons = weapons->GetNextTrueSubKey())
    1.40  	{
    1.41  		dm_weapon_t *wp = new dm_weapon_t;
    1.42 @@ -114,7 +114,7 @@
    1.43  		if (wp->type != WeaponType_Invalid)
    1.44  		{
    1.45  			wp->id = (int)g_Weapons.size();
    1.46 -			sm_trie_insert(g_pWeaponLookup, weapons->GetName(), wp);
    1.47 +			g_WeaponLookup.insert(weapons->GetName(), wp);
    1.48  			g_Weapons.push_back(wp);
    1.49  		}
    1.50  	}
    1.51 @@ -134,10 +134,5 @@
    1.52  		delete wp;
    1.53  	}
    1.54  	g_Weapons.clear();
    1.55 -
    1.56 -	if (g_pWeaponLookup)
    1.57 -	{
    1.58 -		sm_trie_destroy(g_pWeaponLookup);
    1.59 -		g_pWeaponLookup = NULL;
    1.60 -	}
    1.61 +	g_WeaponLookup.clear();
    1.62  }