(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
authorbelugas
Thu, 27 Apr 2006 18:28:56 +0000
changeset 3676 48444d881fbe
parent 3675 911e617e0a7e
child 3677 cb6659a684b5
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
This is following the same scheme as for IndustrySpec
newgrf.c
newgrf_station.c
newgrf_station.h
openttd.c
rail_cmd.c
station_cmd.c
waypoint.c
--- a/newgrf.c	Thu Apr 27 18:21:27 2006 +0000
+++ b/newgrf.c	Thu Apr 27 18:28:56 2006 +0000
@@ -780,7 +780,7 @@
 
 static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int len)
 {
-	StationSpec *stat;
+	StationSpec *statspec;
 	byte *buf = *bufp;
 	int i;
 	bool ret = false;
@@ -796,7 +796,7 @@
 		}
 	}
 
-	stat = &_cur_grffile->stations[stid];
+	statspec = &_cur_grffile->stations[stid];
 
 	switch (prop) {
 		case 0x08: /* Class ID */
@@ -809,19 +809,19 @@
 				classid |= *(buf++) << 8;
 				classid |= *(buf++);
 
-				stat[i].sclass = AllocateStationClass(classid);
+				statspec[i].sclass = AllocateStationClass(classid);
 			}
 			break;
 
 		case 0x09: /* Define sprite layout */
 			FOR_EACH_OBJECT {
-				StationSpec *stat = &_cur_grffile->stations[stid + i];
+				StationSpec *statspec = &_cur_grffile->stations[stid + i];
 				uint t;
 
-				stat->tiles = grf_load_extended(&buf);
-				stat->renderdata = calloc(stat->tiles, sizeof(*stat->renderdata));
-				for (t = 0; t < stat->tiles; t++) {
-					DrawTileSprites *dts = &stat->renderdata[t];
+				statspec->tiles = grf_load_extended(&buf);
+				statspec->renderdata = calloc(statspec->tiles, sizeof(*statspec->renderdata));
+				for (t = 0; t < statspec->tiles; t++) {
+					DrawTileSprites *dts = &statspec->renderdata[t];
 					uint seq_count = 0;
 					PalSpriteID ground_sprite;
 
@@ -863,16 +863,16 @@
 
 		case 0x0A: /* Copy sprite layout */
 			FOR_EACH_OBJECT {
-				StationSpec *stat = &_cur_grffile->stations[stid + i];
+				StationSpec *statspec = &_cur_grffile->stations[stid + i];
 				byte srcid = grf_load_byte(&buf);
-				const StationSpec *srcstat = &_cur_grffile->stations[srcid];
+				const StationSpec *srcstatspec = &_cur_grffile->stations[srcid];
 				uint t;
 
-				stat->tiles = srcstat->tiles;
-				stat->renderdata = calloc(stat->tiles, sizeof(*stat->renderdata));
-				for (t = 0; t < stat->tiles; t++) {
-					DrawTileSprites *dts = &stat->renderdata[t];
-					const DrawTileSprites *sdts = &srcstat->renderdata[t];
+				statspec->tiles = srcstatspec->tiles;
+				statspec->renderdata = calloc(statspec->tiles, sizeof(*statspec->renderdata));
+				for (t = 0; t < statspec->tiles; t++) {
+					DrawTileSprites *dts = &statspec->renderdata[t];
+					const DrawTileSprites *sdts = &srcstatspec->renderdata[t];
 					DrawTileSeqStruct const *sdtss = sdts->seq;
 					int seq_count = 0;
 
@@ -899,20 +899,20 @@
 			break;
 
 		case 0x0B: /* Callback mask */
-			FOR_EACH_OBJECT stat[i].callbackmask = grf_load_byte(&buf);
+			FOR_EACH_OBJECT statspec[i].callbackmask = grf_load_byte(&buf);
 			break;
 
 		case 0x0C: /* Disallowed number of platforms */
-			FOR_EACH_OBJECT stat[i].disallowed_platforms = grf_load_byte(&buf);
+			FOR_EACH_OBJECT statspec[i].disallowed_platforms = grf_load_byte(&buf);
 			break;
 
 		case 0x0D: /* Disallowed platform lengths */
-			FOR_EACH_OBJECT stat[i].disallowed_lengths = grf_load_byte(&buf);
+			FOR_EACH_OBJECT statspec[i].disallowed_lengths = grf_load_byte(&buf);
 			break;
 
 		case 0x0E: /* Define custom layout */
 			FOR_EACH_OBJECT {
-				StationSpec *stat = &_cur_grffile->stations[stid + i];
+				StationSpec *statspec = &_cur_grffile->stations[stid + i];
 
 				while (buf < *bufp + len) {
 					byte length = grf_load_byte(&buf);
@@ -923,27 +923,27 @@
 					if (length == 0 || number == 0) break;
 
 					//debug("l %d > %d ?", length, stat->lengths);
-					if (length > stat->lengths) {
-						stat->platforms = realloc(stat->platforms, length);
-						memset(stat->platforms + stat->lengths, 0, length - stat->lengths);
-
-						stat->layouts = realloc(stat->layouts, length * sizeof(*stat->layouts));
-						memset(stat->layouts + stat->lengths, 0,
-						       (length - stat->lengths) * sizeof(*stat->layouts));
-
-						stat->lengths = length;
+					if (length > statspec->lengths) {
+						statspec->platforms = realloc(statspec->platforms, length);
+						memset(statspec->platforms + statspec->lengths, 0, length - statspec->lengths);
+
+						statspec->layouts = realloc(statspec->layouts, length * sizeof(*statspec->layouts));
+						memset(statspec->layouts + statspec->lengths, 0,
+						       (length - statspec->lengths) * sizeof(*statspec->layouts));
+
+						statspec->lengths = length;
 					}
 					l = length - 1; // index is zero-based
 
 					//debug("p %d > %d ?", number, stat->platforms[l]);
-					if (number > stat->platforms[l]) {
-						stat->layouts[l] = realloc(stat->layouts[l],
-						                               number * sizeof(**stat->layouts));
+					if (number > statspec->platforms[l]) {
+						statspec->layouts[l] = realloc(statspec->layouts[l],
+						                               number * sizeof(**statspec->layouts));
 						// We expect NULL being 0 here, but C99 guarantees that.
-						memset(stat->layouts[l] + stat->platforms[l], 0,
-						       (number - stat->platforms[l]) * sizeof(**stat->layouts));
-
-						stat->platforms[l] = number;
+						memset(statspec->layouts[l] + statspec->platforms[l], 0,
+						       (number - statspec->platforms[l]) * sizeof(**statspec->layouts));
+
+						statspec->platforms[l] = number;
 					}
 
 					p = 0;
@@ -956,8 +956,8 @@
 
 					l--;
 					p--;
-					free(stat->layouts[l][p]);
-					stat->layouts[l][p] = layout;
+					free(statspec->layouts[l][p]);
+					statspec->layouts[l][p] = layout;
 				}
 			}
 			break;
@@ -971,27 +971,27 @@
 			break;
 
 		case 0x10: /* Little/lots cargo threshold */
-			FOR_EACH_OBJECT stat[i].cargo_threshold = grf_load_word(&buf);
+			FOR_EACH_OBJECT statspec[i].cargo_threshold = grf_load_word(&buf);
 			break;
 
 		case 0x11: /* Pylon placement */
-			FOR_EACH_OBJECT stat[i].pylons = grf_load_byte(&buf);
+			FOR_EACH_OBJECT statspec[i].pylons = grf_load_byte(&buf);
 			break;
 
 		case 0x12: /* Cargo types for random triggers */
-			FOR_EACH_OBJECT stat[i].cargo_triggers = grf_load_dword(&buf);
+			FOR_EACH_OBJECT statspec[i].cargo_triggers = grf_load_dword(&buf);
 			break;
 
 		case 0x13: /* General flags */
-			FOR_EACH_OBJECT stat[i].flags = grf_load_byte(&buf);
+			FOR_EACH_OBJECT statspec[i].flags = grf_load_byte(&buf);
 			break;
 
 		case 0x14: /* Overhead wire placement */
-			FOR_EACH_OBJECT stat[i].wires = grf_load_byte(&buf);
+			FOR_EACH_OBJECT statspec[i].wires = grf_load_byte(&buf);
 			break;
 
 		case 0x15: /* Blocked tiles */
-			FOR_EACH_OBJECT stat[i].blocked = grf_load_byte(&buf);
+			FOR_EACH_OBJECT statspec[i].blocked = grf_load_byte(&buf);
 			break;
 
 		default:
@@ -1612,7 +1612,7 @@
 
 		for (i = 0; i < idcount; i++) {
 			uint8 stid = buf[3 + i];
-			StationSpec *stat = &_cur_grffile->stations[stid];
+			StationSpec *statspec = &_cur_grffile->stations[stid];
 			byte *bp = &buf[4 + idcount];
 
 			for (c = 0; c < cidcount; c++) {
@@ -1630,7 +1630,7 @@
 					continue;
 				}
 
-				stat->spritegroup[1] = _cur_grffile->spritegroups[groupid];
+				statspec->spritegroup[1] = _cur_grffile->spritegroups[groupid];
 			}
 		}
 
@@ -1646,12 +1646,12 @@
 
 			for (i = 0; i < idcount; i++) {
 				uint8 stid = buf[3 + i];
-				StationSpec *stat = &_cur_grffile->stations[stid];
-
-				stat->spritegroup[0] = _cur_grffile->spritegroups[groupid];
-				stat->grfid = _cur_grffile->grfid;
-				stat->localidx = stid;
-				SetCustomStation(stat);
+				StationSpec *statspec = &_cur_grffile->stations[stid];
+
+				statspec->spritegroup[0] = _cur_grffile->spritegroups[groupid];
+				statspec->grfid = _cur_grffile->grfid;
+				statspec->localidx = stid;
+				SetCustomStationSpec(statspec);
 			}
 		}
 		return;
--- a/newgrf_station.c	Thu Apr 27 18:21:27 2006 +0000
+++ b/newgrf_station.c	Thu Apr 27 18:28:56 2006 +0000
@@ -127,18 +127,18 @@
  * Tie a station spec to its station class.
  * @param spec The station spec.
  */
-void SetCustomStation(StationSpec *spec)
+void SetCustomStationSpec(StationSpec *statspec)
 {
 	StationClass *station_class;
 	int i;
 
-	assert(spec->sclass < STAT_CLASS_MAX);
-	station_class = &station_classes[spec->sclass];
+	assert(statspec->sclass < STAT_CLASS_MAX);
+	station_class = &station_classes[statspec->sclass];
 
 	i = station_class->stations++;
 	station_class->spec = realloc(station_class->spec, station_class->stations * sizeof(*station_class->spec));
 
-	station_class->spec[i] = spec;
+	station_class->spec[i] = statspec;
 }
 
 /**
@@ -147,7 +147,7 @@
  * @param station The station index with the class.
  * @return The station spec.
  */
-const StationSpec *GetCustomStation(StationClassID sclass, uint station)
+const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station)
 {
 	assert(sclass < STAT_CLASS_MAX);
 	if (station < station_classes[sclass].stations)
@@ -225,16 +225,16 @@
 	}
 }
 
-uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, byte ctype)
+uint32 GetCustomStationRelocation(const StationSpec *statspec, const Station *st, byte ctype)
 {
-	const RealSpriteGroup *rsg = ResolveStationSpriteGroup(spec->spritegroup[ctype], st);
+	const RealSpriteGroup *rsg = ResolveStationSpriteGroup(statspec->spritegroup[ctype], st);
 	if (rsg == NULL) return 0;
 
 	if (rsg->num_loading != 0) return rsg->loading[0]->g.result.sprite;
 	if (rsg->num_loaded  != 0) return rsg->loaded[0]->g.result.sprite;
 
 	DEBUG(grf, 6)("Custom station 0x%08x::0x%02x has no sprites associated.",
-		spec->grfid, spec->localidx);
+		statspec->grfid, statspec->localidx);
 	/* This is what gets subscribed of dtss->image in newgrf.c,
 	 * so it's probably kinda "default offset". Try to use it as
 	 * emergency measure. */
@@ -249,15 +249,15 @@
  * @param exec Whether to actually allocate the spec.
  * @return Index within the Station's spec list, or -1 if the allocation failed.
  */
-int AllocateSpecToStation(const StationSpec *spec, Station *st, bool exec)
+int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec)
 {
 	uint i;
 
-	if (spec == NULL) return 0;
+	if (statspec == NULL) return 0;
 
 	/* Check if this spec has already been allocated */
 	for (i = 1; i < st->num_specs && i < 256; i++) {
-		if (st->speclist[i].spec == spec) return i;
+		if (st->speclist[i].spec == statspec) return i;
 	}
 
 	for (i = 1; i < st->num_specs && i < 256; i++) {
@@ -278,9 +278,9 @@
 				}
 			}
 
-			st->speclist[i].spec     = spec;
-			st->speclist[i].grfid    = spec->grfid;
-			st->speclist[i].localidx = spec->localidx;
+			st->speclist[i].spec     = statspec;
+			st->speclist[i].grfid    = statspec->grfid;
+			st->speclist[i].localidx = statspec->localidx;
 		}
 		return i;
 	}
--- a/newgrf_station.h	Thu Apr 27 18:21:27 2006 +0000
+++ b/newgrf_station.h	Thu Apr 27 18:28:56 2006 +0000
@@ -91,16 +91,16 @@
 uint GetNumStationClasses(void);
 uint GetNumCustomStations(StationClassID sclass);
 
-void SetCustomStation(StationSpec *spec);
-const StationSpec *GetCustomStation(StationClassID sclass, uint station);
+void SetCustomStationSpec(StationSpec *statspec);
+const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station);
 
 /* Get sprite offset for a given custom station and station structure (may be
  * NULL if ctype is set - that means we are in a build dialog). The station
  * structure is used for variational sprite groups. */
-uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, byte ctype);
+uint32 GetCustomStationRelocation(const StationSpec *statspec, const Station *st, byte ctype);
 
 /* Allocate a StationSpec to a Station. This is called once per build operation. */
-int AllocateSpecToStation(const StationSpec *spec, Station *st, bool exec);
+int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec);
 
 /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
 bool DeallocateSpecFromStation(Station *st, byte specindex);
--- a/openttd.c	Thu Apr 27 18:21:27 2006 +0000
+++ b/openttd.c	Thu Apr 27 18:28:56 2006 +0000
@@ -1342,15 +1342,15 @@
 
 		FOR_ALL_WAYPOINTS(wp) {
 			if (wp->xy != 0 && wp->deleted == 0) {
-				const StationSpec *spec = NULL;
+				const StationSpec *statspec = NULL;
 
 				if (HASBIT(_m[wp->xy].m3, 4))
-					spec = GetCustomStation(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1);
+					statspec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1);
 
-				if (spec != NULL) {
+				if (statspec != NULL) {
 					wp->stat_id = _m[wp->xy].m4 + 1;
-					wp->grfid = spec->grfid;
-					wp->localidx = spec->localidx;
+					wp->grfid = statspec->grfid;
+					wp->localidx = statspec->localidx;
 				} else {
 					// No custom graphics set, so set to default.
 					wp->stat_id = 0;
--- a/rail_cmd.c	Thu Apr 27 18:21:27 2006 +0000
+++ b/rail_cmd.c	Thu Apr 27 18:28:56 2006 +0000
@@ -1318,13 +1318,13 @@
 		if (IsRailWaypoint(ti->tile) && IsCustomWaypoint(ti->tile)) {
 			// look for customization
 			byte stat_id = GetWaypointByTile(ti->tile)->stat_id;
-			const StationSpec *stat = GetCustomStation(STAT_CLASS_WAYP, stat_id);
+			const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, stat_id);
 
-			if (stat != NULL) {
+			if (statspec != NULL) {
 				DrawTileSeqStruct const *seq;
 				// emulate station tile - open with building
-				const DrawTileSprites *cust = &stat->renderdata[2 + GetWaypointAxis(ti->tile)];
-				uint32 relocation = GetCustomStationRelocation(stat, ComposeWaypointStation(ti->tile), 0);
+				const DrawTileSprites *cust = &statspec->renderdata[2 + GetWaypointAxis(ti->tile)];
+				uint32 relocation = GetCustomStationRelocation(statspec, ComposeWaypointStation(ti->tile), 0);
 
 				/* We don't touch the 0x8000 bit. In all this
 				 * waypoint code, it is used to indicate that
--- a/station_cmd.c	Thu Apr 27 18:21:27 2006 +0000
+++ b/station_cmd.c	Thu Apr 27 18:28:56 2006 +0000
@@ -918,13 +918,13 @@
 	return layout;
 }
 
-static void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSpec *spec)
+static void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSpec *statspec)
 {
-	if (spec != NULL && spec->lengths >= plat_len &&
-			spec->platforms[plat_len - 1] >= numtracks &&
-			spec->layouts[plat_len - 1][numtracks - 1]) {
+	if (statspec != NULL && statspec->lengths >= plat_len &&
+			statspec->platforms[plat_len - 1] >= numtracks &&
+			statspec->layouts[plat_len - 1][numtracks - 1]) {
 		/* Custom layout defined, follow it. */
-		memcpy(layout, spec->layouts[plat_len - 1][numtracks - 1],
+		memcpy(layout, statspec->layouts[plat_len - 1][numtracks - 1],
 			plat_len * numtracks);
 		return;
 	}
@@ -1042,7 +1042,7 @@
 	if (GB(p2, 8, 8) >= STAT_CLASS_MAX) return CMD_ERROR;
 
 	/* Check if we can allocate a custom stationspec to this station */
-	statspec = GetCustomStation(GB(p2, 8, 8), GB(p2, 16, 8));
+	statspec = GetCustomStationSpec(GB(p2, 8, 8), GB(p2, 16, 8));
 	specindex = AllocateSpecToStation(statspec, st, flags & DC_EXEC);
 	if (specindex == -1) return CMD_ERROR;
 
--- a/waypoint.c	Thu Apr 27 18:21:27 2006 +0000
+++ b/waypoint.c	Thu Apr 27 18:28:56 2006 +0000
@@ -153,8 +153,8 @@
 		if (wp->grfid == 0) continue;
 
 		for (i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) {
-			const StationSpec *spec = GetCustomStation(STAT_CLASS_WAYP, i);
-			if (spec != NULL && spec->grfid == wp->grfid && spec->localidx == wp->localidx) {
+			const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, i);
+			if (statspec != NULL && statspec->grfid == wp->grfid && statspec->localidx == wp->localidx) {
 				wp->stat_id = i;
 				break;
 			}
@@ -213,18 +213,18 @@
 	}
 
 	if (flags & DC_EXEC) {
-		const StationSpec *spec = NULL;
+		const StationSpec *statspec = NULL;
 		MakeRailWaypoint(tile, GetTileOwner(tile), axis, GetRailType(tile), wp->index);
 		MarkTileDirtyByTile(tile);
 
 		if (GB(p1, 0, 8) < GetNumCustomStations(STAT_CLASS_WAYP))
-			spec = GetCustomStation(STAT_CLASS_WAYP, GB(p1, 0, 8));
+			statspec = GetCustomStationSpec(STAT_CLASS_WAYP, GB(p1, 0, 8));
 
-		if (spec != NULL) {
+		if (statspec != NULL) {
 			SetCustomWaypointSprite(tile);
 			wp->stat_id = GB(p1, 0, 8);
-			wp->grfid = spec->grfid;
-			wp->localidx = spec->localidx;
+			wp->grfid = statspec->grfid;
+			wp->localidx = statspec->localidx;
 		} else {
 			// Specified custom graphics do not exist, so use default.
 			ClearCustomWaypointSprite(tile);
@@ -385,7 +385,7 @@
 /* Draw a waypoint */
 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
 {
-	const StationSpec *stat;
+	const StationSpec *statspec;
 	uint32 relocation;
 	const DrawTileSprites *cust;
 	DrawTileSeqStruct const *seq;
@@ -397,18 +397,18 @@
 	x += 33;
 	y += 17;
 
-	stat = GetCustomStation(STAT_CLASS_WAYP, stat_id);
-	if (stat == NULL) {
+	statspec = GetCustomStationSpec(STAT_CLASS_WAYP, stat_id);
+	if (statspec == NULL) {
 		// stat is NULL for default waypoints and when waypoint graphics are
 		// not loaded.
 		DrawDefaultWaypointSprite(x, y, railtype);
 		return;
 	}
 
-	relocation = GetCustomStationRelocation(stat, NULL, 1);
+	relocation = GetCustomStationRelocation(statspec, NULL, 1);
 	// emulate station tile - open with building
 	// add 1 to get the other direction
-	cust = &stat->renderdata[2];
+	cust = &statspec->renderdata[2];
 
 	img = cust->ground_sprite;
 	img += (img < _custom_sprites_base) ? rti->total_offset : rti->custom_ground_offset;