Jump to content

Lockon mission editor util; copying units


pappavis

Recommended Posts

Hallo everyone,

 

Anyone who have made a mission for lockon in the missioneditor will know that to make such a misison one have to have very very much patience. I am working on a tool to solve that issue.

 

Objective of my tool:

Enable mission designers to copy units inclusive of their flight routes, attack points etc. so as to prevent repetitive manual labour mission edititng taks.

 

Take this scenario of a 169th_dedicated server for example:

* A red vs Blue online mission consisting of red and blue air/ground units.

* Various grond units for red side, ground units for blue side.

* Air units for red, and blue, AI or human client players.

* Blue flight departs from airbase sochi: 4*F15, 4*Su-25, 4*A10

--> red departs from Novorossisjks with a smililair configuration.

 

The daunting task as curernt mission editor:

* Create 4 F15 units, assign routes. etc. That in itself if done properly could take about 30 minutes of a misison designers time.

* Now do the same for A10, Su-25 etc etc.

* You end up begin busy maybe 4 hours to create such a mission. To most of us who have a fulltime job, a family etc thats quite a effort. No wonder people are reluctant to create new missions:mad:.

 

My solution:

A little c# windows forms application that:

* Allows a user to open a lockon .mis mission file.

* See a list of all individual flights/units of both ground, air, ship units.

* Provide the user with a inputbox, to specify how many copies he want to make of the unit.

* Allow the user to click a command button which wil create nn-number of copies of the selected unit.

* Allow the user to save this modified mission as a new lockon .mis file in the lockon .mis-format so ast to play the mission in lockon.

 

The difference will be:

* As per the 169th example, the misison designer create ONE flight of F15 then in my app do duplicate 3 times, and the same for the flight of Su-25, Su-27 etc etc, or SAM units whatever you want.

* Mission design time will be 30 minutes and not 4 or more hours.

 

The technical implementation:

* The code is written in Visual Studio.NET2003, programming language C#.

* My problem: i read the .mis file, append the units , then write the file back to lockon.mis format, but lockon wont accept the file, it complans about bad file.

* What i do to create the output file is:

---> read the source .mis file, translate XML part to XML.

---> Append the new units to the source XML.

---> Copy the first 1535 butes header into a storage byte array which is 1535 + size of new XML.

---> Write the complete byte array as binary stream to a file, with extension .mis.

 

For example:

Original total .mis filesize 23456 bytes

XML for the new units: 1000 bytes

New output file size: 24456 bytes.

 

Now the problem is, when the file is wrriten back to disk, that some bytes of the header file are mysteriously modified (by C#???). I cant know HOW it happens! I think that that is the reason why lockon will not read my ffile, coz the C# dotnet compler messes around with the byte values.

 

I made these code to:

* read a example misison file ("Su-25 Night Strike.mis") as binary.

* Get the first 1535 as binary header.

* Get the XML from a mission file such as "Su-25 Night Strike.mis".

* Append XML from a mission file to the header.

* Return a byte array, to write to file using a System.IO.Binarywriter.

 

Prob is the first 1535 bytes of the output bytes are not equal to "Su-25 Night Strike.mis". Any ideas?

 

See here belwo the program code used to append bytes, and write it back to file. Send me a email if you want the complete source code, all weighing in at 1.8Mb.

 

BTW, this post is related to this thread.

 

 

		#region Converts the XML missionfile to MIS.
	/// <summary>
	/// Converts the XML to lockon internal' MIS-fileformat.
	/// </summary>
	/// <param name="xDocToConvert">The xml missionfile source to convert.</param>
	/// <returns></returns>
	public byte[] GetXMLtoMIS(XmlDocument xDocToConvert)
	{
		byte[] bytMissionHeader = null;
		byte[] bytResult = null;

		try
		{
			string strBaseMissionName = AppDomain.CurrentDomain.BaseDirectory + @".\" + ConfigurationSettings.AppSettings["LockonMissionHeader"];
			FileStream fs = new FileStream(strBaseMissionName, FileMode.Open);
			BinaryReader brInput1 = new BinaryReader(fs);

			//Open die voorbeeld lockon .mis-bestand, zoek naar <Lockon en vervangen met eigen misison XML.
			if(brInput1 != null)
			{
				bytMissionHeader = brInput1.ReadBytes(Convert.ToInt32(brInput1.BaseStream.Length));
				int intMissionHeaderEndpos = int.Parse(ConfigurationSettings.AppSettings["MissionHeaderEndpos"]);
				byte[] bytMissionXML = Encoding.UTF8.GetBytes(xDocToConvert.OuterXml.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", ""));

				//Recerveer een deel van geheugen, hier gaat de mission file tijdelijk in worden aangemaakt.
				byte[] bytTemp1 = new byte[intMissionHeaderEndpos + bytMissionXML.Length];

				//kopieer mission header definite, van Eagle Dynamics.
				for(int intTeller = 0; intTeller < intMissionHeaderEndpos; intTeller++)
				{
					bytTemp1[intTeller] = bytMissionHeader[intTeller];
				}

				//Plak de nieuwe door gebruiker gemaakt XML achter aan die header van ED missionfile.
				int tel2 = 0;
				for(int intTeller = intMissionHeaderEndpos + 1; intTeller < intMissionHeaderEndpos + bytMissionXML.Length; intTeller++)
				{
					bytTemp1[intTeller] = bytMissionXML[tel2];
					tel2++;
				}

				bytResult = bytTemp1;
			}
		}
		catch(Exception ex)
		{
			throw new Exception(ex.Message + "; " + ex.StackTrace);
		}

		return bytResult;
	}
	#endregion

 

 

This code writes a .mis file:

public void WriteMISfile()
{
		try
		{
			byte[] bytMIS = new clsMissionFile().GetXMLtoMIS(_xDocNewMission1);

			FileStream fs = new FileStream(objSaveMap.Filename, FileMode.OpenOrCreate);
			BinaryWriter bwOutMIS = new BinaryWriter(fs);

			if(bwOutMIS != null)
			{
				for(int intMisPos = 0 ; intMisPos < bytMIS.Length; intMisPos++)
				{
					bwOutMIS.Write(bytMIS[intMisPos]);
				}
				bwOutMIS.Close();
			}
		}
		catch(Exception ex)
		{
			MessageBox.Show("Error: " + ex.Message + "; " + ex.StackTrace, _appNaam,  MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
		}

}

 

PM me then i'll send you the complete source code, all about 1.8mb.

  • Like 1

met vriendelijke groet,

Михель

 

"умный, спортсмен, комсомолетс"

 

[sIGPIC]159th_pappavis.jpg[/sIGPIC]

 

[TABLE]SPECS: i9-9900K 32gigs RAM, Geforce 2070RTX, Creative XFi Fata1ity, TIR5, Valve Index & HP Reverb, HOTAS Warthog, Logitech G933 Headset, 10Tb storage.[/TABLE]

Link to comment
Share on other sites

Hi men,

I'm not sure but i think Pat01 has already make a prog as you want to make ;-)

Try to d/l this on C6:

http://www.checksix-fr.com/bibliotheque/index.php?page=detail&ID=2773

 

Have a good evening @+

 

It doesnt work, there is an exception error: :mad:

 

Zie het einde van dit bericht voor meer informatie over het aanroepen 
van JIT-foutopsporing (Just In Time) in plaats van dit dialoogvenster.

************** Tekst van uitzondering **************
System.Runtime.InteropServices.SEHException: Een extern onderdeel heeft een uitzondering veroorzaakt.
  at _com_issue_error(Int32 )
  at _com_ptr_t<_com_IIID<IApplication,&_GUID_04a5ec8f_4878_4356_a3e1_58eb9531238d> >.->(_com_ptr_t<_com_IIID<IApplication,&_GUID_04a5ec8f_4878_4356_a3e1_58eb9531238d> >* )
  at LireObjets(TextBox textBox, CheckedListBox checkedListBox)
  at ImpExpGrpLO.Form1.button2_Click(Object sender, EventArgs e)
  at System.Windows.Forms.Control.OnClick(EventArgs e)
  at System.Windows.Forms.Button.OnClick(EventArgs e)
  at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
  at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.ButtonBase.WndProc(Message& m)
  at System.Windows.Forms.Button.WndProc(Message& m)
  at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
  at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
  at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Geladen assembly's **************
mscorlib
   Assembly-versie: 1.0.5000.0
   Win32-versie: 1.1.4322.2032
   CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------

met vriendelijke groet,

Михель

 

"умный, спортсмен, комсомолетс"

 

[sIGPIC]159th_pappavis.jpg[/sIGPIC]

 

[TABLE]SPECS: i9-9900K 32gigs RAM, Geforce 2070RTX, Creative XFi Fata1ity, TIR5, Valve Index & HP Reverb, HOTAS Warthog, Logitech G933 Headset, 10Tb storage.[/TABLE]

Link to comment
Share on other sites

Hi,

Have you installed the .NET Framework, what is your OS?

This soft was dev under WinXP SP2.

 

Have a good evening @+

 

Yes, i am software developer with dotnet 1.1 :icon_syda. My machine have both 1.1 and 2.0beta installed.

met vriendelijke groet,

Михель

 

"умный, спортсмен, комсомолетс"

 

[sIGPIC]159th_pappavis.jpg[/sIGPIC]

 

[TABLE]SPECS: i9-9900K 32gigs RAM, Geforce 2070RTX, Creative XFi Fata1ity, TIR5, Valve Index & HP Reverb, HOTAS Warthog, Logitech G933 Headset, 10Tb storage.[/TABLE]

Link to comment
Share on other sites

Hi Pappavis,

 

the missions have to be located in the LockOn mission directory. If you try to load missions that are somewhere else it leads to an exception error. It has to do with utility or files locations.

Lol, I think it's about something like that, i don't work on it for a while.

 

I could give you some source samples in VC++ .NET if you plan to write some utilities for LockOn. Please send me a personal message at check-six.com or here at LockOn.ru

 

Hope it helps.

Link to comment
Share on other sites

Sorry, I can explane...

I created a map "Zone" in D:\1C\Lockon\Missions and placed 2 missions with

name 1.mis and 2.mis in this map. When I try to compile this 2 files I get a message

Microsoft Visual C++ Runtime library

Runtime error!

Program E:\.......\CompilCampLO_ENG.exe

 

This application has requested the Runtime to terminate it in an unusual way.

Please contact the application´s support team

 

That all!

Knowlege is power!!!

Link to comment
Share on other sites

Thank you for quick responce, Pat! I don´t understand what you mean with sub directory? Here is my path D:\1C\Lock On 1.1\Missions\Zone

but I tried to place files in "Missions" and "Campaigns" directories too. Result is the same. I think that there is another problem. Group utility not work too.

Knowlege is power!!!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...