mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-12-03 09:42:45 +00:00
Clean up type inconsistency on tags.
This commit is contained in:
parent
1d572c5b2c
commit
c0b4090924
2 changed files with 50 additions and 47 deletions
|
@ -2,7 +2,7 @@
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "r_data.h"
|
#include "r_data.h"
|
||||||
|
|
||||||
void Tag_Add (taglist_t* list, const UINT16 tag)
|
void Tag_Add (taglist_t* list, const mtag_t tag)
|
||||||
{
|
{
|
||||||
list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(list->tags), PU_LEVEL, NULL);
|
list->tags = Z_Realloc(list->tags, (list->count + 1) * sizeof(list->tags), PU_LEVEL, NULL);
|
||||||
list->tags[list->count++] = tag;
|
list->tags[list->count++] = tag;
|
||||||
|
@ -22,121 +22,121 @@ 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)
|
void Taglist_AddToSectors (const mtag_t tag, const size_t itemid)
|
||||||
{
|
{
|
||||||
taggroup_t* tagelems;
|
taggroup_t* tagelems;
|
||||||
|
|
||||||
if (tag == -1)
|
if (tag == MTAG_GLOBAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!tags_sectors[tag])
|
if (!tags_sectors[(UINT16)tag])
|
||||||
tags_sectors[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL);
|
tags_sectors[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL);
|
||||||
|
|
||||||
tagelems = tags_sectors[tag];
|
tagelems = tags_sectors[(UINT16)tag];
|
||||||
tagelems->count++;
|
tagelems->count++;
|
||||||
tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL);
|
tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL);
|
||||||
tagelems->elements[tagelems->count - 1] = itemid;
|
tagelems->elements[tagelems->count - 1] = itemid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Taglist_AddToLines (const size_t tag, const size_t itemid)
|
void Taglist_AddToLines (const mtag_t tag, const size_t itemid)
|
||||||
{
|
{
|
||||||
taggroup_t* tagelems;
|
taggroup_t* tagelems;
|
||||||
|
|
||||||
if (tag == -1)
|
if (tag == MTAG_GLOBAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!tags_lines[tag])
|
if (!tags_lines[(UINT16)tag])
|
||||||
tags_lines[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL);
|
tags_lines[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL);
|
||||||
|
|
||||||
tagelems = tags_lines[tag];
|
tagelems = tags_lines[(UINT16)tag];
|
||||||
tagelems->count++;
|
tagelems->count++;
|
||||||
tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL);
|
tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL);
|
||||||
tagelems->elements[tagelems->count - 1] = itemid;
|
tagelems->elements[tagelems->count - 1] = itemid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Taglist_AddToMapthings (const size_t tag, const size_t itemid)
|
void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid)
|
||||||
{
|
{
|
||||||
taggroup_t* tagelems;
|
taggroup_t* tagelems;
|
||||||
|
|
||||||
if (tag == -1)
|
if (tag == MTAG_GLOBAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!tags_mapthings[tag])
|
if (!tags_mapthings[(UINT16)tag])
|
||||||
tags_mapthings[tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL);
|
tags_mapthings[(UINT16)tag] = Z_Calloc(sizeof(taggroup_t), PU_LEVEL, NULL);
|
||||||
|
|
||||||
tagelems = tags_mapthings[tag];
|
tagelems = tags_mapthings[(UINT16)tag];
|
||||||
tagelems->count++;
|
tagelems->count++;
|
||||||
tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL);
|
tagelems->elements = Z_Realloc(tagelems->elements, tagelems->count * sizeof(size_t), PU_LEVEL, NULL);
|
||||||
tagelems->elements[tagelems->count - 1] = itemid;
|
tagelems->elements[tagelems->count - 1] = itemid;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT32 Tag_Iterate_Sectors (const INT16 tag, const size_t p)
|
INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p)
|
||||||
{
|
{
|
||||||
if (tag == -1)
|
if (tag == MTAG_GLOBAL)
|
||||||
{
|
{
|
||||||
if (p < numsectors)
|
if (p < numsectors)
|
||||||
return p;
|
return p;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags_sectors[tag])
|
if (tags_sectors[(UINT16)tag])
|
||||||
{
|
{
|
||||||
if (p < tags_sectors[tag]->count)
|
if (p < tags_sectors[(UINT16)tag]->count)
|
||||||
return tags_sectors[tag]->elements[p];
|
return tags_sectors[(UINT16)tag]->elements[p];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT32 Tag_Iterate_Lines (const INT16 tag, const size_t p)
|
INT32 Tag_Iterate_Lines (const mtag_t tag, const size_t p)
|
||||||
{
|
{
|
||||||
if (tag == -1)
|
if (tag == MTAG_GLOBAL)
|
||||||
{
|
{
|
||||||
if (p < numlines)
|
if (p < numlines)
|
||||||
return p;
|
return p;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags_lines[tag])
|
if (tags_lines[(UINT16)tag])
|
||||||
{
|
{
|
||||||
if (p < tags_lines[tag]->count)
|
if (p < tags_lines[(UINT16)tag]->count)
|
||||||
return tags_lines[tag]->elements[p];
|
return tags_lines[(UINT16)tag]->elements[p];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT32 Tag_Iterate_Things (const INT16 tag, const size_t p)
|
INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p)
|
||||||
{
|
{
|
||||||
if (tag == -1)
|
if (tag == MTAG_GLOBAL)
|
||||||
{
|
{
|
||||||
if (p < nummapthings)
|
if (p < nummapthings)
|
||||||
return p;
|
return p;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags_mapthings[tag])
|
if (tags_mapthings[(UINT16)tag])
|
||||||
{
|
{
|
||||||
if (p < tags_mapthings[tag]->count)
|
if (p < tags_mapthings[(UINT16)tag]->count)
|
||||||
return tags_mapthings[tag]->elements[p];
|
return tags_mapthings[(UINT16)tag]->elements[p];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag)
|
INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
if (tag == -1)
|
if (tag == MTAG_GLOBAL)
|
||||||
{
|
{
|
||||||
for (i = 0; i < numlines; i++)
|
for (i = 0; i < numlines; i++)
|
||||||
if (lines[i].special == special)
|
if (lines[i].special == special)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
else if (tags_lines[tag])
|
else if (tags_lines[(UINT16)tag])
|
||||||
{
|
{
|
||||||
taggroup_t *tagged = tags_lines[tag];
|
taggroup_t *tagged = tags_lines[(UINT16)tag];
|
||||||
for (i = 0; i < tagged->count; i++)
|
for (i = 0; i < tagged->count; i++)
|
||||||
if (lines[tagged->elements[i]].special == special)
|
if (lines[tagged->elements[i]].special == special)
|
||||||
return tagged->elements[i];
|
return tagged->elements[i];
|
||||||
|
|
|
@ -3,14 +3,18 @@
|
||||||
|
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
|
|
||||||
|
typedef INT16 mtag_t;
|
||||||
|
#define MAXTAGS UINT16_MAX
|
||||||
|
#define MTAG_GLOBAL -1
|
||||||
|
|
||||||
/// Multitag list.
|
/// Multitag list.
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UINT16* tags;
|
mtag_t* tags;
|
||||||
UINT16 count;
|
UINT16 count;
|
||||||
} taglist_t;
|
} taglist_t;
|
||||||
|
|
||||||
void Tag_Add (taglist_t* list, const UINT16 tag);
|
void Tag_Add (taglist_t* list, const mtag_t 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
|
typedef struct
|
||||||
|
@ -19,18 +23,17 @@ typedef struct
|
||||||
size_t count;
|
size_t count;
|
||||||
} taggroup_t;
|
} taggroup_t;
|
||||||
|
|
||||||
#define MAXTAGS 65536
|
taggroup_t* tags_sectors[MAXTAGS + 1];
|
||||||
taggroup_t* tags_sectors[MAXTAGS];
|
taggroup_t* tags_lines[MAXTAGS + 1];
|
||||||
taggroup_t* tags_lines[MAXTAGS];
|
taggroup_t* tags_mapthings[MAXTAGS + 1];
|
||||||
taggroup_t* tags_mapthings[MAXTAGS];
|
|
||||||
|
|
||||||
void Taglist_AddToSectors (const size_t tag, const size_t itemid);
|
void Taglist_AddToSectors (const mtag_t tag, const size_t itemid);
|
||||||
void Taglist_AddToLines (const size_t tag, const size_t itemid);
|
void Taglist_AddToLines (const mtag_t tag, const size_t itemid);
|
||||||
void Taglist_AddToMapthings (const size_t tag, const size_t itemid);
|
void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid);
|
||||||
|
|
||||||
INT32 Tag_Iterate_Sectors (const INT16 tag, const size_t p);
|
INT32 Tag_Iterate_Sectors (const mtag_t tag, const size_t p);
|
||||||
INT32 Tag_Iterate_Lines (const INT16 tag, const size_t p);
|
INT32 Tag_Iterate_Lines (const mtag_t tag, const size_t p);
|
||||||
INT32 Tag_Iterate_Things (const INT16 tag, const size_t p);
|
INT32 Tag_Iterate_Things (const mtag_t tag, const size_t p);
|
||||||
|
|
||||||
INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag);
|
INT32 Tag_FindLineSpecial(const INT16 special, const INT16 tag);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue