// // 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; }
// // 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; }
// // 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; }
// // ManagedDirectory Destructor // ManagedDirectory::~ManagedDirectory() { // close the wad file if it is open close(); // remove managed directory from the hash table w_dirhash.removeObject(this); // free directory filename if(name) { efree(name); name = NULL; } // free list of levels if(levels) { efree(levels); levels = NULL; } }
// // INStatsMgrPimpl::parseCSVScores // // Parse the CSV input file used to save top scores. // void INStatsMgrPimpl::parseCSVScores(char *input) { Collection<qstring> fields; // Go past the first line of input, which consists of column headers while(*input && *input != '\n') ++input; // Parse each remaining line while(*input) { parseCSVLine(input, fields); if(fields.getLength() >= FIELD_NUMFIELDS) { int recordType = E_StrToNumLinear(recordTypeNames, INSTAT_NUMTYPES, fields[FIELD_RECORDTYPE].constPtr()); if(recordType < INSTAT_NUMTYPES) { in_stat_t *newStats = estructalloc(in_stat_t, 1); newStats->levelkey = fields[FIELD_LEVELKEY ].duplicate(PU_STATIC); newStats->playername = fields[FIELD_PLAYERNAME].duplicate(PU_STATIC); newStats->skill = fields[FIELD_SKILL ].toInt(); newStats->value = fields[FIELD_VALUE ].toInt(); newStats->maxValue = fields[FIELD_MAXVALUE ].toInt(); newStats->recordType = recordType; // add to hash tables statsByLevelKey.addObject(newStats); } } } }
// // 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); }
virtual ~MetaTablePimpl() { keyhash.destroy(); typehash.destroy(); }
ManagedDirectory *ManagedDirectory::DirectoryForName(const char *filename) { return w_dirhash.objectForKey(filename); }
// // Reverse the order of the chains in the hash tables. This is a necessary // step when cloning a table, since head insertion logic used by EHashTable // will result in reversal of objects otherwise. // void reverseTables() { keyhash.reverseChains(); typehash.reverseChains(); }