Skip to content

Commit 99a1f16

Browse files
committed
Fix typo serialization key in AbstractCinematicEvent (#2449)
The serialization key, for the class's field `initialDuration`, should has been `initialDuration` but `initalDuration` was written.
1 parent 36fc367 commit 99a1f16

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

jme3-core/src/main/java/com/jme3/cinematic/events/AbstractCinematicEvent.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public void write(JmeExporter ex) throws IOException {
292292
OutputCapsule oc = ex.getCapsule(this);
293293
oc.write(playState, "playState", PlayState.Stopped);
294294
oc.write(speed, "speed", 1);
295-
oc.write(initialDuration, "initalDuration", 10);
295+
oc.write(initialDuration, "initialDuration", 10);
296296
oc.write(loopMode, "loopMode", LoopMode.DontLoop);
297297
}
298298

@@ -306,7 +306,15 @@ public void read(JmeImporter im) throws IOException {
306306
InputCapsule ic = im.getCapsule(this);
307307
playState = ic.readEnum("playState", PlayState.class, PlayState.Stopped);
308308
speed = ic.readFloat("speed", 1);
309-
initialDuration = ic.readFloat("initalDuration", 10);
309+
// Originally, "initialDuration" was serialized with the name "initalDuration".
310+
// The next code ensure backward compatibility.
311+
initialDuration = ic.readFloat("initialDuration", -1);
312+
if (initialDuration < 0) {
313+
initialDuration = ic.readFloat("initalDuration", -1);
314+
if (initialDuration < 0) {
315+
initialDuration = 10;
316+
}
317+
}
310318
loopMode = ic.readEnum("loopMode", LoopMode.class, LoopMode.DontLoop);
311319
}
312320

0 commit comments

Comments
 (0)