engine.c
changeset 1474 d83520edcda6
parent 1329 a8a0d60b0a8e
child 1475 b5cf1fc28304
--- a/engine.c	Wed Mar 09 19:42:37 2005 +0000
+++ b/engine.c	Wed Mar 09 19:48:20 2005 +0000
@@ -56,7 +56,7 @@
 	uint i;
 	StringID old;
 
-	for(i=0; i!=TOTAL_NUM_ENGINES; i++) {
+	for (i = 0; i != TOTAL_NUM_ENGINES; i++) {
 		old = _engine_name_strings[i];
 		_engine_name_strings[i] = i + STR_8000_KIRBY_PAUL_TANK_STEAM;
 		DeleteName(old);
@@ -73,10 +73,10 @@
 
 static void SetupEngineNames(void)
 {
-	uint i;
+	StringID *name;
 
-	for(i=0; i!=TOTAL_NUM_ENGINES; i++)
-		_engine_name_strings[i] = STR_SV_EMPTY;
+	for (name = _engine_name_strings; name != endof(_engine_name_strings); name++)
+		*name = STR_SV_EMPTY;
 
 	DeleteCustomEngineNames();
 	LoadCustomEngineNames();
@@ -200,7 +200,7 @@
 	AdjustAvailAircraft();
 }
 
-uint32 _engine_refit_masks[256];
+uint32 _engine_refit_masks[TOTAL_NUM_ENGINES];
 
 
 // TODO: We don't support cargo-specific wagon overrides. Pretty exotic... ;-) --pasky
@@ -214,7 +214,7 @@
 static struct WagonOverrides {
 	int overrides_count;
 	struct WagonOverride *overrides;
-} _engine_wagon_overrides[256];
+} _engine_wagon_overrides[TOTAL_NUM_ENGINES];
 
 void SetWagonOverrideSprites(byte engine, struct SpriteGroup *group,
                              byte *train_id, int trains)
@@ -260,12 +260,12 @@
 }
 
 
-byte _engine_original_sprites[256];
+byte _engine_original_sprites[TOTAL_NUM_ENGINES];
 // 0 - 28 are cargos, 29 is default, 30 is the advert (purchase list)
 // (It isn't and shouldn't be like this in the GRF files since new cargo types
 // may appear in future - however it's more convenient to store it like this in
 // memory. --pasky)
-static struct SpriteGroup _engine_custom_sprites[256][NUM_CID];
+static struct SpriteGroup _engine_custom_sprites[TOTAL_NUM_ENGINES][NUM_CID];
 
 void SetCustomEngineSprites(byte engine, byte cargo, struct SpriteGroup *group)
 {
@@ -622,14 +622,22 @@
 	DoTriggerVehicle(veh, trigger, 0, true);
 }
 
-
-static char *_engine_custom_names[256];
+static char *_engine_custom_names[TOTAL_NUM_ENGINES];
 
 void SetCustomEngineName(int engine, const char *name)
 {
 	_engine_custom_names[engine] = strdup(name);
 }
 
+void UnInitNewgrEngines(void)
+{
+	char **i;
+	for (i = _engine_custom_names; i != endof(_engine_custom_names); i++) {
+		free(*i);
+		*i = NULL;
+	}
+}
+
 StringID GetCustomEngineName(int engine)
 {
 	if (!_engine_custom_names[engine])