You must be logged in to post messages.
Please login or register

Caesar III: Scenario Design
Moderated by Granite Q, Gweilo

Hop to:    
loginhomeregisterhelprules
Bottom
Topic Subject: Saved games tool (C3GameExplorer)
« Previous Page  1 2  Next Page »
posted 07-11-08 22:40 ET (US)   
Well, I'm enjoying the current discussion about file editing tools. At its 10th birthday Caesar 3 seems to receive more attention from file format analysts and graphics modders than ever before. Scenario designers have an interest in editing saved games to go beyond the possiblities of the official editor and not all details of the file format that could be useful seem to have been uncovered yet.

I gathered some insight to Caesar 3's saved game file format when I programmed the Mac-PC-Converter and a little tool for scenario designers, which I called 'C3 Game Explorer', some years ago. C3GameExplorer was beta-tested by Caesar Philon and posted in 2004 in the 'Designer' sub-forum of CBC. I don't have access to that specific sub-forum anymore and don't know if it's still there. The download link has never been posted anywhere else. The predominant opinion at that time was that such a tool should not be made publicly available because it could be used for cheating in contests.

Seeing all the efforts being made to program editing tools and post format specifications, I think the cheating argument doesn't hold anymore. Maybe this little tool can still be useful for some scenario design purposes or even for the ongoing projects, so here is the download link:

http://www.geocities.com/caesar_jan/c3gameexplorer.html

It works fine with Windows XP (and likely with Vista, too, I guess). The webpage is from 2004 and the link to Dragon2's tools is misleading nowadays. If there's interest, I can also post a few more details I found out about the Caesar 3 saved game file format, in addition to what Pecunia posted on her website.



Quoted from the 'About' text file (2004):

What can you do with C3GameExplorer?
====================================

* Edit saved games
- specify local raw materials
- disable trade routes
- edit the costs to open trade routes
- edit buyer and seller prices
- edit the present values of the four ratings (culture, favor, etc.)
- edit personal savings

* Report
Display a couple of scenario settings.

* Convert saved games between PC and Mac
C3GameExplorer incorporates the functionality of my Macintosh tool C3Converter.

* Save and load uncompressed saved games
This is only useful if you want to do low-level editing with a hex editor. If you are familiar with hex editing I can mail you a list with hex offsets.



Some clarifying usage information (2008):

To start, you open a Caesar 3 saved game via File->Open. The 'Open' and 'Save As' dialogs behave in a non-standard way (I was more a Mac guy at that time). When you want to load a game, you must first choose the file type that matches your saved game from the popup at the bottom: 'PC Saved Games (*.sav)', 'Mac Saved Games (*.sav)' or 'Uncompressed Saved Games (*.c3u)'. The default is PC saved game. After you loaded the game. you can use the options from the 'Tools' menu to edit some game data. Finally, to save the modified game, you choose the file format that you want your game to be saved in from the popup.

Uncompressed saved games (i.e. without PKWare (PC) or Zip (Mac) compression) are most useful to study the file format specifictions or to make changes with a hex editor. The procedure would be to open a PC saved game in C3GameExplorer, save it as uncompressed saved game, edit it with your favorite hex editor, open the modified uncompressed saved game in C3GameExplorer and save it as a PC saved game again. The size of an uncompressed PC saved game is always exactly 1.255.013 bytes and offsets to specific values of interest are the same in every saved game.

[This message has been edited by Caesar Jan (edited 07-11-2008 @ 11:11 PM).]

Replies:
posted 07-14-08 13:08 ET (US)     1 / 32  
Impressive, Caesar Jan!

I'm particularly interested in that list of hex offsets.. would you allow me to post them on my site?

Angel Pecunia | HG Downloads programmer and techie
Caesar IV Heaven | Children of the Nile Heaven | Citadel of Poseidon (Zeus/Poseidon) | The Great Wall (Emperor)
posted 07-15-08 19:55 ET (US)     2 / 32  
Pecunia, of course you can post them on your site. But I've just realized that there's isn't much left that you haven't already posted, with the only difference being that you gave the offsets for the .map file.



Caesar III Saved Games


Uncompressed saved games have a fixed size of 1.255.013 bytes. A saved game consists of 37 sections; each section stores different information about the game. When Caesar III for PC saves a game, it uses the PKWare data compression library to compress many of these sections to reduce the file size. The resulting file size depends mainly on the map size and the number of buildings and walkers in your city.

Caesar III for Mac has doubled limits for walker and building sprites. The size of an uncompressed saved game has been extended to 1.944.197 bytes to hold the extra data. However, if the higher sprite limits are not used by a particular Mac game, the extra bytes will be all zeroes. When Caesar III for Mac saves a game, it compresses the complete game - instead of individual game sections - using GZip compression (see 'zlib' by Jean-loup Gailly).

The offsets given here refer to uncompressed saved games. You can use my program C3GameExplorer to uncompress and re-compress PC saved games. Offsets are shown as decimal numbers for better readability. For some purposes it is also possible to edit a PC saved game without uncompressing it first. For example, to edit values in section 26, you can search for a fixpoint like the constant string "Brief description of this map" and then recalculate the offsets for a particular saved game. I guess this is how dragon2's tools work.

Caesar III stores numbers in little endian order, which is the PC (which means Windows here) style to represent data. For example, the personal savings are stored at offset 943184 as a LONG. Let's assume we have personal savings of 1000 Denarii. The hex representation for 1000 is "00 00 03 E8" in big endian. In little endian all bytes are swapped, so it looks like "E8 03 00 00" in your hex editor.

Data Types:
BYTE: 1 byte
SHORT: 2 bytes
LONG: 4 bytes



Game Sections


No.OffsetSizeCpr?Purpose
108nounknown
2852488yesunknown, 162 x 162 x 2 bytes
35249626244yesunknown, 162 x 162 x 1 bytes
47874052488yesunknown
513122852488yesterrain types, 162 x 162 x 2 bytes
618371626244yesunknown
720996052488yesunknown
82624482624 4yesunknown
928869226244yesunknown
1031493626244nounknown (pseudo-random numbers seeds?)
1134118026244yesunknown
1236742426244yesunknown
1339366 826244yesunknown
1441991226244yesunknown
1544615626244yesunkno wn
16472400128000yeswalkers, 1000 x 128 bytes
176004001200yes*unknown
18601600300000yesunknown, 600 x 500 bytes
199016006400yesunknown, 50 x 128 bytes
2090800012nounknown
2190801236136yescity treasury, savings, etc.; rest unknown
2294414870nogovernor name; rest unknown
23944218256000yesbuildings, 2000 x 128 bytes
241200218208nounknown
2512004262706yesempire map cities, 41 x 66 bytes
2612031322188noscenario settings (similar to .map file)
27120532016000yesmessages from your scribes, 1000 x 16 bytes
281221320206nounknown
2912215263232yesunknown
30122475813 772nounknown
3112385301000yesunknown
3212395301000yesunknown
33 12405304000yesunknown
3412445306544nounknown
3512510741280yesu nknown
3612523541280yesunknown
3712536341379nounknown


Offset = decimal offset from the begin of the uncompressed saved game
Size = length of section in bytes
Cpr? = Is the section compressed in a PC saved game?

* Section 17 is not compressed in saved games that have been created with an older version of Caesar III for PC (probably v1.0).



Section 21


OffsetSizePurpose
926092LONGcity treasury (only here?)
937028LONGcity's wages
937032LONGRome's wages
937096LONGtaxes in so far this year
937100LONGtaxes in last year
937204LONGnet in/out flow last year
937208LONGbalance last year
937212LONGbalance this year (same as city treasury)
9428564 x LONGcurrent ratings for culture, prosperity, peace, and favor
9431005 x LONGgods: months since last festival for each god
943184LONGpersonal savings




Section 25


This section contains 41 entries for the cities displayed on the empire map screen. Each entry is 66 bytes long. The first entry is not used and all of its bytes are zeroes. The offset for the second entry (City 1) is 1200492, for the third entry (City 2) 1200558, and so on.

Structure of an entry:

OffsetSizePurpose
0BYTEentry used flag: 1: yes, 0: no
11 byteunknown
2BYTEcity type, usage unclear!
3BYTEcity name ID
42 bytesunknown
616 x BYTEbuy flags: 1 zero byte + flags for the 15 goods
2216 x BYTEsell flags: 1 zero byte + flags for the 15 goods
38SHORTcost to open trade route
4026 bytesunknown


There's usually one city in the list that sells goods but doesn't buy any goods, this is your own city. For your own city, the sell flags specify the goods that your city can produce.

Trade routes both buy and sell goods. To disable a trade route, set city type to 0x00. To re-enable a trade route, set city type to 0x02.

City Types:
0x00: "A Roman City"
0x01: "Our city!"
0x02: "Trade Route"
0x03: "Trade Route"
0x04: "A distant city"
0x05: "A Roman City"

City Name IDs:
0x00: Roma
0x01: Tarentum
0x02: Capua
0x03: Brundisium
0x04: Mediolanum
0x05: Carthago Nova
0x06: Carthago
0x07: Tarraco
0x08: Athenae
0x09: Pergamum
0x0A: Syracusae
0x0B: Toletum
0x0C: Tarsus
0x0D: Leptis Magna
0x0E: Tingis
0x0F: Corinthus
0x10: Valentia
0x11: Ephesus
0x12: Miletus
0x13: Sinope
0x14: Cyrene
0x15: Antiocha
0x16: Heliopolis
0x17: Damascus
0x18: Hierosolyma
0x19: Lindum
0x1A: Calleva
0x1B: Lutetia
0x1C: Massilia
0x1D: Narbo
0x1E: Lugdunum
0x1F: Caesarea
0x20: Alexandria
0x21: Augusta Trevorum
0x22: Argentoratum
0x23: Volubilis
0x24: Londinium
0x25: Thamugadi
0x26: Sarmizegetusa
0x27: Byzantium



Section 26


This section contains mostly the settings from the .map file and some values filled in later by Caesar III, like the invasion months.

OffsetSizePurpose
120326016 x 2 x LONGprices, a pair of buyer's price and seller's price for each of the 15 goods, first pair not used
12035168 bytesrandom seed?
1203532?map starting date
120354620 x SHORTrequests: years
120358620 x SHORTrequests: goods: good ID or 0 if no request
120362620 x SHORTrequests: amounts
120366620 x SHORTrequests: delivery times in years
120370620 x SHORTinvasions: years
120374620 x SHORTinvasions: battle types; 0: no invasion, 1: local uprising, 2: enemy army, 4: distant battle
120378620 x SHORTinvasions: army sizes
120382620 x SHORTinvasions: invasion point indexes; index starts at 0; 8 is the default value, i.e. not applicable; look at offset 1205168 for the invasion point coordinates
120386620 x SHORTinvasions: targets?
1203908LONGstarting funds; the actual starting funds may depend on the difficulty level.
1203912LONGenemy type
1203920LONGmap size X
1203924LONGmap size Y (always the same as map size X), ignored?
120393664 bytesmap subtitle
1204000? bytes"Brief description of this map [...]"; This text seems to be constant in all saved games (or maybe only in saves created by UK/US versions of C3?)
12045484 x SHORTherd points, X-coordiantes
12045564 x SHORTherd points, Y-coordiantes
120468420 x SHORTprice changes: years
120472420 x BYTEprice changes: months
120474420 x BYTEprice changes: goods, good ID od 0 if no change
120476420 x BYTEprice changes: price deltas
120478420 x BYTEprice changes: directions, 0: down, 1: up
1204804LONGgladiator revolt flag
1204808LONGgladiator revolt year
1204812LONGchange of emperor flag
1204816LONGchange of emperor year
1204820LONGsea trade problems flag
1204824LONGland trade problems flag
1204828LONGRome raises wages flag
1204832LONGRome lowers wages flag
1204836LONGcontaminated water flag
1204840LONGiron mine collapse flag
1204844LONGclay pits flooded flag
12048488 x SHORTfishing points, X-coordiantes
12048648 x SHORTfishing points, Y-coordiantes
120488020 x BYTErequests: favour points (default is 8 favor points)
120490020 x BYTEinvasions: months
120492020 x BYTErequests: months
120500450 x SHORTbuildings: enabled/disabled flags
1205104LONGwinning culture (if on)
1205108LONGwinning prosperity (if on)
1205112LONGwinning peace (if on)
1205116LONGwinning favor (if on)
1205140LONGearthquake type; 0: no earthquake, 1: minor earthquake, 2: average earthquake, 3: major earthquake
1205144LONGearthquake year
1205148LONGwinning population flag
1205152LONGwinning population number
1205156SHORTearthquake point X
1205158SHORTearthquake point Y
1205160SHORTpeople entry point X
1205162SHORTpeople entry point Y
1205164SHORTpeople exit point X
1205166SHORTpeople exit point Y
12051688 x SHORTinvasion points X
12051848 x SHORTinvasion points Y
1205200SHORTriver entry point X
1205202SHORTriver entry point Y
1205204SHORTriver exit point X
1205206SHORTriver exit point Y
1205208LONGrescue loan
1205212LONGmax. years to reach 25% milestone
1205216LONGmax. years to reach 50% milestone
1205220LONGmax. years to reach 75% milestone


Some building offsets:
1205006 farms
1205008 raw materials
1205010 workshops
1205014 wall
1205024 hippodrome
1205026 colosseum
1205058 fort
1205062 tower
1205064 small temple
1205066 large temple
1205074 triumphal arch
1205076 dock
1205080 governor's palace
1205084 senate
1205086 forum
1205088 well
1205090 oracle
1205092 mission post
1205094 bridges
1205096 barracks
1205098 military acadamy

Flags:
0x00: off
0x01: on

Good IDs:
0x01: wheat
0x02: vegetables
0x03: fruits
0x04: olives
0x05: vines
0x06: meat/fish
0x07: wine
0x08: oil
0x09: iron
0x0A: timber
0x0B: clay
0x0C: marble
0x0D: weapons
0x0E: furniture
0x0F: pottery

Enemy Types:
0x00: Barbarians
0x01: Etruscans
0x02: Samnites
0x03: Carthaginians
0x04: Macedonians
0x05: Graeci
0x06: Egyptians
0x07: Pergamum
0x08: Seleucids
0x09: Picts
0x0A: Celts
0x0B: Britons
0x0C: Gauls
0x0D: Helvetii
0x0E: Goths
0x0F: Visigoths
0x10: Huns
0x11: Iberians
0x12: Numidians
0x13: Judaeans

Months:
0x00: January
0x01: February
...
0x0B: December

Map Points:
X is the coordinate on the North-East axis
Y is the coordinate on the North-West axis
0xFFFF is used for a non-specified location (default value)



Section 27


Section 27 starts at offset 1205320 and is an array of up to 1000 "messages from your scribes". Each entry is 16 bytes long.

Structure of an entry:

OffsetSizePurpose
04 bytesunknown
4SHORTyear
6BYTEmessage data 1
7BYTEmessage data 2
8SHORTmessage type
10SHORTentry number, starting at 0
12BYTEread flag
13BYTEmonth
142 bytesunknown, always 0s (padding?)


For the message types 0x4a, 0x4b, 0x4e and 0x4f, message data 1 specifies a good ID. For some other message types, message data 1 and message data 2 specify the X- and Y-coordinates of a map location.

Message Types:
0x02: "Population milestone (500 citizens)"
0x03: "Population milestone (1,000 citizens)"
0x04: "Population milestone (2,000 citizens)"
0x05: "Population milestone (3,000 citizens)"
0x06: "Population milestone (5,000 citizens)"
0x07: "Population milestone (10,000 citizens)"
0x08: "Population milestone (15,000 citizens)"
0x09: "Population milestone (20,000 citizens)"
0x0a: "Population milestone (25,000 citizens)"
0x0b: "Rioting in the city"
0x0c: "Fire in the city"
0x0d: "Collapsed building"
0x0e: "Destroyed building (rioters)"
0x10: "City in debt"
0x11: "City in debt again"
0x12: "City still in debt (Emperor is furious)"
0x16: "Local uprising"
0x17: "Barbarians attack!"
0x19: "Distant battle"
0x1a: "Enemies closing"
0x1b: "Enemies at the door"
0x1c: "Emperor requests goods"
0x1e: "Emperor requests army."
0x1f: "Imperial reminder. (Request forgotten?)"
0x20: "The Emperor's gratitude."
0x21: "The Emperor's anger. (Refused to send goods.)"
0x22: "The Emperor's anger. (Forget my request.)"
0x23: "The Emperor's gratitude. (Late delivery)"
0x25: "Employees needed"
0x26: "Small festival"
0x27: "Large festival"
0x28: "Grand festival"
0x29: "Wrath of Ceres"
0x2a: "Wrath of Neptune"
0x2c: "Wrath of Mars"
0x2d: "Wrath of Venus"
0x2e: "People disgruntled"
0x30: "People are angry"
0x34: "Theft"
0x37: "Gods unhappy"
0x3e: "Earthquake!"
0x3f: "Gladiator revolt!"
0x40: "A new Emperor."
0x41: "Sandstorms"
0x42: "Stormy seas"
0x43: "Landslides"
0x44: "Rome pays more wages"
0x45: "Rome pays less wages"
0x46: "Contaminated water"
0x47: "Iron mine caves in"
0x48: "Flooded clay pit"
0x49: "Revolt finished"
0x4a: "Increased trading"
0x4b: "Decreased trading"
0x4d: "Changes to the Empire (boundaries)"
0x4e: "A price rise"
0x4f: "A lower price"
0x57: "Roman city saved"
0x59: "A triumph!!"
0x5b: "Ceres is upset"
0x5c: "Neptune is upset"
0x5d: "Mercury is upset"
0x5e: "Mars is upset"
0x5f: "Venus is upset"
0x60: "A blessing from Ceres"
0x61: "A blessing from Neptune"
0x62: "A blessing from Mercury"
0x63: "A blessing from Mars"
0x64: "A blessing from Venus"
0x65: "The gods are wrathful"
0x67: "Disease"
0x68: "Pestilence"
0x69: "The spirit of Mars"
0x6d: "Working hippodrome"
0x6e: "Working colosseum"
0x6f: "Emigration"
0x72: "Enemy army attacks"
0x73: "Imperial dispatch ready"
0x75: "No working dock"
0x76: "Fishing Boats Can't Navigate"
0x79: "Local uprising (inspired by Mars)"
posted 07-16-08 21:53 ET (US)     3 / 32  
Caesar Jan,

I deliberately avoided looking at your program until I'd released mine for fear of being drawn down yet another road of discovery instead of getting the darn thing done, so I've just looked at it today. I'm very impressed. As you said in another thread, the compression efficiency is not very far short of that used in-game - ) loaded a 127KB save, decompressed it and recompressed and it came back at 128KB. I'm not going to argue with that

You tables are very interesting. Pecunia will love it. I'm really surprised that you had all this knowledge so long ago. Some of your 'unknowns' can be clarified, at least so far as the grids are concerned (this comes from Pecunia's site):

Section 2: Graphic ID's
Section 3: Edge data (Pecunia's term)
Section 4: Building ID's (offsets into building table)
Section 12: Elevation (# of levels)

'Edge data' contains effectively bit vectors describing which tile of a building goes where. Starting from northern tile = 0,0, bits 1 to 3 contain the x coordinate of the tile, bits 4 to 6 the y coordinate. The rest of the map contains what may be a mask of 64 (bit 7) which overlaps the western tile of these buildings. In this section, 'building' includes 2x2 and 3x3 rock formations.

I've just spent the evening examining these grids graphically by getting DesRes to map them as though they were terrain data. Here's what I got:

Section 6: All zeros except 1 = aqueduct. What a waste of space!

Section 7: Walker positions (including fishing boats and seagulls). Any tile with a walker on it when the game was saved has an entry here.

Section 8: Bitfield. Bits 1 to 4 for 2x2 to 5x5 buildings. Bit 5 not used in any map I loaded. Bit 6 (probably randomly determined) locations to display alternative terrain/building graphic. Bit 7 not used. Bit 8 very strange - it's used for plazas and - earthquake fault lines of all things.

Section 9: Associated with animated buildings. I don't fully understand, but any animated building will have data under at least one of its tiles here. Bridges appear here too (even though they're not animated!).

Section 11: Desirability in twos complement notation. Finding this one was very pleasing because I was able to confirm my program is behaving itself.

Section 13: Not found a map where this wasn't all zeros.

Section 14: 1=aqueduct (again!)

Section 15: Apparently the same as section 9.

(I guess you've realized I call the LSB bit 1 and the MSB bit 8)

[This message has been edited by Trium3 (edited 07-18-2008 @ 04:57 AM).]

posted 07-16-08 23:55 ET (US)     4 / 32  
Bit 8 very strange - it's used for plazas and - earthquake fault lines of all things.
Since I haven't understood a word of any of this I've just read it but I thought I'd mention something that may not be widely known nowadays. Earthquake fault lines upset natives and are considered a building that you have placed by the natives on their land. They will attack if the fault lines are in one of their red squares. Don't know if this is of any use but all I can offer.
posted 07-26-08 06:08 ET (US)     5 / 32  
==Section 8: Bitfield. Bits 1 to 4 for 2x2 to 5x5 buildings. Bit 5 not used in any map I loaded. Bit 6 (probably randomly determined) locations to display alternative terrain/building graphic. Bit 7 not used. Bit 8 very strange - it's used for plazas and - earthquake fault lines of all things.==

So would it be possible to edit the quake faultline?

But it ain't necessarily so.
posted 07-27-08 12:10 ET (US)     6 / 32  
So would it be possible to edit the quake faultline?
Not from that particular part of the file, I don't think. That section seems to be all graphics-related and I think the data is only there to trigger an alternative graphic set to the ones normal displayed for rock (which quake-lines are classed as - hence you can mine against them). In any case, this data only shows up after the quake has occurred.

In theory you could edit a map with quake damage to re-route the fault-lines to your convenience (or even remove them altogether) but I think you are more interested in controlling the path before the event rather than after.
posted 08-09-08 13:31 ET (US)     7 / 32  
Impressive!

This may help a lot!

I hate those sea/sand storms and iron mine/clay pit collapse for they bring out those messages and ruins my game at 100% speed.
posted 08-09-08 14:46 ET (US)     8 / 32  
I see you already found it WW.
posted 08-24-08 09:33 ET (US)     9 / 32  
If this tool can edit the amount of products a city can trade, it will be much better. Too sad I can't find the exact offset of them in hex editor.
posted 08-24-08 14:38 ET (US)     10 / 32  
Did you check what is in section 25? Are there really only flags for the items and is the rest of the byte padded with zeroes, or are the other bits used to set the amount.
posted 08-25-08 04:33 ET (US)     11 / 32  
Joshofet - I took a look and yes, they are only flags (0 or 1). Not found where the actual amounts are. Of course, since you only have a choice of three levels they may well be stored as 1, 2 and 3 rather than 15, 25 and 40 so it's hard to know what to look for.

Other things still to be found (which could be useful to scenario designers) include the precise times of 'random' special events (iron mine collapses, etc), the month(s) for god effects, the amounts of increase/decrease in Rome's wages, etc. all of which must be in the save (or calculated from a 'seed' contained therein) since they don't vary with successive plays. I'm also led to believe there is a secondary census adjustment each year in addition to the main one at year roll-over and that also varies with the map save but stays fixed once set.

Right now a means of knowing which iron mine will collapse would come in handy and I know designers are itching to have more control over that earthquake. I'm temporarily preoccupied with other things at present - if anyone knows where any of the 'unknown' stuff is stored please feel free to share it with us.

[This message has been edited by Trium3 (edited 08-25-2008 @ 04:39 AM).]

posted 08-25-08 08:23 ET (US)     12 / 32  
I think I know which iron mine will collapse, but since it is relevant for an ongoing contest at CBC, I will keep that information private until the contest is over.
posted 12-16-08 15:44 ET (US)     13 / 32  
If whisperwind777 is still around, I have those trade amounts, but they are in a compressed part of the file. The annual trade quotas are stored in section 35 and the amounts actually traded this year are stored in section 36. In both sections the information is recorded as 16 x 4-byte (long) integers, one for each goods ID (00 is unused). There is an entry for each city you can trade with. Although Caesar Jan's tool does not directly edit them, you can use it to decompress the save file, edit it with a hex editor and re-compress.

First, open the file in Caesar Jan's tool. Select 'Save As' and set the file type to 'Uncompressed Saved Games'. Then open the resulting file (with a .c3u extension) into your hex editor. Calculate the required offset by (city number x 64) + (goods ID x 4). Add 1251074 (for section 35) or 1252354 (for section 36). Edit the value as required. Save.

In C3 Game Explorer, select 'open', set the file type to 'Uncompressed Saved Games', load your edited file, select 'Save As', set the file type to 'PC Saved Games'. The program will recompress the edited file which can now be loaded into C3.

Note - 'City Number' is the city's consecutive location on the trade list (the same order as it appears in section 25). This is not the same as the city ID.

Edit (a year later ) the parenthesised statement in that note is incorrect. See reply #22

[This message has been edited by Trium3 (edited 01-22-2010 @ 02:37 PM).]

posted 12-16-08 16:49 ET (US)     14 / 32  
I don't know how far scenario designers are interested in this stuff, but it doesn't really come into 'Game Help' so I'm probably best putting it here, especially since it concerns what else you can discover (and edit) using C3GameExplorer to decompress files.

After a few months' distraction with contests I had another look at the save format and can now fill in a few more blanks. Section numbers correspond to those identified by C. Jan in his earlier post.

Section 17 - Destination walkers. 600x2-byte entries (first unused), each referring to the corresponding entry in the Walker Table. Unless the game has some work-around, this implies that there is a limit of 599 destination walkers in addition to the well-known 'sprite' limit of 999. 'Destination walkers' includes random walkers in destination mode.

Section 18 - Paths. One entry for each entry in Section 17 above. A sequence of bytes containing the numbers 0 (indicating North-East) through 7 (indicating North). Thus the sequence 2 2 2 2 1 1 3 3 3 indicates a path heading SE for 4 tiles, E for 2 tiles then S for 3 tiles. The entire sequence is written at each save, even if the walker is already part way along it. On loading the current position in the sequence is derived from the walker's tile counter. The data is not erased when a 'slot' is freed up but is overwritten when that slot is subsequently re-allocated. Thus redundant data may be seen beyond the end of the current path. The limit of 500 bytes of space per entry also implies that a path longer than 500 tiles cannot be permitted.

Section 19 - Formations. Used for soldiers, invaders and animal herds. Up to 16 individual sprites in a single formation. Maximum 50 entries of 128 bytes. 32 bytes are used to identify Walker Table entries for individual members. Entry also contains coordinates, morale (yes, sheep can be Very Bold, even without Academy training ), home building, etc.

Section 31 - Burning buildings. Up to 500 2-byte references to the Buildings Table. May have other purposes, but so far I've only found burning buildings here

Section 33 - Housing list. Up to 2000 2-byte references to the relevant entries in the Buildings Table, presumably used to quickly find vacancies for immigrants.

Section 34 - Storage Facilites. Space for around 200 64-byte entries (exact number unclear since I haven't determined size and purpose of header section) referencing Building Table entries for the city's warehouses and granaries. 15 of those bytes are flags - one for each goods ID. 00=Accepting, 01=Not Accepting, 02=Getting. Wonder what happens if you run out of space? (200 warehouses would put you near the buildings limit anyway)

Section 35 - Trade Quotas. See previous post

Section 36 - Traded Volumes. See previous post

I've also unravelled a lot of the unknown stuff from some of the previously identified sections, but I'm still making progress there. Rather than keep posting extra bits I'll wait until I have something more complete
posted 12-09-09 05:17 ET (US)     15 / 32  
Please Anybody give me link to this file. I want to have raw materials.
posted 12-09-09 05:43 ET (US)     16 / 32  
Hi sevdrone, welcome

What file do you mean, and why would you need it? Can't your problem be resolved in the normal game editor? Please explain your problem, so we can see what help we can offer. You may open a separate thread on it if you want.
posted 12-09-09 05:47 ET (US)     17 / 32  
I see I promised to answer the question about the iron mine above after the mining contest had ended. It has long ago, but I'm afraid I forgot. According to my observations it is the first one built.
posted 12-15-09 20:58 ET (US)     18 / 32  
Joshofet - almost. It is the first one encountered when scanning through the buildings list. Very often, the first built is the first listed, but not always. For example, if you place some vacant lots and build a few mines, the first built will collapse. If some of those lots merge and you build another mine, that becomes the fall guy because it will be listed in one of the now unused slots freed up by the no longer existing tents.
posted 01-21-10 08:47 ET (US)     19 / 32  
Does anyone still happen to have this file and could send it my way? I'd like to play around with it a bit.

Geocities...

[This message has been edited by Pharaoh Aah (edited 01-21-2010 @ 08:48 AM).]

posted 01-21-10 09:38 ET (US)     20 / 32  
If you mean C3GameExplorer, drop an email to the address in my profile (but you have to look for it)
posted 01-22-10 08:00 ET (US)     21 / 32  
First, open the file in Caesar Jan's tool. Select 'Save As' and set the file type to 'Uncompressed Saved Games'. Then open the resulting file (with a .c3u extension) into your hex editor. Calculate the required offset by (city number x 64) + (goods ID x 4). Add 1251074 (for section 35) or 1252354 (for section 36). Edit the value as required. Save.
This is one of the things I'm most interested in modifying in some saves. I think I understand the general process, but haven't managed to successfully calculate the offset yet. (I got a seven-digit number in hex). Do you think you could run a sample edit by me? (Only worried about the quota) I'll probably get it then for sure.
posted 01-22-10 14:25 ET (US)     22 / 32  
Yes, it's a bit complicated

Okay, I've chosen the career Tarsus (if you don't yet have access to Tarsus, pick up somebody's from the downloads section). I load it into C3GameExplorer. I save the file from C3GameExplorer as an uncompressed .c3u and load that into my hex editor. I'm not so good with hex so I'll use decimal for all offsets and values.

The difficult part is establishing which entry relates to which city (my note in reply #13 is incorrect). Section 35, where the trade quotas are stored, does not actually identify the city - it just stores the data and you have to deduce which city each entry relates to. There are two ways to do this - the way you would write a program to do it (by reading the part of the game file which does identify the city) and the way you might prefer to do it as a human (by deduction)

First, the computer's way. Section 25 stores all empire cities in 66-byte entries. Caesar Jan has identified the purpose of some of the values stored in those entries, but not all. In fact, the city's consecutive number in the trade list is stored at offset 4 in each entry, so you scan Section 25 looking for any city which is a trade route (identified by having a 2 or a 3 in offset 2, read the city ID from offset 3 and its consecutive number from offset 4. To do that manually, point your hex editor at the start of Section 25 then advance the cursor 2 bytes. Now repeatedly jump 66 bytes and keep going until you hit a 2 (on the Tarsus map you should be at offset 1201088). The next byte identifies the city (#18 is Miletus) and the byte after tells you it's City Number 1 on the trade list. Continuing this procedure finds Damascus next and identifies it as City Number 4 on the trade list. Then we find Alexandria (#2) and Hierosolyma (#3)

Perhaps easier is to simply examine Section 35 and make deductions about which entry is for which city.

Section 35 begins at offset 1251074 and is arranged as entries of 64 bytes storing 16x4-byte integers. The first entry is unused, so I point my hex editor at the next entry at offset 1251138.

The first integer is always zero (unused). The next is for Goods ID 1 (wheat) and I find the value 40. After that I get zeros for vegetables, fruit, olives and vines, then the value 15 for fish. I know enough now to deduce that this is the entry for Miletus, so for this particular map Miletus is city #1.

The next entry starts at offset 1251202. There I find entries for wine, furniture and weapons, so this city #2 must be Alexandria. Continuing similarly, I find that city #3 is Hierosolyma and #4 is Damascus.

Once we know the city number (by whichever method), we can now find (for example) Hierosolyma's weapons quota by City Number (3) x 64 gives 192 plus Goods ID (13) x 4 = 52 total offset = 244. Add to start of table gives 1251318. To find the corresponding entry in Section 36 (volume traded this year) I add the 244 to the Section 36 offset (1252354) giving 1252598.

I have not experimented with editing these values and I do not know for sure that doing so won't put some other section of the game out of step. I'd expect that you can reset volumes to zero in order to trade more. I don't know if you can trade numbers other than the standard 15, 25 or 40 but I'd like to hear what results you obtain if you should try (and I guess some map designers might like to be able to do that).

I'm sorry it isn't simpler than that. Someone should write a tool to make it easier

[This message has been edited by Trium (edited 01-22-2010 @ 02:31 PM).]

posted 01-22-10 17:45 ET (US)     23 / 32  
Thanks for the very detailed help!

I've now been able to change a yearly quota, and change which city name is where (that one's not too useful).

I also tried changing vegetables in Miletus from 00 to 0F, but it didn't show up as either buying or selling, so I imagine there's another piece to the puzzle somewhere that's needed if you wish to add new goods to a trade city.

I'll definitely play around some more.
posted 01-22-10 19:33 ET (US)     24 / 32  
I know it's a very long post, but look again at Caesar Jan's notes for Section 25. There are a set of buy/sell flags in there.

You'll need to go through S25 in order to find the entry for Miletus (in the Tarsus map it starts at 1201086). Move forward 6 bytes to where the 'buy' flags start or 22 bytes to where the 'sell' flags start. The first flag is always zero - vegetables is the third. Set the required flag to 01 and your vegetables ought to show up.

I'm not very familiar with the map editor but I think it imposes limits on how many goods you can trade with one city (one of our designers may confirm this - perhaps three imports and three exports?). I have no idea what might happen if you manually override this limit - certainly I'd expect problems with space to display the list in interface elements like the Empire Map and the 'goods carried' by trade ships.

[This message has been edited by Trium (edited 01-22-2010 @ 07:38 PM).]

posted 01-24-10 09:24 ET (US)     25 / 32  
Can't believe I missed those!

Anyway, after a day of paper writing, I got back to playing around with that and changed the file as indicated. Unfortunately, they haven't shown up; might there be a flag somewhere that indicates how many goods a city currently buys or sells?
I'm almost positive that the limit is three, as no city in any empire state offers more than that.
« Previous Page  1 2  Next Page »
Caesar IV Heaven » Forums » Caesar III: Scenario Design » Saved games tool (C3GameExplorer)
Top
You must be logged in to post messages.
Please login or register
Hop to:    
Caesar IV Heaven | HeavenGames