Archived

This topic is now archived and is closed to further replies.

gowron67

weird error

Recommended Posts

I am writing a level editor for a 3D game and I have a really strange error when saving out the data to a file type that I designed. The file is arranged into a chunk format whereby the chunk header gives a description of the data type to follow and then gives the length of the data chunk. The length variable is a DWORD. I then have a VERTEX struct which has 5 float variables ( = 20 bytes) and a POLYGON structure which has 3 int variables ( = 12 bytes). To get the length of the chunk I am doing... (in pseudo-code). CHUNK polychunk CHUNK vertexchunk polychunk.length = sizeof(POLYGON)*numpolygons; ... and vertexchunk.length = sizeof(VERTEX)*numvertices; I am absolutely positive that numpolygons and numvertices have the correct number in them because I've done a variable watch during debug...However....the value of the above expressions is evaluating to about 10 times larger than it should be...but if I hardcode the numpolygons and numvertices values, it works perfectly...This is an error I just cannot understand at all. Can anyone help ?? [edited by - gowron67 on August 18, 2002 4:02:00 PM]

Share this post


Link to post
Share on other sites
What alignment is your structure packed on? There might be some padding stuck in there that''s throwing your file size calculations off. But since you said 10 times bigger - that sounds like your decimal point is off in one of the calculations.

Share this post


Link to post
Share on other sites