mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-25 23:13:35 +00:00
Merge branch 'main' into components-wheeeee
This commit is contained in:
commit
bcbc5882dc
@ -19,34 +19,47 @@ HavokVehiclePhysicsComponent::~HavokVehiclePhysicsComponent() {
|
||||
}
|
||||
|
||||
void HavokVehiclePhysicsComponent::SetPosition(const NiPoint3& pos) {
|
||||
if (pos == m_Position) return;
|
||||
m_DirtyPosition = true;
|
||||
m_Position = pos;
|
||||
}
|
||||
|
||||
void HavokVehiclePhysicsComponent::SetRotation(const NiQuaternion& rot) {
|
||||
if (rot == m_Rotation) return;
|
||||
m_DirtyPosition = true;
|
||||
m_Rotation = rot;
|
||||
}
|
||||
|
||||
void HavokVehiclePhysicsComponent::SetVelocity(const NiPoint3& vel) {
|
||||
if (vel == m_Velocity) return;
|
||||
m_DirtyPosition = true;
|
||||
m_Velocity = vel;
|
||||
}
|
||||
|
||||
void HavokVehiclePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) {
|
||||
if (vel == m_AngularVelocity) return;
|
||||
m_DirtyPosition = true;
|
||||
m_AngularVelocity = vel;
|
||||
}
|
||||
|
||||
void HavokVehiclePhysicsComponent::SetIsOnGround(bool val) {
|
||||
if (val == m_IsOnGround) return;
|
||||
m_DirtyPosition = true;
|
||||
m_IsOnGround = val;
|
||||
}
|
||||
|
||||
void HavokVehiclePhysicsComponent::SetIsOnRail(bool val) {
|
||||
if (val == m_IsOnRail) return;
|
||||
m_DirtyPosition = true;
|
||||
m_IsOnRail = val;
|
||||
}
|
||||
|
||||
void HavokVehiclePhysicsComponent::SetRemoteInputInfo(const RemoteInputInfo& remoteInputInfo) {
|
||||
if (m_RemoteInputInfo == remoteInputInfo) return;
|
||||
this->m_RemoteInputInfo = remoteInputInfo;
|
||||
m_DirtyRemoteInput = true;
|
||||
}
|
||||
|
||||
void HavokVehiclePhysicsComponent::SetDirtyPosition(bool val) {
|
||||
m_DirtyPosition = val;
|
||||
}
|
||||
@ -63,9 +76,15 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
||||
outBitStream->Write(bIsInitialUpdate || m_DirtyPosition);
|
||||
|
||||
if (bIsInitialUpdate || m_DirtyPosition) {
|
||||
outBitStream->Write(m_Position);
|
||||
m_DirtyPosition = false;
|
||||
outBitStream->Write(m_Position.x);
|
||||
outBitStream->Write(m_Position.y);
|
||||
outBitStream->Write(m_Position.z);
|
||||
|
||||
outBitStream->Write(m_Rotation);
|
||||
outBitStream->Write(m_Rotation.x);
|
||||
outBitStream->Write(m_Rotation.y);
|
||||
outBitStream->Write(m_Rotation.z);
|
||||
outBitStream->Write(m_Rotation.w);
|
||||
|
||||
outBitStream->Write(m_IsOnGround);
|
||||
outBitStream->Write(m_IsOnRail);
|
||||
@ -73,20 +92,33 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
||||
outBitStream->Write(bIsInitialUpdate || m_DirtyVelocity);
|
||||
|
||||
if (bIsInitialUpdate || m_DirtyVelocity) {
|
||||
outBitStream->Write(m_Velocity);
|
||||
outBitStream->Write(m_Velocity.x);
|
||||
outBitStream->Write(m_Velocity.y);
|
||||
outBitStream->Write(m_Velocity.z);
|
||||
m_DirtyVelocity = false;
|
||||
}
|
||||
|
||||
outBitStream->Write(bIsInitialUpdate || m_DirtyAngularVelocity);
|
||||
|
||||
if (bIsInitialUpdate || m_DirtyAngularVelocity) {
|
||||
outBitStream->Write(m_AngularVelocity);
|
||||
outBitStream->Write(m_AngularVelocity.x);
|
||||
outBitStream->Write(m_AngularVelocity.y);
|
||||
outBitStream->Write(m_AngularVelocity.z);
|
||||
m_DirtyAngularVelocity = false;
|
||||
}
|
||||
|
||||
outBitStream->Write0();
|
||||
outBitStream->Write0(); // local_space_info. TODO: Implement this
|
||||
|
||||
outBitStream->Write0();
|
||||
outBitStream->Write(m_DirtyRemoteInput || bIsInitialUpdate); // remote_input_info
|
||||
if (m_DirtyRemoteInput || bIsInitialUpdate) {
|
||||
outBitStream->Write(m_RemoteInputInfo.m_RemoteInputX);
|
||||
outBitStream->Write(m_RemoteInputInfo.m_RemoteInputY);
|
||||
outBitStream->Write(m_RemoteInputInfo.m_IsPowersliding);
|
||||
outBitStream->Write(m_RemoteInputInfo.m_IsModified);
|
||||
m_DirtyRemoteInput = false;
|
||||
}
|
||||
|
||||
outBitStream->Write(0.0f);
|
||||
outBitStream->Write(125.0f); // remote_input_ping TODO: Figure out how this should be calculated as it seems to be constant through the whole race.
|
||||
|
||||
if (!bIsInitialUpdate) {
|
||||
outBitStream->Write0();
|
||||
@ -95,7 +127,7 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
||||
|
||||
if (bIsInitialUpdate) {
|
||||
outBitStream->Write<uint8_t>(m_EndBehavior);
|
||||
outBitStream->Write1();
|
||||
outBitStream->Write1(); // is input locked?
|
||||
}
|
||||
|
||||
outBitStream->Write0();
|
||||
@ -104,7 +136,6 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
||||
void HavokVehiclePhysicsComponent::Update(float deltaTime) {
|
||||
if (m_SoftUpdate > 5) {
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
m_SoftUpdate = 0;
|
||||
} else {
|
||||
m_SoftUpdate += deltaTime;
|
||||
|
@ -5,6 +5,24 @@
|
||||
#include "Component.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
struct RemoteInputInfo {
|
||||
void operator=(const RemoteInputInfo& other) {
|
||||
m_RemoteInputX = other.m_RemoteInputX;
|
||||
m_RemoteInputY = other.m_RemoteInputY;
|
||||
m_IsPowersliding = other.m_IsPowersliding;
|
||||
m_IsModified = other.m_IsModified;
|
||||
}
|
||||
|
||||
bool operator==(const RemoteInputInfo& other) {
|
||||
return m_RemoteInputX == other.m_RemoteInputX && m_RemoteInputY == other.m_RemoteInputY && m_IsPowersliding == other.m_IsPowersliding && m_IsModified == other.m_IsModified;
|
||||
}
|
||||
|
||||
float m_RemoteInputX;
|
||||
float m_RemoteInputY;
|
||||
bool m_IsPowersliding;
|
||||
bool m_IsModified;
|
||||
};
|
||||
|
||||
/**
|
||||
* Physics component for vehicles.
|
||||
*/
|
||||
@ -94,6 +112,7 @@ public:
|
||||
void SetDirtyPosition(bool val);
|
||||
void SetDirtyVelocity(bool val);
|
||||
void SetDirtyAngularVelocity(bool val);
|
||||
void SetRemoteInputInfo(const RemoteInputInfo&);
|
||||
|
||||
private:
|
||||
bool m_DirtyPosition;
|
||||
@ -110,4 +129,6 @@ private:
|
||||
|
||||
float m_SoftUpdate = 0;
|
||||
uint32_t m_EndBehavior;
|
||||
RemoteInputInfo m_RemoteInputInfo;
|
||||
bool m_DirtyRemoteInput;
|
||||
};
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "CDObjectSkillsTable.h"
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
|
||||
InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document): Component(parent) {
|
||||
InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document) : Component(parent) {
|
||||
this->m_Dirty = true;
|
||||
this->m_Equipped = {};
|
||||
this->m_Pushed = {};
|
||||
@ -830,14 +830,22 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
|
||||
const auto position = m_ParentEntity->GetPosition();
|
||||
|
||||
for (auto* lauchPad : rocketLauchPads) {
|
||||
if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
||||
for (auto* launchPad : rocketLauchPads) {
|
||||
if (!launchPad) continue;
|
||||
|
||||
auto prereq = launchPad->GetVarAsString(u"rocketLaunchPreCondition");
|
||||
if (!prereq.empty()) {
|
||||
PreconditionExpression expression(prereq);
|
||||
if (!expression.Check(m_ParentEntity)) continue;
|
||||
}
|
||||
|
||||
if (Vector3::DistanceSquared(launchPad->GetPosition(), position) > 13 * 13) continue;
|
||||
|
||||
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
|
||||
if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId());
|
||||
|
||||
lauchPad->OnUse(m_ParentEntity);
|
||||
launchPad->OnUse(m_ParentEntity);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -122,8 +122,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
// Make sure the player is at the correct position.
|
||||
|
||||
GameMessages::SendTeleport(player->GetObjectID(), startPosition,
|
||||
startRotation, player->GetSystemAddress(), true,
|
||||
true);
|
||||
startRotation, player->GetSystemAddress(), true);
|
||||
|
||||
// Spawn the vehicle entity.
|
||||
|
||||
@ -238,11 +237,9 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
|
||||
// Make sure everything has the correct position.
|
||||
GameMessages::SendTeleport(player->GetObjectID(), startPosition,
|
||||
startRotation, player->GetSystemAddress(), true,
|
||||
true);
|
||||
startRotation, player->GetSystemAddress(), true);
|
||||
GameMessages::SendTeleport(carEntity->GetObjectID(), startPosition,
|
||||
startRotation, player->GetSystemAddress(), true,
|
||||
true);
|
||||
startRotation, player->GetSystemAddress(), true);
|
||||
}
|
||||
|
||||
void RacingControlComponent::OnRacingClientReady(Entity* player) {
|
||||
@ -629,7 +626,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
GameMessages::SendTeleport(
|
||||
player.playerID, player.respawnPosition,
|
||||
player.respawnRotation,
|
||||
playerEntity->GetSystemAddress(), true, true);
|
||||
playerEntity->GetSystemAddress(), true);
|
||||
|
||||
vehicle->SetPosition(player.respawnPosition);
|
||||
vehicle->SetRotation(player.respawnRotation);
|
||||
|
@ -120,7 +120,7 @@ void GameMessages::SendFireEventClientSide(const LWOOBJID& objectID, const Syste
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void GameMessages::SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, const NiQuaternion& rot, const SystemAddress& sysAddr, bool bSetRotation, bool noGravTeleport) {
|
||||
void GameMessages::SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, const NiQuaternion& rot, const SystemAddress& sysAddr, bool bSetRotation) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
bitStream.Write(objectID);
|
||||
@ -141,7 +141,6 @@ void GameMessages::SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, c
|
||||
bitStream.Write(pos.y);
|
||||
bitStream.Write(pos.z);
|
||||
bitStream.Write(bUseNavmesh);
|
||||
bitStream.Write(noGravTeleport);
|
||||
|
||||
bitStream.Write(rot.w != 1.0f);
|
||||
if (rot.w != 1.0f) bitStream.Write(rot.w);
|
||||
|
@ -40,7 +40,7 @@ enum class eRebuildState : uint32_t;
|
||||
namespace GameMessages {
|
||||
class PropertyDataMessage;
|
||||
void SendFireEventClientSide(const LWOOBJID& objectID, const SystemAddress& sysAddr, std::u16string args, const LWOOBJID& object, int64_t param1, int param2, const LWOOBJID& sender);
|
||||
void SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, const NiQuaternion& rot, const SystemAddress& sysAddr, bool bSetRotation = false, bool noGravTeleport = true);
|
||||
void SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, const NiQuaternion& rot, const SystemAddress& sysAddr, bool bSetRotation = false);
|
||||
void SendPlayAnimation(Entity* entity, const std::u16string& animationName, float fPriority = 0.0f, float fScale = 1.0f);
|
||||
void SendPlayerReady(Entity* entity, const SystemAddress& sysAddr);
|
||||
void SendPlayerAllowedRespawn(LWOOBJID entityID, bool doNotPromptRespawn, const SystemAddress& systemAddress);
|
||||
|
@ -119,7 +119,7 @@ void VanityUtilities::SpawnVanity() {
|
||||
|
||||
auto* scriptComponent = npcEntity->GetComponent<ScriptComponent>();
|
||||
|
||||
if (scriptComponent != nullptr) {
|
||||
if (scriptComponent && !npc.m_Script.empty()) {
|
||||
scriptComponent->SetScript(npc.m_Script);
|
||||
|
||||
for (const auto& npc : npc.m_Flags) {
|
||||
@ -162,7 +162,7 @@ Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoin
|
||||
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventoryComponent != nullptr) {
|
||||
if (inventoryComponent && !inventory.empty()) {
|
||||
inventoryComponent->SetNPCItems(inventory);
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,33 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
|
||||
inStream.Read(angVelocity.z);
|
||||
}
|
||||
|
||||
// TODO figure out how to use these. Ignoring for now, but reading in if they exist.
|
||||
bool hasLocalSpaceInfo{};
|
||||
LWOOBJID objectId{};
|
||||
NiPoint3 localSpacePosition{};
|
||||
bool hasLinearVelocity{};
|
||||
NiPoint3 linearVelocity{};
|
||||
if (inStream.Read(hasLocalSpaceInfo) && hasLocalSpaceInfo) {
|
||||
inStream.Read(objectId);
|
||||
inStream.Read(localSpacePosition.x);
|
||||
inStream.Read(localSpacePosition.y);
|
||||
inStream.Read(localSpacePosition.z);
|
||||
if (inStream.Read(hasLinearVelocity) && hasLinearVelocity) {
|
||||
inStream.Read(linearVelocity.x);
|
||||
inStream.Read(linearVelocity.y);
|
||||
inStream.Read(linearVelocity.z);
|
||||
}
|
||||
}
|
||||
bool hasRemoteInputInfo{};
|
||||
RemoteInputInfo remoteInput{};
|
||||
|
||||
if (inStream.Read(hasRemoteInputInfo) && hasRemoteInputInfo) {
|
||||
inStream.Read(remoteInput.m_RemoteInputX);
|
||||
inStream.Read(remoteInput.m_RemoteInputY);
|
||||
inStream.Read(remoteInput.m_IsPowersliding);
|
||||
inStream.Read(remoteInput.m_IsModified);
|
||||
}
|
||||
|
||||
bool updateChar = true;
|
||||
|
||||
if (possessorComponent != nullptr) {
|
||||
@ -150,9 +177,6 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
|
||||
|
||||
auto* havokVehiclePhysicsComponent = possassableEntity->GetComponent<HavokVehiclePhysicsComponent>();
|
||||
if (havokVehiclePhysicsComponent != nullptr) {
|
||||
// This is flipped for whatever reason
|
||||
rotation = NiQuaternion(rotation.z, rotation.y, rotation.x, rotation.w);
|
||||
|
||||
havokVehiclePhysicsComponent->SetPosition(position);
|
||||
havokVehiclePhysicsComponent->SetRotation(rotation);
|
||||
havokVehiclePhysicsComponent->SetIsOnGround(onGround);
|
||||
@ -161,6 +185,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
|
||||
havokVehiclePhysicsComponent->SetDirtyVelocity(velocityFlag);
|
||||
havokVehiclePhysicsComponent->SetAngularVelocity(angVelocity);
|
||||
havokVehiclePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag);
|
||||
havokVehiclePhysicsComponent->SetRemoteInputInfo(remoteInput);
|
||||
} else {
|
||||
// Need to get the mount's controllable physics
|
||||
auto* controllablePhysicsComponent = possassableEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
|
@ -43,15 +43,7 @@ void MastTeleport::OnTimerDone(Entity* self, std::string timerName) {
|
||||
|
||||
GameMessages::SendTeleport(playerId, position, rotation, player->GetSystemAddress(), true);
|
||||
|
||||
// Hacky fix for odd rotations
|
||||
auto mastName = self->GetVar<std::u16string>(u"MastName");
|
||||
if (mastName == u"Elephant") {
|
||||
GameMessages::SendOrientToAngle(playerId, true, (M_PI / 180) * 140.0f, player->GetSystemAddress());
|
||||
} else if (mastName == u"Jail") {
|
||||
GameMessages::SendOrientToAngle(playerId, true, (M_PI / 180) * 100.0f, player->GetSystemAddress());
|
||||
} else if (mastName == u""){
|
||||
GameMessages::SendOrientToAngle(playerId, true, (M_PI / 180) * 203.0f, player->GetSystemAddress());
|
||||
}
|
||||
GameMessages::SendTeleport(playerId, position, rotation, player->GetSystemAddress(), true);
|
||||
|
||||
const auto cinematic = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"Cinematic"));
|
||||
const auto leanIn = self->GetVar<float>(u"LeanIn");
|
||||
|
@ -6,8 +6,7 @@ void BaseFootRaceManager::OnStartup(Entity* self) {
|
||||
// TODO: Add to FootRaceStarter group
|
||||
}
|
||||
|
||||
void BaseFootRaceManager::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1,
|
||||
int32_t param2, int32_t param3) {
|
||||
void BaseFootRaceManager::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
|
||||
const auto splitArguments = GeneralUtils::SplitString(args, '_');
|
||||
if (splitArguments.size() > 1) {
|
||||
|
||||
@ -37,7 +36,7 @@ void BaseFootRaceManager::OnFireEventServerSide(Entity* self, Entity* sender, st
|
||||
if (character != nullptr) {
|
||||
character->SetPlayerFlag(115, false);
|
||||
if (param2 != -1) // Certain footraces set a flag
|
||||
character->SetPlayerFlag(static_cast<uint32_t>(param2), true);
|
||||
character->SetPlayerFlag(param2, true);
|
||||
}
|
||||
|
||||
StopActivity(self, player->GetObjectID(), 0, param1);
|
||||
|
@ -30,12 +30,6 @@ public:
|
||||
struct SceneObjectDataChunk {
|
||||
std::map<LWOOBJID, SceneObject> objects;
|
||||
|
||||
SceneObject& GetObject(LWOOBJID id) {
|
||||
for (std::map<LWOOBJID, SceneObject>::iterator it = objects.begin(); it != objects.end(); ++it) {
|
||||
if (it->first == id) return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
const void PrintAllObjects() {
|
||||
for (std::map<LWOOBJID, SceneObject>::iterator it = objects.begin(); it != objects.end(); ++it) {
|
||||
std::cout << "\t ID: " << it->first << " LOT: " << it->second.lot << std::endl;
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM gcc:11 as build
|
||||
FROM gcc:12 as build
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
@ -40,7 +40,7 @@ RUN echo "Build server" && \
|
||||
cmake .. -DCMAKE_BUILD_RPATH_USE_ORIGIN=TRUE && \
|
||||
make -j $BUILD_THREADS
|
||||
|
||||
FROM gcc:11 as runtime
|
||||
FROM gcc:12 as runtime
|
||||
|
||||
RUN --mount=type=cache,id=runtime-apt-cache,target=/var/cache/apt \
|
||||
apt update && \
|
||||
|
Loading…
Reference in New Issue
Block a user