diff --git a/rwengine/src/engine/Animator.cpp b/rwengine/src/engine/Animator.cpp index 34c870d1..f0ecb375 100644 --- a/rwengine/src/engine/Animator.cpp +++ b/rwengine/src/engine/Animator.cpp @@ -41,6 +41,8 @@ void Animator::tick(float dt) } } + state.time = state.time + dt; + float animTime = state.time; if (! state.repeat) { @@ -84,7 +86,6 @@ void Animator::tick(float dt) blendFrames[b.second.frameIndex] = xform; #endif } - state.time = state.time + dt; } for (auto& p : blendFrames) diff --git a/tests/test_animation.cpp b/tests/test_animation.cpp index 8ad8204c..b39f12d3 100644 --- a/tests/test_animation.cpp +++ b/tests/test_animation.cpp @@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(test_matrix) } }; - animator.playAnimation(0, &animation, 1.f, true); + animator.playAnimation(0, &animation, 1.f, false); animator.tick(0.0f); diff --git a/tests/test_character.cpp b/tests/test_character.cpp index f824028d..6af0c37e 100644 --- a/tests/test_character.cpp +++ b/tests/test_character.cpp @@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(test_create) BOOST_AUTO_TEST_CASE(test_activities) { { - auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f}); + auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 225.6f}); BOOST_REQUIRE( character != nullptr ); diff --git a/tests/test_globals.hpp b/tests/test_globals.hpp index b381b79d..8b85b907 100644 --- a/tests/test_globals.hpp +++ b/tests/test_globals.hpp @@ -45,13 +45,15 @@ public: Global() { wnd.create(sf::VideoMode(640, 360), "Testing"); d = new GameData(&log, &work, getGamePath()); + + d->loadIMG("/models/gta3"); + d->loadIMG("/anim/cuts"); + d->load(); + e = new GameWorld(&log, &work, d); s = new GameState; e->state = s; - e->data->loadIMG("/models/gta3"); - e->data->loadIMG("/anim/cuts"); - e->data->load(); for(std::map::iterator it = e->data->ideLocations.begin(); it != e->data->ideLocations.end(); ++it) { diff --git a/tests/test_items.cpp b/tests/test_items.cpp index bae2f44a..0813165c 100644 --- a/tests/test_items.cpp +++ b/tests/test_items.cpp @@ -11,18 +11,23 @@ BOOST_AUTO_TEST_CASE(test_character_inventory) BOOST_REQUIRE( character != nullptr ); auto item = Global::get().e->getInventoryItem(4); + auto fist = Global::get().e->getInventoryItem(0); BOOST_REQUIRE(item != nullptr); + BOOST_REQUIRE(fist != nullptr ); + BOOST_CHECK_NE( fist, item ); character->addToInventory(item); + BOOST_CHECK_EQUAL( character->getActiveItem(), fist ); + character->setActiveItem( item->getInventorySlot() ); BOOST_CHECK_EQUAL( character->getActiveItem(), item ); character->removeFromInventory( item->getInventorySlot() ); - BOOST_CHECK_EQUAL( character->getActiveItem(), nullptr ); + BOOST_CHECK_EQUAL( character->getActiveItem(), fist ); Global::get().e->destroyObject(character); } diff --git a/tests/test_renderer.cpp b/tests/test_renderer.cpp index 109a04b9..4c70f62d 100644 --- a/tests/test_renderer.cpp +++ b/tests/test_renderer.cpp @@ -11,13 +11,17 @@ BOOST_AUTO_TEST_CASE(frustum_test_visible) f.update(f.projection()); - BOOST_CHECK( f.intersects({10.f, 0.f, 0.f}, 1.f ) ); - BOOST_CHECK(!f.intersects({-10.f, 0.f, 0.f}, 1.f ) ); + BOOST_CHECK( f.intersects({10.f, 0.f,-10.f}, 1.f ) ); + BOOST_CHECK(!f.intersects({ 0.f, 0.f, 10.f}, 1.f ) ); BOOST_CHECK(!f.intersects({0.f, 10.f, 0.f}, 1.f ) ); BOOST_CHECK(!f.intersects({0.f,-10.f, 0.f}, 1.f ) ); - BOOST_CHECK( f.intersects({10.f, 10.f, 0.f}, 1.f ) ); + BOOST_CHECK(!f.intersects({ 10.f, 0.f, 0.f}, 1.f ) ); + BOOST_CHECK(!f.intersects({-10.f, 0.f, 0.f}, 1.f ) ); + + BOOST_CHECK( f.intersects({ 10.f, 0.f,-10.f}, 1.f ) ); + BOOST_CHECK( f.intersects({-10.f, 0.f,-10.f}, 1.f ) ); } } diff --git a/tests/test_trafficdirector.cpp b/tests/test_trafficdirector.cpp index d4a0e8ea..c2fa89f2 100644 --- a/tests/test_trafficdirector.cpp +++ b/tests/test_trafficdirector.cpp @@ -76,13 +76,12 @@ BOOST_AUTO_TEST_CASE(test_available_nodes) {-10.f, 0.f, 0.f } }; + BOOST_REQUIRE(expected.size() == 3); BOOST_ASSERT( expected.size() == open.size() ); - auto left = open.begin(); - auto right = expected.begin(); - for ( ; left != open.end() && right != expected.end(); ++left, ++right ) - { - BOOST_CHECK( ! ( *left != *right ) ); + for (auto& v : expected) { + BOOST_CHECK(std::find_if(open.begin(), open.end(), + [v](AIGraphNode* n) { return n->position == v; }) != open.end()); } } diff --git a/tests/test_weapon.cpp b/tests/test_weapon.cpp index b05e449c..cffd6fa1 100644 --- a/tests/test_weapon.cpp +++ b/tests/test_weapon.cpp @@ -51,7 +51,8 @@ BOOST_AUTO_TEST_CASE(TestProjectile) projectile->tick(0.016f); } - BOOST_CHECK_LT( glm::distance(character->getPosition(), projectile->getPosition()), 1.f ); + BOOST_CHECK_LT( glm::distance(character->getPosition(), projectile->getPosition()), 10.f ); + BOOST_CHECK_LT( glm::distance(character->getPosition(), projectile->getPosition()), 5.f ); // Grenade should have dentonated by this point BOOST_CHECK( character->getCurrentState().health < 100.f );