chore: default size to 33 on LU(W)Strings since that's the most common lenght (#1410)

Was doing this on other places, but not the main one
This commit is contained in:
Aaron Kimbrell 2024-01-12 14:23:44 -06:00 committed by GitHub
parent 8b6fb8fb44
commit 0bc12141c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 19 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ struct LUString {
std::string string;
uint32_t size;
LUString(uint32_t size) {
LUString(uint32_t size = 33) {
this->size = size;
};
LUString(std::string string, uint32_t size = 33) {
@ -28,7 +28,7 @@ struct LUWString {
std::u16string string;
uint32_t size;
LUWString(uint32_t size) {
LUWString(uint32_t size = 33) {
this->size = size;
};
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 theirZoneID = 0;
uint32_t theirInstanceID = 0;
LUString theirIP(33);
LUString theirIP;
inStream.Read(theirPort);
inStream.Read(theirZoneID);

View File

@ -677,7 +677,7 @@ void HandleMasterPacket(Packet* packet) {
CINSTREAM_SKIP_HEADER;
uint32_t sessionKey = 0;
inStream.Read(sessionKey);
LUWString username(33);
LUWString username;
inStream.Read(username);
//Find them:
@ -761,7 +761,7 @@ void HandleMasterPacket(Packet* packet) {
CINSTREAM_SKIP_HEADER;
uint32_t sessionKey = inStream.Read(sessionKey);
LUString username(33);
LUString username;
inStream.Read(username);
LOG("Got new session alert for user %s", username.string.c_str());
//Find them:
@ -847,10 +847,10 @@ void HandlePacket(Packet* packet) {
switch (static_cast<eWorldMessageType>(packet->data[3])) {
case eWorldMessageType::VALIDATION: {
CINSTREAM_SKIP_HEADER;
LUWString username(33);
LUWString 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
inStream.Read(sessionKey);
LUString clientDatabaseChecksum(32);

View File

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

View File

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