Author Topic: Strange Problem  (Read 2324 times)

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Strange Problem
« on: May 18, 2009, 10:32:14 AM »
So here's the problem.  I've got a rare ore mining beacon and a Rare Ore Mine created right on top of it.  The mine works fine, but for some reason the mining beacon isn't getting marked as surveyed:



Yes, Rare Ore Processing is researched.

Any ideas what I can do to fix this?
"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
Strange Problem
« Reply #1 on: May 18, 2009, 01:47:45 PM »
Is it possible you've got two mining beacons placed over that spot?

Can you post any sample code that can demonstrate this issue?
 

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Strange Problem
« Reply #2 on: May 18, 2009, 02:22:40 PM »
Mining beacons so far:
Code: [Select]
void SetupMines()
{
    // Player 1
    TethysGame::CreateBeacon(mapMiningBeacon, 161, 77, 0, 1, -1);          // Common Ore Mine #1
    TethysGame::CreateBeacon(mapMiningBeacon, 135, 27, 0, 2, -1);          // Common Ore Mine #2

    TethysGame::CreateBeacon(mapMiningBeacon,  88, 40, 1, 1, -1);          // Rare Ore Mine #1
    TethysGame::CreateBeacon(mapMiningBeacon, 120, 97, 1, 2, -1);          // Rare Ore Mine #2

    TethysGame::CreateBeacon(mapFumarole, 127, 100, -1, -1, -1);           // Fumarole #1
    TethysGame::CreateBeacon(mapFumarole,  57,  54, -1, -1, -1);           // Fumarole #2

    TethysGame::CreateBeacon(mapMagmaVent, 118, 8, -1, -1, -1);            // Magma Vent #1

    // Player 2
    TethysGame::CreateBeacon(mapMiningBeacon, 294, 109, 0, 0, -1);         // Common Ore Mine #1
    TethysGame::CreateBeacon(mapMiningBeacon, 286, 149, 0, 0, -1);         // Common Ore Mine #2

    TethysGame::CreateBeacon(mapFumarole, 287, 123, -1, -1, -1);           // Fumarole #1
}

Player 1 Setup:
Code: [Select]
void SetupPlayer1()
{
    short i = 0;
    Unit Unit1;

    Player[i].GoPlymouth();

    // Give Techs
    Player[i].SetTechLevel(4);
    Player[i].MarkResearchComplete(5110);   // Rare Ore Extraction
    Player[i].MarkResearchComplete(5111);   // Independent Turret Power Systems
    Player[i].MarkResearchComplete(5601);   // Heat Dissipation Systems (Plymouth)
    Player[i].MarkResearchComplete(5201);   // Advanced Combat Chassis
    Player[i].MarkResearchComplete(5405);   // Space Program
    Player[i].MarkResearchComplete(5310);   // Hypnopaedia (Plymouth)
    Player[i].MarkResearchComplete(5508);   // Electromagnetic Pulsing
    Player[i].MarkResearchComplete(5599);   // Rocket Propulsion
    Player[i].MarkResearchComplete(7102);   // Explosive Charges
    Player[i].MarkResearchComplete(5202);   // Dissipating Adhesives
    Player[i].MarkResearchComplete(5052);   // Robot-Assist Mechanic (Plymouth)
    Player[i].MarkResearchComplete(5107);   // Magnetohydrodynamics
...
TethysGame::CreateUnit(Unit1, mapRareOreMine, LOCATION(88, 40), i, mapNone, 0);
...

In InitProc, SetupMines is called before player setup stuff is.
"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 Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Strange Problem
« Reply #3 on: May 30, 2009, 11:20:10 AM »
More problems...  This code seems to crash:
Code: [Select]
// Garage 1 Units
    TethysGame::CreateUnit(Unit1, mapPanther, LOCATION(280, 143), i, mapThorsHammer, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(0, 280, 143);
    TethysGame::CreateUnit(Unit1, mapPanther, LOCATION(280, 143), i, mapAcidCloud, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(1, 280, 143);
    TethysGame::CreateUnit(Unit1, mapLynx, LOCATION(280, 143), i, mapEMP, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(2, 280, 143);
    TethysGame::CreateUnit(Unit1, mapLynx, LOCATION(280, 143), i, mapEMP, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(3, 280, 143);
    TethysGame::CreateUnit(Unit1, mapLynx, LOCATION(280, 143), i, mapEMP, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(4, 280, 143);
    TethysGame::CreateUnit(Unit1, mapLynx, LOCATION(280, 143), i, mapRailGun, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(5, 280, 143);

    // Garage 2 Units
    TethysGame::CreateUnit(Unit1, mapPanther, LOCATION(287, 131), i, mapLaser, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(0, 287, 131);
    TethysGame::CreateUnit(Unit1, mapPanther, LOCATION(287, 131), i, mapEMP, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(1, 287, 131);
    TethysGame::CreateUnit(Unit1, mapLynx, LOCATION(287, 131), i, mapRailGun, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(2, 287, 131);
    TethysGame::CreateUnit(Unit1, mapLynx, LOCATION(287, 131), i, mapLaser, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(3, 287, 131);
    TethysGame::CreateUnit(Unit1, mapLynx, LOCATION(287, 131), i, mapLaser, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(4, 287, 131);
    TethysGame::CreateUnit(Unit1, mapLynx, LOCATION(287, 131), i, mapStarflare, 0);
        Unit1.DoSetLights(1);
        Unit1.PutInGarage(5, 287, 131);

I can't figure out why this keeps crashing.  I pretty much copied/pasted code that worked and edited the locations, so by all accounts it should...  (Yes, there are Garages at those locations.)
"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
Strange Problem
« Reply #4 on: May 31, 2009, 03:55:06 PM »
Ok, first you must create the garage. Then you create the vehicle on the dock of the garage. Keep in mind that both units could move a few tiles if you try to create them on impassable terrain. This is probably a bigger issue for the garage, as trying to place a unit on top of the garage usually just moves the vehicle onto the dock. Then call vehicle.PutInGarage, giving it a coordinate of a tile belonging to the garage, *excluding the dock*. The dock is not considered part of the garage. It must be one of the impassable garage tiles.

As far as I can tell, any impassable garage tile will work. Using the coordinates of the dock will cause the game to crash. If the unit is not on the dock, then it won't be placed in the garage (but the game won't crash either, as long as the garage coordinate is a valid non-dock tile).

Checking e01.dll, I noticed the game offsets the x-coordinate by 1 when placing the unit in the garage from the coordinates used when creating the garage. Just keep in mind that the dock tile moves between Eden and Plymouth. It might be wise to choose the coordinate offset such that it is valid for either colony type, just in case you want to change the colony type at some point in development. (Perhaps for testing, or perhaps for a spinoff level).
 

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Strange Problem
« Reply #5 on: May 31, 2009, 04:11:31 PM »
Ah, the dock results in crashy BLARUGHage?  That'd be it then; Player 1 is Plymouth and Player 2 is Eden.  Thanks.
"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
Strange Problem
« Reply #6 on: May 31, 2009, 04:33:17 PM »
As for your first problem, I suspect that creating rare ore mines like that might not be supported. I'm seeing some special cased code for common ore mines and geothermal plants, but nothing specific for rare ore mines (or magma vent mines).

Oddly enough, if you create a rare ore beacon, and then place a common ore mine over it, you will get a rare ore mine. It's actually titled rare ore mine, and does indeed dispense rare ore.

I suspect this is just a bug in the original game that was never caught because they never tried to create rare ore mines like that.


Edit: Of course, when I tried the rare ore mine, it just crashed on me. I didn't get a mine without it being surveyed.

Btw, a complete (small sample) project (or at least main.cpp) demonstrating the issue here could be helpful. Some of the issues I had were using too small of a map to contain all the units you were creating, or having things created over a ridge. At least knowing what map the code was made for would have been useful.
 
« Last Edit: May 31, 2009, 04:35:45 PM by Hooman »

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Strange Problem
« Reply #7 on: May 31, 2009, 06:39:51 PM »
I'm using Axen's Home, and what you said fixed the problem.  No ridges were in the way or anything.

And how can creating rare ore mines like that NOT be supported?  The campaigns do it all the time...

Edit: Well, in case we can't figure out a solution, is there a way for players to start with EDWARD Satellites?
« Last Edit: May 31, 2009, 06:40:26 PM by Sirbomber »
"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 Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Strange Problem
« Reply #8 on: June 10, 2009, 10:56:21 AM »
You'll all be pleased to know we've reached a new all-time low for random OP2 crashes:

Code: [Select]
    TethysGame::CreateUnit(Unit1, mapGarage,LOCATION(373, 40), i, mapNone, 0);
        Unit1.DoIdle();

That's right boys and girls, idling some stupid Garage causes the game to crash.
"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
Strange Problem
« Reply #9 on: June 10, 2009, 10:40:47 PM »
What levels create rare ore mines at the start? I bet they just create a common ore mine over a rare ore beacon. If you tell me what levels do it, I can confirm how they did it.


Any crash details, like a crash address? Or perhaps a recent return address on the stack? I'm wondering if some other code is causing the crash, but it's only apparent with this code present. I assume you're still testing on a map where those coordinates make sense?