Difference between revisions of "Savegame"

From SC4D Encyclopaedia
Jump to navigation Jump to search
(Naomi57 on Simtropolis)
Line 1,291: Line 1,291:
 
|}
 
|}
  
 +
==Source code==
  
 +
Here's a link to the '''CRC algorithm on GitHub''', the algorithm used for the savegame file checksum.
 +
 +
::'''<nowiki>https://github.com/sebamarynissen/SC4/blob/ee7bee8173ec46d155ceaa316eaab074404dff87/src/crc.cpp</nowiki>'''
  
 
{{navbox/SUBFILE}}
 
{{navbox/SUBFILE}}

Revision as of 17:21, 12 March 2020


Savegame (.sc4) files are DBPF files, containing a number of files specific to the city. They can be opened with Reader and the SC4 Savegame Explorer.

It was long thought that it was impossible to modify savegames because the files within it are protected with a CRC checksum. The game refuses to load certain files if it detects the checksum of the file is invalid. This means that every modification to a file in the Savegame requires the checksum to be recalculated as well.

The algorithm used for the checksum was discovered by Simmaster07 during his work on the Prop Pox Fix and was picked up by smf_16 to build a proof of concept that Savegames could in fact be edited which led to an experimental fix for ploppable residentials.

Files Within Savegames

A file within a Savegame may consist of multiple records. Almost every record in the Savegame files has the following structure:

DWORD	Size
DWORD	CRC
DWORD	Memory
BYTES   All the rest

where

  • Size is the length of the record in bytes
  • CRC is the CRC Checksum of the record. This is calculated by running the entire record through the Checksum algorithm, except' for the first 8 bytes (which is the Size and the CRC itself).
  • Memory is a unique identifier of the record. The game probably simply uses the numerical value of the pointer to the record for this. Never set this to 0x00000000 or you'll crash the game.

Below follows a list of all files that can appear within a Savegame. Note that most can be identified by Type Id alone. Not every file has been fully decoded yet, although the most important ones such as the Lot Subfile and the Building Subfile have been more or less fully decoded.

Type ID Group ID Instance ID Name C++ Class Status
ead4ba36 299b2d1b cSC4CityDetailManager
eac937b4 Environmental Advisor/Fluffy News Advisor cSC4Advisor
ea863423 cSC4GetawayVan
ea3ff4f5 ea3ff506 ea3ff4f5 Separator File SC4ReadAppLoadSaveVersion Done
ea230a28 cSC4SeaportDeveloper
ea19e825 Public Safety Advisor cSC4AdvisorSafety
ea0a5acf cSC4PipeConnectionOccupant
ea09d4ae cSC4LandfillDeveloper
e9c622d8 cSC43DRender
e9a6cd3b cSC4NetworkLotManager
e990c18e cSC4LandValueSimulator
e990c045 cSC4FlammabilitySimulator
e990bffc Budget Subfile cSC4DepartmentBudget Partially Decoded
e990be01 Budget Subfile cSC4BudgetSimulator Partially Decoded
e98f9525 cSTETerrain
e86b1eef e86b1eef 286b1f03 Directory File cGZDBSegmentPackedFile Done
e0d07233 Pro-Reading Ordinance cSC4OrdinanceProReadingCampaign Mostly Decoded
e0d0722e Nuclear-Free Ordinance cSC4OrdinanceNuclearFreeZone Mostly Decoded
cbeb4f62 Advisor? cSC4Airplane
cbc14674 cSC4MySimDispatch
cbb32b0a cSC4CarjackedVehicle
ca2c2a2f Utilities Advisor cSC4AdvisorUtility
ca16374f Network Subfile 2 cSC4SubwayOccupant Done
ca15ed6b cSC4SubwayConnectionOccupant
ca14ca03 cSC4AutomataControllerManager
ca09f543 Advisor? (The template for the other advisors?) cSC4AdvisorBase
ca027edb ca027ee1 Region View City Data SC4ReadRegionalCity Partially Decoded
c9efb016 cSC4PropOccupantBurntBuilding
c9c628ec cSC4CameraControl
c9c05c6e Network Subfile 1 cSC4NetworkOccupant Done
c9c05c5d cSC4PowerLineOccupant
c9bd5d4a Lot Subfile cSC4Lot
c9b84e10 cSTETerrainView3D
c990c0a4 cSC4NeighborsSimulator
c990c034 cSC4FloraSimulator
c990bd46 cSC4NetworkManager
c98f9d4a cSC4AircraftManager
c98f9d17 cSC4PedestrianManager
c97f987c cSC4LotBaseTextureOccupant
c2f6e81f Tire Recycling Ordinance cSC4OrdinanceTireRecycling Mostly Decoded
c2bf1e04 Auto Emission Ordinance cSC4OrdinanceVehicleEmissionStandard Mostly Decoded
c2bf1dc5 Youth Curfew Ordinance cSC4OrdinanceYouthCurfew Mostly Decoded
ab72fbb3 Signs cSC4SignpostOccupant
aa9f4a3d Automata cSC4Bus
aa5292d7 Finance Advisor cSC4AdvisorFinance
aa3fe6bc cSC4ParkManager
aa3836fb Tutorial Subfile cSC4TutorialSystem
aa371c32 Reward Advice Subfile cSC4RewardAdvice
aa313c9f Budget Subfile cSC4LineItem Mostly Decoded
aa2049a1 cSC4AirportDeveloper
aa09dc28 cSC4PedestrianOneShot
a9dd6ff4 e98f9525 00000067 Reconcile Map South Side cSTETerrain::SaveEdgeAltitudes Almost Complete
a9dd6ff4 e98f9525 00000066 Reconcile Map East Side cSTETerrain::SaveEdgeAltitudes Almost Complete
a9dd6ff4 e98f9525 00000065 Reconcile Map North Side cSTETerrain::SaveEdgeAltitudes Almost Complete
a9dd6ff4 e98f9525 00000064 Reconcile Map West Side cSTETerrain::SaveEdgeAltitudes Almost Complete
a9dd6ff4 e98f9525 00000001 Terrain Map cSTETerrain::SaveAltitudes Done
a9c8647c e9c8647e 00000001 cSC4View3DWin
a9c741b3 cSC4ModelMaker
a9c05c85 Flora Subfile cSC4FloraOccupant
a9bd882d Building Subfile cSC4BuildingOccupant Basic Overlay Done
a9bc9ab6 cSC4Occupant
a990c08e cSC4OrdinanceSimulator
a990c022 cSC4IndustrialSimulator
a990bfe0 cSC4LotDeveloper
a990bd10 cSC4PropManager
a98f9d3b cSC4VehicleManager
a98f9d28 cSC4WatercraftManager
a97f909e cSC4ConstructionOccupant
a7e7f929 cSC424HourClock
a2bf1e43 Clean Air Ordinance cSC4OrdinanceCleanAir Mostly Decoded
a2bf1de5 Commuter Shuttle Ordinance cSC4OrdinanceShuttleService Mostly Decoded
a2bf1ddc Carpool Ordinance cSC4OrdinanceCarpoolIncentive Mostly Decoded
a0d07129 Legal Gambling Ordinance cSC4OrdinanceLegalizeGambling Mostly Decoded
8be3753b City Situations Advice Subfile cSC4CitySituationAdvice
8ba98eda cSC4Helicopter
8b79c707 Painted Labels cSC4TextDecalOccupant
8a91e7e3 e98f9525 00000003 cSTETerrain::SaveMiscTerrainData
8a91e7e0 e98f9525 00000002 cSTETerrain::SaveVertexProperties
8a4bd52b cSC4NetworkTunnelOccupant
8a41625a cSC4Train
8a2482b9 4a2492bb 00000006 PNG File cSC4City::WriteRegionViewThumbnail Done
8a2482b9 4a2492bb 00000004 PNG File cSC4City::WriteRegionViewThumbnail Done
8a2482b9 4a2492bb 00000002 PNG File cSC4City::WriteRegionViewThumbnail Done
8a2482b9 4a2492bb 00000000 PNG File cSC4City::WriteRegionViewThumbnail Done
8a22bebe cSC4LandfillOccupant
8a09f5f4 Advice Subfiles cSC4Advice
89efa536 Historical Data of City/Graph Data cSC4HistoryWarehouse Mostly Decoded
89d9b9ee 69d9b9f1 cSC4AutoSaveRecord Stores cGZCheatCodeManager::GetCheatCodeSaveData
89c49986 cSC4WealthRequester
89c48f47 cSC4PropDeveloper
8990c372 Mayor View City Data cSC4City
8990c12d cSC4Demand
8990c09a cSC4CrimeSimulator
8990c080 cSC4CommercialSimulator
8990c065 Water Pollution cSC4PollutionSimulator
8990be7a cSC4BuildingDevelopmentSimulator
896e75af cSC4Pedestrian
896e714a Road Construction Automata cSC4Vehicle
82b9999b Power Conservation Ordinance cSC4OrdinancePowerConservation Mostly Decoded
815b4cef Junior Sports Ordinance cSC4OrdinanceJuniorSportsLeague Mostly Decoded
6c1acde1 cSC4Ambulance
6b70efad cSC4MySimBalloonAdvice
6a9335de MySim Advice Subfile cSC4MySimAdvice
6a5f8755 Health & Education Advisor cSC4AdvisorHQ
6a3848db Advice Subfiles cSC4AdviceNeghborDeal
6a26d049 cSC4AdviceSubject
6a1628ba cSC4AutomataAttractor
6a0f82b2 Network Index Subfile cSC4TrafficNetworkMap Decoded
6990c1aa Sims to Jobs Match cSC4TrafficSimulator
6990c04f cSC4PoliceSimulator
6534284a Type 10 Exemplars Decoded.
62f6e7cf Tourism Ordinance cSC4OrdinanceTouristPromotion Mostly Decoded
62bf1db9 Neighborhood Watch Ordinance cSC4OrdinanceNeighborhoodWatch Mostly Decoded
62bf1daa Smoke Detector Ordinance cSC4OrdinanceMandatorySmokeDetectors Mostly Decoded
4c0dd224 cSC4MayorLimo
4c0ae114 cSC4FirePlaneDispatchSource
4be372cd Situation Manager cSC4AdvisorCitySituations
4a5b69ed Automata cSC4TrailerVehicle
4a416254 Automata cSC4TrainCar
4a3ad3e1 Transportation Advisor cSC4AdvisorTraffic
4a232da8 Industry Subfile cSC4BusinessUnit
4a222b98 Automata cSC4PatrolCar
4a1dbbbf MySim Advisors cSC4MySim
4a1b664e cSC4AutomataScriptSystem
4a1628c5 Wildlife Generator cSC4AutomataGenerator
4a0dd616 cSC4AdvisorSystem
49dd6f4c 49dd6f4e 00000001
49cc1bcd cSC4NetworkBridgeOccupant
49c1a034 cSC4NetworkOccupantWithPreBuiltModel
49c05c9f Lot Retaining Walls cSC4LotRetainingWallOccupant
49c05c8f Props cSC4FoundationOccupant
49c05b9f cSC4PipeOccupant
49b9e60a cSC4SimGridFloat32
49b9e606 cSC4SimGridUint32
49b9e605 cSC4SimGridSint16
49b9e604 cSC4SimGridUint16
49b9e603 cSC4SimGridSint8
49b9e602 cSC4SimGridUint8
499b23fe cSC4COMSerializer::SaveClassObjects
4990c013 cSC4ResidentialSimulator
4990bd93 cSC4DispatchManager
498f9b01 cSC4ZoneDeveloper
42bf1e18 Trash Presort Ordinance cSC4OrdinanceTrashPresort Mostly Decoded
40d07236 Free Clinic Ordinance cSC4OrdinanceFreeClinics Mostly Decoded
2b689130 Deals
2a5f877d City Planner Advisor cSC4AdvisorCityPlanning
2a134f42 cSC4NeighborDeal
2990c1e5 Date Subfile cSC4Simulator Partially Decoded
2990c1bc Terrain Arrays cSC4WeatherSimulator Basic Overlay Completed
2990c142 cSC4TractDeveloper
2990c05a cSC4FireProtectionSimulator
2990bff2 cSC4DemandSimulator
299062c0 cSC4LotConfigurationManager
2977aa48 Prop Terrain Decal cSC4PropOccupantTerrainDecal
298f9b2d cSC4ZoneManager
2977aa49 Prop Visual Effect cSC4PropOccupantVisualEffect
2977aa47 Prop Subfile cSC4PropOccupant
22f6e81b Paper Waste Ordinance cSC4OrdinancePaperReductionAct Mostly Decoded
22f6e80c Landfill Gas Ordinance cSC4OrdinanceLandfillGasRecovery Mostly Decoded
2026960b 4a2482bb 00000007 Temp.PNG file cSC4City::WriteRegionViewThumbnail Done
2026960b 4a2482bb 00000005 Temp.PNG file cSC4City::WriteRegionViewThumbnail Done
2026960b 4a2482bb 00000003 Temp.PNG file cSC4City::WriteRegionViewThumbnail Done
2026960b 4a2482bb 00000001 Temp.PNG file cSC4City::WriteRegionViewThumbnail Done
0c0b06e8 cSC4PoliceHelicopterDispatchSource
0bf606a5 My Street Sim cSC4MyStreetSim
0bb14381 cSC4CitySituationManager
0b7d45e0 0b7d45e1 0b7d45e2
0a413481 Reward Requirements cSC4CivicBuildingSimulator
0a134f24 cSC4NeighborConnection
09c05c6a cSC4PowerPoleOccupant
0990c38a cSC4Demolition
0990c138 cSC4GrowthDeveloper
0990c075 cSC4PlumbingSimulator
0990c005 Power Simulator Subfile cSC4PowerSimulator Basic Overlay Completed
0990bdd8 cSC4AuraSimulator
098f964d Item Index Subfile cSC4OccupantManager
096e75f5 cSC4Watercraft
02bf1dfa Water Conservation Ordinance cSC4OrdinanceWaterConservation Mostly Decoded
00d0723d Community CPR Ordinance cSC4OrdinanceCommunityCPRTraining Mostly Decoded

Source code

Here's a link to the CRC algorithm on GitHub, the algorithm used for the savegame file checksum.

https://github.com/sebamarynissen/SC4/blob/ee7bee8173ec46d155ceaa316eaab074404dff87/src/crc.cpp