rodecomp/Source/Contents/Skills/SkillLevelRegistry.cpp
ragnarok-clanker bd0ade90cd Maintenance: [forced, user-approved] Family G27 (resubmit of 10254 rebased on e235d90a; only conflict was the AsyncWorkMgr.h forward
Batch #10259 by ragnarok-clanker: forced by an admin (1 lower score(s), 11 changed function(s)); checked with 508 compiled unit(s), including every includer of Source/Contents/Async/AsyncWorkMgr.h, Source/Contents/Skills/SkillLevelRegistry.h, Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.h, Source/Contents/UserData/CharacterLinkedUserDataMgr.h, Source/UI/Window/UIWindowMgr.h, Source/UI/Window/UIWindowMgr.inl, Source/Contents/Skills/SkillLevelConfig.h, Source/Contents/UserData/CharacterConfigLoad.h, Source/UI/Shortcuts/NormalItemSlotLoad.h.
Deletes: Source/Contents/Skills/SkillLevelConfig.h, Source/Contents/UserData/CharacterConfigLoad.h, Source/UI/Shortcuts/NormalItemSlotLoad.h
2026-11-03 13:32:00 +00:00

59 lines
1.5 KiB
C++

#include "Contents/Skills/SkillInfo.h"
#include "Client/Registry.h"
#include "Client/Session.h"
#include "Contents/Skills/SkillLevelRegistry.h"
#include "Script/LuaScript.h"
#include <cstdio>
#include <cstring>
#include <string>
#include <windows.h>
// OFFSET: 0x00A92370
// FUNCTION: fn_17177
void LoadSkillUseLevelRegistry() {
char key[512];
std::strcpy(key, g_subKey);
std::strcat(key, "\\SkillUseLevelInfo");
HKEY handle;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &handle) != ERROR_SUCCESS) {
return;
}
RegCloseKey(handle);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &handle) != ERROR_SUCCESS) {
return;
}
const auto read = [&](int id) {
DWORD type = REG_DWORD;
DWORD size = sizeof(int);
int value;
char name[100] = {};
const int character = g_session.unknown_0F50;
const char* skill = CSkillInfo::IdName(*g_luaScript, id);
std::sprintf(name, "%s%d", skill, character);
if (RegQueryValueExA(handle, name, nullptr, &type, reinterpret_cast<BYTE*>(&value), &size) != ERROR_SUCCESS || !CSkillInfo::UsesLevel(*g_luaScript, id)) {
return 0;
}
return value;
};
for (int id = 1; id < 7999; ++id) {
g_session.m_skillBundle.SetUnknownValue(id, read(id));
}
for (int id = 8000; id < 8061; ++id) {
g_session.SetHomunSkillLevel(id, read(id));
}
for (int id = 8200; id < 8458; ++id) {
g_session.SetMercSkillLevel(id, read(id));
}
RegCloseKey(handle);
}