1 /* ---------------------------------------------------------------------- *
2 * loadsave.cpp
3 * This file is part of lincity-NG
4 * See COPYING for license, and CREDITS for authors
5 * ---------------------------------------------------------------------- */
6
7 /* this is for saving */
8
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <zlib.h>
12 #include <iostream>
13 #include "tinygettext/gettext.hpp"
14 #include "gui_interface/screen_interface.h"
15 #include "gui_interface/shared_globals.h"
16 #include "stats.h"
17 #include "init_game.h"
18 #include "transport.h"
19
20 #include <fcntl.h>
21 #include <sys/types.h>
22
23 #if defined (TIME_WITH_SYS_TIME)
24 #include <time.h>
25 #include <sys/time.h>
26 #else
27 #if defined (HAVE_SYS_TIME_H)
28 #include <sys/time.h>
29 #else
30 #include <time.h>
31 #endif
32 #endif
33
34 #include <cstdlib>
35 #include <string.h>
36 #include <math.h>
37 /*
38 #if defined (WIN32)
39 #include <winsock.h>
40 #include <io.h>
41 #include <direct.h>
42 #include <process.h>
43 #endif
44 */
45 #ifdef __EMX__
46 #define chown(x,y,z)
47 #endif
48
49 #if defined (HAVE_DIRENT_H)
50 #include <dirent.h>
51 #define NAMLEN(dirent) strlen((dirent)->d_name)
52 #else
53 #define dirent direct
54 #define NAMLEN(dirent) (dirent)->d_namlen
55 #if defined (HAVE_SYS_NDIR_H)
56 #include <sys/ndir.h>
57 #endif
58 #if defined (HAVE_SYS_DIR_H)
59 #include <sys/dir.h>
60 #endif
61 #if defined (HAVE_NDIR_H)
62 #include <ndir.h>
63 #endif
64 #endif
65
66 #include <ctype.h>
67 //#include "common.h"
68 /*
69 #ifdef LC_X11
70 #include <X11/cursorfont.h>
71 #endif
72 */
73 #include "lctypes.h"
74 #include "lin-city.h"
75 #include "engglobs.h"
76 #include "fileutil.h"
77 #include "power.h"
78 #include "gui_interface/pbar_interface.h"
79 #include "lincity-ng/ErrorInterface.hpp"
80 #include "stats.h"
81 #include "loadsave.h"
82
83 #if defined (WIN32) && !defined (NDEBUG)
84 #define START_FAST_SPEED 1
85 #define SKIP_OPENING_SCENE 1
86 #endif
87
88 #define SI_BLACK 252
89 #define SI_RED 253
90 #define SI_GREEN 254
91 #define SI_YELLOW 255
92
93 #define MP_SANITY_CHECK 1
94
95 /* Extern resources */
96 extern int yn_dial_box(const char *, const char *, const char *, const char *);
97 extern void ok_dial_box(const char *, int, const char *);
98 extern void prog_box(const char *, int);
99
100 extern void print_total_money(void);
101 extern int count_groups(int);
102 extern void desert_frontier(int originx, int originy, int w, int h);
103
104 /* ---------------------------------------------------------------------- *
105 * Public functions
106 * ---------------------------------------------------------------------- */
107
save_city(char * cname)108 void save_city(char *cname)
109 {
110 char *s;
111 int l;
112
113 if ((l = strlen(cname)) < 2)
114 return;
115 if ((s = (char *)malloc(lc_save_dir_len + l + 16)) == 0)
116 malloc_failure();
117
118 sprintf(s, "%s%c%s", lc_save_dir, PATH_SLASH, cname);
119
120 save_city_2(s);
121 free(s);
122 }
123
save_city_2(char * cname)124 void save_city_2(char *cname)
125 {
126 int x, y, p;
127 int dumbint = 0;
128 gzFile ofile = gzopen(cname, "wb");
129 if (ofile == NULL) {
130 printf(_("Save file <%s> - "), cname);
131 do_error(_("Can't open save file!"));
132 }
133 /* Now we have upgraded game */
134 ldsv_version = WATERWELL_V2;
135 gzprintf(ofile, "%d\n", ldsv_version);
136
137 for (x = 0; x < WORLD_SIDE_LEN; x++)
138 for (y = 0; y < WORLD_SIDE_LEN; y++) {
139 /* TY po fl cr or i1 i2 i3 i4 i5 i6 i7 PL al ec ws gp wa wp ww wn g1 g2 g3 g4 DA TK AN d4 d5 d6 d7 d8 d9 */
140 gzprintf(ofile, "%u %d %d %u %u %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n"
141 , MP_TYPE(x, y)
142 , MP_INFO(x, y).population
143 , MP_INFO(x, y).flags
144 , MP_INFO(x, y).coal_reserve
145 , MP_INFO(x, y).ore_reserve
146 , MP_INFO(x, y).int_1
147 , MP_INFO(x, y).int_2
148 , MP_INFO(x, y).int_3
149 , MP_INFO(x, y).int_4
150 , MP_INFO(x, y).int_5
151 , MP_INFO(x, y).int_6
152 , MP_INFO(x, y).int_7
153 , MP_POL(x, y)
154 , ground[x][y].altitude
155 , ground[x][y].ecotable
156 , ground[x][y].wastes
157 , ground[x][y].pollution
158 , ground[x][y].water_alt
159 , ground[x][y].water_pol
160 , ground[x][y].water_wast
161 , ground[x][y].water_next
162 , ground[x][y].int1
163 , ground[x][y].int2
164 , ground[x][y].int3
165 , ground[x][y].int4
166 , MP_DATE(x,y) // d1 = date of built
167 , MP_TECH(x,y) // d2 = tech at build time
168 , MP_ANIM(x,y) // d3 = animation_time (see reset_animation_time mess :)
169 , dumbint // d4 could be image index for smooth animation, cf windmill anim_tile
170 , dumbint // d5 percentage of activity to choose family of pic
171 , dumbint // d6
172 , dumbint // d7
173 , dumbint // d8
174 , dumbint // d9
175 );
176 }
177
178 gzprintf(ofile, "%d\n", main_screen_originx);
179 gzprintf(ofile, "%d\n", main_screen_originy);
180
181 gzprintf(ofile, "%d\n", total_time);
182 for (x = 0; x < MAX_NUMOF_SUBSTATIONS; x++) {
183 gzprintf(ofile, "%d\n", substationx[x]);
184 gzprintf(ofile, "%d\n", substationy[x]);
185 }
186 gzprintf(ofile, "%d\n", numof_substations);
187 for (x = 0; x < MAX_NUMOF_MARKETS; x++) {
188 gzprintf(ofile, "%d\n", marketx[x]);
189 gzprintf(ofile, "%d\n", markety[x]);
190 }
191 gzprintf(ofile, "%d\n", numof_markets);
192 gzprintf(ofile, "%d\n", people_pool);
193 gzprintf(ofile, "%o\n", total_money);
194 gzprintf(ofile, "%d\n", income_tax_rate);
195 gzprintf(ofile, "%d\n", coal_tax_rate);
196 gzprintf(ofile, "%d\n", dole_rate);
197 gzprintf(ofile, "%d\n", transport_cost_rate);
198 gzprintf(ofile, "%d\n", goods_tax_rate);
199 gzprintf(ofile, "%d\n", export_tax);
200 gzprintf(ofile, "%d\n", export_tax_rate);
201 gzprintf(ofile, "%d\n", import_cost);
202 gzprintf(ofile, "%d\n", import_cost_rate);
203 gzprintf(ofile, "%d\n", tech_level);
204 gzprintf(ofile, "%d\n", tpopulation);
205 gzprintf(ofile, "%d\n", tstarving_population);
206 gzprintf(ofile, "%d\n", tunemployed_population);
207 gzprintf(ofile, "%d\n", 0); /* waste_goods is obsolete */
208 gzprintf(ofile, "%d\n", power_made);
209 gzprintf(ofile, "%d\n", power_used);
210 gzprintf(ofile, "%d\n", coal_made);
211 gzprintf(ofile, "%d\n", coal_used);
212 gzprintf(ofile, "%d\n", goods_made);
213 gzprintf(ofile, "%d\n", goods_used);
214 gzprintf(ofile, "%d\n", ore_made);
215 gzprintf(ofile, "%d\n", ore_used);
216 gzprintf(ofile, "%d\n", 0); /* Removed diff_old_population, version 1.12 */
217
218 /* Changed, version 1.12 */
219 gzprintf(ofile, "%d\n", monthgraph_size);
220 for (x = 0; x < monthgraph_size; x++) {
221 gzprintf(ofile, "%d\n", monthgraph_pop[x]);
222 gzprintf(ofile, "%d\n", monthgraph_starve[x]);
223 gzprintf(ofile, "%d\n", monthgraph_nojobs[x]);
224 gzprintf(ofile, "%d\n", monthgraph_ppool[x]);
225 }
226 gzprintf(ofile, "%d\n", rockets_launched);
227 gzprintf(ofile, "%d\n", rockets_launched_success);
228 gzprintf(ofile, "%d\n", coal_survey_done);
229
230 for (x = 0; x < PBAR_DATA_SIZE; x++)
231 for (p = 0; p < NUM_PBARS; p++)
232 gzprintf(ofile, "%d\n", pbars[p].data[x]);
233
234 for (p = 0; p < NUM_PBARS; p++) {
235 gzprintf(ofile, "%d\n", pbars[p].oldtot);
236 gzprintf(ofile, "%d\n", pbars[p].diff);
237 }
238
239 gzprintf(ofile, "%d\n", cheat_flag);
240 gzprintf(ofile, "%d\n", total_pollution_deaths);
241 gzprintf(ofile, "%f\n", pollution_deaths_history);
242 gzprintf(ofile, "%d\n", total_starve_deaths);
243 gzprintf(ofile, "%f\n", starve_deaths_history);
244 gzprintf(ofile, "%d\n", total_unemployed_years);
245 gzprintf(ofile, "%f\n", unemployed_history);
246 gzprintf(ofile, "%d\n", max_pop_ever);
247 gzprintf(ofile, "%d\n", total_evacuated);
248 gzprintf(ofile, "%d\n", total_births);
249
250 for (x = 0; x < NUMOF_MODULES; x++)
251 gzprintf(ofile, "%d\n", module_help_flag[x]);
252
253 if (strlen(given_scene) > 1)
254 gzprintf(ofile, "%s\n", given_scene);
255 else
256 gzprintf(ofile, "dummy\n"); /* 1 */
257
258 gzprintf(ofile, "%d\n", highest_tech_level); /* 2 */
259
260 gzprintf(ofile, "sust %d %d %d %d %d %d %d %d %d %d\n", sust_dig_ore_coal_count, sust_port_count, sust_old_money_count, sust_old_population_count, sust_old_tech_count, sust_fire_count, sust_old_money, sust_old_population, sust_old_tech, sustain_flag); /* 3 */
261
262 gzprintf(ofile, "arid %d %d\n", global_aridity, global_mountainity); /* 4 */
263
264 gzprintf(ofile, "dummy\n"); /* 5 */
265
266 gzprintf(ofile, "dummy\n"); /* 6 */
267
268 gzprintf(ofile, "dummy\n"); /* 7 */
269
270 gzprintf(ofile, "dummy\n"); /* 8 */
271
272 gzprintf(ofile, "dummy\n"); /* 9 */
273
274 gzprintf(ofile, "dummy\n"); /* 10 */
275
276 gzclose(ofile);
277 }
278
load_city_2(char * cname)279 void load_city_2(char *cname)
280 {
281 int i, x, y, p;
282 int dumbint = 0;
283 int num_pbars, pbar_data_size;
284 int pbar_tmp;
285 int dummy;
286 gzFile gzfile;
287 char s[512];
288
289 clear_game();
290
291 gzfile = gzopen(cname, "rb");
292 if (gzfile == NULL) {
293 printf(_("Can't open <%s> (gzipped)"), cname);
294 do_error("Can't open it!");
295 }
296
297 sscanf(gzgets(gzfile, s, 256), "%d", &ldsv_version);
298 if (ldsv_version < WATERWELL_V2) {
299 gzclose(gzfile);
300 load_city_old( cname );
301 /* Fix desert frontier for old saved games and scenarios */
302 desert_frontier(0, 0, WORLD_SIDE_LEN, WORLD_SIDE_LEN);
303 return;
304 }
305
306 fprintf(stderr, " ldsv_version = %i \n", ldsv_version);
307 use_waterwell = true;
308
309 init_pbars();
310 num_pbars = NUM_PBARS;
311 pbar_data_size = PBAR_DATA_SIZE;
312
313 init_inventory();
314 print_time_for_year();
315
316 // Easier debugging from saved game: #Line = 100 x + y + 1 (first line = ldsv_version)
317 for (x = 0; x < WORLD_SIDE_LEN; x++) {
318 for (y = 0; y < WORLD_SIDE_LEN; y++) {
319 gzgets(gzfile, s, 512);
320 // TY po fl cr or i1 i2 i3 i4 i5 i6 i7 PL al ec ws gp wa wp ww wn g1 g2 g3 g4 DA TK AN d4 d5 d6 d7 d8 d9
321 sscanf(s, "%hi %d %i %hu %hu %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"
322 , &MP_TYPE(x, y)
323 , &MP_INFO(x, y).population
324 , &MP_INFO(x, y).flags
325 , &MP_INFO(x, y).coal_reserve
326 , &MP_INFO(x, y).ore_reserve
327 , &MP_INFO(x, y).int_1
328 , &MP_INFO(x, y).int_2
329 , &MP_INFO(x, y).int_3
330 , &MP_INFO(x, y).int_4
331 , &MP_INFO(x, y).int_5
332 , &MP_INFO(x, y).int_6
333 , &MP_INFO(x, y).int_7
334 , &MP_POL(x, y)
335 , &ground[x][y].altitude
336 , &ground[x][y].ecotable
337 , &ground[x][y].wastes
338 , &ground[x][y].pollution
339 , &ground[x][y].water_alt
340 , &ground[x][y].water_pol
341 , &ground[x][y].water_wast
342 , &ground[x][y].water_next
343 , &ground[x][y].int1
344 , &ground[x][y].int2
345 , &ground[x][y].int3
346 , &ground[x][y].int4
347 , &MP_DATE(x,y) // d1 = date of built
348 , &MP_TECH(x,y) // d2 = tech at build time
349 , &MP_ANIM(x,y) // d3 = animation_time (see reset_animation_time mess :)
350 , &dumbint // d4 could be image index for smooth animation, cf windmill anim_tile
351 , &dumbint // d5 percentage of activity to choose family of pic
352 , &dumbint // d6
353 , &dumbint // d7
354 , &dumbint // d8
355 , &dumbint // d9
356 );
357 if (get_group_of_type(MP_TYPE(x, y)) == GROUP_MARKET)
358 inventory(x, y);
359 }
360 }
361 set_map_groups();
362
363 sscanf(gzgets(gzfile, s, 256), "%d", &main_screen_originx);
364 sscanf(gzgets(gzfile, s, 256), "%d", &main_screen_originy);
365
366 sscanf(gzgets(gzfile, s, 256), "%d", &total_time);
367
368 for (x = 0; x < MAX_NUMOF_SUBSTATIONS; x++) {
369 sscanf(gzgets(gzfile, s, 256), "%d", &substationx[x]);
370 sscanf(gzgets(gzfile, s, 256), "%d", &substationy[x]);
371 }
372 sscanf(gzgets(gzfile, s, 256), "%d", &numof_substations);
373
374 for (x = 0; x < MAX_NUMOF_MARKETS; x++) {
375 sscanf(gzgets(gzfile, s, 256), "%d", &marketx[x]);
376 sscanf(gzgets(gzfile, s, 256), "%d", &markety[x]);
377 }
378 sscanf(gzgets(gzfile, s, 256), "%d", &numof_markets);
379 sscanf(gzgets(gzfile, s, 256), "%d", &people_pool);
380 sscanf(gzgets(gzfile, s, 256), "%o", &total_money);
381 sscanf(gzgets(gzfile, s, 256), "%d", &income_tax_rate);
382 sscanf(gzgets(gzfile, s, 256), "%d", &coal_tax_rate);
383 sscanf(gzgets(gzfile, s, 256), "%d", &dole_rate);
384 sscanf(gzgets(gzfile, s, 256), "%d", &transport_cost_rate);
385 sscanf(gzgets(gzfile, s, 256), "%d", &goods_tax_rate);
386 sscanf(gzgets(gzfile, s, 256), "%d", &export_tax);
387 sscanf(gzgets(gzfile, s, 256), "%d", &export_tax_rate);
388 sscanf(gzgets(gzfile, s, 256), "%d", &import_cost);
389 sscanf(gzgets(gzfile, s, 256), "%d", &import_cost_rate);
390 sscanf(gzgets(gzfile, s, 256), "%d", &tech_level);
391 sscanf(gzgets(gzfile, s, 256), "%d", &tpopulation);
392 sscanf(gzgets(gzfile, s, 256), "%d", &tstarving_population);
393 sscanf(gzgets(gzfile, s, 256), "%d", &tunemployed_population);
394 sscanf(gzgets(gzfile, s, 256), "%d", &x); /* waste_goods obsolete */
395 sscanf(gzgets(gzfile, s, 256), "%d", &power_made);
396 sscanf(gzgets(gzfile, s, 256), "%d", &power_used);
397 sscanf(gzgets(gzfile, s, 256), "%d", &coal_made);
398 sscanf(gzgets(gzfile, s, 256), "%d", &coal_used);
399 sscanf(gzgets(gzfile, s, 256), "%d", &goods_made);
400 sscanf(gzgets(gzfile, s, 256), "%d", &goods_used);
401 sscanf(gzgets(gzfile, s, 256), "%d", &ore_made);
402 sscanf(gzgets(gzfile, s, 256), "%d", &ore_used);
403 sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &diff_old_population */
404
405 /* Update variables calculated from those above */
406 housed_population = tpopulation / ((total_time % NUMOF_DAYS_IN_MONTH) + 1);
407
408 /* Get size of monthgraph array */
409 sscanf(gzgets(gzfile, s, 256), "%d", &i);
410 for (x = 0; x < i; x++) {
411 /* If more entries in file than will fit on screen,
412 then we need to skip past them. */
413 if (x >= monthgraph_size) {
414 sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &monthgraph_pop[x] */
415 sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &monthgraph_starve[x] */
416 sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &monthgraph_nojobs[x] */
417 sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &monthgraph_ppool[x] */
418 } else {
419 sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_pop[x]);
420 sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_starve[x]);
421 sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_nojobs[x]);
422 sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_ppool[x]);
423 }
424 }
425 /* If screen bigger than number of entries in file, pad with zeroes */
426 while (x < monthgraph_size) {
427 monthgraph_pop[x] = 0;
428 monthgraph_starve[x] = 0;
429 monthgraph_nojobs[x] = 0;
430 monthgraph_ppool[x] = 0;
431 x++;
432 }
433 sscanf(gzgets(gzfile, s, 256), "%d", &rockets_launched);
434 sscanf(gzgets(gzfile, s, 256), "%d", &rockets_launched_success);
435 sscanf(gzgets(gzfile, s, 256), "%d", &coal_survey_done);
436
437 for (x = 0; x < pbar_data_size; x++) {
438 for (p = 0; p < num_pbars; p++) {
439 sscanf(gzgets(gzfile, s, 256), "%d", &(pbar_tmp));
440 update_pbar(p, pbar_tmp, 1);
441 }
442 }
443
444 for (p = 0; p < num_pbars; p++)
445 pbars[p].data_size = pbar_data_size;
446
447 for (p = 0; p < num_pbars; p++) {
448 sscanf(gzgets(gzfile, s, 256), "%d", &(pbars[p].oldtot));
449 sscanf(gzgets(gzfile, s, 256), "%d", &(pbars[p].diff));
450 }
451
452 sscanf(gzgets(gzfile, s, 256), "%d", &cheat_flag);
453 sscanf(gzgets(gzfile, s, 256), "%d", &total_pollution_deaths);
454 sscanf(gzgets(gzfile, s, 256), "%f", &pollution_deaths_history);
455 sscanf(gzgets(gzfile, s, 256), "%d", &total_starve_deaths);
456 sscanf(gzgets(gzfile, s, 256), "%f", &starve_deaths_history);
457 sscanf(gzgets(gzfile, s, 256), "%d", &total_unemployed_years);
458 sscanf(gzgets(gzfile, s, 256), "%f", &unemployed_history);
459 sscanf(gzgets(gzfile, s, 256), "%d", &max_pop_ever);
460 sscanf(gzgets(gzfile, s, 256), "%d", &total_evacuated);
461 sscanf(gzgets(gzfile, s, 256), "%d", &total_births);
462
463 for (x = 0; x < NUMOF_MODULES; x++)
464 sscanf(gzgets(gzfile, s, 256), "%d", &(module_help_flag[x]));
465
466 sscanf(gzgets(gzfile, s, 256), "%128s", given_scene);
467 if (strncmp(given_scene, "dummy", 5) == 0 || strlen(given_scene) < 3)
468 given_scene[0] = 0;
469 sscanf(gzgets(gzfile, s, 256), "%128s", s);
470 if (strncmp(given_scene, "dummy", 5) != 0)
471 sscanf(s, "%d", &highest_tech_level);
472 else
473 highest_tech_level = 0;
474
475 gzgets(gzfile, s, 200);
476 if (sscanf
477 (s, "sust %d %d %d %d %d %d %d %d %d %d", &sust_dig_ore_coal_count, &sust_port_count, &sust_old_money_count,
478 &sust_old_population_count, &sust_old_tech_count, &sust_fire_count, &sust_old_money, &sust_old_population,
479 &sust_old_tech, &sustain_flag) == 10) {
480 sust_dig_ore_coal_tip_flag = sust_port_flag = 1;
481 } else
482 sustain_flag = sust_dig_ore_coal_count = sust_port_count
483 = sust_old_money_count = sust_old_population_count
484 = sust_old_tech_count = sust_fire_count = sust_old_money = sust_old_population = sust_old_tech = 0;
485
486 gzgets(gzfile, s, 80);
487 sscanf(s, "arid %d %d", &global_aridity, &global_mountainity);
488
489 gzclose(gzfile);
490
491 /* FIXME: AL1 this is initialisation stuff, should go elsewhere */
492
493 // Engine stuff
494 if (tech_level > MODERN_WINDMILL_TECH)
495 modern_windmill_flag = 1;
496
497 numof_shanties = count_groups(GROUP_SHANTY);
498 numof_communes = count_groups(GROUP_COMMUNE);
499
500 /* set up the university intake. */
501 x = count_groups(GROUP_UNIVERSITY);
502 if (x > 0) {
503 university_intake_rate = (count_groups(GROUP_SCHOOL) * 20) / x;
504 if (university_intake_rate > 100)
505 university_intake_rate = 100;
506 } else
507 university_intake_rate = 50;
508
509 print_total_money();
510
511 //reset_animation_times
512 //get alt_min, alt_max
513 alt_min = 2000000000;
514 alt_max = -alt_min;
515 for ( y = 0; y < WORLD_SIDE_LEN; y++){
516 for ( x = 0; x < WORLD_SIDE_LEN; x++) {
517 MP_ANIM(x,y) = 0;
518 if (MP_GROUP(x, y) == GROUP_FIRE){
519 MP_INFO(x, y).int_3 = 0;
520 }
521 if (alt_min > ALT(x,y)){
522 alt_min = ALT(x,y);
523 }
524 if (alt_max < ALT(x,y)){
525 alt_max = ALT(x,y);
526 }
527 }
528 }
529 alt_step = (alt_max - alt_min) /10;
530
531 map_power_grid(true); /* WCK: Is this safe to do here?
532 * AL1: No, in NG_1.1
533 * In case of error message with ok_dial_box
534 * the dialog cannot appear because the screen
535 * is not set up => crash.
536 * FIXME: move all initialisation elsewhere, in
537 * engine.cpp or simulate.cpp.
538 */
539 // UI stuff
540 if (main_screen_originx > WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1)
541 main_screen_originx = WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1;
542
543 if (main_screen_originy > WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1)
544 main_screen_originy = WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1;
545
546 unhighlight_module_button(selected_module);
547 selected_module = sbut[7]; /* 7 is track. Watch out though! */
548 highlight_module_button(selected_module);
549 set_selected_module(CST_TRACK_LR);
550 connect_transport(1, 1, WORLD_SIDE_LEN - 2, WORLD_SIDE_LEN - 2);
551 /* Fix desert frontier for old saved games and scenarios */
552 desert_frontier(0, 0, WORLD_SIDE_LEN, WORLD_SIDE_LEN);
553
554 }
555
556