Skip to content

Serialization Design

Rhys Fuller edited this page Apr 8, 2022 · 8 revisions

File Format

  • File will be in binary.
  • File will begin with the string "Civilization209" to prove that it is a proper save file of the game.
  • File will then have an integer representing the current score of the game.
  • File will then have a char representing the current season of the game.
  • File will then have a double representing the game speed.
  • File will then have an integer X representing the number of items in the Entity List.
  • Following that, there will be X sections representing X entities.
    • Section will start with a string identifying the type of entity.
    • Section will then have two doubles representing the location coordinates.
    • Section will then have an integer representing the turn count.
      • For sections representing Mobile Entities, there will then be two doubles representing the current destination coordinates.
      • For sections representing Mobile Entities, there will then be a double representing speed.
      • For sections representing Mobile Entities, there will then be a double representing heading.
        • For Mobile Entity Sections representing Troops, there will be an integer representing health and a character representing nationality.
        • For Mobile Entity Sections representing Projectiles, there will be an integer representing damage.
        • For Mobile Entity Sections representing Weather, there will be a char representing weather type.
      • For sections representing cities, there will be an integer representing the population.
      • For sections representing cities, there will be a double representing incrementation rate.
      • For sections representing cities, there will be a char representing nationality.
      • For sections representing cities, there will be a boolean representing selected.
      • For sections representing cities, there will be a double representing fire rate.

Sample File

(Text representation of binary)

Civilization209
939
.5
4
W
City|43.2|23.4|5|21|1.0|P|true|2.0|
Troop|80.2|46.2|3|100.0|100.0|1.7|180.0|2|P|
Projectile|70.4|46.2|1|80.2|46.2|1.3|180.0|2|
Weather|300.2|267.4|0|1000.0|1000.0|5.0|180.0|F|

Links to Relevant Code

Game Load Function

Game Save Function

Individual Save Functions not yet implemented as according to specification.

Clone this wiki locally