1
0
Fork 0

(svn r23051) [1.1] -Backport from trunk:

- Fix: AI backlog was to short to fully display the backtrace of some AI crashes [FS#4798] (r23012)
- Fix: When the last used server is deleted from the list also clear the last used server if it is the same [FS#4791] (r23011)
- Fix: [NewGRF] Make sure temporary storage is cleared before test and exec runs for DoCommands so NewGRF callbacks cannot change the result between the runs (r22996)
- Fix: [NewGRF] Tile was cleared before the object-placement callback was run, resulting in possible differences in test and exec run [FS#4775] (r22994)
release/1.1
rubidium 2011-10-22 20:45:19 +00:00
parent c1359d6d8a
commit 83d41e122c
4 changed files with 27 additions and 9 deletions

View File

@ -37,9 +37,9 @@
AIObject::GetLogPointer() = new LogData(); AIObject::GetLogPointer() = new LogData();
LogData *log = (LogData *)AIObject::GetLogPointer(); LogData *log = (LogData *)AIObject::GetLogPointer();
log->lines = CallocT<char *>(80); log->lines = CallocT<char *>(400);
log->type = CallocT<AILog::AILogType>(80); log->type = CallocT<AILog::AILogType>(400);
log->count = 80; log->count = 400;
log->pos = log->count - 1; log->pos = log->count - 1;
log->used = 0; log->used = 0;
} }

View File

@ -633,6 +633,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
/* Test the command. */ /* Test the command. */
_cleared_object_areas.Clear(); _cleared_object_areas.Clear();
SetTownRatingTestMode(true); SetTownRatingTestMode(true);
ClearStorageChanges(false);
res = proc(tile, flags, p1, p2, text); res = proc(tile, flags, p1, p2, text);
SetTownRatingTestMode(false); SetTownRatingTestMode(false);
@ -672,6 +673,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
/* Actually try and execute the command. If no cost-type is given /* Actually try and execute the command. If no cost-type is given
* use the construction one */ * use the construction one */
_cleared_object_areas.Clear(); _cleared_object_areas.Clear();
ClearStorageChanges(false);
CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text); CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
if (cmd_id == CMD_COMPANY_CTRL) { if (cmd_id == CMD_COMPANY_CTRL) {

View File

@ -716,9 +716,8 @@ public:
} }
case NGWW_LASTJOINED: { case NGWW_LASTJOINED: {
NetworkGameList *last_joined = NetworkGameListAddItem(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port)); if (this->last_joined != NULL) {
if (last_joined != NULL) { this->server = this->last_joined;
this->server = last_joined;
/* search the position of the newly selected server */ /* search the position of the newly selected server */
for (uint i = 0; i < this->servers.Length(); i++) { for (uint i = 0; i < this->servers.Length(); i++) {
@ -862,6 +861,7 @@ public:
if (this->server != NULL) { if (this->server != NULL) {
if (keycode == WKC_DELETE) { // Press 'delete' to remove servers if (keycode == WKC_DELETE) { // Press 'delete' to remove servers
NetworkGameListRemoveItem(this->server); NetworkGameListRemoveItem(this->server);
if (this->server == this->last_joined) this->last_joined = NULL;
this->server = NULL; this->server = NULL;
this->list_pos = SLP_INVALID; this->list_pos = SLP_INVALID;
} }

View File

@ -205,7 +205,9 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/* Owned land is special as it can be placed on any slope. */ /* Owned land is special as it can be placed on any slope. */
cost.AddCost(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR)); cost.AddCost(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR));
} else { } else {
/* Check the surface to build on. */ /* Check the surface to build on. At this time we can't actually execute the
* the CLEAR_TILE commands since the newgrf callback later on can check
* some information about the tiles. */
bool allow_water = (spec->flags & (OBJECT_FLAG_BUILT_ON_WATER | OBJECT_FLAG_NOT_ON_LAND)) != 0; bool allow_water = (spec->flags & (OBJECT_FLAG_BUILT_ON_WATER | OBJECT_FLAG_NOT_ON_LAND)) != 0;
bool allow_ground = (spec->flags & OBJECT_FLAG_NOT_ON_LAND) == 0; bool allow_ground = (spec->flags & OBJECT_FLAG_NOT_ON_LAND) == 0;
TILE_AREA_LOOP(t, ta) { TILE_AREA_LOOP(t, ta) {
@ -214,7 +216,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (!IsWaterTile(t)) { if (!IsWaterTile(t)) {
/* Normal water tiles don't have to be cleared. For all other tile types clear /* Normal water tiles don't have to be cleared. For all other tile types clear
* the tile but leave the water. */ * the tile but leave the water. */
cost.AddCost(DoCommand(t, 0, 0, flags & ~DC_NO_WATER, CMD_LANDSCAPE_CLEAR)); cost.AddCost(DoCommand(t, 0, 0, flags & ~DC_NO_WATER & ~DC_EXEC, CMD_LANDSCAPE_CLEAR));
} else { } else {
/* Can't build on water owned by another company. */ /* Can't build on water owned by another company. */
Owner o = GetTileOwner(t); Owner o = GetTileOwner(t);
@ -223,7 +225,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
} else { } else {
if (!allow_ground) return_cmd_error(STR_ERROR_MUST_BE_BUILT_ON_WATER); if (!allow_ground) return_cmd_error(STR_ERROR_MUST_BE_BUILT_ON_WATER);
/* For non-water tiles, we'll have to clear it before building. */ /* For non-water tiles, we'll have to clear it before building. */
cost.AddCost(DoCommand(t, 0, 0, flags, CMD_LANDSCAPE_CLEAR)); cost.AddCost(DoCommand(t, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR));
} }
} }
@ -244,6 +246,20 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
} }
} }
if (flags & DC_EXEC) {
/* This is basically a copy of the loop above with the exception that we now
* execute the commands and don't check for errors, since that's already done. */
TILE_AREA_LOOP(t, ta) {
if (HasTileWaterGround(t)) {
if (!IsWaterTile(t)) {
DoCommand(t, 0, 0, (flags & ~DC_NO_WATER) | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR);
}
} else {
DoCommand(t, 0, 0, flags | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR);
}
}
}
} }
if (cost.Failed()) return cost; if (cost.Failed()) return cost;