mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
- CodeChange: renamed CmdTrainGotoDepot() to CmdSendTrainToDepot() to be consistent with other depot commands. - CodeChange: 'newgame' console command now calls the unabused GenRandomNewGame(). For the server it still creates a new game, a client quits the game and continues in SP. - CodeChange: in the game-difficulty window, setup the disabled buttons on window creation, not every redraw.
This commit is contained in:
parent
921cc4e94a
commit
c626555f68
64
command.c
64
command.c
@ -63,7 +63,7 @@ DEF_COMMAND(CmdStartStopTrain);
|
||||
|
||||
DEF_COMMAND(CmdSellRailWagon);
|
||||
|
||||
DEF_COMMAND(CmdTrainGotoDepot);
|
||||
DEF_COMMAND(CmdSendTrainToDepot);
|
||||
DEF_COMMAND(CmdForceTrainProceed);
|
||||
DEF_COMMAND(CmdReverseTrainDirection);
|
||||
|
||||
@ -123,7 +123,6 @@ DEF_COMMAND(CmdRenameTown);
|
||||
DEF_COMMAND(CmdDoTownAction);
|
||||
|
||||
DEF_COMMAND(CmdSetRoadDriveSide);
|
||||
DEF_COMMAND(CmdSetTownNameType);
|
||||
|
||||
DEF_COMMAND(CmdChangeDifficultyLevel);
|
||||
DEF_COMMAND(CmdChangePatchSetting);
|
||||
@ -135,13 +134,6 @@ DEF_COMMAND(CmdSendShipToDepot);
|
||||
DEF_COMMAND(CmdChangeShipServiceInt);
|
||||
DEF_COMMAND(CmdRefitShip);
|
||||
|
||||
|
||||
DEF_COMMAND(CmdStartNewGame);
|
||||
DEF_COMMAND(CmdCreateScenario);
|
||||
|
||||
DEF_COMMAND(CmdSetNewLandscapeType);
|
||||
|
||||
DEF_COMMAND(CmdGenRandomNewGame);
|
||||
DEF_COMMAND(CmdCloneOrder);
|
||||
|
||||
DEF_COMMAND(CmdClearArea);
|
||||
@ -205,7 +197,7 @@ static CommandProc * const _command_proc_table[] = {
|
||||
CmdStartStopTrain, /* 36 */
|
||||
NULL, /* 37 */
|
||||
CmdSellRailWagon, /* 38 */
|
||||
CmdTrainGotoDepot, /* 39 */
|
||||
CmdSendTrainToDepot, /* 39 */
|
||||
CmdForceTrainProceed, /* 40 */
|
||||
CmdReverseTrainDirection, /* 41 */
|
||||
|
||||
@ -236,11 +228,11 @@ static CommandProc * const _command_proc_table[] = {
|
||||
|
||||
CmdSellAircraft, /* 59 */
|
||||
CmdStartStopAircraft, /* 60 */
|
||||
/***************************************************/
|
||||
|
||||
CmdBuildAircraft, /* 61 */
|
||||
CmdSendAircraftToHangar, /* 62 */
|
||||
CmdChangeAircraftServiceInt, /* 63 */
|
||||
CmdRefitAircraft, /* 64 */
|
||||
CmdRefitAircraft, /* 64 <-- Hackykid */
|
||||
|
||||
CmdPlaceSign, /* 65 */
|
||||
CmdRenameSign, /* 66 */
|
||||
@ -252,60 +244,60 @@ static CommandProc * const _command_proc_table[] = {
|
||||
CmdTurnRoadVeh, /* 71 */
|
||||
CmdChangeRoadVehServiceInt, /* 72 */
|
||||
|
||||
CmdPause, /* 73 */
|
||||
CmdPause, /* 73 <-- TODO: check/enforce by server */
|
||||
|
||||
CmdBuyShareInCompany, /* 74 */
|
||||
CmdSellShareInCompany, /* 75 */
|
||||
CmdBuyCompany, /* 76 */
|
||||
|
||||
CmdBuildTown, /* 77 */
|
||||
CmdBuildTown, /* 77 <-- offline / scenario only */
|
||||
NULL, /* 78 */
|
||||
NULL, /* 79 */
|
||||
CmdRenameTown, /* 80 */
|
||||
CmdRenameTown, /* 80 <-- TODO: check/enforce by server */
|
||||
CmdDoTownAction, /* 81 */
|
||||
|
||||
CmdSetRoadDriveSide, /* 82 */
|
||||
CmdSetTownNameType, /* 83 */
|
||||
CmdSetRoadDriveSide, /* 82 <-- TODO: check/enforce by server */
|
||||
NULL, /* 83 */
|
||||
NULL, /* 84 */
|
||||
CmdChangeDifficultyLevel, /* 85 */
|
||||
CmdChangeDifficultyLevel, /* 85 <-- TODO: check/enforce by server */
|
||||
|
||||
CmdStartStopShip, /* 86 */
|
||||
CmdSellShip, /* 87 */
|
||||
CmdBuildShip, /* 88 */
|
||||
CmdSendShipToDepot, /* 89 */
|
||||
CmdChangeShipServiceInt, /* 90 */
|
||||
CmdRefitShip, /* 91 */
|
||||
CmdRefitShip, /* 91 <-- Hackykid */
|
||||
|
||||
CmdStartNewGame, /* 92 */
|
||||
NULL, /* 92 */
|
||||
NULL, /* 93 */
|
||||
CmdCreateScenario, /* 94 */
|
||||
NULL, /* 94 */
|
||||
NULL, /* 95 */
|
||||
NULL, /* 96 */
|
||||
CmdSetNewLandscapeType, /* 97 */
|
||||
NULL, /* 97 */
|
||||
|
||||
CmdGenRandomNewGame, /* 98 */
|
||||
NULL, /* 98 */
|
||||
|
||||
CmdCloneOrder, /* 99 */
|
||||
|
||||
CmdClearArea, /* 100 */
|
||||
NULL, /* 101 */
|
||||
|
||||
CmdMoneyCheat, /* 102 */
|
||||
/***************************************************/
|
||||
CmdMoneyCheat, /* 102 <-- offline only */
|
||||
CmdBuildCanal, /* 103 */
|
||||
CmdPlayerCtrl, /* 104 */
|
||||
CmdPlayerCtrl, /* 104 <-- TODO: check/enforce by server */
|
||||
|
||||
CmdLevelLand, /* 105 */
|
||||
CmdLevelLand, /* 105 <-- Hackykid */
|
||||
|
||||
CmdRefitRailVehicle, /* 106 */
|
||||
CmdRefitRailVehicle, /* 106 <-- Hackykid */
|
||||
CmdRestoreOrderIndex, /* 107 */
|
||||
CmdBuildLock, /* 108 */
|
||||
CmdStartScenario, /* 109 */
|
||||
CmdBuildSignalTrack, /* 110 */
|
||||
CmdRemoveSignalTrack, /* 111 */
|
||||
CmdDestroyCompanyHQ, /* 112 <-- done */
|
||||
CmdBuildLock, /* 108 <-- Hackykid */
|
||||
CmdStartScenario, /* 109 <-- UNNEEDED */
|
||||
CmdBuildSignalTrack, /* 110 <-- Hackykid */
|
||||
CmdRemoveSignalTrack, /* 111 <-- Hackykid */
|
||||
CmdDestroyCompanyHQ, /* 112 */
|
||||
CmdGiveMoney, /* 113 */
|
||||
CmdChangePatchSetting, /* 114 */
|
||||
CmdReplaceVehicle, /* 115 */
|
||||
CmdChangePatchSetting, /* 114 <-- TODO: check/enforce by server */
|
||||
CmdReplaceVehicle, /* 115 <-- Hackykid */
|
||||
};
|
||||
|
||||
/* This function range-checks a cmd, and checks if the cmd is not NULL */
|
||||
@ -386,7 +378,7 @@ error:
|
||||
|
||||
int32 GetAvailableMoneyForCommand(void)
|
||||
{
|
||||
uint pid = _current_player;
|
||||
PlayerID pid = _current_player;
|
||||
if (pid >= MAX_PLAYERS) return 0x7FFFFFFF; // max int
|
||||
return DEREF_PLAYER(pid)->player_money;
|
||||
}
|
||||
|
@ -712,15 +712,11 @@ DEF_CONSOLE_CMD(ConNewGame)
|
||||
{
|
||||
if (argc == 0) {
|
||||
IConsoleHelp("Start a new game. Usage: 'newgame'");
|
||||
IConsoleHelp("The server can force a new game using 'newgame', any client using it will part and start a single-player game");
|
||||
return true;
|
||||
}
|
||||
|
||||
_docommand_recursive = 0;
|
||||
|
||||
_random_seeds[0][0] = Random();
|
||||
_random_seeds[0][1] = InteractiveRandom();
|
||||
|
||||
SwitchMode(SM_NEWGAME);
|
||||
GenRandomNewGame(Random(), InteractiveRandom());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ static int DedicatedVideoMainLoop(void)
|
||||
/* If SwitchMode is SM_LOAD, it means that the user used the '-g' options */
|
||||
if (_switch_mode != SM_LOAD) {
|
||||
_switch_mode = SM_NONE;
|
||||
DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_GEN_RANDOM_NEW_GAME);
|
||||
GenRandomNewGame(Random(), InteractiveRandom());
|
||||
} else {
|
||||
_switch_mode = SM_NONE;
|
||||
/* First we need to test if the savegame can be loaded, else we will end up playing the
|
||||
|
@ -228,6 +228,7 @@ enum SaveOrLoadMode {
|
||||
int SaveOrLoad(const char *filename, int mode);
|
||||
|
||||
void AfterLoadTown(void);
|
||||
void GenRandomNewGame(uint32 rnd1, uint32 rnd2);
|
||||
void AskExitGame(void);
|
||||
void AskExitToGameMenu(void);
|
||||
|
||||
|
68
intro_gui.c
68
intro_gui.c
@ -45,6 +45,14 @@ static const Widget _select_game_widgets[] = {
|
||||
extern void HandleOnEditText(WindowEvent *e);
|
||||
extern void HandleOnEditTextCancel(void);
|
||||
|
||||
static inline void CreateScenario(void) {_switch_mode = SM_EDITOR;}
|
||||
|
||||
static inline void SetNewLandscapeType(byte landscape)
|
||||
{
|
||||
_opt_newgame.landscape = landscape;
|
||||
InvalidateWindowClasses(WC_SELECT_GAME);
|
||||
}
|
||||
|
||||
static void SelectGameWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
/* We do +/- 6 for the map_xy because 64 is 2^6, but it is the lowest available element */
|
||||
@ -64,13 +72,12 @@ static void SelectGameWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
case WE_CLICK:
|
||||
switch (e->click.widget) {
|
||||
case 2: DoCommandP(0, 0, 0, NULL, CMD_START_NEW_GAME); break;
|
||||
case 2: AskForNewGameToStart(); break;
|
||||
case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
|
||||
case 4: DoCommandP(0, InteractiveRandom(), 0, NULL, CMD_CREATE_SCENARIO); break;
|
||||
case 4: CreateScenario(); break;
|
||||
case 5: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
|
||||
case 6: case 7: case 8: case 9:
|
||||
// XXX: Useless usage of the CMD infrastructure?
|
||||
DoCommandP(0, e->click.widget - 6, 0, NULL, CMD_SET_NEW_LANDSCAPE_TYPE);
|
||||
SetNewLandscapeType(e->click.widget - 6);
|
||||
break;
|
||||
case 10: case 11: /* Mapsize X */
|
||||
ShowDropDownMenu(w, mapsizes, _patches.map_x - 6, 11, 0, 0);
|
||||
@ -122,50 +129,12 @@ void ShowSelectGameWindow(void)
|
||||
AllocateWindowDesc(&_select_game_desc);
|
||||
}
|
||||
|
||||
|
||||
// p1 = mode
|
||||
// 0 - start new game
|
||||
// 1 - close new game dialog
|
||||
|
||||
int32 CmdStartNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
void GenRandomNewGame(uint32 rnd1, uint32 rnd2)
|
||||
{
|
||||
if (!(flags & DC_EXEC))
|
||||
return 0;
|
||||
|
||||
switch(p1) {
|
||||
case 0: // show select game window
|
||||
AskForNewGameToStart();
|
||||
break;
|
||||
case 1: // close select game window
|
||||
DeleteWindowById(WC_SAVELOAD, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 CmdGenRandomNewGame(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (!(flags & DC_EXEC))
|
||||
return 0;
|
||||
|
||||
// this forces stuff into test mode.
|
||||
_docommand_recursive = 0;
|
||||
|
||||
_random_seeds[0][0] = p1;
|
||||
_random_seeds[0][1] = p2;
|
||||
_random_seeds[0][0] = rnd1;
|
||||
_random_seeds[0][1] = rnd2;
|
||||
|
||||
SwitchMode(SM_NEWGAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 CmdCreateScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (!(flags & DC_EXEC))
|
||||
return 0;
|
||||
|
||||
_switch_mode = SM_EDITOR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 CmdStartScenario(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
@ -297,12 +266,3 @@ void AskExitToGameMenu(void)
|
||||
{
|
||||
AllocateWindowDescFront(&_ask_quit_game_desc, 0);
|
||||
}
|
||||
|
||||
int32 CmdSetNewLandscapeType(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
_opt_newgame.landscape = p1;
|
||||
InvalidateWindowClasses(WC_SELECT_GAME);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1480,8 +1480,8 @@ static void SelectScenarioWndProc(Window *w, WindowEvent *e) {
|
||||
break;
|
||||
|
||||
case 6: /* Click the listbox */
|
||||
if(e->click.pt.y < list_start)
|
||||
DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_GEN_RANDOM_NEW_GAME);
|
||||
if (e->click.pt.y < list_start)
|
||||
GenRandomNewGame(Random(), InteractiveRandom());
|
||||
else {
|
||||
char *name;
|
||||
int y = (e->click.pt.y - list_start) / 10;
|
||||
|
@ -563,8 +563,8 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
|
||||
_is_network_server = true;
|
||||
ttd_strlcpy(_network_server_name, WP(w, querystr_d).text.buf, sizeof(_network_server_name));
|
||||
UpdateTextBufferSize(&WP(w, querystr_d).text);
|
||||
if(selected_map==NULL) { // start random new game
|
||||
DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_GEN_RANDOM_NEW_GAME);
|
||||
if (selected_map == NULL) { // start random new game
|
||||
GenRandomNewGame(Random(), InteractiveRandom());
|
||||
} else { // load a scenario
|
||||
char *name;
|
||||
if ((name = FiosBrowseTo(selected_map)) != NULL) {
|
||||
|
@ -176,8 +176,10 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
break;
|
||||
case 14: /* Town names */
|
||||
if (_game_mode == GM_MENU)
|
||||
DoCommandP(0, e->dropdown.index, 0, NULL, CMD_SET_TOWN_NAME_TYPE | CMD_MSG(STR_EMPTY));
|
||||
if (_game_mode == GM_MENU) {
|
||||
_opt_ptr->town_name = e->dropdown.index;
|
||||
InvalidateWindow(WC_GAME_OPTIONS, 0);
|
||||
}
|
||||
break;
|
||||
case 17: /* Autosave options */
|
||||
_opt_ptr->autosave = e->dropdown.index;
|
||||
@ -205,8 +207,16 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
}
|
||||
|
||||
/** Change the side of the road vehicles drive on (server only).
|
||||
* @param x,y unused
|
||||
* @param p1 the side of the road; 0 = left side and 1 = right side
|
||||
* @param p2 unused
|
||||
*/
|
||||
int32 CmdSetRoadDriveSide(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
/* Check boundaries and you can only change this if NO vehicles have been built yet */
|
||||
if (p1 > 1 || RoadVehiclesAreBuilt()) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
_opt_ptr->road_side = p1;
|
||||
InvalidateWindow(WC_GAME_OPTIONS,0);
|
||||
@ -214,16 +224,6 @@ int32 CmdSetRoadDriveSide(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 CmdSetTownNameType(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
_opt_ptr->town_name = p1;
|
||||
InvalidateWindow(WC_GAME_OPTIONS,0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const Widget _game_options_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 369, 0, 13, STR_00B1_GAME_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
@ -369,24 +369,24 @@ static GameOptions _opt_mod_temp;
|
||||
static void GameDifficultyWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
uint32 click_a, click_b, disabled;
|
||||
int i;
|
||||
int y, value;
|
||||
|
||||
w->click_state = (1 << 3) << _opt_mod_temp.diff_level; // have current difficulty button clicked
|
||||
case WE_CREATE: /* Setup disabled buttons when creating window */
|
||||
// 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);
|
||||
|
||||
if (_game_mode == GM_EDITOR)
|
||||
SETBIT(w->disabled_state, 7);
|
||||
if (_game_mode == GM_EDITOR) SETBIT(w->disabled_state, 7);
|
||||
|
||||
if (_networking) {
|
||||
SETBIT(w->disabled_state, 7); // disable highscore chart in multiplayer
|
||||
if (!_network_server)
|
||||
SETBIT(w->disabled_state, 10); // Disable save-button in multiplayer (and if client)
|
||||
}
|
||||
break;
|
||||
case WE_PAINT: {
|
||||
uint32 click_a, click_b, disabled;
|
||||
int i;
|
||||
int y, value;
|
||||
|
||||
w->click_state = (1 << 3) << _opt_mod_temp.diff_level; // have current difficulty button clicked
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
click_a = _difficulty_click_a;
|
||||
|
@ -1433,7 +1433,7 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v)
|
||||
* @param p1 train to send to the depot
|
||||
* @param p2 unused
|
||||
*/
|
||||
int32 CmdTrainGotoDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
int32 CmdSendTrainToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
Vehicle *v;
|
||||
TrainFindDepotData tfdd;
|
||||
|
Loading…
Reference in New Issue
Block a user