示例#1
0
//
// 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;
}
示例#2
0
//
// 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;
}
示例#3
0
//
// 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;
}
示例#4
0
//
// 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;
}
示例#5
0
//
// 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;
    }
}
示例#6
0
//
// 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);
         }
      }
   }
}
示例#7
0
//
// Obtain a weaponinfo_t structure by name.
//
weaponinfo_t *E_WeaponForDEHNum(const int dehnum)
{
   return e_WeaponDehHash.objectForKey(dehnum);
}
示例#8
0
//
// Obtain a weaponinfo_t structure by name.
//
weaponinfo_t *E_WeaponForName(const char *name)
{
   return e_WeaponNameHash.objectForKey(name);
}
示例#9
0
//
// Obtain a weaponinfo_t structure for its ID number.
//
weaponinfo_t *E_WeaponForID(const int id)
{
   return e_WeaponIDHash.objectForKey(id);
}
示例#10
0
 virtual ~MetaTablePimpl()
 {
    keyhash.destroy();
    typehash.destroy();
 }
示例#11
0
ManagedDirectory *ManagedDirectory::DirectoryForName(const char *filename)
{
    return w_dirhash.objectForKey(filename);
}
示例#12
0
 //
 // 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();
 }