Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: default size to 33 on LU(W)Strings #1410

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dChatServer/ChatIgnoreList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions dGame/UserManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions dMasterServer/MasterServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion dNet/AuthPackets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions dNet/BitStreamUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion dNet/MasterPackets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions dWorldServer/WorldServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/dCommonTests/TestLUString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/dCommonTests/TestLUWString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Loading