Batch #16269 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_17177 LoadSkillUseLevelRegistry: logic confirmed by peer review Peer-reviewed-by: youko, Toshiro Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
64 lines
1.6 KiB
C++
64 lines
1.6 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>
|
|
|
|
// GLOBAL: gl_25596
|
|
const char* g_skillUseLevelInfoKeySuffix = "\\SkillUseLevelInfo";
|
|
|
|
// OFFSET: 0x00A92370
|
|
// FUNCTION: fn_17177
|
|
void LoadSkillUseLevelRegistry() {
|
|
char key[512];
|
|
std::strcpy(key, g_subKey);
|
|
std::strcat(key, g_skillUseLevelInfoKeySuffix);
|
|
HKEY probe;
|
|
|
|
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &probe) != ERROR_SUCCESS) {
|
|
return;
|
|
}
|
|
|
|
RegCloseKey(probe);
|
|
|
|
HKEY 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.selectedCharacterSlot;
|
|
const char* skill = CSkillInfo::IdName(*g_session.m_hotkeyScript, id);
|
|
std::sprintf(name, "%s%d", skill, character);
|
|
|
|
if (RegQueryValueExA(handle, name, nullptr, &type, reinterpret_cast<BYTE*>(&value), &size) != ERROR_SUCCESS || !CSkillInfo::UsesLevel(*g_session.m_hotkeyScript, 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);
|
|
}
|