Merge remote-tracking branch 'upstream/main' into PetFixes

This commit is contained in:
jadebenn
2024-12-17 22:42:56 -06:00
114 changed files with 2240 additions and 216 deletions

View File

@@ -6375,3 +6375,58 @@ void GameMessages::SendUpdateInventoryUi(LWOOBJID objectId, const SystemAddress&
SEND_PACKET;
}
namespace GameMessages {
void GameMsg::Send(const SystemAddress& sysAddr) const {
CBITSTREAM;
CMSGHEADER;
bitStream.Write(target); // Who this message will be sent to on the (a) client
bitStream.Write(msgId); // the ID of this message
Serialize(bitStream); // write the message data
// Send to everyone if someone sent unassigned system address, or to one specific client.
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) {
SEND_PACKET_BROADCAST;
} else {
SEND_PACKET;
}
}
void DisplayTooltip::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(doOrDie);
bitStream.Write(noRepeat);
bitStream.Write(noRevive);
bitStream.Write(isPropertyTooltip);
bitStream.Write(show);
bitStream.Write(translate);
bitStream.Write(time);
bitStream.Write<int32_t>(id.size());
bitStream.Write(id);
std::string toWrite;
for (const auto* item : localizeParams) {
toWrite += item->GetString() + "\n";
}
if (!toWrite.empty()) toWrite.pop_back();
bitStream.Write<int32_t>(toWrite.size());
bitStream.Write(GeneralUtils::ASCIIToUTF16(toWrite));
if (!toWrite.empty()) bitStream.Write<uint16_t>(0x00); // Null Terminator
bitStream.Write<int32_t>(imageName.size());
bitStream.Write(imageName);
bitStream.Write<int32_t>(text.size());
bitStream.Write(text);
}
void UseItemOnClient::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(itemLOT);
bitStream.Write(itemToUse);
bitStream.Write(itemType);
bitStream.Write(playerId);
bitStream.Write(targetPosition.x);
bitStream.Write(targetPosition.y);
bitStream.Write(targetPosition.z);
}
}

View File

@@ -11,6 +11,7 @@
#include "eCyclingMode.h"
#include "eLootSourceType.h"
#include "Brick.h"
#include "MessageType/Game.h"
class AMFBaseValue;
class Entity;
@@ -20,6 +21,7 @@ class User;
class Leaderboard;
class PropertySelectQueryProperty;
class TradeItem;
class LDFBaseData;
enum class eAnimationFlags : uint32_t;
@@ -48,6 +50,15 @@ enum class eCameraTargetCyclingMode : int32_t {
};
namespace GameMessages {
struct GameMsg {
GameMsg(MessageType::Game gmId) : msgId{ gmId } {}
virtual ~GameMsg() = default;
void Send(const SystemAddress& sysAddr) const;
virtual void Serialize(RakNet::BitStream& bitStream) const {}
MessageType::Game msgId;
LWOOBJID target{ LWOOBJID_EMPTY };
};
class PropertyDataMessage;
void SendFireEventClientSide(const LWOOBJID& objectID, const SystemAddress& sysAddr, std::u16string args, const LWOOBJID& object, int64_t param1, int param2, const LWOOBJID& sender);
void SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, const NiQuaternion& rot, const SystemAddress& sysAddr, bool bSetRotation = false);
@@ -700,6 +711,32 @@ namespace GameMessages {
// This is a client gm however its default values are exactly what we need to get around the invisible inventory item issues.
void SendUpdateInventoryUi(LWOOBJID objectId, const SystemAddress& sysAddr);
struct DisplayTooltip : public GameMsg {
DisplayTooltip() : GameMsg(MessageType::Game::DISPLAY_TOOLTIP) {}
bool doOrDie{};
bool noRepeat{};
bool noRevive{};
bool isPropertyTooltip{};
bool show{};
bool translate{};
int32_t time{};
std::u16string id{};
std::vector<LDFBaseData*> localizeParams{};
std::u16string imageName{};
std::u16string text{};
void Serialize(RakNet::BitStream& bitStream) const override;
};
struct UseItemOnClient : public GameMsg {
UseItemOnClient() : GameMsg(MessageType::Game::USE_ITEM_ON_CLIENT) {}
LWOOBJID playerId{};
LWOOBJID itemToUse{};
uint32_t itemType{};
LOT itemLOT{};
NiPoint3 targetPosition{};
void Serialize(RakNet::BitStream& bitStream) const override;
};
};
#endif // GAMEMESSAGES_H