SEPR-EEP / taxe-game-3

0 stars 0 forks source link

Navigable Snapshots, Replay #16

Closed AlfioEmanueleFresta closed 9 years ago

AlfioEmanueleFresta commented 9 years ago
AlfioEmanueleFresta commented 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).

image

AlfioEmanueleFresta commented 9 years ago

Something we could think about :

rc1035 commented 9 years ago

Great progress so far! Few bugs spotted from a quick test run:

AlfioEmanueleFresta commented 9 years ago

@rc1035 you're right, I'm pretty sure this is not supposed to happen:

image

I'm trying to figure out the nature of the problem - unfortunately with no luck for now.

AlfioEmanueleFresta commented 9 years ago

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.

AlfioEmanueleFresta commented 9 years ago

These seem to be the major problems atm:

  1. When replaying, the first train moves are always wrong. Instead of going from the first station towards the second, the train moves from the latest station reached towards the second of the route. Once the second station of the route has been reached, the route continues normally.
  2. When replaying if the replay has been started when the train is still moving, crazy things happen. This seems mainly due to the fact that the train route is not cancelled and the actor is not told to stop.
    • ATM the only solution I can think of would be not to allow the player to start a replay if a train is moving.
rc1035 commented 9 years ago

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.

AlfioEmanueleFresta commented 9 years ago

Apparently all of the problems up here have been solved now.