From 0a907f41d20678817bf54ac3c8ce3643b309723a Mon Sep 17 00:00:00 2001 From: Tr0n Date: Sun, 7 Apr 2024 22:11:12 +0200 Subject: [PATCH] remove unnecessary leftover closures --- src/game/src/OXEvent.cpp | 4 +- src/game/src/battle.cpp | 17 +++---- src/game/src/char.cpp | 14 ++---- src/game/src/char_skill.cpp | 98 ++++++++++++++++++------------------ src/game/src/cmd_general.cpp | 38 +++++++------- src/game/src/db.cpp | 32 ++++++------ src/game/src/item.cpp | 6 +-- src/game/src/p2p.cpp | 6 +-- 8 files changed, 95 insertions(+), 120 deletions(-) diff --git a/src/game/src/OXEvent.cpp b/src/game/src/OXEvent.cpp index 0015b31..2156afb 100644 --- a/src/game/src/OXEvent.cpp +++ b/src/game/src/OXEvent.cpp @@ -215,9 +215,7 @@ EVENTFUNC(oxevent_timer) SendNoticeMap(LC_TEXT("No (X)"), OXEVENT_MAP_INDEX, true); } - { - SendNoticeMap(LC_TEXT("In 5 sec. everyone who gave an incorrect answer will be removed."), OXEVENT_MAP_INDEX, true); - } + SendNoticeMap(LC_TEXT("In 5 sec. everyone who gave an incorrect answer will be removed."), OXEVENT_MAP_INDEX, true); flag++; return PASSES_PER_SEC(5); diff --git a/src/game/src/battle.cpp b/src/game/src/battle.cpp index 1dd029c..b7ca89f 100644 --- a/src/game/src/battle.cpp +++ b/src/game/src/battle.cpp @@ -205,19 +205,14 @@ int CalcMagicDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim) float CalcAttackRating(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool bIgnoreTargetRating) { - int iARSrc; - int iERSrc; + int iARSrc = std::min(90, (attacker_dx * 4 + attacker_lv * 2) / 6); + int iERSrc = std::min(90, (victim_dx * 4 + victim_lv * 2) / 6); - { - int attacker_dx = pkAttacker->GetPolymorphPoint(POINT_DX); - int attacker_lv = pkAttacker->GetLevel(); + int attacker_dx = pkAttacker->GetPolymorphPoint(POINT_DX); + int attacker_lv = pkAttacker->GetLevel(); - int victim_dx = pkVictim->GetPolymorphPoint(POINT_DX); - int victim_lv = pkAttacker->GetLevel(); - - iARSrc = std::min(90, (attacker_dx * 4 + attacker_lv * 2) / 6); - iERSrc = std::min(90, (victim_dx * 4 + victim_lv * 2) / 6); - } + int victim_dx = pkVictim->GetPolymorphPoint(POINT_DX); + int victim_lv = pkAttacker->GetLevel(); float fAR = ((float) iARSrc + 210.0f) / 300.0f; // fAR = 0.7 ~ 1.0 diff --git a/src/game/src/char.cpp b/src/game/src/char.cpp index 161df91..8bab896 100644 --- a/src/game/src/char.cpp +++ b/src/game/src/char.cpp @@ -2112,10 +2112,8 @@ void CHARACTER::ComputeBattlePoints() iArmor += GetPoint(POINT_PARTY_DEFENDER_BONUS); // INTERNATIONAL_VERSION - { - PointChange(POINT_DEF_GRADE, iDef + iArmor); - PointChange(POINT_CLIENT_DEF_GRADE, (iShowDef + iArmor) - GetPoint(POINT_DEF_GRADE)); - } + PointChange(POINT_DEF_GRADE, iDef + iArmor); + PointChange(POINT_CLIENT_DEF_GRADE, (iShowDef + iArmor) - GetPoint(POINT_DEF_GRADE)); // END_OF_INTERNATIONAL_VERSION PointChange(POINT_MAGIC_ATT_GRADE, GetLevel() * 2 + GetPoint(POINT_IQ) * 2 + GetPoint(POINT_MAGIC_ATT_GRADE_BONUS)); @@ -5124,11 +5122,9 @@ bool CHARACTER::WarpSet(int x, int y, int lPrivateMapIndex) GetDesc()->Packet(&p, sizeof(TPacketGCWarp)); - { - char buf[256]; - snprintf(buf, sizeof(buf), "%s MapIdx %d DestMapIdx%d DestX%d DestY%d Empire%d", GetName(), GetMapIndex(), lPrivateMapIndex, x, y, GetEmpire()); - LogManager::instance().CharLog(this, 0, "WARP", buf); - } + char buf[256]; + snprintf(buf, sizeof(buf), "%s MapIdx %d DestMapIdx%d DestX%d DestY%d Empire%d", GetName(), GetMapIndex(), lPrivateMapIndex, x, y, GetEmpire()); + LogManager::instance().CharLog(this, 0, "WARP", buf); return true; } diff --git a/src/game/src/char_skill.cpp b/src/game/src/char_skill.cpp index b4d25f5..cf19082 100644 --- a/src/game/src/char_skill.cpp +++ b/src/game/src/char_skill.cpp @@ -473,70 +473,68 @@ bool CHARACTER::LearnSkillByBook(DWORD dwSkillVnum, BYTE bProb) SPDLOG_DEBUG("LearnSkillByBook {} table idx {} value {}", GetName(), idx, aiSkillBookCountForLevelUp[idx]); + int need_bookcount = GetSkillLevel(dwSkillVnum) - 20; + + PointChange(POINT_EXP, -need_exp); + + quest::CQuestManager& q = quest::CQuestManager::instance(); + quest::PC* pPC = q.GetPC(GetPlayerID()); + + if (pPC) { - int need_bookcount = GetSkillLevel(dwSkillVnum) - 20; + char flag[128+1]; + memset(flag, 0, sizeof(flag)); + snprintf(flag, sizeof(flag), "traning_master_skill.%u.read_count", dwSkillVnum); - PointChange(POINT_EXP, -need_exp); + int read_count = pPC->GetFlag(flag); + int percent = 65; - quest::CQuestManager& q = quest::CQuestManager::instance(); - quest::PC* pPC = q.GetPC(GetPlayerID()); - - if (pPC) + if (FindAffect(AFFECT_SKILL_BOOK_BONUS)) { - char flag[128+1]; - memset(flag, 0, sizeof(flag)); - snprintf(flag, sizeof(flag), "traning_master_skill.%u.read_count", dwSkillVnum); + percent = 0; + RemoveAffect(AFFECT_SKILL_BOOK_BONUS); + } - int read_count = pPC->GetFlag(flag); - int percent = 65; - - if (FindAffect(AFFECT_SKILL_BOOK_BONUS)) + if (Random::get(1, 100) > percent) + { + // 책읽기에 성공 + if (read_count >= need_bookcount) { - percent = 0; - RemoveAffect(AFFECT_SKILL_BOOK_BONUS); + SkillLevelUp(dwSkillVnum, SKILL_UP_BY_BOOK); + pPC->SetFlag(flag, 0); + + ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have successfully finished your training with the Book.")); + LogManager::instance().CharLog(this, dwSkillVnum, "READ_SUCCESS", ""); + return true; } - - if (Random::get(1, 100) > percent) + else { - // 책읽기에 성공 - if (read_count >= need_bookcount) + pPC->SetFlag(flag, read_count + 1); + + switch (Random::get(1, 3)) { - SkillLevelUp(dwSkillVnum, SKILL_UP_BY_BOOK); - pPC->SetFlag(flag, 0); + case 1: + ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("I'm making progress, but I still haven't understood everything.")); + break; + + case 2: + ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("These instructions are difficult to understand. I have to carry on studying.")); + break; - ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have successfully finished your training with the Book.")); - LogManager::instance().CharLog(this, dwSkillVnum, "READ_SUCCESS", ""); - return true; + case 3: + default: + ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("I understand this chapter. But I've got to carry on working hard.")); + break; } - else - { - pPC->SetFlag(flag, read_count + 1); - switch (Random::get(1, 3)) - { - case 1: - ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("I'm making progress, but I still haven't understood everything.")); - break; - - case 2: - ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("These instructions are difficult to understand. I have to carry on studying.")); - break; - - case 3: - default: - ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("I understand this chapter. But I've got to carry on working hard.")); - break; - } - - ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have to read %d more skill books to improve this skill."), need_bookcount - read_count); - return true; - } + ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have to read %d more skill books to improve this skill."), need_bookcount - read_count); + return true; } } - else - { - // 사용자의 퀘스트 정보 로드 실패 - } + } + else + { + // 사용자의 퀘스트 정보 로드 실패 } } diff --git a/src/game/src/cmd_general.cpp b/src/game/src/cmd_general.cpp index 67b0f64..68e7e64 100644 --- a/src/game/src/cmd_general.cpp +++ b/src/game/src/cmd_general.cpp @@ -271,22 +271,20 @@ EVENTFUNC(timed_event) { ch->m_pkTimedEvent = NULL; + switch (info->subcmd) { - switch (info->subcmd) - { - case SCMD_LOGOUT: - case SCMD_QUIT: - case SCMD_PHASE_SELECT: - { - TPacketNeedLoginLogInfo acc_info; - acc_info.dwPlayerID = ch->GetDesc()->GetAccountTable().id; + case SCMD_LOGOUT: + case SCMD_QUIT: + case SCMD_PHASE_SELECT: + { + TPacketNeedLoginLogInfo acc_info; + acc_info.dwPlayerID = ch->GetDesc()->GetAccountTable().id; - db_clientdesc->DBPacket( HEADER_GD_VALID_LOGOUT, 0, &acc_info, sizeof(acc_info) ); + db_clientdesc->DBPacket( HEADER_GD_VALID_LOGOUT, 0, &acc_info, sizeof(acc_info) ); - LogManager::instance().DetailLoginLog( false, ch ); - } - break; - } + LogManager::instance().DetailLoginLog( false, ch ); + } + break; } switch (info->subcmd) @@ -2233,17 +2231,15 @@ ACMD(do_cube) ACMD(do_in_game_mall) { - { - char country_code[3]; - country_code[0] = 'd'; country_code[1] = 'e'; country_code[2] = '\0'; + char country_code[3]; + country_code[0] = 'd'; country_code[1] = 'e'; country_code[2] = '\0'; - char buf[512+1]; + char buf[512+1]; - snprintf(buf, sizeof(buf), "mall http://%s/ishop?pid=%u&c=%s&sid=%d", - g_strWebMallURL.c_str(), ch->GetPlayerID(), country_code, g_server_id); + snprintf(buf, sizeof(buf), "mall http://%s/ishop?pid=%u&c=%s&sid=%d", + g_strWebMallURL.c_str(), ch->GetPlayerID(), country_code, g_server_id); - ch->ChatPacket(CHAT_TYPE_COMMAND, buf); - } + ch->ChatPacket(CHAT_TYPE_COMMAND, buf); } // 주사위 diff --git a/src/game/src/db.cpp b/src/game/src/db.cpp index df703d6..37bda7d 100644 --- a/src/game/src/db.cpp +++ b/src/game/src/db.cpp @@ -355,26 +355,24 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) char szCreateDate[256] = "00000000"; - { - str_to_number(aiPremiumTimes[PREMIUM_EXP], row[col++]); - str_to_number(aiPremiumTimes[PREMIUM_ITEM], row[col++]); - str_to_number(aiPremiumTimes[PREMIUM_SAFEBOX], row[col++]); - str_to_number(aiPremiumTimes[PREMIUM_AUTOLOOT], row[col++]); - str_to_number(aiPremiumTimes[PREMIUM_FISH_MIND], row[col++]); - str_to_number(aiPremiumTimes[PREMIUM_MARRIAGE_FAST], row[col++]); - str_to_number(aiPremiumTimes[PREMIUM_GOLD], row[col++]); + str_to_number(aiPremiumTimes[PREMIUM_EXP], row[col++]); + str_to_number(aiPremiumTimes[PREMIUM_ITEM], row[col++]); + str_to_number(aiPremiumTimes[PREMIUM_SAFEBOX], row[col++]); + str_to_number(aiPremiumTimes[PREMIUM_AUTOLOOT], row[col++]); + str_to_number(aiPremiumTimes[PREMIUM_FISH_MIND], row[col++]); + str_to_number(aiPremiumTimes[PREMIUM_MARRIAGE_FAST], row[col++]); + str_to_number(aiPremiumTimes[PREMIUM_GOLD], row[col++]); - int retValue = 0; - str_to_number(retValue, row[col]); + int retValue = 0; + str_to_number(retValue, row[col]); - time_t create_time = retValue; - struct tm * tm1; - tm1 = localtime(&create_time); - strftime(szCreateDate, 255, "%Y%m%d", tm1); + time_t create_time = retValue; + struct tm * tm1; + tm1 = localtime(&create_time); + strftime(szCreateDate, 255, "%Y%m%d", tm1); - SPDLOG_DEBUG("Create_Time {} {}", retValue, szCreateDate); - SPDLOG_DEBUG("Block Time {} ", strncmp(szCreateDate, g_stBlockDate.c_str(), 8)); - } + SPDLOG_DEBUG("Create_Time {} {}", retValue, szCreateDate); + SPDLOG_DEBUG("Block Time {} ", strncmp(szCreateDate, g_stBlockDate.c_str(), 8)); int nPasswordDiff = strcmp(szEncrytPassword, szPassword); diff --git a/src/game/src/item.cpp b/src/game/src/item.cpp index 8f3beb7..7fa631f 100644 --- a/src/game/src/item.cpp +++ b/src/game/src/item.cpp @@ -1085,10 +1085,8 @@ void CItem::SetOwnership(LPCHARACTER ch, int iSec) if (m_pkOwnershipEvent) return; - { - if (iSec <= 10) - iSec = 30; - } + if (iSec <= 10) + iSec = 30; m_dwOwnershipPID = ch->GetPlayerID(); diff --git a/src/game/src/p2p.cpp b/src/game/src/p2p.cpp index 339b616..48759b6 100644 --- a/src/game/src/p2p.cpp +++ b/src/game/src/p2p.cpp @@ -228,11 +228,7 @@ CCI * P2P_MANAGER::FindByPID(DWORD pid) CCI * P2P_MANAGER::Find(const char * c_pszName) { - TCCIMap::const_iterator it; - - { - it = m_map_pkCCI.find(c_pszName); - } + TCCIMap::const_iterator it = m_map_pkCCI.find(c_pszName); if (it == m_map_pkCCI.end()) return NULL;