Welcome to Open Carnage

A resource for Halo Custom Edition and MCC modding, with unique means of rewarding content creation and support. Have a wander to see why we're worth the time!

EST. 14th of February, 2012

Sign in to follow this  
Followers 0

[SDK] Core development

Hello! I'd like to share some of the progress I have been making on one of my projects. Hopefully get some feed back to help make this be a useful tool for many.

I'd like to introduce the Core SDK.

What is the goal?
   The goal of creating this SDK is to allow people to easily access the data inside a halo cache file programmatically. Streamlining the creation of modding tools by taking care of the dirty work, and letting you get straight to writing the fun stuff. This will be a DLL for windows compiled with and without the .net framework (So even the novice writing with visual basic can still use the library), and for linux it will be a shared object.


How does will it work?

   Simply link the library, create a HaloCache variable, Tell it to load from a file, and profit. All of the information available in sapien, and guerilla will be populated to the data in the HaloCache class.


What are my dreams for the project?

   I hope to have an all in one solution, allowing access to all the data in a map, the ability to rebuild the map if necessary. I want to implement helper functions like model data to VBO for quick rendering in openGL, data to command buffer for vulkan, ect. Sanity checking to try and catch illegal parameters, and mitigate exception errors.


What do I actually have done?
   Currently I have parsed scenario data, and I have defined a handful of tags. I have implemented debug functionality that you can hook into tags, that allow for sanity checking, and when an illegal parameter is caught, the ability to hook a function in to handle the error. Currently, I have not defined the sanity checking functions yet. I need to finish defining everything first, before I can verify its integrity. Steady progress has been made, and I wanted to share with the community in hopes to add things that might be desired before the code becomes too hard to change.


Finally, an example on its current state of functionality:

To start the process you will have to link the Core library, and include header. (This is just an example, so I'll leave this ambiguous until release)

Let's take a look at an example main

int main()
	HaloCache Map;					//Create the variable to hold the map data
	Map.Open(MapLocationHere);			//However you wish to handle finding the file, just put the location here
	Map.PreLoad(false);				//PreLoad only loads the header information incase you dont need everything
		//Map loading failed. Maybe with a _Core hook we could see why.
	Map.Close();					//Close the file(Can be done after load to free file, it's now loaded to memory)
							//Maybe we want to see where the 1st vehicle is in the map
	std::cout << Map.Scenario.Vehicles[0].Position.ToString(); /
  							//Maybe we want to change the Not Placed flags on a vehicle.
  	Map.Scenario.Vehicles[2].NotPlaced = NotPlaced::Automatically;
     	 //We changed something that requires the map to be rebuilt. I haven't implimented this yet
  	//Map.SaveChanges(MapSaveLocationHere); This is half implimented but this is how it would close
	Return 0;

HaloCache is the main class that holds all the information. It also handles loading from the file to memory. The Open() function takes a location to the map file.
Once the HaloCache has a file to load, we call the preload function. Load, and PreLoad are separated out because it may be beneficial to just load the header information, and not waste the processing power loading the entire map. The parameter passed (PreLoad(True/False)) Will determine if the preloader should head straight into loading once finished (true is the default parameter). I decided against it in the example to show the load function as well. Both the preload, and the load return a boolean value, so you can easy determine if they failed. If they did fail, information will be available on it. You just have to hook a debug to the variable (The next example). The debug can also be linked to a error handling function on a per tag, or per map basis. It could reopen the file dialog and ask to try again for example.


I will fully map out the structure of the HaloCache class once it's complete. Variables will move around a bit as development goes on, but inside of there is the currently organized scenario data, with all of the offsets adjusted for map magic.



Let's take a closer look at the _Core handler discussed earlier.

void Log(Handle DebugInformation)
		Case ErrorCode::Notification:
			std::cout << DebugInformation.Details;	//This is debug information
		Case ErrorCode::Error:				//This is Non-fatal error info
			std::cout << DebugInformation.Details;	//Output the error
			DebugInformation.ErrorHandle = ooppss;	//call the ooppss function to handle it
		Case ErrorCode::Fatal:				//This is when you dun goofed.
			std::cout << DebugInformation.Details;	//Output the error
			DebugInformation.ErrorHandle = nichtgut;//call the nichtgut function to try and handle it.

int main()
  HaloCache Map;
  Map._Core.DebugHook = Log;
  Map._Core.InheritHook = true;
  ...								//!!!ERROR we sent the wrong map location
  return 0;

In this example, we setup a _Core hook, and tried to load a map file. Sadly, we typed the name wrong, and Core couldn't find the map. This is how the situation is handled:
Debug information is broken up into:


Notification, Standard debug information.

Error, Non-fatal error easily recoverable.

Fatal, Difficult to recover from, but you can always try.


The Handle class contains the severity of the message, Details of the message, and the reference to the error handler. (The hook can also be inherited by the tags children.)


So what would the output look like for this?
In this case it's a simple cout, so it would be printed to the terminal/cmd as a string:


Attempting to find: IncorrectMapLoc
	Unable to find file specified.

Now we know the load failed because we told it the wrong place.

This is all I have implemented currently. Development has been steady; however, I'm about to drive/move across country so I'm going to have to take a week/two off here soon. If there are any other features you'd be interested in seeing implemented, please let me know!

Edited by Zatarita
WaeV and PopeTX28 like this

Share this post

Link to post
Share on other sites




You know what. I think I misunderstood; I understand now. I thought invader just built maps, after glancing through the some of the source I still didn't understand. After looking at that link I understand now.

Yes I'd love to talk on discord now that I understand.


If that's the case we can close the thread, I don't want to step on any feet. And kavas been doing it longer, it'll likely be better suited

Edited by Zatarita

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.