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
3a8b2a6f
Commit
3a8b2a6f
authored
4 years ago
by
Nev3r
Browse files
Options
Downloads
Patches
Plain Diff
Better documentation.
parent
cc98be4d
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
+16
-1
16 additions, 1 deletion
src/taglist.c
src/taglist.h
+2
-3
2 additions, 3 deletions
src/taglist.h
with
18 additions
and
4 deletions
src/taglist.c
+
16
−
1
View file @
3a8b2a6f
...
...
@@ -15,10 +15,15 @@
#include
"z_zone.h"
#include
"r_data.h"
// Taggroups are used to list elements of the same tag, for iteration.
// Since elements can now have multiple tags, it means an element may appear
// in several taggroups at the same time. These are built on level load.
taggroup_t
*
tags_sectors
[
MAXTAGS
+
1
];
taggroup_t
*
tags_lines
[
MAXTAGS
+
1
];
taggroup_t
*
tags_mapthings
[
MAXTAGS
+
1
];
/// Adds a tag to a given element's taglist.
/// \warning This does not rebuild the global taggroups, which are used for iteration.
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
);
...
...
@@ -26,6 +31,7 @@ void Tag_Add (taglist_t* list, const mtag_t tag)
}
/// Sets the first tag entry in a taglist.
/// Replicates the old way of accessing element->tag.
void
Tag_FSet
(
taglist_t
*
list
,
const
mtag_t
tag
)
{
if
(
!
list
->
count
)
...
...
@@ -38,6 +44,7 @@ void Tag_FSet (taglist_t* list, const mtag_t tag)
}
/// Gets the first tag entry in a taglist.
/// Replicates the old way of accessing element->tag.
mtag_t
Tag_FGet
(
const
taglist_t
*
list
)
{
if
(
list
->
count
)
...
...
@@ -46,6 +53,7 @@ mtag_t Tag_FGet (const taglist_t* list)
return
0
;
}
/// Returns true if the given tag exist inside the list.
boolean
Tag_Find
(
const
taglist_t
*
list
,
const
mtag_t
tag
)
{
size_t
i
;
...
...
@@ -56,6 +64,7 @@ boolean Tag_Find (const taglist_t* list, const mtag_t tag)
return
false
;
}
/// Returns true if at least one tag is shared between two given lists.
boolean
Tag_Share
(
const
taglist_t
*
list1
,
const
taglist_t
*
list2
)
{
size_t
i
;
...
...
@@ -66,6 +75,7 @@ boolean Tag_Share (const taglist_t* list1, const taglist_t* list2)
return
false
;
}
/// Returns true if both lists are identical.
boolean
Tag_Compare
(
const
taglist_t
*
list1
,
const
taglist_t
*
list2
)
{
size_t
i
;
...
...
@@ -80,7 +90,7 @@ boolean Tag_Compare (const taglist_t* list1, const taglist_t* list2)
return
true
;
}
/// Search for an element inside a global taggroup.
size_t
Taggroup_Find
(
const
taggroup_t
*
group
,
const
size_t
id
)
{
size_t
i
;
...
...
@@ -95,6 +105,7 @@ size_t Taggroup_Find (const taggroup_t *group, const size_t id)
return
-
1
;
}
/// Add an element to a global taggroup.
void
Taggroup_Add
(
taggroup_t
*
garray
[],
const
mtag_t
tag
,
size_t
id
)
{
taggroup_t
*
group
;
...
...
@@ -135,6 +146,7 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id)
group
->
elements
[
i
]
=
id
;
}
/// Remove an element from a global taggroup.
void
Taggroup_Remove
(
taggroup_t
*
garray
[],
const
mtag_t
tag
,
size_t
id
)
{
taggroup_t
*
group
;
...
...
@@ -191,6 +203,8 @@ static void Taglist_AddToMapthings (const mtag_t tag, const size_t itemid)
Taggroup_Add
(
tags_mapthings
,
tag
,
itemid
);
}
/// After all taglists have been built for each element (sectors, lines, things),
/// the global taggroups, made for iteration, are built here.
void
Taglist_InitGlobalTables
(
void
)
{
size_t
i
,
j
;
...
...
@@ -338,6 +352,7 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start)
// Ingame list manipulation.
/// Changes the first tag for a given sector, and updates the global taggroups.
void
Tag_SectorFSet
(
const
size_t
id
,
const
mtag_t
tag
)
{
sector_t
*
sec
=
&
sectors
[
id
];
...
...
This diff is collapsed.
Click to expand it.
src/taglist.h
+
2
−
3
View file @
3a8b2a6f
...
...
@@ -20,7 +20,7 @@ typedef INT16 mtag_t;
#define MAXTAGS UINT16_MAX
#define MTAG_GLOBAL -1
/// Multitag list.
/// Multitag list.
Each taggable element will have its own taglist.
typedef
struct
{
mtag_t
*
tags
;
...
...
@@ -28,16 +28,15 @@ typedef struct
}
taglist_t
;
void
Tag_Add
(
taglist_t
*
list
,
const
mtag_t
tag
);
void
Tag_FSet
(
taglist_t
*
list
,
const
mtag_t
tag
);
mtag_t
Tag_FGet
(
const
taglist_t
*
list
);
boolean
Tag_Find
(
const
taglist_t
*
list
,
const
mtag_t
tag
);
boolean
Tag_Share
(
const
taglist_t
*
list1
,
const
taglist_t
*
list2
);
boolean
Tag_Compare
(
const
taglist_t
*
list1
,
const
taglist_t
*
list2
);
void
Tag_SectorFSet
(
const
size_t
id
,
const
mtag_t
tag
);
/// Taggroup list. It is essentially just an element id list.
typedef
struct
{
size_t
*
elements
;
...
...
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