(svn r4484) - Newstations: Use StringIDs instead of char*s to reference our custom names.
authorpeter1138
Thu, 20 Apr 2006 17:04:08 +0000
changeset 3594 31fd59e606c8
parent 3593 22df29be81b4
child 3595 20621831cd46
(svn r4484) - Newstations: Use StringIDs instead of char*s to reference our custom names.
lang/english.txt
newgrf_station.c
newgrf_station.h
--- a/lang/english.txt	Thu Apr 20 13:33:40 2006 +0000
+++ b/lang/english.txt	Thu Apr 20 17:04:08 2006 +0000
@@ -1711,6 +1711,9 @@
 STR_306C_STATION_TOO_SPREAD_OUT                                 :{WHITE}...station too spread out
 STR_306D_NONUNIFORM_STATIONS_DISALLOWED                         :{WHITE}...nonuniform stations disabled
 
+STR_STAT_CLASS_DFLT                                             :Default station
+STR_STAT_CLASS_WAYP                                             :Waypoints
+
 ##id 0x3800
 STR_3800_SHIP_DEPOT_ORIENTATION                                 :{WHITE}Ship Depot Orientation
 STR_3801_MUST_BE_BUILT_ON_WATER                                 :{WHITE}...must be built on water
--- a/newgrf_station.c	Thu Apr 20 13:33:40 2006 +0000
+++ b/newgrf_station.c	Thu Apr 20 17:04:08 2006 +0000
@@ -6,6 +6,7 @@
 #include "openttd.h"
 #include "debug.h"
 #include "sprite.h"
+#include "table/strings.h"
 #include "station.h"
 #include "station_map.h"
 #include "newgrf_station.h"
@@ -22,10 +23,7 @@
 	StationClassID i;
 	for (i = 0; i < STAT_CLASS_MAX; i++) {
 		station_classes[i].id = 0;
-
-		free(station_classes[i].name);
-		station_classes[i].name = NULL;
-
+		station_classes[i].name = STR_EMPTY;
 		station_classes[i].stations = 0;
 
 		free(station_classes[i].spec);
@@ -34,13 +32,13 @@
 
 	// Set up initial data
 	station_classes[0].id = 'DFLT';
-	station_classes[0].name = strdup("Default");
+	station_classes[0].name = STR_STAT_CLASS_DFLT;
 	station_classes[0].stations = 1;
 	station_classes[0].spec = malloc(sizeof(*station_classes[0].spec));
 	station_classes[0].spec[0] = NULL;
 
 	station_classes[1].id = 'WAYP';
-	station_classes[1].name = strdup("Waypoints");
+	station_classes[1].name = STR_STAT_CLASS_WAYP;
 	station_classes[1].stations = 1;
 	station_classes[1].spec = malloc(sizeof(*station_classes[1].spec));
 	station_classes[1].spec[0] = NULL;
--- a/newgrf_station.h	Thu Apr 20 13:33:40 2006 +0000
+++ b/newgrf_station.h	Thu Apr 20 17:04:08 2006 +0000
@@ -22,6 +22,7 @@
 	int localidx; ///< Index within GRF file of station.
 
 	StationClassID sclass; ///< The class to which this spec belongs.
+	StringID name; ///< Name of this station.
 
 	/**
 	 * Bitmask of number of platforms available for the station.
@@ -76,14 +77,13 @@
  */
 typedef struct stationclass {
 	uint32 id;          ///< ID of this class, e.g. 'DFLT', 'WAYP', etc.
-	char *name;         ///< Name of this class.
+	StringID name;      ///< Name of this class.
 	uint stations;      ///< Number of stations in this class.
 	StationSpec **spec; ///< Array of station specifications.
 } StationClass;
 
 void ResetStationClasses(void);
 StationClassID AllocateStationClass(uint32 class);
-void SetStationClassName(StationClassID sclass, const char *name);
 uint GetNumStationClasses(void);
 uint GetNumCustomStations(StationClassID sclass);