Merge branch 'template_train_replacement-sx' into jgrpp
This commit is contained in:
@@ -164,6 +164,9 @@ void GroupStatistics::Clear()
|
|||||||
*/
|
*/
|
||||||
/* static */ void GroupStatistics::CountEngine(const Vehicle *v, int delta)
|
/* static */ void GroupStatistics::CountEngine(const Vehicle *v, int delta)
|
||||||
{
|
{
|
||||||
|
/* make virtual trains group-neutral */
|
||||||
|
if (HasBit(v->subtype, GVSF_VIRTUAL)) return;
|
||||||
|
|
||||||
assert(delta == 1 || delta == -1);
|
assert(delta == 1 || delta == -1);
|
||||||
GroupStatistics::GetAllGroup(v).num_engines[v->engine_type] += delta;
|
GroupStatistics::GetAllGroup(v).num_engines[v->engine_type] += delta;
|
||||||
GroupStatistics::Get(v).num_engines[v->engine_type] += delta;
|
GroupStatistics::Get(v).num_engines[v->engine_type] += delta;
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
#include "../tbtr_template_vehicle.h"
|
#include "../tbtr_template_vehicle.h"
|
||||||
#include "../tbtr_template_vehicle_func.h"
|
#include "../tbtr_template_vehicle_func.h"
|
||||||
#include "../train.h"
|
#include "../train.h"
|
||||||
|
#include "../core/backup_type.hpp"
|
||||||
|
#include "../core/random_func.hpp"
|
||||||
|
|
||||||
#include "saveload.h"
|
#include "saveload.h"
|
||||||
|
|
||||||
@@ -100,8 +102,12 @@ void AfterLoadTemplateVehiclesUpdateImage()
|
|||||||
{
|
{
|
||||||
TemplateVehicle *tv;
|
TemplateVehicle *tv;
|
||||||
|
|
||||||
|
SavedRandomSeeds saved_seeds;
|
||||||
|
SaveRandomSeeds(&saved_seeds);
|
||||||
|
|
||||||
FOR_ALL_TEMPLATES(tv) {
|
FOR_ALL_TEMPLATES(tv) {
|
||||||
if (tv->Prev() == NULL) {
|
if (tv->Prev() == NULL) {
|
||||||
|
Backup<CompanyByte> cur_company(_current_company, tv->owner, FILE_LINE);
|
||||||
StringID err;
|
StringID err;
|
||||||
Train* t = VirtualTrainFromTemplateVehicle(tv, err);
|
Train* t = VirtualTrainFromTemplateVehicle(tv, err);
|
||||||
if (t != NULL) {
|
if (t != NULL) {
|
||||||
@@ -123,8 +129,11 @@ void AfterLoadTemplateVehiclesUpdateImage()
|
|||||||
}
|
}
|
||||||
delete t;
|
delete t;
|
||||||
}
|
}
|
||||||
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RestoreRandomSeeds(saved_seeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern const ChunkHandler _template_vehicle_chunk_handlers[] = {
|
extern const ChunkHandler _template_vehicle_chunk_handlers[] = {
|
||||||
|
@@ -732,6 +732,7 @@ uint CountVehiclesInChain(const Vehicle *v)
|
|||||||
*/
|
*/
|
||||||
bool Vehicle::IsEngineCountable() const
|
bool Vehicle::IsEngineCountable() const
|
||||||
{
|
{
|
||||||
|
if (HasBit(this->subtype, GVSF_VIRTUAL)) return false;
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
case VEH_AIRCRAFT: return Aircraft::From(this)->IsNormalAircraft(); // don't count plane shadows and helicopter rotors
|
case VEH_AIRCRAFT: return Aircraft::From(this)->IsNormalAircraft(); // don't count plane shadows and helicopter rotors
|
||||||
case VEH_TRAIN:
|
case VEH_TRAIN:
|
||||||
|
@@ -960,6 +960,10 @@ CommandCost CmdVirtualTrainFromTemplateVehicle(TileIndex tile, DoCommandFlag fla
|
|||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tv->owner != _current_company) {
|
||||||
|
return CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
bool should_execute = (flags & DC_EXEC) != 0;
|
bool should_execute = (flags & DC_EXEC) != 0;
|
||||||
|
|
||||||
if (should_execute) {
|
if (should_execute) {
|
||||||
@@ -981,6 +985,8 @@ Train* VirtualTrainFromTemplateVehicle(TemplateVehicle* tv, StringID &err)
|
|||||||
CommandCost c;
|
CommandCost c;
|
||||||
Train *tmp, *head, *tail;
|
Train *tmp, *head, *tail;
|
||||||
|
|
||||||
|
assert(tv->owner == _current_company);
|
||||||
|
|
||||||
head = CmdBuildVirtualRailVehicle(tv->engine_type, true, err);
|
head = CmdBuildVirtualRailVehicle(tv->engine_type, true, err);
|
||||||
if (!head) return NULL;
|
if (!head) return NULL;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user