mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
Every game message still written or read by hand is now a NetGameMsg with Serialize and Deserialize, in per-domain files: - MovementMessages: teleport, platforms (resync and its request), orient to angle, node rotation lock, gravity scale, jetpack mode, control scheme, respawn checkpoint, rails (set/start, ready, cancel, arrived), mount inventory ID, dismount complete, possession ack, ghost reference override and position, camera cycling (eCameraTargetCyclingMode moves here). - ZoneMessages: player loaded (the old PLAYER_LOADED case), ready for updates, player ready, restore to post load stats, server done loading, invalid zone transfer list, zone summary display/dismissed, level processing complete, object world state, and the localized announcement WorldMigration wrote by hand. - PlayerMessages: chat mode, GM level, LEGO score, currency, reputation, GM invis, pickup currency, zone and player statistics, chat commands, bug reports, verify ack. - ObjectMessages: fire event client/server side, notify client (zone) object, notify object, script network vars, failed preconditions, terminate interaction, set name, request use, request server object info. - QuickBuildMessages: notify state, enable, cancel. - ActivityMessages gains match response/update/request, leaderboard request and data, shooting gallery score/rotation/fire, activity state change. - MissionMessages gains MissionDialogueCancelled (a no-op, as before). The wire structs left in GameMessages.h move to their domains (tooltip and emote to Effects, loot and item use to Inventory, model build to Building, behavior sound to Property, skill sets to Skill) and gain the missing direction. The dismount logic moves to PossessorComponent::OnDismountComplete. Every inbound message is registered in the GameMessageHandler map; the switch is gone, and GameMessages.cpp only holds the GameMsg/NetGameMsg base code. Call sites build the structs (NotifyClientObject, TerminateInteraction, Teleport, PlatformResync, FireEventClientSide, NotifyObject and NotifyClientZoneObject get convenience constructors like PlayFXEffect). Dead senders are dropped: SendSetShootingGalleryParams (no callers, field order was a guess), SendTeamPickupItem (the struct already existed), SendRequestActivitySummaryLeaderboardData (the struct covers it). Verified with RemainingMessagesTests: every old Send* function is frozen verbatim in Legacy/RemainingMessagesLegacy.h and compared byte for byte (same bits, destination and broadcast flag) over grids of inputs; every old Handle* read sequence is frozen as a Read* oracle and compared with the struct's Deserialize; round trips, truncation and a golden packet. PlayerLoaded (0x00dc36f0), SetGMLevel (0x00dd6230), MissionDialogueCancelled (0x00d9cc10) and LocalizedAnnouncementServerToSingleClient (0x00f23c50) were checked against the client. Behaviour notes: an inbound message that fails to deserialize is dropped, so ParseChatMessage over MAX_MESSAGE_LENGTH is dropped instead of truncated, and PLAYER_LOADED / READY_FOR_UPDATES / MISSION_DIALOGUE_CANCELLED now read their (unused) client fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
158 lines
4.9 KiB
C++
158 lines
4.9 KiB
C++
#include "RocketLaunchpadControlComponent.h"
|
|
#include "MasterPackets.h"
|
|
|
|
#include <sstream>
|
|
|
|
#include "GameMessages.h"
|
|
#include "ObjectMessages.h"
|
|
#include "ZoneMessages.h"
|
|
#include "CharacterComponent.h"
|
|
#include "dZoneManager.h"
|
|
#include "EntityManager.h"
|
|
#include "Item.h"
|
|
#include "Game.h"
|
|
#include "Logger.h"
|
|
#include "CDClientDatabase.h"
|
|
#include "ChatPackets.h"
|
|
#include "MissionComponent.h"
|
|
#include "PropertyEntranceComponent.h"
|
|
#include "MultiZoneEntranceComponent.h"
|
|
#include "dServer.h"
|
|
#include "BitStreamUtils.h"
|
|
#include "eObjectWorldState.h"
|
|
#include "ServiceType.h"
|
|
#include "MessageType/Master.h"
|
|
|
|
RocketLaunchpadControlComponent::RocketLaunchpadControlComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
|
|
auto query = CDClientDatabase::CreatePreppedStmt(
|
|
"SELECT targetZone, defaultZoneID, targetScene, altLandingPrecondition, altLandingSpawnPointName FROM RocketLaunchpadControlComponent WHERE id = ?;");
|
|
query.bind(1, componentID);
|
|
|
|
auto result = query.execQuery();
|
|
|
|
if (!result.eof() && !result.fieldIsNull("targetZone")) {
|
|
m_TargetZone = result.getIntField("targetZone");
|
|
m_DefaultZone = result.getIntField("defaultZoneID");
|
|
m_TargetScene = result.getStringField("targetScene");
|
|
m_AltPrecondition = new PreconditionExpression(result.getStringField("altLandingPrecondition"));
|
|
m_AltLandingScene = result.getStringField("altLandingSpawnPointName");
|
|
}
|
|
|
|
result.finalize();
|
|
}
|
|
|
|
RocketLaunchpadControlComponent::~RocketLaunchpadControlComponent() {
|
|
delete m_AltPrecondition;
|
|
}
|
|
|
|
void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId, LWOCLONEID cloneId) {
|
|
auto zone = mapId == LWOMAPID_INVALID ? m_TargetZone : mapId;
|
|
|
|
if (zone == 0) {
|
|
return;
|
|
}
|
|
|
|
// This also gets triggered by a proximity monitor + item equip, I will set that up when havok is ready
|
|
auto* characterComponent = originator->GetComponent<CharacterComponent>();
|
|
auto* character = originator->GetCharacter();
|
|
|
|
if (!characterComponent || !character) return;
|
|
|
|
auto* rocket = characterComponent->GetRocket(originator);
|
|
if (!rocket) {
|
|
LOG("Unable to find rocket!");
|
|
return;
|
|
}
|
|
|
|
// we have the ability to launch, so now we prep the zone
|
|
TellMasterToPrepZone(zone);
|
|
|
|
// Achievement unlocked: "All zones unlocked"
|
|
if (!m_AltLandingScene.empty() && m_AltPrecondition->Check(originator)) {
|
|
character->SetTargetScene(m_AltLandingScene);
|
|
} else {
|
|
character->SetTargetScene(m_TargetScene);
|
|
}
|
|
|
|
characterComponent->UpdatePlayerStatistic(RocketsUsed);
|
|
|
|
character->SaveXMLToDatabase();
|
|
|
|
SetSelectedMapId(originator->GetObjectID(), zone);
|
|
|
|
GameMessages::FireEventClientSide(m_Parent->GetObjectID(), u"RocketEquipped", rocket->GetId(), originator->GetObjectID()).SendToClient(originator->GetSystemAddress());
|
|
|
|
GameMessages::ChangeObjectWorldState worldState;
|
|
worldState.target = rocket->GetId();
|
|
worldState.newState = eObjectWorldState::ATTACHED;
|
|
worldState.Send(UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
Game::entityManager->SerializeEntity(originator);
|
|
}
|
|
|
|
void RocketLaunchpadControlComponent::OnUse(Entity* originator) {
|
|
// If we are have the property or the LUP component, we don't want to immediately launch
|
|
// instead we let their OnUse handlers do their things
|
|
// which components of an Object have their OnUse called when using them
|
|
// so we don't need to call it here
|
|
auto* propertyEntrance = m_Parent->GetComponent<PropertyEntranceComponent>();
|
|
if (propertyEntrance) {
|
|
return;
|
|
}
|
|
|
|
auto* rocketLaunchLUP = m_Parent->GetComponent<MultiZoneEntranceComponent>();
|
|
if (rocketLaunchLUP) {
|
|
return;
|
|
}
|
|
|
|
// No rocket no launch
|
|
auto* rocket = originator->GetComponent<CharacterComponent>()->RocketEquip(originator);
|
|
if (!rocket) {
|
|
return;
|
|
}
|
|
Launch(originator);
|
|
}
|
|
|
|
void RocketLaunchpadControlComponent::OnProximityUpdate(Entity* entering, std::string name, std::string status) {
|
|
// Proximity rockets are handled by item equipment
|
|
}
|
|
|
|
void RocketLaunchpadControlComponent::SetSelectedMapId(LWOOBJID player, LWOMAPID mapID) {
|
|
m_SelectedMapIds[player] = mapID;
|
|
}
|
|
|
|
LWOMAPID RocketLaunchpadControlComponent::GetSelectedMapId(LWOOBJID player) const {
|
|
const auto index = m_SelectedMapIds.find(player);
|
|
|
|
if (index == m_SelectedMapIds.end()) return 0;
|
|
|
|
return index->second;
|
|
}
|
|
|
|
void RocketLaunchpadControlComponent::SetSelectedCloneId(LWOOBJID player, LWOCLONEID cloneId) {
|
|
m_SelectedCloneIds[player] = cloneId;
|
|
}
|
|
|
|
LWOCLONEID RocketLaunchpadControlComponent::GetSelectedCloneId(LWOOBJID player) const {
|
|
const auto index = m_SelectedCloneIds.find(player);
|
|
|
|
if (index == m_SelectedCloneIds.end()) return 0;
|
|
|
|
return index->second;
|
|
}
|
|
|
|
void RocketLaunchpadControlComponent::TellMasterToPrepZone(int zoneID) {
|
|
MasterPackets::PrepZone request;
|
|
request.zoneID = zoneID;
|
|
MasterPackets::SendToMaster(request);
|
|
}
|
|
|
|
|
|
LWOMAPID RocketLaunchpadControlComponent::GetTargetZone() const {
|
|
return m_TargetZone;
|
|
}
|
|
|
|
LWOMAPID RocketLaunchpadControlComponent::GetDefaultZone() const {
|
|
return m_DefaultZone;
|
|
}
|