core/HalfLife2.h
changeset 4069 336e32fe098f
parent 3997 59bcfc51eb79
     1.1 --- a/core/HalfLife2.h	Sun Aug 25 11:59:48 2013 -0700
     1.2 +++ b/core/HalfLife2.h	Sun Aug 25 11:59:48 2013 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /**
     1.5 - * vim: set ts=4 :
     1.6 + * vim: set ts=4 sw=4 tw=99 noet :
     1.7   * =============================================================================
     1.8   * SourceMod
     1.9   * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
    1.10 @@ -35,8 +35,10 @@
    1.11  #include <sh_list.h>
    1.12  #include <sh_string.h>
    1.13  #include <sh_tinyhash.h>
    1.14 -#include <sm_trie_tpl.h>
    1.15 -#include "sm_trie.h"
    1.16 +#include <am-utility.h>
    1.17 +#include <am-hashmap.h>
    1.18 +#include <sm_stringhashmap.h>
    1.19 +#include <sm_namehashset.h>
    1.20  #include "sm_globals.h"
    1.21  #include "sm_queue.h"
    1.22  #include <IGameHelpers.h>
    1.23 @@ -59,16 +61,38 @@
    1.24  
    1.25  struct DataTableInfo
    1.26  {
    1.27 +	struct SendPropPolicy
    1.28 +	{
    1.29 +		static inline bool matches(const char *name, const sm_sendprop_info_t &info)
    1.30 +		{
    1.31 +			return strcmp(name, info.prop->GetName()) == 0;
    1.32 +		}
    1.33 +	};
    1.34 +
    1.35 +	static inline bool matches(const char *name, const DataTableInfo *info)
    1.36 +	{
    1.37 +		return strcmp(name, info->sc->GetName()) == 0;
    1.38 +	}
    1.39 +
    1.40 +	DataTableInfo(ServerClass *sc)
    1.41 +		: sc(sc)
    1.42 +	{
    1.43 +	}
    1.44 +
    1.45  	ServerClass *sc;
    1.46 -	KTrie<sm_sendprop_info_t> lookup;
    1.47 +	NameHashSet<sm_sendprop_info_t, SendPropPolicy> lookup;
    1.48  };
    1.49  
    1.50 -struct DataMapTrie
    1.51 +struct DataMapCachePolicy
    1.52  {
    1.53 -	DataMapTrie() : trie(NULL) {}
    1.54 -	KTrie<sm_datatable_info_t> *trie;
    1.55 +	static inline bool matches(const char *name, const sm_datatable_info_t &info)
    1.56 +	{
    1.57 +		return strcmp(name, info.prop->fieldName) == 0;
    1.58 +	}
    1.59  };
    1.60  
    1.61 +typedef NameHashSet<sm_datatable_info_t, DataMapCachePolicy> DataMapCache;
    1.62 +
    1.63  struct DelayedFakeCliCmd
    1.64  {
    1.65  	String cmd;
    1.66 @@ -169,9 +193,10 @@
    1.67  	void InitLogicalEntData();
    1.68  	void InitCommandLine();
    1.69  private:
    1.70 -	Trie *m_pClasses;
    1.71 -	List<DataTableInfo *> m_Tables;
    1.72 -	THash<datamap_t *, DataMapTrie> m_Maps;
    1.73 +	typedef ke::HashMap<datamap_t *, DataMapCache *, ke::PointerPolicy<datamap_t> > DataTableMap;
    1.74 +
    1.75 +	NameHashSet<DataTableInfo *> m_Classes;
    1.76 +	DataTableMap m_Maps;
    1.77  	int m_MsgTextMsg;
    1.78  	int m_HinTextMsg;
    1.79  	int m_SayTextMsg;