Merge branch 'main' into player-stuff-2

This commit is contained in:
David Markowitz 2024-01-12 21:47:46 -08:00
commit 1c5b8cc265
13 changed files with 40 additions and 19 deletions

View File

@ -81,7 +81,7 @@ void ChatIgnoreList::AddIgnore(Packet* packet) {
inStream.IgnoreBytes(4); // ignore some garbage zeros idk inStream.IgnoreBytes(4); // ignore some garbage zeros idk
LUWString toIgnoreName(33); LUWString toIgnoreName;
inStream.Read(toIgnoreName); inStream.Read(toIgnoreName);
std::string toIgnoreStr = toIgnoreName.GetAsString(); std::string toIgnoreStr = toIgnoreName.GetAsString();
@ -147,7 +147,7 @@ void ChatIgnoreList::RemoveIgnore(Packet* packet) {
inStream.IgnoreBytes(4); // ignore some garbage zeros idk inStream.IgnoreBytes(4); // ignore some garbage zeros idk
LUWString removedIgnoreName(33); LUWString removedIgnoreName;
inStream.Read(removedIgnoreName); inStream.Read(removedIgnoreName);
std::string removedIgnoreStr = removedIgnoreName.GetAsString(); std::string removedIgnoreStr = removedIgnoreName.GetAsString();

View File

@ -80,6 +80,7 @@
#include "RacingStatsComponent.h" #include "RacingStatsComponent.h"
#include "CollectibleComponent.h" #include "CollectibleComponent.h"
#include "ItemComponent.h" #include "ItemComponent.h"
#include "GhostComponent.h"
// Table includes // Table includes
#include "CDComponentsRegistryTable.h" #include "CDComponentsRegistryTable.h"
@ -436,6 +437,8 @@ void Entity::Initialize() {
AddComponent<PlayerForcedMovementComponent>(); AddComponent<PlayerForcedMovementComponent>();
AddComponent<CharacterComponent>(m_Character)->LoadFromXml(m_Character->GetXMLDoc()); AddComponent<CharacterComponent>(m_Character)->LoadFromXml(m_Character->GetXMLDoc());
AddComponent<GhostComponent>();
} }
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::INVENTORY) > 0 || m_Character) { if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::INVENTORY) > 0 || m_Character) {

View File

@ -267,7 +267,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
User* u = GetUser(sysAddr); User* u = GetUser(sysAddr);
if (!u) return; if (!u) return;
LUWString LUWStringName(33); LUWString LUWStringName;
uint32_t firstNameIndex; uint32_t firstNameIndex;
uint32_t middleNameIndex; uint32_t middleNameIndex;
uint32_t lastNameIndex; uint32_t lastNameIndex;
@ -437,7 +437,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
uint32_t charID = static_cast<uint32_t>(objectID); uint32_t charID = static_cast<uint32_t>(objectID);
LOG("Received char rename request for ID: %llu (%u)", objectID, charID); LOG("Received char rename request for ID: %llu (%u)", objectID, charID);
LUWString LUWStringName(33); LUWString LUWStringName;
inStream.Read(LUWStringName); inStream.Read(LUWStringName);
const auto newName = LUWStringName.GetAsString(); const auto newName = LUWStringName.GetAsString();

View File

@ -10,6 +10,7 @@ set(DGAME_DCOMPONENTS_SOURCES
"ControllablePhysicsComponent.cpp" "ControllablePhysicsComponent.cpp"
"DestroyableComponent.cpp" "DestroyableComponent.cpp"
"DonationVendorComponent.cpp" "DonationVendorComponent.cpp"
"GhostComponent.cpp"
"InventoryComponent.cpp" "InventoryComponent.cpp"
"ItemComponent.cpp" "ItemComponent.cpp"
"LevelProgressionComponent.cpp" "LevelProgressionComponent.cpp"

View File

@ -0,0 +1,4 @@
#include "GhostComponent.h"
// TODO Move ghosting related code from Player to here
GhostComponent::GhostComponent(Entity* parent) : Component(parent) {}

View File

@ -0,0 +1,13 @@
#ifndef __GHOSTCOMPONENT__H__
#define __GHOSTCOMPONENT__H__
#include "Component.h"
#include "eReplicaComponentType.h"
class GhostComponent : public Component {
public:
static inline const eReplicaComponentType ComponentType = eReplicaComponentType::GHOST;
GhostComponent(Entity* parent);
};
#endif //!__GHOSTCOMPONENT__H__

View File

@ -503,7 +503,7 @@ void HandlePacket(Packet* packet) {
uint32_t theirZoneID = 0; uint32_t theirZoneID = 0;
uint32_t theirInstanceID = 0; uint32_t theirInstanceID = 0;
ServerType theirServerType; ServerType theirServerType;
LUString theirIP(33); LUString theirIP;
inStream.Read(theirPort); inStream.Read(theirPort);
inStream.Read(theirZoneID); inStream.Read(theirZoneID);
@ -555,7 +555,7 @@ void HandlePacket(Packet* packet) {
CINSTREAM_SKIP_HEADER; CINSTREAM_SKIP_HEADER;
uint32_t sessionKey = 0; uint32_t sessionKey = 0;
inStream.Read(sessionKey); inStream.Read(sessionKey);
LUString username(33); LUString username;
inStream.Read(username); inStream.Read(username);
for (auto it : activeSessions) { for (auto it : activeSessions) {
@ -579,7 +579,7 @@ void HandlePacket(Packet* packet) {
case eMasterMessageType::REQUEST_SESSION_KEY: { case eMasterMessageType::REQUEST_SESSION_KEY: {
CINSTREAM_SKIP_HEADER; CINSTREAM_SKIP_HEADER;
LUWString username(33); LUWString username;
inStream.Read(username); inStream.Read(username);
LOG("Requesting session key for %s", username.GetAsString().c_str()); LOG("Requesting session key for %s", username.GetAsString().c_str());
for (auto key : activeSessions) { for (auto key : activeSessions) {

View File

@ -95,7 +95,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
std::vector<Stamp> stamps; std::vector<Stamp> stamps;
stamps.emplace_back(eStamps::PASSPORT_AUTH_START, 0); stamps.emplace_back(eStamps::PASSPORT_AUTH_START, 0);
LUWString usernameLUString(33); LUWString usernameLUString;
inStream.Read(usernameLUString); inStream.Read(usernameLUString);
const auto username = usernameLUString.GetAsString(); const auto username = usernameLUString.GetAsString();

View File

@ -12,7 +12,7 @@ struct LUString {
std::string string; std::string string;
uint32_t size; uint32_t size;
LUString(uint32_t size) { LUString(uint32_t size = 33) {
this->size = size; this->size = size;
}; };
LUString(std::string string, uint32_t size = 33) { LUString(std::string string, uint32_t size = 33) {
@ -28,7 +28,7 @@ struct LUWString {
std::u16string string; std::u16string string;
uint32_t size; uint32_t size;
LUWString(uint32_t size) { LUWString(uint32_t size = 33) {
this->size = size; this->size = size;
}; };
LUWString(std::u16string string, uint32_t size = 33) { LUWString(std::u16string string, uint32_t size = 33) {

View File

@ -99,7 +99,7 @@ void MasterPackets::HandleServerInfo(Packet* packet) {
uint32_t theirPort = 0; uint32_t theirPort = 0;
uint32_t theirZoneID = 0; uint32_t theirZoneID = 0;
uint32_t theirInstanceID = 0; uint32_t theirInstanceID = 0;
LUString theirIP(33); LUString theirIP;
inStream.Read(theirPort); inStream.Read(theirPort);
inStream.Read(theirZoneID); inStream.Read(theirZoneID);

View File

@ -678,7 +678,7 @@ void HandleMasterPacket(Packet* packet) {
CINSTREAM_SKIP_HEADER; CINSTREAM_SKIP_HEADER;
uint32_t sessionKey = 0; uint32_t sessionKey = 0;
inStream.Read(sessionKey); inStream.Read(sessionKey);
LUWString username(33); LUWString username;
inStream.Read(username); inStream.Read(username);
//Find them: //Find them:
@ -762,7 +762,7 @@ void HandleMasterPacket(Packet* packet) {
CINSTREAM_SKIP_HEADER; CINSTREAM_SKIP_HEADER;
uint32_t sessionKey = inStream.Read(sessionKey); uint32_t sessionKey = inStream.Read(sessionKey);
LUString username(33); LUString username;
inStream.Read(username); inStream.Read(username);
LOG("Got new session alert for user %s", username.string.c_str()); LOG("Got new session alert for user %s", username.string.c_str());
//Find them: //Find them:
@ -848,10 +848,10 @@ void HandlePacket(Packet* packet) {
switch (static_cast<eWorldMessageType>(packet->data[3])) { switch (static_cast<eWorldMessageType>(packet->data[3])) {
case eWorldMessageType::VALIDATION: { case eWorldMessageType::VALIDATION: {
CINSTREAM_SKIP_HEADER; CINSTREAM_SKIP_HEADER;
LUWString username(33); LUWString username;
inStream.Read(username); inStream.Read(username);
LUWString sessionKey(33); LUWString sessionKey;
// sometimes client puts a null terminator at the end of the checksum and sometimes doesn't, weird // sometimes client puts a null terminator at the end of the checksum and sometimes doesn't, weird
inStream.Read(sessionKey); inStream.Read(sessionKey);
LUString clientDatabaseChecksum(32); LUString clientDatabaseChecksum(32);

View File

@ -101,7 +101,7 @@ TEST(LUString33Test, SerializeReadTestNew) {
std::string testString; std::string testString;
for (int i = 0; i < 33; i++) testString += "a"; for (int i = 0; i < 33; i++) testString += "a";
bitStream.Write(LUString(testString, 33)); bitStream.Write(LUString(testString, 33));
LUString result(33); LUString result;
ASSERT_EQ(result.size, 33); ASSERT_EQ(result.size, 33);
ASSERT_TRUE(bitStream.Read(result)); ASSERT_TRUE(bitStream.Read(result));
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0); ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
@ -113,7 +113,7 @@ TEST(LUString33Test, SerializeReadTestNewPartial) {
std::string testString; std::string testString;
for (int i = 0; i < 15; i++) testString += "a"; for (int i = 0; i < 15; i++) testString += "a";
bitStream.Write(LUString(testString, 33)); bitStream.Write(LUString(testString, 33));
LUString result(33); LUString result;
ASSERT_EQ(result.size, 33); ASSERT_EQ(result.size, 33);
ASSERT_TRUE(bitStream.Read(result)); ASSERT_TRUE(bitStream.Read(result));
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0); ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);

View File

@ -101,7 +101,7 @@ TEST(LUWString33Test, SerializeReadTestNew) {
std::u16string testString; std::u16string testString;
for (int i = 0; i < 33; i++) testString += u'ü'; for (int i = 0; i < 33; i++) testString += u'ü';
bitStream.Write(LUWString(testString, 33)); bitStream.Write(LUWString(testString, 33));
LUWString result(33); LUWString result;
ASSERT_EQ(result.size, 33); ASSERT_EQ(result.size, 33);
ASSERT_TRUE(bitStream.Read(result)); ASSERT_TRUE(bitStream.Read(result));
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0); ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
@ -113,7 +113,7 @@ TEST(LUWString33Test, SerializeReadTestNewPartial) {
std::u16string testString; std::u16string testString;
for (int i = 0; i < 15; i++) testString += u'ü'; for (int i = 0; i < 15; i++) testString += u'ü';
bitStream.Write(LUWString(testString, 33)); bitStream.Write(LUWString(testString, 33));
LUWString result(33); LUWString result;
ASSERT_EQ(result.size, 33); ASSERT_EQ(result.size, 33);
ASSERT_TRUE(bitStream.Read(result)); ASSERT_TRUE(bitStream.Read(result));
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0); ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);