From: Erik V. <eri...@hc...> - 2008-10-31 20:14:24
|
I pulled down your latest updates, and went to see if I could resolve the 18AL Bug report about not being able to upgrade tiles... and ran into a bug in your updates, that generates a NULL Pointer when trying to purchase the last Private (giving out the President's Share). It looks like in the StockRound Class, the setBuyableCerts routine (line 179) attempts to get the cost of the purchase with the call: price = comp.getParPrice().getPrice () * cert.getShares (); When I look at the PublicCompany.java Class, and the GetParPrice routine, it is checking the flag "hasParPrice" -- which is set to -TRUE- (this is wrong since the price has not been set yet via dialog). and then it returns: return parPrice != null? parPrice.getPrice() : null; and if -FALSE- it returns: return currentPrice != null ? currentPrice.getPrice () : null; In the -TRUE- Case, it will return the parPrice StockSpace. In the -FALSE- case, it is returning the Current Stock Value, and not the Par Price Value which is implied by the routine name. So if the -hasParPrice- variable is NOT set, it tries to get the currentPrice. And this should not be set either... This routine looks wierd. Yes, I think it actually means "getInitialPrice" or such, although it seems to be used in various ways. But hasParPrice() only means that a company has a fixed price for buying unsold certificates. In many games, all shares are sold at current market price, even from IPO (although I think in most cases unsold shares are moved to the company treasury when a company floats). In that case hasParPrice() is false. Would it make sense to add a routine like: public int getParPrice () { /* Get the ParPrice StockSpace with the first getPrice call, and get the actual int value with the second call */ return parPrice != null ? parPrice.getPrice().getPrice() : 0; } So if you want the Int Value of the Par Price... you call the routine, and allow JAVA to use the appropriate routine? In this case like 179 of StockRound.java would be: price = comp.getParPrice () * cert.getShares (); Note, it Appears in 1830 I can set price for B&O, and buy it, but once the Stock Round starts, I have no stocks available to buy in the IPO. And I get the same NULL Pointer Exception on Line 179 of Stock Round. OK, my recent changes appear to have broken this. In StockRound, I had to move around code a bit to enable buying non-president shares before starting a company, as is allowed in some games for "government companies", like the 1835 Prussian and the 18Scan SJ, but I had not really tested that "normal" company starts would still work :-( I'll sort this out today or tomorrow. This whole matter clearly needs a closer look. I'll look at your suggestions as well. Erik. |