Add lookup tag tables construction.

This commit is contained in:
Nev3r 2020-04-12 15:16:04 +02:00
parent 38e92aecfd
commit 07b4d0ee3d
3 changed files with 80 additions and 6 deletions

View File

@ -1578,6 +1578,7 @@ void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean e
static inline void P_InitTagLists(void) static inline void P_InitTagLists(void)
{ {
register size_t i; register size_t i;
size_t j;
for (i = numsectors - 1; i != (size_t)-1; i--) 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[i].nexttag = lines[j].firsttag;
lines[j].firsttag = (INT32)i; 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. /** Finds minimum light from an adjacent sector.
@ -2025,7 +2048,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
INT32 triggercolor = (INT32)sides[triggerline->sidenum[0]].toptexture; INT32 triggercolor = (INT32)sides[triggerline->sidenum[0]].toptexture;
UINT8 color = (actor->player ? actor->player->powers[pw_dye] : actor->color); UINT8 color = (actor->player ? actor->player->powers[pw_dye] : actor->color);
boolean invert = (triggerline->flags & ML_NOCLIMB ? true : false); boolean invert = (triggerline->flags & ML_NOCLIMB ? true : false);
if (invert ^ (triggercolor != color)) if (invert ^ (triggercolor != color))
return false; return false;
} }
@ -4034,23 +4057,23 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
} }
} }
break; break;
case 463: // Dye object case 463: // Dye object
{ {
INT32 color = sides[line->sidenum[0]].toptexture; INT32 color = sides[line->sidenum[0]].toptexture;
if (mo) if (mo)
{ {
if (color < 0 || color >= MAXTRANSLATIONS) if (color < 0 || color >= MAXTRANSLATIONS)
return; return;
var1 = 0; var1 = 0;
var2 = color; var2 = color;
A_Dye(mo); A_Dye(mo);
} }
} }
break; break;
#ifdef POLYOBJECTS #ifdef POLYOBJECTS
case 480: // Polyobj_DoorSlide case 480: // Polyobj_DoorSlide
case 481: // Polyobj_DoorSwing case 481: // Polyobj_DoorSwing
@ -7271,7 +7294,7 @@ void P_SpawnSpecials(boolean fromnetsave)
case 331: case 331:
case 333: case 333:
break; break;
// Object dye executors // Object dye executors
case 334: case 334:
case 336: case 336:

View File

@ -20,3 +20,39 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2)
return true; 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;
}

View File

@ -12,4 +12,19 @@ typedef struct
void Tag_Add (taglist_t* list, const UINT16 tag); void Tag_Add (taglist_t* list, const UINT16 tag);
boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2); 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__ #endif //__R_TAGLIST__