mirror of https://github.com/OpenTTD/OpenTTD
(svn r3362) Fix issue with loading old (TTD) savegames:
- move call to convert from old to new train subtypes. - ensure AI is started for AI players.release/0.4.5
parent
911a8aa08d
commit
4b464093e7
|
@ -15,6 +15,8 @@
|
||||||
#include "signs.h"
|
#include "signs.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "depot.h"
|
#include "depot.h"
|
||||||
|
#include "network.h"
|
||||||
|
#include "ai/ai.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
HEADER_SIZE = 49,
|
HEADER_SIZE = 49,
|
||||||
|
@ -1065,6 +1067,9 @@ static bool LoadOldPlayer(LoadgameState *ls, int num)
|
||||||
* to some harmless state, like 'loop vehicle'; 1 */
|
* to some harmless state, like 'loop vehicle'; 1 */
|
||||||
if (!IS_HUMAN_PLAYER(num) && p->ai.state == 20) p->ai.state = 1;
|
if (!IS_HUMAN_PLAYER(num) && p->ai.state == 20) p->ai.state = 1;
|
||||||
|
|
||||||
|
if (p->is_ai && (!_networking || _network_server) && _ai.enabled)
|
||||||
|
AI_StartNewAI(p->index);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1135,6 +1135,10 @@ bool AfterLoadGame(void)
|
||||||
// Load the sprites
|
// Load the sprites
|
||||||
GfxLoadSprites();
|
GfxLoadSprites();
|
||||||
|
|
||||||
|
/* Connect front and rear engines of multiheaded trains and converts
|
||||||
|
* subtype to the new format */
|
||||||
|
if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew();
|
||||||
|
|
||||||
// Update current year
|
// Update current year
|
||||||
SetDate(_date);
|
SetDate(_date);
|
||||||
|
|
||||||
|
|
|
@ -2252,7 +2252,7 @@ static void Save_VEHS(void)
|
||||||
* Converts all trains to the new subtype format introduced in savegame 16.2
|
* Converts all trains to the new subtype format introduced in savegame 16.2
|
||||||
* It also links multiheaded engines or make them forget they are multiheaded if no suitable partner is found
|
* It also links multiheaded engines or make them forget they are multiheaded if no suitable partner is found
|
||||||
*/
|
*/
|
||||||
static inline void ConvertOldMultiheadToNew(void)
|
void ConvertOldMultiheadToNew(void)
|
||||||
{
|
{
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
|
@ -2396,11 +2396,6 @@ static void Load_VEHS(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect front and rear engines of multiheaded trains and converts subtype to the new format */
|
|
||||||
if (CheckSavegameVersionOldStyle(17, 1)) {
|
|
||||||
ConvertOldMultiheadToNew();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChunkHandler _veh_chunk_handlers[] = {
|
const ChunkHandler _veh_chunk_handlers[] = {
|
||||||
|
|
|
@ -317,6 +317,7 @@ int32 GetTrainRunningCost(const Vehicle *v);
|
||||||
int CheckTrainStoppedInDepot(const Vehicle *v);
|
int CheckTrainStoppedInDepot(const Vehicle *v);
|
||||||
|
|
||||||
bool VehicleNeedsService(const Vehicle *v);
|
bool VehicleNeedsService(const Vehicle *v);
|
||||||
|
void ConvertOldMultiheadToNew(void);
|
||||||
|
|
||||||
typedef struct GetNewVehiclePosResult {
|
typedef struct GetNewVehiclePosResult {
|
||||||
int x,y;
|
int x,y;
|
||||||
|
|
Loading…
Reference in New Issue