Fix hang when a player buys a ship with fewer missile pylons and the missiles on the old ship aren't loaded on contiguous pylons starting at pylon 0

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@125 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Dylan Smith 2005-09-13 20:50:31 +00:00
parent 133ad4f938
commit fe0e20a852
3 changed files with 29 additions and 0 deletions

View File

@ -1248,6 +1248,9 @@ NSMutableDictionary* currentShipyard;
has_scoop = NO;
energy_unit = ENERGY_UNIT_NONE;
// ensure all missiles are tidied up and start at pylon 0
[self tidyMissilePylons];
// get missiles from ship_info
missiles = [(NSNumber*)[(NSDictionary*)[ship_info objectForKey:SHIPYARD_KEY_SHIP] objectForKey:@"missiles"] intValue];

View File

@ -504,6 +504,7 @@ Your fair use and other rights are in no way affected by the above.
- (void) sort_missiles;
- (void) safe_all_missiles;
- (void) select_next_missile;
- (void) tidyMissilePylons;
- (void) clearAlert_flags;
- (void) setAlert_flag:(int) flag :(BOOL) value;

View File

@ -2210,9 +2210,34 @@ static BOOL galactic_witchjump;
missile_status = MISSILE_STATUS_SAFE;
}
- (void) tidyMissilePylons
{
// Shuffle missiles up so there's:
// no gaps between missiles
// the first missile is in the first pylon
int i;
int pylon=0;
for(i = 0; i < SHIPENTITY_MAX_MISSILES; i++)
{
if(missile_entity[i])
{
missile_entity[pylon]=missile_entity[i];
pylon++;
}
}
// missiles have been shoved up, now make sure the remainder
// of the pylons are cleaned up.
for(i = pylon; i < SHIPENTITY_MAX_MISSILES; i++)
{
missile_entity[i]=nil;
}
}
- (void) select_next_missile
{
int i;
for (i = 1; i < max_missiles; i++)
{
int next_missile = (active_missile + i) % max_missiles;