refactor: remaining game messages as structs, switch removed

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>
This commit is contained in:
Aaron Kimbrell
2026-09-27 00:49:30 -05:00
parent 05e6bf18fe
commit acdfd2212d
143 changed files with 5376 additions and 2698 deletions

View File

@@ -2,6 +2,7 @@
#include "Entity.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "MovementMessages.h"
#include "ProximityMonitorComponent.h"
void AgBusDoor::OnStartup(Entity* self) {
@@ -49,9 +50,9 @@ void AgBusDoor::OnProximityUpdate(Entity* self, Entity* entering, std::string na
void AgBusDoor::MoveDoor(Entity* self, bool bOpen) {
if (bOpen) {
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, true, 1, 0);
GameMessages::PlatformResync(*self, true, 1, 0).Send(UNASSIGNED_SYSTEM_ADDRESS);
} else {
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, true, 0, 1);
GameMessages::PlatformResync(*self, true, 0, 1).Send(UNASSIGNED_SYSTEM_ADDRESS);
self->AddTimer("dustTimer", 2.0f);
}

View File

@@ -6,6 +6,7 @@
#include "DestroyableComponent.h"
#include "eReplicaComponentType.h"
#include "Loot.h"
#include "InventoryMessages.h"
void AgImagSmashable::OnDie(Entity* self, Entity* killer) {
bool maxImagGreaterThanZero = false;

View File

@@ -1,6 +1,7 @@
#include "AgJetEffectServer.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "ObjectMessages.h"
#include "EntityManager.h"
#include "SkillComponent.h"
#include "eReplicaComponentType.h"
@@ -8,9 +9,7 @@
void AgJetEffectServer::OnUse(Entity* self, Entity* user) {
if (inUse || self->GetLOT() != 6859) return;
GameMessages::SendNotifyClientObject(
self->GetObjectID(), u"toggleInUse", 1, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS
);
GameMessages::NotifyClientObject(self->GetObjectID(), u"toggleInUse", 1, 0, LWOOBJID_EMPTY, "").Send(UNASSIGNED_SYSTEM_ADDRESS);
inUse = true;
auto entities = Game::entityManager->GetEntitiesInGroup("Jet_FX");
@@ -53,9 +52,7 @@ void AgJetEffectServer::OnTimerDone(Entity* self, std::string timerName) {
auto* skillComponent = mortar->GetComponent<SkillComponent>();
if (skillComponent) skillComponent->CastSkill(318);
} else if (timerName == "CineDone") {
GameMessages::SendNotifyClientObject(
self->GetObjectID(), u"toggleInUse", -1, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS
);
GameMessages::NotifyClientObject(self->GetObjectID(), u"toggleInUse", -1, 0, LWOOBJID_EMPTY, "").Send(UNASSIGNED_SYSTEM_ADDRESS);
inUse = false;
}
}

View File

@@ -1,11 +1,13 @@
#include "AgPicnicBlanket.h"
#include "Loot.h"
#include "GameMessages.h"
#include "ObjectMessages.h"
#include "Entity.h"
#include "eTerminateType.h"
#include "InventoryMessages.h"
void AgPicnicBlanket::OnUse(Entity* self, Entity* user) {
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
GameMessages::TerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()).Send(UNASSIGNED_SYSTEM_ADDRESS);
if (self->GetVar<bool>(u"active"))
return;
self->SetVar<bool>(u"active", true);

View File

@@ -1,6 +1,7 @@
#include "AgQbElevator.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "MovementMessages.h"
void AgQbElevator::OnStartup(Entity* self) {
@@ -14,8 +15,7 @@ void AgQbElevator::OnQuickBuildComplete(Entity* self, Entity* target) {
float delayTime = killTime - endTime;
if (delayTime < 1) delayTime = 1;
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, true, 0,
0, 0, eMovementPlatformState::Stationary);
GameMessages::PlatformResync(*self, true, 0, 0, 0, eMovementPlatformState::Stationary).Send(UNASSIGNED_SYSTEM_ADDRESS);
//add a timer that will kill the QB if no players get on in the killTime
self->AddTimer("startKillTimer", killTime);
@@ -32,8 +32,7 @@ void AgQbElevator::OnProximityUpdate(Entity* self, Entity* entering, std::string
self->SetBoolean(u"qbPlayerRdy", true);
self->CancelTimer("StartElevator");
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, true, 0,
1, 1, eMovementPlatformState::Moving);
GameMessages::PlatformResync(*self, true, 0, 1, 1, eMovementPlatformState::Moving).Send(UNASSIGNED_SYSTEM_ADDRESS);
} else if (!self->GetBoolean(u"StartTimer")) {
self->SetBoolean(u"StartTimer", true);
self->AddTimer("StartElevator", startTime);
@@ -44,8 +43,7 @@ void AgQbElevator::OnProximityUpdate(Entity* self, Entity* entering, std::string
void AgQbElevator::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "StartElevator") {
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, true, 0,
1, 1, eMovementPlatformState::Moving);
GameMessages::PlatformResync(*self, true, 0, 1, 1, eMovementPlatformState::Moving).Send(UNASSIGNED_SYSTEM_ADDRESS);
} else if (timerName == "startKillTimer") {
killTimerStartup(self);
} else if (timerName == "KillTimer") {

View File

@@ -2,12 +2,13 @@
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "ObjectMessages.h"
#include "RenderComponent.h"
#include "Entity.h"
#include "eTerminateType.h"
void AgShipPlayerShockServer::OnUse(Entity* self, Entity* user) {
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
GameMessages::TerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()).Send(UNASSIGNED_SYSTEM_ADDRESS);
if (active) {
return;
}

View File

@@ -1,5 +1,6 @@
#include "AgTurret.h"
#include "GameMessages.h"
#include "MovementMessages.h"
void AgTurret::OnStartup(Entity* self) {
// TODO: do this legit way
@@ -13,5 +14,8 @@ void AgTurret::OnTimerDone(Entity* self, std::string timerName) {
}
void AgTurret::OnQuickBuildStart(Entity* self, Entity* user) {
GameMessages::SendLockNodeRotation(self, "base");
GameMessages::LockNodeRotation lockNodeRotation;
lockNodeRotation.target = self->GetObjectID();
lockNodeRotation.nodeName = "base";
lockNodeRotation.Send(UNASSIGNED_SYSTEM_ADDRESS);
}

View File

@@ -1,6 +1,7 @@
#include "FvConsoleLeftQuickbuild.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "ObjectMessages.h"
#include "eTerminateType.h"
#include "eQuickBuildState.h"
@@ -45,5 +46,5 @@ void FvConsoleLeftQuickbuild::OnUse(Entity* self, Entity* user) {
}
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
GameMessages::TerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()).Send(UNASSIGNED_SYSTEM_ADDRESS);
}

View File

@@ -1,6 +1,7 @@
#include "FvConsoleRightQuickbuild.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "ObjectMessages.h"
#include "eTerminateType.h"
#include "eQuickBuildState.h"
@@ -45,5 +46,5 @@ void FvConsoleRightQuickbuild::OnUse(Entity* self, Entity* user) {
}
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
GameMessages::TerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()).Send(UNASSIGNED_SYSTEM_ADDRESS);
}

View File

@@ -2,6 +2,7 @@
#include "Character.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "ObjectMessages.h"
#include "EntityInfo.h"
#include "ScriptedActivityComponent.h"
@@ -21,16 +22,14 @@ void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
// If the player already spawned a panda
auto playerPandas = Game::entityManager->GetEntitiesInGroup("panda" + std::to_string(target->GetObjectID()));
if (!playerPandas.empty()) {
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"playerPanda",
target->GetObjectID(), 0, 0, target->GetObjectID());
GameMessages::FireEventClientSide(self->GetObjectID(), u"playerPanda", target->GetObjectID(), target->GetObjectID()).SendToClient(target->GetSystemAddress());
return;
}
// If there's already too many spawned pandas
auto pandas = Game::entityManager->GetEntitiesInGroup("pandas");
if (pandas.size() > 4) {
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"tooManyPandas",
target->GetObjectID(), 0, 0, target->GetObjectID());
GameMessages::FireEventClientSide(self->GetObjectID(), u"tooManyPandas", target->GetObjectID(), target->GetObjectID()).SendToClient(target->GetSystemAddress());
return;
}

View File

@@ -1,6 +1,7 @@
#include "InstanceExitTransferPlayerToLastNonInstance.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "ObjectMessages.h"
#include "CharacterComponent.h"
#include "Character.h"
#include "dServer.h"
@@ -50,7 +51,7 @@ void InstanceExitTransferPlayerToLastNonInstance::OnMessageBoxResponse(Entity* s
}
}
GameMessages::SendTerminateInteraction(sender->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
GameMessages::TerminateInteraction(sender->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()).Send(UNASSIGNED_SYSTEM_ADDRESS);
}

View File

@@ -3,6 +3,7 @@
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "ActivityMessages.h"
#include "MovementMessages.h"
#include "dZoneManager.h"
#include "Character.h"
#include "ShootingGalleryComponent.h"
@@ -19,6 +20,7 @@
#include "eGameActivity.h"
#include "Item.h"
#include <ranges>
#include "BuildingMessages.h"
void SGCannon::OnStartup(Entity* self) {
LOG("OnStartup");
@@ -314,7 +316,7 @@ void SGCannon::DoSpawnTimerFunc(Entity* self, const std::string& name) {
// Save the enemy and tell it to start pathing
if (enemy != nullptr) {
const_cast<std::vector<LWOOBJID>&>(self->GetVar<std::vector<LWOOBJID>>(SpawnedObjects)).push_back(enemy->GetObjectID());
GameMessages::SendPlatformResync(enemy, UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::PlatformResync(*enemy).Send(UNASSIGNED_SYSTEM_ADDRESS);
}
}
}
@@ -713,12 +715,13 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
UpdateStreak(self);
GameMessages::SendNotifyClientShootingGalleryScore(self->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS,
0.0f,
score,
target->GetObjectID(),
target->GetPosition()
);
GameMessages::NotifyClientShootingGalleryScore galleryScore;
galleryScore.target = self->GetObjectID();
galleryScore.addTime = 0.0f;
galleryScore.score = score;
galleryScore.targetID = target->GetObjectID();
galleryScore.targetPos = target->GetPosition();
galleryScore.Send(UNASSIGNED_SYSTEM_ADDRESS);
auto newScore = self->GetVar<int32_t>(TotalScoreVariable) + score;

View File

@@ -1,6 +1,7 @@
#include "PropertyDeathPlane.h"
#include "Entity.h"
#include "GameMessages.h"
#include "MovementMessages.h"
#include "EntityManager.h"
void PropertyDeathPlane::OnCollisionPhantom(Entity* self, Entity* target) {
@@ -12,5 +13,5 @@ void PropertyDeathPlane::OnCollisionPhantom(Entity* self, Entity* target) {
auto* teleport = teleportGroup[0];
GameMessages::SendTeleport(target->GetObjectID(), teleport->GetPosition(), teleport->GetRotation(), target->GetSystemAddress());
GameMessages::Teleport(target->GetObjectID(), teleport->GetPosition(), teleport->GetRotation()).SendToClient(target->GetSystemAddress());
}

View File

@@ -1,6 +1,8 @@
#include "NsConcertInstrument.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "MovementMessages.h"
#include "ObjectMessages.h"
#include "Item.h"
#include "DestroyableComponent.h"
#include "EntityManager.h"
@@ -71,8 +73,7 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) {
}
if (activePlayer != nullptr && name == "checkPlayer" && self->GetVar<bool>(u"beingPlayed")) {
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"checkMovement", 0, 0,
activePlayer->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::NotifyClientObject(self->GetObjectID(), u"checkMovement", 0, 0, activePlayer->GetObjectID(), "").Send(UNASSIGNED_SYSTEM_ADDRESS);
auto* stats = activePlayer->GetComponent<DestroyableComponent>();
if (stats) {
if (stats->GetImagination() > 0) {
@@ -90,8 +91,7 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) {
} else if (name == "cleanupAfterStop") {
if (activePlayer != nullptr) {
UnEquipInstruments(self, activePlayer);
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"stopPlaying", 0, 0,
activePlayer->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::NotifyClientObject(self->GetObjectID(), u"stopPlaying", 0, 0, activePlayer->GetObjectID(), "").Send(UNASSIGNED_SYSTEM_ADDRESS);
}
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
@@ -120,8 +120,7 @@ void NsConcertInstrument::StartPlayingInstrument(Entity* self, Entity* player) {
// Stuff to notify the player
EquipInstruments(self, player);
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"startPlaying", 0, 0,
player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::NotifyClientObject(self->GetObjectID(), u"startPlaying", 0, 0, player->GetObjectID(), "").Send(UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::PlayCinematic cinematic;
cinematic.target = player->GetObjectID();
cinematic.pathName = cinematics.at(instrumentLot);
@@ -163,8 +162,7 @@ void NsConcertInstrument::StopPlayingInstrument(Entity* self, Entity* player) {
endCinematic.leadOut = 1.0f;
endCinematic.Send(UNASSIGNED_SYSTEM_ADDRESS);
RenderComponent::PlayAnimation(player, smashAnimations.at(instrumentLot), 2.0f);
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"stopCheckingMovement", 0, 0,
player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::NotifyClientObject(self->GetObjectID(), u"stopCheckingMovement", 0, 0, player->GetObjectID(), "").Send(UNASSIGNED_SYSTEM_ADDRESS);
}
self->SetVar<bool>(u"beingPlayed", false);
@@ -288,7 +286,7 @@ void NsConcertInstrument::RepositionPlayer(Entity* self, Entity* player) {
break;
}
GameMessages::SendTeleport(player->GetObjectID(), position, rotation, player->GetSystemAddress());
GameMessages::Teleport(player->GetObjectID(), position, rotation).SendToClient(player->GetSystemAddress());
}
InstrumentLot NsConcertInstrument::GetInstrumentLot(Entity* self) {

View File

@@ -2,6 +2,7 @@
#include "EntityManager.h"
#include "GameMessages.h"
#include "Loot.h"
#include "InventoryMessages.h"
void NsQbImaginationStatue::OnStartup(Entity* self) {

View File

@@ -3,6 +3,7 @@
#include "EntityManager.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "ObjectMessages.h"
void RockHydrantBroken::OnStartup(Entity* self) {
self->AddTimer("playEffect", 1);
@@ -20,7 +21,7 @@ void RockHydrantBroken::OnStartup(Entity* self) {
msg.bActive = true;
msg.Send(UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::NotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision").Send(UNASSIGNED_SYSTEM_ADDRESS);
}
self->AddTimer("KillBroken", 10);
@@ -36,7 +37,7 @@ void RockHydrantBroken::OnTimerDone(Entity* self, std::string timerName) {
msg.bActive = false;
msg.Send(UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision", UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::NotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision").Send(UNASSIGNED_SYSTEM_ADDRESS);
}
self->Kill();

View File

@@ -2,6 +2,7 @@
#include "Character.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "ObjectMessages.h"
#include "EntityManager.h"
#include "dZoneManager.h"
#include "eMissionState.h"
@@ -25,8 +26,7 @@ void AgPropguards::OnMissionDialogueOK(Entity* self, Entity* target, int mission
} else if (missionState == eMissionState::READY_TO_COMPLETE) {
// Makes the guard disappear once the mission has been completed
const auto zoneControlID = Game::entityManager->GetZoneControlEntity()->GetObjectID();
GameMessages::SendNotifyClientObject(zoneControlID, u"GuardChat", 0, 0, self->GetObjectID(),
"", UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::NotifyClientObject(zoneControlID, u"GuardChat", 0, 0, self->GetObjectID(), "").Send(UNASSIGNED_SYSTEM_ADDRESS);
self->AddCallbackTimer(5.0f, [self]() {
auto spawnerName = self->GetVar<std::string>(u"spawner_name");