rodecomp/Source/Contents/Skills/SkillLevelRegistry.cpp
ragnarok-clanker a47d20f8be Reconstruct readable C++ and organize cohesive source subsystems
Administrative source import: native x86 compilation passed for 423 authored units. Source placement and submission states are migrated separately; this commit does not imply peer acceptance.

Previous head: 35d2a8cb36
Payload SHA256: 592f016d2730c5593bb653aa054c1e5f76a6df72c8f5a09e66f74876e2e33dee
2026-10-25 07:42:41 +00:00

57 lines
1.4 KiB
C++

#include "Contents/Skills/SkillInfo.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 SkillLevelRegistry::Load() {
char key[512];
std::strcpy(key, this->baseKey);
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 = this->character;
const char* skill = CSkillInfo::IdName(this->script, id);
std::sprintf(name, "%s%d", skill, character);
if (RegQueryValueExA(handle, name, nullptr, &type, reinterpret_cast<BYTE*>(&value), &size) != ERROR_SUCCESS || !CSkillInfo::UsesLevel(this->script, id)) {
return 0;
}
return value;
};
for (int id = 1; id < 7999; ++id) {
this->useLevels[id] = read(id);
}
for (int id = 8000; id < 8061; ++id) {
this->homunculusLevels[id - 8000] = read(id);
}
for (int id = 8200; id < 8458; ++id) {
this->otherLevels[id - 8200] = read(id);
}
RegCloseKey(handle);
}