From: Erik V. <eri...@xs...> - 2010-07-17 22:03:21
|
Follow-up: I have added a generic method Util.addToList() to simplify the object-moving-to-a-list-at-a-given-position code. While doing this, I realised that Undo does not yet identically restores all affected lists. For instance, in Portfolio.addCertificate(), three lists are updated when a certificate is added: - an overall list of certs, - a map of lists of certs per company, - a map of lists of certs per type. To fix that, I'm now passing down an int array, with the location in each list from which the objects are removed. Erik. -----Original Message----- From: Erik Vos [mailto:eri...@xs...] Sent: Saturday 17 July 2010 13:11 To: 'Development list for Rails: an 18xx game' Subject: Re: [Rails-devel] 1856 bugs in Rails 1.3 -- undo during CGRformation hangs game I have fixed this problem by ensuring that undoing any ObjectMove will always restore the original stack order. This covers most object types; I think only price token moves are not included as these follow a different paradigm, but in that case stack order restoration had already been dealt with previously. The case in question now works correctly. I have also tested against a number of longish test cases, and these all work. My testing revealed another bug, where price tokens moving upwards vanished in the empty upper left corner of the 1835 stock chart. That bug is now also fixed. I'll will have another look at ObjectMoves, because I think the code can be simplified by providing simpler way to find in which List any Moveable object is held by its owner. Perhaps price token moves can then also be rewritten as ObjectMoves. I'll discuss another point raised below by Stefan in a next post. Erik. -----Original Message----- From: ste...@we... [mailto:ste...@we...] Sent: Tuesday 13 July 2010 23:35 To: Erik Vos Subject: Fwd: Re: [Rails-devel] 1856 bugs in Rails 1.3 -- undo during CGR formation hangs game Fowarding test case for sequenc problem. ---------- Forwarded Message ---------- Subject: Re: [Rails-devel] 1856 bugs in Rails 1.3 -- undo during CGR formation hangs game Date: Monday 21 June 2010 From: Stefan Frey <ste...@we...> To: "Development list for Rails: an 18xx game" <rai...@li...> Erik: Just some follow-up to the issue. I explain it with an example, as it might be an instructive case to remember for potential issues with the undo-function in Rails. This bug is easily reproducible under simplified conditions. I attach the save file for the example. There are several steps involved (see example file) A) Owner of AR (player David, owns 50%) sells a (single) certificate B) Undo this action C) Player A sells a (single) certificate again D) Other player (Alice) buys that share from the pool E) Save Game: Until then everything looks fine: David owns 40%. Alice owns 10% F) Reload game: Now David owns only 30%, Alice owns 10%, the Pool has 10%! What happened internally: You have to be aware, that certificates are internally identified by ids. Assume that David has single certificates called AR-1 to AR-3. A) David sells 10% certificate (assume that this is certificate AR-1) B) Undo that action (now AR-1 comes to the bottom of his certificates) C) David sells 10% again, but now this is certificate AR-2 D) Alice buys AR-2 from the pool E) save only saves actions, which were not undone (thus actions C and D) F) on the reload for C) AR-1 gets sold to the Pool, but in D) Alice still buys AR-2, but the previous owner is now not the Pool, but David! The reason is a combination of issues: 1) The BuyCertificates action stores certificate by id 2) The SellShares action only stores percentages sold 3) The Undoing of share moves does not keep the order of certificates By changing any of the three the problem can be solved. The main issue is mixing addressing interchangeable objects once by ids and in the other case by type. This can only work, if evey selection by type works deterministically (thus never from unordered collections etc.) and the undo mechanism strictly restores the previous ordering. Stefan ---------------------------------------------------------------------------- -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Rails-devel mailing list Rai...@li... https://lists.sourceforge.net/lists/listinfo/rails-devel |