public BriefingRunner (ReadyRoomScreen screen, Chk scenario, string scenario_prefix) { this.screen = screen; this.scenario = scenario; this.prefix = scenario_prefix; triggerData = scenario.BriefingData; }
void ParseSection(string section_name) { SectionData sec = sections[section_name]; if (sec == null) { throw new Exception(String.Format("map file is missing section {0}, cannot load", section_name)); } if (sec.buffer == null) { stream.Position = sec.data_position; sec.buffer = new byte[sec.data_length]; stream.Read(sec.buffer, 0, (int)sec.data_length); } byte[] section_data = sec.buffer; if (section_name == "TYPE") { scenarioType = Util.ReadWord(section_data, 0); } else if (section_name == "ERA ") { tileSet = (Tileset)Util.ReadWord(section_data, 0); } else if (section_name == "DIM ") { width = Util.ReadWord(section_data, 0); height = Util.ReadWord(section_data, 2); } else if (section_name == "MTXM") { mapTiles = new ushort[width, height]; int y, x; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { mapTiles[x, y] = Util.ReadWord(section_data, (y * width + x) * 2); } } } else if (section_name == "MASK") { mapMask = new byte[width, height]; int y, x; int i = 0; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { mapMask[x, y] = section_data [i++]; } } } else if (section_name == "SPRP") { int nameStringIndex = Util.ReadWord(section_data, 0); int descriptionStringIndex = Util.ReadWord(section_data, 2); Console.WriteLine("mapName = {0}", nameStringIndex); Console.WriteLine("mapDescription = {0}", descriptionStringIndex); mapName = GetMapString(nameStringIndex); mapDescription = GetMapString(descriptionStringIndex); } else if (section_name == "STR ") { ReadStrings(section_data); } else if (section_name == "OWNR") { numPlayers = 0; for (int i = 0; i < 12; i++) { /* * 00 - Unused * 03 - Rescuable * 05 - Computer * 06 - Human * 07 - Neutral */ if (section_data[i] == 0x05) { numComputerSlots++; } else if (section_data[i] == 0x06) { numHumanSlots++; } } } else if (section_name == "SIDE") { /* * 00 - Zerg * 01 - Terran * 02 - Protoss * 03 - Independent * 04 - Neutral * 05 - User Select * 07 - Inactive * 10 - Human */ numPlayers = 0; for (int i = 0; i < 12; i++) { if (section_data[i] == 0x05) /* user select */ { numPlayers++; } } } else if (section_name == "UNIT") { ReadUnits(section_data); } else if (section_name == "MBRF") { briefingData = new TriggerData(); briefingData.Parse(section_data, true); } else { Console.WriteLine("Unhandled Chk section type {0}, length {1}", section_name, section_data.Length); } }
void ParseSection (string section_name) { SectionData sec = sections[section_name]; if (sec == null) throw new Exception (String.Format ("map file is missing section {0}, cannot load", section_name)); if (sec.buffer == null) { stream.Position = sec.data_position; sec.buffer = new byte[sec.data_length]; stream.Read (sec.buffer, 0, (int)sec.data_length); } byte[] section_data = sec.buffer; if (section_name == "TYPE") { scenarioType = Util.ReadWord (section_data, 0); } else if (section_name == "ERA ") tileSet = (Tileset)Util.ReadWord (section_data, 0); else if (section_name == "DIM ") { width = Util.ReadWord (section_data, 0); height = Util.ReadWord (section_data, 2); } else if (section_name == "MTXM") { mapTiles = new ushort[width,height]; int y, x; for (y = 0; y < height; y ++) for (x = 0; x < width; x ++) mapTiles[x,y] = Util.ReadWord (section_data, (y*width + x)*2); } else if (section_name == "MASK") { mapMask = new byte[width,height]; int y, x; int i = 0; for (y = 0; y < height; y ++) for (x = 0; x < width; x ++) mapMask[x,y] = section_data [i++]; } else if (section_name == "SPRP") { int nameStringIndex = Util.ReadWord (section_data, 0); int descriptionStringIndex = Util.ReadWord (section_data, 2); Console.WriteLine ("mapName = {0}", nameStringIndex); Console.WriteLine ("mapDescription = {0}", descriptionStringIndex); mapName = GetMapString (nameStringIndex); mapDescription = GetMapString (descriptionStringIndex); } else if (section_name == "STR ") { ReadStrings (section_data); } else if (section_name == "OWNR") { numPlayers = 0; for (int i = 0; i < 12; i ++) { /* 00 - Unused 03 - Rescuable 05 - Computer 06 - Human 07 - Neutral */ if (section_data[i] == 0x05) numComputerSlots ++; else if (section_data[i] == 0x06) numHumanSlots ++; } } else if (section_name == "SIDE") { /* 00 - Zerg 01 - Terran 02 - Protoss 03 - Independent 04 - Neutral 05 - User Select 07 - Inactive 10 - Human */ numPlayers = 0; for (int i = 0; i < 12; i ++) { if (section_data[i] == 0x05) /* user select */ numPlayers++; } } else if (section_name == "UNIT") { ReadUnits (section_data); } else if (section_name == "MBRF") { briefingData = new TriggerData(); briefingData.Parse (section_data, true); } else Console.WriteLine ("Unhandled Chk section type {0}, length {1}", section_name, section_data.Length); }