Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
5df60f8e
Commit
5df60f8e
authored
4 years ago
by
Nev3r
Browse files
Options
Downloads
Patches
Plain Diff
Make use of functions for the tag lists iterations instead of bloated macros.
parent
8495b598
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1097
UDMF: Multitag support
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/taglist.c
+55
-0
55 additions, 0 deletions
src/taglist.c
src/taglist.h
+11
-11
11 additions, 11 deletions
src/taglist.h
with
66 additions
and
11 deletions
src/taglist.c
+
55
−
0
View file @
5df60f8e
#include
"taglist.h"
#include
"taglist.h"
#include
"z_zone.h"
#include
"z_zone.h"
#include
"r_data.h"
void
Tag_Add
(
taglist_t
*
list
,
const
UINT16
tag
)
void
Tag_Add
(
taglist_t
*
list
,
const
UINT16
tag
)
{
{
...
@@ -56,3 +57,57 @@ void Taglist_AddToMapthings (const size_t tag, const size_t itemid)
...
@@ -56,3 +57,57 @@ void Taglist_AddToMapthings (const size_t tag, const size_t itemid)
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
)
{
if
(
tag
==
-
1
)
{
if
(
p
<
numsectors
)
return
p
;
return
-
1
;
}
if
(
tags_sectors
[
tag
])
{
if
(
p
<
tags_sectors
[
tag
]
->
count
)
return
tags_sectors
[
tag
]
->
elements
[
p
];
return
-
1
;
}
return
-
1
;
}
INT32
Tag_Iterate_Lines
(
const
INT16
tag
,
const
size_t
p
)
{
if
(
tag
==
-
1
)
{
if
(
p
<
numlines
)
return
p
;
return
-
1
;
}
if
(
tags_lines
[
tag
])
{
if
(
p
<
tags_lines
[
tag
]
->
count
)
return
tags_lines
[
tag
]
->
elements
[
p
];
return
-
1
;
}
return
-
1
;
}
INT32
Tag_Iterate_Things
(
const
INT16
tag
,
const
size_t
p
)
{
if
(
tag
==
-
1
)
{
if
(
p
<
nummapthings
)
return
p
;
return
-
1
;
}
if
(
tags_mapthings
[
tag
])
{
if
(
p
<
tags_mapthings
[
tag
]
->
count
)
return
tags_mapthings
[
tag
]
->
elements
[
p
];
return
-
1
;
}
return
-
1
;
}
This diff is collapsed.
Click to expand it.
src/taglist.h
+
11
−
11
View file @
5df60f8e
#include
"doomtype.h"
#ifndef __R_TAGLIST__
#ifndef __R_TAGLIST__
#define __R_TAGLIST__
#define __R_TAGLIST__
#include
"doomtype.h"
/// Multitag list.
/// Multitag list.
typedef
struct
typedef
struct
{
{
...
@@ -27,16 +27,16 @@ taggroup_t* tags_mapthings[MAXTAGS];
...
@@ -27,16 +27,16 @@ taggroup_t* tags_mapthings[MAXTAGS];
void
Taglist_AddToSectors
(
const
size_t
tag
,
const
size_t
itemid
);
void
Taglist_AddToSectors
(
const
size_t
tag
,
const
size_t
itemid
);
void
Taglist_AddToLines
(
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
);
void
Taglist_AddToMapthings
(
const
size_t
tag
,
const
size_t
itemid
);
#endif //__R_TAGLIST__
INT32
Tag_Iterate_Sectors
(
const
INT16
tag
,
const
size_t
p
);
INT32
Tag_Iterate_Lines
(
const
INT16
tag
,
const
size_t
p
);
INT32
Tag_Iterate_Things
(
const
INT16
tag
,
const
size_t
p
);
#define TAG_ITER_C size_t kkkk;
#define TAG_ITER_C size_t kkkk;
#define TAG_ITER(fn, tag, id) for(kkkk = 0; (id = fn(tag, kkkk)) >= 0; kkkk++)
#define TAG_ITER(group, grouptotal, tag, id)\
#define TAG_ITER_SECTORS(tag, id) TAG_ITER(Tag_Iterate_Sectors, tag, id)
if (group[tag] || tag == -1) for(\
#define TAG_ITER_LINES(tag, id) TAG_ITER(Tag_Iterate_Lines, tag, id)
tag != -1 ? (id = group[tag]->elements[kkkk = 0]) : (id = 0);\
#define TAG_ITER_THINGS(tag, id) TAG_ITER(Tag_Iterate_Things, tag, id)
tag != -1 ? (kkkk < group[tag]->count) : (id < grouptotal);\
tag != -1 ? (id = group[tag]->elements[++kkkk]) : (id++))
#define TAG_ITER_SECTORS(tag, id) TAG_ITER(tags_sectors, numsectors, tag, id)
#endif //__R_TAGLIST__
#define TAG_ITER_LINES(tag, id) TAG_ITER(tags_lines, numlines, tag, id)
#define TAG_ITER_THINGS(tag, id) TAG_ITER(tags_mapthings, nummapthings, tag, id)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment