Structure of edifice.bst

Structure of edifice.bst -> edifice.bst (old); support/discussion/questions

Moderator: thunderchero

User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Structure of edifice.bst

Post by DCER »

File Structure Overview

Offset 0x0000 to 0x0003 number of buildings
Offset 0x0004 to 0x0007 address of the buildings address map (file offset)
Offset 0x0008 to 0x01F3 tech map (496 bytes)
Offset 0x01F4 to 0x02E3 ignore list (240 bytes)
Offset 0x02E4 to 0x???? building data (n * 176 bytes)

Followed by address map (n * 4 bytes).


Structure of various sub-blocks

Tech map

Offset 0x0008 to 0x0009 number of buildings with biotech requirement
Offset 0x000A to 0x000B number of buildings with computer requirement
Offset 0x000C to 0x000D number of buildings with construction requirement
Offset 0x000E to 0x000F number of buildings with energy requirement
Offset 0x0010 to 0x0011 number of buildings with propulsion requirement
Offset 0x0012 to 0x0013 number of buildings with weapons requirement
Offset 0x0014 to 0x0015 number of buildings with All techs requirement

Offset 0x0016 to 0x0017 0x0000 (separator?)

Followed by: (offset 0x0018 to 0x01F3 - 476 bytes)

Code: Select all

For each tech requirement (7)
    For each tech level (10)
        address (4 bytes) of the first building with given tech req. and level

    0x00000000 separator? (4 bytes)

    For each tech level (10)
        number of buildings with given tech req. and level (2 bytes)

    0x00000000 separator? (4 bytes)
Ignore list

Code: Select all

For each empire (5)
    bit mask of all the buildings (48 bytes == 384 bits)
The bit index of a building in the list is calculated as 2^(building index) - 1

If the bit is set to 1, this means the building is ignored. The way UE sets these is it checks if the building can be build by the empire and then sets the bit to 0 (if it can) or 1 (if it can't).

Building data

Each building takes up 176 bytes. The listed building need to be sorted by tech requirement and tech level.

Each building consists of:

Offset 0x0000 to 0x0027 Singular name (40 bytes)
Offset 0x0028 to 0x004F Plural name (40 bytes)
Offset 0x0050 to 0x0051 ID (2 bytes)
Offset 0x0052 to 0x0053 Upgrade For ID (2 bytes)
Offset 0x0054 to 0x0057 Unknown (4 bytes)
Offset 0x0058 to 0x005F Image prefix (8 bytes)
Offset 0x0060 to 0x0064 Unknown (5 bytes)
Offset 0x0065 to 0x0065 Tech req. type (1 byte)

Values:
0 - Biotech
1 - Computer
2 - Construction
3 - Energy
4 - Propulsion
5 - Weapon
6 - All

Offset 0x0066 to 0x0066 Tech level (1 byte)
Offset 0x0067 to 0x0067 Excluded empires mask (bit set to 1 means cannot by built by said empire)
Offset 0x0068 to 0x006F Race requirement (1 means race required)
Offset 0x0070 to 0x0070 Politic requirement (1 byte)

Values:
0 - Home system
1 - Native Member system
2 - Non-native member system
3 - Subjugated system
4 - Affiliated system
5 - Independent minor race system
6 - Conquered home system
9 - None
A - Rebel system
B - Empty system

Offset 0x0071 to 0x0071 System requirement (1 byte)

Values:
0 - Arctic planet
1 - Barren planet
2 - Desert planet
3 - Gas Giant
4 - Jungle planet
5 - Oceanic planet
6 - Terran planet
7 - Volcanic planet
8 - None
9 - Asteroid (not working)
A - Asteroid belt dilithium (not working)
B - Dilithium
C - Worm hole (not working)
D - Radio Pulsar (not working)
E - X-Ray Pulsar (not working)

Offset 0x0072 to 0x0072 bonus type (index from edifbnft.bst)
Offset 0x0073 to 0x0073 build limit

Values:
0 - None
1 - One per system
2 - One per empire

Offset 0x0074 to 0x0074 group

Values:
00 - Main Cardassian food
01 - Main Federation food
02 - Main Ferengi food
03 - Main Klingon food
04 - Main Romulan food
06 - Main Cardassian industry
07 - Main Federation industry
08 - Main Ferengi industry
09 - Main Klingon industry
0A - Main Romulan industry
0C - Main Cardassian energy
0D - Main Federation energy
0E - Main Ferengi energy
0F - Main Klingon energy
10 - Main Romulan energy
12 - Main Cardassian intel
13 - Main Federation intel
14 - Main Ferengi intel
15 - Main Klingon intel
16 - Main Romulan intel
18 - Main Cardassian research
19 - Main Federation research
1A - Main Ferengi research
1B - Main Klingon research
1C - Main Romulan research
1E - Scanners
22 - Other

Offset 0x0075 to 0x0075 Category

Values:
00 - Research
01 - Development
02 - Food
03 - Energy
04 - Defense

Offset 0x0076 to 0x0077 unknown (2 bytes)
Offset 0x0078 to 0x0079 build cost (2 bytes)
Offset 0x007A to 0x007B unknown (2 bytes)
Offset 0x007C to 0x007D energy cost (2 bytes)
Offset 0x007E to 0x007F unknown (2 bytes)
Offset 0x0080 to 0x0081 population cost (2 bytes) - either 00 or 0A
Offset 0x0082 to 0x0083 morale bonus (2 bytes)
Offset 0x0084 to 0x0085 unknown (2 bytes)
Offset 0x0086 to 0x0087 Cardassian bonus (2 bytes)
Offset 0x0088 to 0x0089 Federation bonus (2 bytes)
Offset 0x008A to 0x008B Ferengi bonus (2 bytes)
Offset 0x008C to 0x008D Klingon bonus (2 bytes)
Offset 0x008E to 0x008F Romulan bonus (2 bytes)
Offset 0x0090 to 0x0091 neutral bonus (2 bytes)
Offset 0x0092 to 0x0093 Cardassian unrest bonus ? (2 bytes)
Offset 0x0094 to 0x0095 Federation unrest bonus ? (2 bytes)
Offset 0x0096 to 0x0097 Ferengi unrest bonus ? (2 bytes)
Offset 0x0098 to 0x0099 Klingon unrest bonus ? (2 bytes)
Offset 0x009A to 0x009B Romulan unrest bonus ? (2 bytes)
Offset 0x009C to 0x009D neutral unrest bonus ? (2 bytes)
Offset 0x009E to 0x00AB unknown (14 bytes)
Offset 0x00AC to 0x00AF description address

All strings need to end with a 0x00 byte.


Address map

Consists of 4 byte addresses (file offsets) pointing to the start of a building's data entry. Addresses are sorted by building id.

To get the file offset of building with ID 0, you would look at the first address, for building with ID 30, you'd look at the 31st address.
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

viewtopic.php?name=Forums&file=viewtopi ... highlight=
I've just read that topic... looks like buildings with technology requirements above ten would require a major code re-write :.(

thanks thought for that infomation anyway it helped me to correct some of my misconceptions about the edifce.bst file
given what i said,
Offset 0x0016 to 0x0017 0x0000 (separator?)
could tihs have been left for sociology?
Code:

Code: Select all

For each empire (5) 
    bit mask of all the buildings (48 bytes == 384 bits) 
therefore this implies the maximum number of buildings is 384

is UE set up to use extra buildings at the moment? or just standard 318?


so as i under stand this

Code: Select all

Offset 0x0000 to 0x0003 number of buildings (adding an extra 66)
	3e 01 00 00	->	80 01 00 00
		318	->	384

=================================================

Offset 0x0004 to 0x0007 address of the buildings address map (file offset)
	84 DD 00 00	->	E4 0A 01 00
sets the file for the maximum 384 buildings,

add 66 buildings data to the end(?) or the 318*176 byte block (not sure what these'll be ;))

addjust Offset 0x0008 to 0x01F3 tech map (496 bytes) and Offset 0x01F4 to 0x02E3 ignore list (240 bytes) as appropriate

#
are there any changes required in trek.exe -- do you know if it is setup to use 318 building i.e. hard coded or is this read from the first four bytes of this file?
User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Post by DCER »

Offset 0x0016 to 0x0017 0x0000 (separator?)
could tihs have been left for sociology?[/quote]

Possibly, yes. But it would then probably read as bio, ..., soc, All instead of bio, ..., All, soc
is UE set up to use extra buildings at the moment? or just standard 318?
It should be able to read/save a file with more buildings, but this is untested.
are there any changes required in trek.exe -- do you know if it is setup to use 318 building i.e. hard coded or is this read from the first four bytes of this file?
It probably works the same as for shiplist.sst. The number of buildings is likely to be found multiple times in trek.exe, you'd need to find them all.
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

since i last posted i've added 66 test buildings to the edifice.bst and am continuing my efforts. Thanks for the quick reply DCER :), I will post back once i've done some test. It's good to here that UE might read this file (again i'll post how that goes asap :D)

'a dream that became a reality and spread throughtout the stars...'
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Post by Tethys »

Also let me know how it goes Peter, I am looking to add buildings to the game as well :P
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

Without making any changes (except those required by UE trek.exe update) the initial test (Fedz) generated this :( as expected this mean there is gold in the trek.exe to be uncovered hovever i detected only 42 instances of 318 in trek.exe so will work on these and 317.

Code: Select all

ST:BOF Fri Jul  9 23:08:09 2010

Version Under Test: 72
File: ..\..\source\game\building\redifice.c, Line: 267, The id 320 is bigger than the max StructureId of 317

Initialize State: 31
Player Empire: 1	Starting Seed: 1278713288
Galaxy shape: 0	Galaxy Size: 2
Last edited by Peter1981 on Sat Jul 10, 2010 5:29 am, edited 1 time in total.
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

Code: Select all

LOC_4504E3:
cmp ax, 13Dh
ja    short loc_45050d
this is the test for this error

Code: Select all

0x4f8e5		3D 01 (317) -> 7F 01 (383)
well that solves the crash at the start of the game and in f4 (science screen) i can see all the buildings. -- testing further...

However on selecting a building in F4 screen with an id > 318 CTD mo crash log :(
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

Code: Select all

xor     eax, eax
mov     ax,  dx
lea      ecx, ds:0[eax*4]
mov    eax, ds:dword_5B425C
add     eax, ecx
mov    ecx, [eax]
mov    eax, [ecx+0ACh]
inc      edx
call     sub_450720
mov    [ecx+54h], eax
cmp     dx, 13Dh
jbe      short loc_4506AB
this seems to be a loop increment ?

Code: Select all

0x4fad8		3D 01 (317) -> 7F 01 (383)
resulted in CTD on galaxy load :(

Code: Select all

0x53108		3D 01 (317) -> 7F 01 (383)
resulted in CTD before intro movie :(

Code: Select all

0x8602b		3D 01 (317) -> 7F 01 (383)
no noticeable effect?
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

Code: Select all

jle -> 317 (dec) 

0x4f8e3		4504E3   cmp     ax, 13D 	/
0x4fad5		4506D5   cmp     dx, 13D	/ x CTD 
0x53102		453D02   cmp     bx, 13D 	/ x CTD
0x851c1		485DC1   cmp     ecx, 13D 	cmp ecx 148h?
0x85294		485E94   cmp     ecx, 13D 	cmp ecx 148h?
0x85343		485F43   cmp     ecx, 13D 	cmp ecx 148h?
0x853ce		485FCE   cmp     ecx, 13D 	cmp ecx 148h?
0x8544d		48604D   cmp     ecx, 13D 	cmp ecx 148h?
0x85472		486072   cmp     cx, 13D 	/
0x85923		486523   cmp     bx, 13D 	/
0x85f36		486B36   cmp     cx, 13D 	/
0x86028		486C28   cmp     bx, 13D 	/
0x8623e		486E3E   cmp     ecx, 13D 	cmp ecx 148h?
0x862e1		486EE1   cmp     ecx, 13D 	cmp ecx 148h?
0x8636c		486F6C   cmp     ecx, 13D 	cmp ecx 148h?
0x86391		486F91   cmp     bx, 13D 	/ 17Eh?
0x86752		487352   cmp     bx, 13D 	/ 17Eh?
0x8680c		48740C   cmp     bx, 13D 	/	
0x868e9		4874E9   cmp     bx, 13D 	/
0x869cb		4875CB   cmp     ecx, 13D 	/ 
0x86abb		4876BB   cmp     ecx, 13D 	/ 


jb  -> 318 (dec) 

0xadda		40B9DA   cmp     ax, 13E 	/ 180h
0xcb52		40D752   cmp     bx, 13E 	/ 180h
0x39e62		43AA62   cmp     bx, 13E 	/ 180h
0xf38c6		4F44C6   cmp     dx, 13E 	/ 180h
tested all these and noted some discrpencies with SCT list ate the values with a ? updated by UE DCER?
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

Code: Select all

ST:BOF Sat Jul 10 12:41:02 2010

Version Under Test: 72
File: ..\..\source\game\tech\techrslt.c, Line: 268, Building count for tech advancement pop up is too large

Initialize State: 31
Player Empire: 1	Starting Seed: 1278761721
Galaxy shape: 0	Galaxy Size: 0

yet another CTD :) but...

i solved this bu reducing the number of buildings to less than 0F which is the test for this error :) for the popup screen

However UE or I've broken colonisation F1 F7 M1 P7 I7 should be F1 M1 P1 I1 U1 .... EDIT: sorted out the upgrade colony issue
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

Job done 13d with 17e and 13e with 17f

read the How to here

viewtopic.php?name=Forums&file=viewtopic&t=1599
Last edited by Peter1981 on Sat Jul 10, 2010 1:01 pm, edited 1 time in total.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2404
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Post by Tethys »

This is wonderful news! I cant wait to get some new buildings in my mod! Good work Peter and DCER! You guys are great! :D
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

It should be able to read/save a file with more buildings, but this is untested
UE seems to work well with new i.e. extra buildings :D
User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Re: Structure of edifice.bst

Post by Gowron »

Thank you very much for this overview, DCER :)

Just one tiny thing:
DCER wrote: Offset 0x0000 to 0x0003 number of buildings
Isn't it the highest index (= number of buildings minus one)?
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.
User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Post by DCER »

I'm pretty sure it's the number of buildings, maybe used for determining the size of the address map. UE saves it as such and the files I've checked have it set as 318.

If you find it to be otherwise let me know and I'll update my post.
Last edited by DCER on Sun Jul 18, 2010 2:21 pm, edited 1 time in total.
Post Reply

Return to “Structure of edifice.bst -> edifice.bst (old)”