Author Topic: Decompilation coordination thread  (Read 24520 times)

0 Members and 1 Guest are viewing this topic.

Offline scient

Re: Decompilation coordination thread
« Reply #105 on: September 24, 2017, 07:01:22 AM »
Speaking of the patch documentation, the other thing that left me wondering was the "SELECT PLANETARY ORBIT" "80..100 million miles" option when generating a new map. It's the first thing the map generator asks yet I can't see if it affects anything? Another thread suggested it affects eco damage but not sure how to verify it. At least it should be explained in the readme or worded differently. The map in this game doesn't represent temperature per se, there's only humidity which already has its own setting.

I thought I'd have a quick look at this. So it looks like this was enabled by Yitzi's patch, not by default. By default, the global variable that handles this is set to 1: "90 million miles (average planet)".

SMACX global variable offset: 0x94A2B0
valid values: 0,1,2

The only function that references this global, outside of map configuration, is world_temperature(). This in turn is called by world_build() or world_climate(). The key one is world_climate() that gets called during terraforming, random events, planet busting, ecology functions and many others. It seems to get called on average between 10-20 turns.

Inside world_temperature() the global 0x94A2B0 is used as an upper bound value in the random generation of a local variable as well as some conditional checks. In the end, a value between 0 and 2 is passed as a parameter to the function temp_set(x,y,VALUE). The function looks like it loops through the tiles setting this value. Tiles temperature will change over the course of the game. It seems near the poles, it is always 0. This is likely part of the logic checks on the x/y bounds. It looks like the temp of a square will affect whether it is arid, moist or rainy.

Hopefully this adds some clarity to what this setting is doing. If there is interest, I will decompile the entire world_temperature function.

Offline Induktio

Re: Decompilation coordination thread
« Reply #106 on: November 09, 2017, 11:27:55 PM »
SMACX global variable offset: 0x94A2B0
valid values: 0,1,2

The only function that references this global, outside of map configuration, is world_temperature(). This in turn is called by world_build() or world_climate(). The key one is world_climate() that gets called during terraforming, random events, planet busting, ecology functions and many others. It seems to get called on average between 10-20 turns.

Interesting information right there. I suppose this setting then influences global warming. From the player's perspective it might be most important to see whether this setting will lessen or increase the effects of global warming. I don't know enough to judge whether those other effects have noticeable changes with the temperature option.

Offline Induktio

Re: Decompilation coordination thread
« Reply #107 on: July 03, 2018, 08:26:39 PM »
IDA Pro 6.8.150423 with hexrays works. I think other 6.8 versions will work too.

idc files attached (database and separate typeinfo).

They're from my own database and have a handful more annotations than scient's database.
Decided to take a look at this again. If anyone has problems opening Scient's database, it is also pretty easy to import the annotations from these idc files. One should copy the lines containing MakeName or MakeComm and paste them into IDA's script input box. Then you should have most of the important functions with plain text names, no matter which version of IDA is in use.

There's many things we could improve with the current AI though. Some important ones:
1. How many colony pods to build
2. Where does the AI build colonies
3. How many formers to build
4. How is the terraforming action selected for a given former

If anyone has function locations for these actions already figured out, you could post them here. I'd suspect many of them have something to do with function 0X56B5B0, "enemy_move" but it is the most complicated function in the whole binary.

Offline Induktio

Re: Decompilation coordination thread
« Reply #108 on: July 04, 2018, 09:28:16 PM »
Also a question for scient et al. Does this IDA database incorporate any of the information kyrub used when he made his AI patch?

Edit: ahh, of course kyrub already posted his idc file much earlier here: http://alphacentauri2.info/index.php?topic=14229.msg65853#msg65853

There seems to be some similarities but I'm not sure yet if kyrub's database has any information that scient's analysis doesn't. It's a different binary but Firaxis probably shared a lot of the codebase.
« Last Edit: July 04, 2018, 10:11:23 PM by Induktio »

Offline Induktio

Re: Decompilation coordination thread
« Reply #109 on: July 11, 2018, 03:51:54 PM »
Here's a small mod for terranx.exe that enables some debugging output. It is probably only useful for mod developers. The game by default creates a file called logfile.txt but all of the debug output was disabled when the game binary was built. This patch was built on the default GOG binary, no other changes have been made. To enable the debug patch, edit Alpha Centauri.Ini and make sure it includes these lines:

Code: [Select]
[Alpha Centauri]
Multi Debug=1

Any other value will disable the debug mode. Then just start the game from terranx_debug.exe and you can read the output from logfile.txt. 

Offline bvanevery

  • Emperor of the Tanks
  • Thinker
  • *
  • Posts: 6370
  • €659
  • View Inventory
  • Send /Gift
  • Allows access to AC2's quiz & chess sections for 144 hours from time of use.  You can't do without Leadship  Must. have. caffeine. -Ahhhhh; good.  Premium environmentally-responsible coffee, grown with love and care by Gaian experts.  
  • Planning for the next 20 years of SMACX.
  • AC2 Hall Of Fame AC Text modder Author of at least one AAR
    • View Profile
    • Awards
Re: Decompilation coordination thread
« Reply #110 on: July 13, 2018, 08:14:34 PM »
If only we knew the secret as to why the AI builds units until it runs out of support.  If we could stop that behavior, it would be the single biggest possible improvement to the competence of the game.

Offline scient

Re: Decompilation coordination thread
« Reply #111 on: July 24, 2018, 10:50:56 PM »
Here is the most recent export from my database. It includes a lot of additional work and clean up over the past year or so. Especially around the internal structures. I had meant to post this closer to the the beginning of the year but I've been super busy with work and certifications. There are still a few things I'd like to do before "officially" sharing this. However, I figured this might be of some use if you are poking around.

Offline Induktio

Re: Decompilation coordination thread
« Reply #112 on: July 27, 2018, 09:09:29 PM »
Yeah, I've been reversing some additional stuff as I've been developing my new mod. Anyway, looks like this file has not been posted here yet:
https://web.archive.org/web/20080827173127/http://meepo.dnsalias.org/misc/SMAC-MP.txt

It's an old but really accurate description of the map tile data structure. It is dynamically allocated so the pointer to the table is found from 0x94A30C.

Here's some additional observations:
Bytes  3- 4  Bitfield, some unknown flags
Byte   5  Faction bitfield, probably zone of control or tile visibility
Byte  15  Not constant, might relate to visibility

Offline scient

Re: Decompilation coordination thread
« Reply #113 on: July 28, 2018, 08:23:31 AM »
Yeah, I have same document from another board many years ago. Pretty sure I tried to incorporate some of that info into my IDA DB analysis. I think it's still on the todo list to flesh it out more. I did add one bit of info to my version of the document related to internal structure and coordinates. This way you can locate a particular tile's data.

How to get to map struct in memory:
[94A30C] + 0x2C * ((x_coord >> 1) + y_coord * [68FAF0])

Offline Induktio

Re: Decompilation coordination thread
« Reply #114 on: July 29, 2018, 04:41:26 PM »
Here's the header files I've been preparing for release:
https://github.com/induktio/smacheaders

I've omitted any structures related to the graphics rendering because my mod doesn't interact with those issues. But for anything else, people can always send a patch.

So for example, if we wanted to access the map array with this "api", we could write:
Code: [Select]
MAP* mapsq(int x, int y) {
    int i = x/2 + (*tx_map_half_x) * y;
    if (i >= 0 && i < *tx_map_half_x * *tx_map_axis_y)
        return &((*tx_map_ptr)[i]);
    else
        return NULL;
}

 

* User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

* Community poll

SMAC v.4 SMAX v.2 (or previous versions)
-=-
24 (7%)
XP Compatibility patch
-=-
9 (2%)
Gog version for Windows
-=-
103 (32%)
Scient (unofficial) patch
-=-
40 (12%)
Kyrub's latest patch
-=-
14 (4%)
Yitzi's latest patch
-=-
89 (28%)
AC for Mac
-=-
3 (0%)
AC for Linux
-=-
6 (1%)
Gog version for Mac
-=-
10 (3%)
No patch
-=-
16 (5%)
Total Members Voted: 314
AC2 Wiki Logo
-click pic for wik-

* Random quote

Organic Superlube? Oh, it's great stuff, great stuff. You really have to keep an eye on it, though - it'll try and slide away from you the first chance it gets.
~T. M. Morgan-Reilly, Morgan Metagenics

* Select your theme

*
Templates: 5: index (default), PortaMx/Mainindex (default), PortaMx/Frames (default), Display (default), GenericControls (default).
Sub templates: 8: init, html_above, body_above, portamx_above, main, portamx_below, body_below, html_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 45 - 1228KB. (show)
Queries used: 38.

[Show Queries]