mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 20:02:40 +01:00
Merge pull request #484 from husho/fixcrash
Fixed crash on new game, fixed missions not failing on death/arrest
This commit is contained in:
commit
5f85de5bd3
@ -12,14 +12,17 @@
|
|||||||
#include "script/ScriptModule.hpp"
|
#include "script/ScriptModule.hpp"
|
||||||
|
|
||||||
void ScriptMachine::executeThread(SCMThread& t, int msPassed) {
|
void ScriptMachine::executeThread(SCMThread& t, int msPassed) {
|
||||||
// @todo Add support for multiple players
|
auto& players = getState()->world->players;
|
||||||
PlayerController* player = getState()->world->players.at(0);
|
|
||||||
if (t.isMission
|
if (!players.empty()) {
|
||||||
&& t.deathOrArrestCheck
|
// @todo Add support for multiple players
|
||||||
&& (player->isWasted() || player->isBusted())) {
|
PlayerController* player = players.at(0);
|
||||||
t.wastedOrBusted = true;
|
if (t.isMission && t.deathOrArrestCheck &&
|
||||||
t.stackDepth = 0;
|
(player->isWasted() || player->isBusted())) {
|
||||||
t.programCounter = t.calls[t.stackDepth];
|
t.wastedOrBusted = true;
|
||||||
|
t.stackDepth = 0;
|
||||||
|
t.programCounter = t.calls[t.stackDepth];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.wakeCounter > 0) {
|
if (t.wakeCounter > 0) {
|
||||||
@ -180,7 +183,11 @@ void ScriptMachine::executeThread(SCMThread& t, int msPassed) {
|
|||||||
|
|
||||||
ScriptMachine::ScriptMachine(GameState* _state, SCMFile* file,
|
ScriptMachine::ScriptMachine(GameState* _state, SCMFile* file,
|
||||||
ScriptModule* ops)
|
ScriptModule* ops)
|
||||||
: file(file), module(ops), state(_state), debugFlag(false), randomNumberGen(std::random_device()()) {
|
: file(file)
|
||||||
|
, module(ops)
|
||||||
|
, state(_state)
|
||||||
|
, debugFlag(false)
|
||||||
|
, randomNumberGen(std::random_device()()) {
|
||||||
// Copy globals
|
// Copy globals
|
||||||
auto size = file->getGlobalsSize();
|
auto size = file->getGlobalsSize();
|
||||||
globalData.resize(size);
|
globalData.resize(size);
|
||||||
@ -204,7 +211,7 @@ void ScriptMachine::startThread(SCMThread::pc_t start, bool mission) {
|
|||||||
t.isMission = mission;
|
t.isMission = mission;
|
||||||
t.finished = false;
|
t.finished = false;
|
||||||
t.stackDepth = 0;
|
t.stackDepth = 0;
|
||||||
t.deathOrArrestCheck = false;
|
t.deathOrArrestCheck = true;
|
||||||
t.wastedOrBusted = false;
|
t.wastedOrBusted = false;
|
||||||
_activeThreads.push_back(t);
|
_activeThreads.push_back(t);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user