• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Dev] Map Structure

Junior Spellweaver
Joined
Nov 19, 2014
Messages
132
Reaction score
12
if i didn't make this simple wrong, you are would not to share your informations.
:)
 
Retired (Goddamn idiots)
Joined
Dec 3, 2003
Messages
391
Reaction score
483
bergi, BOOL in C++ is an int, not a bool type.
So you're looking at 4 bytes versus one byte.
As well as char being 2 bytes due to unicode. I recommend using byte instead.
 
Last edited:
[emoji848]
Legend
Joined
Dec 3, 2011
Messages
2,232
Reaction score
1,518
bergi, BOOL in C++ is an int, not a bool type.
So you're looking at 4 bytes versus one byte.
As well as char being 2 bytes due to unicode. I recommend using byte instead.

This is all about Marshaling in C# really. You can apply native / unmanaged type attributes like he did with:
Code:
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)]
or optionally
Code:
[MarshalAs(UnmanagedType.Bool)]
which will make a C# bool always a 4-byte integer. This is the default btw. so it's not necessary to specify it explicitly!

The struct posted by bergi9 works because:
  • The marshals every C# bool to a 32-bit integer
  • He applied a ByValArray Type with a constant size marshal tag to the "strEventParam" Array
 
Back
Top