mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-19 18:25:27 +00:00
feat(missions): keep the viewed flag of missions in progress, as the client
The client keeps a viewed flag on each mission in progress, sets it with SetMissionViewed (LWOMissionComponent::msgSetMissionViewed 0x00bec7a0, only for missions in progress) and reads it as v on the mission's <cur> entry (LWOMissionComponent::LoadFromSaveData 0x00d171c0, a number or "true", false when missing). The server now handles SetMissionViewed, saves v="1" for a viewed mission in progress and loads it back; saves without v load as not viewed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -130,6 +130,7 @@ json ToJson(const GameMessages::SetFlag& m);
|
||||
json ToJson(const GameMessages::NotifyClientFlagChange& m);
|
||||
json ToJson(const GameMessages::HasBeenCollected& m);
|
||||
json ToJson(const GameMessages::SetMissionTypeState& m);
|
||||
json ToJson(const GameMessages::SetMissionViewed& m);
|
||||
json ToJson(const GameMessages::NotifyLevelRewards& m);
|
||||
json ToJson(const GameMessages::Teleport& m);
|
||||
json ToJson(const GameMessages::StartPathing& m);
|
||||
@@ -1319,6 +1320,12 @@ json ToJson(const GameMessages::SetMissionTypeState& m) {
|
||||
j["type"] = ToJson(m.type);
|
||||
return j;
|
||||
}
|
||||
json ToJson(const GameMessages::SetMissionViewed& m) {
|
||||
json j = json::object();
|
||||
j["missionID"] = ToJson(m.missionID);
|
||||
j["viewed"] = ToJson(m.viewed);
|
||||
return j;
|
||||
}
|
||||
json ToJson(const GameMessages::NotifyLevelRewards& m) {
|
||||
json j = json::object();
|
||||
j["level"] = ToJson(m.level);
|
||||
@@ -2643,6 +2650,7 @@ const std::vector<Entry>& Entries() {
|
||||
{ MessageType::Game::NOTIFY_CLIENT_FLAG_CHANGE, eDirection::TO_CLIENT, "NotifyClientFlagChange", &ReadWith<GameMessages::NotifyClientFlagChange> },
|
||||
{ MessageType::Game::HAS_BEEN_COLLECTED, eDirection::TO_SERVER, "HasBeenCollected", &ReadWith<GameMessages::HasBeenCollected> },
|
||||
{ MessageType::Game::SET_MISSION_TYPE_STATE, eDirection::TO_SERVER, "SetMissionTypeState", &ReadWith<GameMessages::SetMissionTypeState> },
|
||||
{ MessageType::Game::SET_MISSION_VIEWED, eDirection::TO_SERVER, "SetMissionViewed", &ReadWith<GameMessages::SetMissionViewed> },
|
||||
{ MessageType::Game::NOTIFY_LEVEL_REWARDS, eDirection::TO_CLIENT, "NotifyLevelRewards", &ReadWith<GameMessages::NotifyLevelRewards> },
|
||||
{ MessageType::Game::TELEPORT, eDirection::TO_CLIENT, "Teleport", &ReadWith<GameMessages::Teleport> },
|
||||
{ MessageType::Game::START_PATHING, eDirection::TO_CLIENT, "StartPathing", &ReadWith<GameMessages::StartPathing> },
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace {
|
||||
{ SET_FLAG, []() { return std::make_unique<SetFlag>(); } },
|
||||
{ HAS_BEEN_COLLECTED, []() { return std::make_unique<HasBeenCollected>(); } },
|
||||
{ SET_MISSION_TYPE_STATE, []() { return std::make_unique<SetMissionTypeState>(); } },
|
||||
{ SET_MISSION_VIEWED, []() { return std::make_unique<SetMissionViewed>(); } },
|
||||
|
||||
// Effects, emotes, cinematics, UI
|
||||
{ PLAY_EMOTE, []() { return std::make_unique<PlayEmote>(); } },
|
||||
|
||||
@@ -273,6 +273,22 @@ namespace GameMessages {
|
||||
if (missionComponent) missionComponent->SetMissionTypeState(type, subtype, state);
|
||||
}
|
||||
|
||||
void SetMissionViewed::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(missionID);
|
||||
bitStream.Write(viewed);
|
||||
}
|
||||
|
||||
bool SetMissionViewed::Deserialize(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(missionID));
|
||||
VALIDATE_READ(bitStream.Read(viewed));
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetMissionViewed::Handle(Entity& entity, const SystemAddress& sysAddr) {
|
||||
auto* const missionComponent = entity.GetComponent<MissionComponent>();
|
||||
if (missionComponent) missionComponent->SetMissionViewed(missionID, viewed);
|
||||
}
|
||||
|
||||
void NotifyLevelRewards::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(level);
|
||||
bitStream.Write(sendingRewards);
|
||||
|
||||
@@ -149,6 +149,18 @@ namespace GameMessages {
|
||||
std::string type{};
|
||||
};
|
||||
|
||||
// Client -> server. The player looked at a mission in progress (LWOMissionComponent::msgSetMissionViewed 0x00bec7a0);
|
||||
// the server keeps it and saves it as v on the mission's <cur> entry, which the client reads on load.
|
||||
struct SetMissionViewed : public NetGameMsg {
|
||||
SetMissionViewed() : NetGameMsg(MessageType::Game::SET_MISSION_VIEWED) {}
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
void Handle(Entity& entity, const SystemAddress& sysAddr) override;
|
||||
|
||||
int32_t missionID{};
|
||||
bool viewed{};
|
||||
};
|
||||
|
||||
// Server -> client.
|
||||
struct NotifyLevelRewards : public NetGameMsg {
|
||||
NotifyLevelRewards() : NetGameMsg(MessageType::Game::NOTIFY_LEVEL_REWARDS) {}
|
||||
|
||||
Reference in New Issue
Block a user