mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-17 03:37:08 -06:00
Compare commits
5 Commits
fix_gravit
...
AddEntityS
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f76d28584e | ||
|
|
0779f33c2e | ||
|
|
2b1edfa7e5 | ||
|
|
972db85dbf | ||
|
|
7321382fe2 |
@@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
void ConstructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, bool skipChecks = false);
|
void ConstructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, bool skipChecks = false);
|
||||||
void DestructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
void DestructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
void SerializeEntity(Entity* entity);
|
virtual void SerializeEntity(Entity* entity);
|
||||||
|
|
||||||
void ConstructAllEntities(const SystemAddress& sysAddr);
|
void ConstructAllEntities(const SystemAddress& sysAddr);
|
||||||
void DestructAllEntities(const SystemAddress& sysAddr);
|
void DestructAllEntities(const SystemAddress& sysAddr);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp"
|
set(DGAME_DCOMPONENTS_SOURCES
|
||||||
|
"BaseCombatAIComponent.cpp"
|
||||||
"BouncerComponent.cpp"
|
"BouncerComponent.cpp"
|
||||||
"BuffComponent.cpp"
|
"BuffComponent.cpp"
|
||||||
"BuildBorderComponent.cpp"
|
"BuildBorderComponent.cpp"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ CharacterComponent::CharacterComponent(Entity* parent, Character* character) : C
|
|||||||
m_DirtySocialInfo = false;
|
m_DirtySocialInfo = false;
|
||||||
|
|
||||||
m_PvpEnabled = false;
|
m_PvpEnabled = false;
|
||||||
m_GMLevel = character->GetGMLevel();
|
m_GMLevel = character != nullptr ? character->GetGMLevel() : eGameMasterLevel::CIVILIAN;
|
||||||
|
|
||||||
m_EditorEnabled = false;
|
m_EditorEnabled = false;
|
||||||
m_EditorLevel = m_GMLevel;
|
m_EditorLevel = m_GMLevel;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "GameMessages.h"
|
#include "GameMessages.h"
|
||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
|
#include "PropertySelectQueryProperty.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the launch pad that's used to select and browse properties
|
* Represents the launch pad that's used to select and browse properties
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
set(DGAMETEST_SOURCES
|
set(DGAMETEST_SOURCES
|
||||||
|
"EntityTests.cpp"
|
||||||
"GameDependencies.cpp"
|
"GameDependencies.cpp"
|
||||||
|
"EntityTests.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(dComponentsTests)
|
add_subdirectory(dComponentsTests)
|
||||||
@@ -13,7 +15,7 @@ file(COPY ${GAMEMESSAGE_TESTBITSTREAMS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
|||||||
# Add the executable. Remember to add all tests above this!
|
# Add the executable. Remember to add all tests above this!
|
||||||
add_executable(dGameTests ${DGAMETEST_SOURCES})
|
add_executable(dGameTests ${DGAMETEST_SOURCES})
|
||||||
|
|
||||||
target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main dGame dZoneManager dPhysics Detour Recast tinyxml2 dWorldServer dChatFilter dNavigation)
|
target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main GTest::gmock dGame dZoneManager dPhysics Detour Recast tinyxml2 dWorldServer dChatFilter dNavigation)
|
||||||
|
|
||||||
# Discover the tests
|
# Discover the tests
|
||||||
gtest_discover_tests(dGameTests)
|
gtest_discover_tests(dGameTests)
|
||||||
|
|||||||
250
tests/dGameTests/EntityTests.cpp
Normal file
250
tests/dGameTests/EntityTests.cpp
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
#include "GameDependencies.h"
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "BaseCombatAIComponent.h"
|
||||||
|
#include "BouncerComponent.h"
|
||||||
|
#include "BuffComponent.h"
|
||||||
|
#include "BuildBorderComponent.h"
|
||||||
|
#include "CharacterComponent.h"
|
||||||
|
#include "Component.h"
|
||||||
|
#include "ControllablePhysicsComponent.h"
|
||||||
|
#include "DestroyableComponent.h"
|
||||||
|
#include "InventoryComponent.h"
|
||||||
|
#include "LevelProgressionComponent.h"
|
||||||
|
#include "LUPExhibitComponent.h"
|
||||||
|
#include "MissionComponent.h"
|
||||||
|
#include "MissionOfferComponent.h"
|
||||||
|
#include "ModelComponent.h"
|
||||||
|
#include "ModuleAssemblyComponent.h"
|
||||||
|
#include "MovementAIComponent.h"
|
||||||
|
#include "MovingPlatformComponent.h"
|
||||||
|
#include "PetComponent.h"
|
||||||
|
#include "PhantomPhysicsComponent.h"
|
||||||
|
#include "PlayerForcedMovementComponent.h"
|
||||||
|
#include "PossessableComponent.h"
|
||||||
|
#include "PossessorComponent.h"
|
||||||
|
#include "PropertyComponent.h"
|
||||||
|
#include "PropertyEntranceComponent.h"
|
||||||
|
#include "PropertyManagementComponent.h"
|
||||||
|
#include "PropertyVendorComponent.h"
|
||||||
|
#include "ProximityMonitorComponent.h"
|
||||||
|
#include "RacingControlComponent.h"
|
||||||
|
#include "RailActivatorComponent.h"
|
||||||
|
#include "RebuildComponent.h"
|
||||||
|
#include "RenderComponent.h"
|
||||||
|
#include "RigidbodyPhantomPhysicsComponent.h"
|
||||||
|
#include "RocketLaunchLupComponent.h"
|
||||||
|
#include "RocketLaunchpadControlComponent.h"
|
||||||
|
#include "ScriptedActivityComponent.h"
|
||||||
|
#include "ShootingGalleryComponent.h"
|
||||||
|
#include "SimplePhysicsComponent.h"
|
||||||
|
#include "SkillComponent.h"
|
||||||
|
#include "SoundTriggerComponent.h"
|
||||||
|
#include "SwitchComponent.h"
|
||||||
|
#include "TriggerComponent.h"
|
||||||
|
#include "VehiclePhysicsComponent.h"
|
||||||
|
#include "VendorComponent.h"
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "eReplicaPacketType.h"
|
||||||
|
|
||||||
|
class EntityTests : public GameDependenciesTest {
|
||||||
|
protected:
|
||||||
|
struct {
|
||||||
|
BaseCombatAIComponent* baseCombatAIComponent;
|
||||||
|
int32_t combatAiComponentTarget = 0;
|
||||||
|
};
|
||||||
|
BouncerComponent* bouncerComponent;
|
||||||
|
BuffComponent* buffComponent;
|
||||||
|
BuildBorderComponent* buildBorderComponent;
|
||||||
|
CharacterComponent* characterComponent;
|
||||||
|
ControllablePhysicsComponent* controllablePhysicsComponent;
|
||||||
|
DestroyableComponent* destroyableComponent;
|
||||||
|
InventoryComponent* inventoryComponent;
|
||||||
|
LevelProgressionComponent* levelProgressionComponent;
|
||||||
|
LUPExhibitComponent* lUPExhibitComponent;
|
||||||
|
MissionComponent* missionComponent;
|
||||||
|
MissionOfferComponent* missionOfferComponent;
|
||||||
|
ModelComponent* modelComponent;
|
||||||
|
ModuleAssemblyComponent* moduleAssemblyComponent;
|
||||||
|
MovementAIComponent* movementAIComponent;
|
||||||
|
MovingPlatformComponent* movingPlatformComponent;
|
||||||
|
PetComponent* petComponent;
|
||||||
|
PhantomPhysicsComponent* phantomPhysicsComponent;
|
||||||
|
PlayerForcedMovementComponent* playerForcedMovementComponent;
|
||||||
|
PossessableComponent* possessableComponent;
|
||||||
|
PossessorComponent* possessorComponent;
|
||||||
|
PropertyComponent* propertyComponent;
|
||||||
|
PropertyEntranceComponent* propertyEntranceComponent;
|
||||||
|
PropertyManagementComponent* propertyManagementComponent;
|
||||||
|
PropertyVendorComponent* propertyVendorComponent;
|
||||||
|
ProximityMonitorComponent* proximityMonitorComponent;
|
||||||
|
RacingControlComponent* racingControlComponent;
|
||||||
|
RailActivatorComponent* railActivatorComponent;
|
||||||
|
RebuildComponent* rebuildComponent;
|
||||||
|
RenderComponent* renderComponent;
|
||||||
|
RigidbodyPhantomPhysicsComponent* rigidbodyPhantomPhysicsComponent;
|
||||||
|
RocketLaunchLupComponent* rocketLaunchLupComponent;
|
||||||
|
RocketLaunchpadControlComponent* rocketLaunchpadControlComponent;
|
||||||
|
ScriptedActivityComponent* scriptedActivityComponent;
|
||||||
|
ShootingGalleryComponent* shootingGalleryComponent;
|
||||||
|
SimplePhysicsComponent* simplePhysicsComponent;
|
||||||
|
SkillComponent* skillComponent;
|
||||||
|
SoundTriggerComponent* soundTriggerComponent;
|
||||||
|
SwitchComponent* switchComponent;
|
||||||
|
TriggerComponent* triggerComponent;
|
||||||
|
VehiclePhysicsComponent* vehiclePhysicsComponent;
|
||||||
|
VendorComponent* vendorComponent;
|
||||||
|
Entity* testedEntity;
|
||||||
|
void SetUp() override {
|
||||||
|
srand(time(NULL));
|
||||||
|
SetUpDependencies();
|
||||||
|
testedEntity = new Entity(5, info);
|
||||||
|
Game::logger->Log("EntityTests", "starting");
|
||||||
|
bouncerComponent = new BouncerComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "BouncerComponent");
|
||||||
|
buffComponent = new BuffComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "BuffComponent");
|
||||||
|
buildBorderComponent = new BuildBorderComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "BuildBorderComponent");
|
||||||
|
characterComponent = new CharacterComponent(testedEntity, nullptr);
|
||||||
|
Game::logger->Log("EntityTests", "CharacterComponent");
|
||||||
|
controllablePhysicsComponent = new ControllablePhysicsComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "ControllablePhysicsComponent");
|
||||||
|
destroyableComponent = new DestroyableComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "DestroyableComponent");
|
||||||
|
inventoryComponent = new InventoryComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "InventoryComponent");
|
||||||
|
levelProgressionComponent = new LevelProgressionComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "LevelProgressionComponent");
|
||||||
|
lUPExhibitComponent = new LUPExhibitComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "LUPExhibitComponent");
|
||||||
|
missionComponent = new MissionComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "MissionComponent");
|
||||||
|
missionOfferComponent = new MissionOfferComponent(testedEntity, 2345);
|
||||||
|
Game::logger->Log("EntityTests", "MissionOfferComponent");
|
||||||
|
modelComponent = new ModelComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "ModelComponent");
|
||||||
|
moduleAssemblyComponent = new ModuleAssemblyComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "ModuleAssemblyComponent");
|
||||||
|
movementAIComponent = new MovementAIComponent(testedEntity, MovementAIInfo());
|
||||||
|
Game::logger->Log("EntityTests", "MovementAIComponent");
|
||||||
|
movingPlatformComponent = new MovingPlatformComponent(testedEntity, "");
|
||||||
|
Game::logger->Log("EntityTests", "MovingPlatformComponent");
|
||||||
|
petComponent = new PetComponent(testedEntity, 1234);
|
||||||
|
Game::logger->Log("EntityTests", "PetComponent");
|
||||||
|
phantomPhysicsComponent = new PhantomPhysicsComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "PhantomPhysicsComponent");
|
||||||
|
playerForcedMovementComponent = new PlayerForcedMovementComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "PlayerForcedMovementComponent");
|
||||||
|
possessableComponent = new PossessableComponent(testedEntity, 124);
|
||||||
|
Game::logger->Log("EntityTests", "PossessableComponent");
|
||||||
|
possessorComponent = new PossessorComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "PossessorComponent");
|
||||||
|
propertyComponent = new PropertyComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "PropertyComponent");
|
||||||
|
propertyEntranceComponent = new PropertyEntranceComponent(38, testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "PropertyEntranceComponent");
|
||||||
|
propertyManagementComponent = new PropertyManagementComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "PropertyManagementComponent");
|
||||||
|
propertyVendorComponent = new PropertyVendorComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "PropertyVendorComponent");
|
||||||
|
proximityMonitorComponent = new ProximityMonitorComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "ProximityMonitorComponent");
|
||||||
|
racingControlComponent = new RacingControlComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "RacingControlComponent");
|
||||||
|
railActivatorComponent = new RailActivatorComponent(testedEntity, 4231);
|
||||||
|
Game::logger->Log("EntityTests", "RailActivatorComponent");
|
||||||
|
rebuildComponent = new RebuildComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "RebuildComponent");
|
||||||
|
renderComponent = new RenderComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "RenderComponent");
|
||||||
|
rigidbodyPhantomPhysicsComponent = new RigidbodyPhantomPhysicsComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "RigidbodyPhantomPhysicsComponent");
|
||||||
|
rocketLaunchLupComponent = new RocketLaunchLupComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "RocketLaunchLupComponent");
|
||||||
|
rocketLaunchpadControlComponent = new RocketLaunchpadControlComponent(testedEntity, 5);
|
||||||
|
Game::logger->Log("EntityTests", "RocketLaunchpadControlComponent");
|
||||||
|
scriptedActivityComponent = new ScriptedActivityComponent(testedEntity, 4);
|
||||||
|
Game::logger->Log("EntityTests", "ScriptedActivityComponent");
|
||||||
|
shootingGalleryComponent = new ShootingGalleryComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "ShootingGalleryComponent");
|
||||||
|
simplePhysicsComponent = new SimplePhysicsComponent(3, testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "SimplePhysicsComponent");
|
||||||
|
skillComponent = new SkillComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "SkillComponent");
|
||||||
|
soundTriggerComponent = new SoundTriggerComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "SoundTriggerComponent");
|
||||||
|
switchComponent = new SwitchComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "SwitchComponent");
|
||||||
|
triggerComponent = new TriggerComponent(testedEntity, "");
|
||||||
|
Game::logger->Log("EntityTests", "TriggerComponent");
|
||||||
|
vehiclePhysicsComponent = new VehiclePhysicsComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "VehiclePhysicsComponent");
|
||||||
|
vendorComponent = new VendorComponent(testedEntity);
|
||||||
|
Game::logger->Log("EntityTests", "VendorComponent");
|
||||||
|
baseCombatAIComponent->SetState(AiState::dead);
|
||||||
|
combatAiComponentTarget = rand();
|
||||||
|
baseCombatAIComponent->SetTarget(combatAiComponentTarget);
|
||||||
|
|
||||||
|
bouncerComponent->SetPetEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override {
|
||||||
|
TearDownDependencies();
|
||||||
|
delete baseCombatAIComponent;
|
||||||
|
delete bouncerComponent;
|
||||||
|
delete buffComponent;
|
||||||
|
delete buildBorderComponent;
|
||||||
|
delete characterComponent;
|
||||||
|
delete controllablePhysicsComponent;
|
||||||
|
delete destroyableComponent;
|
||||||
|
delete inventoryComponent;
|
||||||
|
delete levelProgressionComponent;
|
||||||
|
delete lUPExhibitComponent;
|
||||||
|
delete missionComponent;
|
||||||
|
delete missionOfferComponent;
|
||||||
|
delete modelComponent;
|
||||||
|
delete moduleAssemblyComponent;
|
||||||
|
delete movementAIComponent;
|
||||||
|
delete movingPlatformComponent;
|
||||||
|
delete petComponent;
|
||||||
|
delete phantomPhysicsComponent;
|
||||||
|
delete playerForcedMovementComponent;
|
||||||
|
delete possessableComponent;
|
||||||
|
delete possessorComponent;
|
||||||
|
delete propertyComponent;
|
||||||
|
delete propertyEntranceComponent;
|
||||||
|
delete propertyManagementComponent;
|
||||||
|
delete propertyVendorComponent;
|
||||||
|
delete proximityMonitorComponent;
|
||||||
|
delete racingControlComponent;
|
||||||
|
delete railActivatorComponent;
|
||||||
|
delete rebuildComponent;
|
||||||
|
delete renderComponent;
|
||||||
|
delete rigidbodyPhantomPhysicsComponent;
|
||||||
|
delete rocketLaunchLupComponent;
|
||||||
|
delete rocketLaunchpadControlComponent;
|
||||||
|
delete scriptedActivityComponent;
|
||||||
|
delete shootingGalleryComponent;
|
||||||
|
delete simplePhysicsComponent;
|
||||||
|
delete skillComponent;
|
||||||
|
delete soundTriggerComponent;
|
||||||
|
delete switchComponent;
|
||||||
|
delete triggerComponent;
|
||||||
|
delete vehiclePhysicsComponent;
|
||||||
|
delete vendorComponent;
|
||||||
|
operator delete(testedEntity);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(EntityTests, EntityConstructionTest) {
|
||||||
|
CBITSTREAM;
|
||||||
|
testedEntity->WriteComponents(&bitStream, eReplicaPacketType::CONSTRUCTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(EntityTests, EntitySerializationTest) {
|
||||||
|
CBITSTREAM;
|
||||||
|
testedEntity->WriteComponents(&bitStream, eReplicaPacketType::SERIALIZATION);
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
#include "EntityInfo.h"
|
#include "EntityInfo.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
|
|
||||||
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
class dZoneManager;
|
class dZoneManager;
|
||||||
@@ -21,6 +23,11 @@ public:
|
|||||||
void Send(RakNet::BitStream* bitStream, const SystemAddress& sysAddr, bool broadcast) override { sentBitStream = bitStream; };
|
void Send(RakNet::BitStream* bitStream, const SystemAddress& sysAddr, bool broadcast) override { sentBitStream = bitStream; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class EntityManagerMock : public EntityManager {
|
||||||
|
public:
|
||||||
|
void SerializeEntity(Entity* entity) override {};
|
||||||
|
};
|
||||||
|
|
||||||
class GameDependenciesTest : public ::testing::Test {
|
class GameDependenciesTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUpDependencies() {
|
void SetUpDependencies() {
|
||||||
@@ -32,7 +39,7 @@ protected:
|
|||||||
Game::logger = new dLogger("./testing.log", true, true);
|
Game::logger = new dLogger("./testing.log", true, true);
|
||||||
Game::server = new dServerMock();
|
Game::server = new dServerMock();
|
||||||
Game::config = new dConfig("worldconfig.ini");
|
Game::config = new dConfig("worldconfig.ini");
|
||||||
Game::entityManager = new EntityManager();
|
Game::entityManager = new EntityManagerMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDownDependencies() {
|
void TearDownDependencies() {
|
||||||
|
|||||||
Reference in New Issue
Block a user