mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
6a38b67ed5
* General AMF cleanup Proper memory management as well as style cleanup * General optimizations Fix AMFArray so values are properly deleted when you leave the scope it was created in. Add bounds check for deletion so you don't double delete. Remove all AMFdeletions that are contained in an array since the array now manages its own memory and deletes it when it is no longer needed. * Better tests and fix de-serialize Fix de-serialize to be correct and implement a test to check this * Update AMFDeserializeTests.cpp * Update AMFFormat.cpp
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
#include "StoryBoxInteractServer.h"
|
|
#include "Character.h"
|
|
#include "GameMessages.h"
|
|
#include "dServer.h"
|
|
#include "AMFFormat.h"
|
|
|
|
void StoryBoxInteractServer::OnUse(Entity* self, Entity* user) {
|
|
if (self->GetVar<bool>(u"hasCustomText"))
|
|
{
|
|
const auto& customText = self->GetVar<std::string>(u"customText");
|
|
|
|
{
|
|
AMFArrayValue args;
|
|
|
|
auto* state = new AMFStringValue();
|
|
state->SetStringValue("Story");
|
|
|
|
args.InsertValue("state", state);
|
|
|
|
GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "pushGameState", &args);
|
|
}
|
|
|
|
user->AddCallbackTimer(0.1f, [user, customText] () {
|
|
AMFArrayValue args;
|
|
|
|
auto* text = new AMFStringValue();
|
|
text->SetStringValue(customText);
|
|
|
|
args.InsertValue("visible", new AMFTrueValue());
|
|
args.InsertValue("text", text);
|
|
|
|
GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "ToggleStoryBox", &args);
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
const auto storyText = self->GetVarAsString(u"storyText");
|
|
|
|
int32_t boxFlag = self->GetVar<int32_t>(u"altFlagID");
|
|
if (boxFlag <= 0)
|
|
{
|
|
boxFlag = (10000 + Game::server->GetZoneID() +std::stoi(storyText.substr(storyText.length() - 2)));
|
|
}
|
|
|
|
if (user->GetCharacter()->GetPlayerFlag(boxFlag) == false) {
|
|
user->GetCharacter()->SetPlayerFlag(boxFlag, true);
|
|
GameMessages::SendFireEventClientSide(self->GetObjectID(), user->GetSystemAddress(), u"achieve", LWOOBJID_EMPTY, 0, -1, LWOOBJID_EMPTY);
|
|
}
|
|
} |