Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
wincent
2024-01-16 21:46:31 +01:00
597 changed files with 12170 additions and 9657 deletions

View File

@@ -1,4 +1,9 @@
set(DGAME_DGAMEMESSAGES_SOURCES "GameMessageHandler.cpp"
set(DGAME_DGAMEMESSAGES_SOURCES
"GameMessageHandler.cpp"
"GameMessages.cpp"
"PropertyDataMessage.cpp"
"PropertySelectQueryProperty.cpp" PARENT_SCOPE)
"PropertySelectQueryProperty.cpp")
add_library(dGameMessages STATIC ${DGAME_DGAMEMESSAGES_SOURCES})
target_link_libraries(dGameMessages PUBLIC dDatabase)
target_precompile_headers(dGameMessages REUSE_FROM dGameBase)

View File

@@ -7,7 +7,7 @@
#include "MissionComponent.h"
#include "BitStreamUtils.h"
#include "dServer.h"
#include "../thirdparty/raknet/Source/RakNetworkFactory.h"
#include "RakNetworkFactory.h"
#include <future>
#include "User.h"
#include "UserManager.h"
@@ -34,8 +34,11 @@
#include "eMissionTaskType.h"
#include "eReplicaComponentType.h"
#include "eConnectionType.h"
using namespace std;
#include "eGameMessageType.h"
#include "ePlayerFlag.h"
#include "dConfig.h"
#include "GhostComponent.h"
#include "StringifiedEnum.h"
void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID) {
@@ -47,11 +50,11 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
User* usr = UserManager::Instance()->GetUser(sysAddr);
if (!entity) {
LOG("Failed to find associated entity (%llu), aborting GM (%X)!", objectID, messageID);
LOG("Failed to find associated entity (%llu), aborting GM: %4i, %s!", objectID, messageID, StringifiedEnum::ToString(messageID).data());
return;
}
if (messageID != eGameMessageType::READY_FOR_UPDATES) LOG_DEBUG("received game message ID: %i", messageID);
if (messageID != eGameMessageType::READY_FOR_UPDATES) LOG_DEBUG("Received GM with ID and name: %4i, %s", messageID, StringifiedEnum::ToString(messageID).data());
switch (messageID) {
@@ -106,9 +109,9 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
GameMessages::SendRestoreToPostLoadStats(entity, sysAddr);
entity->SetPlayerReadyForUpdates();
auto* player = dynamic_cast<Player*>(entity);
if (player != nullptr) {
player->ConstructLimboEntities();
auto* ghostComponent = entity->GetComponent<GhostComponent>();
if (ghostComponent != nullptr) {
ghostComponent->ConstructLimboEntities();
}
InventoryComponent* inv = entity->GetComponent<InventoryComponent>();
@@ -135,14 +138,14 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
script->OnPlayerLoaded(zoneControl, player);
script->OnPlayerLoaded(zoneControl, entity);
}
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
for (Entity* scriptEntity : scriptedActs) {
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
script->OnPlayerLoaded(scriptEntity, player);
script->OnPlayerLoaded(scriptEntity, entity);
}
}
}
@@ -173,6 +176,13 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
GameMessages::SendPlayerReady(entity, sysAddr);
GameMessages::SendPlayerReady(Game::zoneManager->GetZoneControlObject(), sysAddr);
if (Game::config->GetValue("allow_players_to_skip_cinematics") != "1"
|| !entity->GetCharacter()
|| !entity->GetCharacter()->GetPlayerFlag(ePlayerFlag::DLU_SKIP_CINEMATICS)) return;
entity->AddCallbackTimer(0.5f, [entity, sysAddr]() {
if (!entity) return;
GameMessages::SendEndCinematic(entity->GetObjectID(), u"", sysAddr);
});
break;
}
@@ -187,8 +197,8 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
}
case eGameMessageType::MISSION_DIALOGUE_CANCELLED: {
//This message is pointless for our implementation, as the client just carries on after
//rejecting a mission offer. We dont need to do anything. This is just here to remove a warning in our logs :)
// This message is pointless for our implementation, as the client just carries on after
// rejecting a mission offer. We dont need to do anything. This is just here to remove a warning in our logs :)
break;
}
@@ -244,13 +254,6 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
case eGameMessageType::REQUEST_RESURRECT: {
GameMessages::SendResurrect(entity);
/*auto* dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE));
if (dest) {
dest->SetHealth(4);
dest->SetArmor(0);
dest->SetImagination(6);
Game::entityManager->SerializeEntity(entity);
}*/
break;
}
case eGameMessageType::GET_HOT_PROPERTY_DATA: {
@@ -267,7 +270,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
auto* skill_component = entity->GetComponent<SkillComponent>();
if (skill_component != nullptr) {
auto* bs = new RakNet::BitStream((unsigned char*)message.sBitStream.c_str(), message.sBitStream.size(), false);
auto* bs = new RakNet::BitStream(reinterpret_cast<unsigned char*>(const_cast<char*>(message.sBitStream.c_str())), message.sBitStream.size(), false);
skill_component->SyncPlayerProjectile(message.i64LocalID, bs, message.i64TargetID);
@@ -294,7 +297,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
bool success = false;
if (behaviorId > 0) {
RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)startSkill.sBitStream.c_str(), startSkill.sBitStream.size(), false);
RakNet::BitStream* bs = new RakNet::BitStream(reinterpret_cast<unsigned char*>(const_cast<char*>(startSkill.sBitStream.c_str())), startSkill.sBitStream.size(), false);
auto* skillComponent = entity->GetComponent<SkillComponent>();
@@ -339,24 +342,19 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
RakNet::BitStream bitStreamLocal;
BitStreamUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
bitStreamLocal.Write(entity->GetObjectID());
//bitStreamLocal.Write((unsigned short)eGameMessageType::ECHO_SYNC_SKILL);
//bitStreamLocal.Write(inStream);
SyncSkill sync = SyncSkill(inStream); // inStream replaced &bitStream
//sync.Serialize(&bitStreamLocal);
ostringstream buffer;
std::ostringstream buffer;
for (unsigned int k = 0; k < sync.sBitStream.size(); k++) {
char s;
s = sync.sBitStream.at(k);
buffer << setw(2) << hex << setfill('0') << (int)s << " ";
buffer << std::setw(2) << std::hex << std::setfill('0') << static_cast<int>(s) << " ";
}
//cout << buffer.str() << endl;
if (usr != nullptr) {
RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)sync.sBitStream.c_str(), sync.sBitStream.size(), false);
RakNet::BitStream* bs = new RakNet::BitStream(reinterpret_cast<unsigned char*>(const_cast<char*>(sync.sBitStream.c_str())), sync.sBitStream.size(), false);
auto* skillComponent = entity->GetComponent<SkillComponent>();
@@ -425,7 +423,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
break;
case eGameMessageType::REBUILD_CANCEL:
GameMessages::HandleRebuildCancel(inStream, entity);
GameMessages::HandleQuickBuildCancel(inStream, entity);
break;
case eGameMessageType::MATCH_REQUEST:
@@ -693,8 +691,11 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
case eGameMessageType::CANCEL_DONATION_ON_PLAYER:
GameMessages::HandleCancelDonationOnPlayer(inStream, entity);
break;
case eGameMessageType::REQUEST_VENDOR_STATUS_UPDATE:
GameMessages::SendVendorStatusUpdate(entity, sysAddr, true);
break;
default:
LOG_DEBUG("Unknown game message ID: %i", messageID);
LOG_DEBUG("Received Unknown GM with ID: %4i, %s", messageID, StringifiedEnum::ToString(messageID).data());
break;
}
}

View File

@@ -18,9 +18,8 @@
#include "Game.h"
#include "Logger.h"
#include "GameMessages.h"
#include "../dDatabase/CDClientDatabase.h"
enum class eGameMessageType : uint16_t;
#include "CDClientDatabase.h"
#include "eGameMessageType.h"
namespace GameMessageHandler {
void HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID);

File diff suppressed because it is too large Load Diff

View File

@@ -32,10 +32,11 @@ enum class eObjectWorldState : uint32_t;
enum class eTerminateType : uint32_t;
enum class eControlScheme : uint32_t;
enum class eStateChangeType : uint32_t;
enum class ePetAbilityType : uint32_t;
enum class ePetTamingNotifyType : uint32_t;
enum class eUseItemResponse : uint32_t;
enum class eQuickBuildFailReason : uint32_t;
enum class eRebuildState : uint32_t;
enum class eQuickBuildState : uint32_t;
enum class BehaviorSlot : int32_t;
namespace GameMessages {
@@ -74,6 +75,7 @@ namespace GameMessages {
int iIndex = 0, int iDesiredWaypointIndex = 1, int nextIndex = 1,
eMovementPlatformState movementState = eMovementPlatformState::Moving);
void SendResetMissions(Entity* entity, const SystemAddress& sysAddr, const int32_t missionid = -1);
void SendRestoreToPostLoadStats(Entity* entity, const SystemAddress& sysAddr);
void SendServerDoneLoadingAllObjects(Entity* entity, const SystemAddress& sysAddr);
void SendGMLevelBroadcast(const LWOOBJID& objectID, eGameMasterLevel level);
@@ -99,8 +101,8 @@ namespace GameMessages {
void SendBroadcastTextToChatbox(Entity* entity, const SystemAddress& sysAddr, const std::u16string& attrs, const std::u16string& wsText);
void SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent, eLootSourceType sourceType);
void SendRebuildNotifyState(Entity* entity, eRebuildState prevState, eRebuildState state, const LWOOBJID& playerID);
void SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, eQuickBuildFailReason failReason, float duration, const LWOOBJID& playerID);
void SendQuickBuildNotifyState(Entity* entity, eQuickBuildState prevState, eQuickBuildState state, const LWOOBJID& playerID);
void SendEnableQuickBuild(Entity* entity, bool enable, bool fail, bool success, eQuickBuildFailReason failReason, float duration, const LWOOBJID& playerID);
void AddActivityOwner(Entity* entity, LWOOBJID& ownerID);
void SendTerminateInteraction(const LWOOBJID& objectID, eTerminateType type, const LWOOBJID& terminator);
@@ -206,7 +208,7 @@ namespace GameMessages {
void SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uint32_t buffID, uint32_t msDuration,
bool addImmunity = false, bool cancelOnDamaged = false, bool cancelOnDeath = true,
bool cancelOnLogout = false, bool cancelOnRemoveBuff = true, bool cancelOnUi = false,
bool cancelOnUnequip = false, bool cancelOnZone = false, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
bool cancelOnUnequip = false, bool cancelOnZone = false, bool addedByTeammate = false, bool applyOnTeammates = false, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
void SendToggleGMInvis(LWOOBJID objectId, bool enabled, const SystemAddress& sysAddr);
@@ -385,7 +387,7 @@ namespace GameMessages {
void SendClientExitTamingMinigame(LWOOBJID objectId, bool bVoluntaryExit, const SystemAddress& sysAddr);
void SendShowPetActionButton(LWOOBJID objectId, int32_t buttonLabel, bool bShow, const SystemAddress& sysAddr);
void SendShowPetActionButton(const LWOOBJID objectId, const ePetAbilityType petAbility, const bool bShow, const SystemAddress& sysAddr);
void SendPlayEmote(LWOOBJID objectId, int32_t emoteID, LWOOBJID target, const SystemAddress& sysAddr);
@@ -601,7 +603,7 @@ namespace GameMessages {
void HandleSetGhostReffrenceOverride(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleFireEventServerSide(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleRequestPlatformResync(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
void HandleRebuildCancel(RakNet::BitStream* inStream, Entity* entity);
void HandleQuickBuildCancel(RakNet::BitStream* inStream, Entity* entity);
void HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
void HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity);
void HandleModularBuildConvertModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);

View File

@@ -17,21 +17,21 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con
stream.Write<uint32_t>(cloneId); // clone id
const auto& name = GeneralUtils::UTF8ToUTF16(Name);
stream.Write(uint32_t(name.size()));
stream.Write<uint32_t>(name.size());
for (uint32_t i = 0; i < name.size(); ++i) {
stream.Write(uint16_t(name[i]));
stream.Write<uint16_t>(name[i]);
}
const auto& description = GeneralUtils::UTF8ToUTF16(Description);
stream.Write(uint32_t(description.size()));
stream.Write<uint32_t>(description.size());
for (uint32_t i = 0; i < description.size(); ++i) {
stream.Write(uint16_t(description[i]));
stream.Write<uint16_t>(description[i]);
}
const auto& owner = GeneralUtils::UTF8ToUTF16(OwnerName);
stream.Write(uint32_t(owner.size()));
stream.Write<uint32_t>(owner.size());
for (uint32_t i = 0; i < owner.size(); ++i) {
stream.Write(uint16_t(owner[i]));
stream.Write<uint16_t>(owner[i]);
}
stream.Write<LWOOBJID>(OwnerId);
@@ -49,9 +49,9 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con
stream.Write<uint32_t>(0);
const auto& spawn = GeneralUtils::ASCIIToUTF16(SpawnName);
stream.Write(uint32_t(spawn.size()));
stream.Write<uint32_t>(spawn.size());
for (uint32_t i = 0; i < spawn.size(); ++i) {
stream.Write(uint16_t(spawn[i]));
stream.Write<uint16_t>(spawn[i]);
}
stream.Write<uint32_t>(0); // String length
@@ -71,9 +71,9 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con
// Does this go here???
// const auto& rejectionReasonConverted = GeneralUtils::UTF8ToUTF16(rejectionReason);
// stream.Write(uint32_t(rejectionReasonConverted.size()));
// stream.Write<uint32_t>(rejectionReasonConverted.size());
// for (uint32_t i = 0; i < rejectionReasonConverted.size(); ++i) {
// stream.Write(uint16_t(rejectionReasonConverted[i]));
// stream.Write<uint16_t>(rejectionReasonConverted[i]);
// }
stream.Write<uint32_t>(0);
@@ -93,7 +93,7 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con
stream.Write<char>(PrivacyOption);
stream.Write(uint32_t(Paths.size()));
stream.Write<uint32_t>(Paths.size());
for (const auto& path : Paths) {
stream.Write(path.x);

View File

@@ -4,21 +4,21 @@ void PropertySelectQueryProperty::Serialize(RakNet::BitStream& stream) const {
stream.Write(CloneId);
const auto& owner = GeneralUtils::UTF8ToUTF16(OwnerName);
stream.Write(uint32_t(owner.size()));
stream.Write<uint32_t>(owner.size());
for (uint32_t i = 0; i < owner.size(); ++i) {
stream.Write(static_cast<uint16_t>(owner[i]));
stream.Write<uint16_t>(owner[i]);
}
const auto& name = GeneralUtils::UTF8ToUTF16(Name);
stream.Write(uint32_t(name.size()));
stream.Write<uint32_t>(name.size());
for (uint32_t i = 0; i < name.size(); ++i) {
stream.Write(static_cast<uint16_t>(name[i]));
stream.Write<uint16_t>(name[i]);
}
const auto& description = GeneralUtils::UTF8ToUTF16(Description);
stream.Write(uint32_t(description.size()));
stream.Write<uint32_t>(description.size());
for (uint32_t i = 0; i < description.size(); ++i) {
stream.Write(static_cast<uint16_t>(description[i]));
stream.Write<uint16_t>(description[i]);
}
stream.Write(Reputation);