85#if !defined(__BIG_ENDIAN__)
92#define SWAP_SHORTS(buf, len) swap_shorts(buf, len)
99#define HALF_SWAP_LONGS(buf, len) half_swap_longs(buf, len)
111 for (i = 0; i < len; i++) {
112 *buf = ((*buf & 0xFF) <<8) | ((*buf &0xFF00) >>8);
128 for (i = 0; i < len; i++) {
131 ((l & 0x0000ffff) << 16) |
132 ((l & 0xffff0000) >> 16);
148#define SWAP_SHORTS(buf, len)
157#define HALF_SWAP_LONGS(buf, len)
173 size_t result = fread(buf,
sizeof(
short), len, f);
175 if ((
int)result != len) {
198 if ((
int)fwrite(buf,
sizeof(
short), len, f) != len) {
219 f = fopen(filename.c_str(),
"rb");
226 fseek(f, 0L, SEEK_END);
228 fseek(f, 0L, SEEK_SET);
233 mapSizeShort *
sizeof(short);
238 historySize + mapSize;
240 historySize + mapSize + mapSize;
244 hasMop || (size == mapFileSize);
257 ?
load_short((
short *)mopBase, mapSizeShort, f)
339 if (simSpeed < 0 || simSpeed > 3) {
369 if ((f = fopen(filename.c_str(),
"wb")) == NULL) {
431 std::string name = NULL;
432 std::string fname = NULL;
438 if (s < SC_DULLSVILLE || s >
SC_RIO) {
445 fname =
"cities/scenario_dullsville.cty";
447 cityTime = ((1900 - 1900) * 48) + 2;
451 name =
"San Francisco";
452 fname =
"cities/scenario_san_francisco.cty";
454 cityTime = ((1906 - 1900) * 48) + 2;
459 fname =
"cities/scenario_hamburg.cty";
461 cityTime = ((1944 - 1900) * 48) + 2;
466 fname =
"cities/scenario_bern.cty";
468 cityTime = ((1965 - 1900) * 48) + 2;
473 fname =
"cities/scenario_tokyo.cty";
475 cityTime = ((1957 - 1900) * 48) + 2;
480 fname =
"cities/scenario_detroit.cty";
482 cityTime = ((1972 - 1900) * 48) + 2;
487 fname =
"cities/scenario_boston.cty";
489 cityTime = ((2010 - 1900) * 48) + 2;
493 name =
"Rio de Janeiro";
494 fname =
"cities/scenario_rio_de_janeiro.cty";
496 cityTime = ((2047 - 1900) * 48) + 2;
524 callback->didLoadScenario(
this, callbackVal, name, fname);
543 size_t pos = (lastSlash == std::string::npos) ? 0 : lastSlash + 1;
547 (lastDot == std::string::npos) ?
cityFileName.length() : lastDot;
549 std::string newCityName =
cityFileName.substr(pos, last - pos);
550 setCityName(newCityName);
570 callback->didLoadCity(
this, callbackVal, filename);
580 callback->didntLoadCity(
this, callbackVal, filename);
615 callback->saveCityAs(
this, callbackVal, filename);
625 callback->didSaveCity(
this, callbackVal, filename);
635 callback->didntSaveCity(
this, callbackVal, filename);
656 (lastSlash == std::string::npos) ? 0 : lastSlash + 1;
658 (lastDot == std::string::npos) ?
cityFileName.length() : lastDot;
661 std::string newCityName =
664 setCityName(newCityName);
bool doInitialEval
Need to perform initial city evaluation.
void didntLoadCity(const std::string &msg)
bool loadFileData(const std::string &filename)
void doSaveCityAs(const std::string &filename)
void didSaveCity(const std::string &filename)
Scenario scenario
Scenario being played.
std::string cityFileName
Filename of the last loaded city.
void loadScenario(Scenario s)
void didntSaveCity(const std::string &msg)
void setAutoGoto(bool value)
bool loadFile(const std::string &filename)
std::string cityName
Name of the city.
void setFunds(int dollars)
void didLoadCity(const std::string &filename)
void setAutoBulldoze(bool value)
void setEnableSound(bool value)
bool mustUpdateOptions
Options displayed at user need updating.
void saveCityAs(const std::string &filename)
unsigned short * map[WORLD_W]
bool enableSound
Enable sound.
bool saveFile(const std::string &filename)
void setGameLevel(GameLevel level)
void didLoadScenario(int s, const std::string name, const std::string fname)
void setCleanCityName(const std::string &name)
bool loadCity(const std::string &filename)
Quad totalFunds
Funds of the player.
void setAutoBudget(bool value)
static bool load_short(short *buf, int len, FILE *f)
static void half_swap_longs(long *buf, int len)
#define HALF_SWAP_LONGS(buf, len)
static void swap_shorts(short *buf, int len)
#define SWAP_SHORTS(buf, len)
static bool save_short(short *buf, int len, FILE *f)
Header file for Micropolis game engine.
@ SC_TOKYO
Tokyo (scary monster)
@ SC_NONE
No scenario (free playing)
@ SC_BOSTON
Boston (nuclear meltdown)
@ SC_SAN_FRANCISCO
San francisco (earthquake)
@ SC_HAMBURG
Hamburg (fire bombs)
@ SC_DULLSVILLE
Dullsville (boredom)
@ SC_DETROIT
Detroit (crime)
static const int HISTORY_LENGTH
@ LEVEL_EASY
Simple game level.
static const int MISC_HISTORY_LENGTH
static T max(const T a, const T b)