diff --git a/Client/Client.cpp b/Client/Client.cpp index ebe1b87..90e5790 100644 --- a/Client/Client.cpp +++ b/Client/Client.cpp @@ -9,11 +9,11 @@ DWORD dwWritten; BOOL fSuccess = FALSE; DWORD cbRead, cbToWrite, cbWritten, dwMode; -int CreatePipe(std::string name) +int CreatePipe(std::wstring name) { while (1) { - hPipe = CreateFileA( + hPipe = CreateFileW( name.c_str(), // pipe name GENERIC_READ | // read and write access GENERIC_WRITE, @@ -50,9 +50,9 @@ int CreatePipe(std::string name) return 0; } -std::string ReadMessage() +std::wstring ReadMessage() { - char chBuf[10240]; + wchar_t chBuf[10240]; do { // Read from the pipe. @@ -60,7 +60,7 @@ std::string ReadMessage() fSuccess = ReadFile( hPipe, // pipe handle chBuf, // buffer to receive reply - 10240 * sizeof(char), // size of buffer + 10240 * sizeof(wchar_t), // size of buffer &cbRead, // number of bytes read NULL); // not overlapped @@ -68,27 +68,28 @@ std::string ReadMessage() break; } while (!fSuccess); - return std::string(chBuf); + return std::wstring(chBuf); } int main() { - CreatePipe("\\\\.\\pipe\\PipeL2Bot"); + CreatePipe(L"\\\\.\\pipe\\PipeL2Bot"); std::cout << "Connected to the connection pipe" << std::endl; auto name = ReadMessage(); CloseHandle(hPipe); - std::cout << "Received main pipe name: " << name << std::endl; + std::wcout << L"Received main pipe name: " << name << std::endl; std::cin.get(); CreatePipe(name); - const std::string message = "invalidate"; + const std::wstring message = L"invalidate"; DWORD written; WriteFile(hPipe, message.c_str(), message.size() + 1, &written, NULL); while (true) { - std::cout << ReadMessage() << std::endl; + const auto msg = ReadMessage(); + std::wcout << msg << std::endl; } std::cin.get(); } \ No newline at end of file diff --git a/L2BotCore/Domain/Entities/AbnormalEffect.h b/L2BotCore/Domain/Entities/AbnormalEffect.h index c0d525c..cc74a06 100644 --- a/L2BotCore/Domain/Entities/AbnormalEffect.h +++ b/L2BotCore/Domain/Entities/AbnormalEffect.h @@ -43,14 +43,14 @@ namespace L2Bot::Domain::Entities { std::vector result; - result.push_back({ "skillId", std::to_string(m_SkillId) }); - result.push_back({ "level", std::to_string(m_Level) }); + result.push_back({ L"skillId", std::to_wstring(m_SkillId) }); + result.push_back({ L"level", std::to_wstring(m_Level) }); if (m_IsNewState) { - result.push_back({ "name", m_Name }); - result.push_back({ "iconName", m_IconName }); - result.push_back({ "description", m_Description }); + result.push_back({ L"name", m_Name }); + result.push_back({ L"iconName", m_IconName }); + result.push_back({ L"description", m_Description }); } return result; @@ -59,9 +59,9 @@ namespace L2Bot::Domain::Entities AbnormalEffect( const uint32_t skillId, const uint8_t level, - const std::string& name, - const std::string& description, - const std::string& iconName + const std::wstring& name, + const std::wstring& description, + const std::wstring& iconName ) : m_SkillId(skillId), m_Level(level), @@ -87,9 +87,9 @@ namespace L2Bot::Domain::Entities private: uint32_t m_SkillId = 0; uint8_t m_Level = 0; - std::string m_Name = ""; - std::string m_Description = ""; - std::string m_IconName = ""; + std::wstring m_Name = L""; + std::wstring m_Description = L""; + std::wstring m_IconName = L""; bool m_IsNewState = true; }; } diff --git a/L2BotCore/Domain/Entities/ArmorItem.h b/L2BotCore/Domain/Entities/ArmorItem.h index c94a7fe..eb18ace 100644 --- a/L2BotCore/Domain/Entities/ArmorItem.h +++ b/L2BotCore/Domain/Entities/ArmorItem.h @@ -60,28 +60,28 @@ namespace L2Bot::Domain::Entities if (m_PrevState.isNewState) { - result.push_back({ "armorType", std::to_string(static_cast(m_ArmorType)) }); - result.push_back({ "crystalType", std::to_string(static_cast(m_CrystalType)) }); - result.push_back({ "setEffect", m_SetEffect }); - result.push_back({ "addSetEffect", m_AddSetEffect }); - result.push_back({ "enchantEffect", m_EnchantEffect }); + result.push_back({ L"armorType", std::to_wstring(static_cast(m_ArmorType)) }); + result.push_back({ L"crystalType", std::to_wstring(static_cast(m_CrystalType)) }); + result.push_back({ L"setEffect", m_SetEffect }); + result.push_back({ L"addSetEffect", m_AddSetEffect }); + result.push_back({ L"enchantEffect", m_EnchantEffect }); } if (m_PrevState.isNewState || m_IsEquipped != m_PrevState.isEquipped) { - result.push_back({ "isEquipped", std::to_string(m_IsEquipped) }); + result.push_back({ L"isEquipped", std::to_wstring(m_IsEquipped) }); } if (m_PrevState.isNewState || m_EnchantLevel != m_PrevState.enchantLevel) { - result.push_back({ "enchantLevel", std::to_string(m_EnchantLevel) }); + result.push_back({ L"enchantLevel", std::to_wstring(m_EnchantLevel) }); } if (m_PrevState.isNewState || m_PDefense != m_PrevState.pDefense) { - result.push_back({ "pDefense", std::to_string(m_PDefense) }); + result.push_back({ L"pDefense", std::to_wstring(m_PDefense) }); } if (m_PrevState.isNewState || m_MDefense != m_PrevState.mDefense) { - result.push_back({ "mDefense", std::to_string(m_MDefense) }); + result.push_back({ L"mDefense", std::to_wstring(m_MDefense) }); } return result; @@ -91,9 +91,9 @@ namespace L2Bot::Domain::Entities const uint32_t objectId, const uint32_t itemId, const int32_t mana, - const std::string& name, - const std::string& iconName, - const std::string& description, + const std::wstring& name, + const std::wstring& iconName, + const std::wstring& description, const uint16_t weight, const bool isEquipped, const uint16_t enchantLevel, @@ -101,9 +101,9 @@ namespace L2Bot::Domain::Entities const Enums::CrystalTypeEnum crystalType, const uint32_t pDefense, const uint32_t mDefense, - const std::string& setEffect, - const std::string& addSetEffect, - const std::string& enchantEffect + const std::wstring& setEffect, + const std::wstring& addSetEffect, + const std::wstring& enchantEffect ) : BaseItem ( @@ -163,9 +163,9 @@ namespace L2Bot::Domain::Entities Enums::CrystalTypeEnum m_CrystalType = Enums::CrystalTypeEnum::none; uint32_t m_PDefense = 0; uint32_t m_MDefense = 0; - std::string m_SetEffect = ""; - std::string m_AddSetEffect = ""; - std::string m_EnchantEffect = ""; + std::wstring m_SetEffect = L""; + std::wstring m_AddSetEffect = L""; + std::wstring m_EnchantEffect = L""; GetState m_PrevState = GetState(); }; } diff --git a/L2BotCore/Domain/Entities/BaseItem.h b/L2BotCore/Domain/Entities/BaseItem.h index b12ed59..e1a0f90 100644 --- a/L2BotCore/Domain/Entities/BaseItem.h +++ b/L2BotCore/Domain/Entities/BaseItem.h @@ -58,24 +58,24 @@ namespace L2Bot::Domain::Entities { std::vector result; - result.push_back({ "objectId", std::to_string(m_ObjectId) }); - result.push_back({ "itemId", std::to_string(m_ItemId) }); + result.push_back({ L"objectId", std::to_wstring(m_ObjectId) }); + result.push_back({ L"itemId", std::to_wstring(m_ItemId) }); if (m_PrevState.isNewState) { - result.push_back({ "type", std::to_string(static_cast(m_Type))}); - result.push_back({ "name", m_Name }); - result.push_back({ "iconName", m_IconName }); - result.push_back({ "description", m_Description }); + result.push_back({ L"type", std::to_wstring(static_cast(m_Type))}); + result.push_back({ L"name", m_Name }); + result.push_back({ L"iconName", m_IconName }); + result.push_back({ L"description", m_Description }); } if (m_PrevState.isNewState || m_Mana != m_PrevState.mana) { - result.push_back({ "mana", std::to_string(m_Mana) }); + result.push_back({ L"mana", std::to_wstring(m_Mana) }); } if (m_PrevState.isNewState || m_Weight != m_PrevState.weight) { - result.push_back({ "weight", std::to_string(m_Weight) }); + result.push_back({ L"weight", std::to_wstring(m_Weight) }); } return result; @@ -85,9 +85,9 @@ namespace L2Bot::Domain::Entities const uint32_t objectId, const uint32_t itemId, const int32_t mana, - const std::string& name, - const std::string& iconName, - const std::string& description, + const std::wstring& name, + const std::wstring& iconName, + const std::wstring& description, const uint16_t weight, const Enums::ItemTypeEnum type ) : @@ -130,9 +130,9 @@ namespace L2Bot::Domain::Entities uint32_t m_ObjectId = 0; uint32_t m_ItemId = 0; int32_t m_Mana = -1; - std::string m_Name = ""; - std::string m_IconName = ""; - std::string m_Description = ""; + std::wstring m_Name = L""; + std::wstring m_IconName = L""; + std::wstring m_Description = L""; uint16_t m_Weight = 0; Enums::ItemTypeEnum m_Type = Enums::ItemTypeEnum::none; GetState m_PrevState = GetState(); diff --git a/L2BotCore/Domain/Entities/Drop.h b/L2BotCore/Domain/Entities/Drop.h index 250a969..45b703d 100644 --- a/L2BotCore/Domain/Entities/Drop.h +++ b/L2BotCore/Domain/Entities/Drop.h @@ -38,10 +38,10 @@ namespace L2Bot::Domain::Entities if (m_IsNewState) { - result.push_back({ "itemId", std::to_string(m_ItemId) }); - result.push_back({ "amount", std::to_string(m_Amount) }); - result.push_back({ "name", m_Name }); - result.push_back({ "iconName", m_IconName }); + result.push_back({ L"itemId", std::to_wstring(m_ItemId) }); + result.push_back({ L"amount", std::to_wstring(m_Amount) }); + result.push_back({ L"name", m_Name }); + result.push_back({ L"iconName", m_IconName }); } return result; @@ -52,8 +52,8 @@ namespace L2Bot::Domain::Entities const ValueObjects::Transform transform, const uint32_t itemId, const uint32_t amount, - const std::string& name, - const std::string& iconName + const std::wstring& name, + const std::wstring& iconName ) : WorldObject(id, transform), m_ItemId(itemId), @@ -69,8 +69,8 @@ namespace L2Bot::Domain::Entities private: uint32_t m_ItemId = 0; uint32_t m_Amount = 0; - std::string m_Name = ""; - std::string m_IconName = ""; + std::wstring m_Name = L""; + std::wstring m_IconName = L""; bool m_IsNewState = true; }; } diff --git a/L2BotCore/Domain/Entities/EtcItem.h b/L2BotCore/Domain/Entities/EtcItem.h index 528e00e..29f6a44 100644 --- a/L2BotCore/Domain/Entities/EtcItem.h +++ b/L2BotCore/Domain/Entities/EtcItem.h @@ -49,16 +49,16 @@ namespace L2Bot::Domain::Entities if (m_PrevState.isNewState) { - result.push_back({ "isQuest", std::to_string(m_IsQuest) }); + result.push_back({ L"isQuest", std::to_wstring(m_IsQuest) }); } if (m_PrevState.isNewState || m_Amount != m_PrevState.amount) { - result.push_back({ "amount", std::to_string(m_Amount) }); + result.push_back({ L"amount", std::to_wstring(m_Amount) }); } if (m_PrevState.isNewState || m_IsAutoused != m_PrevState.isAutoused) { - result.push_back({ "isAutoused", std::to_string(m_IsAutoused) }); + result.push_back({ L"isAutoused", std::to_wstring(m_IsAutoused) }); } return result; @@ -68,9 +68,9 @@ namespace L2Bot::Domain::Entities const uint32_t objectId, const uint32_t itemId, const int32_t mana, - const std::string& name, - const std::string& iconName, - const std::string& description, + const std::wstring& name, + const std::wstring& iconName, + const std::wstring& description, const uint16_t weight, const uint32_t amount, const bool isQuest diff --git a/L2BotCore/Domain/Entities/Hero.h b/L2BotCore/Domain/Entities/Hero.h index 486c88c..6ba604b 100644 --- a/L2BotCore/Domain/Entities/Hero.h +++ b/L2BotCore/Domain/Entities/Hero.h @@ -70,43 +70,43 @@ namespace L2Bot::Domain::Entities if (m_PrevState.isNewState || !m_FullName.IsEqual(&m_PrevState.fullName)) { - result.push_back({ "fullName", m_FullName.BuildSerializationNodes() }); + result.push_back({ L"fullName", m_FullName.BuildSerializationNodes() }); } if (m_PrevState.isNewState || !m_VitalStats.IsEqual(&m_PrevState.vitalStats)) { - result.push_back({ "vitalStats", m_VitalStats.BuildSerializationNodes() }); + result.push_back({ L"vitalStats", m_VitalStats.BuildSerializationNodes() }); } if (m_PrevState.isNewState || !m_Phenotype.IsEqual(&m_PrevState.phenotype)) { - result.push_back({ "phenotype", m_Phenotype.BuildSerializationNodes() }); + result.push_back({ L"phenotype", m_Phenotype.BuildSerializationNodes() }); } if (m_PrevState.isNewState || !m_ExperienceInfo.IsEqual(&m_PrevState.experienceInfo)) { - result.push_back({ "experienceInfo", m_ExperienceInfo.BuildSerializationNodes() }); + result.push_back({ L"experienceInfo", m_ExperienceInfo.BuildSerializationNodes() }); } if (m_PrevState.isNewState || !m_PermanentStats.IsEqual(&m_PrevState.permanentStats)) { - result.push_back({ "permanentStats", m_PermanentStats.BuildSerializationNodes() }); + result.push_back({ L"permanentStats", m_PermanentStats.BuildSerializationNodes() }); } if (m_PrevState.isNewState || !m_VariableStats.IsEqual(&m_PrevState.variableStats)) { - result.push_back({ "variableStats", m_VariableStats.BuildSerializationNodes() }); + result.push_back({ L"variableStats", m_VariableStats.BuildSerializationNodes() }); } if (m_PrevState.isNewState || !m_Reputation.IsEqual(&m_PrevState.reputation)) { - result.push_back({ "reputation", m_Reputation.BuildSerializationNodes() }); + result.push_back({ L"reputation", m_Reputation.BuildSerializationNodes() }); } if (m_PrevState.isNewState || !m_InventoryInfo.IsEqual(&m_PrevState.inventoryInfo)) { - result.push_back({ "inventoryInfo", m_InventoryInfo.BuildSerializationNodes() }); + result.push_back({ L"inventoryInfo", m_InventoryInfo.BuildSerializationNodes() }); } if (m_PrevState.isNewState || m_TargetId != m_PrevState.targetId) { - result.push_back({ "targetId", std::to_string(m_TargetId) }); + result.push_back({ L"targetId", std::to_wstring(m_TargetId) }); } if (m_PrevState.isNewState || m_IsStanding != m_PrevState.isStanding) { - result.push_back({ "isStanding", std::to_string(m_IsStanding) }); + result.push_back({ L"isStanding", std::to_wstring(m_IsStanding) }); } return result; diff --git a/L2BotCore/Domain/Entities/NPC.h b/L2BotCore/Domain/Entities/NPC.h index 6c3063c..5f279ad 100644 --- a/L2BotCore/Domain/Entities/NPC.h +++ b/L2BotCore/Domain/Entities/NPC.h @@ -49,20 +49,20 @@ namespace L2Bot::Domain::Entities if (m_PrevState.isNewState || !m_FullName.IsEqual(&m_PrevState.fullName)) { - result.push_back({ "fullName", m_FullName.BuildSerializationNodes() }); + result.push_back({ L"fullName", m_FullName.BuildSerializationNodes() }); } if (m_PrevState.isNewState) { - result.push_back({ "isHostile", std::to_string(m_IsHostile) }); - result.push_back({ "npcId", std::to_string(m_NpcId) }); + result.push_back({ L"isHostile", std::to_wstring(m_IsHostile) }); + result.push_back({ L"npcId", std::to_wstring(m_NpcId) }); } if (m_PrevState.isNewState || m_SpoilState != m_PrevState.spoilState) { - result.push_back({ "spoilState", std::to_string(static_cast(m_SpoilState)) }); + result.push_back({ L"spoilState", std::to_wstring(static_cast(m_SpoilState)) }); } if (m_PrevState.isNewState || !m_VitalStats.IsEqual(&m_PrevState.vitalStats)) { - result.push_back({ "vitalStats", m_VitalStats.BuildSerializationNodes() }); + result.push_back({ L"vitalStats", m_VitalStats.BuildSerializationNodes() }); } return result; diff --git a/L2BotCore/Domain/Entities/Player.h b/L2BotCore/Domain/Entities/Player.h index b340afd..c1721dd 100644 --- a/L2BotCore/Domain/Entities/Player.h +++ b/L2BotCore/Domain/Entities/Player.h @@ -40,11 +40,11 @@ namespace L2Bot::Domain::Entities if (m_PrevState.isNewState || !m_FullName.IsEqual(&m_PrevState.fullName)) { - result.push_back({ "fullName", m_FullName.BuildSerializationNodes() }); + result.push_back({ L"fullName", m_FullName.BuildSerializationNodes() }); } if (m_PrevState.isNewState || !m_Phenotype.IsEqual(&m_PrevState.phenotype)) { - result.push_back({ "phenotype", m_Phenotype.BuildSerializationNodes() }); + result.push_back({ L"phenotype", m_Phenotype.BuildSerializationNodes() }); } return result; diff --git a/L2BotCore/Domain/Entities/ShieldItem.h b/L2BotCore/Domain/Entities/ShieldItem.h index bef9e12..275b148 100644 --- a/L2BotCore/Domain/Entities/ShieldItem.h +++ b/L2BotCore/Domain/Entities/ShieldItem.h @@ -52,22 +52,22 @@ namespace L2Bot::Domain::Entities if (m_PrevState.isNewState) { - result.push_back({ "crystalType", std::to_string(static_cast(m_CrystalType)) }); - result.push_back({ "evasion", std::to_string(m_Evasion) }); - result.push_back({ "defRate", std::to_string(m_DefRate) }); + result.push_back({ L"crystalType", std::to_wstring(static_cast(m_CrystalType)) }); + result.push_back({ L"evasion", std::to_wstring(m_Evasion) }); + result.push_back({ L"defRate", std::to_wstring(m_DefRate) }); } if (m_PrevState.isNewState || m_IsEquipped != m_PrevState.isEquipped) { - result.push_back({ "isEquipped", std::to_string(m_IsEquipped) }); + result.push_back({ L"isEquipped", std::to_wstring(m_IsEquipped) }); } if (m_PrevState.isNewState || m_EnchantLevel != m_PrevState.enchantLevel) { - result.push_back({ "enchantLevel", std::to_string(m_EnchantLevel) }); + result.push_back({ L"enchantLevel", std::to_wstring(m_EnchantLevel) }); } if (m_PrevState.isNewState || m_PDefense != m_PrevState.pDefense) { - result.push_back({ "pDefense", std::to_string(m_PDefense) }); + result.push_back({ L"pDefense", std::to_wstring(m_PDefense) }); } return result; @@ -77,9 +77,9 @@ namespace L2Bot::Domain::Entities const uint32_t objectId, const uint32_t itemId, const int32_t mana, - const std::string& name, - const std::string& iconName, - const std::string& description, + const std::wstring& name, + const std::wstring& iconName, + const std::wstring& description, const uint16_t weight, const bool isEquipped, const uint16_t enchantLevel, diff --git a/L2BotCore/Domain/Entities/Skill.h b/L2BotCore/Domain/Entities/Skill.h index 6fe5d7d..dd0914c 100644 --- a/L2BotCore/Domain/Entities/Skill.h +++ b/L2BotCore/Domain/Entities/Skill.h @@ -90,43 +90,43 @@ namespace L2Bot::Domain::Entities { std::vector result; - result.push_back({ "skillId", std::to_string(m_SkillId) }); - result.push_back({ "level", std::to_string(m_Level) }); + result.push_back({ L"skillId", std::to_wstring(m_SkillId) }); + result.push_back({ L"level", std::to_wstring(m_Level) }); if (m_PrevState.isNewState) { - result.push_back({ "isActive", std::to_string(m_IsActive) }); - result.push_back({ "name", m_Name }); - result.push_back({ "iconName", m_IconName }); + result.push_back({ L"isActive", std::to_wstring(m_IsActive) }); + result.push_back({ L"name", m_Name }); + result.push_back({ L"iconName", m_IconName }); } if (m_PrevState.isNewState || m_Description != m_PrevState.description) { - result.push_back({ "description", m_Description }); + result.push_back({ L"description", m_Description }); } if (m_PrevState.isNewState || m_Cost != m_PrevState.cost) { - result.push_back({ "cost", std::to_string(m_Cost) }); + result.push_back({ L"cost", std::to_wstring(m_Cost) }); } if (m_PrevState.isNewState || m_Range != m_PrevState.range) { - result.push_back({ "range", std::to_string(m_Range) }); + result.push_back({ L"range", std::to_wstring(m_Range) }); } if (m_PrevState.isNewState || m_IsToggled != m_PrevState.isToggled) { - result.push_back({ "isToggled", std::to_string(m_IsToggled) }); + result.push_back({ L"isToggled", std::to_wstring(m_IsToggled) }); } if (m_PrevState.isNewState || m_IsCasting != m_PrevState.isCasting) { - result.push_back({ "isCasting", std::to_string(m_IsCasting) }); + result.push_back({ L"isCasting", std::to_wstring(m_IsCasting) }); } if (m_PrevState.isNewState || m_IsReloading != m_PrevState.isReloading) { - result.push_back({ "isReloading", std::to_string(m_IsReloading) }); + result.push_back({ L"isReloading", std::to_wstring(m_IsReloading) }); } if (m_PrevState.isNewState || IsReadyToUse() != m_PrevState.isReadyToUse) { - result.push_back({ "isReadyToUse", std::to_string(IsReadyToUse()) }); + result.push_back({ L"isReadyToUse", std::to_wstring(IsReadyToUse()) }); } return result; @@ -138,9 +138,9 @@ namespace L2Bot::Domain::Entities const bool isActive, const uint8_t cost, const int16_t range, - const std::string& name, - const std::string& description, - const std::string& iconName, + const std::wstring& name, + const std::wstring& description, + const std::wstring& iconName, const bool isToggled, const bool isCasting, const bool isReloading @@ -183,7 +183,7 @@ namespace L2Bot::Domain::Entities { uint8_t cost = 0; int16_t range = 0; - std::string description = ""; + std::wstring description = L""; bool isToggled = false; bool isCasting = false; bool isReloading = false; @@ -198,9 +198,9 @@ namespace L2Bot::Domain::Entities bool m_IsActive = false; uint8_t m_Cost = 0; int16_t m_Range = 0; - std::string m_Name = ""; - std::string m_Description = ""; - std::string m_IconName = ""; + std::wstring m_Name = L""; + std::wstring m_Description = L""; + std::wstring m_IconName = L""; bool m_IsToggled = false; bool m_IsCasting = false; bool m_IsReloading = false; diff --git a/L2BotCore/Domain/Entities/WeaponItem.h b/L2BotCore/Domain/Entities/WeaponItem.h index 478fc4f..e6c8999 100644 --- a/L2BotCore/Domain/Entities/WeaponItem.h +++ b/L2BotCore/Domain/Entities/WeaponItem.h @@ -68,32 +68,32 @@ namespace L2Bot::Domain::Entities if (m_PrevState.isNewState) { - result.push_back({ "weaponType", std::to_string(static_cast(m_WeaponType)) }); - result.push_back({ "crystalType", std::to_string(static_cast(m_CrystalType)) }); - result.push_back({ "rndDamage", std::to_string(m_RndDamage) }); - result.push_back({ "critical", std::to_string(m_Critical) }); - result.push_back({ "hitModify", std::to_string(m_HitModify) }); - result.push_back({ "attackSpeed", std::to_string(m_AttackSpeed) }); - result.push_back({ "mpConsume", std::to_string(m_MpConsume) }); - result.push_back({ "soulshotCount", std::to_string(m_SoulshotCount) }); - result.push_back({ "spiritshotCount", std::to_string(m_SpiritshotCount) }); + result.push_back({ L"weaponType", std::to_wstring(static_cast(m_WeaponType)) }); + result.push_back({ L"crystalType", std::to_wstring(static_cast(m_CrystalType)) }); + result.push_back({ L"rndDamage", std::to_wstring(m_RndDamage) }); + result.push_back({ L"critical", std::to_wstring(m_Critical) }); + result.push_back({ L"hitModify", std::to_wstring(m_HitModify) }); + result.push_back({ L"attackSpeed", std::to_wstring(m_AttackSpeed) }); + result.push_back({ L"mpConsume", std::to_wstring(m_MpConsume) }); + result.push_back({ L"soulshotCount", std::to_wstring(m_SoulshotCount) }); + result.push_back({ L"spiritshotCount", std::to_wstring(m_SpiritshotCount) }); } if (m_PrevState.isNewState || m_IsEquipped != m_PrevState.isEquipped) { - result.push_back({ "isEquipped", std::to_string(m_IsEquipped) }); + result.push_back({ L"isEquipped", std::to_wstring(m_IsEquipped) }); } if (m_PrevState.isNewState || m_EnchantLevel != m_PrevState.enchantLevel) { - result.push_back({ "enchantLevel", std::to_string(m_EnchantLevel) }); + result.push_back({ L"enchantLevel", std::to_wstring(m_EnchantLevel) }); } if (m_PrevState.isNewState || m_PAttack != m_PrevState.pAttack) { - result.push_back({ "pAttack", std::to_string(m_PAttack) }); + result.push_back({ L"pAttack", std::to_wstring(m_PAttack) }); } if (m_PrevState.isNewState || m_MAttack != m_PrevState.mAttack) { - result.push_back({ "mAttack", std::to_string(m_MAttack) }); + result.push_back({ L"mAttack", std::to_wstring(m_MAttack) }); } return result; @@ -103,9 +103,9 @@ namespace L2Bot::Domain::Entities const uint32_t objectId, const uint32_t itemId, const int32_t mana, - const std::string& name, - const std::string& iconName, - const std::string& description, + const std::wstring& name, + const std::wstring& iconName, + const std::wstring& description, const uint16_t weight, const bool isEquipped, const uint16_t enchantLevel, diff --git a/L2BotCore/Domain/Entities/WorldObject.h b/L2BotCore/Domain/Entities/WorldObject.h index 18b7e37..f74df4f 100644 --- a/L2BotCore/Domain/Entities/WorldObject.h +++ b/L2BotCore/Domain/Entities/WorldObject.h @@ -34,10 +34,10 @@ namespace L2Bot::Domain::Entities { std::vector result; - result.push_back({ "id", std::to_string(GetId()) }); + result.push_back({ L"id", std::to_wstring(GetId()) }); if (m_PrevState.isNewState || !m_Transform.IsEqual(&m_PrevState.transform)) { - result.push_back({ "transform", m_Transform.BuildSerializationNodes() }); + result.push_back({ L"transform", m_Transform.BuildSerializationNodes() }); } return result; diff --git a/L2BotCore/Domain/Serializers/Node.h b/L2BotCore/Domain/Serializers/Node.h index 1251469..6666ffd 100644 --- a/L2BotCore/Domain/Serializers/Node.h +++ b/L2BotCore/Domain/Serializers/Node.h @@ -7,18 +7,18 @@ namespace L2Bot::Domain::Serializers { struct Node { - const std::string name = ""; - const std::string value = ""; + const std::wstring name = L""; + const std::wstring value = L""; const std::vector children; const bool isArray = false; const bool isContainer = false; Node() = delete; - Node(const std::string& name, const std::string& value) : + Node(const std::wstring& name, const std::wstring& value) : name(name), value(value) { } - Node(const std::string& name, const std::vector children, const bool isArray = false) : + Node(const std::wstring& name, const std::vector children, const bool isArray = false) : name(name), children(children), isArray(isArray), isContainer(true) { } diff --git a/L2BotCore/Domain/Serializers/SerializableStateContainer.h b/L2BotCore/Domain/Serializers/SerializableStateContainer.h index b53db33..fa55037 100644 --- a/L2BotCore/Domain/Serializers/SerializableStateContainer.h +++ b/L2BotCore/Domain/Serializers/SerializableStateContainer.h @@ -14,21 +14,21 @@ namespace L2Bot::Domain::Serializers for (const auto& kvp : m_Objects) { - std::string operationName = ""; + std::wstring operationName = L""; switch (kvp->GetState()) { case Enums::EntityStateEnum::created: - operationName = "created"; + operationName = L"created"; break; case Enums::EntityStateEnum::updated: - operationName = "updated"; + operationName = L"updated"; break; case Enums::EntityStateEnum::deleted: - operationName = "deleted"; + operationName = L"deleted"; break; } - if (operationName != "") + if (operationName != L"") { result.push_back( { @@ -42,7 +42,7 @@ namespace L2Bot::Domain::Serializers return result; } - SerializableStateContainer(const std::vector> objects, const std::string& containerName) : + SerializableStateContainer(const std::vector> objects, const std::wstring& containerName) : m_Objects(objects), m_ContainerName(containerName) { @@ -51,6 +51,6 @@ namespace L2Bot::Domain::Serializers virtual ~SerializableStateContainer() = default; private: const std::vector> m_Objects; - const std::string m_ContainerName; + const std::wstring m_ContainerName; }; } \ No newline at end of file diff --git a/L2BotCore/Domain/Serializers/SerializerInterface.h b/L2BotCore/Domain/Serializers/SerializerInterface.h index 76d1710..0dbe714 100644 --- a/L2BotCore/Domain/Serializers/SerializerInterface.h +++ b/L2BotCore/Domain/Serializers/SerializerInterface.h @@ -8,6 +8,6 @@ namespace L2Bot::Domain::Serializers class SerializerInterface { public: - virtual const std::string Serialize(std::vector nodes, const bool isArray = false) const = 0; + virtual const std::wstring Serialize(std::vector nodes, const bool isArray = false) const = 0; }; } diff --git a/L2BotCore/Domain/Transports/TransportInterface.h b/L2BotCore/Domain/Transports/TransportInterface.h index a37a330..0629a1f 100644 --- a/L2BotCore/Domain/Transports/TransportInterface.h +++ b/L2BotCore/Domain/Transports/TransportInterface.h @@ -8,7 +8,7 @@ namespace L2Bot::Domain::Transports public: virtual const bool Connect() = 0; virtual const bool IsConnected() const = 0; - virtual const void Send(const std::string& data) = 0; - virtual const std::string Receive() = 0; + virtual const void Send(const std::wstring& data) = 0; + virtual const std::wstring Receive() = 0; }; } diff --git a/L2BotCore/Domain/ValueObjects/ChatMessage.h b/L2BotCore/Domain/ValueObjects/ChatMessage.h index 487dd12..d5887f8 100644 --- a/L2BotCore/Domain/ValueObjects/ChatMessage.h +++ b/L2BotCore/Domain/ValueObjects/ChatMessage.h @@ -13,18 +13,18 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "objectId", std::to_string(m_ObjectId) }, - { "channel", std::to_string(static_cast(m_Channel)) }, - { "name", m_Name }, - { "text", m_Text } + { L"objectId", std::to_wstring(m_ObjectId) }, + { L"channel", std::to_wstring(static_cast(m_Channel)) }, + { L"name", m_Name }, + { L"text", m_Text } }; } ChatMessage( const uint32_t objectId, const Enums::ChatChannelEnum channel, - const std::string& name, - const std::string& text + const std::wstring& name, + const std::wstring& text ) : m_ObjectId(objectId), m_Channel(channel), @@ -39,7 +39,7 @@ namespace L2Bot::Domain::ValueObjects private: uint32_t m_ObjectId = 0; Enums::ChatChannelEnum m_Channel = Enums::ChatChannelEnum::all; - std::string m_Name = ""; - std::string m_Text = ""; + std::wstring m_Name = L""; + std::wstring m_Text = L""; }; } diff --git a/L2BotCore/Domain/ValueObjects/ExperienceInfo.h b/L2BotCore/Domain/ValueObjects/ExperienceInfo.h index 43fa434..0641af9 100644 --- a/L2BotCore/Domain/ValueObjects/ExperienceInfo.h +++ b/L2BotCore/Domain/ValueObjects/ExperienceInfo.h @@ -28,9 +28,9 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "level", std::to_string(m_Level) }, - { "exp", std::to_string(m_Exp) }, - { "sp", std::to_string(m_Sp) } + { L"level", std::to_wstring(m_Level) }, + { L"exp", std::to_wstring(m_Exp) }, + { L"sp", std::to_wstring(m_Sp) } }; } diff --git a/L2BotCore/Domain/ValueObjects/FullName.h b/L2BotCore/Domain/ValueObjects/FullName.h index 758ea21..934b7b5 100644 --- a/L2BotCore/Domain/ValueObjects/FullName.h +++ b/L2BotCore/Domain/ValueObjects/FullName.h @@ -7,11 +7,11 @@ namespace L2Bot::Domain::ValueObjects class FullName : public Serializers::Serializable { public: - const std::string& GetNickname() const + const std::wstring& GetNickname() const { return m_Nickname; } - const std::string& GetTitle() const + const std::wstring& GetTitle() const { return m_Title; } @@ -24,14 +24,14 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "nickname", m_Nickname }, - { "title", m_Title } + { L"nickname", m_Nickname }, + { L"title", m_Title } }; } FullName( - const std::string& nickname, - const std::string& title + const std::wstring& nickname, + const std::wstring& title ) : m_Nickname(nickname), m_Title(title) @@ -41,7 +41,7 @@ namespace L2Bot::Domain::ValueObjects FullName() = default; virtual ~FullName() = default; private: - std::string m_Nickname = ""; - std::string m_Title = ""; + std::wstring m_Nickname = L""; + std::wstring m_Title = L""; }; } diff --git a/L2BotCore/Domain/ValueObjects/InventoryInfo.h b/L2BotCore/Domain/ValueObjects/InventoryInfo.h index 420b82b..f035013 100644 --- a/L2BotCore/Domain/ValueObjects/InventoryInfo.h +++ b/L2BotCore/Domain/ValueObjects/InventoryInfo.h @@ -34,9 +34,9 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "maxWeight", std::to_string(m_MaxWeight) }, - { "weight", std::to_string(m_Weight) }, - { "slots", std::to_string(m_Slots) } + { L"maxWeight", std::to_wstring(m_MaxWeight) }, + { L"weight", std::to_wstring(m_Weight) }, + { L"slots", std::to_wstring(m_Slots) } }; } diff --git a/L2BotCore/Domain/ValueObjects/PermanentStats.h b/L2BotCore/Domain/ValueObjects/PermanentStats.h index c81ae9a..3386c88 100644 --- a/L2BotCore/Domain/ValueObjects/PermanentStats.h +++ b/L2BotCore/Domain/ValueObjects/PermanentStats.h @@ -45,12 +45,12 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "str", std::to_string(m_Str) }, - { "dex", std::to_string(m_Dex) }, - { "con", std::to_string(m_Con) }, - { "int", std::to_string(m_Int) }, - { "men", std::to_string(m_Men) }, - { "wit", std::to_string(m_Wit) } + { L"str", std::to_wstring(m_Str) }, + { L"dex", std::to_wstring(m_Dex) }, + { L"con", std::to_wstring(m_Con) }, + { L"int", std::to_wstring(m_Int) }, + { L"men", std::to_wstring(m_Men) }, + { L"wit", std::to_wstring(m_Wit) } }; } diff --git a/L2BotCore/Domain/ValueObjects/Phenotype.h b/L2BotCore/Domain/ValueObjects/Phenotype.h index 15e2bce..9f4121f 100644 --- a/L2BotCore/Domain/ValueObjects/Phenotype.h +++ b/L2BotCore/Domain/ValueObjects/Phenotype.h @@ -40,10 +40,10 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "race", std::to_string(static_cast(m_Race)) }, - { "isMale", std::to_string(m_IsMale) }, - { "class", std::to_string(static_cast(m_Class)) }, - { "activeClass", std::to_string(static_cast(m_ActiveClass)) } + { L"race", std::to_wstring(static_cast(m_Race)) }, + { L"isMale", std::to_wstring(m_IsMale) }, + { L"class", std::to_wstring(static_cast(m_Class)) }, + { L"activeClass", std::to_wstring(static_cast(m_ActiveClass)) } }; } diff --git a/L2BotCore/Domain/ValueObjects/Reputation.h b/L2BotCore/Domain/ValueObjects/Reputation.h index d6f0d65..cb0bd2c 100644 --- a/L2BotCore/Domain/ValueObjects/Reputation.h +++ b/L2BotCore/Domain/ValueObjects/Reputation.h @@ -44,11 +44,11 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "karma", std::to_string(m_Karma) }, - { "pkKills", std::to_string(m_PkKills) }, - { "pvpKills", std::to_string(m_PvpKills) }, - { "recRemaining", std::to_string(m_RecRemaining) }, - { "evalScore", std::to_string(m_EvalScore) } + { L"karma", std::to_wstring(m_Karma) }, + { L"pkKills", std::to_wstring(m_PkKills) }, + { L"pvpKills", std::to_wstring(m_PvpKills) }, + { L"recRemaining", std::to_wstring(m_RecRemaining) }, + { L"evalScore", std::to_wstring(m_EvalScore) } }; } diff --git a/L2BotCore/Domain/ValueObjects/Transform.h b/L2BotCore/Domain/ValueObjects/Transform.h index 5bb7a6c..1c83f06 100644 --- a/L2BotCore/Domain/ValueObjects/Transform.h +++ b/L2BotCore/Domain/ValueObjects/Transform.h @@ -43,10 +43,10 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "position", m_Position.BuildSerializationNodes() }, - { "rotation", m_Rotation.BuildSerializationNodes() }, - { "velocity", m_Velocity.BuildSerializationNodes() }, - { "acceleration", m_Acceleration.BuildSerializationNodes() } + { L"position", m_Position.BuildSerializationNodes() }, + { L"rotation", m_Rotation.BuildSerializationNodes() }, + { L"velocity", m_Velocity.BuildSerializationNodes() }, + { L"acceleration", m_Acceleration.BuildSerializationNodes() } }; } diff --git a/L2BotCore/Domain/ValueObjects/VariableStats.h b/L2BotCore/Domain/ValueObjects/VariableStats.h index adee767..8dab172 100644 --- a/L2BotCore/Domain/ValueObjects/VariableStats.h +++ b/L2BotCore/Domain/ValueObjects/VariableStats.h @@ -60,15 +60,15 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "accuracy", std::to_string(m_Accuracy) }, - { "critRate", std::to_string(m_CritRate) }, - { "pAttack", std::to_string(m_PAttack) }, - { "attackSpeed", std::to_string(m_AttackSpeed) }, - { "pDefense", std::to_string(m_PDefense) }, - { "evasion", std::to_string(m_Evasion) }, - { "mAttack", std::to_string(m_MAttack) }, - { "mDefense", std::to_string(m_MDefense) }, - { "castingSpeed", std::to_string(m_CastingSpeed) } + { L"accuracy", std::to_wstring(m_Accuracy) }, + { L"critRate", std::to_wstring(m_CritRate) }, + { L"pAttack", std::to_wstring(m_PAttack) }, + { L"attackSpeed", std::to_wstring(m_AttackSpeed) }, + { L"pDefense", std::to_wstring(m_PDefense) }, + { L"evasion", std::to_wstring(m_Evasion) }, + { L"mAttack", std::to_wstring(m_MAttack) }, + { L"mDefense", std::to_wstring(m_MDefense) }, + { L"castingSpeed", std::to_wstring(m_CastingSpeed) } }; } diff --git a/L2BotCore/Domain/ValueObjects/Vector3.h b/L2BotCore/Domain/ValueObjects/Vector3.h index fbf5871..4ccb1d7 100644 --- a/L2BotCore/Domain/ValueObjects/Vector3.h +++ b/L2BotCore/Domain/ValueObjects/Vector3.h @@ -42,9 +42,9 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "x", std::to_string(m_X) }, - { "y", std::to_string(m_Y) }, - { "z", std::to_string(m_Z) } + { L"x", std::to_wstring(m_X) }, + { L"y", std::to_wstring(m_Y) }, + { L"z", std::to_wstring(m_Z) } }; } diff --git a/L2BotCore/Domain/ValueObjects/VitalStats.h b/L2BotCore/Domain/ValueObjects/VitalStats.h index 6b4319d..70ede93 100644 --- a/L2BotCore/Domain/ValueObjects/VitalStats.h +++ b/L2BotCore/Domain/ValueObjects/VitalStats.h @@ -49,12 +49,12 @@ namespace L2Bot::Domain::ValueObjects { return std::vector { - { "maxHp", std::to_string(m_MaxHp) }, - { "hp", std::to_string(m_Hp) }, - { "maxMp", std::to_string(m_MaxMp) }, - { "mp", std::to_string(m_Mp) }, - { "maxCp", std::to_string(m_MaxCp) }, - { "cp", std::to_string(m_Cp) } + { L"maxHp", std::to_wstring(m_MaxHp) }, + { L"hp", std::to_wstring(m_Hp) }, + { L"maxMp", std::to_wstring(m_MaxMp) }, + { L"mp", std::to_wstring(m_Mp) }, + { L"maxCp", std::to_wstring(m_MaxCp) }, + { L"cp", std::to_wstring(m_Cp) } }; } diff --git a/L2BotDll/Application.h b/L2BotDll/Application.h index cf21b51..dacda83 100644 --- a/L2BotDll/Application.h +++ b/L2BotDll/Application.h @@ -62,9 +62,9 @@ private: JsonSerializer m_Serializer; NamedPipeTransport m_Transport; - static const std::string PIPE_NAME; + static const std::wstring PIPE_NAME; static const uint16_t RADIUS; }; -const std::string Application::PIPE_NAME = std::string("PipeL2Bot"); +const std::wstring Application::PIPE_NAME = std::wstring(L"PipeL2Bot"); const uint16_t Application::RADIUS = 2000; \ No newline at end of file diff --git a/L2BotDll/Common/Common.cpp b/L2BotDll/Common/Common.cpp index 050fbe7..0d10788 100644 --- a/L2BotDll/Common/Common.cpp +++ b/L2BotDll/Common/Common.cpp @@ -5,14 +5,7 @@ #include #pragma comment(lib, "Rpcrt4.lib") -std::string ConvertFromWideChar(const wchar_t* str) -{ - std::wstring ws(str); - std::string result(ws.begin(), ws.end()); - return result; -} - -std::string GenerateUUID() +std::wstring GenerateUUID() { UUID uuid; ::ZeroMemory(&uuid, sizeof(UUID)); @@ -24,7 +17,7 @@ std::string GenerateUUID() if (wszUuid == NULL) { - return ""; + return L""; } std::wstring ws = wszUuid; @@ -32,5 +25,5 @@ std::string GenerateUUID() ::RpcStringFree((RPC_WSTR*)&wszUuid); wszUuid = NULL; - return std::string(ws.begin(), ws.end()); + return ws; } \ No newline at end of file diff --git a/L2BotDll/Common/Common.h b/L2BotDll/Common/Common.h index 6f2c3bb..c2f5542 100644 --- a/L2BotDll/Common/Common.h +++ b/L2BotDll/Common/Common.h @@ -3,5 +3,4 @@ #include #include -std::string ConvertFromWideChar(const wchar_t* str); -std::string GenerateUUID(); \ No newline at end of file +std::wstring GenerateUUID(); \ No newline at end of file diff --git a/L2BotDll/DTO/ChatMessage.h b/L2BotDll/DTO/ChatMessage.h index b8a1366..3166d03 100644 --- a/L2BotDll/DTO/ChatMessage.h +++ b/L2BotDll/DTO/ChatMessage.h @@ -7,6 +7,6 @@ struct ChatMessage { const uint32_t objectId = 0; const uint8_t channel = 0; - const std::string name = ""; - const std::string text = ""; + const std::wstring name = L""; + const std::wstring text = L""; }; \ No newline at end of file diff --git a/L2BotDll/Serializers/JsonSerializer.h b/L2BotDll/Serializers/JsonSerializer.h index d2ee74c..f9ecc1a 100644 --- a/L2BotDll/Serializers/JsonSerializer.h +++ b/L2BotDll/Serializers/JsonSerializer.h @@ -8,15 +8,15 @@ using namespace L2Bot::Domain; class JsonSerializer : public Serializers::SerializerInterface { public: - const std::string Serialize(std::vector nodes, const bool isArray = false) const override + const std::wstring Serialize(std::vector nodes, const bool isArray = false) const override { - std::string result = isArray ? "[" : "{"; + std::wstring result = isArray ? L"[" : L"{"; for (auto it = nodes.begin(); it != nodes.end(); ++it) { if (!isArray) { - result += "\"" + it->name + "\":"; + result += L"\"" + it->name + L"\":"; } if (it->isContainer) { @@ -24,15 +24,15 @@ public: } else { - result += "\"" + it->value + "\""; + result += L"\"" + it->value + L"\""; } if (std::next(it) != nodes.end()) { - result += ","; + result += L","; } } - result += isArray ? "]" : "}"; + result += isArray ? L"]" : L"}"; return result; } diff --git a/L2BotDll/Services/WorldHandler.h b/L2BotDll/Services/WorldHandler.h index 7fcd331..1a4e6c1 100644 --- a/L2BotDll/Services/WorldHandler.h +++ b/L2BotDll/Services/WorldHandler.h @@ -98,8 +98,8 @@ private: { if (m_Transport.IsConnected()) { - const std::string& response = m_Transport.Receive(); - if (response == "invalidate") + const std::wstring& response = m_Transport.Receive(); + if (response == L"invalidate") { Invalidate(); } @@ -124,13 +124,13 @@ private: { std::vector items { - Serializers::SerializableStateContainer{m_HeroService.GetEntities(), "hero"}, - Serializers::SerializableStateContainer{m_DropService.GetEntities(), "drop"}, - Serializers::SerializableStateContainer{m_NPCService.GetEntities(), "npc"}, - Serializers::SerializableStateContainer{m_PlayerService.GetEntities(), "player"}, - Serializers::SerializableStateContainer{m_SkillService.GetEntities(), "skill"}, - Serializers::SerializableStateContainer{m_ItemService.GetEntities(), "item"}, - Serializers::SerializableStateContainer{m_AbnormalEffectService.GetEntities(), "abnormalEffect"}, + Serializers::SerializableStateContainer{m_HeroService.GetEntities(), L"hero"}, + Serializers::SerializableStateContainer{m_DropService.GetEntities(), L"drop"}, + Serializers::SerializableStateContainer{m_NPCService.GetEntities(), L"npc"}, + Serializers::SerializableStateContainer{m_PlayerService.GetEntities(), L"player"}, + Serializers::SerializableStateContainer{m_SkillService.GetEntities(), L"skill"}, + Serializers::SerializableStateContainer{m_ItemService.GetEntities(), L"item"}, + Serializers::SerializableStateContainer{m_AbnormalEffectService.GetEntities(), L"abnormalEffect"}, }; std::vector result; @@ -144,7 +144,7 @@ private: for (const auto& message : m_ChatMessageService.GetMessages()) { - result.push_back(Serializers::Node{ "chat", message.BuildSerializationNodes() }); + result.push_back(Serializers::Node{ L"chat", message.BuildSerializationNodes() }); } return result; diff --git a/L2BotDll/Transports/DebugViewTransport.h b/L2BotDll/Transports/DebugViewTransport.h index e716fa9..3c3c108 100644 --- a/L2BotDll/Transports/DebugViewTransport.h +++ b/L2BotDll/Transports/DebugViewTransport.h @@ -18,15 +18,15 @@ public: return true; } - const void Send(const std::string& data) override + const void Send(const std::wstring& data) override { - OutputDebugStringA(data.c_str()); + OutputDebugStringW(data.c_str()); } - const std::string Receive() override + const std::wstring Receive() override { // delay imitation std::this_thread::sleep_for(std::chrono::milliseconds(50)); - return ""; + return L""; } DebugViewTransport() = default; diff --git a/L2BotDll/Transports/NamedPipe.h b/L2BotDll/Transports/NamedPipe.h index 5450488..98e6f10 100644 --- a/L2BotDll/Transports/NamedPipe.h +++ b/L2BotDll/Transports/NamedPipe.h @@ -10,7 +10,7 @@ class NamedPipe { public: - const bool Connect(const std::string& pipeName) + const bool Connect(const std::wstring& pipeName) { if (m_Pipe == NULL || m_PipeName != pipeName) { @@ -25,7 +25,7 @@ public: CreateOverlapped(m_WritingOverlapped); } - m_Pipe = CreateNamedPipeA(("\\\\.\\pipe\\" + pipeName).c_str(), + m_Pipe = CreateNamedPipeW((L"\\\\.\\pipe\\" + pipeName).c_str(), PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, @@ -58,7 +58,7 @@ public: return m_Connected; } - void Send(const std::string& message) + void Send(const std::wstring& message) { if (!m_Connected) { @@ -66,7 +66,7 @@ public: } DWORD written; - const auto result = WriteFile(m_Pipe, message.c_str(), message.size() + 1, &written, &m_WritingOverlapped); + const auto result = WriteFile(m_Pipe, message.c_str(), (message.size() + 1) * sizeof(wchar_t), &written, &m_WritingOverlapped); const auto lastError = GetLastError(); if (!result) @@ -88,16 +88,16 @@ public: } } - const std::string Receive() + const std::wstring Receive() { if (!m_Connected) { - return ""; + return L""; } DWORD dwRead; - std::unique_ptr buffer = std::make_unique(BUFFER_SIZE); - const auto result = ReadFile(m_Pipe, buffer.get(), BUFFER_SIZE * sizeof(char), &dwRead, &m_ReadingOverlapped); + std::unique_ptr buffer = std::make_unique(BUFFER_SIZE); + const auto result = ReadFile(m_Pipe, buffer.get(), BUFFER_SIZE * sizeof(wchar_t), &dwRead, &m_ReadingOverlapped); const auto lastError = GetLastError(); if (!result) @@ -110,17 +110,17 @@ public: if (!overlappedResult) { m_Connected = false; - return ""; + return L""; } } else { m_Connected = false; - return ""; + return L""; } } - std::string message = std::string(buffer.get()); + std::wstring message = std::wstring(buffer.get()); return message; } @@ -182,7 +182,7 @@ private: } private: - std::string m_PipeName = ""; + std::wstring m_PipeName = L""; HANDLE m_Pipe = NULL; bool m_Connected = false; OVERLAPPED m_ConntectingOverlapped = OVERLAPPED(); diff --git a/L2BotDll/Transports/NamedPipeTransport.h b/L2BotDll/Transports/NamedPipeTransport.h index f079eb3..031986f 100644 --- a/L2BotDll/Transports/NamedPipeTransport.h +++ b/L2BotDll/Transports/NamedPipeTransport.h @@ -11,7 +11,7 @@ class NamedPipeTransport : public Transports::TransportInterface public: const bool Connect() override { - OutputDebugStringA(m_PipeName.c_str()); + OutputDebugStringW(m_PipeName.c_str()); if (!m_ConnectionPipe.Connect(m_PipeName)) { return false; @@ -19,9 +19,9 @@ public: OutputDebugStringA("Client connected to connection pipe"); - const std::string mainPipeName = GenerateUUID(); + const auto mainPipeName = GenerateUUID(); - m_ConnectionPipe.Send("\\\\.\\pipe\\" + mainPipeName); + m_ConnectionPipe.Send(L"\\\\.\\pipe\\" + mainPipeName); OutputDebugStringA("Name of main pipe sended"); @@ -32,12 +32,12 @@ public: } OutputDebugStringA("Client connected to main pipe"); - m_Pipe.Send("Hello!"); + m_Pipe.Send(L"Hello!"); return true; } - const void Send(const std::string& data) override + const void Send(const std::wstring& data) override { if (!m_Pipe.IsConnected()) { @@ -46,11 +46,11 @@ public: m_Pipe.Send(data); } - const std::string Receive() override + const std::wstring Receive() override { if (!m_Pipe.IsConnected()) { - return ""; + return L""; } return m_Pipe.Receive(); @@ -61,7 +61,7 @@ public: return m_Pipe.IsConnected(); } - NamedPipeTransport(const std::string& pipeName) : + NamedPipeTransport(const std::wstring& pipeName) : m_PipeName(pipeName) { } @@ -72,5 +72,5 @@ public: private: NamedPipe m_ConnectionPipe; NamedPipe m_Pipe; - std::string m_PipeName = ""; + std::wstring m_PipeName = L""; }; \ No newline at end of file diff --git a/L2BotDll/Versions/Interlude/Factories/AbnormalEffectFactory.h b/L2BotDll/Versions/Interlude/Factories/AbnormalEffectFactory.h index 9e4e3f0..f8282b9 100644 --- a/L2BotDll/Versions/Interlude/Factories/AbnormalEffectFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/AbnormalEffectFactory.h @@ -35,9 +35,9 @@ namespace Interlude return std::make_unique( skillId, static_cast(level), - ConvertFromWideChar(name), - ConvertFromWideChar(description), - iconEntry ? ConvertFromWideChar(iconEntry->value) : "" + std::wstring(name), + std::wstring(description), + iconEntry ? std::wstring(iconEntry->value) : L"" ); } diff --git a/L2BotDll/Versions/Interlude/Factories/DropFactory.h b/L2BotDll/Versions/Interlude/Factories/DropFactory.h index 25a7d58..9af0166 100644 --- a/L2BotDll/Versions/Interlude/Factories/DropFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/DropFactory.h @@ -41,8 +41,8 @@ namespace Interlude ), item->itemId, item->amount, - nameEntry ? ConvertFromWideChar(nameEntry->value) : "", - iconEntry ? ConvertFromWideChar(iconEntry->value) : "" + nameEntry ? std::wstring(nameEntry->value) : L"", + iconEntry ? std::wstring(iconEntry->value) : L"" ); } diff --git a/L2BotDll/Versions/Interlude/Factories/HeroFactory.h b/L2BotDll/Versions/Interlude/Factories/HeroFactory.h index 50f5a03..0c4dca1 100644 --- a/L2BotDll/Versions/Interlude/Factories/HeroFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/HeroFactory.h @@ -30,8 +30,8 @@ namespace Interlude ValueObjects::Vector3(item->pawn->Acceleration.x, item->pawn->Acceleration.y, item->pawn->Acceleration.z) ), ValueObjects::FullName( - ConvertFromWideChar(item->nickname), - ConvertFromWideChar(item->title) + std::wstring(item->nickname), + std::wstring(item->title) ), ValueObjects::VitalStats( item->maxHp, item->hp, diff --git a/L2BotDll/Versions/Interlude/Factories/ItemFactory.h b/L2BotDll/Versions/Interlude/Factories/ItemFactory.h index 167032e..e6f1996 100644 --- a/L2BotDll/Versions/Interlude/Factories/ItemFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/ItemFactory.h @@ -35,10 +35,10 @@ namespace Interlude const auto data = m_L2GameData.GetItemData(itemInfo.itemId); const auto nameEntry = data ? m_FName.GetEntry(data->nameIndex) : nullptr; - const auto name = nameEntry ? ConvertFromWideChar(nameEntry->value) : ""; + const auto name = nameEntry ? std::wstring(nameEntry->value) : L""; const auto iconEntry = data ? m_FName.GetEntry(data->iconNameIndex) : nullptr; - const auto icon = iconEntry ? ConvertFromWideChar(iconEntry->value) : ""; - const auto description = data && data->description ? ConvertFromWideChar(data->description) : ""; + const auto icon = iconEntry ? std::wstring(iconEntry->value) : L""; + const auto description = data && data->description ? std::wstring(data->description) : L""; if (data) { @@ -92,9 +92,9 @@ namespace Interlude std::unique_ptr CreateEtc( const ItemData& itemInfo, const FL2ItemDataBase* itemData, - const std::string& name, - const std::string& icon, - const std::string& description + const std::wstring& name, + const std::wstring& icon, + const std::wstring& description ) const { return std::make_unique( @@ -113,16 +113,16 @@ namespace Interlude std::unique_ptr CreateArmor( const ItemData& itemInfo, const FL2ItemDataBase* itemData, - const std::string& name, - const std::string& icon, - const std::string& description + const std::wstring& name, + const std::wstring& icon, + const std::wstring& description ) const { const auto casted = static_cast(itemData); - const auto setEffect = casted && casted->setEffect ? ConvertFromWideChar(casted->setEffect) : ""; - const auto addSetEffect = casted && casted->setEffect ? ConvertFromWideChar(casted->setEffect) : ""; - const auto enchantEffect = casted && casted->enchantEffect ? ConvertFromWideChar(casted->enchantEffect) : ""; + const auto setEffect = casted && casted->setEffect ? std::wstring(casted->setEffect) : L""; + const auto addSetEffect = casted && casted->setEffect ? std::wstring(casted->setEffect) : L""; + const auto enchantEffect = casted && casted->enchantEffect ? std::wstring(casted->enchantEffect) : L""; return std::make_unique( itemInfo.objectId, @@ -147,9 +147,9 @@ namespace Interlude std::unique_ptr CreateWeaponOrShield( const ItemData& itemInfo, const FL2ItemDataBase* itemData, - const std::string& name, - const std::string& icon, - const std::string& description + const std::wstring& name, + const std::wstring& icon, + const std::wstring& description ) const { const auto casted = static_cast(itemData); diff --git a/L2BotDll/Versions/Interlude/Factories/NPCFactory.h b/L2BotDll/Versions/Interlude/Factories/NPCFactory.h index 46a9622..a166c4d 100644 --- a/L2BotDll/Versions/Interlude/Factories/NPCFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/NPCFactory.h @@ -30,8 +30,8 @@ namespace Interlude item->npcId, spoiledState, ValueObjects::FullName( - ConvertFromWideChar(item->nickname), - ConvertFromWideChar(item->title) + std::wstring(item->nickname), + std::wstring(item->title) ), ValueObjects::VitalStats( item->maxHp, item->hp, diff --git a/L2BotDll/Versions/Interlude/Factories/PlayerFactory.h b/L2BotDll/Versions/Interlude/Factories/PlayerFactory.h index 5090662..22e0de9 100644 --- a/L2BotDll/Versions/Interlude/Factories/PlayerFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/PlayerFactory.h @@ -27,8 +27,8 @@ namespace Interlude ValueObjects::Vector3(item->pawn->Acceleration.x, item->pawn->Acceleration.y, item->pawn->Acceleration.z) ), ValueObjects::FullName( - ConvertFromWideChar(item->nickname), - ConvertFromWideChar(item->title) + std::wstring(item->nickname), + std::wstring(item->title) ), ValueObjects::Phenotype( (Enums::RaceEnum)item->raceId, diff --git a/L2BotDll/Versions/Interlude/Factories/SkillFactory.h b/L2BotDll/Versions/Interlude/Factories/SkillFactory.h index d93805d..c2227c4 100644 --- a/L2BotDll/Versions/Interlude/Factories/SkillFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/SkillFactory.h @@ -40,9 +40,9 @@ namespace Interlude isActive != 1, static_cast(cost), static_cast(range), - ConvertFromWideChar(name), - ConvertFromWideChar(description), - iconEntry ? ConvertFromWideChar(iconEntry->value) : "", + std::wstring(name), + std::wstring(description), + iconEntry ? std::wstring(iconEntry->value) : L"", false, false, false diff --git a/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp b/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp index e1f1570..65fcb83 100644 --- a/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp +++ b/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp @@ -177,8 +177,8 @@ namespace Interlude { buffer[0], static_cast(buffer[1]), - ConvertFromWideChar(reinterpret_cast(buffer[2])), - ConvertFromWideChar(reinterpret_cast(buffer[3])) + std::wstring(reinterpret_cast(buffer[2])), + std::wstring(reinterpret_cast(buffer[3])) } } ); diff --git a/L2BotDll/pch.h b/L2BotDll/pch.h index 7b7042a..166abe4 100644 --- a/L2BotDll/pch.h +++ b/L2BotDll/pch.h @@ -30,6 +30,4 @@ #include #include -std::string ConvertFromWideChar(const wchar_t* str); - #endif //PCH_H