Changeset - r10654:403d5cfff246
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-01-10 14:30:01
rubidium@openttd.org
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
3 files changed with 14 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1912,6 +1912,7 @@ STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD  
 
STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING                         :{WHITE}Adjoins more than one existing station/loading area
 
STR_3007_TOO_MANY_STATIONS_LOADING                              :{WHITE}Too many stations/loading areas in this town
 
STR_3008_TOO_MANY_STATIONS_LOADING                              :{WHITE}Too many stations/loading areas
 
STR_TOO_MANY_STATION_SPECS                                      :{WHITE}Too many railway station parts
 
STR_TOO_MANY_BUS_STOPS                                          :{WHITE}Too many bus stops
 
STR_TOO_MANY_TRUCK_STOPS                                        :{WHITE}Too many lorry stations
 
STR_3009_TOO_CLOSE_TO_ANOTHER_STATION                           :{WHITE}Too close to another station/loading area
src/newgrf_station.cpp
Show inline comments
 
@@ -693,16 +693,22 @@ int AllocateSpecToStation(const StationS
 

	
 
	if (statspec == NULL || st == NULL) return 0;
 

	
 
	/* Check if this spec has already been allocated */
 
	for (i = 1; i < st->num_specs && i < MAX_SPECLIST; i++) {
 
		if (st->speclist[i].spec == statspec) return i;
 
	}
 

	
 
	for (i = 1; i < st->num_specs && i < MAX_SPECLIST; i++) {
 
		if (st->speclist[i].spec == NULL && st->speclist[i].grfid == 0) break;
 
	}
 

	
 
	if (i == MAX_SPECLIST) return -1;
 
	if (i == MAX_SPECLIST) {
 
		/* As final effort when the spec list is already full...
 
		 * try to find the same spec and return that one. This might
 
		 * result in slighty "wrong" (as per specs) looking stations,
 
		 * but it's fairly unlikely that one reaches the limit anyways.
 
		 */
 
		for (i = 1; i < st->num_specs && i < MAX_SPECLIST; i++) {
 
			if (st->speclist[i].spec == statspec) return i;
 
		}
 

	
 
		return -1;
 
	}
 

	
 
	if (exec) {
 
		if (i >= st->num_specs) {
src/station_cmd.cpp
Show inline comments
 
@@ -1031,7 +1031,7 @@ CommandCost CmdBuildRailroadStation(Tile
 
	/* Check if we can allocate a custom stationspec to this station */
 
	const StationSpec *statspec = GetCustomStationSpec((StationClassID)GB(p2, 0, 8), GB(p2, 8, 8));
 
	int specindex = AllocateSpecToStation(statspec, st, flags & DC_EXEC);
 
	if (specindex == -1) return CMD_ERROR;
 
	if (specindex == -1) return_cmd_error(STR_TOO_MANY_STATION_SPECS);
 

	
 
	if (statspec != NULL) {
 
		/* Perform NewStation checks */
0 comments (0 inline, 0 general)