mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 02:12:45 +01:00
Fixed: tests weren't working
Fixed: mission timer Timer was going crazy due to missing 02d9 opcode, update timer 25 times per second Fixed: mission timer Don't beep on every timer update
This commit is contained in:
parent
363840396a
commit
f9fc588d64
@ -314,7 +314,7 @@ bool ItemPickup::onPlayerTouch() {
|
||||
totalRounds /= 5;
|
||||
}
|
||||
|
||||
const auto& character = engine->getPlayer()->getCharacter();
|
||||
auto character = engine->getPlayer()->getCharacter();
|
||||
|
||||
character->addToInventory(item->inventorySlot, totalRounds);
|
||||
|
||||
@ -353,7 +353,7 @@ HealthPickup::HealthPickup(GameWorld* world, const glm::vec3& position,
|
||||
}
|
||||
|
||||
bool HealthPickup::onPlayerTouch() {
|
||||
const auto& character = engine->getPlayer()->getCharacter();
|
||||
auto character = engine->getPlayer()->getCharacter();
|
||||
|
||||
if (character->getCurrentState().health >= 100.f) {
|
||||
return false;
|
||||
@ -370,7 +370,7 @@ ArmourPickup::ArmourPickup(GameWorld* world, const glm::vec3& position,
|
||||
}
|
||||
|
||||
bool ArmourPickup::onPlayerTouch() {
|
||||
const auto& character = engine->getPlayer()->getCharacter();
|
||||
auto character = engine->getPlayer()->getCharacter();
|
||||
|
||||
if (character->getCurrentState().armour >= 100.f) {
|
||||
return false;
|
||||
@ -388,7 +388,7 @@ CollectablePickup::CollectablePickup(GameWorld* world,
|
||||
}
|
||||
|
||||
bool CollectablePickup::onPlayerTouch() {
|
||||
const auto& state = engine->state;
|
||||
auto state = engine->state;
|
||||
|
||||
if (state->playerInfo.hiddenPackagesCollected ==
|
||||
state->playerInfo.hiddenPackageCount) {
|
||||
|
@ -7685,8 +7685,7 @@ bool opcode_02d8(const ScriptArguments& args, const ScriptCharacter character, c
|
||||
opcode 02d9
|
||||
*/
|
||||
void opcode_02d9(const ScriptArguments& args) {
|
||||
RW_UNIMPLEMENTED_OPCODE(0x02d9);
|
||||
RW_UNUSED(args);
|
||||
args.getState()->bigNVeinyPickupsCollected = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -482,6 +482,7 @@ void RWGame::tick(float dt) {
|
||||
|
||||
static float clockAccumulator = 0.f;
|
||||
static float scriptTimerAccumulator = 0.f;
|
||||
static ScriptInt beepTime = std::numeric_limits<ScriptInt>::max();
|
||||
if (currState->shouldWorldUpdate()) {
|
||||
world->chase.update(dt);
|
||||
|
||||
@ -503,19 +504,25 @@ void RWGame::tick(float dt) {
|
||||
clockAccumulator -= 1.f;
|
||||
}
|
||||
|
||||
constexpr float timerClockRate = 1.f / 30.f;
|
||||
|
||||
if (state.scriptTimerVariable && !state.scriptTimerPaused) {
|
||||
scriptTimerAccumulator += dt;
|
||||
while (scriptTimerAccumulator >= 1.f) {
|
||||
(*state.scriptTimerVariable) -= 1000;
|
||||
while (scriptTimerAccumulator >= timerClockRate) {
|
||||
// Original game uses milliseconds
|
||||
(*state.scriptTimerVariable) -= timerClockRate * 1000;
|
||||
if (*state.scriptTimerVariable <= 0) {
|
||||
(*state.scriptTimerVariable) = 0;
|
||||
state.scriptTimerVariable = nullptr;
|
||||
}
|
||||
// 11 seconds
|
||||
if (*state.scriptTimerVariable <= 11000) {
|
||||
if (*state.scriptTimerVariable <= 11000 &&
|
||||
beepTime - *state.scriptTimerVariable >= 1000) {
|
||||
beepTime = *state.scriptTimerVariable;
|
||||
|
||||
// @todo beep
|
||||
}
|
||||
scriptTimerAccumulator -= 1.f;
|
||||
scriptTimerAccumulator -= timerClockRate;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ public:
|
||||
OnStreet) {
|
||||
}
|
||||
|
||||
bool onCharacterTouch(CharacterObject*) {
|
||||
bool onPlayerTouch() {
|
||||
picked_up = true;
|
||||
return true;
|
||||
}
|
||||
@ -24,9 +24,11 @@ BOOST_AUTO_TEST_SUITE(PickupTests)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_pickup_interaction) {
|
||||
{
|
||||
auto objectID = 9999;
|
||||
auto character =
|
||||
Global::get().e->createPedestrian(1, {30.1f, 0.f, 0.f});
|
||||
Global::get().e->createPlayer({30.1f, 0.f, 0.f}, {1.f, 0.f, 0.f, 0.f}, objectID);
|
||||
BOOST_REQUIRE(character != nullptr);
|
||||
Global::get().e->state->playerObject = objectID;
|
||||
|
||||
TestPickup* p = new TestPickup(Global::get().e, {30.f, 0.f, 0.f});
|
||||
|
||||
@ -60,9 +62,11 @@ BOOST_AUTO_TEST_CASE(test_pickup_interaction) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_item_pickup) {
|
||||
{
|
||||
auto objectID = 9999;
|
||||
auto character =
|
||||
Global::get().e->createPedestrian(1, {30.1f, 0.f, 0.f});
|
||||
Global::get().e->createPlayer({30.1f, 0.f, 0.f}, {1.f, 0.f, 0.f, 0.f}, objectID);
|
||||
BOOST_REQUIRE(character != nullptr);
|
||||
Global::get().e->state->playerObject = objectID;
|
||||
|
||||
auto pistol = Global::get().d->weaponData[1].get();
|
||||
auto model = Global::get().d->modelinfo[pistol->modelID].get();
|
||||
|
Loading…
Reference in New Issue
Block a user