2014-06-26 18:55:17 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <data/WeaponData.hpp>
|
2014-09-13 04:29:32 +02:00
|
|
|
#include <loaders/GenericDATLoader.hpp>
|
2016-09-11 18:09:54 +02:00
|
|
|
#include <objects/PickupObject.hpp>
|
|
|
|
#include <objects/InstanceObject.hpp>
|
2017-10-26 03:51:24 +02:00
|
|
|
#include "test_Globals.hpp"
|
2014-06-26 18:55:17 +02:00
|
|
|
|
|
|
|
// Tests against loading various data files
|
|
|
|
// These tests are bad but so are the interfaces so it cancels out.
|
|
|
|
|
2019-01-18 02:29:59 +01:00
|
|
|
BOOST_AUTO_TEST_SUITE(DataTests, DATA_TEST_PREDICATE)
|
2014-06-26 18:55:17 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_weapon_dat) {
|
|
|
|
GenericDATLoader l;
|
2018-11-08 00:26:38 +01:00
|
|
|
std::vector<WeaponData> weaponData;
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
l.loadWeapons(Global::get().getGamePath() + "/data/weapon.dat", weaponData);
|
|
|
|
|
|
|
|
BOOST_ASSERT(weaponData.size() > 0);
|
|
|
|
|
2018-11-08 00:26:38 +01:00
|
|
|
const auto& data = weaponData.front();
|
|
|
|
|
|
|
|
BOOST_CHECK(data.fireType == WeaponData::MELEE);
|
|
|
|
BOOST_CHECK(data.hitRange == 2.8f);
|
|
|
|
BOOST_CHECK(data.fireRate == 750);
|
|
|
|
BOOST_CHECK(data.reloadMS == 300);
|
|
|
|
BOOST_CHECK(data.clipSize == 1000);
|
|
|
|
BOOST_CHECK(data.damage == 8);
|
|
|
|
BOOST_CHECK(data.speed == -1.f);
|
|
|
|
BOOST_CHECK(data.meleeRadius == 0.5f);
|
|
|
|
BOOST_CHECK(data.lifeSpan == -1.0f);
|
|
|
|
BOOST_CHECK(data.spread == -1.0f);
|
|
|
|
BOOST_CHECK(data.fireOffset == glm::vec3(0.1f, 0.65f, 0.2f));
|
|
|
|
BOOST_CHECK(data.animation1 == "fightppunch");
|
|
|
|
BOOST_CHECK(data.animation2 == "kick_floor");
|
|
|
|
BOOST_CHECK(data.animLoopStart == 0);
|
|
|
|
BOOST_CHECK(data.animLoopEnd == 99);
|
|
|
|
BOOST_CHECK(data.animFirePoint == 12);
|
|
|
|
BOOST_CHECK(data.animCrouchFirePoint == 12);
|
|
|
|
BOOST_CHECK(data.modelID == -1);
|
|
|
|
BOOST_CHECK(data.flags == 0);
|
2014-09-13 04:29:32 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_dynamic_dat_loader) {
|
|
|
|
GenericDATLoader l;
|
2018-11-08 11:57:56 +01:00
|
|
|
std::unordered_map<std::string, DynamicObjectData> dynamicObjects;
|
2014-09-13 04:29:32 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
l.loadDynamicObjects(Global::get().getGamePath() + "/data/object.dat",
|
2018-11-08 11:57:56 +01:00
|
|
|
dynamicObjects);
|
2014-09-13 04:29:32 +02:00
|
|
|
|
2018-11-08 11:57:56 +01:00
|
|
|
BOOST_ASSERT(!dynamicObjects.empty());
|
|
|
|
|
|
|
|
BOOST_ASSERT(dynamicObjects.find("wastebin") != dynamicObjects.end());
|
|
|
|
BOOST_ASSERT(dynamicObjects.find("lamppost1") != dynamicObjects.end());
|
|
|
|
|
|
|
|
auto lamp = dynamicObjects.at("lamppost1");
|
2014-09-13 04:29:32 +02:00
|
|
|
|
2018-11-08 11:57:56 +01:00
|
|
|
BOOST_CHECK_EQUAL(lamp.mass, 600.0);
|
|
|
|
BOOST_CHECK_EQUAL(lamp.turnMass, 4000.0);
|
|
|
|
BOOST_CHECK_CLOSE(lamp.airRes, 0.99, 1.0);
|
|
|
|
BOOST_CHECK_CLOSE(lamp.elasticity, 0.05, 0.01);
|
|
|
|
BOOST_CHECK_EQUAL(lamp.buoyancy, 50.0);
|
|
|
|
BOOST_CHECK_EQUAL(lamp.uprootForce, 400);
|
|
|
|
BOOST_CHECK_EQUAL(lamp.collDamageMulti, 1.0);
|
|
|
|
BOOST_CHECK_EQUAL(lamp.collDamageEffect, 1);
|
|
|
|
BOOST_CHECK_EQUAL(lamp.collResponseFlags, 1);
|
|
|
|
BOOST_CHECK_EQUAL(lamp.cameraAvoid, false);
|
2014-09-13 04:29:32 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_handling_data_loader) {
|
|
|
|
GenericDATLoader l;
|
2018-11-08 15:01:59 +01:00
|
|
|
std::unordered_map<std::string, VehicleInfo> vehicleInfos;
|
2014-09-13 04:29:32 +02:00
|
|
|
|
2018-11-08 15:01:59 +01:00
|
|
|
l.loadHandling(Global::get().getGamePath() + "/data/handling.cfg", vehicleInfos);
|
2014-09-13 04:29:32 +02:00
|
|
|
|
2018-11-08 15:01:59 +01:00
|
|
|
BOOST_ASSERT(!vehicleInfos.empty());
|
|
|
|
BOOST_ASSERT(vehicleInfos.find("STINGER") != vehicleInfos.end());
|
2014-09-13 04:29:32 +02:00
|
|
|
|
2018-11-08 15:01:59 +01:00
|
|
|
auto info = vehicleInfos.find("STINGER");
|
|
|
|
const auto& handling = info->second.handling;
|
2014-09-13 04:29:32 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_CHECK_EQUAL(handling.mass, 1000.0);
|
|
|
|
BOOST_CHECK_EQUAL(handling.flags, 0xA182);
|
|
|
|
BOOST_CHECK_EQUAL(handling.driveType, VehicleHandlingInfo::All);
|
|
|
|
BOOST_CHECK_EQUAL(handling.engineType, VehicleHandlingInfo::Petrol);
|
2014-06-26 18:55:17 +02:00
|
|
|
}
|
2016-09-11 15:46:23 +02:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_model_files_loaded) {
|
|
|
|
auto& d = Global::get().d;
|
|
|
|
|
|
|
|
// The weapon models should be associated by the MODELFILE entries
|
|
|
|
auto ak47 = d->findModelInfo<SimpleModelInfo>(171);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(ak47->name, "ak47");
|
|
|
|
BOOST_CHECK_NE(ak47->getAtomic(0), nullptr);
|
|
|
|
}
|
2016-09-11 18:09:54 +02:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_model_archive_loaded) {
|
|
|
|
auto& d = Global::get().d;
|
|
|
|
auto& e = Global::get().e;
|
|
|
|
|
|
|
|
/// @todo Implement streaming
|
|
|
|
// Currently, instanciating an entity will load the model
|
|
|
|
{
|
|
|
|
auto crim = d->findModelInfo<PedModelInfo>(24);
|
|
|
|
auto pickup = e->createPickup({}, 24, PickupObject::InShop);
|
|
|
|
|
|
|
|
BOOST_REQUIRE(crim->type() == ModelDataType::PedInfo);
|
|
|
|
BOOST_CHECK_NE(crim->getModel(), nullptr);
|
|
|
|
|
|
|
|
e->destroyObject(pickup);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto info = d->findModelInfo<SimpleModelInfo>(2202);
|
|
|
|
auto inst = e->createInstance(2202, {});
|
|
|
|
|
|
|
|
BOOST_REQUIRE(info->type() == ModelDataType::SimpleInfo);
|
|
|
|
BOOST_CHECK_NE(info->getAtomic(0), nullptr);
|
|
|
|
|
|
|
|
e->destroyObject(inst);
|
|
|
|
}
|
|
|
|
}
|
2014-06-26 18:55:17 +02:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|