4coder » Forums » Custom Map_ID
CalPhorus
3 posts
#14697 Custom Map_ID
7 months ago Edited by CalPhorus on March 25, 2018, 9:55 p.m. Reason: Initial post

Hello,

I know that there are the built-in values for `Map_ID`, but is it possible to create new ones using variables of type `int32_t` (since all of the functions/structs that make use of a `Map_ID` actually use `int32_t`)?

Thanks!
Mr4thDimention
Allen Webster
424 posts / 2 projects

Heyo

#14699 Custom Map_ID
7 months ago

Yep!

You don't have to do anything special to register your own maps except you need to make sure it has a value not clashing with any of the other maps in use.
CalPhorus
3 posts
#14709 Custom Map_ID
7 months ago

I just tried making a map with a custom value (the value that I am using for the custom map is 0x01000008 or (1<<24)+8), and 4coder crashes. I tried changing the value to one of the 4coder built-ins (mapid_file), and 4coder no longer crashes. Putting it in Visual Studio to debug my code, my code is reached and once it returns from `get_bindings` it crashes with an exception: "Exception thrown at 0x00007FF8BD6A2672 (4ed_app.dll) in 4ed.exe: 0xC0000005: Access violation reading location 0x0000000000000190". I am using the 4.0.25 version purchased from itch.io.
Mr4thDimention
Allen Webster
424 posts / 2 projects

Heyo

#14718 Custom Map_ID
6 months, 4 weeks ago Edited by Allen Webster on March 27, 2018, 5:26 a.m.

Why are you using "(1 << 24) + 8"? Values over (1 << 24) are reserved for built in maps like mapid_global, mapid_file, etc. You should just start at 0, or if you're trying to avoid conflicting with "default_code_map", just start at "default_maps_count". That isn't a map, it's there so you can start you enum from there.

However - that's not suppose to cause a crash. It's suppose to give you a warning and just not make the map... will take a look at that part.
CalPhorus
3 posts
#14732 Custom Map_ID
6 months, 4 weeks ago

I noticed the maps started at 1<<24, so I figured that all of the maps were supposed to start there (both built-in and custom).

Thanks for the help, changing the initial value in my enum to "default_maps_count" fixed all crashes!
Mr4thDimention
Allen Webster
424 posts / 2 projects

Heyo

#14750 Custom Map_ID
6 months, 4 weeks ago

Great!

There used to be better documentation on this in the custom code... I guess it got lost at some point while things were moving around because I don't see it anymore :/

Thanks for bringing this stuff to my attention.