mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-18 09:45:28 +00:00
Merge origin/main into experimental: behaviors, raw terrain scene lookups, property model fixes, player count
Main's model behaviors (every rotation, DoDamage, OnTimer, OnStartup, MoveBackToStart, moves along the model's local axes), raw terrain reading with scene lookups and scene tools, property model and brick by brick fixes and the chat server's player count fix, merged onto this branch's structures: - game messages stay structs; the angular velocity messages join them and the handler sets a message's target - strips own their speed again and the block names, moves and rotations stay in the shared action table (PropertyBehaviorActions, which the dashboard's behavior player reads; it now lists rotations too) - the zone keeps reading its file through ZoneFile and takes the boundaries from it, then loads the raw terrain as main does; the old dNavigation terrain reader is gone - the show all response stays a struct and logs a player count mismatch as main does - the property management component tells models who sent a chat message Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,8 @@ set(DCOMPONENTS_TESTS
|
||||
"VendorBuybackTests.cpp"
|
||||
"RacingWrongWayTests.cpp"
|
||||
"DestroyableComponentTests.cpp"
|
||||
"InventoryGroupTests.cpp"
|
||||
"ModelComponentTests.cpp"
|
||||
"PetComponentTests.cpp"
|
||||
"SimplePhysicsComponentTests.cpp"
|
||||
"MovementBlockerScenarioTests.cpp"
|
||||
|
||||
@@ -132,3 +132,11 @@ TEST_F(InventoryGroupTests, TheLockedFlagIsSavedAndLoaded) {
|
||||
EXPECT_TRUE(groups[0].locked);
|
||||
EXPECT_FALSE(groups[1].locked);
|
||||
}
|
||||
|
||||
TEST_F(InventoryGroupTests, OnlyBricksAndModelsHaveGroups) {
|
||||
Group("ADD", "user_group1", u"g", eInventoryType::ITEMS);
|
||||
EXPECT_FALSE(inventory->GetGroups().contains(eInventoryType::ITEMS));
|
||||
|
||||
Group("ADD", "user_group1", u"g", eInventoryType::BRICKS);
|
||||
EXPECT_EQ(inventory->GetGroups().at(eInventoryType::BRICKS).size(), 1u);
|
||||
}
|
||||
|
||||
55
tests/dGameTests/dComponentsTests/ModelComponentTests.cpp
Normal file
55
tests/dGameTests/dComponentsTests/ModelComponentTests.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "GameDependencies.h"
|
||||
|
||||
#include "BitStream.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "Entity.h"
|
||||
#include "GameMessages.h"
|
||||
#include "ModelComponent.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
class ModelComponentTests : public GameDependenciesTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
SetUpDependencies();
|
||||
CDClientManager::GetEntriesMutable<CDComponentsRegistryTable>().insert_or_assign(static_cast<uint64_t>(info.lot), 0);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
TearDownDependencies();
|
||||
}
|
||||
|
||||
// The bits a model's serialization writes
|
||||
static uint32_t SerializedBits(Entity& entity) {
|
||||
auto* model = entity.AddComponent<ModelComponent>(-1);
|
||||
RakNet::BitStream bitStream;
|
||||
model->Serialize(bitStream, true);
|
||||
return bitStream.GetNumberOfBitsUsed();
|
||||
}
|
||||
};
|
||||
|
||||
// Item block (1 + 64 + 32 + 1), model block (1 + 1 + 32 + 96 + 128)
|
||||
constexpr uint32_t ModelBlockBits = 98 + 258;
|
||||
// Behavior info: flag, count, paused, and on the initial update the editing info flag
|
||||
constexpr uint32_t BehaviorBits = 1 + 32 + 1 + 1;
|
||||
|
||||
// The client reads the behaviors only for property and inventory models (ObjectLoader2::LoadModelBehaviorsComponent)
|
||||
TEST_F(ModelComponentTests, OtherModelsHaveNoBehaviorInfo) {
|
||||
Entity entity(1, info);
|
||||
EXPECT_EQ(SerializedBits(entity), ModelBlockBits);
|
||||
}
|
||||
|
||||
TEST_F(ModelComponentTests, PropertyModelsHaveBehaviorInfo) {
|
||||
EntityInfo propertyInfo = info;
|
||||
propertyInfo.settings.Insert<bool>(u"propertyObjectID", true);
|
||||
Entity entity(1, propertyInfo);
|
||||
EXPECT_EQ(SerializedBits(entity), ModelBlockBits + BehaviorBits);
|
||||
}
|
||||
|
||||
TEST_F(ModelComponentTests, InventoryModelsHaveBehaviorInfo) {
|
||||
EntityInfo inventoryInfo = info;
|
||||
inventoryInfo.settings.Insert<bool>(u"inInventory", true);
|
||||
Entity entity(1, inventoryInfo);
|
||||
EXPECT_EQ(SerializedBits(entity), ModelBlockBits + BehaviorBits);
|
||||
}
|
||||
Reference in New Issue
Block a user