Skip to content

Commit f6adee3

Browse files
committed
Fix property results for States.
1 parent 6a401de commit f6adee3

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

src/main/java/net/mtrop/doom/tools/decohack/DecoHackParser.java

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4231,17 +4231,21 @@ else if ((pointerIndex == null && parsedAction.pointer != null) || (pointerIndex
42314231
}
42324232
else while (currentType(DecoHackKernel.TYPE_IDENTIFIER))
42334233
{
4234-
if (context.supports(DEHFeatureLevel.DOOM19) && !parseStateBodyDoom19Properties(context, state, notModified, index))
4234+
PropertyResult pr;
4235+
if (context.supports(DEHFeatureLevel.DOOM19) && (pr = parseStateBodyDoom19Properties(context, state, notModified, index)) != PropertyResult.BYPASSED)
42354236
{
4236-
return false;
4237+
if (pr == PropertyResult.ERROR)
4238+
return false;
42374239
}
4238-
else if (context.supports(DEHFeatureLevel.MBF21) && !parseStateBodyMBF21Properties(context, state, notModified))
4240+
else if (context.supports(DEHFeatureLevel.MBF21) && (pr = parseStateBodyMBF21Properties(context, state, notModified)) != PropertyResult.BYPASSED)
42394241
{
4240-
return false;
4242+
if (pr == PropertyResult.ERROR)
4243+
return false;
42414244
}
4242-
else if (context.supports(DEHFeatureLevel.ID24) && !parseStateBodyID24Properties(context, state, notModified))
4245+
else if (context.supports(DEHFeatureLevel.ID24) && (pr = parseStateBodyID24Properties(context, state, notModified)) != PropertyResult.BYPASSED)
42434246
{
4244-
return false;
4247+
if (pr == PropertyResult.ERROR)
4248+
return false;
42454249
}
42464250
else if (currentIsCustomProperty(context, DEHState.class))
42474251
{
@@ -4273,68 +4277,72 @@ else if (currentIsCustomProperty(context, DEHState.class))
42734277
return true;
42744278
}
42754279

4276-
private boolean parseStateBodyDoom19Properties(AbstractPatchContext<?> context, DEHState state, AtomicBoolean notModified, int index)
4280+
private PropertyResult parseStateBodyDoom19Properties(AbstractPatchContext<?> context, DEHState state, AtomicBoolean notModified, int index)
42774281
{
42784282
if (matchIdentifierIgnoreCase(Keyword.SPRITENAME))
42794283
{
42804284
Integer value;
42814285
if ((value = matchSpriteIndexName(context)) == null)
42824286
{
42834287
addErrorMessage("Expected valid sprite name after \"%s\".", Keyword.SPRITENAME);
4284-
return false;
4288+
return PropertyResult.ERROR;
42854289
}
42864290

42874291
state.setSpriteIndex(value);
42884292
notModified.set(false);
4293+
return PropertyResult.ACCEPTED;
42894294
}
42904295
else if (matchIdentifierIgnoreCase(Keyword.FRAME))
42914296
{
42924297
Deque<Integer> value;
42934298
if ((value = matchFrameIndices()) == null)
42944299
{
42954300
addErrorMessage("Expected valid frame characters after \"%s\".", Keyword.FRAME);
4296-
return false;
4301+
return PropertyResult.ERROR;
42974302
}
42984303

42994304
if (value.size() > 1)
43004305
{
43014306
addErrorMessage("Expected a single frame character after \"%s\".", Keyword.FRAME);
4302-
return false;
4307+
return PropertyResult.ERROR;
43034308
}
43044309

43054310
state.setFrameIndex(value.pollFirst());
43064311
notModified.set(false);
4312+
return PropertyResult.ACCEPTED;
43074313
}
43084314
else if (matchIdentifierIgnoreCase(Keyword.DURATION))
43094315
{
43104316
Integer value;
43114317
if ((value = matchInteger()) == null)
43124318
{
43134319
addErrorMessage("Expected integer after \"%s\".", Keyword.DURATION);
4314-
return false;
4320+
return PropertyResult.ERROR;
43154321
}
43164322

43174323
state.setDuration(value);
43184324
notModified.set(false);
4325+
return PropertyResult.ACCEPTED;
43194326
}
43204327
else if (matchIdentifierIgnoreCase(Keyword.NEXTSTATE))
43214328
{
43224329
StateIndex value;
43234330
if ((value = parseStateIndex(context)) == null)
43244331
{
43254332
addErrorMessage("Expected valid state index clause after \"%s\".", Keyword.NEXTSTATE);
4326-
return false;
4333+
return PropertyResult.ERROR;
43274334
}
43284335

43294336
Integer next;
43304337
if ((next = value.resolve(context)) == null)
43314338
{
43324339
addErrorMessage("Expected valid state index clause after \"%s\": label \"%s\" could not be resolved.", Keyword.NEXTSTATE, value.label);
4333-
return false;
4340+
return PropertyResult.ERROR;
43344341
}
43354342

43364343
state.setNextStateIndex(next);
43374344
notModified.set(false);
4345+
return PropertyResult.ACCEPTED;
43384346
}
43394347
else if (matchIdentifierIgnoreCase(Keyword.POINTER))
43404348
{
@@ -4348,7 +4356,7 @@ else if (matchIdentifierIgnoreCase(Keyword.POINTER))
43484356
if (requireAction != null && requireAction)
43494357
{
43504358
addErrorMessage("Expected an action pointer for this state.");
4351-
return false;
4359+
return PropertyResult.ERROR;
43524360
}
43534361
else
43544362
{
@@ -4357,7 +4365,7 @@ else if (matchIdentifierIgnoreCase(Keyword.POINTER))
43574365
}
43584366
else if (!parseActionClause(context, null, action, requireAction))
43594367
{
4360-
return false;
4368+
return PropertyResult.ERROR;
43614369
}
43624370

43634371
if (isBoom && pointerIndex != null && action.pointer == null)
@@ -4373,63 +4381,70 @@ else if (!parseActionClause(context, null, action, requireAction))
43734381
;
43744382

43754383
notModified.set(false);
4384+
return PropertyResult.ACCEPTED;
43764385
}
43774386
else if (currentIdentifierIgnoreCase(Keyword.OFFSET))
43784387
{
43794388
ParsedAction action = new ParsedAction();
43804389
if (!parseOffsetClause(action))
4381-
return false;
4390+
return PropertyResult.ERROR;
43824391

43834392
state
43844393
.setMisc1(action.misc1)
43854394
.setMisc2(action.misc2)
43864395
;
43874396

43884397
notModified.set(false);
4398+
return PropertyResult.ACCEPTED;
43894399
}
43904400
else if (matchIdentifierIgnoreCase(Keyword.STATE_BRIGHT))
43914401
{
43924402
state.setBright(true);
43934403
notModified.set(false);
4404+
return PropertyResult.ACCEPTED;
43944405
}
43954406
else if (matchIdentifierIgnoreCase(Keyword.STATE_NOTBRIGHT))
43964407
{
43974408
state.setBright(false);
43984409
notModified.set(false);
4410+
return PropertyResult.ACCEPTED;
43994411
}
44004412

4401-
return true;
4413+
return PropertyResult.BYPASSED;
44024414
}
44034415

4404-
private boolean parseStateBodyMBF21Properties(AbstractPatchContext<?> context, DEHState state, AtomicBoolean notModified)
4416+
private PropertyResult parseStateBodyMBF21Properties(AbstractPatchContext<?> context, DEHState state, AtomicBoolean notModified)
44054417
{
44064418
if (matchIdentifierIgnoreCase(Keyword.STATE_FAST))
44074419
{
44084420
state.setMBF21Flags(state.getMBF21Flags() | DEHStateMBF21Flag.SKILL5FAST.getValue());
44094421
notModified.set(false);
4422+
return PropertyResult.ACCEPTED;
44104423
}
44114424
else if (matchIdentifierIgnoreCase(Keyword.STATE_NOTFAST))
44124425
{
44134426
state.setMBF21Flags(state.getMBF21Flags() & ~DEHStateMBF21Flag.SKILL5FAST.getValue());
44144427
notModified.set(false);
4428+
return PropertyResult.ACCEPTED;
44154429
}
44164430

4417-
return true;
4431+
return PropertyResult.BYPASSED;
44184432
}
44194433

4420-
private boolean parseStateBodyID24Properties(AbstractPatchContext<?> context, DEHState state, AtomicBoolean notModified)
4434+
private PropertyResult parseStateBodyID24Properties(AbstractPatchContext<?> context, DEHState state, AtomicBoolean notModified)
44214435
{
44224436
if (currentIdentifierIgnoreCase(Keyword.TRANMAP))
44234437
{
44244438
ParsedAction action = new ParsedAction();
44254439
if (!parseTranmapClause(context, action))
4426-
return false;
4440+
return PropertyResult.ERROR;
44274441

44284442
state.setTranmap(action.tranmap);
44294443
notModified.set(false);
4444+
return PropertyResult.ACCEPTED;
44304445
}
44314446

4432-
return true;
4447+
return PropertyResult.BYPASSED;
44334448
}
44344449

44354450
// Parse a single state and if true is returned, the input state is altered.

src/main/resources/docs/changelogs/CHANGELOG-decohack.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ DECOHack
44
### Changed for 0.40.1
55

66
* `Fixed` Copying an object didn't copy over its custom property values.
7+
* `Changed` Some better internal handling of properties for states.
78

89

910
### Changed for 0.40.0

0 commit comments

Comments
 (0)