Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
UltimateZoneBuilder
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
Alam Ed Arias
UltimateZoneBuilder
Commits
464f4c4e
Commit
464f4c4e
authored
1 year ago
by
biwa
Browse files
Options
Downloads
Patches
Plain Diff
ZScript parser: fixed an issue where mixins were not added to extend classes. Fixes #880
parent
eb62da5b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Source/Core/ZDoom/ZScriptParser.cs
+46
-42
46 additions, 42 deletions
Source/Core/ZDoom/ZScriptParser.cs
with
46 additions
and
42 deletions
Source/Core/ZDoom/ZScriptParser.cs
+
46
−
42
View file @
464f4c4e
...
@@ -1241,45 +1241,8 @@ namespace CodeImp.DoomBuilder.ZDoom
...
@@ -1241,45 +1241,8 @@ namespace CodeImp.DoomBuilder.ZDoom
}
}
// Mixins. https://zdoom.org/wiki/ZScript_mixins
// Mixins. https://zdoom.org/wiki/ZScript_mixins
if
(((
ZScriptActorStructure
)
actor
).
Mixins
.
Count
>
0
)
foreach
(
string
mixinclassname
in
((
ZScriptActorStructure
)
actor
).
Mixins
)
{
ApplyMixin
(
actor
,
mixinclassname
);
foreach
(
string
mixinclassname
in
((
ZScriptActorStructure
)
actor
).
Mixins
)
{
if
(!
mixinclasses
.
ContainsKey
(
mixinclassname
))
{
LogWarning
(
"Unable to find \""
+
mixinclassname
+
"\" mixin class while parsing \""
+
actor
.
ClassName
+
"\""
);
continue
;
}
ZScriptClassStructure
mixincls
=
mixinclasses
[
mixinclassname
];
// States
if
(
actor
.
states
.
Count
==
0
&&
mixincls
.
Actor
.
states
.
Count
!=
0
)
{
// Can't use HasState and GetState here, because it does some magic that will not work for mixins
if
(!
actor
.
states
.
ContainsKey
(
"spawn"
)
&&
mixincls
.
Actor
.
states
.
ContainsKey
(
"spawn"
))
actor
.
states
.
Add
(
"spawn"
,
mixincls
.
Actor
.
GetState
(
"spawn"
));
}
// Properties
if
(!
actor
.
props
.
ContainsKey
(
"height"
)
&&
mixincls
.
Actor
.
props
.
ContainsKey
(
"height"
))
actor
.
props
[
"height"
]
=
new
List
<
string
>(
mixincls
.
Actor
.
props
[
"height"
]);
if
(!
actor
.
props
.
ContainsKey
(
"radius"
)
&&
mixincls
.
Actor
.
props
.
ContainsKey
(
"radius"
))
actor
.
props
[
"radius"
]
=
new
List
<
string
>(
mixincls
.
Actor
.
props
[
"radius"
]);
// Flags
if
(!
actor
.
flags
.
ContainsKey
(
"spawnceiling"
)
&&
mixincls
.
Actor
.
flags
.
ContainsKey
(
"spawnceiling"
))
actor
.
flags
[
"spawnceiling"
]
=
true
;
if
(!
actor
.
flags
.
ContainsKey
(
"solid"
)
&&
mixincls
.
Actor
.
flags
.
ContainsKey
(
"solid"
))
actor
.
flags
[
"solid"
]
=
true
;
// user_ variables
foreach
(
string
uservarname
in
mixincls
.
Actor
.
uservars
.
Keys
)
actor
.
uservars
[
uservarname
]
=
mixincls
.
Actor
.
uservars
[
uservarname
];
}
}
// Extensions. https://zdoom.org/wiki/ZScript_classes#Extending_Classes
// Extensions. https://zdoom.org/wiki/ZScript_classes#Extending_Classes
if
(
cls
.
Extensions
.
Count
>
0
)
if
(
cls
.
Extensions
.
Count
>
0
)
...
@@ -1291,9 +1254,13 @@ namespace CodeImp.DoomBuilder.ZDoom
...
@@ -1291,9 +1254,13 @@ namespace CodeImp.DoomBuilder.ZDoom
if
(
extenseionactor
==
null
)
if
(
extenseionactor
==
null
)
continue
;
continue
;
// States
// Apply mixins to the extension class
if
(
extenseionactor
.
states
.
ContainsKey
(
"spawn"
))
foreach
(
string
mixinclassname
in
((
ZScriptActorStructure
)
extenseionactor
).
Mixins
)
actor
.
states
[
"spawn"
]
=
extenseionactor
.
GetState
(
"spawn"
);
ApplyMixin
(
extenseionactor
,
mixinclassname
);
// States
if
(
extenseionactor
.
states
.
ContainsKey
(
"spawn"
))
actor
.
states
[
"spawn"
]
=
extenseionactor
.
GetState
(
"spawn"
);
// Properties
// Properties
if
(
extenseionactor
.
props
.
ContainsKey
(
"height"
))
if
(
extenseionactor
.
props
.
ContainsKey
(
"height"
))
...
@@ -1349,6 +1316,43 @@ namespace CodeImp.DoomBuilder.ZDoom
...
@@ -1349,6 +1316,43 @@ namespace CodeImp.DoomBuilder.ZDoom
return
true
;
return
true
;
}
}
private
void
ApplyMixin
(
ActorStructure
actor
,
string
mixinclassname
)
{
if
(!
mixinclasses
.
ContainsKey
(
mixinclassname
))
{
LogWarning
(
"Unable to find \""
+
mixinclassname
+
"\" mixin class while parsing \""
+
actor
.
ClassName
+
"\""
);
return
;
}
ZScriptClassStructure
mixincls
=
mixinclasses
[
mixinclassname
];
// States
if
(
actor
.
states
.
Count
==
0
&&
mixincls
.
Actor
.
states
.
Count
!=
0
)
{
// Can't use HasState and GetState here, because it does some magic that will not work for mixins
if
(!
actor
.
states
.
ContainsKey
(
"spawn"
)
&&
mixincls
.
Actor
.
states
.
ContainsKey
(
"spawn"
))
actor
.
states
.
Add
(
"spawn"
,
mixincls
.
Actor
.
GetState
(
"spawn"
));
}
// Properties
if
(!
actor
.
props
.
ContainsKey
(
"height"
)
&&
mixincls
.
Actor
.
props
.
ContainsKey
(
"height"
))
actor
.
props
[
"height"
]
=
new
List
<
string
>(
mixincls
.
Actor
.
props
[
"height"
]);
if
(!
actor
.
props
.
ContainsKey
(
"radius"
)
&&
mixincls
.
Actor
.
props
.
ContainsKey
(
"radius"
))
actor
.
props
[
"radius"
]
=
new
List
<
string
>(
mixincls
.
Actor
.
props
[
"radius"
]);
// Flags
if
(!
actor
.
flags
.
ContainsKey
(
"spawnceiling"
)
&&
mixincls
.
Actor
.
flags
.
ContainsKey
(
"spawnceiling"
))
actor
.
flags
[
"spawnceiling"
]
=
true
;
if
(!
actor
.
flags
.
ContainsKey
(
"solid"
)
&&
mixincls
.
Actor
.
flags
.
ContainsKey
(
"solid"
))
actor
.
flags
[
"solid"
]
=
true
;
// user_ variables
foreach
(
string
uservarname
in
mixincls
.
Actor
.
uservars
.
Keys
)
actor
.
uservars
[
uservarname
]
=
mixincls
.
Actor
.
uservars
[
uservarname
];
}
#
endregion
#
endregion
#
region
==================
Methods
#
region
==================
Methods
...
...
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