From: Raimar F. <hawk@B205a.WH8.TU-Dresden.De> - 2000-10-03 00:19:53
|
On Mon, Oct 02, 2000 at 11:21:21PM +0200, Ulrich Kuhn wrote: > yOn Mon, 2 Oct 2000, Michael Grundel wrote: > > > > A few littleties: > > > For memory's sake and as it is my job :-) I recommend the following patch > > > for DataTypeInfoForOneTurn.java: > > > > > > 27,28c27,28 > > > < data = new int[FreecivConstants.MAX_NUM_PLAYERS]; > > > < defined = new boolean[FreecivConstants.MAX_NUM_PLAYERS]; > > > --- > > > > data = new int[4]; > > > > defined = new boolean[4]; > > > 44a45 > > > > if (player >= data.length) grow(Math.max(data.length*2, player)); > > ^^^ ^^^^^^^^^^^^^ > > We should be careful not to make it larger than FreecivConstants.MAX_NUM_PLAYERS > > by doubling. > > Could this happen or did I miss something? As Ulrich mentions below currently this can not happen. However there is no harm if data is larger than FreecivConstants.MAX_NUM_PLAYERS. DataTypeInfoForOneTurn doesn't have enough information to check for the validity of a given playernumber. However it can test if the value was set previously. > Since MAX_NUM_PLAYERS is 32 this can not happen: 4 -> 8 -> 16 -> 32 > So the highest player number will be 31 and that fits in an array with 32 > places. Raimar -- The Software is not designed or licensed for use in on-line control equipment in hazardous environments, such as operation of nuclear facilities, aircraft navigation or control, or direct life support machines. -- Java Compiler Compiler Download and License Agreement |