From b3b28dced23e5b9f8e44d8fb197d6510759d61b3 Mon Sep 17 00:00:00 2001 From: Darkvater Date: Sat, 24 Feb 2007 16:46:36 +0000 Subject: [PATCH] (svn r8883) [0.5] -Backport from trunk (r8740, r8793, r8865, r8878): - GCC warnings for r8738 (r8740) - Correct spelling of real french townnames and 'remove' a duplicate (r8793) - (NewGRF) Ignore 1 byte action 0s during safety check (r8865) - Stricter checks for CmdMoveRailVehicle() parameters (r8878) --- newgrf.c | 5 +++++ oldloader.c | 1 + table/namegen.h | 10 +++++----- train_cmd.c | 14 ++++++-------- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/newgrf.c b/newgrf.c index 4f8721b9ed..781ab62aaf 100644 --- a/newgrf.c +++ b/newgrf.c @@ -1479,6 +1479,11 @@ static void SafeChangeInfo(byte *buf, int len) uint8 numinfo; uint8 index; + if (len == 1) { + grfmsg(8, "Silently ignoring one-byte special sprite 0x00"); + return; + } + check_length(len, 6, "SafeChangeInfo"); buf++; feature = grf_load_byte(&buf); diff --git a/oldloader.c b/oldloader.c index 94f252df70..8c644d3155 100644 --- a/oldloader.c +++ b/oldloader.c @@ -1531,6 +1531,7 @@ static bool LoadOldMain(LoadgameState *ls) SetTileType(i, MP_CLEAR); SetTileOwner(i, OWNER_NONE); } + default: break; } break; } } diff --git a/table/namegen.h b/table/namegen.h index a5d9974d61..ef9a04b328 100644 --- a/table/namegen.h +++ b/table/namegen.h @@ -709,17 +709,17 @@ static const char *name_french_real[] = { "Bordeaux", "Bayonne", "Montpellier", - "Montelimar", + "Montélimar", "Valence", "Digne", "Nice", "Cannes", "St. Tropez", - "Marseilles", + "Marseille", "Narbonne", "Sète", "Aurillac", - "Gueret", + "Guéret", "Le Creusot", "Nevers", "Auxerre", @@ -731,7 +731,7 @@ static const char *name_french_real[] = { "Chaumont", "Langres", "Bourg", - "Lyons", + "Lyon", "Vienne", "Grenoble", "Toulon", @@ -763,7 +763,7 @@ static const char *name_french_real[] = { "Beaujolais", "Narbonne", "Albi", - "St. Valery", + "Paris", "Biarritz", "Béziers", "Nîmes", diff --git a/train_cmd.c b/train_cmd.c index 11bf9ae104..1754dd45a2 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -1004,13 +1004,15 @@ int32 CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) src = GetVehicle(s); - if (src->type != VEH_Train) return CMD_ERROR; + if (src->type != VEH_Train || !CheckOwnership(src->owner)) return CMD_ERROR; // if nothing is selected as destination, try and find a matching vehicle to drag to. if (d == INVALID_VEHICLE) { dst = IsTrainEngine(src) ? NULL : FindGoodVehiclePos(src); } else { + if (!IsValidVehicleID(d)) return CMD_ERROR; dst = GetVehicle(d); + if (dst->type != VEH_Train || !CheckOwnership(dst->owner)) return CMD_ERROR; } // if an articulated part is being handled, deal with its parent vehicle @@ -1022,17 +1024,15 @@ int32 CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) // don't move the same vehicle.. if (src == dst) return 0; - /* the player must be the owner */ - if (!CheckOwnership(src->owner) || (dst != NULL && !CheckOwnership(dst->owner))) - return CMD_ERROR; - /* locate the head of the two chains */ src_head = GetFirstVehicleInChain(src); - dst_head = NULL; if (dst != NULL) { dst_head = GetFirstVehicleInChain(dst); + if (dst_head->tile != src_head->tile) return CMD_ERROR; // Now deal with articulated part of destination wagon dst = GetLastEnginePart(dst); + } else { + dst_head = NULL; } if (dst != NULL && IsMultiheaded(dst) && !IsTrainEngine(dst) && IsTrainWagon(src)) { @@ -1089,8 +1089,6 @@ int32 CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) // check if all vehicles in the dest train are stopped. dst_len = CheckTrainStoppedInDepot(dst_head); if (dst_len < 0) return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED); - - assert(dst_head->tile == src_head->tile); } // We are moving between rows, so only count the wagons from the source