// // Returns a weapon type index given its name. Returns -1 // if a weapon type is not found. // weapontype_t E_WeaponNumForName(const char *name) { weaponinfo_t *info = nullptr; weapontype_t ret = -1; if((info = e_WeaponNameHash.objectForKey(name))) ret = info->id; return ret; }
// // MetaKey // // If the given key string is already interned, the metakey_t structure that // stores it will be returned. If not, it will be added to the collection of // keys and hashed by name. // static metakey_t &MetaKey(const char *key) { metakey_t *keyObj; // Do we already have this key? if(!(keyObj = metaKeyHash.objectForKey(key))) { keyObj = &metaKeys.addNew(); keyObj->key = estrdup(key); keyObj->index = metaKeys.getLength() - 1; keyObj->unmodHC = ENCStringHashKey::HashCode(key); // hash it metaKeyHash.addObject(keyObj, keyObj->unmodHC); } return *keyObj; }
// // ManagedDirectory::AddManagedDir // // Adds a new managed wad directory. Returns the new directory object. // ManagedDirectory *ManagedDirectory::AddManagedDir(const char *filename) { ManagedDirectory *newdir = NULL; // make sure there isn't one by this name already if(w_dirhash.objectForKey(filename)) return NULL; newdir = new ManagedDirectory; newdir->name = estrdup(filename); // set type information newdir->setType(WadDirectory::MANAGED); // mark as managed // add it to the hash table w_dirhash.addObject(newdir); return newdir; }
// // MetaKey // // If the given key string is already interned, the metakey_t structure that // stores it will be returned. If not, it will be added to the collection of // keys and hashed by name. // static metakey_t &MetaKey(const char *key) { metakey_t *keyObj; unsigned int unmodHC = ENCStringHashKey::HashCode(key); // Do we already have this key? if(!(keyObj = metaKeyHash.objectForKey(key, unmodHC))) { keyObj = estructalloc(metakey_t, 1); // add it to the list metaKeys.add(keyObj); keyObj->key = estrdup(key); keyObj->index = metaKeys.getLength() - 1; keyObj->unmodHC = unmodHC; // check for table overload, and hash it MetaHashRebuild<>(metaKeyHash); metaKeyHash.addObject(keyObj, keyObj->unmodHC); } return *keyObj; }
// // Obtain a weaponinfo_t structure by name. // weaponinfo_t *E_WeaponForDEHNum(const int dehnum) { return e_WeaponDehHash.objectForKey(dehnum); }
// // Obtain a weaponinfo_t structure by name. // weaponinfo_t *E_WeaponForName(const char *name) { return e_WeaponNameHash.objectForKey(name); }
// // Obtain a weaponinfo_t structure for its ID number. // weaponinfo_t *E_WeaponForID(const int id) { return e_WeaponIDHash.objectForKey(id); }
ManagedDirectory *ManagedDirectory::DirectoryForName(const char *filename) { return w_dirhash.objectForKey(filename); }