mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +00:00
Refactor: Amf3 implementation (#998)
* Update AMFDeserializeTests.cpp Redo Amf3 functionality Overhaul the whole thing due to it being outdated and clunky to use Sometimes you want to keep the value Update AMFDeserializeTests.cpp * Fix enum and constructors Correct enum to a class and simplify names. Add a proper default constructor * Update MasterServer.cpp * Fix bugs and add more tests * Refactor: AMF with templates in mind - Remove hard coded bodge - Use templates and generics to allow for much looser typing and strengthened implementation - Move code into header only implementation for portability Refactor: Convert AMF implementation to templates - Rip out previous implementation - Remove all extraneous terminology - Add proper overloads for all types of inserts - Fix up tests and codebase * Fix compiler errors * Check for null first * Add specialization for const char* * Update tests for new template specialization * Switch BitStream to use references * Rename files * Check enum bounds on deserialize I did this on a phone
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
#include "BinaryPathFinder.h"
|
||||
#include "dConfig.h"
|
||||
#include "eBubbleType.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "MovingPlatformComponent.h"
|
||||
#include "eMissionState.h"
|
||||
#include "TriggerComponent.h"
|
||||
@@ -251,26 +251,20 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
{
|
||||
AMFArrayValue args;
|
||||
|
||||
auto* state = new AMFStringValue();
|
||||
state->SetStringValue("Story");
|
||||
args.Insert("state", "Story");
|
||||
|
||||
args.InsertValue("state", state);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", args);
|
||||
}
|
||||
|
||||
entity->AddCallbackTimer(0.5f, [customText, entity]() {
|
||||
AMFArrayValue args;
|
||||
|
||||
auto* text = new AMFStringValue();
|
||||
text->SetStringValue(customText);
|
||||
|
||||
args.InsertValue("visible", new AMFTrueValue());
|
||||
args.InsertValue("text", text);
|
||||
args.Insert("visible", true);
|
||||
args.Insert("text", customText);
|
||||
|
||||
Game::logger->Log("SlashCommandHandler", "Sending %s", customText.c_str());
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", args);
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -530,12 +524,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
if (chatCommand == "setuistate" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
AMFStringValue* value = new AMFStringValue();
|
||||
value->SetStringValue(args[0]);
|
||||
AMFArrayValue uiState;
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("state", value);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "pushGameState", &args);
|
||||
uiState.Insert("state", args.at(0));
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "pushGameState", uiState);
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Switched UI state.");
|
||||
|
||||
@@ -543,11 +536,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
|
||||
if (chatCommand == "toggle" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
AMFTrueValue* value = new AMFTrueValue();
|
||||
|
||||
AMFArrayValue amfArgs;
|
||||
amfArgs.InsertValue("visible", value);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, args[0], &amfArgs);
|
||||
|
||||
amfArgs.Insert("visible", true);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, args[0], amfArgs);
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Toggled UI state.");
|
||||
|
||||
@@ -1617,7 +1610,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if ((chatCommand == "debugui") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Opening UIDebugger...");
|
||||
AMFArrayValue args;
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "ToggleUIDebugger;", nullptr);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "ToggleUIDebugger;", args);
|
||||
}
|
||||
|
||||
if ((chatCommand == "boost") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
@@ -2023,15 +2016,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
void SlashCommandHandler::SendAnnouncement(const std::string& title, const std::string& message) {
|
||||
AMFArrayValue args;
|
||||
auto* titleValue = new AMFStringValue();
|
||||
titleValue->SetStringValue(title);
|
||||
auto* messageValue = new AMFStringValue();
|
||||
messageValue->SetStringValue(message);
|
||||
|
||||
args.InsertValue("title", titleValue);
|
||||
args.InsertValue("message", messageValue);
|
||||
args.Insert("title", title);
|
||||
args.Insert("message", message);
|
||||
|
||||
GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", &args);
|
||||
GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", args);
|
||||
|
||||
//Notify chat about it
|
||||
CBITSTREAM;
|
||||
|
Reference in New Issue
Block a user