Topic: Some info regarding maps in mission scripts  (Read 2435 times)

0 Members and 1 Guest are viewing this topic.

Offline FPF-SCM_TraceyG_XC

  • Empress of the Empire
  • Commander
  • *
  • Posts: 2543
  • Gender: Female
Some info regarding maps in mission scripts
« on: December 09, 2004, 05:33:05 am »
The mapterrain selection method used in a mission script quite often combines or lumps in together several different types of terrains, eg, by using kAnyPlanet or kAnyBase and so on.
The method takes three parameters as in put, terraintype, planettype and base type. There is 27 different terrain types, 13 different base types and 6 different planet types, making a total of 27*13*6=2,106 maps.
Thats a lot of maps, mostly only about 8 or 10 different maps ever find their way into a script.

So, I decided to make a HUGE MissionMaps.cpp file which indicidually coded for every map. All 2,107 of them. It took awhile, and I had to use the /Zm option to increase the heapsize when compiling (the file was over 64,000 lines), but it did compile.

I created a single player mct file to test out this new mission, and later I would create a map with examples of all the different map types to test them out. I added the mission to the scripts directory and went to load up the game.

3 minutes later I am still waiting for the game to load up, it normally only takes 20-30 seconds on the first load, subsequent loads even less. Finally I get to the single player campaign selector, select the Mission Testing campaign now present from the newly added mct file, and click on start new game.

Again, 3 minutes later, I'm still waiting for the new game to load up. At this point I begin to become concerned something is wrong my computer. Finally I make it into the game... move my ship around till the correct mission is triggered, and select it.

The screen hangs for 3 minutes again, then finally I make it to the briefing screen. I select 'start'... another 3 minutes goes by... and finally I make it into mission.

What is going on here?? I repeated the above several times after a fresh reboot, same result. I turned off everything non-essential as much as I could, still no difference. In desperation, I uninstall OP and reload it with a fresh copy, after repatching, adding in OP+ etc. I load uo the game and success, it load in 20 seconds again. So, I place the mission back in the scripts folder (remember, this is now a clean install, no other junk anywhere), readd the mct file, and go to load up the game.

And then it happens again, I'm waiting 3 minutes for it to load.

The mission script is bigger than usual at 1.2MB, it appears that it is the script that is causing the game to take so long to load. This would only happen if the game is doing something with mission scripts when it starts, perhaps validating them or analysing them or something. The same must happen when a new campaign is started.

The odd thing is, that I have made missions that big before, yet never seen this slowing down effect. I can only conclude that the number of different of maps is having some kind of exponential effect on the processing of the mission script by the game.

I took out the mission script, and the game returned to normal.

So, it appears that while the game does have 2,106 different map combinations, it is not practically feasible to use them all. I'll investigate further to see how many maps canbe used before this slow down effect becomes noticeable.
Captain FPF-TraceyG, Federation Protection Fleet


SFC2.net Admin member
SFC3.net Admin member
Voting member of the DGA
Member of XenoCorp, Squadron Commodore

Offline Rhaz

  • Lt. Junior Grade
  • *
  • Posts: 374
Re: Some info regarding maps in mission scripts
« Reply #1 on: December 10, 2004, 08:55:08 pm »
Warning: Novice mission coder here

From your description, it sounds like the engine is allocating memory for all of the maps before the user selects the one they want to play with, instead of just pulling in the names and then loading the map as the mission starts. 

Is there a way to define a set of minimally dimensioned maps in the MissionMaps.cpp and then alter the size of the map (possible?) and add in the various map objects / terrain in the initialization code?

Rhaz

Offline FPF-SCM_TraceyG_XC

  • Empress of the Empire
  • Commander
  • *
  • Posts: 2543
  • Gender: Female
Re: Some info regarding maps in mission scripts
« Reply #2 on: December 10, 2004, 10:50:25 pm »
You can create map objects after the mission has started, however, the map sizes are set in MissionMaps.cpp

I am guessing that when the game first loads up, a table is created containing mission matching stats that include where, when, who etc. will trigger off a mission. When a new campaign is created, this table is corealted to the campaign map and another table created (possibly called the Prepared Missions list) for each hex. This has the advantage of moving some of the processing associated with the overheads of running a campaign to before the campaign starts.

It would also explain why when a mission script is removed the scripts folder during a campaign, the game appears to offer less missions. It selects the removed mission to be displayed at the mission selector, but because the mission no longer exists, no mission is offered.

So far I have tried creating a mission with 54 maps, this seems to work fine, they are all large maps too, however, I don't think the size of the map effects any preprocessing overheads.
Captain FPF-TraceyG, Federation Protection Fleet


SFC2.net Admin member
SFC3.net Admin member
Voting member of the DGA
Member of XenoCorp, Squadron Commodore