1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-25 11:52:40 +01:00

Fix crash starting new game

The player doesn't always exist, so we do need to check..
This commit is contained in:
Daniel Evans 2016-11-24 21:29:25 +00:00
parent c63d12b70a
commit 6ef99c0de9

View File

@ -125,22 +125,22 @@ void IngameState::tick(float dt) {
auto player = game->getPlayer();
// Force all input to 0 if player input is disabled
/// @todo verify 0ing input is the correct behaviour
const auto inputEnabled = player->isInputEnabled();
auto input = [&](GameInputState::Control c) {
return inputEnabled ? world->state->input[0][c] : 0.f;
};
auto pressed = [&](GameInputState::Control c) {
return inputEnabled && world->state->input[0].pressed(c) &&
!world->state->input[1].pressed(c);
};
auto held = [&](GameInputState::Control c) {
return inputEnabled && world->state->input[0].pressed(c);
};
if (player) {
// Force all input to 0 if player input is disabled
/// @todo verify 0ing input is the correct behaviour
const auto inputEnabled = player->isInputEnabled();
auto input = [&](GameInputState::Control c) {
return inputEnabled ? world->state->input[0][c] : 0.f;
};
auto pressed = [&](GameInputState::Control c) {
return inputEnabled && world->state->input[0].pressed(c) &&
!world->state->input[1].pressed(c);
};
auto held = [&](GameInputState::Control c) {
return inputEnabled && world->state->input[0].pressed(c);
};
float viewDistance = 4.f;
switch (camMode) {
case IngameState::CAMERA_CLOSE: