Decompile 2 functions in Source/Contents/ActorNameCache.cpp, Source/Contents/ActorNameCard.h
Batch #1693 by eAthena: 0 byte-identical, 2 confirmed by peer review. - fn_03499 CActorNameCardHolder::Save: logic confirmed by peer review - fn_03506 CActorNameCardHolder::Load: logic confirmed by peer review Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). Adds to the build: Source/Contents/ActorNameCache.cpp
This commit is contained in:
parent
e803253b29
commit
9ad1ef7f75
3 changed files with 111 additions and 0 deletions
107
Source/Contents/ActorNameCache.cpp
Normal file
107
Source/Contents/ActorNameCache.cpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#include "Contents/ActorNameCard.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
// OFFSET: 0x005BFA60
|
||||
// FUNCTION: fn_03499
|
||||
std::size_t CActorNameCardHolder::Save(std::vector<char>& output) {
|
||||
if (this->cards.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<char> buffer(0x400);
|
||||
std::size_t offset = 4;
|
||||
*reinterpret_cast<std::size_t*>(&buffer[0]) = this->cards.size();
|
||||
|
||||
for (const auto& entry : this->cards) {
|
||||
const CActorNameCard& card = entry.second;
|
||||
const std::size_t needed = offset + card.name.size() + card.unknown_001C.size() + card.unknown_0034.size() + card.unknown_004C.size() + 0x14;
|
||||
if (buffer.size() < needed) {
|
||||
buffer.resize(needed + 1);
|
||||
}
|
||||
|
||||
*reinterpret_cast<std::uint32_t*>(&buffer[offset]) = entry.first;
|
||||
|
||||
int length = static_cast<int>(card.name.size());
|
||||
*reinterpret_cast<int*>(&buffer[offset + 4]) = length;
|
||||
offset += 8;
|
||||
if (length > 0) {
|
||||
std::memcpy(&buffer[offset], card.name.c_str(), length);
|
||||
offset += length;
|
||||
}
|
||||
|
||||
length = static_cast<int>(card.unknown_001C.size());
|
||||
*reinterpret_cast<int*>(&buffer[offset]) = length;
|
||||
offset += 4;
|
||||
if (length > 0) {
|
||||
std::memcpy(&buffer[offset], card.unknown_001C.c_str(), length);
|
||||
offset += length;
|
||||
}
|
||||
|
||||
length = static_cast<int>(card.unknown_0034.size());
|
||||
*reinterpret_cast<int*>(&buffer[offset]) = length;
|
||||
offset += 4;
|
||||
if (length > 0) {
|
||||
std::memcpy(&buffer[offset], card.unknown_0034.c_str(), length);
|
||||
offset += length;
|
||||
}
|
||||
|
||||
length = static_cast<int>(card.unknown_004C.size());
|
||||
*reinterpret_cast<int*>(&buffer[offset]) = length;
|
||||
offset += 4;
|
||||
if (length > 0) {
|
||||
std::memcpy(&buffer[offset], card.unknown_004C.c_str(), length);
|
||||
offset += length;
|
||||
}
|
||||
}
|
||||
|
||||
output.assign(buffer.begin(), buffer.begin() + offset);
|
||||
return this->cards.size();
|
||||
}
|
||||
|
||||
// OFFSET: 0x005C05B0
|
||||
// FUNCTION: fn_03506
|
||||
std::size_t CActorNameCardHolder::Load(const std::vector<char>& input) {
|
||||
if (input.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this->cards.clear();
|
||||
const int count = *reinterpret_cast<const int*>(input.data());
|
||||
std::string text;
|
||||
std::size_t offset = 4;
|
||||
for (int index = 0; index < count; ++index) {
|
||||
const std::uint32_t id = *reinterpret_cast<const std::uint32_t*>(&input[offset]);
|
||||
this->cards[id].Reset();
|
||||
|
||||
int length = *reinterpret_cast<const int*>(&input[offset + 4]);
|
||||
offset += 8;
|
||||
if (length > 0) {
|
||||
this->cards[id].name.assign(&input[offset], length);
|
||||
offset += length;
|
||||
}
|
||||
|
||||
length = *reinterpret_cast<const int*>(&input[offset]);
|
||||
offset += 4;
|
||||
if (length > 0) {
|
||||
this->cards[id].unknown_001C.assign(&input[offset], length);
|
||||
offset += length;
|
||||
}
|
||||
|
||||
length = *reinterpret_cast<const int*>(&input[offset]);
|
||||
offset += 4;
|
||||
if (length > 0) {
|
||||
this->cards[id].unknown_0034.assign(&input[offset], length);
|
||||
offset += length;
|
||||
}
|
||||
|
||||
length = *reinterpret_cast<const int*>(&input[offset]);
|
||||
offset += 4;
|
||||
if (length > 0) {
|
||||
this->cards[id].unknown_004C.assign(&input[offset], length);
|
||||
offset += length;
|
||||
}
|
||||
}
|
||||
|
||||
return this->cards.size();
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
#include <deque>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CActorNameCard {
|
||||
public:
|
||||
|
|
@ -54,6 +55,8 @@ public:
|
|||
std::string Name(std::uint32_t id);
|
||||
void SetName(std::uint32_t id, std::string name);
|
||||
const CActorNameCard& Lookup(std::uint32_t id);
|
||||
std::size_t Save(std::vector<char>& output);
|
||||
std::size_t Load(const std::vector<char>& input);
|
||||
void Set(std::uint32_t id, std::string name, std::string value1, std::string value2, std::string value3, std::string value4, std::string value5,
|
||||
std::uint32_t value);
|
||||
std::uint32_t FindId(std::string name);
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@
|
|||
"Source/Client/Session.cpp": 0,
|
||||
"Source/Contents/ActorGeometry.cpp": 4,
|
||||
"Source/Contents/ActorMovementRoute.cpp": 4,
|
||||
"Source/Contents/ActorNameCache.cpp": 4,
|
||||
"Source/Contents/ActorNameCard.cpp": 4,
|
||||
"Source/Contents/ActorNameDirectory.cpp": 4,
|
||||
"Source/Contents/ActorNameRequests.cpp": 4,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue