mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-12-12 22:02:01 +00:00
Add lookup tag tables construction.
This commit is contained in:
parent
38e92aecfd
commit
07b4d0ee3d
3 changed files with 80 additions and 6 deletions
23
src/p_spec.c
23
src/p_spec.c
|
@ -1578,6 +1578,7 @@ void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean e
|
|||
static inline void P_InitTagLists(void)
|
||||
{
|
||||
register size_t i;
|
||||
size_t j;
|
||||
|
||||
for (i = numsectors - 1; i != (size_t)-1; i--)
|
||||
{
|
||||
|
@ -1592,6 +1593,28 @@ static inline void P_InitTagLists(void)
|
|||
lines[i].nexttag = lines[j].firsttag;
|
||||
lines[j].firsttag = (INT32)i;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAXTAGS; i++)
|
||||
{
|
||||
tags_sectors[i] = NULL;
|
||||
tags_lines[i] = NULL;
|
||||
tags_mapthings[i] = NULL;
|
||||
}
|
||||
for (i = 0; i < numsectors; i++)
|
||||
{
|
||||
for (j = 0; j < sectors[i].tags.count; j++)
|
||||
Taglist_AddToSectors(sectors[i].tags.tags[j], i);
|
||||
}
|
||||
for (i = 0; i < numlines; i++)
|
||||
{
|
||||
for (j = 0; j < lines[i].tags.count; j++)
|
||||
Taglist_AddToLines(lines[i].tags.tags[j], i);
|
||||
}
|
||||
for (i = 0; i < nummapthings; i++)
|
||||
{
|
||||
for (j = 0; j < mapthings[i].tags.count; j++)
|
||||
Taglist_AddToMapthings(mapthings[i].tags.tags[j], i);
|
||||
}
|
||||
}
|
||||
|
||||
/** Finds minimum light from an adjacent sector.
|
||||
|
|
|
@ -20,3 +20,39 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Taglist_AddToSectors (const size_t tag, const size_t itemid)
|
||||
{
|
||||
taggroup_t* tagelems;
|
||||
if (!tags_sectors[tag])
|
||||
tags_sectors[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL);
|
||||
|
||||
tagelems = tags_sectors[tag];
|
||||
tagelems->count++;
|
||||
tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL);
|
||||
tagelems->elements[tagelems->count - 1] = itemid;
|
||||
}
|
||||
|
||||
void Taglist_AddToLines (const size_t tag, const size_t itemid)
|
||||
{
|
||||
taggroup_t* tagelems;
|
||||
if (!tags_lines[tag])
|
||||
tags_lines[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL);
|
||||
|
||||
tagelems = tags_lines[tag];
|
||||
tagelems->count++;
|
||||
tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL);
|
||||
tagelems->elements[tagelems->count - 1] = itemid;
|
||||
}
|
||||
|
||||
void Taglist_AddToMapthings (const size_t tag, const size_t itemid)
|
||||
{
|
||||
taggroup_t* tagelems;
|
||||
if (!tags_mapthings[tag])
|
||||
tags_mapthings[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL);
|
||||
|
||||
tagelems = tags_mapthings[tag];
|
||||
tagelems->count++;
|
||||
tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL);
|
||||
tagelems->elements[tagelems->count - 1] = itemid;
|
||||
}
|
||||
|
|
|
@ -12,4 +12,19 @@ typedef struct
|
|||
|
||||
void Tag_Add (taglist_t* list, const UINT16 tag);
|
||||
boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t *elements;
|
||||
size_t count;
|
||||
} taggroup_t;
|
||||
|
||||
#define MAXTAGS 65536
|
||||
taggroup_t* tags_sectors[MAXTAGS];
|
||||
taggroup_t* tags_lines[MAXTAGS];
|
||||
taggroup_t* tags_mapthings[MAXTAGS];
|
||||
|
||||
void Taglist_AddToSectors (const size_t tag, const size_t itemid);
|
||||
void Taglist_AddToLines (const size_t tag, const size_t itemid);
|
||||
void Taglist_AddToMapthings (const size_t tag, const size_t itemid);
|
||||
#endif //__R_TAGLIST__
|
||||
|
|
Loading…
Reference in a new issue