Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmap extractor - dont save struct padding to temp files #2832

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/vmap_extractor/vmapextract/wmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ bool WMOGroup::open()
{
liquflags |= 1;
hlq = new WMOLiquidHeader;
f.read(hlq, 0x1E);
f.read(hlq, WMOLiquidHeaderSize);
LiquEx_size = sizeof(WMOLiquidVert) * hlq->xverts * hlq->yverts;
LiquEx = new WMOLiquidVert[hlq->xverts * hlq->yverts];
f.read(LiquEx, LiquEx_size);
Expand Down Expand Up @@ -497,7 +497,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool pPrecis
llog << ":\ntype: " << hlq->type << " (root:" << rootWMO->flags << " group:" << flags << ")\n";
llog.close(); */

fwrite(hlq, sizeof(WMOLiquidHeader), 1, output);
fwrite(hlq, WMOLiquidHeaderSize, 1, output);
// only need height values, the other values are unknown anyway
for (uint32 i = 0; i < LiquEx_size / sizeof(WMOLiquidVert); ++i)
fwrite(&LiquEx[i].height, sizeof(float), 1, output);
Expand Down
6 changes: 4 additions & 2 deletions contrib/vmap_extractor/vmapextract/wmo.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ class WMORoot

struct WMOLiquidHeader
{
int xverts, yverts, xtiles, ytiles;
int32 xverts, yverts, xtiles, ytiles;
float pos_x;
float pos_y;
float pos_z;
short type;
uint16 type;
};

constexpr int32 WMOLiquidHeaderSize = sizeof(int32) /* xverts */ + sizeof(int32) /* yverts */ + sizeof(int32) /* xtiles */ + sizeof(int32) /* ytiles */ + sizeof(float) /* pos_x */ + sizeof(float) /* pos_y */ + sizeof(float) /* pos_z */ + sizeof(uint16) /* type */;

struct WMOLiquidVert
{
uint16 unk1;
Expand Down
9 changes: 6 additions & 3 deletions src/game/vmap/TileAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,15 @@ namespace VMAP

struct WMOLiquidHeader
{
int xverts, yverts, xtiles, ytiles;
int32 xverts, yverts, xtiles, ytiles;
float pos_x;
float pos_y;
float pos_z;
short type;
uint16 type;
};

constexpr uint32 WMOLiquidHeaderSize = sizeof(int32) /* xverts */ + sizeof(int32) /* yverts */ + sizeof(int32) /* xtiles */ + sizeof(int32) /* ytiles */ + sizeof(float) /* pos_x */ + sizeof(float) /* pos_y */ + sizeof(float) /* pos_z */ + sizeof(uint16) /* type */;

//=================================================================
bool TileAssembler::convertRawFile(std::string const& pModelFilename)
{
Expand Down Expand Up @@ -479,7 +482,7 @@ namespace VMAP
READ_OR_RETURN(&blockId, 4);
CMP_OR_RETURN(blockId, "LIQU");
READ_OR_RETURN(&blocksize, sizeof(int));
READ_OR_RETURN(&hlq, sizeof(WMOLiquidHeader));
READ_OR_RETURN(&hlq, WMOLiquidHeaderSize);
liquid = new WmoLiquid(hlq.xtiles, hlq.ytiles, Vector3(hlq.pos_x, hlq.pos_y, hlq.pos_z), hlq.type);
uint32 size = hlq.xverts * hlq.yverts;
READ_OR_RETURN(liquid->GetHeightStorage(), size * sizeof(float));
Expand Down