Skip to content

Commit 1d77336

Browse files
Simplify character position checks in applyCharPos
Refactor character position handling in applyCharPos function. It turns out it couldn't prepare the character if a `<boyfriend>`, `<gf>` or `<dad>` isn't defined in the XML.
1 parent 369f2b2 commit 1d77336

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

source/funkin/game/stage/Stage.hx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,15 +451,15 @@ class Stage extends Layer {
451451
public function applyCharPos(char:Character, posName:String, id:Float = 0) {
452452
var charName:String = char.curCharacter;
453453
var charPos:Null<StageCharPos> = characterPosLookup.exists(charName) ? characterPosLookup.get(charName) : characterPosLookup.get(posName);
454-
if(charPos != null && charPos.position != -1) {
454+
if(charPos != null)
455455
charPos.prepareCharacter(char, id);
456-
// allows setting characters in different layers
457-
// their position (index) is relative to their layer
458-
var layerRef:Layer = charPos.layer;
456+
// allows setting characters in different layers
457+
// their position (index) is relative to their layer
458+
var layerRef:Layer = charPos.layer;
459+
if(charPos.position != -1)
459460
layerRef.insert(charPos.position, char);
460-
}
461461
else
462-
this.add(char);
462+
layerRef.add(char);
463463
}
464464

465465
override function update(elapsed:Float) {

0 commit comments

Comments
 (0)