mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-21 21:17:25 +00:00
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:
parent
8b6fb8fb44
commit
0bc12141c3
@ -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();
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -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);
|
||||||
|
@ -677,7 +677,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:
|
||||||
@ -761,7 +761,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:
|
||||||
@ -847,10 +847,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);
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user