mirror of https://github.com/OpenTTD/OpenTTD
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
- Fix: [ 1153926 ] All my settings in vain... IGNORED! - Change: I hope I got it all right. Pressing 'New Game' (either choosing random or a preset scenario) and 'Create Scenario' will start a new game with the settings and difficulty in the intro menu. Using 'Load Game' and 'Play Scenario' will take the values from the savegame/scenario itself.release/0.4.5
parent
c3f9f5efaf
commit
010d1a9be3
11
intro_gui.c
11
intro_gui.c
|
@ -45,8 +45,8 @@ extern void HandleOnEditTextCancel(void);
|
||||||
static void SelectGameWndProc(Window *w, WindowEvent *e) {
|
static void SelectGameWndProc(Window *w, WindowEvent *e) {
|
||||||
switch(e->event) {
|
switch(e->event) {
|
||||||
case WE_PAINT:
|
case WE_PAINT:
|
||||||
w->click_state = (w->click_state & ~(0xC0) & ~(0xF << 12)) | (1 << (_new_opt.landscape+12)) | (1<<6);
|
w->click_state = (w->click_state & ~(0xC0) & ~(0xF << 12)) | (1 << (_opt_newgame.landscape + 12)) | (1<<6);
|
||||||
SetDParam(0, STR_6801_EASY + _new_opt.diff_level);
|
SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level);
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -74,10 +74,6 @@ static void SelectGameWndProc(Window *w, WindowEvent *e) {
|
||||||
DoCommandP(0, e->click.widget - 12, 0, NULL, CMD_SET_NEW_LANDSCAPE_TYPE);
|
DoCommandP(0, e->click.widget - 12, 0, NULL, CMD_SET_NEW_LANDSCAPE_TYPE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WE_KEYPRESS:
|
|
||||||
switch(e->keypress.keycode) {
|
|
||||||
case WKC_BACKQUOTE: IConsoleSwitch(); break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
|
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break;
|
||||||
|
@ -293,8 +289,7 @@ void AskExitToGameMenu(void)
|
||||||
int32 CmdSetNewLandscapeType(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
int32 CmdSetNewLandscapeType(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
// XXX: some stuff
|
_opt_newgame.landscape = p1;
|
||||||
_new_opt.landscape = p1;
|
|
||||||
InvalidateWindowClasses(WC_SELECT_GAME);
|
InvalidateWindowClasses(WC_SELECT_GAME);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
22
main_gui.c
22
main_gui.c
|
@ -1826,8 +1826,7 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
|
||||||
if (local == 0xff) local = 0; // spectator
|
if (local == 0xff) local = 0; // spectator
|
||||||
|
|
||||||
switch(e->keypress.keycode) {
|
switch(e->keypress.keycode) {
|
||||||
case WKC_F1:
|
case WKC_F1: case WKC_PAUSE:
|
||||||
case WKC_PAUSE:
|
|
||||||
ToolbarPauseClick(w);
|
ToolbarPauseClick(w);
|
||||||
break;
|
break;
|
||||||
case WKC_F2: ShowGameOptions(); break;
|
case WKC_F2: ShowGameOptions(); break;
|
||||||
|
@ -1856,6 +1855,8 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
|
||||||
case WKC_CTRL | 'S': _make_screenshot = 1; break;
|
case WKC_CTRL | 'S': _make_screenshot = 1; break;
|
||||||
case WKC_CTRL | 'G': _make_screenshot = 2; break;
|
case WKC_CTRL | 'G': _make_screenshot = 2; break;
|
||||||
case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break;
|
case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break;
|
||||||
|
default: return;
|
||||||
|
e->keypress.cont = false;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -2260,14 +2261,18 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_KEYPRESS:
|
case WE_KEYPRESS:
|
||||||
|
if (e->keypress.keycode == WKC_BACKQUOTE) {
|
||||||
|
IConsoleSwitch();
|
||||||
|
e->keypress.cont = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (_game_mode == GM_MENU)
|
if (_game_mode == GM_MENU)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (e->keypress.keycode) {
|
switch (e->keypress.keycode) {
|
||||||
case 'C':
|
case 'C': case 'Z': {
|
||||||
case 'Z': {
|
Point pt = GetTileBelowCursor();
|
||||||
Point pt;
|
|
||||||
pt = GetTileBelowCursor();
|
|
||||||
if (pt.x != -1) {
|
if (pt.x != -1) {
|
||||||
ScrollMainWindowTo(pt.x, pt.y);
|
ScrollMainWindowTo(pt.x, pt.y);
|
||||||
if (e->keypress.keycode == 'Z')
|
if (e->keypress.keycode == 'Z')
|
||||||
|
@ -2306,11 +2311,6 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WKC_BACKQUOTE:
|
|
||||||
IConsoleSwitch();
|
|
||||||
e->keypress.cont=false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
case WKC_RETURN:
|
case WKC_RETURN:
|
||||||
case 'T' | WKC_SHIFT:
|
case 'T' | WKC_SHIFT:
|
||||||
|
|
15
misc_cmd.c
15
misc_cmd.c
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "ttd.h"
|
#include "ttd.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
@ -7,6 +6,7 @@
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
#include "gui.h"
|
||||||
#include "saveload.h"
|
#include "saveload.h"
|
||||||
#include "economy.h"
|
#include "economy.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
@ -222,15 +222,14 @@ int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
if (p1 != (uint32)-1L) {
|
if (p1 != (uint32)-1L) {
|
||||||
((int*)&_opt_mod_ptr->diff)[p1] = p2;
|
((int*)&_opt_ptr->diff)[p1] = p2;
|
||||||
_opt_mod_ptr->diff_level = 3;
|
_opt_ptr->diff_level = 3;
|
||||||
} else {
|
} else
|
||||||
_opt_mod_ptr->diff_level = p2;
|
_opt_ptr->diff_level = p2;
|
||||||
}
|
|
||||||
// If we are a network-client, update the difficult setting (if it is open)
|
// If we are a network-client, update the difficult setting (if it is open)
|
||||||
if (_networking && !_network_server && FindWindowById(WC_GAME_OPTIONS, 0) != NULL)
|
if (_networking && !_network_server && FindWindowById(WC_GAME_OPTIONS, 0) != NULL)
|
||||||
memcpy(&_opt_mod_temp, _opt_mod_ptr, sizeof(GameOptions));
|
ShowGameDifficulty();
|
||||||
InvalidateWindow(WC_GAME_OPTIONS, 0);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1267,7 +1267,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
|
||||||
strcpy(_file_to_saveload.name, name);
|
strcpy(_file_to_saveload.name, name);
|
||||||
DeleteWindow(w);
|
DeleteWindow(w);
|
||||||
} else if (_saveload_mode == SLD_LOAD_SCENARIO) {
|
} else if (_saveload_mode == SLD_LOAD_SCENARIO) {
|
||||||
_switch_mode = SM_LOAD_SCENARIO;
|
_switch_mode = (_game_mode == GM_MENU) ? SM_LOAD : SM_LOAD_SCENARIO;
|
||||||
SetFiosType(file->type);
|
SetFiosType(file->type);
|
||||||
strcpy(_file_to_saveload.name, name);
|
strcpy(_file_to_saveload.name, name);
|
||||||
DeleteWindow(w);
|
DeleteWindow(w);
|
||||||
|
|
|
@ -516,7 +516,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
|
||||||
_switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR;
|
_switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR;
|
||||||
return NETWORK_RECV_STATUS_SAVEGAME;
|
return NETWORK_RECV_STATUS_SAVEGAME;
|
||||||
}
|
}
|
||||||
_opt_mod_ptr = &_opt;
|
|
||||||
|
_opt_ptr = &_opt; // during a network game you are always in-game
|
||||||
|
|
||||||
// Say we received the map and loaded it correctly!
|
// Say we received the map and loaded it correctly!
|
||||||
SEND_COMMAND(PACKET_CLIENT_MAP_OK)();
|
SEND_COMMAND(PACKET_CLIENT_MAP_OK)();
|
||||||
|
|
21
settings.c
21
settings.c
|
@ -781,18 +781,17 @@ static const SettingDesc debug_settings[] = {
|
||||||
{NULL, 0, NULL, NULL, NULL}
|
{NULL, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* The settings showed when opened in the intro-menu. These values also are saved to
|
||||||
|
* openttd.cfg, thus _opt_newgame is used here (not _opt which is used ingame with loaded games!) */
|
||||||
static const SettingDesc gameopt_settings[] = {
|
static const SettingDesc gameopt_settings[] = {
|
||||||
{"diff_level", SDT_UINT8, (void*)9, &_new_opt.diff_level, NULL},
|
{"diff_level", SDT_UINT8, (void*)9, &_opt_newgame.diff_level, NULL},
|
||||||
{"diff_custom", SDT_INTLIST | SDT_UINT32 | (sizeof(GameDifficulty)/4) << 16, NULL, &_new_opt.diff, NULL},
|
{"diff_custom", SDT_INTLIST | SDT_UINT32 | (sizeof(GameDifficulty)/4) << 16, NULL, &_opt_newgame.diff, NULL},
|
||||||
{"currency", SDT_UINT8 | SDT_ONEOFMANY, (void*)0, &_new_opt.currency, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SEK|custom" },
|
{"currency", SDT_UINT8 | SDT_ONEOFMANY, (void*)0, &_opt_newgame.currency, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SEK|custom" },
|
||||||
{"distances", SDT_UINT8 | SDT_ONEOFMANY, (void*)1, &_new_opt.kilometers, "imperial|metric" },
|
{"distances", SDT_UINT8 | SDT_ONEOFMANY, (void*)1, &_opt_newgame.kilometers, "imperial|metric" },
|
||||||
// XXX: Slovakish is an awful nonsense. It is either Slovak or
|
{"town_names", SDT_UINT8 | SDT_ONEOFMANY, (void*)0, &_opt_newgame.town_name, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss" },
|
||||||
// Slovakian, I personally prefer the former. --pasky
|
{"landscape", SDT_UINT8 | SDT_ONEOFMANY, (void*)0, &_opt_newgame.landscape, "normal|hilly|desert|candy" },
|
||||||
{"town_names", SDT_UINT8 | SDT_ONEOFMANY, (void*)0, &_new_opt.town_name, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss" },
|
{"autosave", SDT_UINT8 | SDT_ONEOFMANY, (void*)1, &_opt_newgame.autosave, "off|monthly|quarterly|half year|yearly" },
|
||||||
{"landscape", SDT_UINT8 | SDT_ONEOFMANY, (void*)0, &_new_opt.landscape, "normal|hilly|desert|candy" },
|
{"road_side", SDT_UINT8 | SDT_ONEOFMANY, (void*)1, &_opt_newgame.road_side, "left|right" },
|
||||||
{"autosave", SDT_UINT8 | SDT_ONEOFMANY, (void*)1, &_new_opt.autosave, "off|monthly|quarterly|half year|yearly" },
|
|
||||||
{"road_side", SDT_UINT8 | SDT_ONEOFMANY, (void*)1, &_new_opt.road_side, "left|right" },
|
|
||||||
{NULL, 0, NULL, NULL, NULL}
|
{NULL, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
113
settings_gui.c
113
settings_gui.c
|
@ -85,11 +85,11 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
|
||||||
StringID str = STR_02BE_DEFAULT;
|
StringID str = STR_02BE_DEFAULT;
|
||||||
w->disabled_state = (_vehicle_design_names & 1) ? (++str, 0) : (1 << 21);
|
w->disabled_state = (_vehicle_design_names & 1) ? (++str, 0) : (1 << 21);
|
||||||
SetDParam(0, str);
|
SetDParam(0, str);
|
||||||
SetDParam(1, _currency_string_list[_opt_mod_ptr->currency]);
|
SetDParam(1, _currency_string_list[_opt_ptr->currency]);
|
||||||
SetDParam(2, _opt_mod_ptr->kilometers + STR_0139_IMPERIAL_MILES);
|
SetDParam(2, _opt_ptr->kilometers + STR_0139_IMPERIAL_MILES);
|
||||||
SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_mod_ptr->road_side);
|
SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side);
|
||||||
SetDParam(4, STR_TOWNNAME_ORIGINAL_ENGLISH + _opt_mod_ptr->town_name);
|
SetDParam(4, STR_TOWNNAME_ORIGINAL_ENGLISH + _opt_ptr->town_name);
|
||||||
SetDParam(5, _autosave_dropdown[_opt_mod_ptr->autosave]);
|
SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]);
|
||||||
SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
|
SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
|
||||||
i = GetCurRes();
|
i = GetCurRes();
|
||||||
SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
|
SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
|
||||||
|
@ -103,10 +103,10 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
|
||||||
case WE_CLICK:
|
case WE_CLICK:
|
||||||
switch (e->click.widget) {
|
switch (e->click.widget) {
|
||||||
case 5: /* Setup currencies dropdown */
|
case 5: /* Setup currencies dropdown */
|
||||||
ShowDropDownMenu(w, _currency_string_list, _opt_mod_ptr->currency, e->click.widget, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
|
ShowDropDownMenu(w, _currency_string_list, _opt_ptr->currency, e->click.widget, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
|
||||||
return;
|
return;
|
||||||
case 8: /* Setup distance unit dropdown */
|
case 8: /* Setup distance unit dropdown */
|
||||||
ShowDropDownMenu(w, _distances_dropdown, _opt_mod_ptr->kilometers, e->click.widget, 0, 0);
|
ShowDropDownMenu(w, _distances_dropdown, _opt_ptr->kilometers, e->click.widget, 0, 0);
|
||||||
return;
|
return;
|
||||||
case 11: { /* Setup road-side dropdown */
|
case 11: { /* Setup road-side dropdown */
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -114,17 +114,17 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
|
||||||
/* You can only change the drive side if you are in the menu or ingame with
|
/* You can only change the drive side if you are in the menu or ingame with
|
||||||
* no vehicles present. In a networking game only the server can change it */
|
* no vehicles present. In a networking game only the server can change it */
|
||||||
if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server))
|
if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server))
|
||||||
i = (-1) ^ (1 << _opt_mod_ptr->road_side); // disable the other value
|
i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value
|
||||||
|
|
||||||
ShowDropDownMenu(w, _driveside_dropdown, _opt_mod_ptr->road_side, e->click.widget, i, 0);
|
ShowDropDownMenu(w, _driveside_dropdown, _opt_ptr->road_side, e->click.widget, i, 0);
|
||||||
} return;
|
} return;
|
||||||
case 14: { /* Setup townname dropdown */
|
case 14: { /* Setup townname dropdown */
|
||||||
int i = _opt_mod_ptr->town_name;
|
int i = _opt_ptr->town_name;
|
||||||
ShowDropDownMenu(w, BuildDynamicDropdown(STR_TOWNNAME_ORIGINAL_ENGLISH, SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1), i, e->click.widget, (_game_mode == GM_MENU) ? 0 : (-1) ^ (1 << i), 0);
|
ShowDropDownMenu(w, BuildDynamicDropdown(STR_TOWNNAME_ORIGINAL_ENGLISH, SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1), i, e->click.widget, (_game_mode == GM_MENU) ? 0 : (-1) ^ (1 << i), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 17: /* Setup autosave dropdown */
|
case 17: /* Setup autosave dropdown */
|
||||||
ShowDropDownMenu(w, _autosave_dropdown, _opt_mod_ptr->autosave, e->click.widget, 0, 0);
|
ShowDropDownMenu(w, _autosave_dropdown, _opt_ptr->autosave, e->click.widget, 0, 0);
|
||||||
return;
|
return;
|
||||||
case 20: /* Setup customized vehicle-names dropdown */
|
case 20: /* Setup customized vehicle-names dropdown */
|
||||||
ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names&1)?1:0, e->click.widget, (_vehicle_design_names&2)?0:2, 0);
|
ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names&1)?1:0, e->click.widget, (_vehicle_design_names&2)?0:2, 0);
|
||||||
|
@ -162,15 +162,15 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
|
||||||
case 5: /* Currency */
|
case 5: /* Currency */
|
||||||
if (e->dropdown.index == 23)
|
if (e->dropdown.index == 23)
|
||||||
ShowCustCurrency();
|
ShowCustCurrency();
|
||||||
_opt_mod_ptr->currency = _opt.currency = e->dropdown.index;
|
_opt_ptr->currency = e->dropdown.index;
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
break;
|
break;
|
||||||
case 8: /* Distance units */
|
case 8: /* Distance units */
|
||||||
_opt_mod_ptr->kilometers = e->dropdown.index;
|
_opt_ptr->kilometers = e->dropdown.index;
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
break;
|
break;
|
||||||
case 11: /* Road side */
|
case 11: /* Road side */
|
||||||
if (_opt_mod_ptr->road_side != e->dropdown.index) { // only change if setting changed
|
if (_opt_ptr->road_side != e->dropdown.index) { // only change if setting changed
|
||||||
DoCommandP(0, e->dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_EMPTY));
|
DoCommandP(0, e->dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_EMPTY));
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
|
||||||
DoCommandP(0, e->dropdown.index, 0, NULL, CMD_SET_TOWN_NAME_TYPE | CMD_MSG(STR_EMPTY));
|
DoCommandP(0, e->dropdown.index, 0, NULL, CMD_SET_TOWN_NAME_TYPE | CMD_MSG(STR_EMPTY));
|
||||||
break;
|
break;
|
||||||
case 17: /* Autosave options */
|
case 17: /* Autosave options */
|
||||||
_opt_mod_ptr->autosave = e->dropdown.index;
|
_opt_ptr->autosave = e->dropdown.index;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case 24: /* Change interface language */
|
case 24: /* Change interface language */
|
||||||
|
@ -208,7 +208,7 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
|
||||||
int32 CmdSetRoadDriveSide(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
int32 CmdSetRoadDriveSide(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
_opt_mod_ptr->road_side = p1;
|
_opt_ptr->road_side = p1;
|
||||||
InvalidateWindow(WC_GAME_OPTIONS,0);
|
InvalidateWindow(WC_GAME_OPTIONS,0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -217,7 +217,7 @@ int32 CmdSetRoadDriveSide(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
int32 CmdSetTownNameType(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
int32 CmdSetTownNameType(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
_opt_mod_ptr->town_name = p1;
|
_opt_ptr->town_name = p1;
|
||||||
InvalidateWindow(WC_GAME_OPTIONS,0);
|
InvalidateWindow(WC_GAME_OPTIONS,0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -288,12 +288,12 @@ typedef struct {
|
||||||
} GameSettingData;
|
} GameSettingData;
|
||||||
|
|
||||||
static const GameSettingData _game_setting_info[] = {
|
static const GameSettingData _game_setting_info[] = {
|
||||||
{0,7,1,0},
|
{ 0, 7, 1, STR_NULL},
|
||||||
{ 0, 3, 1, STR_6830_IMMEDIATE},
|
{ 0, 3, 1, STR_6830_IMMEDIATE},
|
||||||
{ 0, 2, 1, STR_6816_LOW},
|
{ 0, 2, 1, STR_6816_LOW},
|
||||||
{ 0, 3, 1, STR_26816_NONE},
|
{ 0, 3, 1, STR_26816_NONE},
|
||||||
{100,500,50,0},
|
{100, 500, 50, STR_NULL},
|
||||||
{2,4,1,0},
|
{ 2, 4, 1, STR_NULL},
|
||||||
{ 0, 2, 1, STR_6820_LOW},
|
{ 0, 2, 1, STR_6820_LOW},
|
||||||
{ 0, 4, 1, STR_681B_VERY_SLOW},
|
{ 0, 4, 1, STR_681B_VERY_SLOW},
|
||||||
{ 0, 2, 1, STR_6820_LOW},
|
{ 0, 2, 1, STR_6820_LOW},
|
||||||
|
@ -312,7 +312,7 @@ static inline bool GetBitAndShift(uint32 *b)
|
||||||
{
|
{
|
||||||
uint32 x = *b;
|
uint32 x = *b;
|
||||||
*b >>= 1;
|
*b >>= 1;
|
||||||
return (x&1) != 0;
|
return HASBIT(x, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -361,15 +361,21 @@ enum {
|
||||||
GAMEDIFF_WND_ROWSIZE = 9
|
GAMEDIFF_WND_ROWSIZE = 9
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Temporary holding place of values in the difficulty window until 'Save' is clicked
|
||||||
|
static GameOptions _opt_mod_temp;
|
||||||
|
// 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
|
||||||
|
#define DIFF_INGAME_DISABLED_BUTTONS 0x383E
|
||||||
|
|
||||||
static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
case WE_PAINT: {
|
case WE_PAINT: {
|
||||||
uint32 click_a, click_b, disabled;
|
uint32 click_a, click_b, disabled;
|
||||||
int i;
|
int i;
|
||||||
int x,y,value;
|
int y, value;
|
||||||
|
|
||||||
w->click_state = (1 << 3) << _opt_mod_temp.diff_level;
|
w->click_state = (1 << 3) << _opt_mod_temp.diff_level; // have current difficulty button clicked
|
||||||
|
// disable all other difficulty buttons during gameplay except for 'custom'
|
||||||
w->disabled_state = (_game_mode != GM_NORMAL) ? 0 : (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
|
w->disabled_state = (_game_mode != GM_NORMAL) ? 0 : (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
|
||||||
|
|
||||||
if (_game_mode == GM_EDITOR)
|
if (_game_mode == GM_EDITOR)
|
||||||
|
@ -386,34 +392,28 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||||
click_a = _difficulty_click_a;
|
click_a = _difficulty_click_a;
|
||||||
click_b = _difficulty_click_b;
|
click_b = _difficulty_click_b;
|
||||||
|
|
||||||
/* XXX - This is most likely the worst way I have ever seen
|
/* XXX - Disabled buttons in normal gameplay. Bitshifted for each button to see if
|
||||||
to disable some buttons and to enable others.
|
* that bit is set. If it is set, the button is disabled */
|
||||||
What the value means, is this:
|
disabled = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0;
|
||||||
if bit1 is enabled, setting 1 is disabled
|
|
||||||
then it is shifted to the left, and the story
|
|
||||||
repeats....
|
|
||||||
-- TrueLight */
|
|
||||||
disabled = _game_mode == GM_NORMAL ? 0x383E : 0;
|
|
||||||
|
|
||||||
x = 0;
|
|
||||||
y = GAMEDIFF_WND_TOP_OFFSET;
|
y = GAMEDIFF_WND_TOP_OFFSET;
|
||||||
for (i = 0; i != GAME_DIFFICULTY_NUM; i++) {
|
for (i = 0; i != GAME_DIFFICULTY_NUM; i++) {
|
||||||
DrawFrameRect(x+5, y, x+5+8, y+8, 3, GetBitAndShift(&click_a)?0x20:0);
|
DrawFrameRect( 5, y, 5 + 8, y + 8, 3, GetBitAndShift(&click_a) ? (1 << 5) : 0);
|
||||||
DrawFrameRect(x+15, y, x+15+8, y+8, 3, GetBitAndShift(&click_b)?0x20:0);
|
DrawFrameRect(15, y, 15 + 8, y + 8, 3, GetBitAndShift(&click_b) ? (1 << 5) : 0);
|
||||||
if (GetBitAndShift(&disabled) || (_networking && !_network_server)) {
|
if (GetBitAndShift(&disabled) || (_networking && !_network_server)) {
|
||||||
int color = 0x8000 | _color_list[3].unk2;
|
int color = PALETTE_MODIFIER_COLOR | _color_list[3].unk2;
|
||||||
GfxFillRect(x+6, y+1, x+6+8, y+8, color);
|
GfxFillRect( 6, y + 1, 6 + 8, y + 8, color);
|
||||||
GfxFillRect(x+16, y+1, x+16+8, y+8, color);
|
GfxFillRect(16, y + 1, 16 + 8, y + 8, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawStringCentered(x+10, y, STR_6819, 0);
|
DrawStringCentered(10, y, STR_6819, 0);
|
||||||
DrawStringCentered(x+20, y, STR_681A, 0);
|
DrawStringCentered(20, y, STR_681A, 0);
|
||||||
|
|
||||||
|
|
||||||
value = _game_setting_info[i].str + ((int*)&_opt_mod_temp.diff)[i];
|
value = _game_setting_info[i].str + ((int*)&_opt_mod_temp.diff)[i];
|
||||||
if (i == 4) value *= 1000; // handle currency option
|
if (i == 4) value *= 1000; // XXX - handle currency option
|
||||||
SetDParam(0, value);
|
SetDParam(0, value);
|
||||||
DrawString(x+30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, 0);
|
DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, 0);
|
||||||
|
|
||||||
y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit
|
y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit
|
||||||
}
|
}
|
||||||
|
@ -421,18 +421,18 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case WE_CLICK:
|
case WE_CLICK:
|
||||||
switch (e->click.widget) {
|
switch (e->click.widget) {
|
||||||
case 8: {
|
case 8: { /* Difficulty settings widget, decode click */
|
||||||
|
const GameSettingData *info;
|
||||||
int x, y;
|
int x, y;
|
||||||
uint btn, dis;
|
uint btn, dis;
|
||||||
int val;
|
int val;
|
||||||
const GameSettingData *info;
|
|
||||||
|
|
||||||
// Don't allow clients to make any changes
|
// Don't allow clients to make any changes
|
||||||
if (_networking && !_network_server)
|
if (_networking && !_network_server)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x = e->click.pt.x - 5;
|
x = e->click.pt.x - 5;
|
||||||
if (!IS_INT_INSIDE(x, 0, 21))
|
if (!IS_INT_INSIDE(x, 0, 21)) // Button area
|
||||||
return;
|
return;
|
||||||
|
|
||||||
y = e->click.pt.y - GAMEDIFF_WND_TOP_OFFSET;
|
y = e->click.pt.y - GAMEDIFF_WND_TOP_OFFSET;
|
||||||
|
@ -445,7 +445,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Clicked disabled button?
|
// Clicked disabled button?
|
||||||
dis = (_game_mode == GM_NORMAL) ? 0x383E : 0;
|
dis = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0;
|
||||||
|
|
||||||
if (HASBIT(dis, btn))
|
if (HASBIT(dis, btn))
|
||||||
return;
|
return;
|
||||||
|
@ -454,7 +454,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
val = ((int*)&_opt_mod_temp.diff)[btn];
|
val = ((int*)&_opt_mod_temp.diff)[btn];
|
||||||
|
|
||||||
info = &_game_setting_info[btn];
|
info = &_game_setting_info[btn]; // get information about the difficulty setting
|
||||||
if (x >= 10) {
|
if (x >= 10) {
|
||||||
// Increase button clicked
|
// Increase button clicked
|
||||||
val = min(val + info->step, info->max);
|
val = min(val + info->step, info->max);
|
||||||
|
@ -469,8 +469,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||||
((int*)&_opt_mod_temp.diff)[btn] = val;
|
((int*)&_opt_mod_temp.diff)[btn] = val;
|
||||||
SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom
|
SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
case 3: case 4: case 5: case 6: /* Easy / Medium / Hard / Custom */
|
case 3: case 4: case 5: case 6: /* Easy / Medium / Hard / Custom */
|
||||||
// temporarily change difficulty level
|
// temporarily change difficulty level
|
||||||
SetDifficultyLevel(e->click.widget - 3, &_opt_mod_temp);
|
SetDifficultyLevel(e->click.widget - 3, &_opt_mod_temp);
|
||||||
|
@ -484,7 +483,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||||
for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
|
for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
|
||||||
val = ((int*)&_opt_mod_temp.diff)[btn];
|
val = ((int*)&_opt_mod_temp.diff)[btn];
|
||||||
// if setting has changed, change it
|
// if setting has changed, change it
|
||||||
if (val != ((int*)&_opt_mod_ptr->diff)[btn])
|
if (val != ((int*)&_opt_mod_temp.diff)[btn])
|
||||||
DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
|
DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
|
||||||
}
|
}
|
||||||
DoCommandP(0, -1, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
|
DoCommandP(0, -1, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
|
||||||
|
@ -496,13 +495,12 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||||
StartupEconomy();
|
StartupEconomy();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 11: // Cancel button - close window
|
case 11: /* Cancel button - close window, abandon changes */
|
||||||
DeleteWindow(w);
|
DeleteWindow(w);
|
||||||
break;
|
break;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
|
|
||||||
case WE_MOUSELOOP:
|
case WE_MOUSELOOP: /* Handle the visual 'clicking' of the buttons */
|
||||||
if (_difficulty_timeout != 0 && !--_difficulty_timeout) {
|
if (_difficulty_timeout != 0 && !--_difficulty_timeout) {
|
||||||
_difficulty_click_a = 0;
|
_difficulty_click_a = 0;
|
||||||
_difficulty_click_b = 0;
|
_difficulty_click_b = 0;
|
||||||
|
@ -512,6 +510,8 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef DIFF_INGAME_DISABLED_BUTTONS
|
||||||
|
|
||||||
static const Widget _game_difficulty_widgets[] = {
|
static const Widget _game_difficulty_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
{ WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||||
{ WWT_CAPTION, RESIZE_NONE, 10, 11, 369, 0, 13, STR_6800_DIFFICULTY_LEVEL, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
{ WWT_CAPTION, RESIZE_NONE, 10, 11, 369, 0, 13, STR_6800_DIFFICULTY_LEVEL, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||||
|
@ -539,10 +539,9 @@ static const WindowDesc _game_difficulty_desc = {
|
||||||
void ShowGameDifficulty(void)
|
void ShowGameDifficulty(void)
|
||||||
{
|
{
|
||||||
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
||||||
/* copy current settings to temporary holding place
|
/* Copy current settings (ingame or in intro) to temporary holding place
|
||||||
* change that when setting stuff, copy back on clicking 'OK'
|
* change that when setting stuff, copy back on clicking 'OK' */
|
||||||
*/
|
memcpy(&_opt_mod_temp, _opt_ptr, sizeof(GameOptions));
|
||||||
memcpy(&_opt_mod_temp, _opt_mod_ptr, sizeof(GameOptions));
|
|
||||||
AllocateWindowDesc(&_game_difficulty_desc);
|
AllocateWindowDesc(&_game_difficulty_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1872,7 +1872,7 @@ bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type)
|
||||||
* owned by a town no removal if rating is lower than ... depends now on
|
* owned by a town no removal if rating is lower than ... depends now on
|
||||||
* difficulty setting. Minimum town rating selected by difficulty level
|
* difficulty setting. Minimum town rating selected by difficulty level
|
||||||
*/
|
*/
|
||||||
modemod = _default_rating_settings[_opt_mod_ptr->diff.town_council_tolerance][type];
|
modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type];
|
||||||
|
|
||||||
if (t->ratings[_current_player] < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
|
if (t->ratings[_current_player] < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
|
||||||
SetDParam(0, t->index);
|
SetDParam(0, t->index);
|
||||||
|
|
79
ttd.c
79
ttd.c
|
@ -460,10 +460,11 @@ static void UnInitializeGame(void)
|
||||||
static void LoadIntroGame(void)
|
static void LoadIntroGame(void)
|
||||||
{
|
{
|
||||||
char filename[256];
|
char filename[256];
|
||||||
_game_mode = GM_MENU;
|
|
||||||
_display_opt &= ~DO_TRANS_BUILDINGS; // don't make buildings transparent in intro
|
|
||||||
|
|
||||||
_opt_mod_ptr = &_new_opt;
|
_game_mode = GM_MENU;
|
||||||
|
CLRBITS(_display_opt, DO_TRANS_BUILDINGS); // don't make buildings transparent in intro
|
||||||
|
_opt_ptr = &_opt_newgame;
|
||||||
|
|
||||||
GfxLoadSprites();
|
GfxLoadSprites();
|
||||||
LoadStringWidthTable();
|
LoadStringWidthTable();
|
||||||
|
|
||||||
|
@ -480,7 +481,6 @@ static void LoadIntroGame(void)
|
||||||
#endif
|
#endif
|
||||||
GenerateWorld(1, 6, 6); // if failed loading, make empty world.
|
GenerateWorld(1, 6, 6); // if failed loading, make empty world.
|
||||||
}
|
}
|
||||||
_opt.currency = _new_opt.currency;
|
|
||||||
|
|
||||||
_pause = 0;
|
_pause = 0;
|
||||||
_local_player = 0;
|
_local_player = 0;
|
||||||
|
@ -648,12 +648,11 @@ int ttd_main(int argc, char* argv[])
|
||||||
NetworkStartUp();
|
NetworkStartUp();
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
||||||
// Default difficulty level
|
_opt_ptr = &_opt_newgame;
|
||||||
_opt_mod_ptr = &_new_opt;
|
|
||||||
|
|
||||||
// ugly hack, if diff_level is 9, it means we got no setting from the config file, so we load the default settings.
|
/* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */
|
||||||
if (_opt_mod_ptr->diff_level == 9)
|
if (_opt_newgame.diff_level == 9)
|
||||||
SetDifficultyLevel(0, _opt_mod_ptr);
|
SetDifficultyLevel(0, &_opt_newgame);
|
||||||
|
|
||||||
// initialize the ingame console
|
// initialize the ingame console
|
||||||
IConsoleInit();
|
IConsoleInit();
|
||||||
|
@ -734,8 +733,8 @@ static void MakeNewGame(void)
|
||||||
_game_mode = GM_NORMAL;
|
_game_mode = GM_NORMAL;
|
||||||
|
|
||||||
// Copy in game options
|
// Copy in game options
|
||||||
_opt_mod_ptr = &_opt;
|
_opt_ptr = &_opt;
|
||||||
memcpy(&_opt, &_new_opt, sizeof(_opt));
|
memcpy(_opt_ptr, &_opt_newgame, sizeof(GameOptions));
|
||||||
|
|
||||||
GfxLoadSprites();
|
GfxLoadSprites();
|
||||||
|
|
||||||
|
@ -766,8 +765,8 @@ static void MakeNewEditorWorld(void)
|
||||||
_game_mode = GM_EDITOR;
|
_game_mode = GM_EDITOR;
|
||||||
|
|
||||||
// Copy in game options
|
// Copy in game options
|
||||||
_opt_mod_ptr = &_opt;
|
_opt_ptr = &_opt;
|
||||||
memcpy(&_opt, &_new_opt, sizeof(_opt));
|
memcpy(_opt_ptr, &_opt_newgame, sizeof(GameOptions));
|
||||||
|
|
||||||
GfxLoadSprites();
|
GfxLoadSprites();
|
||||||
|
|
||||||
|
@ -787,6 +786,12 @@ static void MakeNewEditorWorld(void)
|
||||||
void StartupPlayers(void);
|
void StartupPlayers(void);
|
||||||
void StartupDisasters(void);
|
void StartupDisasters(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start Scenario starts a new game based on a scenario.
|
||||||
|
* Eg 'New Game' --> select a preset scenario
|
||||||
|
* This starts a scenario based on your current difficulty settings just
|
||||||
|
* fix the landscape as that can be different from what is selected in the intro
|
||||||
|
*/
|
||||||
static void StartScenario(void)
|
static void StartScenario(void)
|
||||||
{
|
{
|
||||||
_game_mode = GM_NORMAL;
|
_game_mode = GM_NORMAL;
|
||||||
|
@ -799,11 +804,6 @@ static void StartScenario(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy in game options
|
|
||||||
// Removed copying of game options when using "new game". --dominik
|
|
||||||
// _opt_mod_ptr = &_opt;
|
|
||||||
// memcpy(&_opt, &_new_opt, sizeof(_opt));
|
|
||||||
|
|
||||||
GfxLoadSprites();
|
GfxLoadSprites();
|
||||||
|
|
||||||
// Reinitialize windows
|
// Reinitialize windows
|
||||||
|
@ -818,16 +818,18 @@ static void StartScenario(void)
|
||||||
ShowErrorMessage(_error_message, STR_4009_GAME_LOAD_FAILED, 0, 0);
|
ShowErrorMessage(_error_message, STR_4009_GAME_LOAD_FAILED, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
byte landscape = _opt.landscape; // backup loaded landscape;
|
||||||
|
_opt_ptr = &_opt;
|
||||||
|
memcpy(_opt_ptr, &_opt_newgame, sizeof(GameOptions));
|
||||||
|
_opt_ptr->landscape = landscape;
|
||||||
|
}
|
||||||
|
|
||||||
// Inititalize data
|
// Inititalize data
|
||||||
StartupPlayers();
|
StartupPlayers();
|
||||||
StartupEngines();
|
StartupEngines();
|
||||||
StartupDisasters();
|
StartupDisasters();
|
||||||
|
|
||||||
// When starting a scenario, is it really a load..
|
|
||||||
// and in AfterLoad a player is started when it is
|
|
||||||
// a scenario.. so we do not need it here.
|
|
||||||
// DoStartupNewPlayer(false);
|
|
||||||
|
|
||||||
_local_player = 0;
|
_local_player = 0;
|
||||||
|
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
@ -887,11 +889,11 @@ void SwitchMode(int new_mode)
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
||||||
switch (new_mode) {
|
switch (new_mode) {
|
||||||
case SM_EDITOR: // Switch to scenario editor
|
case SM_EDITOR: /* Switch to scenario editor */
|
||||||
MakeNewEditorWorld();
|
MakeNewEditorWorld();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SM_NEWGAME:
|
case SM_NEWGAME: /* New Game --> 'Random game' */
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
if (_network_server)
|
if (_network_server)
|
||||||
snprintf(_network_game_info.map_name, 40, "Random");
|
snprintf(_network_game_info.map_name, 40, "Random");
|
||||||
|
@ -899,12 +901,12 @@ void SwitchMode(int new_mode)
|
||||||
MakeNewGame();
|
MakeNewGame();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SM_START_SCENARIO:
|
case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */
|
||||||
StartScenario();
|
StartScenario();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
normal_load:
|
case SM_LOAD: { /* Load game, Play Scenario */
|
||||||
case SM_LOAD: { // Load game
|
_opt_ptr = &_opt;
|
||||||
|
|
||||||
_error_message = INVALID_STRING_ID;
|
_error_message = INVALID_STRING_ID;
|
||||||
if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL)) {
|
if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL)) {
|
||||||
|
@ -921,14 +923,11 @@ normal_load:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SM_LOAD_SCENARIO: {
|
case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (_game_mode == GM_MENU) goto normal_load;
|
|
||||||
|
|
||||||
if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR)) {
|
if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR)) {
|
||||||
_opt_mod_ptr = &_opt;
|
_opt_ptr = &_opt;
|
||||||
_opt_mod_temp = _opt;
|
|
||||||
|
|
||||||
_local_player = OWNER_NONE;
|
_local_player = OWNER_NONE;
|
||||||
_generating_world = true;
|
_generating_world = true;
|
||||||
|
@ -952,18 +951,18 @@ normal_load:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case SM_MENU: // Switch to game menu
|
case SM_MENU: /* Switch to game intro menu */
|
||||||
LoadIntroGame();
|
LoadIntroGame();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SM_SAVE: // Save game
|
case SM_SAVE: /* Save game */
|
||||||
if (SaveOrLoad(_file_to_saveload.name, SL_SAVE) != SL_OK)
|
if (SaveOrLoad(_file_to_saveload.name, SL_SAVE) != SL_OK)
|
||||||
ShowErrorMessage(INVALID_STRING_ID, STR_4007_GAME_SAVE_FAILED, 0, 0);
|
ShowErrorMessage(INVALID_STRING_ID, STR_4007_GAME_SAVE_FAILED, 0, 0);
|
||||||
else
|
else
|
||||||
DeleteWindowById(WC_SAVELOAD, 0);
|
DeleteWindowById(WC_SAVELOAD, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SM_GENRANDLAND:
|
case SM_GENRANDLAND: /* Generate random land within scenario editor */
|
||||||
GenerateWorld(2, _patches.map_x, _patches.map_y);
|
GenerateWorld(2, _patches.map_x, _patches.map_y);
|
||||||
// XXX: set date
|
// XXX: set date
|
||||||
_local_player = OWNER_NONE;
|
_local_player = OWNER_NONE;
|
||||||
|
@ -1037,16 +1036,16 @@ static void DoAutosave(void)
|
||||||
char buf[200];
|
char buf[200];
|
||||||
|
|
||||||
if (_patches.keep_all_autosave && _local_player != OWNER_SPECTATOR) {
|
if (_patches.keep_all_autosave && _local_player != OWNER_SPECTATOR) {
|
||||||
Player *p;
|
const Player *p = DEREF_PLAYER(_local_player);
|
||||||
char *s;
|
char *s;
|
||||||
sprintf(buf, "%s%s", _path.autosave_dir, PATHSEP);
|
sprintf(buf, "%s%s", _path.autosave_dir, PATHSEP);
|
||||||
p = DEREF_PLAYER(_local_player);
|
|
||||||
SetDParam(0, p->name_1);
|
SetDParam(0, p->name_1);
|
||||||
SetDParam(1, p->name_2);
|
SetDParam(1, p->name_2);
|
||||||
SetDParam(2, _date);
|
SetDParam(2, _date);
|
||||||
s = (char*)GetString(buf + strlen(_path.autosave_dir) + strlen(PATHSEP), STR_4004);
|
s = (char*)GetString(buf + strlen(_path.autosave_dir) + strlen(PATHSEP), STR_4004);
|
||||||
strcpy(s, ".sav");
|
strcpy(s, ".sav");
|
||||||
} else {
|
} else { /* Save a maximum of 15 autosaves */
|
||||||
int n = _autosave_ctr;
|
int n = _autosave_ctr;
|
||||||
_autosave_ctr = (_autosave_ctr + 1) & 15;
|
_autosave_ctr = (_autosave_ctr + 1) & 15;
|
||||||
sprintf(buf, "%s%sautosave%d.sav", _path.autosave_dir, PATHSEP, n);
|
sprintf(buf, "%s%sautosave%d.sav", _path.autosave_dir, PATHSEP, n);
|
||||||
|
@ -1231,7 +1230,7 @@ static void UpdateExclusiveRights(void)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
byte convert_currency[] = {
|
const byte convert_currency[] = {
|
||||||
0, 1, 12, 8, 3,
|
0, 1, 12, 8, 3,
|
||||||
10, 14, 19, 4, 5,
|
10, 14, 19, 4, 5,
|
||||||
9, 11, 13, 6, 17,
|
9, 11, 13, 6, 17,
|
||||||
|
|
28
variables.h
28
variables.h
|
@ -2,11 +2,8 @@
|
||||||
#define VARIABLES_H
|
#define VARIABLES_H
|
||||||
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
//enum { DPARAM_SIZE = 32 };
|
|
||||||
|
|
||||||
|
|
||||||
// ********* START OF SAVE REGION
|
// ********* START OF SAVE REGION
|
||||||
|
|
||||||
#if !defined(MAX_PATH)
|
#if !defined(MAX_PATH)
|
||||||
# define MAX_PATH 260
|
# define MAX_PATH 260
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,11 +29,15 @@ typedef struct {
|
||||||
byte road_side;
|
byte road_side;
|
||||||
} GameOptions;
|
} GameOptions;
|
||||||
|
|
||||||
// These are the options for the current game
|
/* These are the options for the current game
|
||||||
|
* either ingame, or loaded. Also used for networking games */
|
||||||
VARDEF GameOptions _opt;
|
VARDEF GameOptions _opt;
|
||||||
|
|
||||||
// These are the options for the new game
|
/* These are the default options for a new game */
|
||||||
VARDEF GameOptions _new_opt;
|
VARDEF GameOptions _opt_newgame;
|
||||||
|
|
||||||
|
// Pointer to one of the two _opt OR _opt_newgame structs
|
||||||
|
VARDEF GameOptions *_opt_ptr;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CF_NOEURO = 0,
|
CF_NOEURO = 0,
|
||||||
|
@ -242,10 +243,6 @@ typedef struct Paths {
|
||||||
|
|
||||||
VARDEF Paths _path;
|
VARDEF Paths _path;
|
||||||
|
|
||||||
// Which options struct does options modify?
|
|
||||||
VARDEF GameOptions *_opt_mod_ptr;
|
|
||||||
VARDEF GameOptions _opt_mod_temp;
|
|
||||||
|
|
||||||
// NOSAVE: Used in palette animations only, not really important.
|
// NOSAVE: Used in palette animations only, not really important.
|
||||||
VARDEF int _timer_counter;
|
VARDEF int _timer_counter;
|
||||||
|
|
||||||
|
@ -331,19 +328,16 @@ VARDEF char _savedump_path[64];
|
||||||
VARDEF uint _savedump_first, _savedump_freq, _savedump_last;
|
VARDEF uint _savedump_first, _savedump_freq, _savedump_last;
|
||||||
// end of debug features
|
// end of debug features
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char *name;
|
|
||||||
char *file;
|
|
||||||
} DynLangEnt;
|
|
||||||
|
|
||||||
// Used for dynamic language support
|
// Used for dynamic language support
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int num; // number of languages
|
int num; // number of languages
|
||||||
int curr; // currently selected language index
|
int curr; // currently selected language index
|
||||||
char curr_file[32]; // currently selected language file
|
char curr_file[32]; // currently selected language file
|
||||||
StringID dropdown[32 + 1]; // used in settings dialog
|
StringID dropdown[32 + 1]; // used in settings dialog
|
||||||
DynLangEnt ent[32];
|
struct {
|
||||||
|
char *name;
|
||||||
|
char *file;
|
||||||
|
} ent[32];
|
||||||
} DynamicLanguages;
|
} DynamicLanguages;
|
||||||
|
|
||||||
VARDEF DynamicLanguages _dynlang;
|
VARDEF DynamicLanguages _dynlang;
|
||||||
|
|
Loading…
Reference in New Issue