diff --git a/Source/Client/Application/Launcher.cpp b/Source/Client/Application/Launcher.cpp index feaeb752d..d4af7d217 100644 --- a/Source/Client/Application/Launcher.cpp +++ b/Source/Client/Application/Launcher.cpp @@ -833,9 +833,9 @@ HANDLE StartClientProcess(char* program) { STARTUPINFOA startup = {}; startup.cb = sizeof(startup); + PROCESS_INFORMATION process = {}; startup.dwFlags = STARTF_USESHOWWINDOW; startup.wShowWindow = SW_SHOWNORMAL; - PROCESS_INFORMATION process = {}; CreateProcessA(nullptr, commandLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startup, &process); return process.hProcess; diff --git a/Source/Contents/Actors/MercenaryAI.cpp b/Source/Contents/Actors/MercenaryAI.cpp index 9e5852075..d27776ae4 100644 --- a/Source/Contents/Actors/MercenaryAI.cpp +++ b/Source/Contents/Actors/MercenaryAI.cpp @@ -305,8 +305,8 @@ int AiHomunAttack(lua_State* state) { // OFFSET: 0x00D9ECA0 // FUNCTION: fn_22336 int AiMercenaryAttack(lua_State* state) { - std::uint32_t aid = static_cast(lua_tonumber(state, 1)); - std::uint32_t target = static_cast(lua_tonumber(state, 2)); + std::uint32_t aid = static_cast(luaL_checknumber(state, 1)); + std::uint32_t target = static_cast(luaL_checknumber(state, 2)); if (!g_session.IsMercenaryAid(aid)) { return 0; } @@ -1067,13 +1067,13 @@ int AiMove(lua_State* state) { // OFFSET: 0x00DA0260 // FUNCTION: fn_22345 int AiMoveToOwner(lua_State* state) { - std::uint32_t aid = static_cast(lua_tonumber(state, 1)); + std::uint32_t aid = static_cast(luaL_checknumber(state, 1)); if (!g_session.IsHomunAid(aid) && !g_session.IsMercenaryAid(aid)) { return 0; } + MoveToOwnerPacket packet; if (static_cast(g_modeMgr.GetGameMode())->scene->GetGameActorByAID(aid)) { - MoveToOwnerPacket packet; packet.opcode = ID_CZ_REQUEST_MOVETOOWNER; packet.aid = aid; GetRagConnection().Send(reinterpret_cast(GetRagConnection()).FixedLength(packet.opcode), &packet); @@ -1085,12 +1085,12 @@ int AiMoveToOwner(lua_State* state) { // OFFSET: 0x00DA0300 // FUNCTION: fn_22346 int AiSkillGround(lua_State* state) { - std::uint32_t aid = static_cast(lua_tonumber(state, 1)); + std::uint32_t aid = static_cast(luaL_checknumber(state, 1)); int skillArgs[4]; - skillArgs[0] = static_cast(lua_tonumber(state, 3)); - skillArgs[1] = static_cast(lua_tonumber(state, 4)); - skillArgs[2] = static_cast(lua_tonumber(state, 5)); - skillArgs[3] = static_cast(lua_tonumber(state, 2)); + skillArgs[0] = static_cast(luaL_checknumber(state, 3)); + skillArgs[1] = static_cast(luaL_checknumber(state, 4)); + skillArgs[2] = static_cast(luaL_checknumber(state, 5)); + skillArgs[3] = static_cast(luaL_checknumber(state, 2)); if (!g_session.IsHomunAid(aid) && !g_session.IsMercenaryAid(aid)) { return 0; @@ -1111,10 +1111,10 @@ int AiSkillGround(lua_State* state) { // OFFSET: 0x00DA0420 // FUNCTION: fn_22347 int AiSkillObject(lua_State* state) { - std::uint32_t aid = static_cast(lua_tonumber(state, 1)); - unsigned int level = static_cast(lua_tonumber(state, 2)); - std::uint32_t skillId = static_cast(lua_tonumber(state, 3)); - std::uint32_t target = static_cast(lua_tonumber(state, 4)); + std::uint32_t aid = static_cast(luaL_checknumber(state, 1)); + unsigned int level = static_cast(luaL_checknumber(state, 2)); + std::uint32_t skillId = static_cast(luaL_checknumber(state, 3)); + std::uint32_t target = static_cast(luaL_checknumber(state, 4)); CSkillInfo skill = g_session.LookupSkill(skillId); if (!skill.available) { diff --git a/Source/Contents/Effects/Skills/PowderingEffect.cpp b/Source/Contents/Effects/Skills/PowderingEffect.cpp index 4cd1ec3c2..00cf89f04 100644 --- a/Source/Contents/Effects/Skills/PowderingEffect.cpp +++ b/Source/Contents/Effects/Skills/PowderingEffect.cpp @@ -171,14 +171,14 @@ void CPowderingEffect::InitSmokeParticle(CParticle* particle) { // OFFSET: 0x007097B0 // FUNCTION: fn_07093 bool CPowderingEffect::IsAlive() { - for (CParticle* particle : this->smokeParticles) { - if (particle->animationState != 2) { + for (auto it = this->smokeParticles.begin(); it != this->smokeParticles.end(); ++it) { + if ((*it)->animationState != 2) { return true; } } - for (CParticle* particle : this->spriteParticles) { - if (particle->animationState != 2) { + for (auto it = this->spriteParticles.begin(); it != this->spriteParticles.end(); ++it) { + if ((*it)->animationState != 2) { return true; } } diff --git a/Source/Contents/Guild/GuildInfo.cpp b/Source/Contents/Guild/GuildInfo.cpp index d23cd65de..b65117554 100644 --- a/Source/Contents/Guild/GuildInfo.cpp +++ b/Source/Contents/Guild/GuildInfo.cpp @@ -53,7 +53,12 @@ void GuildInfo::ClearMembers() { // OFFSET: 0x00AE4270 // FUNCTION: fn_18033 void GuildInfo::RemoveAgitId(int value) { - auto it = std::find(this->agitIds.begin(), this->agitIds.end(), value); + auto it = this->agitIds.begin(); + for (; it != this->agitIds.end(); ++it) { + if (value == *it) { + break; + } + } if (it != this->agitIds.end()) { this->agitIds.erase(it); } diff --git a/Source/Contents/Items/NeoPackageItemMgr.cpp b/Source/Contents/Items/NeoPackageItemMgr.cpp index 1e33e92e9..f499bcaf7 100644 --- a/Source/Contents/Items/NeoPackageItemMgr.cpp +++ b/Source/Contents/Items/NeoPackageItemMgr.cpp @@ -223,15 +223,17 @@ void CPaidPackageItemMgr::AddItem(int itemId) { bool CPaidPackageItemMgr::LoadScript() { CLuaInstance script; script.SetGlobal("C_AddItemSold", CPaidPackageItemMgr::LuaAddItemSold); - if (script.LoadFile("LuaFiles514\\Lua Files\\ProbabilityInfo\\SimpleCashShopScript.lub") == true) { - lua_State* state = script.GetState(); - if (state) { - lua_getfield(state, LUA_GLOBALSINDEX, "LoadItemSoldTbl"); - if (lua_pcall(state, 0, 0, 0) != 0) { - MessageBoxA(nullptr, lua_tolstring(state, -1, nullptr), "CPaidItemMgr", 0); - } else { - return true; - } + if (script.LoadFile("LuaFiles514\\Lua Files\\ProbabilityInfo\\SimpleCashShopScript.lub") == false) { + return false; + } + + lua_State* state = script.GetState(); + if (state) { + lua_getfield(state, LUA_GLOBALSINDEX, "LoadItemSoldTbl"); + if (lua_pcall(state, 0, 0, 0) != 0) { + MessageBoxA(nullptr, lua_tolstring(state, -1, nullptr), "CPaidItemMgr", 0); + } else { + return true; } } diff --git a/Source/Contents/Items/SelectPackageItemMgr.cpp b/Source/Contents/Items/SelectPackageItemMgr.cpp index d7dfb84bc..c4ef9689f 100644 --- a/Source/Contents/Items/SelectPackageItemMgr.cpp +++ b/Source/Contents/Items/SelectPackageItemMgr.cpp @@ -56,15 +56,17 @@ bool CSelectPackageItemMgr::LoadScript() { CLuaInstance script; script.SetGlobal("AddTab", CSelectPackageItemMgr::LuaAddTab); script.SetGlobal("AddItem", CSelectPackageItemMgr::LuaAddItem); - if (script.LoadFile("LuaFiles514\\Lua Files\\SelectPackage\\SelectPackageItem_Cln.lub") == true) { - lua_State* state = script.GetState(); - if (state) { - lua_getfield(state, LUA_GLOBALSINDEX, "LoadTable"); - if (lua_pcall(state, 0, 0, 0) != 0) { - MessageBoxA(nullptr, lua_tolstring(state, -1, nullptr), "CSelectPackageItemMgr", 0); - } else { - lua_settop(state, -2); - } + if (script.LoadFile("LuaFiles514\\Lua Files\\SelectPackage\\SelectPackageItem_Cln.lub") == false) { + return false; + } + + lua_State* state = script.GetState(); + if (state) { + lua_getfield(state, LUA_GLOBALSINDEX, "LoadTable"); + if (lua_pcall(state, 0, 0, 0) != 0) { + MessageBoxA(nullptr, lua_tolstring(state, -1, nullptr), "CSelectPackageItemMgr", 0); + } else { + lua_settop(state, -2); } } diff --git a/Source/Contents/Tables/SimpleStringMgr.cpp b/Source/Contents/Tables/SimpleStringMgr.cpp index 307f06138..df3f49c46 100644 --- a/Source/Contents/Tables/SimpleStringMgr.cpp +++ b/Source/Contents/Tables/SimpleStringMgr.cpp @@ -112,7 +112,7 @@ void CSimpleStringMgr::AddString(STR_TYPE type, const char* key, const char* val } auto table = this->m_tables.find(type); - if (table == this->m_tables.end()) { + if (this->m_tables.end() == table) { std::unordered_map entries; entries.emplace(key, value); this->m_tables.emplace(type, std::move(entries));