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,15 +12,18 @@
|
|||||||
#include "script/ScriptModule.hpp"
|
#include "script/ScriptModule.hpp"
|
||||||
|
|
||||||
void ScriptMachine::executeThread(SCMThread& t, int msPassed) {
|
void ScriptMachine::executeThread(SCMThread& t, int msPassed) {
|
||||||
|
auto& players = getState()->world->players;
|
||||||
|
|
||||||
|
if (!players.empty()) {
|
||||||
// @todo Add support for multiple players
|
// @todo Add support for multiple players
|
||||||
PlayerController* player = getState()->world->players.at(0);
|
PlayerController* player = players.at(0);
|
||||||
if (t.isMission
|
if (t.isMission && t.deathOrArrestCheck &&
|
||||||
&& t.deathOrArrestCheck
|
(player->isWasted() || player->isBusted())) {
|
||||||
&& (player->isWasted() || player->isBusted())) {
|
|
||||||
t.wastedOrBusted = true;
|
t.wastedOrBusted = true;
|
||||||
t.stackDepth = 0;
|
t.stackDepth = 0;
|
||||||
t.programCounter = t.calls[t.stackDepth];
|
t.programCounter = t.calls[t.stackDepth];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (t.wakeCounter > 0) {
|
if (t.wakeCounter > 0) {
|
||||||
t.wakeCounter = std::max(t.wakeCounter - msPassed, 0);
|
t.wakeCounter = std::max(t.wakeCounter - msPassed, 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