Advertisement
liquidspark

Zeus MapFileParser.h

Nov 17th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  MapFileParser.h     -- Here we parse various halo map files.
  3. //  Zeus
  4. //
  5. //  Created by Sparky on 11/16/11.
  6. //  Copyright 2011 MacGamingMods.com and HaloDemoMods.com. All rights reserved.
  7. //
  8.  
  9.     // basic things to include
  10. #import <Foundation/Foundation.h>
  11.  
  12.     // include the map file types we will be handling... nevermind, that's not how this will work. see the method comments below for more information
  13.  
  14.  
  15.  
  16. @interface MapFileParser : NSObject {   // this object will interpret map file data for classes like DetermineHaloMapFileType
  17. @private
  18.         //variables
  19.     NSMutableData * map;        // this object will hold the map file data in memory
  20.  
  21.         // all the information we gather from our map file
  22.         // first, the basics about the map
  23.     NSMutableData * mapheader;  // this object will hold the map file header data
  24.     NSString * mapbuildversion;     // this will hold the version as stored in the map file
  25.     NSMutableData * mapchecksum;    // this will hold the map file checksum
  26.     NSString * mapplatform;     // this will hold the platform, whether mac, pc, xbox, etc.
  27.     NSMutableData * maptype;            // this will hold whether it's singleplayer or multiplayer
  28.     NSString * mapname;         // this will hold the name of the map, ie. bloodgulch
  29.     NSMutableData * mapdatasize;    // the size of the data in the map file
  30.     NSMutableData * mapmetadatasize;    // the size of the tag data in the map file
  31.     NSNumber * maptagcount;     // number of tags in the map
  32.     NSMutableData * mapmodelvertexdatasize; // size of the vertex coordinate data for models in the map
  33.     NSNumber * mapmodelvertexcount;         // number of model vertices in the map
  34.     NSMutableData * mapmodelindexdatasize;      // size of the index data for models in the map
  35.     NSNumber * mapmodelindexcount;              // number of model indeces in the map
  36.     NSMutableData * mapmagicprimary;        // the primary map magic used in calculating offsets to tag metadata
  37.     NSMutableData * mapmagicsecondary;      // the secondary map magic used in calculating offsets to referenced data besides tag info (correct?)
  38.    
  39.         // next, the metadata related to each tag type (named after the four-letter tag names... ya like that? hehe.)
  40.     NSMutableData * h1_actr;    // Actor
  41.     NSMutableData * h1_actv;    // Actor Variant
  42.     NSMutableData * h1_ant;     // Antenna
  43.     NSMutableData * h1_antr;    // Animation Trigger (model animations)
  44.     NSMutableData * h1_bipd;    // Biped
  45.     NSMutableData * h1_bitm;    // Bitmap
  46.     NSMutableData * h1_boom;    // Spheroid
  47.     NSMutableData * h1_cdmg;    // Continuous Damage Effect
  48.     NSMutableData * h1_coll;    // Model Collision Geometry
  49.     NSMutableData * h1_colo;    // Color Table
  50.     NSMutableData * h1_cont;    // Contrail
  51.     NSMutableData * h1_ctrl;    // Device Control
  52.     NSMutableData * h1_deca;    // Decal
  53.     NSMutableData * h1_dela;    // UI Widget Definition
  54.     NSMutableData * h1_devc;    // Input Device Defaults
  55.     NSMutableData * h1_devi;    // Device
  56.     NSMutableData * h1_dobc;    // Detail Object Collection
  57.     NSMutableData * h1_effe;    // Effect
  58.     NSMutableData * h1_elec;    // Lightning
  59.     NSMutableData * h1_eqip;    // Equipment
  60.     NSMutableData * h1_flag;    // Flag
  61.     NSMutableData * h1_fog;     // Fog
  62.     NSMutableData * h1_font;    // Font
  63.     NSMutableData * h1_foot;    // Material Effects
  64.     NSMutableData * h1_garb;    // Garbage
  65.     NSMutableData * h1_glw;     // Glow
  66.     NSMutableData * h1_grhi;    // Grenade HUD Interface
  67.     NSMutableData * h1_hmt;     // HUD Message Text
  68.     NSMutableData * h1_hud;     // HUD Number
  69.     NSMutableData * h1_hudg;    // HUD Globals
  70.     NSMutableData * h1_item;    // Item
  71.     NSMutableData * h1_itmc;    // Item Collection
  72.     NSMutableData * h1_jpt;     // Damage Effect
  73.     NSMutableData * h1_lens;    // Lens Flare
  74.     NSMutableData * h1_lifi;    // Device Light Fixture
  75.     NSMutableData * h1_ligh;    // Light
  76.     NSMutableData * h1_lsnd;    // Sound Looping
  77.     NSMutableData * h1_mach;    // Device Machine
  78.     NSMutableData * h1_matg;    // Game Globals
  79.     NSMutableData * h1_metr;    // Meter
  80.     NSMutableData * h1_mgs2;    // Light Volume
  81.     NSMutableData * h1_mod2;    // Gearbox Model (pc model)
  82.     NSMutableData * h1_mode;    // Model
  83.     NSMutableData * h1_mply;    // Multiplayer Scenario Description
  84.     NSMutableData * h1_ngpr;    // Network Game Preferences
  85.     NSMutableData * h1_obje;    // Object
  86.     NSMutableData * h1_part;    // Particle
  87.     NSMutableData * h1_pctl;    // Particle System
  88.     NSMutableData * h1_phys;    // Physics
  89.     NSMutableData * h1_plac;    // Placeholder
  90.     NSMutableData * h1_pphy;    // Point Physics
  91.     NSMutableData * h1_proj;    // Projectile
  92.     NSMutableData * h1_rain;    // Weather Particle System
  93.     NSMutableData * h1_sbsp;    // Scenario Structure BSP
  94.     NSMutableData * h1_scen;    // Scenery
  95.     NSMutableData * h1_scex;    // Shader Transparent Chicago Extended
  96.     NSMutableData * h1_schi;    // Shader Transparent Chicago
  97.     NSMutableData * h1_scnr;    // Scenario
  98.     NSMutableData * h1_senv;    // Shader Environment
  99.     NSMutableData * h1_sgla;    // Shader Transparent Glass
  100.     NSMutableData * h1_shdr;    // Shader
  101.     NSMutableData * h1_sky;     // Sky
  102.     NSMutableData * h1_smet;    // Shader Transparent Meter
  103.     NSMutableData * h1_snd;     // Sound
  104.     NSMutableData * h1_snde;    // Sound Environment
  105.     NSMutableData * h1_soso;    // Shader Model
  106.     NSMutableData * h1_sotr;    // Shader Transparent Generic
  107.     NSMutableData * h1_soul;    // UI Widget Collection
  108.     NSMutableData * h1_spla;    // Shader Transparent Plasma
  109.     NSMutableData * h1_ssce;    // Sound Scenery
  110.     NSMutableData * h1_str;     // String List
  111.     NSMutableData * h1_swat;    // Shader Transparent Water
  112.     NSMutableData * h1_tagc;    // Tag Collection
  113.     NSMutableData * h1_trak;    // Camera Track
  114.     NSMutableData * h1_udlg;    // Unit Dialogue
  115.     NSMutableData * h1_unhi;    // Unit HUD Interface
  116.     NSMutableData * h1_unit;    // Unit
  117.     NSMutableData * h1_ustr;    // Unicode String List
  118.     NSMutableData * h1_vcky;    // Virtual Keyboard
  119.     NSMutableData * h1_vehi;    // Vehicle
  120.     NSMutableData * h1_weap;    // Weapon
  121.     NSMutableData * h1_wind;    // Wind
  122.     NSMutableData * h1_wphi;    // Weapon HUD Interface
  123. }
  124.  
  125.     //methods
  126.  
  127.     // the methods that parse each element (header, tags, other data) of the map file are defined here
  128.     // the methods that represent each element (return its data) are defined within the respective header files within the folder "Map File Types"
  129.     // methods that are used to change (write) the data to a map are also found in those specific map type header files
  130.     // we do this because the map file parser does not need to handle specific collections of tags unique to a map file, but handles all the possible map data
  131.     // therefore, the type of map can be identified by the information gathered by this class; this info is used by DetermineHaloMapFileType
  132.     // after a map file is chosen to be opened by the user, DetermineHaloMapFileType will use the methods in MapFileParser to identify the map based upon its header information
  133.     // we'll use one method for each type of data parsing (header, each type of tag, each type of data), and then within that method will be specific parsing code for each type of supported map file; although this code is specific to each map file, it will be handled here because it still relates to parsing; so if we add new types of supported map files, we will need to add the data and tag objects (as you see above) and add new methods (as you see below) for parsing that data here, and then add a new class under "Map File Types" for handling those objects specifically in other ways such as reading and writing their specific types of data
  134.     // so this MapFileParser class is basically the heart of the matter which interprets the information for all the map creation and editing tasks; within various other files, specific tasks (such as determining the map file type and interpreting user modifications to the map scenario) are handled within classes related to those specific tasks, while specific map types are handled within their appropriately-named classes under "Map File Types" where for example the Halo1DemoTrialMacPCMapClass class uses the tag objects seen above prefixed with h1_ which represents Halo 1 tags
  135.  
  136. -(id)parse_map:(NSMutableData *)map;    // define the generic parsing method for the entire map; used to rebuild mapfile data from memory to file
  137. -(id)parse_mapheader:(NSMutableData *)mapheader;    // this instance method will be used to parse the header data of each supported map type
  138. -(id)parse_mapbuildversion:(NSString *)mapbuildversion; // this parses the build version data... not sure if I should use the following technique instead:
  139.                                                     // -(NSString *)buildversion;   ...which maintains interpretation as a string
  140. -(id)parse_mapchecksum:(NSMutableData *)mapchecksum;
  141. -(id)parse_mapplatform:(NSString *)mapplatform;
  142. -(id)parse_maptype:(NSMutableData *)maptype;        // I forgot how this is stored. Maybe as a number? Might use NSNumber then.
  143. -(id)parse_mapname:(NSString *)mapname;
  144. -(id)parse_mapdatasize:(NSMutableData *)mapdatasize;
  145. -(id)parse_mapmetadatasize:(NSMutableData *)mapmetadatasize;
  146. -(id)parse_maptagcount:(NSNumber *)maptagcount;
  147. -(id)parse_mapmodelvertexdatasize:(NSMutableData *)mapmodelvertexdatasize;
  148. -(id)parse_mapmodelvertexcount:(NSNumber *)mapmodelvertexcount;
  149. -(id)parse_mapmodelindexdatasize:(NSMutableData *)mapmodelindexdatasize;
  150. -(id)parse_mapmodelindexcount:(NSNumber *)mapmodelindexcount;
  151.  
  152. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement