Batch #14286 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_19599 CNavigationManager::LoadStates: logic confirmed by peer review Peer-reviewed-by: Yommy, secret, KWDev Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#include "Contents/NavigationManager.h"
|
|
|
|
#include <cstring>
|
|
|
|
// OFFSET: 0x00B974D0
|
|
// FUNCTION: fn_19599
|
|
bool CNavigationManager::LoadStates(std::vector<char> packet) {
|
|
if (packet.begin() == packet.end()) {
|
|
return false;
|
|
}
|
|
|
|
const int count = *reinterpret_cast<const int*>(packet.data());
|
|
std::size_t offset = sizeof(int);
|
|
char map[0x14] = {};
|
|
this->states.clear();
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
NavigationTarget target;
|
|
std::memcpy(&target.type, packet.data() + offset, sizeof(target.type));
|
|
offset += sizeof(target.type);
|
|
std::memset(map, 0, sizeof(map));
|
|
std::memcpy(map, packet.data() + offset, sizeof(map));
|
|
offset += sizeof(map);
|
|
std::memcpy(&target.x, packet.data() + offset, sizeof(target.x));
|
|
offset += sizeof(target.x);
|
|
std::memcpy(&target.y, packet.data() + offset, sizeof(target.y));
|
|
offset += sizeof(target.y);
|
|
int nameLength;
|
|
std::memcpy(&nameLength, packet.data() + offset, sizeof(nameLength));
|
|
offset += sizeof(nameLength);
|
|
|
|
if (nameLength > 0) {
|
|
target.name.resize(nameLength, '\0');
|
|
std::memcpy(&target.name[0], packet.data() + offset, nameLength);
|
|
offset += nameLength;
|
|
}
|
|
|
|
CNaviInfo* info = this->FindObject(map);
|
|
if (info != nullptr) {
|
|
target.object = info;
|
|
this->states.push_back(target);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|