// // 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; }
// // 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); } } } }