summaryrefslogtreecommitdiff
path: root/misc_cmd.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-05-12 00:11:37 +0000
committerDarkvater <darkvater@openttd.org>2005-05-12 00:11:37 +0000
commit921cc4e94a7703816ff63e4f673eaa9d8a7da4ca (patch)
tree2a2c6834d0b034f560428a4c3abe47e5e2df1f44 /misc_cmd.c
parentf3b217db9dd377d2e8e5d28434cc01ffe5c23b3b (diff)
downloadopenttd-921cc4e94a7703816ff63e4f673eaa9d8a7da4ca.tar.xz
(svn r2297) - CodeChange: server-check the next batch of commands.
- CodeChange: since only the server will be able to modify difficulty settings, leave the checking of correct values besides, and trust users will join legit servers. - CodeChange: for renaming signs, only check if GetDParam(); eg _decode_parameters is empty ('\0') or not, instead of the extra check of players, etc. That basically does the same thing. Also dirty sign two times when renaming, once before, once after the action. Because if the name becomes shorter and you update only after, garbage remains on the screen. - CodeChange: made GetMaskOfTownActions() available to the town-cmd to double-check if the action was available to the player. For this purpose the hardcoded _local_player has been removed from the function and is now passed as a parameter.
Diffstat (limited to 'misc_cmd.c')
-rw-r--r--misc_cmd.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/misc_cmd.c b/misc_cmd.c
index 52f237ba2..ea7a6ecb6 100644
--- a/misc_cmd.c
+++ b/misc_cmd.c
@@ -172,8 +172,14 @@ int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return 0;
}
-// p1 = 0 decrease pause counter
-// p1 = 1 increase pause counter
+/** Pause/Unpause the game (server-only).
+ * Increase or decrease the pause counter. If the counter is zero,
+ * the game is unpaused. A counter is used instead of a boolean value
+ * to have more control over the game when saving/loading, etc.
+ * @param x,y unused
+ * @param p1 0 = decrease pause counter; 1 = increase pause counter
+ * @param p2 unused
+ */
int32 CmdPause(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) {
@@ -213,16 +219,29 @@ int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return (int32)p1;
}
+/** Change difficulty level/settings (server-only).
+ * We cannot really check for valid values of p2 (too much work mostly); stored
+ * in file 'settings_gui.c' _game_setting_info[]; we'll just trust the server it knows
+ * what to do and does this correctly
+ * @param x,y unused
+ * @param p1 the difficulty setting being changed. If it is -1, the difficulty level
+ * itself is changed. The new value is inside p2
+ * @param p2 new value for a difficulty setting or difficulty level
+ */
int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
+ if (p1 >= GAME_DIFFICULTY_NUM) return CMD_ERROR;
+
if (flags & DC_EXEC) {
if (p1 != (uint32)-1L) {
((int*)&_opt_ptr->diff)[p1] = p2;
- _opt_ptr->diff_level = 3;
+ _opt_ptr->diff_level = 3; // custom difficulty level
} else
_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).
+ * Use this instead of just dirtying the window because we need to load in
+ * the new difficulty settings */
if (_networking && !_network_server && FindWindowById(WC_GAME_OPTIONS, 0) != NULL)
ShowGameDifficulty();
}