mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-06-11 04:35:39 +00:00
fix: playing an emote not showing on all clients (#1800)
* Fix emote broadcast failure with adding new GameMsg * Remove PlayAnimation ()function in place of EmotePlayed() Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> * Change int casting methodology to explicit int32_t for consistency * Set default behavior for EmotePlayed struct This is to avoid undefined behavior when using method --------- Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
This commit is contained in:
parent
e42df5b02e
commit
891b176b4f
@ -942,6 +942,11 @@ void PetComponent::Command(const NiPoint3& position, const LWOOBJID source, cons
|
||||
if (commandType == 1) {
|
||||
// Emotes
|
||||
GameMessages::SendPlayEmote(m_Parent->GetObjectID(), typeId, owner->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::EmotePlayed msg;
|
||||
msg.target = owner->GetObjectID();
|
||||
msg.emoteID = typeId;
|
||||
msg.targetID = 0; // Or set to the intended target entity's ID, or 0 if no target
|
||||
msg.Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||
} else if (commandType == 3) {
|
||||
// Follow me, ???
|
||||
} else if (commandType == 6) {
|
||||
|
@ -4963,7 +4963,7 @@ void GameMessages::HandleQuickBuildCancel(RakNet::BitStream& inStream, Entity* e
|
||||
}
|
||||
|
||||
void GameMessages::HandlePlayEmote(RakNet::BitStream& inStream, Entity* entity) {
|
||||
int emoteID;
|
||||
int32_t emoteID;
|
||||
LWOOBJID targetID;
|
||||
|
||||
inStream.Read(emoteID);
|
||||
@ -4982,7 +4982,11 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream& inStream, Entity* entity)
|
||||
if (emote) sAnimationName = emote->animationName;
|
||||
}
|
||||
|
||||
RenderComponent::PlayAnimation(entity, sAnimationName);
|
||||
GameMessages::EmotePlayed msg;
|
||||
msg.target = entity->GetObjectID();
|
||||
msg.emoteID = emoteID;
|
||||
msg.targetID = targetID; // The emote’s target entity or 0 if none
|
||||
msg.Send(UNASSIGNED_SYSTEM_ADDRESS); // Broadcast to all clients
|
||||
|
||||
MissionComponent* missionComponent = entity->GetComponent<MissionComponent>();
|
||||
if (!missionComponent) return;
|
||||
@ -6469,4 +6473,9 @@ namespace GameMessages {
|
||||
stream.Write(soundID != -1);
|
||||
if (soundID != -1) stream.Write(soundID);
|
||||
}
|
||||
|
||||
void EmotePlayed::Serialize(RakNet::BitStream& stream) const {
|
||||
stream.Write(emoteID);
|
||||
stream.Write(targetID);
|
||||
}
|
||||
}
|
||||
|
@ -833,6 +833,15 @@ namespace GameMessages {
|
||||
struct ResetModelToDefaults : public GameMsg {
|
||||
ResetModelToDefaults() : GameMsg(MessageType::Game::RESET_MODEL_TO_DEFAULTS) {}
|
||||
};
|
||||
};
|
||||
|
||||
struct EmotePlayed : public GameMsg {
|
||||
EmotePlayed() : GameMsg(MessageType::Game::EMOTE_PLAYED), emoteID(0), targetID(0) {}
|
||||
|
||||
void Serialize(RakNet::BitStream& stream) const override;
|
||||
|
||||
int32_t emoteID;
|
||||
LWOOBJID targetID;
|
||||
};
|
||||
|
||||
};
|
||||
#endif // GAMEMESSAGES_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user