rodecomp/Source/Network/Packets/SkillUpdatePacket.cpp
ragnarok-clanker c932ad6499 Maintenance: Resubmission of 15134 without the 12 struct/type renames (their new names changed mangled symbols in 17 functions). Rena
Batch #15141 by ragnarok-clanker: no function's compiled code changes; checked with 537 compiled unit(s), including every includer of Source/Client/Input/LanguageTC.h, Source/Client/Mode/CGameMode.h, Source/Client/Mode/CLoginMode.h, Source/Client/Replay.h, Source/Client/Session.h, Source/Contents/AchievementMgr.h, Source/Contents/Actors/CharacterRender.h, Source/Contents/Actors/EffectActors.h, Source/Contents/Actors/GameActor.h, Source/Contents/Actors/Pc.h, Source/Contents/EnchantMgr.h, Source/Contents/GuildInfo.h, Source/Contents/Messenger/MessengerWindows.h, Source/Contents/Schedule/TimeScheduler.h, Source/Contents/Sound/SoundMgr.h, Source/Contents/SpriteLayerDrawing.h, Source/Contents/TableMng.h, Source/Contents/World/SkyBox.h, Source/UI/Chat/UINewChatWnd.h, Source/UI/Text/CreateLineInfo.h, Source/UI/UIGradeEnchantWnd.h, Source/UI/Window/UINewSelectCharWnd.h, Source/UI/Window/UINewSkillListWnd.h, Source/UI/Window/UIPetInfoWnd.h, Source/UI/Window/UIReplayRECControlWnd.h, Source/UI/Window/UIWindowMgr.h, Source/UI/Window/UIWindowMgr.inl.
2026-11-09 12:21:09 +00:00

122 lines
3.7 KiB
C++

#include "Client/Mode/CGameMode.h"
#include "UI/Window/UIEnums.h"
#include "Network/Packets/PacketId.h"
#include "Client/Session.h"
#include "UI/Window/UIWindow.h"
#include "UI/Window/UIWindowMgr.h"
#include <cstring>
namespace {
// INLINED
template <class T> T Read(const unsigned char* bytes) {
T value;
std::memcpy(&value, bytes, sizeof(value));
return value;
}
}
// OFFSET: 0x00D42AA0
// FUNCTION: fn_21829
void CGameMode::ApplySkillUpdatePacket(const void* packet) {
*reinterpret_cast<int*>(&this->equipmentRequestState[0x0C]) = 0;
const auto* bytes = static_cast<const unsigned char*>(packet);
const auto opcode = Read<std::uint16_t>(bytes);
const auto id = Read<std::uint16_t>(bytes + 2);
CSkillInfo value;
switch (opcode) {
case ID_ZC_SKILLINFO_UPDATE:
value = g_session.m_skillBundle.Lookup(id);
break;
case ID_ZC_HOSKILLINFO_UPDATE:
value = g_session.LookupHomunSkill(id);
break;
case 670:
value = g_session.LookupMercSkill(id);
break;
}
value.id = id;
value.level = Read<std::int16_t>(bytes + 4);
value.spCost = static_cast<std::int32_t>(Read<std::int16_t>(bytes + 6));
value.upgradable = bytes[10];
value.range = static_cast<std::int32_t>(Read<std::int16_t>(bytes + 8));
value.apCost = value.UseApAmount(*g_session.m_hotkeyScript, value.level);
g_session.m_skillBundle.ApplyLevelChange(value);
switch (opcode) {
case ID_ZC_SKILLINFO_UPDATE:
g_session.UpdateSkill(value, 1, 0);
break;
case ID_ZC_HOSKILLINFO_UPDATE:
g_session.UpdateHomunSkill(value, 1);
break;
case 670:
g_session.UpdateMercSkill(value, 1);
break;
}
}
// OFFSET: 0x00D06AF0
// FUNCTION: fn_21577
void CGameMode::ReceiveLearnedSkill(
std::uint16_t id, std::int16_t level, int type, std::uint8_t upgradable, std::int16_t spCost, std::int16_t range, std::int16_t unknown0030
) {
CSkillInfo value;
value.type = type;
value.id = id;
value.level = level;
value.upgradable = upgradable;
value.name = value.IdName(*g_session.m_hotkeyScript);
value.spCost = spCost;
value.range = range;
value.learnedLevel = unknown0030;
value.apCost = value.UseApAmount(*g_session.m_hotkeyScript, level);
g_session.m_skillBundle.RecordLevelChange(value);
if (value.id == 336) {
g_session.adoptionSkillAvailable = 1;
}
g_session.UpdateSkill(value, 1, 0);
}
// OFFSET: 0x00D2B5C0
// FUNCTION: fn_45442
void CGameMode::ApplyAdditionalSkillPacket(const void* packet) {
*reinterpret_cast<int*>(&this->equipmentRequestState[0x0C]) = 0;
g_session.m_additionalSkills.clear();
const auto* bytes = static_cast<const unsigned char*>(packet);
const auto length = static_cast<std::uint32_t>(static_cast<int>(Read<std::int16_t>(bytes + 2)) - 6);
const std::uint32_t count = length / 37;
const unsigned char* record = bytes + 6;
for (std::uint32_t index = 0; index < count; ++index, record += 37) {
CSkillInfo value;
value.level = Read<std::int16_t>(record + 6);
value.id = Read<std::uint16_t>(record);
value.spCost = static_cast<std::int32_t>(Read<std::int16_t>(record + 8));
value.type = Read<std::uint32_t>(record + 2);
value.upgradable = record[36];
value.name = value.IdName(*g_session.m_hotkeyScript);
value.apCost = value.UseApAmount(*g_session.m_hotkeyScript, value.level);
if (value.id - 10000u <= 19u) {
g_session.UpdateAdditionalSkill(value, 1);
}
}
g_session.m_guildSkillPoint = Read<std::int16_t>(bytes + 4);
g_session.InvalidateWindowFrames();
if (g_windowMgr.guildSkillWnd) {
g_windowMgr.guildSkillWnd->SendMsg(nullptr, UM_REFRESHITEM, 0, 0, 0, 0);
}
if (g_windowMgr.shortCutWnd) {
g_windowMgr.shortCutWnd->SendMsg(nullptr, UM_REFRESHITEM, 0, 0, 0, 0);
}
}