A Community discussion forum for Halo Custom Edition, Halo 2 Vista, Portal and Halo Machinima

Home  Search Register  Login Member ListRecent Posts
  
 
»Forums Index »Halo Custom Edition (Bungie/Gearbox) »Halo CE General Discussion »C code open for comments. PLEASE READ, MosesofEgypt, 002 / Kavawuvi...

Author Topic: C code open for comments. PLEASE READ, MosesofEgypt, 002 / Kavawuvi... (7 messages, Page 1 of 1)
Moderators: Dennis

sparky
Joined: Jun 27, 2009

If you want to see the nature of a man, quote God.


Posted: Apr 27, 2019 11:41 AM    Msg. 1 of 7       
I did structs for ".model" tags.
I'm looking for comments.
https://pastebin.com/ZCxV1LDY

1) Is it legible?
2) Do you have issues with float_t instead of float? Look at math.h to see what float_t is used for.
3) Any complaints with not using the typedef data types such as long_integer and real and tag?
4) Any last words about not storing padding values?
5) How else would you do nested arrays besides the approach as shown here?
struct model_region_permutation_marker_block {
struct data name;
int16_t node_index;
struct real_quaternion rotation;
struct real_point_3d translation;
};
struct model_region_permutation_block {
struct data name;
uint32_t flags;
int16_t super_low;
int16_t low;
int16_t medium;
int16_t high;
int16_t super_high;
struct {
size_t count;
struct model_region_permutation_marker_block* elements;
} markers;
};


Thanks.


Kavawuvi
Joined: May 24, 2018

Brrrrrrring Ha!


Posted: Apr 27, 2019 01:05 PM    Msg. 2 of 7       
1) Yes.
2) No. float_t can be used interchangeably with float.
3) As long as the size is correct when compiled for 32-bit and 64-bit, it's fine.
4) Padding is nice if you want to directly map data to a struct. If you don't need to do this, though, then that works.
5) Considering you're using C and not C++ and thus don't have access to the magical power of templates, that's fine.


sparky
Joined: Jun 27, 2009

If you want to see the nature of a man, quote God.


Posted: Apr 27, 2019 06:58 PM    Msg. 3 of 7       
Thanks.
I am guessing that they did padding in the (interface) definitions -- which are like templates -- because of the static pointer calculations during map compilation and reading the data into memory. But contrarily, there is more padding than necessary for 32-bit integer memory address alignment. And it seems strange that the padding is unmodified, skipped, by the HEK programs that write to disk. Perhaps they were simply frivolous with skipped bytes to give themselves more leeway as they anticipated adding more metadata to the template definitions. Anyway, I'm not using template style, so it doesn't really matter much to me because I'm not trying to remake the game engine literally.

I comment more about this in a new Discord server I started. I did so because this forum is too slow and it's more fun reading short blurbs of text in a more chronologically-visible manner than editing my thread replies into long walls of text which I have heard several people say over the years they dislike, and which doesn't show as being updated in the thread list. If anyone wants the link to the Galaxy Verge Discord server, send me a private message while I'm still around. So far, it's only Lolslayer and me there. (Thanks again, Lolslayer.)

I look forward to MosesofEgypt and any other software developer's responses and comments. If someone bumps one of my threads on this forum, I'll reply to it with some pastebin code links when the time comes. Otherwise, when the time comes, I'll simply start a new thread to discuss its progress.


Kavawuvi
Joined: May 24, 2018

Brrrrrrring Ha!


Posted: May 1, 2019 07:05 PM    Msg. 4 of 7       
Quote: --- Original message by: sparky
Thanks.
I am guessing that they did padding in the (interface) definitions -- which are like templates -- because of the static pointer calculations during map compilation and reading the data into memory. But contrarily, there is more padding than necessary for 32-bit integer memory address alignment. And it seems strange that the padding is unmodified, skipped, by the HEK programs that write to disk. Perhaps they were simply frivolous with skipped bytes to give themselves more leeway as they anticipated adding more metadata to the template definitions. Anyway, I'm not using template style, so it doesn't really matter much to me because I'm not trying to remake the game engine literally.


Most padding is actual padding. There are, however, plenty of values that Guerilla does not write to that tool.exe actually does write to. If these values are left at 0, unexpected things may happen such as dying instantly from fall damage or various effects not triggering on dedicated servers when they should.


Masters1337
Joined: Mar 5, 2006

halonaminator's unfortunate idol


Posted: May 1, 2019 08:37 PM    Msg. 5 of 7       
Quote: --- Original message by: Kavawuvi
Quote: --- Original message by: sparky
Thanks.
I am guessing that they did padding in the (interface) definitions -- which are like templates -- because of the static pointer calculations during map compilation and reading the data into memory. But contrarily, there is more padding than necessary for 32-bit integer memory address alignment. And it seems strange that the padding is unmodified, skipped, by the HEK programs that write to disk. Perhaps they were simply frivolous with skipped bytes to give themselves more leeway as they anticipated adding more metadata to the template definitions. Anyway, I'm not using template style, so it doesn't really matter much to me because I'm not trying to remake the game engine literally.


Most padding is actual padding. There are, however, plenty of values that Guerilla does not write to that tool.exe actually does write to. If these values are left at 0, unexpected things may happen such as dying instantly from fall damage or various effects not triggering on dedicated servers when they should.


I would love to learn more about these.


sparky
Joined: Jun 27, 2009

If you want to see the nature of a man, quote God.


Posted: May 2, 2019 12:54 PM    Msg. 6 of 7       
My approach includes comparing padding values among stock tags within the map files to see which are pre-calculated values for optimization and so on.

I'm essentially saying that I'm including all the interesting data but not the ignored bytes and thus my structs and approach is not equivalent but an attempt to hone or alter what the HEK and Halo does.
Edited by sparky on May 2, 2019 at 12:56 PM


1bobsam1
Joined: Mar 18, 2010

I win. You lose.


Posted: May 2, 2019 10:48 PM    Msg. 7 of 7       
Just a small tip, if you do not know of this program by chance. ReClassEx is a nice program to easily sort and live edit structures if you know the address that they are set to during run-time. It's obviously not anything CheatEngine or other run-time memory viewers/editor/debugers cannot do, but this provides a nice way of generating structures and setting values of memory at the structure's offsets if needed.

I've been using it a lot lately in creating structures for Modern Warfare 3 research I've been doing. It just has a nice simple logical layout for this specific task.

https://github.com/ajkhoury/ReClassEx

 

 
Previous Older Thread    Next newer Thread







Time: Wed February 26, 2020 3:23 PM 219 ms.
A Halo Maps Website