Compare commits

..

1 Commits

Author SHA1 Message Date
Daniel Seiler
9ddb2b5f2e Unset MAXIMUM_OUTGOING_BANDWIDTH by default 2024-04-11 17:21:34 +02:00
13 changed files with 54 additions and 77 deletions

View File

@@ -254,7 +254,7 @@ void Entity::Initialize() {
}
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MINI_GAME_CONTROL) > 0) {
AddComponent<MiniGameControlComponent>(m_TemplateID);
AddComponent<MiniGameControlComponent>();
}
uint32_t possessableComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::POSSESSABLE);
@@ -666,7 +666,7 @@ void Entity::Initialize() {
// Shooting gallery component
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SHOOTING_GALLERY) > 0) {
AddComponent<ShootingGalleryComponent>(m_TemplateID);
AddComponent<ShootingGalleryComponent>();
}
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY, -1) != -1) {

View File

@@ -47,6 +47,7 @@ set(DGAME_DCOMPONENTS_SOURCES
"TriggerComponent.cpp"
"HavokVehiclePhysicsComponent.cpp"
"VendorComponent.cpp"
"MiniGameControlComponent.cpp"
"ScriptComponent.cpp"
)

View File

@@ -696,20 +696,22 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument& document) {
}
void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool bIsInitialUpdate) {
// LWOInventoryComponent_EquippedItem
outBitStream.Write(bIsInitialUpdate || m_Dirty);
if (bIsInitialUpdate || m_Dirty) {
outBitStream.Write(true);
outBitStream.Write<uint32_t>(m_Equipped.size());
for (const auto& pair : m_Equipped) {
const auto item = pair.second;
if (bIsInitialUpdate) AddItemSkills(item.lot);
if (bIsInitialUpdate) {
AddItemSkills(item.lot);
}
outBitStream.Write(item.id);
outBitStream.Write(item.lot);
outBitStream.Write0(); // subkey
outBitStream.Write0();
outBitStream.Write(item.count > 0);
if (item.count > 0) outBitStream.Write(item.count);
@@ -717,7 +719,7 @@ void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool b
outBitStream.Write(item.slot != 0);
if (item.slot != 0) outBitStream.Write<uint16_t>(item.slot);
outBitStream.Write0(); // inventory type
outBitStream.Write0();
bool flag = !item.config.empty();
outBitStream.Write(flag);
@@ -744,21 +746,11 @@ void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool b
}
m_Dirty = false;
} else {
outBitStream.Write(false);
}
// EquippedModelTransform
outBitStream.Write(false);
/*
outBitStream.Write(bIsInitialUpdate || m_Dirty); // Same dirty or different?
if (bIsInitialUpdate || m_Dirty) {
outBitStream.Write<uint32_t>(m_Equipped.size()); // Equiped models?
for (const auto& [location, item] : m_Equipped) {
outBitStream.Write(item.id);
outBitStream.Write(item.pos);
outBitStream.Write(item.rot);
}
}
*/
}
void InventoryComponent::Update(float deltaTime) {

View File

@@ -2,16 +2,4 @@
void ItemComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
outBitStream.Write0();
/*
outBitStream.Write(isConstruction || m_Dirty); // Same dirty or different?
if (isConstruction || m_Dirty) {
outBitStream.Write(m_parent->GetObjectID());
outBitStream.Write(moderationStatus);
outBitStream.Write(!description.empty());
if (!description.empty()) {
outBitStream.Write<uint32_t>(description.size());
outBitStream.Write(description) // u16string
}
}
*/
}

View File

@@ -0,0 +1,5 @@
#include "MiniGameControlComponent.h"
void MiniGameControlComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
outBitStream.Write<uint32_t>(0x40000000);
}

View File

@@ -1,13 +1,15 @@
#ifndef __MINIGAMECONTROLCOMPONENT__H__
#define __MINIGAMECONTROLCOMPONENT__H__
#include "ActivityComponent.h"
#include "Component.h"
#include "eReplicaComponentType.h"
class MiniGameControlComponent final : public ActivityComponent {
class MiniGameControlComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MINI_GAME_CONTROL;
MiniGameControlComponent(Entity* parent, LOT lot) : ActivityComponent(parent, lot) {}
MiniGameControlComponent(Entity* parent) : Component(parent) {}
void Serialize(RakNet::BitStream& outBitStream, bool isConstruction);
};
#endif //!__MINIGAMECONTROLCOMPONENT__H__

View File

@@ -2,6 +2,11 @@
#include "EntityManager.h"
#include "ScriptedActivityComponent.h"
ShootingGalleryComponent::ShootingGalleryComponent(Entity* parent) : Component(parent) {
}
ShootingGalleryComponent::~ShootingGalleryComponent() = default;
void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams& params) {
m_StaticParams = params;
}
@@ -12,15 +17,20 @@ void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryPara
Game::entityManager->SerializeEntity(m_Parent);
}
void ShootingGalleryComponent::SetCurrentPlayerID(LWOOBJID playerID) {
m_CurrentPlayerID = playerID;
m_Dirty = true;
AddActivityPlayerData(playerID);
};
void ShootingGalleryComponent::Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) {
ActivityComponent::Serialize(outBitStream, isInitialUpdate);
// Start ScriptedActivityComponent
outBitStream.Write<bool>(true);
if (m_CurrentPlayerID == LWOOBJID_EMPTY) {
outBitStream.Write<uint32_t>(0);
} else {
outBitStream.Write<uint32_t>(1);
outBitStream.Write<LWOOBJID>(m_CurrentPlayerID);
for (size_t i = 0; i < 10; i++) {
outBitStream.Write<float_t>(0.0f);
}
}
// End ScriptedActivityComponent
if (isInitialUpdate) {
outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetX());

View File

@@ -2,7 +2,7 @@
#include "dCommonVars.h"
#include "NiPoint3.h"
#include "Entity.h"
#include "ActivityComponent.h"
#include "Component.h"
#include "eReplicaComponentType.h"
/**
@@ -71,11 +71,12 @@ struct StaticShootingGalleryParams {
* A very ancient component that was used to guide shooting galleries, it's still kind of used but a lot of logic is
* also in the related scripts.
*/
class ShootingGalleryComponent final : public ActivityComponent {
class ShootingGalleryComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SHOOTING_GALLERY;
explicit ShootingGalleryComponent(Entity* parent, LOT lot) : ActivityComponent(parent, lot) {}
explicit ShootingGalleryComponent(Entity* parent);
~ShootingGalleryComponent();
void Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) override;
/**
@@ -106,8 +107,13 @@ public:
* Sets the entity that's currently playing the shooting gallery
* @param playerID the entity to set
*/
void SetCurrentPlayerID(LWOOBJID playerID);
void SetCurrentPlayerID(LWOOBJID playerID) { m_CurrentPlayerID = playerID; m_Dirty = true; };
/**
* Returns the player that's currently playing the shooting gallery
* @return the player that's currently playing the shooting gallery
*/
LWOOBJID GetCurrentPlayerID() const { return m_CurrentPlayerID; };
private:
/**

View File

@@ -486,32 +486,6 @@ SkillComponent::~SkillComponent() {
void SkillComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) outBitStream.Write0();
/*
outBitStream.Write(bIsInitialUpdate && !m_managedBehaviors.empty());
if (bIsInitialUpdate && !m_managedBehaviors.empty()) {
outBitStream.Write<uint32_t>(m_managedBehaviors.size());
for (const auto& [id, skill] : m_managedBehaviors) {
outBitStream.Write(skill.skillUID);
outBitStream.Write(skill.skillID);
outBitStream.Write(skill.cast_type);
outBitStream.Write(skill.cancel_type);
outBitStream.Write(skill.behavior_count);
for (auto& index : skill.behavior_count) {
outBitStream.Write<uint32_t>(behaviorUID); // Maybe
outBitStream.Write<uint32_t>(action);
outBitStream.Write<uint32_t>(wait_time_ms);
outBitStream.Write<uint32_t>(template_id);
outBitStream.Write(casterObjId);
outBitStream.Write(originatorObjId);
outBitStream.Write(targetObjId);
outBitStream.Write<bool>(usedMouse);
outBitStream.Write(cooldown);
outBitStream.Write(charge_time);
outBitStream.Write(imagination_cost);
}
}
}
*/
}
/// <summary>

View File

@@ -17,9 +17,7 @@ void TokenConsoleServer::OnUse(Entity* self, Entity* user) {
inv->RemoveItem(6194, bricksToTake);
//play sound
if (self->HasVar(u"sound1")) {
GameMessages::SendPlayNDAudioEmitter(self, user->GetSystemAddress(), self->GetVarAsString(u"sound1"));
}
GameMessages::SendPlayNDAudioEmitter(self, user->GetSystemAddress(), "947d0d52-c7f8-4516-8dee-e1593a7fd1d1");
//figure out which faction the player belongs to:
auto character = user->GetCharacter();

View File

@@ -39,7 +39,7 @@ void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) {
const auto useSound = self->GetVar<std::string>(u"sound1");
if (!useSound.empty()) {
GameMessages::SendPlayNDAudioEmitter(self, user->GetSystemAddress(), useSound);
GameMessages::SendPlayNDAudioEmitter(self, UNASSIGNED_SYSTEM_ADDRESS, useSound);
}
// Player must be in faction to interact with this entity.

View File

@@ -90,7 +90,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
auto* shootingGalleryComponent = self->GetComponent<ShootingGalleryComponent>();
if (shootingGalleryComponent != nullptr) {
shootingGalleryComponent->AddActivityPlayerData(player->GetObjectID());
shootingGalleryComponent->SetCurrentPlayerID(player->GetObjectID());
LOG("Setting player ID");

View File

@@ -40,6 +40,7 @@ services:
- MYSQL_PASSWORD=${MARIADB_PASSWORD:?error}
- EXTERNAL_IP=${EXTERNAL_IP:-localhost}
- CLIENT_NET_VERSION=${CLIENT_NET_VERSION:-171022}
- MAXIMUM_OUTGOING_BANDWIDTH=${MAXIMUM_OUTGOING_BANDWIDTH:0}
depends_on:
- darkflamedb
ports: