- moved FDoomEdMap to its own file to make the upcoming changes a bit nicer to handle.
This commit is contained in:
parent
6c603b3c78
commit
ccd9fb9c23
3 changed files with 183 additions and 133 deletions
133
src/info.cpp
133
src/info.cpp
|
|
@ -389,139 +389,6 @@ fixed_t *DmgFactors::CheckFactor(FName type)
|
|||
return pdf;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FDoomEdMap DoomEdMap;
|
||||
|
||||
FDoomEdMap::FDoomEdEntry *FDoomEdMap::DoomEdHash[DOOMED_HASHSIZE];
|
||||
|
||||
FDoomEdMap::~FDoomEdMap()
|
||||
{
|
||||
Empty();
|
||||
}
|
||||
|
||||
void FDoomEdMap::AddType (int doomednum, const PClass *type, bool temporary)
|
||||
{
|
||||
unsigned int hash = (unsigned int)doomednum % DOOMED_HASHSIZE;
|
||||
FDoomEdEntry *entry = DoomEdHash[hash];
|
||||
while (entry && entry->DoomEdNum != doomednum)
|
||||
{
|
||||
entry = entry->HashNext;
|
||||
}
|
||||
if (entry == NULL)
|
||||
{
|
||||
entry = new FDoomEdEntry;
|
||||
entry->HashNext = DoomEdHash[hash];
|
||||
entry->DoomEdNum = doomednum;
|
||||
DoomEdHash[hash] = entry;
|
||||
}
|
||||
else if (!entry->temp)
|
||||
{
|
||||
Printf (PRINT_BOLD, "Warning: %s and %s both have doomednum %d.\n",
|
||||
type->TypeName.GetChars(), entry->Type->TypeName.GetChars(), doomednum);
|
||||
}
|
||||
entry->temp = temporary;
|
||||
entry->Type = type;
|
||||
}
|
||||
|
||||
void FDoomEdMap::DelType (int doomednum)
|
||||
{
|
||||
unsigned int hash = (unsigned int)doomednum % DOOMED_HASHSIZE;
|
||||
FDoomEdEntry **prev = &DoomEdHash[hash];
|
||||
FDoomEdEntry *entry = *prev;
|
||||
while (entry && entry->DoomEdNum != doomednum)
|
||||
{
|
||||
prev = &entry->HashNext;
|
||||
entry = entry->HashNext;
|
||||
}
|
||||
if (entry != NULL)
|
||||
{
|
||||
*prev = entry->HashNext;
|
||||
delete entry;
|
||||
}
|
||||
}
|
||||
|
||||
void FDoomEdMap::Empty ()
|
||||
{
|
||||
int bucket;
|
||||
|
||||
for (bucket = 0; bucket < DOOMED_HASHSIZE; ++bucket)
|
||||
{
|
||||
FDoomEdEntry *probe = DoomEdHash[bucket];
|
||||
|
||||
while (probe != NULL)
|
||||
{
|
||||
FDoomEdEntry *next = probe->HashNext;
|
||||
delete probe;
|
||||
probe = next;
|
||||
}
|
||||
DoomEdHash[bucket] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const PClass *FDoomEdMap::FindType (int doomednum) const
|
||||
{
|
||||
unsigned int hash = (unsigned int)doomednum % DOOMED_HASHSIZE;
|
||||
FDoomEdEntry *entry = DoomEdHash[hash];
|
||||
while (entry && entry->DoomEdNum != doomednum)
|
||||
entry = entry->HashNext;
|
||||
return entry ? entry->Type : NULL;
|
||||
}
|
||||
|
||||
struct EdSorting
|
||||
{
|
||||
const PClass *Type;
|
||||
int DoomEdNum;
|
||||
};
|
||||
|
||||
static int STACK_ARGS sortnums (const void *a, const void *b)
|
||||
{
|
||||
return ((const EdSorting *)a)->DoomEdNum -
|
||||
((const EdSorting *)b)->DoomEdNum;
|
||||
}
|
||||
|
||||
void FDoomEdMap::DumpMapThings ()
|
||||
{
|
||||
TArray<EdSorting> infos (PClass::m_Types.Size());
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DOOMED_HASHSIZE; ++i)
|
||||
{
|
||||
FDoomEdEntry *probe = DoomEdHash[i];
|
||||
|
||||
while (probe != NULL)
|
||||
{
|
||||
EdSorting sorting = { probe->Type, probe->DoomEdNum };
|
||||
infos.Push (sorting);
|
||||
probe = probe->HashNext;
|
||||
}
|
||||
}
|
||||
|
||||
if (infos.Size () == 0)
|
||||
{
|
||||
Printf ("No map things registered\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
qsort (&infos[0], infos.Size (), sizeof(EdSorting), sortnums);
|
||||
|
||||
for (i = 0; i < (int)infos.Size (); ++i)
|
||||
{
|
||||
Printf ("%6d %s\n",
|
||||
infos[i].DoomEdNum, infos[i].Type->TypeName.GetChars());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (dumpmapthings)
|
||||
{
|
||||
FDoomEdMap::DumpMapThings ();
|
||||
}
|
||||
|
||||
|
||||
static void SummonActor (int command, int command2, FCommandLine argv)
|
||||
{
|
||||
if (CheckCheatmode ())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue