(svn r25614) -Fix [FS#5651]: [Script] Give a slightly less generic error when removing inexisting rail

-Fix [FS#5650]: [Script] Be more specific that a non-NewGRF station can be built when asking for a NewGRF station
This commit is contained in:
rubidium 2013-07-15 18:19:26 +00:00
parent 72fb509286
commit de90a1ffb3
3 changed files with 16 additions and 2 deletions

View File

@ -53,6 +53,9 @@ void SQAIRail_Register(Squirrel *engine)
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_ON_ONEWAY_ROAD, ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD); ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_ON_ONEWAY_ROAD, ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD);
ScriptError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK, ScriptRail::ERR_UNSUITABLE_TRACK); ScriptError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK, ScriptRail::ERR_UNSUITABLE_TRACK);
ScriptError::RegisterErrorMap(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, ScriptRail::ERR_UNSUITABLE_TRACK);
ScriptError::RegisterErrorMap(STR_ERROR_THERE_ARE_NO_SIGNALS, ScriptRail::ERR_UNSUITABLE_TRACK);
ScriptError::RegisterErrorMap(STR_ERROR_THERE_IS_NO_STATION, ScriptRail::ERR_UNSUITABLE_TRACK);
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED, ScriptRail::ERR_RAILTYPE_DISALLOWS_CROSSING); ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED, ScriptRail::ERR_RAILTYPE_DISALLOWS_CROSSING);
ScriptError::RegisterErrorMapString(ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD"); ScriptError::RegisterErrorMapString(ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD");

View File

@ -53,6 +53,9 @@ void SQGSRail_Register(Squirrel *engine)
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_ON_ONEWAY_ROAD, ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD); ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_ON_ONEWAY_ROAD, ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD);
ScriptError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK, ScriptRail::ERR_UNSUITABLE_TRACK); ScriptError::RegisterErrorMap(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK, ScriptRail::ERR_UNSUITABLE_TRACK);
ScriptError::RegisterErrorMap(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, ScriptRail::ERR_UNSUITABLE_TRACK);
ScriptError::RegisterErrorMap(STR_ERROR_THERE_ARE_NO_SIGNALS, ScriptRail::ERR_UNSUITABLE_TRACK);
ScriptError::RegisterErrorMap(STR_ERROR_THERE_IS_NO_STATION, ScriptRail::ERR_UNSUITABLE_TRACK);
ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED, ScriptRail::ERR_RAILTYPE_DISALLOWS_CROSSING); ScriptError::RegisterErrorMap(STR_ERROR_CROSSING_DISALLOWED, ScriptRail::ERR_RAILTYPE_DISALLOWS_CROSSING);
ScriptError::RegisterErrorMapString(ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD"); ScriptError::RegisterErrorMapString(ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD, "ERR_CROSSING_ON_ONEWAY_ROAD");

View File

@ -32,8 +32,8 @@ public:
/** One-way roads cannot have crossings */ /** One-way roads cannot have crossings */
ERR_CROSSING_ON_ONEWAY_ROAD, // [STR_ERROR_CROSSING_ON_ONEWAY_ROAD] ERR_CROSSING_ON_ONEWAY_ROAD, // [STR_ERROR_CROSSING_ON_ONEWAY_ROAD]
/** Track not suitable for signals */ /** No suitable track could be found */
ERR_UNSUITABLE_TRACK, // [STR_ERROR_NO_SUITABLE_RAILROAD_TRACK] ERR_UNSUITABLE_TRACK, // [STR_ERROR_NO_SUITABLE_RAILROAD_TRACK, STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, STR_ERROR_THERE_ARE_NO_SIGNALS, STR_ERROR_THERE_IS_NO_STATION]
/** This railtype cannot have crossings */ /** This railtype cannot have crossings */
ERR_RAILTYPE_DISALLOWS_CROSSING, // [STR_ERROR_CROSSING_DISALLOWED] ERR_RAILTYPE_DISALLOWS_CROSSING, // [STR_ERROR_CROSSING_DISALLOWED]
@ -268,6 +268,9 @@ public:
* Build a NewGRF rail station. This calls callback 18 to let a NewGRF * Build a NewGRF rail station. This calls callback 18 to let a NewGRF
* provide the station class / id to build, so we don't end up with * provide the station class / id to build, so we don't end up with
* only the default stations on the map. * only the default stations on the map.
* When no NewGRF provides a rail station, or an unbuildable rail station is
* returned by a NewGRF, this function will fall back to building a default
* non-NewGRF station as if ScriptRail::BuildRailStation was called.
* @param tile Place to build the station. * @param tile Place to build the station.
* @param direction The direction to build the station. * @param direction The direction to build the station.
* @param num_platforms The number of platforms to build. * @param num_platforms The number of platforms to build.
@ -319,6 +322,7 @@ public:
* @pre IsValidTile(tile). * @pre IsValidTile(tile).
* @pre IsValidTile(tile2). * @pre IsValidTile(tile2).
* @game @pre Valid ScriptCompanyMode active in scope. * @game @pre Valid ScriptCompanyMode active in scope.
* @exception ScriptRail::ERR_UNSUITABLE_TRACK
* @return Whether at least one tile has been/can be cleared or not. * @return Whether at least one tile has been/can be cleared or not.
*/ */
static bool RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail); static bool RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
@ -331,6 +335,7 @@ public:
* @pre IsValidTile(tile). * @pre IsValidTile(tile).
* @pre IsValidTile(tile2). * @pre IsValidTile(tile2).
* @game @pre Valid ScriptCompanyMode active in scope. * @game @pre Valid ScriptCompanyMode active in scope.
* @exception ScriptRail::ERR_UNSUITABLE_TRACK
* @return Whether at least one tile has been/can be cleared or not. * @return Whether at least one tile has been/can be cleared or not.
*/ */
static bool RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail); static bool RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
@ -369,6 +374,7 @@ public:
* @pre ScriptMap::IsValidTile(tile). * @pre ScriptMap::IsValidTile(tile).
* @pre (GetRailTracks(tile) & rail_track) != 0. * @pre (GetRailTracks(tile) & rail_track) != 0.
* @game @pre Valid ScriptCompanyMode active in scope. * @game @pre Valid ScriptCompanyMode active in scope.
* @exception ScriptRail::ERR_UNSUITABLE_TRACK
* @return Whether the rail has been/can be removed or not. * @return Whether the rail has been/can be removed or not.
* @note You can only remove a single track with this function so do not * @note You can only remove a single track with this function so do not
* use the values from RailTrack as bitmask. * use the values from RailTrack as bitmask.
@ -424,6 +430,7 @@ public:
* (ScriptMap::GetTileX(from) == ScriptMap::GetTileX(tile) && ScriptMap::GetTileX(tile) == ScriptMap::GetTileX(to)) || * (ScriptMap::GetTileX(from) == ScriptMap::GetTileX(tile) && ScriptMap::GetTileX(tile) == ScriptMap::GetTileX(to)) ||
* (ScriptMap::GetTileY(from) == ScriptMap::GetTileY(tile) && ScriptMap::GetTileY(tile) == ScriptMap::GetTileY(to)). * (ScriptMap::GetTileY(from) == ScriptMap::GetTileY(tile) && ScriptMap::GetTileY(tile) == ScriptMap::GetTileY(to)).
* @game @pre Valid ScriptCompanyMode active in scope. * @game @pre Valid ScriptCompanyMode active in scope.
* @exception ScriptRail::ERR_UNSUITABLE_TRACK
* @return Whether the rail has been/can be removed or not. * @return Whether the rail has been/can be removed or not.
*/ */
static bool RemoveRail(TileIndex from, TileIndex tile, TileIndex to); static bool RemoveRail(TileIndex from, TileIndex tile, TileIndex to);
@ -457,6 +464,7 @@ public:
* @pre ScriptMap::DistanceManhattan(tile, front) == 1. * @pre ScriptMap::DistanceManhattan(tile, front) == 1.
* @pre GetSignalType(tile, front) != SIGNALTYPE_NONE. * @pre GetSignalType(tile, front) != SIGNALTYPE_NONE.
* @game @pre Valid ScriptCompanyMode active in scope. * @game @pre Valid ScriptCompanyMode active in scope.
* @exception ScriptRail::ERR_UNSUITABLE_TRACK
* @return Whether the signal has been/can be removed or not. * @return Whether the signal has been/can be removed or not.
*/ */
static bool RemoveSignal(TileIndex tile, TileIndex front); static bool RemoveSignal(TileIndex tile, TileIndex front);