Author Topic: Game Crash With Mining Groups  (Read 3309 times)

Offline Angellus Mortis

  • Full Member
  • ***
  • Posts: 138
Game Crash With Mining Groups
« on: August 02, 2010, 07:34:45 PM »
It seems that when my AI have a set up colony and I destroy the Common Ore Smelter WHILE the mine is still online, the game crashes. I played around with everything and saw that this was in fact the cause of the error. Does this happen to anyone else? If so any ideas to fix it?
« Last Edit: August 02, 2010, 07:58:58 PM by angellus »

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Game Crash With Mining Groups
« Reply #1 on: August 02, 2010, 09:17:09 PM »
This is AI we're talking about, so I'm going to skip the question and answer session and just ask for your code.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Angellus Mortis

  • Full Member
  • ***
  • Posts: 138
Game Crash With Mining Groups
« Reply #2 on: August 02, 2010, 09:50:38 PM »
The code is correct. There is no flaw in it. I have done AI mining many times before and I have tested around and found the exact cause of the crash, but to make you happy here you go.

Code: [Select]
    scriptGlobal.B2CommonBox1 = MAP_RECT(275-1, 104-1, 286-1, 110-1);
    scriptGlobal.B2Com1 = CreateMiningGroup(ai);
    scriptGlobal.B2Com1.SetTargCount(mapCargoTruck, mapNone, 2);
  
    IUnit IUnit1;

    GroupEnumerator B2DozeEnum(scriptGlobal.B2Dozer);
    B2DozeEnum.GetNext(IUnit1);

    scriptGlobal.B2Com1.Setup(LOCATION(280-1, 109-1), LOCATION(276-1, 109-1), mapCommonOreMine, mapCommonOreSmelter, scriptGlobal.B2CommonBox1);
    scriptGlobal.B2Com1.TakeUnit(scriptGlobal.B2Truck1);
    scriptGlobal.B2Com1.TakeUnit(scriptGlobal.B2Truck2);
    IUnit1.Doze(scriptGlobal.B2CommonBox1);

Also, you may of been able to guess this, but I use HFL with IUnit. And going back and keep testing, it does not do it with multiple Common Ore Smelters.
« Last Edit: August 02, 2010, 10:06:03 PM by angellus »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Game Crash With Mining Groups
« Reply #3 on: August 02, 2010, 11:52:32 PM »
A crash address might also be helpful. Some of the AI functions seem to have limits due to static buffers, which generally aren't documented (and possibly not really known either).
 

Offline Angellus Mortis

  • Full Member
  • ***
  • Posts: 138
Game Crash With Mining Groups
« Reply #4 on: August 03, 2010, 12:48:59 AM »
No idea how to get the crash address, but like I said it does not do it with more then 2 Common Ore Smelters so it is almost impossible to do in a normal game.

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Game Crash With Mining Groups
« Reply #5 on: August 03, 2010, 02:03:44 AM »
Angellus, I kinda wanted all of your code.  Upload the .CPP and .H file(s).
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Game Crash With Mining Groups
« Reply #6 on: August 04, 2010, 12:56:53 AM »
You know, SVN is very useful for this sort of thing. Not only can someone else, such as Sirbomber, spot the problem, but once they've figured out how to fix it they can commit the change rather than just post how to do it. You can then look at a "diff" to see what exactly changed.


If the game crashes, the Windows error message box should provide some crash details. Usually it at least has a crash address. It might not label it in quite those words though.
 

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
Game Crash With Mining Groups
« Reply #7 on: August 04, 2010, 09:20:36 AM »
On Windows 7 at least (and I would assume the crash dialog for Vista is almost identical) you can click "details" on the error message where it says "Outpost 2 has stopped working" and scroll down to the entry for "crash address" or "fault offset" (I believe fault offset is the term they use). The address is the RVA from the load address of the faulting module (so VA = image base + fault offset of course)

You can get the same information in the event log, if you open the "application" log you can find entries labeled "application error" and copy the fault address and faulting module from there.

And yes, I highly recommend using SVN as opposed to copy/pasting snippets of code.