openttd.c
changeset 4171 5c6e60c392c3
parent 4132 ed67e886fd89
child 4184 541f819f2125
equal deleted inserted replaced
4170:81bafc4dd1b9 4171:5c6e60c392c3
    66 
    66 
    67 /* TODO: usrerror() for errors which are not of an internal nature but
    67 /* TODO: usrerror() for errors which are not of an internal nature but
    68  * caused by the user, i.e. missing files or fatal configuration errors.
    68  * caused by the user, i.e. missing files or fatal configuration errors.
    69  * Post-0.4.0 since Celestar doesn't want this in SVN before. --pasky */
    69  * Post-0.4.0 since Celestar doesn't want this in SVN before. --pasky */
    70 
    70 
    71 void CDECL error(const char* s, ...)
    71 void CDECL error(const char *s, ...)
    72 {
    72 {
    73 	va_list va;
    73 	va_list va;
    74 	char buf[512];
    74 	char buf[512];
    75 
    75 
    76 	va_start(va, s);
    76 	va_start(va, s);
   228 		}
   228 		}
   229 	}
   229 	}
   230 }
   230 }
   231 
   231 
   232 
   232 
   233 static void ParseResolution(int res[2], const char* s)
   233 static void ParseResolution(int res[2], const char *s)
   234 {
   234 {
   235 	char *t = strchr(s, 'x');
   235 	char *t = strchr(s, 'x');
   236 	if (t == NULL) {
   236 	if (t == NULL) {
   237 		ShowInfoF("Invalid resolution '%s'", s);
   237 		ShowInfoF("Invalid resolution '%s'", s);
   238 		return;
   238 		return;
   308 
   308 
   309 #if defined(UNIX) && !defined(__MORPHOS__)
   309 #if defined(UNIX) && !defined(__MORPHOS__)
   310 extern void DedicatedFork(void);
   310 extern void DedicatedFork(void);
   311 #endif
   311 #endif
   312 
   312 
   313 int ttd_main(int argc, char* argv[])
   313 int ttd_main(int argc, char *argv[])
   314 {
   314 {
   315 	MyGetOptData mgo;
   315 	MyGetOptData mgo;
   316 	int i;
   316 	int i;
   317 	const char *optformat;
   317 	const char *optformat;
   318 	char musicdriver[16], sounddriver[16], videodriver[16];
   318 	char musicdriver[16], sounddriver[16], videodriver[16];
   999 	MusicLoop();
   999 	MusicLoop();
  1000 }
  1000 }
  1001 
  1001 
  1002 void BeforeSaveGame(void)
  1002 void BeforeSaveGame(void)
  1003 {
  1003 {
  1004 	const Window* w = FindWindowById(WC_MAIN_WINDOW, 0);
  1004 	const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
  1005 
  1005 
  1006 	if (w != NULL) {
  1006 	if (w != NULL) {
  1007 		_saved_scrollpos_x = WP(w, const vp_d).scrollpos_x;
  1007 		_saved_scrollpos_x = WP(w, const vp_d).scrollpos_x;
  1008 		_saved_scrollpos_y = WP(w, const vp_d).scrollpos_y;
  1008 		_saved_scrollpos_y = WP(w, const vp_d).scrollpos_y;
  1009 		_saved_scrollpos_zoom = w->viewport->zoom;
  1009 		_saved_scrollpos_zoom = w->viewport->zoom;
  1032 }
  1032 }
  1033 
  1033 
  1034 // before savegame version 4, the name of the company determined if it existed
  1034 // before savegame version 4, the name of the company determined if it existed
  1035 static void CheckIsPlayerActive(void)
  1035 static void CheckIsPlayerActive(void)
  1036 {
  1036 {
  1037 	Player* p;
  1037 	Player *p;
  1038 
  1038 
  1039 	FOR_ALL_PLAYERS(p) {
  1039 	FOR_ALL_PLAYERS(p) {
  1040 		if (p->name_1 != 0) p->is_active = true;
  1040 		if (p->name_1 != 0) p->is_active = true;
  1041 	}
  1041 	}
  1042 }
  1042 }
  1043 
  1043 
  1044 // since savegame version 4.1, exclusive transport rights are stored at towns
  1044 // since savegame version 4.1, exclusive transport rights are stored at towns
  1045 static void UpdateExclusiveRights(void)
  1045 static void UpdateExclusiveRights(void)
  1046 {
  1046 {
  1047 	Town* t;
  1047 	Town *t;
  1048 
  1048 
  1049 	FOR_ALL_TOWNS(t) {
  1049 	FOR_ALL_TOWNS(t) {
  1050 		if (t->xy != 0) t->exclusivity = (byte)-1;
  1050 		if (t->xy != 0) t->exclusivity = (byte)-1;
  1051 	}
  1051 	}
  1052 
  1052 
  1262 		}
  1262 		}
  1263 	}
  1263 	}
  1264 
  1264 
  1265 	/* Elrails got added in rev 24 */
  1265 	/* Elrails got added in rev 24 */
  1266 	if (CheckSavegameVersion(24)) {
  1266 	if (CheckSavegameVersion(24)) {
  1267 		Vehicle* v;
  1267 		Vehicle *v;
  1268 		uint i;
  1268 		uint i;
  1269 		TileIndex t;
  1269 		TileIndex t;
  1270 		RailType min_rail = RAILTYPE_ELECTRIC;
  1270 		RailType min_rail = RAILTYPE_ELECTRIC;
  1271 
  1271 
  1272 		for (i = 0; i < lengthof(_engines); i++) {
  1272 		for (i = 0; i < lengthof(_engines); i++) {
  1273 			Engine* e = GetEngine(i);
  1273 			Engine *e = GetEngine(i);
  1274 			if (e->type == VEH_Train &&
  1274 			if (e->type == VEH_Train &&
  1275 					(e->railtype != RAILTYPE_RAIL || RailVehInfo(i)->engclass == 2)) {
  1275 					(e->railtype != RAILTYPE_RAIL || RailVehInfo(i)->engclass == 2)) {
  1276 				e->railtype++;
  1276 				e->railtype++;
  1277 			}
  1277 			}
  1278 		}
  1278 		}