(svn r25991) [1.3] -Backport from trunk:

- Fix: Temporary persistent storage modifications, e.g. command tests or those from GUI, were not properly reset, creating the possibility of desyncs [FS#5772] (r25956)
- Fix: Train's 'force proceed' status gets reset when the track on the other side of the tile has a signal [FS#5723] (r25955)
- Fix: Wrong signal conversions for savegames from before 0.4.5 [FS#5731, FS#5732] (r25954, r25953)
- Fix: Do not skip numbers when skipping spaces and other sorting 'improving' characters [FS#5719] (r25952)
This commit is contained in:
rubidium 2013-11-13 22:00:46 +00:00
parent a4551ff5ac
commit 3e445b2a6d
4 changed files with 18 additions and 10 deletions

View File

@ -84,7 +84,7 @@ struct PersistentStorageArray : BaseStorageArray {
if (this->storage[pos] == value) return;
/* We do not have made a backup; lets do so */
if (this->prev_storage != NULL) {
if (this->prev_storage == NULL) {
this->prev_storage = MallocT<TYPE>(SIZE);
memcpy(this->prev_storage, this->storage, sizeof(this->storage));
@ -121,6 +121,7 @@ struct PersistentStorageArray : BaseStorageArray {
memcpy(this->storage, this->prev_storage, sizeof(this->storage));
}
free(this->prev_storage);
this->prev_storage = NULL;
}
};

View File

@ -1196,11 +1196,15 @@ bool AfterLoadGame()
switch (GetTileType(t)) {
case MP_RAILWAY:
if (HasSignals(t)) {
/* Original signal type/variant was stored in m4 but since saveload
* version 48 they are in m2. The bits has been already moved to m2
* (see the code somewhere above) so don't use m4, use m2 instead. */
/* convert PBS signals to combo-signals */
if (HasBit(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO);
if (HasBit(_m[t].m2, 2)) SB(_m[t].m2, 0, 2, SIGTYPE_COMBO);
/* move the signal variant back */
SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
SB(_m[t].m2, 2, 1, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
ClrBit(_m[t].m2, 3);
}
@ -1480,13 +1484,15 @@ bool AfterLoadGame()
}
if (IsSavegameVersionBefore(64)) {
/* copy the signal type/variant and move signal states bits */
/* Since now we allow different signal types and variants on a single tile.
* Move signal states to m4 to make room and clone the signal type/variant. */
for (TileIndex t = 0; t < map_size; t++) {
if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) {
/* move signal states */
SetSignalStates(t, GB(_m[t].m2, 4, 4));
SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X));
SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X));
ClrBit(_m[t].m2, 7);
SB(_m[t].m2, 4, 4, 0);
/* clone signal type and variant */
SB(_m[t].m2, 4, 3, GB(_m[t].m2, 0, 3));
}
}
}

View File

@ -608,7 +608,7 @@ char *strcasestr(const char *haystack, const char *needle)
*/
static const char *SkipGarbage(const char *str)
{
while (*str != '\0' && (*str < 'A' || IsInsideMM(*str, '[', '`' + 1) || IsInsideMM(*str, '{', '~' + 1))) str++;
while (*str != '\0' && (*str < '0' || IsInsideMM(*str, ';', '@' + 1) || IsInsideMM(*str, '[', '`' + 1) || IsInsideMM(*str, '{', '~' + 1))) str++;
return str;
}

View File

@ -3139,8 +3139,9 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
* this to one, then if we reach the next signal it is
* decreased to zero and we won't pass that new signal. */
Trackdir dir = FindFirstTrackdir(trackdirbits);
if (GetSignalType(gp.new_tile, TrackdirToTrack(dir)) != SIGTYPE_PBS ||
!HasSignalOnTrackdir(gp.new_tile, ReverseTrackdir(dir))) {
if (HasSignalOnTrackdir(gp.new_tile, dir) ||
(HasSignalOnTrackdir(gp.new_tile, ReverseTrackdir(dir)) &&
GetSignalType(gp.new_tile, TrackdirToTrack(dir)) != SIGTYPE_PBS)) {
/* However, we do not want to be stopped by PBS signals
* entered via the back. */
v->force_proceed = (v->force_proceed == TFP_SIGNAL) ? TFP_STUCK : TFP_NONE;