Well I wouldn't jump too far ahead until we fully understand the code. I'm not sure if it's possible to extend the range yet. But I've made some progress deciphering it.
SCT is largely correct. My IDB has sub_47A430 listed as Game_Map_GridMap_47A430, which is called by Game_Borders_Calculate. I believe all the functions mentioned are called from Game_Borders_Calculate (4476C0). I'm 100% certain this is the right function. Here's a short snippet from Game_Borders_Calculate:
Code: Select all
[Tbc]:0044773F mov bx, [edx+StarbaseInfo_t.shipFunction]
[Tbc]:00447743 lea eax, [edx+StarbaseInfo_t.sectorPos] ; Load Effective Address
[Tbc]:00447746 cmp bx, 7 ; Compare Two Operands
[Tbc]:0044774A jnz short loc_4477A7 ; Jump if Not Zero (ZF=0)
This would seem to support the comments about separate functions handling outposts and starbases. But I'm still not sure how it works overall. I've been doing the donkey work, trying to make the code as readable as possible first. It's paying off, but it's slow work.
I did notice at the very end of Game_Borders_Calculate, a call to Game_Borders_4472B0 -- this code actually sets the claim and ownership flags for the sectors. You'll notice the claim flag is set using inclusive OR
, whereas ownership is exclusive
Code: Select all
mov [edi+edx*4+Sector_t.Ownership], edx
It's a bit strange. First it loops through the starbases, checking if they're operational, who owns them, etc. and makes calls to the GridMap functions based on this. Then another function loops over the starsystems to see who owns them, etc. The final function loops over all the sectors (the entire grid), setting the claim and ownership. But it looks at starbases and starsystems too. So why the separate functions?
Maybe BotF is keeping multiple copies of data again...
It should become clearer once we figure out the GridMap functions like the one at 47A430 which uses the borderGridMap data stored at 5B4210 (it's an array of 5 pointers, dynamically allocated grids, one for each empire). I'll try make it a priority to reverse engineer that data structure (a little harder than usual since it's dynamically allocated and it's not stored in the save files: the Game_Border_Calculate function is also called just after LoadGame).