1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-09 20:32:43 +01:00

Restore vehicle generators from save data

This commit is contained in:
Daniel Evans 2016-06-26 05:09:48 +01:00 committed by Daniel Evans
parent 45103c3440
commit d2ec218f89
3 changed files with 68 additions and 15 deletions

View File

@ -1,5 +1,6 @@
#ifndef RWENGINE_VEHICLEGENERATOR_HPP
#define RWENGINE_VEHICLEGENERATOR_HPP
#include <glm/glm.hpp>
/**
* Stores information about where the game can generate vehicles.
@ -30,6 +31,32 @@ struct VehicleGenerator
* Intentionally disabled to match behaviour
*/
int remainingSpawns;
VehicleGenerator(const glm::vec3& position_,
float heading_,
int modelID_,
int colourFG_,
int colourBG_,
bool alwaysSpawn_,
short alarmThreshold_,
short lockedThreshold_,
int minDelay_,
int maxDelay_,
int lastSpawnTime_,
int remainingSpawns_)
: position(position_)
, heading(heading_)
, vehicleID(modelID_)
, colourFG(colourFG_)
, colourBG(colourBG_)
, alwaysSpawn(alwaysSpawn_)
, alarmThreshold(alarmThreshold_)
, lockedThreshold(lockedThreshold_)
, minDelay(minDelay_)
, maxDelay(maxDelay_)
, lastSpawnTime(lastSpawnTime_)
, remainingSpawns(remainingSpawns_)
{}
};
#endif

View File

@ -1189,6 +1189,24 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
vehicle->setSecondaryColour(car.colorBG);
}
for (unsigned g = 0; g < carGenerators.size(); ++g) {
auto& gen = carGenerators[g];
state.vehicleGenerators.emplace_back(
gen.position,
gen.angle,
gen.modelId,
gen.colourFG,
gen.colourBG,
gen.force,
gen.alarmChance,
gen.lockedChance,
gen.minDelay,
gen.maxDelay,
gen.timestamp,
101 /// @todo determine where the remainingSpawns should be
);
}
// Load import / export lists
state.importExportPortland = garageData.bfImportExportPortland;
state.importExportShoreside = garageData.bfImportExportShoreside;

View File

@ -113,21 +113,29 @@ void game_create_vehicle_generator(const ScriptArguments& args)
return;
}
VehicleGenerator vg;
vg.position = position;
vg.heading = args[3].real;
vg.vehicleID = args[4].integer;
vg.colourFG = args[5].integer;
vg.colourBG = args[6].integer;
vg.alwaysSpawn = args[7].integer != 0;
vg.alarmThreshold = args[8].integer;
vg.lockedThreshold = args[9].integer;
vg.minDelay = args[10].integer;
vg.maxDelay = args[11].integer;
vg.lastSpawnTime = 0;
vg.remainingSpawns = 0;
float heading = args[3].real;
int vehicleID = args[4].integer;
int colourFG = args[5].integer;
int colourBG = args[6].integer;
bool alwaysSpawn = args[7].integer != 0;
short alarmThreshold = args[8].integer;
short lockedThreshold = args[9].integer;
int minDelay = args[10].integer;
int maxDelay = args[11].integer;
VehicleGenerator vg{position,
heading,
vehicleID,
colourFG,
colourBG,
alwaysSpawn,
alarmThreshold,
lockedThreshold,
minDelay,
maxDelay,
0,
0};
*args[12].globalInteger = args.getWorld()->state->vehicleGenerators.size();
args.getWorld()->state->vehicleGenerators.push_back(vg);