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);
312 if (simSpeed < 0 || simSpeed > 3) {
342 if ((f = fopen(filename.c_str(),
"wb")) == NULL) {
403 std::string name = NULL;
404 std::string fname = NULL;
410 if (s < SC_DULLSVILLE || s >
SC_RIO) {
417 fname =
"cities/scenario_dullsville.cty";
419 cityTime = ((1900 - 1900) * 48) + 2;
423 name =
"San Francisco";
424 fname =
"cities/scenario_san_francisco.cty";
426 cityTime = ((1906 - 1900) * 48) + 2;
431 fname =
"cities/scenario_hamburg.cty";
433 cityTime = ((1944 - 1900) * 48) + 2;
438 fname =
"cities/scenario_bern.cty";
440 cityTime = ((1965 - 1900) * 48) + 2;
445 fname =
"cities/scenario_tokyo.cty";
447 cityTime = ((1957 - 1900) * 48) + 2;
452 fname =
"cities/scenario_detroit.cty";
454 cityTime = ((1972 - 1900) * 48) + 2;
459 fname =
"cities/scenario_boston.cty";
461 cityTime = ((2010 - 1900) * 48) + 2;
465 name =
"Rio de Janeiro";
466 fname =
"cities/scenario_rio_de_janeiro.cty";
468 cityTime = ((2047 - 1900) * 48) + 2;
496 callback->didLoadScenario(
this, callbackVal, name, fname);
515 size_t pos = (lastSlash == std::string::npos) ? 0 : lastSlash + 1;
519 (lastDot == std::string::npos) ?
cityFileName.length() : lastDot;
521 std::string newCityName =
cityFileName.substr(pos, last - pos);
522 setCityName(newCityName);
540 callback->didLoadCity(
this, callbackVal, filename);
550 callback->didntLoadCity(
this, callbackVal, filename);
585 callback->saveCityAs(
this, callbackVal, filename);
595 callback->didSaveCity(
this, callbackVal, filename);
605 callback->didntSaveCity(
this, callbackVal, filename);
626 (lastSlash == std::string::npos) ? 0 : lastSlash + 1;
628 (lastDot == std::string::npos) ?
cityFileName.length() : lastDot;
631 std::string newCityName =
634 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)