rodecomp/Source/Client/Mode/GameMode.cpp
ragnarok-clanker dc75d034da Decompile 4 functions in Source/Client/Mode/GameMode.cpp, Source/Client/Mode/CGameMode.h
Batch #4433 by Snow: 0 byte-identical, 4 confirmed by peer review.

- fn_21420 CGameMode::IsActiveSkillEffectId: logic confirmed by peer review
- fn_21414 CGameMode::GetActiveSkillEffectTimeText: logic confirmed by peer review
- fn_21582 CGameMode::IsExcludedSkillEffectId: logic confirmed by peer review
- fn_21583 CGameMode::SubD07740: logic confirmed by peer review

Peer-reviewed-by: eAthena, willerthal
Reviewed-by: ragnarok-clanker
2026-10-30 03:15:09 +00:00

166 lines
3.9 KiB
C++

#include "Client/Mode/CGameMode.h"
#include "Client/Replay.h"
#include "Client/Session.h"
#include "Contents/MessageTable.h"
#include "Contents/Skills/ClientSkills.h"
#include "UI/Window/UIWindowMgr.h"
#include "Utility/Text/FormatString.h"
#include <cstdint>
#include <string>
#include <vector>
#include <timeapi.h>
// GLOBAL: gl_24661
std::vector<ActiveSkillEffect> g_activeSkillEffects;
// OFFSET: 0x00CCF480
// FUNCTION: fn_21242
void CGameMode::PushUnknown01A4(int value) {
this->unknown_01A4.push_back(value);
}
// OFFSET: 0x00CCF530
// FUNCTION: fn_21243
bool CGameMode::IsOverWeight(bool notify) {
int maxWeight = g_session.m_maxWeight;
if (maxWeight < 1) {
maxWeight = 1;
}
if (g_session.m_weight * 100 / maxWeight < 90) {
return false;
}
if (notify) {
g_windowMgr.SendNotice(3, 0, 0, 0, 0, 0);
g_windowMgr.SendNotice(1, reinterpret_cast<std::intptr_t>(LookupMessage(307)), 255, 0, 0, 0);
}
return true;
}
// OFFSET: 0x00CCFCF0
// FUNCTION: fn_21247
void CGameMode::CompleteUnknown0194(std::uint32_t id, const std::string& text) {
auto it = this->unknown_0194.find(id);
if (it != this->unknown_0194.end()) {
this->SendMsg(140, reinterpret_cast<int>(text.c_str()), it->second, 0, 0);
this->unknown_0194.erase(it);
}
}
// OFFSET: 0x00CED190
// FUNCTION: fn_21363
void CGameMode::UpdateUnknown0628(int id, bool add) {
if (add == true) {
this->unknown_0628.insert(id);
} else {
this->unknown_0628.erase(id);
}
}
// OFFSET: 0x00CF0380
// FUNCTION: fn_21414
std::string CGameMode::GetActiveSkillEffectTimeText(int skillId, int* activeSkillId) {
std::string output;
*activeSkillId = skillId;
for (const ActiveSkillEffect& effect : g_activeSkillEffects) {
const int effectId = static_cast<int>(effect.id);
if (skillId != (effectId == 0x2A ? 0x0C : effectId)) {
continue;
}
*activeSkillId = effectId;
const std::uint32_t expiration = effect.unknown_0004;
if (expiration == 999999 || expiration == 0) {
return output;
}
std::uint32_t remainingSeconds = 0;
if (g_replayAnimationScaling == 0) {
remainingSeconds = (expiration - timeGetTime()) / 1000;
} else {
const int remainingMilliseconds = static_cast<int>(expiration) - static_cast<int>(Replay::Instance().elapsed);
if (remainingMilliseconds >= 1000) {
remainingSeconds = static_cast<std::uint32_t>(remainingMilliseconds) / 1000;
}
}
const int signedSeconds = static_cast<int>(remainingSeconds);
const int hours = signedSeconds / 3600;
if (hours != 0) {
output.append(FormatOwnedString("%d %s", hours, LookupMessage(0x6A1)));
}
const int remainder = signedSeconds - hours * 3600;
const int minutes = remainder / 60;
const int seconds = remainder % 60;
if (minutes != 0) {
output.append(FormatOwnedString(" %d %s", minutes, LookupMessage(0x70F)));
}
if (seconds != 0) {
output.append(FormatOwnedString(" %d %s", seconds, LookupMessage(0x710)));
}
break;
}
return output;
}
// OFFSET: 0x00CF0A80
// FUNCTION: fn_21420
bool CGameMode::IsActiveSkillEffectId(std::uint32_t id) {
if (this->IsExcludedSkillEffectId(id)) {
return false;
}
for (const ActiveSkillEffect& effect : g_activeSkillEffects) {
if (effect.id == id) {
return true;
}
}
return false;
}
// OFFSET: 0x00D07720
// FUNCTION: fn_21582
bool CGameMode::IsExcludedSkillEffectId(std::uint32_t id) {
return id == 0x28 || id == 0x2A;
}
// OFFSET: 0x00D07740
// FUNCTION: fn_21583
int CGameMode::SubD07740(int id, int defaultResult) {
if (id < 0xFB5) {
if (id == 0xFB4 || id == 0x13) {
return 1;
}
if (id == 0x14) {
return 0;
}
} else {
switch (id) {
case 0xFB5:
case 0xFCB:
case 0xFE5:
case 0xFEC:
case 0x1009:
case 0x10A8:
return 0;
case 0xFCA:
case 0xFE4:
case 0xFEB:
case 0x1008:
case 0x10A7:
return 1;
}
}
return defaultResult;
}