Closed AlfioEmanueleFresta closed 9 years ago
While playing, snaphshots are created. The method that triggers the creation of a snapshot is setState
. This happens every time a turn is ended, and at every start of an animation - so it is fine for a nice animated replay. At this time it is also triggered for minor events we may want to exclude (such as when you want to place a train and the cursors changes).
Something we could think about :
Great progress so far! Few bugs spotted from a quick test run:
@rc1035 you're right, I'm pretty sure this is not supposed to happen:
I'm trying to figure out the nature of the problem - unfortunately with no luck for now.
Found the problem that caused trains to be unselectable after a replay.
The following code was used to check if a Train was stationary at a given station:
if(((Train) resource).getPosition() == station.getLocation()) {
In Java, the ==
operator returns true for objects only if the two sides are references to the same object, not if the two objects are considered equal (i.e. two different position objects -generated by cloning when a snapshot is created- that contain the same X and Y values were considered not equal). Fixed by changing the condition to:
if(((Train) resource).getPosition().equals(station.getLocation())) {
Very subtle indeed.
These seem to be the major problems atm:
That is a very subtle bug, not sure if I would have been able to spot it!
For the 1st problem, it sounds like issues possibly relating to (1) the position of the train, and/or (2) the order that which actions are added to the actor of the train. I'll look into it tomorrow.
For the 2nd problem, what do you mean by 'train is still moving' - does this mean the train has not yet reached the final destination of its route, or that the actor of the train is still moving (i.e. we are still in the animating state). I think not allowing the replay button to be pressed during the animating state is perfectly reasonable.
An additional bug:
Once a goal is completed we get a null pointer exception. The issue seems to be at TrainMoveController.java:113, we try to set the trains' actor's visibility to false, yet the train no longer has an actor.
Apparently all of the problems up here have been solved now.
Snapshot
class, containing properties of the Game at a given point in timeGame.getSnapshotsNumber()
to know how many snapshots there areGame.createSnapshot()
to push a snapshot of the current state to the listGame.loadSnapshot(Snapshot)
to load a snapshot