Author Topic: Surpassing The Unit/building Limit  (Read 2627 times)

Offline Kamikaze088

  • Newbie
  • *
  • Posts: 35
Surpassing The Unit/building Limit
« on: February 04, 2009, 10:54:44 AM »
A while back I edited the Plymouth Starship II single player mission (removing the lava flow and blight). My goal was to assimilate eden structures (capturing convecs with structures) to surpass the building limit. I indeed did, and continued for a while, possibly doubling what the game set as a limit. Then after a few more buildings the game would crash. Is this just a limit to the programming? Does anyone have any more information on it?

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
Surpassing The Unit/building Limit
« Reply #1 on: February 04, 2009, 02:27:14 PM »
There is a hard limit of I think 2048 objects. That includes every last object, from buildings, units to fumarole, magma vents and disasters.
The 2048 object limit represents the maximum memory the game may allocate for objects. Surpassing that limit the way you did certainly overwrote some memory entries causing the game to crash.
"Nothing from nowhere, I'm no one at all"

Offline Kamikaze088

  • Newbie
  • *
  • Posts: 35
Surpassing The Unit/building Limit
« Reply #2 on: February 04, 2009, 07:35:43 PM »
Thank you for replying to my post. That information is helpful. It's too bad the program can't handle more.

Offline Mcshay

  • Administrator
  • Sr. Member
  • *****
  • Posts: 404
Surpassing The Unit/building Limit
« Reply #3 on: February 04, 2009, 07:59:22 PM »
There is a much lower soft limit as well (due to, among other things, programming errors on Dynamix's part). It scales according the the number of players in the game; if single player games scale the same as multiplayer games (ie: you have something like 80 in 6p but 120 in 2p).

In any case, experience has taught me to be careful when passing the limit, a few hundred units seems to like to crash the game.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Surpassing The Unit/building Limit
« Reply #4 on: February 04, 2009, 09:31:04 PM »
Keep in mind that weapons fire also counts as a unit.


Btw, if you have a CD install, or an older version, the hard limit will be 1023. We upgraded that to 2047.

I believe the unit allocation function returns null (0) when it runs out of space, but the return value is never checked. If you check the crash address, it will probably say something about reading a low memory address close to 0. Quite likely from 0 - 120 (0x78 in hex).
 

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Surpassing The Unit/building Limit
« Reply #5 on: February 04, 2009, 09:35:10 PM »
Edit: Monster!  Why would you want to get rid of the Blight?  It's super-fun!!!  And purple.

Anyways, original post:

When did the game crash, exactly (mark)?  What were you doing at the time?
If you hacked the DLL, maybe that has something to do with it?

Just suggesting it might not be unit-limit related.
« Last Edit: February 04, 2009, 09:39:30 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 Kamikaze088

  • Newbie
  • *
  • Posts: 35
Surpassing The Unit/building Limit
« Reply #6 on: February 05, 2009, 08:13:01 AM »
Good point about the DLL. It might have to do with the editing. I think the blight approaches at mark 3500? Unfortunately, I don't have the original saved file to test this. From what I remember it triggered the crash when I started to construct several more buildings. I'm already in the process of re-creating it to investigate further. I have the most recent version of the game installed as well.

Would anyone care to look at the DLL? I'm not exactly a pro at hacking, but it works!

Any way to upgrade the unit count past 2047

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Surpassing The Unit/building Limit
« Reply #7 on: February 05, 2009, 09:43:15 PM »
Quote
Any way to upgrade the unit count past 2047
Upgrading past 2047 would require rather extensive changes throughout the game engine, and we have no reliable way of location all the places that would need to be edited. So no.


Quote
Would anyone care to look at the DLL? I'm not exactly a pro at hacking, but it works!
Maybe just post the technical details about the edit you made to the DLL? That might be a quicker and easier way to verify that it makes sense then dumping the entire DLL in someone's lap.


Also, if you get info about the crash, such as the crash address, it might provide more clues as to why exactly it crashed.
 

Offline Kamikaze088

  • Newbie
  • *
  • Posts: 35
Surpassing The Unit/building Limit
« Reply #8 on: February 06, 2009, 12:24:34 PM »
On the DLL edit: pardon my inexperience in programming (I took the route of biological sciences instead). I edited the cps2.dll file in a hex editor by replacing these characters with the underscore _ (* shows where I made the change).

Original:
GiveAIOre_InitProc_L*ava_Flow_L*ava_Vent_LevelDesc_MapName_Mi*crobe_NoResponseToTrigger_ReleaseMorale

Edited:

GiveAIOre_InitProc__ava_Flow__ava_Vent_LevelDesc_MapName_M_crobe_NoResponseToTrigger_ReleaseMorale

Hex edit was saved. When the game loads it gives these two errors:

Couldn't resolve data reference Lava_Vent in mission script
Couldn't resolve data reference Microbe in mission script

Click ok on those errors, and you can play the mission normally with no other apparent problems.

For the crash much later in the game I will have to get back to you on that. It will take a while to get to that point again in the file. If my hard drive didn't fail on me last year I would be able to tell you now : )

Thanks again for the interest in this post - glad to see the OP2 community is alive and thriving.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Surpassing The Unit/building Limit
« Reply #9 on: February 08, 2009, 07:21:10 PM »
Hmm, that is a bit of a fishy way to edit the level. It might very well have something to do with the crash.

I can show you how to edit the level so that it doesn't pop up any errors. If you're interested, just say so. It might not hurt to go take a peek at OllyDbg first, or related posts in the programming forum first though.
 

Offline Kamikaze088

  • Newbie
  • *
  • Posts: 35
Surpassing The Unit/building Limit
« Reply #10 on: February 09, 2009, 09:14:35 AM »
Oh, I agree... it's a very fishy way to edit code. It worked at the time, but with my renewed interest in OP2 I would like to edit it properly (and also eliminate the possibility it is causing a crash later in the game). So, yes I am interested! I downloaded the OllyDbg and viewed the posts on DLL editing - it's a lot of info. Perhaps this is a good chance to create a "how to section" for beginners? (if there isn't one already).

Where do we begin?
« Last Edit: February 09, 2009, 09:15:17 AM by Kamikaze088 »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Surpassing The Unit/building Limit
« Reply #11 on: February 09, 2009, 08:13:03 PM »
Hmm, I just went looking for posts that would be somewhat like an introductory tutorial. I came across two that seemed somewhat suitable.

http://forum.outpost2.net/index.php?showto...indpost&p=64384
http://forum.outpost2.net/index.php?showto...indpost&p=55605


There were also a few minor ones you can peek at once you're a little more comfortable.
http://forum.outpost2.net/index.php?showto...indpost&p=64686
http://forum.outpost2.net/index.php?showto...indpost&p=66260


And of course there is the OllyDbg comments file, which contains plenty of code and data labels, and lots of comments that I added.
http://forum.outpost2.net/index.php?showto...indpost&p=57935
I'm sure it's not up to date, but it's more than enough to help you get started peeking around. I might have added something more current to the SVN, but I can't really remember now. At any rate, it may be easier to just use the forum download for starters, and it tells you how to actually use the files.
 

Offline Kamikaze088

  • Newbie
  • *
  • Posts: 35
Surpassing The Unit/building Limit
« Reply #12 on: February 11, 2009, 08:27:36 PM »
I've taken a look at those posts and it helps a bit. I at least have a better understanding of the programs used to edit. As for appraoching the edits I would like to do... how do I go about preventing the lava and blight? Do I create a new command at that location, or do I delete the call for that trigger? How is this type of editing usually handled?

It might be helpful to have a more simple example than the one given about editing the unit count.
« Last Edit: February 11, 2009, 08:28:11 PM by Kamikaze088 »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Surpassing The Unit/building Limit
« Reply #13 on: February 13, 2009, 02:46:08 AM »
OK, I think we'd better split this off into a thread in the programming forum. Probably the easiest edit, would be to overwrite the start of the callback function with a RET instruction. I'll maybe try to provide an example on the weekend.

... or are there already examples of this posted? Seems like such a common thing to do, there must be examples of it somewhere. Or maybe I'm just thinking of resulting DLLs that got posted without details on how they were made.
 

Offline Kamikaze088

  • Newbie
  • *
  • Posts: 35
Surpassing The Unit/building Limit
« Reply #14 on: February 13, 2009, 03:22:44 PM »
Agreed. Let's move this thread to the programming forum. I looked for examples of simple edits, but I did not find much. Most posts discuss results, not step-by-step instructions as to how the edits were made. I'll continue to look through posts and I will be diving into some C++ as well.

I look forward to your example : )