00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00030
00031
00032
00033
00034
00035 #include "stratagus.h"
00036 #include "map.h"
00037 #include "patch_manager.h"
00038 #include "iolib.h"
00039 #include "version.h"
00040
00041
00042
00043
00044
00045
00046
00047
00048
00054 void CMap::Save(CFile *file) const
00055 {
00056 file->printf("\n--- -----------------------------------------\n");
00057 file->printf("--- MODULE: map\n\n");
00058
00059 file->printf("StratagusMap(\n");
00060
00061 file->printf(" \"version\", \"" StratagusFormatString "\",\n",
00062 StratagusFormatArgs(StratagusVersion));
00063 file->printf(" \"description\", \"%s\",\n", this->Info.Description.c_str());
00064
00065 file->printf(" \"the-map\", {\n");
00066
00067 file->printf(" \"size\", {%d, %d},\n", this->Info.MapWidth, this->Info.MapHeight);
00068 file->printf(" \"%s\",\n", this->NoFogOfWar ? "no-fog-of-war" : "fog-of-war");
00069 file->printf(" \"filename\", \"%s\",\n", this->Info.Filename.c_str());
00070
00071 file->printf(" \"map-fields\", {\n");
00072 for (int h = 0; h < this->Info.MapHeight; ++h) {
00073 file->printf(" -- %d\n", h);
00074 for (int w = 0; w < this->Info.MapWidth; ++w) {
00075 CMapField* mf;
00076
00077 mf = this->Field(w, h);
00078 file->printf(" {");
00079 for (int i = 0; i < PlayerMax; ++i) {
00080 if (mf->Visible[i] == 1) {
00081 file->printf(" \"explored\", %d,", i);
00082 }
00083 }
00084 if (mf->Flags & MapFieldLandAllowed) {
00085 file->printf(" \"land\",");
00086 }
00087 if (mf->Flags & MapFieldCoastAllowed) {
00088 file->printf(" \"coast\",");
00089 }
00090 if (mf->Flags & MapFieldWaterAllowed) {
00091 file->printf(" \"water\",");
00092 }
00093 if (mf->Flags & MapFieldNoBuilding) {
00094 file->printf(" \"mud\",");
00095 }
00096 if (mf->Flags & MapFieldUnpassable) {
00097 file->printf(" \"block\",");
00098 }
00099 #if 1
00100
00101
00102
00103 if (mf->Flags & MapFieldLandUnit) {
00104 file->printf(" \"ground\",");
00105 }
00106 if (mf->Flags & MapFieldAirUnit) {
00107 file->printf(" \"air\",");
00108 }
00109 if (mf->Flags & MapFieldSeaUnit) {
00110 file->printf(" \"sea\",");
00111 }
00112 if (mf->Flags & MapFieldBuilding) {
00113 file->printf(" \"building\",");
00114 }
00115 #endif
00116 if (w & 1) {
00117 file->printf("},\n");
00118 } else {
00119 file->printf("}, ");
00120 }
00121 }
00122 }
00123 file->printf("}})\n");
00124
00125 file->printf("%s", PatchManager.savePatches().c_str());
00126 }
00127