rodecomp/Source/Contents/World/WorldGroundImport.h
ragnarok-clanker b678131329 Maintenance: Restore original C3dGround/C3dGround15 hierarchy as GroundBase/GroundGeometry with 20 virtual slots, base size0x64 and d
Batch #14713 by ragnarok-clanker: forced by an admin (7 lower score(s), 49 changed function(s)); checked with 27 compiled unit(s), including every includer of Source/Contents/Ground/GroundGeometry.h, Source/Contents/Ground/GroundWaterState.h, Source/Contents/World/WorldGroundImport.h.
2026-11-07 16:19:02 +00:00

61 lines
1.8 KiB
C

#ifndef RAGNAROK_SOURCE_CONTENTS_WORLD_WORLDGROUNDIMPORT_H
#define RAGNAROK_SOURCE_CONTENTS_WORLD_WORLDGROUNDIMPORT_H
#include "Client/Application/ErrorDialog.h"
#include "Contents/Ground/GroundGeometry.h"
#include "Resource/World/GroundResource.h"
#include "Resource/ResourceMgr.h"
#include "Resource/World/TerrainResource.h"
#include "Resource/World/WorldResource.h"
#include "Utility/Math/ScalarConversion.h"
// INLINED
inline bool ImportWorldGround(
const C3dWorldRes& world, ResourceMgr& resources, CRenderSystemBase* renderSystem, C3dAttr*& terrain, GroundGeometry*& ground,
int& nearbyRange, const float* lightDirection, const float* diffuse, const float* ambient
) {
if (world.terrainName.empty()) {
ShowErrorDialog(renderSystem, "attr ", 0);
return false;
}
terrain = static_cast<C3dAttr*>(resources.Load(world.terrainName.c_str()));
if (!terrain) {
ShowErrorDialog(renderSystem, "attr ", 0);
return false;
}
terrain->cellSize = 5;
nearbyRange *= terrain->cellSize;
if (world.groundName.empty()) {
ShowErrorDialog(renderSystem, "gnd ", 0);
return false;
}
auto* resource = static_cast<CGndRes*>(resources.Load(world.groundName.c_str()));
if (!resource) {
ShowErrorDialog(renderSystem, "ground", 0);
return false;
}
if (!resource->loaded) {
ShowErrorDialog(renderSystem, "", 0);
return false;
}
ground = new GroundGeometry;
ground->Build(*resource, lightDirection, diffuse, ambient);
ground->terrain = terrain;
const int pitch = TruncateToInt(world.wavePitch);
const int phase = TruncateToInt(world.waveSpeed);
ground->SetWater(world.waterLevel, world.waterType, world.waterAnimation, pitch, phase, world.waveHeight);
ground->ImportWater(*resource);
resources.Remove(resource);
return true;
}
#endif