Restore translation-unit ownership and publish verified source corrections

Owner-authorized source migration: 31 helper-only translation units were merged into their callers or existing inline headers; both build manifests updated. Includes the preserved source payload, Lua configuration matching wowdecomp, and exact malloca expansion without diagnostic pragmas.

449 native units compiled locally and 449 staged units compiled by the pinned server toolchain. No previously byte-matched function regressed. Compiler mapping diagnostics remain recorded as needs_cleanup, not accepted or peer-confirmed. Existing independent review records are preserved. README.md is intentionally unchanged.
This commit is contained in:
ragnarok-clanker 2026-10-25 15:42:21 +00:00
commit e168b4e4a6
326 changed files with 9538 additions and 3481 deletions

View file

@ -7,10 +7,12 @@
#include <cstring>
// INLINED
AnimatedModelNode::AnimatedModelNode(TextureCache& textures)
: model(nullptr), parent(nullptr), unknown_0040(0), vertexCount(0), textureVertexCount(0), faceCount(0), sharedTextureVertices(0), m_textures(textures) {
}
// INLINED
AnimatedModelNode::~AnimatedModelNode() {
for (CTexture* texture : this->textures) {
texture->Release();
@ -19,14 +21,14 @@ AnimatedModelNode::~AnimatedModelNode() {
}
// OFFSET: 0x007521F0
// FUNCTION: fn_07956
// FUNCTION: fn_07979
C3dAnimModelRes::C3dAnimModelRes(ModelResourceContext& context)
: shade(2), frameCount(0), animationLength(0), speed(1.0f), unknown_0150(0), unknown_0154(0.0f), unknown_0158(0.0f), unknown_015C(0.0f), alpha(255),
m_context(&context) {
}
// OFFSET: 0x00753510
// FUNCTION: fn_07960
// FUNCTION: fn_07993
C3dAnimModelRes::~C3dAnimModelRes() {
this->Unload();
}
@ -38,7 +40,6 @@ C3dAnimModelRes* C3dAnimModelRes::Create() {
}
// OFFSET: 0x00752380
// FUNCTION: fn_07957
// OFFSET: 0x0075C710
// FUNCTION: fn_08023
void C3dAnimModelRes::Unload() {

View file

@ -4,6 +4,7 @@
#include <map>
namespace {
// INLINED
void Normalize(float* vector) {
const float squared = (vector[0] * vector[0] + vector[1] * vector[1]) + vector[2] * vector[2];
const float length = std::sqrt(squared);

View file

@ -1,103 +0,0 @@
#include "Render/Textures/Texture.h"
#include "Render/Textures/TextureCache.h"
#include "Resource/Models/ModelResource.h"
#include "Resource/ResourceByteReader.h"
#include <algorithm>
#include <cstring>
// OFFSET: 0x00750B10
// FUNCTION: fn_07950
void C3dModelResV1::ReadNode(ResourceByteReader& input, unsigned minor, const std::vector<std::string>& textureNames) {
auto node = std::make_unique<ModelNode>(this->m_context->textures);
node->model = this;
node->alpha = this->alpha;
char field[40]{};
input.Read(field, sizeof(field));
node->name = field;
input.Read(field, sizeof(field));
node->parentName = field;
int textureCount = 0;
input.Read(&textureCount, 4);
for (int index = 0; index < textureCount; ++index) {
int textureIndex = 0;
input.Read(&textureIndex, 4);
CTexture* texture = this->m_context->textures.Load(textureNames[textureIndex].c_str(), 0, false, true, false);
node->textures.push_back(texture);
if (texture) {
texture->Retain();
}
}
float matrix[12];
input.Read(matrix, sizeof(matrix));
input.Read(node->position, sizeof(node->position));
input.Read(&node->angle, 4);
input.Read(node->axis, sizeof(node->axis));
input.Read(node->scale, sizeof(node->scale));
node->mesh = std::make_unique<ModelMesh>();
ModelMesh& mesh = *node->mesh;
int vertexCount = 0;
input.Read(&vertexCount, 4);
mesh.vertices.resize(static_cast<unsigned>(vertexCount));
input.Read(mesh.vertices.data(), static_cast<unsigned>(vertexCount) * 12u);
for (auto& vertex : mesh.vertices) {
const float y = ((vertex[0] * matrix[1] + vertex[1] * matrix[4]) + matrix[7] * vertex[2]) + matrix[10];
const float z = ((vertex[0] * matrix[2] + vertex[1] * matrix[5]) + matrix[8] * vertex[2]) + matrix[11];
vertex[0] = ((vertex[0] * matrix[0] + vertex[1] * matrix[3]) + vertex[2] * matrix[6]) + matrix[9];
vertex[1] = y;
vertex[2] = z;
}
int textureVertexCount = 0;
input.Read(&textureVertexCount, 4);
mesh.textureVertices.resize(static_cast<unsigned>(textureVertexCount));
if (minor == 1) {
float uv[2];
for (auto& vertex : mesh.textureVertices) {
input.Read(uv, sizeof(uv));
vertex = {0xFFFFFFFFu, uv[0], uv[1]};
}
} else {
input.Read(mesh.textureVertices.data(), static_cast<unsigned>(textureVertexCount) * 12u);
}
std::uint32_t faceCount = 0;
input.Read(&faceCount, 4);
mesh.faces.resize(faceCount);
unsigned char record[24];
for (ModelFace& face : mesh.faces) {
input.Read(record, minor == 1 ? 20 : 24);
std::memcpy(face.vertices, record, sizeof(face.vertices));
std::memcpy(face.textureVertices, record + 6, sizeof(face.textureVertices));
std::memcpy(&face.texture, record + 12, sizeof(face.texture));
std::memcpy(&face.twoSided, record + 16, sizeof(face.twoSided));
std::uint32_t group = 0;
if (minor != 1) {
std::memcpy(&group, record + 20, sizeof(group));
}
face.smoothing.push_back(group);
}
std::sort(mesh.faces.begin(), mesh.faces.end(), [](const ModelFace& a, const ModelFace& b) { return a.texture < b.texture; });
mesh.CalculateNormals();
int rotationCount;
input.Read(&rotationCount, 4);
for (int index = 0; index < rotationCount; ++index) {
ModelRotationKey key;
input.Read(&key, sizeof(key));
node->rotationKeys.push_back(key);
}
this->meshes[node->name] = node->mesh.get();
this->nodes.push_back(node.release());
}

View file

@ -1,141 +0,0 @@
#include "Render/Textures/Texture.h"
#include "Render/Textures/TextureCache.h"
#include "Resource/Models/ModelResource.h"
#include "Resource/ResourceByteReader.h"
#include <algorithm>
#include <cstring>
namespace {
std::string ReadName(ResourceByteReader& input) {
unsigned bytes = 0;
input.Read(&bytes, 4);
char name[40]{};
input.Read(name, bytes);
return name;
}
void ReadKeys(ResourceByteReader& input, std::vector<ModelRotationKey>& keys, bool scale) {
int count = 0;
input.Read(&count, 4);
for (int index = 0; index < count; ++index) {
ModelRotationKey key;
if (scale) {
key = {0, {0, 0, 0, 1}};
}
input.Read(&key, sizeof(key));
keys.push_back(key);
}
}
}
void C3dModelResV2::ReadNode(ResourceByteReader& input, unsigned minor, const std::vector<std::string>& textureNames) {
auto node = std::make_unique<ModelNode>(this->m_context->textures);
node->model = this;
node->mesh = std::make_unique<ModelMesh>();
node->name = ReadName(input);
node->parentName = ReadName(input);
int textureCount = 0;
input.Read(&textureCount, 4);
for (int index = 0; index < textureCount; ++index) {
std::string name;
if (minor < 3) {
int texture = 0;
input.Read(&texture, 4);
name = textureNames[texture];
} else {
name = ReadName(input);
}
CTexture* texture = this->m_context->textures.Load(name.c_str(), 0, false, true, false);
node->textures.push_back(texture);
if (texture) {
texture->Retain();
}
}
input.Read(node->transform, sizeof(node->transform));
ModelMesh& mesh = *node->mesh;
unsigned vertexCount = 0;
input.Read(&vertexCount, 4);
mesh.vertices.resize(vertexCount);
input.Read(mesh.vertices.data(), vertexCount * 12u);
unsigned textureVertexCount = 0;
input.Read(&textureVertexCount, 4);
mesh.textureVertices.resize(textureVertexCount);
input.Read(mesh.textureVertices.data(), textureVertexCount * 12u);
int faceCount = 0;
input.Read(&faceCount, 4);
mesh.faces.resize(static_cast<unsigned>(faceCount));
for (ModelFace& face : mesh.faces) {
std::vector<unsigned char> bytes;
unsigned char fixed[24];
const unsigned char* record;
unsigned size;
if (minor == 1) {
input.Read(fixed, sizeof(fixed));
record = fixed;
size = sizeof(fixed);
} else {
size = 0;
input.Read(&size, 4);
bytes.resize(size);
input.Read(bytes.data(), size);
record = bytes.data();
}
std::memcpy(face.vertices, record, sizeof(face.vertices));
std::memcpy(face.textureVertices, record + 6, sizeof(face.textureVertices));
std::memcpy(&face.texture, record + 12, sizeof(face.texture));
std::memcpy(&face.twoSided, record + 16, sizeof(face.twoSided));
const unsigned groups = (size - 20u) / 4u;
face.smoothing.resize(groups);
std::memcpy(face.smoothing.data(), record + 20, groups * 4u);
}
std::sort(mesh.faces.begin(), mesh.faces.end(), [](const ModelFace& a, const ModelFace& b) { return a.texture < b.texture; });
mesh.CalculateNormals();
ReadKeys(input, node->scaleKeys, false);
ReadKeys(input, node->rotationKeys, true);
ReadKeys(input, node->positionKeys, false);
if (minor == 3) {
int textureAnimations = 0;
input.Read(&textureAnimations, 4);
for (int index = 0; index < textureAnimations; ++index) {
int texture = 0;
input.Read(&texture, 4);
ModelTextureChannels channels;
int channelCount = 0;
input.Read(&channelCount, 4);
for (int channel = 0; channel < channelCount; ++channel) {
int id = 0;
int keyCount = 0;
input.Read(&id, 4);
input.Read(&keyCount, 4);
for (int key = 0; key < keyCount; ++key) {
ModelTextureKey value;
input.Read(&value, sizeof(value));
channels[id].push_back(value);
}
}
node->textureKeys[texture] = std::move(channels);
}
}
this->meshes[node->name] = node->mesh.get();
this->nodes.push_back(node.release());
}

View file

@ -5,17 +5,17 @@
#include "Resource/Models/ModelResource.h"
#include "Resource/ResourceByteReader.h"
#include <algorithm>
#include <cstring>
// OFFSET: 0x00755630
// FUNCTION: fn_07985
// OFFSET: 0x00750B10
// FUNCTION: fn_07950
// FUNCTION: fn_07985
ModelNode::ModelNode(TextureCache& textures) : model(nullptr), parent(nullptr), alpha(255), m_textures(textures) {
}
// OFFSET: 0x007570F0
// FUNCTION: fn_08002
// FUNCTION: fn_07996
ModelNode::~ModelNode() {
for (CTexture* texture : this->textures) {
if (texture) {
@ -31,16 +31,15 @@ C3dModelRes::C3dModelRes(ModelResourceContext& context) : major(0), shade(0), al
}
// OFFSET: 0x00757090
// FUNCTION: fn_08000
// FUNCTION: fn_07995
C3dModelRes::~C3dModelRes() = default;
// OFFSET: 0x00750A70
// FUNCTION: fn_07949
// FUNCTION: fn_07983
C3dModelResV1::C3dModelResV1(ModelResourceContext& context) : C3dModelRes(context), animationLength(0) {
}
// OFFSET: 0x00751E70
// FUNCTION: fn_07952
// INLINED
C3dModelResV1::~C3dModelResV1() = default;
// OFFSET: 0x00750A70
@ -80,6 +79,102 @@ void C3dModelRes::Unload() {
this->movieNames.clear();
}
// INLINED
inline void C3dModelResV1::ReadNode(ResourceByteReader& input, unsigned minor, const std::vector<std::string>& textureNames) {
auto node = std::make_unique<ModelNode>(this->m_context->textures);
node->model = this;
node->alpha = this->alpha;
char field[40]{};
input.Read(field, sizeof(field));
node->name = field;
input.Read(field, sizeof(field));
node->parentName = field;
int textureCount = 0;
input.Read(&textureCount, 4);
for (int index = 0; index < textureCount; ++index) {
int textureIndex = 0;
input.Read(&textureIndex, 4);
CTexture* texture = this->m_context->textures.Load(textureNames[textureIndex].c_str(), 0, false, true, false);
node->textures.push_back(texture);
if (texture) {
texture->Retain();
}
}
float matrix[12];
input.Read(matrix, sizeof(matrix));
input.Read(node->position, sizeof(node->position));
input.Read(&node->angle, 4);
input.Read(node->axis, sizeof(node->axis));
input.Read(node->scale, sizeof(node->scale));
node->mesh = std::make_unique<ModelMesh>();
ModelMesh& mesh = *node->mesh;
int vertexCount = 0;
input.Read(&vertexCount, 4);
mesh.vertices.resize(static_cast<unsigned>(vertexCount));
input.Read(mesh.vertices.data(), static_cast<unsigned>(vertexCount) * 12u);
for (auto& vertex : mesh.vertices) {
const float y = ((vertex[0] * matrix[1] + vertex[1] * matrix[4]) + matrix[7] * vertex[2]) + matrix[10];
const float z = ((vertex[0] * matrix[2] + vertex[1] * matrix[5]) + matrix[8] * vertex[2]) + matrix[11];
vertex[0] = ((vertex[0] * matrix[0] + vertex[1] * matrix[3]) + vertex[2] * matrix[6]) + matrix[9];
vertex[1] = y;
vertex[2] = z;
}
int textureVertexCount = 0;
input.Read(&textureVertexCount, 4);
mesh.textureVertices.resize(static_cast<unsigned>(textureVertexCount));
if (minor == 1) {
float uv[2];
for (auto& vertex : mesh.textureVertices) {
input.Read(uv, sizeof(uv));
vertex = {0xFFFFFFFFu, uv[0], uv[1]};
}
} else {
input.Read(mesh.textureVertices.data(), static_cast<unsigned>(textureVertexCount) * 12u);
}
std::uint32_t faceCount = 0;
input.Read(&faceCount, 4);
mesh.faces.resize(faceCount);
unsigned char record[24];
for (ModelFace& face : mesh.faces) {
input.Read(record, minor == 1 ? 20 : 24);
std::memcpy(face.vertices, record, sizeof(face.vertices));
std::memcpy(face.textureVertices, record + 6, sizeof(face.textureVertices));
std::memcpy(&face.texture, record + 12, sizeof(face.texture));
std::memcpy(&face.twoSided, record + 16, sizeof(face.twoSided));
std::uint32_t group = 0;
if (minor != 1) {
std::memcpy(&group, record + 20, sizeof(group));
}
face.smoothing.push_back(group);
}
// INLINED
std::sort(mesh.faces.begin(), mesh.faces.end(), [](const ModelFace& a, const ModelFace& b) { return a.texture < b.texture; });
mesh.CalculateNormals();
int rotationCount;
input.Read(&rotationCount, 4);
for (int index = 0; index < rotationCount; ++index) {
ModelRotationKey key;
input.Read(&key, sizeof(key));
node->rotationKeys.push_back(key);
}
this->meshes[node->name] = node->mesh.get();
this->nodes.push_back(node.release());
}
// OFFSET: 0x00750B10
// FUNCTION: fn_07950
bool C3dModelResV1::Load(const char* name) {

View file

@ -1,17 +1,47 @@
#include "Client/Application/ErrorDialog.h"
#include "Render/Textures/Texture.h"
#include "Render/Textures/TextureCache.h"
#include "Resource/Bitmap/BitmapResource.h"
#include "Resource/Models/ModelResource.h"
#include "Resource/ResourceByteReader.h"
#include <algorithm>
#include <cstring>
namespace {
// INLINED
std::string ReadName(ResourceByteReader& input) {
unsigned bytes = 0;
input.Read(&bytes, 4);
char name[40]{};
input.Read(name, bytes);
return name;
}
void ReadKeys(ResourceByteReader& input, std::vector<ModelRotationKey>& keys, bool scale) {
int count = 0;
input.Read(&count, 4);
for (int index = 0; index < count; ++index) {
ModelRotationKey key;
if (scale) {
key = {0, {0, 0, 0, 1}};
}
input.Read(&key, sizeof(key));
keys.push_back(key);
}
}
}
// OFFSET: 0x00751ED0
// FUNCTION: fn_07953
// FUNCTION: fn_07984
C3dModelResV2::C3dModelResV2(ModelResourceContext& context) : C3dModelRes(context), framesPerSecond(0.0f), animationLength(0) {
}
// OFFSET: 0x00752190
// FUNCTION: fn_07955
// INLINED
C3dModelResV2::~C3dModelResV2() = default;
// OFFSET: 0x00751ED0
@ -60,12 +90,118 @@ bool C3dModelResV2::Load(const char* name) {
return true;
}
// INLINED
inline void C3dModelResV2::ReadNode(ResourceByteReader& input, unsigned minor, const std::vector<std::string>& textureNames) {
auto node = std::make_unique<ModelNode>(this->m_context->textures);
node->model = this;
node->mesh = std::make_unique<ModelMesh>();
node->name = ReadName(input);
node->parentName = ReadName(input);
int textureCount = 0;
input.Read(&textureCount, 4);
for (int index = 0; index < textureCount; ++index) {
std::string name;
if (minor < 3) {
int texture = 0;
input.Read(&texture, 4);
name = textureNames[texture];
} else {
name = ReadName(input);
}
CTexture* texture = this->m_context->textures.Load(name.c_str(), 0, false, true, false);
node->textures.push_back(texture);
if (texture) {
texture->Retain();
}
}
input.Read(node->transform, sizeof(node->transform));
ModelMesh& mesh = *node->mesh;
unsigned vertexCount = 0;
input.Read(&vertexCount, 4);
mesh.vertices.resize(vertexCount);
input.Read(mesh.vertices.data(), vertexCount * 12u);
unsigned textureVertexCount = 0;
input.Read(&textureVertexCount, 4);
mesh.textureVertices.resize(textureVertexCount);
input.Read(mesh.textureVertices.data(), textureVertexCount * 12u);
int faceCount = 0;
input.Read(&faceCount, 4);
mesh.faces.resize(static_cast<unsigned>(faceCount));
for (ModelFace& face : mesh.faces) {
std::vector<unsigned char> bytes;
unsigned char fixed[24];
const unsigned char* record;
unsigned size;
if (minor == 1) {
input.Read(fixed, sizeof(fixed));
record = fixed;
size = sizeof(fixed);
} else {
size = 0;
input.Read(&size, 4);
bytes.resize(size);
input.Read(bytes.data(), size);
record = bytes.data();
}
std::memcpy(face.vertices, record, sizeof(face.vertices));
std::memcpy(face.textureVertices, record + 6, sizeof(face.textureVertices));
std::memcpy(&face.texture, record + 12, sizeof(face.texture));
std::memcpy(&face.twoSided, record + 16, sizeof(face.twoSided));
const unsigned groups = (size - 20u) / 4u;
face.smoothing.resize(groups);
std::memcpy(face.smoothing.data(), record + 20, groups * 4u);
}
// INLINED
std::sort(mesh.faces.begin(), mesh.faces.end(), [](const ModelFace& a, const ModelFace& b) { return a.texture < b.texture; });
mesh.CalculateNormals();
ReadKeys(input, node->scaleKeys, false);
ReadKeys(input, node->rotationKeys, true);
ReadKeys(input, node->positionKeys, false);
if (minor == 3) {
int textureAnimations = 0;
input.Read(&textureAnimations, 4);
for (int index = 0; index < textureAnimations; ++index) {
int texture = 0;
input.Read(&texture, 4);
ModelTextureChannels channels;
int channelCount = 0;
input.Read(&channelCount, 4);
for (int channel = 0; channel < channelCount; ++channel) {
int id = 0;
int keyCount = 0;
input.Read(&id, 4);
input.Read(&keyCount, 4);
for (int key = 0; key < keyCount; ++key) {
ModelTextureKey value;
input.Read(&value, sizeof(value));
channels[id].push_back(value);
}
}
node->textureKeys[texture] = std::move(channels);
}
}
this->meshes[node->name] = node->mesh.get();
this->nodes.push_back(node.release());
}
// OFFSET: 0x00759ED0
// FUNCTION: fn_08020
// OFFSET: 0x0075AB20
// FUNCTION: fn_08021
// OFFSET: 0x0075B8E0
// FUNCTION: fn_08022
void C3dModelResV2::ReadVersion(ResourceByteReader& input, unsigned minor) {
input.Read(&this->animationLength, 4);
input.Read(&this->shade, 4);