rodecomp/Source/Resource/World/TerrainResource.cpp
ragnarok-clanker ffbeee0f2a Maintenance: Forced maintainer submission (resubmission of 14678 after td sync to 8deac7a3; replaces 14460 and 14473). Native-run fix
Batch #14681 by ragnarok-clanker: forced by an admin (6 lower score(s), 70 changed function(s)); checked with 555 compiled unit(s), including every includer of Source/Client/Mode/CLoginMode.h, Source/Client/Session.h, Source/Contents/Actors/GameActor.h, Source/Contents/Actors/GrannyGameActor.h, Source/Contents/Actors/Pc.h, Source/Contents/Actors/RenderObject.h, Source/Contents/EffectResourceSwitcher.h, Source/Contents/Effects/CartCannon.h, Source/Contents/Effects/EZ2STREffectEx.h, Source/Contents/Effects/EffectActor.h, Source/Contents/Effects/MonsterSkillEffects.h, Source/Contents/Effects/RagEffect.h, Source/Contents/Effects/RectUpEffect.h, Source/Contents/Ground/GroundGeometry.h, Source/Network/Connection/Connection.h, Source/Resource/Audio/WaveResource.h, Source/Resource/Bitmap/BitmapResource.h, Source/Resource/EZeffectResource.h, Source/Resource/EmblemResource.h, Source/Resource/GifResource.h, Source/Resource/ImfResource.h, Source/Resource/Models/AnimatedModelResource.h, Source/Resource/Models/GrannyModelResource.h, Source/Resource/Models/ModelResource.h, Source/Resource/PaletteResource.h, Source/Resource/RmaResource.h, Source/Resource/Sprites/ActionResource.h, Source/Resource/Sprites/SpriteResource.h, Source/Resource/World/GroundResource.h, Source/Resource/World/TerrainResource.h, Source/Resource/World/WorldResource.h, Source/UI/Buttons/UIBmpRadioBtn.h, Source/UI/Buttons/UITextButton.h, Source/UI/Item/UIItemPurchaseWnd.h, Source/UI/Item/UIItemSellWnd.h, Source/UI/Item/UIItemSellWnd2.h, Source/UI/Item/UIItemStoreWnd.h, Source/UI/Item/UIItemWnd.h, Source/UI/Item/UIParaItemShopWnd.h, Source/UI/Items/UIItemRepairWnd.h, Source/UI/Items/UIMakeTargetListWnd.h, Source/UI/Items/UIMakeTargetProcessWnd.h, Source/UI/Items/UIWeaponRefineWnd.h, Source/UI/Rodex/UIRodexInboxWnd.h, Source/UI/Shop/UIMerchantItemShopWnd.h, Source/UI/Shop/UIMerchantMirrorItemWnd.h, Source/UI/Shop/UIMerchantShopMakeWnd.h, Source/UI/StylingShop/UIStylingShopWnd.h, Source/UI/UIChangeMaterialWnd.h, Source/UI/UIIngredientInfoWnd.h, Source/UI/UIItemReformWnd.h, Source/UI/UILapineScrollBar.h, Source/UI/Window/UIHotKeyWnd.h, Source/UI/Window/UINewSelectCharWnd.h.
2026-11-07 14:05:21 +00:00

87 lines
2 KiB
C++

#include "Client/Application/ErrorDialog.h"
#include "File/File.h"
#include "Render/DeviceContext/DCSurface.h"
#include "Resource/World/TerrainResource.h"
#include "Resource/ResourceMgr.h"
#include <cstring>
// OFFSET: 0x00748A70
// FUNCTION: fn_07833
C3dAttr::C3dAttr() {
this->width = 0;
this->height = 0;
this->cellSize = 5;
}
// INLINED
C3dAttr::~C3dAttr() = default;
// OFFSET: 0x00748410
// FUNCTION: fn_07828
C3dAttr* C3dAttr::Create() {
return new C3dAttr;
}
// OFFSET: 0x007484E0
// FUNCTION: fn_07829
bool C3dAttr::Load(const char* name) {
CFile file;
file.Open(name, 0, true, false);
char magic[5]{};
file.Read(magic, 4);
if (std::strcmp(magic, "GRAT") != 0) {
ShowErrorDialog("Block Attr ", 0);
file.Close();
return false;
}
unsigned char major;
unsigned char minor;
file.Read(&major, 1);
file.Read(&minor, 1);
if (major == 1 && minor <= 3) {
int columns;
int rows;
file.Read(&columns, sizeof(columns));
file.Read(&rows, sizeof(rows));
this->Unload();
const auto count = static_cast<std::uint32_t>(columns) * static_cast<std::uint32_t>(rows);
this->m_cells.resize(count);
this->width = columns;
this->height = rows;
file.Read(this->m_cells.data(), count * sizeof(TerrainHeightCell));
if (minor >= 3) {
for (int row = 0; row < rows; ++row) {
for (int column = 0; column < columns; ++column) {
this->m_cells[static_cast<unsigned>(row) * static_cast<unsigned>(columns) + static_cast<unsigned>(column)].type &= 0x7FFFFFFFu;
}
}
}
file.Close();
} else {
ShowErrorDialog("C3dAttr::Unsupported Version", 0);
}
file.Close();
return true;
}
// OFFSET: 0x00748840
// FUNCTION: fn_07830
void C3dAttr::Unload() {
this->width = 0;
this->height = 0;
}
// INLINED
C3dAttr::C3dAttr(const char* extension, const char* prefix) {
ResourceMgr::Instance().Register(extension, prefix, this);
}
// GLOBAL: gl_25548
C3dAttr g_gatPrototype("gat", "");