Add CMapField::Save.
This commit is contained in:
parent
b57817ffd6
commit
fee897b0a7
2 changed files with 62 additions and 52 deletions
|
@ -136,6 +136,7 @@
|
|||
#include "unit_cache.h"
|
||||
#endif
|
||||
|
||||
class CFile;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Map - field
|
||||
|
@ -176,6 +177,9 @@ public:
|
|||
#endif
|
||||
{}
|
||||
|
||||
void Save(CFile &file) const;
|
||||
|
||||
public:
|
||||
unsigned short Tile; /// graphic tile number
|
||||
unsigned short Flags; /// field flags
|
||||
unsigned char Cost; /// unit cost to move in this tile
|
||||
|
|
|
@ -47,6 +47,61 @@
|
|||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
void CMapField::Save(CFile &file) const
|
||||
{
|
||||
file.printf(" {%3d, %3d, %2d, %2d,", Tile, playerInfo.SeenTile, Value, Cost);
|
||||
for (int i = 0; i != PlayerMax; ++i) {
|
||||
if (playerInfo.Visible[i] == 1) {
|
||||
file.printf(" \"explored\", %d,", i);
|
||||
}
|
||||
}
|
||||
if (Flags & MapFieldHuman) {
|
||||
file.printf(" \"human\",");
|
||||
}
|
||||
if (Flags & MapFieldLandAllowed) {
|
||||
file.printf(" \"land\",");
|
||||
}
|
||||
if (Flags & MapFieldCoastAllowed) {
|
||||
file.printf(" \"coast\",");
|
||||
}
|
||||
if (Flags & MapFieldWaterAllowed) {
|
||||
file.printf(" \"water\",");
|
||||
}
|
||||
if (Flags & MapFieldNoBuilding) {
|
||||
file.printf(" \"mud\",");
|
||||
}
|
||||
if (Flags & MapFieldUnpassable) {
|
||||
file.printf(" \"block\",");
|
||||
}
|
||||
if (Flags & MapFieldWall) {
|
||||
file.printf(" \"wall\",");
|
||||
}
|
||||
if (Flags & MapFieldRocks) {
|
||||
file.printf(" \"rock\",");
|
||||
}
|
||||
if (Flags & MapFieldForest) {
|
||||
file.printf(" \"wood\",");
|
||||
}
|
||||
#if 1
|
||||
// Not Required for save
|
||||
// These are required for now, UnitType::FieldFlags is 0 until
|
||||
// UpdateStats is called which is after the game is loaded
|
||||
if (Flags & MapFieldLandUnit) {
|
||||
file.printf(" \"ground\",");
|
||||
}
|
||||
if (Flags & MapFieldAirUnit) {
|
||||
file.printf(" \"air\",");
|
||||
}
|
||||
if (Flags & MapFieldSeaUnit) {
|
||||
file.printf(" \"sea\",");
|
||||
}
|
||||
if (Flags & MapFieldBuilding) {
|
||||
file.printf(" \"building\",");
|
||||
}
|
||||
#endif
|
||||
file.printf("}");
|
||||
}
|
||||
|
||||
/**
|
||||
** Save the complete map.
|
||||
**
|
||||
|
@ -77,60 +132,11 @@ void CMap::Save(CFile &file) const
|
|||
for (int w = 0; w < this->Info.MapWidth; ++w) {
|
||||
const CMapField &mf = *this->Field(w, h);
|
||||
|
||||
file.printf(" {%3d, %3d, %2d, %2d,", mf.Tile, mf.playerInfo.SeenTile, mf.Value, mf.Cost);
|
||||
for (int i = 0; i < PlayerMax; ++i) {
|
||||
if (mf.playerInfo.Visible[i] == 1) {
|
||||
file.printf(" \"explored\", %d,", i);
|
||||
}
|
||||
}
|
||||
if (mf.Flags & MapFieldHuman) {
|
||||
file.printf(" \"human\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldLandAllowed) {
|
||||
file.printf(" \"land\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldCoastAllowed) {
|
||||
file.printf(" \"coast\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldWaterAllowed) {
|
||||
file.printf(" \"water\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldNoBuilding) {
|
||||
file.printf(" \"mud\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldUnpassable) {
|
||||
file.printf(" \"block\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldWall) {
|
||||
file.printf(" \"wall\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldRocks) {
|
||||
file.printf(" \"rock\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldForest) {
|
||||
file.printf(" \"wood\",");
|
||||
}
|
||||
#if 1
|
||||
// Not Required for save
|
||||
// These are required for now, UnitType::FieldFlags is 0 until
|
||||
// UpdateStats is called which is after the game is loaded
|
||||
if (mf.Flags & MapFieldLandUnit) {
|
||||
file.printf(" \"ground\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldAirUnit) {
|
||||
file.printf(" \"air\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldSeaUnit) {
|
||||
file.printf(" \"sea\",");
|
||||
}
|
||||
if (mf.Flags & MapFieldBuilding) {
|
||||
file.printf(" \"building\",");
|
||||
}
|
||||
#endif
|
||||
mf.Save(file);
|
||||
if (w & 1) {
|
||||
file.printf("},\n");
|
||||
file.printf(",\n");
|
||||
} else {
|
||||
file.printf("}, ");
|
||||
file.printf(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue