crlib: reworked dictionary to hashmap.

linkage: another fix to dynamic linkage.
cpp: fixed msvc warning about placement new.
This commit is contained in:
dmitry 2020-06-15 22:36:11 +03:00 committed by jeefo
commit 43f6a7828a
12 changed files with 291 additions and 312 deletions

View file

@ -73,8 +73,8 @@ private:
StringArray m_logos;
StringArray m_avatars;
Dictionary <String, String, HashLangString> m_language;
Dictionary <int32, DifficultyData, IntNoHash <int32>> m_difficulty;
HashMap <String, String, HashLangString> m_language;
HashMap <int32, DifficultyData> m_difficulty;
// default tables for personality weapon preferences, overridden by weapon.cfg
SmallArray <int32> m_normalWeaponPrefs = { 0, 2, 1, 4, 5, 6, 3, 12, 10, 24, 25, 13, 11, 8, 7, 22, 23, 18, 21, 17, 19, 15, 17, 9, 14, 16 };

View file

@ -628,23 +628,10 @@ private:
# define HOOK_CAST SharedLibrary::Handle
#endif
private:
template <typename K> struct CharHash {
uint32 operator () (const char *key) const {
auto str = const_cast <char *> (key);
uint32 hash = 0;
while (*str++) {
hash = ((hash << 5) + hash) + *str;
}
return hash;
}
};
private:
SharedLibrary m_self;
SimpleHook m_dlsym;
Dictionary <const char *, SharedLibrary::Handle, CharHash <const char *>> m_exports;
HashMap <StringRef, SharedLibrary::Handle> m_exports;
public:
EntityLinkage () = default;

View file

@ -71,6 +71,7 @@ CR_DECLARE_SCOPED_ENUM (StatusIconCache,
class MessageDispatcher final : public Singleton <MessageDispatcher> {
private:
using MsgFunc = void (MessageDispatcher::*) ();
using MsgHash = Hash <int32>;
private:
struct Args {
@ -87,20 +88,22 @@ private:
};
private:
Dictionary <String, int32> m_textMsgCache; // cache strings for faster access for textmsg
Dictionary <String, int32> m_showMenuCache; // cache for the showmenu message
Dictionary <String, int32> m_statusIconCache; // cache for status icon message
Dictionary <String, int32> m_teamInfoCache; // cache for teaminfo message
HashMap <String, int32> m_textMsgCache; // cache strings for faster access for textmsg
HashMap <String, int32> m_showMenuCache; // cache for the showmenu message
HashMap <String, int32> m_statusIconCache; // cache for status icon message
HashMap <String, int32> m_teamInfoCache; // cache for teaminfo message
private:
Bot *m_bot {}; // owner of a message
NetMsg m_current {}; // ongoing message id
SmallArray <Args> m_args; // args collected from write* functions
Dictionary <String, NetMsg> m_wanted; // wanted messages
Dictionary <NetMsg, int32, IntNoHash <int32>> m_maps; // maps our message to id to engine message id
Dictionary <NetMsg, MsgFunc, IntNoHash <int32>> m_handlers; // maps our message id to handler function
HashMap <String, NetMsg> m_wanted; // wanted messages
HashMap <int32, NetMsg> m_reverseMap; // maps engine message id to our message id
HashMap <NetMsg, int32, MsgHash> m_maps; // maps our message to id to engine message id
HashMap <NetMsg, MsgFunc, MsgHash> m_handlers; // maps our message id to handler function
private:
void netMsgTextMsg ();

View file

@ -36,8 +36,8 @@ private:
SmallArray <Client> m_clients;
SmallArray <Twin <String, String>> m_tags;
Dictionary <int32, String, IntNoHash <int32>> m_weaponAlias;
Dictionary <String, int32> m_noiseCache;
HashMap <int32, String> m_weaponAlias;
HashMap <String, int32> m_noiseCache;
SimpleHook m_sendToHook;
public: