protected void ReadBattalion(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { last_move = reader.ReadUInt32(); last_combat = reader.ReadUInt32(); parent_id = new VU_ID(); parent_id.num_ = reader.ReadUInt32(); parent_id.creator_ = reader.ReadUInt32(); last_obj = new VU_ID(); last_obj.num_ = reader.ReadUInt32(); last_obj.creator_ = reader.ReadUInt32(); supply = reader.ReadByte(); fatigue = reader.ReadByte(); morale = reader.ReadByte(); heading = reader.ReadByte(); final_heading = reader.ReadByte(); if (version < 15) { dummy = reader.ReadByte(); } position = reader.ReadByte(); } }
protected void ReadCampaignBase(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { id = new VU_ID(); id.num_ = reader.ReadUInt32(); id.creator_ = reader.ReadUInt32(); entityType = reader.ReadUInt16(); x = reader.ReadInt16(); y = reader.ReadInt16(); if (version < 70) { z = 0; } else { z = reader.ReadSingle(); } spotTime = reader.ReadUInt32(); spotted = reader.ReadInt16(); baseFlags = reader.ReadInt16(); owner = reader.ReadByte(); campId = reader.ReadInt16(); } }
protected void ReadGroundUnit(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { orders = reader.ReadByte(); division = reader.ReadInt16(); aobj = new VU_ID(); aobj.num_ = reader.ReadUInt32(); aobj.creator_ = reader.ReadUInt32(); } }
public void ReadCampaignManager(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { id = new VU_ID(); id.num_ = reader.ReadUInt32(); id.creator_ = reader.ReadUInt32(); entityType = reader.ReadUInt16(); managerFlags = reader.ReadInt16(); owner = reader.ReadByte(); } }
protected void Read(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { id = new VU_ID(); id.num_ = reader.ReadUInt32(); id.creator_ = reader.ReadUInt32(); schedule = new byte[32]; for (int j = 0; j < schedule.Length; j++) { schedule[j] = reader.ReadByte(); } } }
protected void ReadBrigade(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { elements = reader.ReadByte(); element = new VU_ID[elements]; for (int i = 0; i < elements; i++) { var thisElement = new VU_ID(); thisElement.num_ = reader.ReadUInt32(); thisElement.creator_ = reader.ReadUInt32(); element[i] = thisElement; } } }
public void Read(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { haves = reader.ReadByte(); GridX = reader.ReadInt16(); GridY = reader.ReadInt16(); GridZ = reader.ReadInt16(); Arrive = reader.ReadUInt32(); Action = reader.ReadByte(); RouteAction = reader.ReadByte(); var tmp = reader.ReadByte(); Formation = (byte)(tmp & 0x0f); FormationSpacing = (short)(((tmp >> 4) & 0x0F) - 8); if (version < 72) { Flags = reader.ReadUInt16(); } else { Flags = reader.ReadUInt32(); } if ((haves & WP_HAVE_TARGET) != 0) { TargetID = new VU_ID(); TargetID.num_ = reader.ReadUInt32(); TargetID.creator_ = reader.ReadUInt32(); TargetBuilding = reader.ReadByte(); } else { TargetID = new VU_ID(); TargetBuilding = 255; } if ((haves & WP_HAVE_DEPTIME) != 0) { Depart = reader.ReadUInt32(); } else { Depart = Arrive; } } }
public void ReadUnit(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { last_check = reader.ReadUInt32(); roster = reader.ReadInt32(); unit_flags = reader.ReadInt32(); dest_x = reader.ReadInt16(); dest_y = reader.ReadInt16(); target_id = new VU_ID(); target_id.num_ = reader.ReadUInt32(); target_id.creator_ = reader.ReadUInt32(); if (version > 1) { cargo_id = new VU_ID(); cargo_id.num_ = reader.ReadUInt32(); cargo_id.creator_ = reader.ReadUInt32(); } else { cargo_id = new VU_ID(); } moved = reader.ReadByte(); losses = reader.ReadByte(); tactic = reader.ReadByte(); if (version >= 71) { current_wp = reader.ReadUInt16(); } else { current_wp = reader.ReadByte(); } name_id = reader.ReadInt16(); reinforcement = reader.ReadInt16(); DecodeWaypoints(stream, version); } }
protected void Decode(byte[] bytes, int version, short numObjectiveDeltas) { using (var stream = new MemoryStream(bytes)) using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { deltas = new ObjectiveDelta[numObjectiveDeltas]; for (int i = 0; i < numObjectiveDeltas; i++) { ObjectiveDelta thisObjectiveDelta = new ObjectiveDelta(); VU_ID id = new VU_ID(); id.num_ = reader.ReadUInt32(); id.creator_ = reader.ReadUInt32(); thisObjectiveDelta.id = id; thisObjectiveDelta.last_repair = reader.ReadUInt32(); thisObjectiveDelta.owner = reader.ReadByte(); thisObjectiveDelta.supply = reader.ReadByte(); thisObjectiveDelta.fuel = reader.ReadByte(); thisObjectiveDelta.losses = reader.ReadByte(); var numFstatus = reader.ReadByte(); thisObjectiveDelta.fStatus = new byte[numFstatus]; if (version < 64) { thisObjectiveDelta.fStatus[0] = reader.ReadByte(); } else { for (int j = 0; j < numFstatus; j++) { thisObjectiveDelta.fStatus[j] = reader.ReadByte(); } } deltas[i] = thisObjectiveDelta; } } }
protected void ReadObjective(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { lastRepair = reader.ReadUInt32(); if (version > 1) { obj_flags = reader.ReadUInt32(); } else { obj_flags = reader.ReadUInt16(); } supply = reader.ReadByte(); fuel = reader.ReadByte(); losses = reader.ReadByte(); byte numStatuses = reader.ReadByte(); fstatus = new byte[numStatuses]; for (int i = 0; i < numStatuses; i++) { fstatus[i] = reader.ReadByte(); } priority = reader.ReadByte(); nameId = reader.ReadInt16(); parent = new VU_ID(); parent.num_ = reader.ReadUInt32(); parent.creator_ = reader.ReadUInt32(); first_owner = reader.ReadByte(); links = reader.ReadByte(); if (links > 0) { link_data = new CampObjectiveLinkDataType[links]; } else { link_data = null; } for (int i = 0; i < links; i++) { CampObjectiveLinkDataType thisLink = new CampObjectiveLinkDataType(); thisLink.costs = new byte[(int)MoveType.MOVEMENT_TYPES]; for (int j = 0; j < (int)MoveType.MOVEMENT_TYPES; j++) { thisLink.costs[j] = reader.ReadByte(); } VU_ID newId = new VU_ID(); newId.num_ = reader.ReadUInt32(); newId.creator_ = reader.ReadUInt32(); thisLink.id = newId; link_data[i] = thisLink; } if (version >= 20) { byte hasRadarData = reader.ReadByte(); if (hasRadarData > 0) { detect_ratio = new float[8]; for (int i = 0; i < 8; i++) { detect_ratio[i] = reader.ReadSingle(); } } else { detect_ratio = null; } } else { detect_ratio = null; } } }
private void ReadFlight(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { z = reader.ReadSingle(); fuel_burnt = reader.ReadInt32(); if (version < 65) { fuel_burnt = 0; } last_move = reader.ReadUInt32(); last_combat = reader.ReadUInt32(); time_on_target = reader.ReadUInt32(); mission_over_time = reader.ReadUInt32(); mission_target = reader.ReadInt16(); loadouts = 0; if (version < 24) { use_loadout = 0; weapons = new byte[16]; loadouts = 1; loadout = new LoadoutStruct[loadouts]; if (version >= 8) { use_loadout = reader.ReadSByte(); if (use_loadout != 0) { LoadoutArray junk = new LoadoutArray(); junk.Stores = new LoadoutStruct[5]; for (int j = 0; j < 5; j++) { LoadoutStruct thisStore = junk.Stores[j]; thisStore.WeaponID = new ushort[16]; for (int k = 0; k < 16; k++) { thisStore.WeaponID[k] = reader.ReadByte(); } thisStore.WeaponCount = new byte[16]; for (int k = 0; k < 16; k++) { thisStore.WeaponCount[k] = reader.ReadByte(); } } loadout[0] = junk.Stores[0]; } } weapon = new short[16]; if (version < 18) { for (int j = 0; j < 16; j++) { weapon[j] = reader.ReadInt16(); } if (use_loadout == 0) { for (int j = 0; j < 16; j++) { loadout[0].WeaponID[j] = (byte)weapon[j]; } } } else { for (int j = 0; j < 16; j++) { weapon[j] = reader.ReadByte(); } if (use_loadout == 0) { for (int j = 0; j < 16; j++) { loadout[0].WeaponID[j] = (byte)weapon[j]; } } } for (int j = 0; j < 16; j++) { weapons[j] = reader.ReadByte(); } if (use_loadout == 0) { for (int j = 0; j < 16; j++) { loadout[0].WeaponCount[j] = weapons[j]; } } } else { loadouts = reader.ReadByte(); loadout = new LoadoutStruct[loadouts]; for (int j = 0; j < loadouts; j++) { LoadoutStruct thisLoadout = new LoadoutStruct(); thisLoadout.WeaponID = new ushort[16]; for (int k = 0; k < 16; k++) { if (version >= WEAPON_IDS_WIDENED_VERSION) { thisLoadout.WeaponID[k] = reader.ReadUInt16(); } else { thisLoadout.WeaponID[k] = reader.ReadByte(); } } thisLoadout.WeaponCount = new byte[16]; for (int k = 0; k < 16; k++) { thisLoadout.WeaponCount[k] = reader.ReadByte(); } loadout[j] = thisLoadout; } } mission = reader.ReadByte(); if (version > 65) { old_mission = reader.ReadByte(); } else { old_mission = mission; } last_direction = reader.ReadByte(); priority = reader.ReadByte(); mission_id = reader.ReadByte(); if (version < 14) { dummy = reader.ReadByte(); } eval_flags = reader.ReadByte(); if (version > 65) { mission_context = reader.ReadByte(); } else { mission_context = 0; } package = new VU_ID(); package.num_ = reader.ReadUInt32(); package.creator_ = reader.ReadUInt32(); squadron = new VU_ID(); squadron.num_ = reader.ReadUInt32(); squadron.creator_ = reader.ReadUInt32(); if (version > 65) { requester = new VU_ID(); requester.num_ = reader.ReadUInt32(); requester.creator_ = reader.ReadUInt32(); } else { requester = new VU_ID(); } slots = new byte[4]; for (int j = 0; j < 4; j++) { slots[j] = reader.ReadByte(); } pilots = new byte[4]; for (int j = 0; j < 4; j++) { pilots[j] = reader.ReadByte(); } plane_stats = new byte[4]; for (int j = 0; j < 4; j++) { plane_stats[j] = reader.ReadByte(); } player_slots = new byte[4]; for (int j = 0; j < 4; j++) { player_slots[j] = reader.ReadByte(); } last_player_slot = reader.ReadByte(); callsign_id = reader.ReadByte(); callsign_num = reader.ReadByte(); if (version >= 72) { refuelQuantity = reader.ReadUInt32(); } else { refuelQuantity = 0; } } }
protected void ReadPackage(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { elements = reader.ReadByte(); element = new VU_ID[elements]; for (int i = 0; i < elements; i++) { VU_ID thisElement = new VU_ID(); thisElement.num_ = reader.ReadUInt32(); thisElement.creator_ = reader.ReadUInt32(); element[i] = thisElement; } interceptor = new VU_ID(); interceptor.num_ = reader.ReadUInt32(); interceptor.creator_ = reader.ReadUInt32(); if (version >= 7) { awacs = new VU_ID(); awacs.num_ = reader.ReadUInt32(); awacs.creator_ = reader.ReadUInt32(); jstar = new VU_ID(); jstar.num_ = reader.ReadUInt32(); jstar.creator_ = reader.ReadUInt32(); ecm = new VU_ID(); ecm.num_ = reader.ReadUInt32(); ecm.creator_ = reader.ReadUInt32(); tanker = new VU_ID(); tanker.num_ = reader.ReadUInt32(); tanker.creator_ = reader.ReadUInt32(); } wait_cycles = reader.ReadByte(); mis_request = new MissionRequest(); if (Final && wait_cycles == 0) { requests = reader.ReadInt16(); if (version < 35) { threat_stats = reader.ReadInt16(); } responses = reader.ReadInt16(); mis_request.mission = (byte)reader.ReadInt16(); mis_request.context = (byte)reader.ReadInt16(); mis_request.requesterID = new VU_ID(); mis_request.requesterID.num_ = reader.ReadUInt32(); mis_request.requesterID.creator_ = reader.ReadUInt32(); mis_request.targetID = new VU_ID(); mis_request.targetID.num_ = reader.ReadUInt32(); mis_request.targetID.creator_ = reader.ReadUInt32(); if (version >= 26) { mis_request.tot = reader.ReadUInt32(); } else if (version >= 16) { mis_request.tot = reader.ReadUInt32(); } if (version >= 35) { mis_request.action_type = reader.ReadByte(); } else { mis_request.action_type = 0; } if (version >= 41) { mis_request.priority = reader.ReadInt16(); } else { mis_request.priority = 1; } package_flags = 0; } else { flights = reader.ReadByte(); wait_for = reader.ReadInt16(); iax = reader.ReadInt16(); iay = reader.ReadInt16(); eax = reader.ReadInt16(); eay = reader.ReadInt16(); bpx = reader.ReadInt16(); bpy = reader.ReadInt16(); tpx = reader.ReadInt16(); tpy = reader.ReadInt16(); takeoff = reader.ReadUInt32(); tp_time = reader.ReadUInt32(); package_flags = reader.ReadUInt32(); caps = reader.ReadInt16(); requests = reader.ReadInt16(); if (version < 35) { threat_stats = reader.ReadInt16(); } responses = reader.ReadInt16(); num_ingress_waypoints = reader.ReadByte(); ingress_waypoints = new Waypoint[num_ingress_waypoints]; for (int j = 0; j < num_ingress_waypoints; j++) { ingress_waypoints[j] = new Waypoint(stream, version); } num_egress_waypoints = reader.ReadByte(); egress_waypoints = new Waypoint[num_egress_waypoints]; for (int j = 0; j < num_egress_waypoints; j++) { egress_waypoints[j] = new Waypoint(stream, version); } mis_request.requesterID = new VU_ID(); mis_request.requesterID.num_ = reader.ReadUInt32(); mis_request.requesterID.creator_ = reader.ReadUInt32(); mis_request.targetID = new VU_ID(); mis_request.targetID.num_ = reader.ReadUInt32(); mis_request.targetID.creator_ = reader.ReadUInt32(); mis_request.secondaryID = new VU_ID(); mis_request.secondaryID.num_ = reader.ReadUInt32(); mis_request.secondaryID.creator_ = reader.ReadUInt32(); mis_request.pakID = new VU_ID(); mis_request.pakID.num_ = reader.ReadUInt32(); mis_request.pakID.creator_ = reader.ReadUInt32(); mis_request.who = reader.ReadByte(); mis_request.vs = reader.ReadByte(); reader.ReadBytes(2); //align on int32 boundary mis_request.tot = reader.ReadUInt32(); mis_request.tx = reader.ReadInt16(); mis_request.ty = reader.ReadInt16(); mis_request.flags = reader.ReadUInt32(); mis_request.caps = reader.ReadInt16(); mis_request.target_num = reader.ReadInt16(); mis_request.speed = reader.ReadInt16(); mis_request.match_strength = reader.ReadInt16(); mis_request.priority = reader.ReadInt16(); mis_request.tot_type = reader.ReadByte(); mis_request.action_type = reader.ReadByte(); mis_request.mission = reader.ReadByte(); mis_request.aircraft = reader.ReadByte(); mis_request.context = reader.ReadByte(); mis_request.roe_check = reader.ReadByte(); if (!(version < 35)) { mis_request.delayed = reader.ReadByte(); mis_request.start_block = reader.ReadByte(); mis_request.final_block = reader.ReadByte(); mis_request.slots = new byte[4]; for (int k = 0; k < 4; k++) { mis_request.slots[k] = reader.ReadByte(); } mis_request.min_to = reader.ReadSByte(); mis_request.max_to = reader.ReadSByte(); reader.ReadBytes(3);// align on int32 boundary } } } }
protected void Decode(byte[] bytes) { using (var stream = new MemoryStream(bytes)) using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { int nullLoc = 0; CurrentTime = reader.ReadUInt32(); if (CurrentTime == 0) { CurrentTime = 1; } if (_version >= 48) { TE_StartTime = reader.ReadUInt32(); TE_TimeLimit = reader.ReadUInt32(); if (_version >= 49) { TE_VictoryPoints = reader.ReadInt32(); } else { TE_VictoryPoints = 0; } } else { TE_StartTime = CurrentTime; TE_TimeLimit = CurrentTime + (60 * 60 * 5 * 1000); TE_VictoryPoints = 0; } if (_version >= 52) { TE_Type = reader.ReadInt32(); TE_number_teams = reader.ReadInt32(); for (int i = 0; i < 8; i++) { TE_number_aircraft[i] = reader.ReadInt32(); } for (int i = 0; i < 8; i++) { TE_number_f16s[i] = reader.ReadInt32(); } TE_team = reader.ReadInt32(); for (int i = 0; i < 8; i++) { TE_team_pts[i] = reader.ReadInt32(); } TE_flags = reader.ReadInt32(); nullLoc = 0; for (int i = 0; i < 8; i++) { TeamBasicInfo info = new TeamBasicInfo(); info.teamFlag = reader.ReadByte(); info.teamColor = reader.ReadByte(); var teamNameBytes = reader.ReadBytes(20); info.teamName = Encoding.ASCII.GetString(teamNameBytes, 0, 20); nullLoc = info.teamName.IndexOf('\0'); if (nullLoc > -1) { info.teamName = info.teamName.Substring(0, nullLoc); } var teamMottoBytes = reader.ReadBytes(200); info.teamMotto = Encoding.ASCII.GetString(teamMottoBytes, 0, 200); nullLoc = info.teamMotto.IndexOf('\0'); if (nullLoc > -1) { info.teamMotto = info.teamMotto.Substring(0, nullLoc); } this.TeamBasicInfo[i] = info; } } else { TE_Type = 0; TE_number_teams = 0; TE_number_aircraft = new int[8]; TE_number_f16s = new int[8]; TE_team = 0; TE_team_pts = new int[8]; TE_flags = 0; } if (_version >= 19) { lastMajorEvent = reader.ReadUInt32(); } lastResupply = reader.ReadUInt32(); lastRepair = reader.ReadUInt32(); lastReinforcement = reader.ReadUInt32(); this.TimeStamp = reader.ReadInt16(); Group = reader.ReadInt16(); GroundRatio = reader.ReadInt16(); AirRatio = reader.ReadInt16(); AirDefenseRatio = reader.ReadInt16(); NavalRatio = reader.ReadInt16(); Brief = reader.ReadInt16(); TheaterSizeX = reader.ReadInt16(); TheaterSizeY = reader.ReadInt16(); CurrentDay = reader.ReadByte(); ActiveTeams = reader.ReadByte(); DayZero = reader.ReadByte(); EndgameResult = reader.ReadByte(); Situation = reader.ReadByte(); EnemyAirExp = reader.ReadByte(); EnemyADExp = reader.ReadByte(); BullseyeName = reader.ReadByte(); BullseyeX = reader.ReadInt16(); BullseyeY = reader.ReadInt16(); var theaterNameBytes = reader.ReadBytes(40); TheaterName = Encoding.ASCII.GetString(theaterNameBytes, 0, 40); nullLoc = TheaterName.IndexOf('\0'); if (nullLoc > -1) { TheaterName = TheaterName.Substring(0, nullLoc); } var scenarioBytes = reader.ReadBytes(40); Scenario = Encoding.ASCII.GetString(scenarioBytes, 0, 40); nullLoc = Scenario.IndexOf('\0'); if (nullLoc > -1) { Scenario = Scenario.Substring(0, nullLoc); } var saveFileBytes = reader.ReadBytes(40); SaveFile = Encoding.ASCII.GetString(saveFileBytes, 0, 40); nullLoc = SaveFile.IndexOf('\0'); if (nullLoc > -1) { SaveFile = SaveFile.Substring(0, nullLoc); } var uiNameBytes = reader.ReadBytes(40); UIName = Encoding.ASCII.GetString(uiNameBytes, 0, 40); nullLoc = UIName.IndexOf('\0'); if (nullLoc > -1) { UIName = UIName.Substring(0, nullLoc); } VU_ID squadronId = new VU_ID(); squadronId.num_ = reader.ReadUInt32(); squadronId.creator_ = reader.ReadUInt32(); PlayerSquadronID = squadronId; NumRecentEventEntries = reader.ReadInt16(); if (NumRecentEventEntries > 0) { RecentEventEntries = new EventNode[NumRecentEventEntries]; for (int i = 0; i < NumRecentEventEntries; i++) { EventNode thisNode = new EventNode(); thisNode.x = reader.ReadInt16(); thisNode.y = reader.ReadInt16(); thisNode.time = reader.ReadUInt32(); thisNode.flags = reader.ReadByte(); thisNode.Team = reader.ReadByte(); reader.ReadBytes(2); //align on int32 boundary //skip EventText pointer reader.ReadBytes(4); //skip UiEventNode pointer reader.ReadBytes(4); short eventTextSize = reader.ReadInt16(); var eventTextBytes = reader.ReadBytes(eventTextSize); string eventText = Encoding.ASCII.GetString(eventTextBytes, 0, eventTextSize); nullLoc = eventText.IndexOf('\0'); if (nullLoc > -1) { eventText = eventText.Substring(0, nullLoc); } thisNode.eventText = eventText; RecentEventEntries[i] = thisNode; } } NumPriorityEventEntries = reader.ReadInt16(); if (NumPriorityEventEntries > 0) { PriorityEventEntries = new EventNode[NumPriorityEventEntries]; for (int i = 0; i < NumPriorityEventEntries; i++) { EventNode thisNode = new EventNode(); thisNode.x = reader.ReadInt16(); thisNode.y = reader.ReadInt16(); thisNode.time = reader.ReadUInt32(); thisNode.flags = reader.ReadByte(); thisNode.Team = reader.ReadByte(); reader.ReadBytes(2); //align on int32 boundary //skip EventText pointer reader.ReadBytes(4); //skip UiEventNode pointer reader.ReadBytes(4); short eventTextSize = reader.ReadInt16(); var eventTextBytes = reader.ReadBytes(eventTextSize); string eventText = Encoding.ASCII.GetString(eventTextBytes, 0, eventTextSize); nullLoc = eventText.IndexOf('\0'); if (nullLoc > -1) { eventText = eventText.Substring(0, nullLoc); } thisNode.eventText = eventText; PriorityEventEntries[i] = thisNode; } } CampMapSize = reader.ReadInt16(); if (CampMapSize > 0) { CampMap = reader.ReadBytes(CampMapSize); } LastIndexNum = reader.ReadInt16(); NumAvailableSquadrons = reader.ReadInt16(); if (NumAvailableSquadrons > 0) { if (_version < 42) { SquadInfo = new SquadInfo[NumAvailableSquadrons]; for (int i = 0; i < NumAvailableSquadrons; i++) { SquadInfo thisSquadInfo = new SquadInfo(); thisSquadInfo.x = reader.ReadSingle(); thisSquadInfo.y = reader.ReadSingle(); VU_ID thisSquadId = new VU_ID(); thisSquadId.num_ = reader.ReadUInt32(); thisSquadId.creator_ = reader.ReadUInt32(); thisSquadInfo.id = thisSquadId; thisSquadInfo.descriptionIndex = reader.ReadInt16(); thisSquadInfo.nameId = reader.ReadInt16(); thisSquadInfo.specialty = reader.ReadByte(); thisSquadInfo.currentStrength = reader.ReadByte(); thisSquadInfo.country = reader.ReadByte(); var airbaseNameBytes = reader.ReadBytes(80); thisSquadInfo.airbaseName = Encoding.ASCII.GetString(airbaseNameBytes, 0, 80); nullLoc = thisSquadInfo.airbaseName.IndexOf('\0'); if (nullLoc > -1) { thisSquadInfo.airbaseName = thisSquadInfo.airbaseName.Substring(0, nullLoc); } reader.ReadByte(); //align on int32 boundary SquadInfo[i] = thisSquadInfo; } } else { SquadInfo = new SquadInfo[NumAvailableSquadrons]; for (int i = 0; i < NumAvailableSquadrons; i++) { SquadInfo thisSquadInfo = new SquadInfo(); thisSquadInfo.x = reader.ReadSingle(); thisSquadInfo.y = reader.ReadSingle(); VU_ID thisSquadId = new VU_ID(); thisSquadId.num_ = reader.ReadUInt32(); thisSquadId.creator_ = reader.ReadUInt32(); thisSquadInfo.id = thisSquadId; thisSquadInfo.descriptionIndex = reader.ReadInt16(); thisSquadInfo.nameId = reader.ReadInt16(); thisSquadInfo.airbaseIcon = reader.ReadInt16(); thisSquadInfo.squadronPath = reader.ReadInt16(); thisSquadInfo.specialty = reader.ReadByte(); thisSquadInfo.currentStrength = reader.ReadByte(); thisSquadInfo.country = reader.ReadByte(); var airbaseNameBytes = reader.ReadBytes(40); thisSquadInfo.airbaseName = Encoding.ASCII.GetString(airbaseNameBytes, 0, 40); nullLoc = thisSquadInfo.airbaseName.IndexOf('\0'); if (nullLoc > -1) { thisSquadInfo.airbaseName = thisSquadInfo.airbaseName.Substring(0, nullLoc); } reader.ReadByte(); //align on int32 boundary SquadInfo[i] = thisSquadInfo; } } } if (_version >= 31) { Tempo = reader.ReadByte(); } if (_version >= 43) { CreatorIP = reader.ReadInt32(); CreationTime = reader.ReadInt32(); CreationRand = reader.ReadInt32(); } } }
protected void Read(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { id = new VU_ID(); id.num_ = reader.ReadUInt32(); id.creator_ = reader.ReadUInt32(); entityType = reader.ReadUInt16(); who = reader.ReadByte(); cteam = reader.ReadByte(); flags = reader.ReadInt16(); if (version > 2) { member = new byte[8]; for (int j = 0; j < member.Length; j++) { member[j] = reader.ReadByte(); } stance = new short[8]; for (int j = 0; j < stance.Length; j++) { stance[j] = reader.ReadInt16(); } } else { member = new byte[8]; for (int j = 0; j < 7; j++) { member[j] = reader.ReadByte(); } stance = new short[8]; for (int j = 0; j < 7; j++) { stance[j] = reader.ReadInt16(); } } firstColonel = reader.ReadInt16(); firstCommander = reader.ReadInt16(); firstWingman = reader.ReadInt16(); lastWingman = reader.ReadInt16(); playerRating = 0.0F; lastPlayerMission = 0; if (version > 11) { airExperience = reader.ReadByte(); airDefenseExperience = reader.ReadByte(); groundExperience = reader.ReadByte(); navalExperience = reader.ReadByte(); } else { reader.ReadBytes(4); airExperience = 80; airDefenseExperience = 80; groundExperience = 80; navalExperience = 80; } initiative = reader.ReadInt16(); supplyAvail = reader.ReadUInt16(); fuelAvail = reader.ReadUInt16(); if (version > 53) { replacementsAvail = reader.ReadUInt16(); playerRating = reader.ReadSingle(); lastPlayerMission = reader.ReadUInt32(); } else { replacementsAvail = 0; playerRating = 0.0f; lastPlayerMission = 0; } if (version < 40) { reader.ReadBytes(4); } currentStats = new TeamStatus(); currentStats.airDefenseVehs = reader.ReadUInt16(); currentStats.aircraft = reader.ReadUInt16(); currentStats.groundVehs = reader.ReadUInt16(); currentStats.ships = reader.ReadUInt16(); currentStats.supply = reader.ReadUInt16(); currentStats.fuel = reader.ReadUInt16(); currentStats.airbases = reader.ReadUInt16(); currentStats.supplyLevel = reader.ReadByte(); currentStats.fuelLevel = reader.ReadByte(); startStats = new TeamStatus(); startStats.airDefenseVehs = reader.ReadUInt16(); startStats.aircraft = reader.ReadUInt16(); startStats.groundVehs = reader.ReadUInt16(); startStats.ships = reader.ReadUInt16(); startStats.supply = reader.ReadUInt16(); startStats.fuel = reader.ReadUInt16(); startStats.airbases = reader.ReadUInt16(); startStats.supplyLevel = reader.ReadByte(); startStats.fuelLevel = reader.ReadByte(); reinforcement = reader.ReadInt16(); bonusObjs = new VU_ID[20]; for (int j = 0; j < bonusObjs.Length; j++) { VU_ID thisId = new VU_ID(); thisId.num_ = reader.ReadUInt32(); thisId.creator_ = reader.ReadUInt32(); bonusObjs[j] = thisId; } bonusTime = new uint[20]; for (int j = 0; j < bonusTime.Length; j++) { bonusTime[j] = reader.ReadUInt32(); } objtype_priority = new byte[36]; for (int j = 0; j < objtype_priority.Length; j++) { objtype_priority[j] = reader.ReadByte(); } unittype_priority = new byte[20]; for (int j = 0; j < unittype_priority.Length; j++) { unittype_priority[j] = reader.ReadByte(); } if (version < 30) { mission_priority = new byte[40]; for (int j = 0; j < mission_priority.Length; j++) { mission_priority[j] = reader.ReadByte(); } } else { mission_priority = new byte[41]; for (int j = 0; j < mission_priority.Length; j++) { mission_priority[j] = reader.ReadByte(); } } if (version < 34) { attackTime = reader.ReadUInt32(); offensiveLoss = reader.ReadByte(); } max_vehicle = new byte[4]; for (int j = 0; j < max_vehicle.Length; j++) { max_vehicle[j] = reader.ReadByte(); } int nullLoc = 0; if (version > 4) { teamFlag = reader.ReadByte(); if (version > 32) { teamColor = reader.ReadByte(); } else { teamColor = 0; } equipment = reader.ReadByte(); var nameBytes = reader.ReadBytes(20); name = Encoding.ASCII.GetString(nameBytes, 0, 20); nullLoc = name.IndexOf('\0'); if (nullLoc > 0) { name = name.Substring(0, nullLoc); } else { name = String.Empty; } } if (version > 32) { var mottoBytes = reader.ReadBytes(200); teamMotto = Encoding.ASCII.GetString(mottoBytes, 0, 200); nullLoc = teamMotto.IndexOf('\0'); if (nullLoc > 0) { teamMotto = teamMotto.Substring(0, nullLoc); } else { teamMotto = string.Empty; } } else { teamMotto = string.Empty; } if (version > 33) { if (version > 50) { groundAction = new TeamGndActionType(); groundAction.actionTime = reader.ReadUInt32(); groundAction.actionTimeout = reader.ReadUInt32(); groundAction.actionObjective = new VU_ID(); groundAction.actionObjective.num_ = reader.ReadUInt32(); groundAction.actionObjective.creator_ = reader.ReadUInt32(); groundAction.actionType = reader.ReadByte(); groundAction.actionTempo = reader.ReadByte(); groundAction.actionPoints = reader.ReadByte(); } else if (version > 41) { reader.ReadBytes(27); groundAction = new TeamGndActionType(); } else { reader.ReadBytes(23); groundAction = new TeamGndActionType(); } defensiveAirAction = new TeamAirActionType(); defensiveAirAction.actionStartTime = reader.ReadUInt32(); defensiveAirAction.actionStopTime = reader.ReadUInt32(); defensiveAirAction.actionObjective = new VU_ID(); defensiveAirAction.actionObjective.num_ = reader.ReadUInt32(); defensiveAirAction.actionObjective.creator_ = reader.ReadUInt32(); defensiveAirAction.lastActionObjective = new VU_ID(); defensiveAirAction.lastActionObjective.num_ = reader.ReadUInt32(); defensiveAirAction.lastActionObjective.creator_ = reader.ReadUInt32(); defensiveAirAction.actionType = reader.ReadByte(); reader.ReadBytes(3); //align on int32 boundary offensiveAirAction = new TeamAirActionType(); offensiveAirAction.actionStartTime = reader.ReadUInt32(); offensiveAirAction.actionStopTime = reader.ReadUInt32(); offensiveAirAction.actionObjective = new VU_ID(); offensiveAirAction.actionObjective.num_ = reader.ReadUInt32(); offensiveAirAction.actionObjective.creator_ = reader.ReadUInt32(); offensiveAirAction.lastActionObjective = new VU_ID(); offensiveAirAction.lastActionObjective.num_ = reader.ReadUInt32(); offensiveAirAction.lastActionObjective.creator_ = reader.ReadUInt32(); offensiveAirAction.actionType = reader.ReadByte(); reader.ReadBytes(3); //align on int32 boundary } else { groundAction = new TeamGndActionType(); defensiveAirAction = new TeamAirActionType(); offensiveAirAction = new TeamAirActionType(); } if (version < 43) { groundAction.actionType = 2; supplyAvail = fuelAvail = 1000; } if (version < 51) { if (who == (byte)CountryListEnum.COUN_RUSSIA) { firstColonel = 500; firstCommander = 505; firstWingman = 538; lastWingman = 583; } else if (who == (byte)CountryListEnum.COUN_CHINA) { firstColonel = 600; firstCommander = 605; firstWingman = 639; lastWingman = 686; } else if (who == (byte)CountryListEnum.COUN_US) { firstColonel = 0; firstCommander = 20; firstWingman = 149; lastWingman = 373; } else { firstColonel = 400; firstCommander = 408; firstWingman = 460; lastWingman = 499; } } } }
private void ReadSquadron(Stream stream, int version) { using (var reader = new BinaryReader(stream, Encoding.Default, leaveOpen: true)) { fuel = reader.ReadInt32(); specialty = reader.ReadByte(); if (version < 69) { stores = new byte[200]; for (int i = 0; i < 200; i++) { stores[i] = reader.ReadByte(); } } else if (version < 72) { stores = new byte[220]; for (int i = 0; i < 220; i++) { stores[i] = reader.ReadByte(); } } else { stores = new byte[600]; for (int i = 0; i < 600; i++) { stores[i] = reader.ReadByte(); } } if (version < 47) { if (version >= 29) { pilots = new Pilot[48]; for (int j = 0; j < pilots.Length; j++) { Pilot thisPilot = new Pilot(); thisPilot.pilot_id = reader.ReadInt16(); thisPilot.pilot_skill_and_rating = reader.ReadByte(); thisPilot.pilot_status = reader.ReadByte(); thisPilot.aa_kills = reader.ReadByte(); thisPilot.ag_kills = reader.ReadByte(); thisPilot.as_kills = reader.ReadByte(); thisPilot.an_kills = reader.ReadByte(); /* * p.missions_flown = reader.ReadInt16(); */ pilots[j] = thisPilot; } } else { pilots = new Pilot[36]; for (int j = 0; j < pilots.Length; j++) { Pilot thisPilot = new Pilot(); thisPilot.pilot_id = reader.ReadInt16(); thisPilot.pilot_skill_and_rating = reader.ReadByte(); thisPilot.pilot_status = reader.ReadByte(); thisPilot.aa_kills = reader.ReadByte(); thisPilot.ag_kills = reader.ReadByte(); thisPilot.as_kills = reader.ReadByte(); thisPilot.an_kills = reader.ReadByte(); /* * p.missions_flown = reader.ReadInt16(); */ pilots[j] = thisPilot; } } } else { pilots = new Pilot[48]; for (int j = 0; j < pilots.Length; j++) { Pilot thisPilot = new Pilot(); thisPilot.pilot_id = reader.ReadInt16(); thisPilot.pilot_skill_and_rating = reader.ReadByte(); thisPilot.pilot_status = reader.ReadByte(); thisPilot.aa_kills = reader.ReadByte(); thisPilot.ag_kills = reader.ReadByte(); thisPilot.as_kills = reader.ReadByte(); thisPilot.an_kills = reader.ReadByte(); thisPilot.missions_flown = reader.ReadInt16(); pilots[j] = thisPilot; } } schedule = new int[16]; for (int j = 0; j < schedule.Length; j++) { schedule[j] = reader.ReadInt32(); } airbase_id = new VU_ID(); airbase_id.num_ = reader.ReadUInt32(); airbase_id.creator_ = reader.ReadUInt32(); hot_spot = new VU_ID(); hot_spot.num_ = reader.ReadUInt32(); hot_spot.creator_ = reader.ReadUInt32(); if (version >= 6 && version < 16) { junk = new VU_ID(); junk.num_ = reader.ReadUInt32(); junk.creator_ = reader.ReadUInt32(); } rating = new byte[16]; for (int j = 0; j < rating.Length; j++) { rating[j] = reader.ReadByte(); } aa_kills = reader.ReadInt16(); ag_kills = reader.ReadInt16(); as_kills = reader.ReadInt16(); an_kills = reader.ReadInt16(); missions_flown = reader.ReadInt16(); mission_score = reader.ReadInt16(); total_losses = reader.ReadByte(); if (version >= 9) { pilot_losses = reader.ReadByte(); } else { pilot_losses = 0; } if (version >= 45) { squadron_patch = reader.ReadByte(); } } }