Changeset - r8118:2e26e814db44
[Not reviewed]
master
0 2 0
glx - 17 years ago 2007-12-21 22:11:55
glx@openttd.org
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
2 files changed with 32 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/newgrf_commons.cpp
Show inline comments
 
@@ -10,12 +10,13 @@
 
#include "landscape.h"
 
#include "town.h"
 
#include "industry.h"
 
#include "newgrf.h"
 
#include "newgrf_commons.h"
 
#include "tile_map.h"
 
#include "station_map.h"
 

	
 
/** Constructor of generic class
 
 * @param offset end of original data for this entity. i.e: houses = 110
 
 * @param maximum of entities this manager can deal with. i.e: houses = 512
 
 * @param invalid is the ID used to identify an invalid entity id
 
 */
 
@@ -274,9 +275,12 @@ TileIndex GetNearbyTile(byte parameter, 
 
	int8 x = GB(parameter, 0, 4);
 
	int8 y = GB(parameter, 4, 4);
 

	
 
	if (x >= 8) x -= 16;
 
	if (y >= 8) y -= 16;
 

	
 
	/* Swap width and height depending on axis for railway stations */
 
	if (IsRailwayStationTile(tile) && GetRailStationAxis(tile) == AXIS_X) Swap(x, y);
 

	
 
	/* Make sure we never roam outside of the map */
 
	return TILE_MASK(tile + TileDiffXY(x, y));
 
}
src/newgrf_station.cpp
Show inline comments
 
@@ -436,12 +436,40 @@ static uint32 StationGetVariable(const R
 
		case 0x49:
 
			if (!HasBit(_svc.valid, 5)) { _svc.v49 = GetPlatformInfoHelper(tile, false, true, false); SetBit(_svc.valid, 5); }
 
			return _svc.v49;
 

	
 
		/* Variables which use the parameter */
 
		/* Variables 0x60 to 0x65 are handled separately below */
 
		case 0x67: { // Land info of nearby tiles
 
			Axis axis = GetRailStationAxis(tile);
 

	
 
			if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
 
			byte tile_type = GetTerrainType(tile) << 2 | (IsTileType(tile, MP_WATER) ? 1 : 0) << 1;
 

	
 
			uint z;
 
			Slope tileh = GetTileSlope(tile, &z);
 
			bool swap = (axis == AXIS_Y && HasBit(tileh, 0) != HasBit(tileh, 2));
 
			return GetTileType(tile) << 24 | z << 16 | tile_type << 8 | (tileh ^ (swap ? 5 : 0));
 
		}
 

	
 
		case 0x68: { // Station info of nearby tiles
 
			TileIndex nearby_tile = GetNearbyTile(parameter, tile);
 

	
 
			if (!IsRailwayStationTile(nearby_tile)) return 0xFFFFFFFF;
 

	
 
			uint32 grfid = st->speclist[GetCustomStationSpecIndex(tile)].grfid;
 
			bool perpendicular = GetRailStationAxis(tile) != GetRailStationAxis(nearby_tile);
 
			bool same_station = st->TileBelongsToRailStation(nearby_tile);
 
			uint32 res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10;
 

	
 
			if (IsCustomStationSpecIndex(nearby_tile)) {
 
				const StationSpecList ssl = GetStationByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)];
 
				res |= 1 << (ssl.grfid != grfid ? 9 : 8) | ssl.localidx;
 
			}
 
			return res;
 
		}
 

	
 
		/* General station properties */
 
		case 0x82: return 50;
 
		case 0x84: return st->string_id;
 
		case 0x86: return 0;
 
		case 0x8A: return st->had_vehicle_of_type;
0 comments (0 inline, 0 general)