author | Darkvater |
Thu, 12 May 2005 00:18:30 +0000 | |
changeset 1794 | 44f9deff97ed |
parent 1793 | 8ac8a8c9ec0f |
child 1796 | cae31916ae54 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
1317
f382f1b439c7
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
1147
diff
changeset
|
3 |
#include "string.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
193
diff
changeset
|
4 |
#include "table/strings.h" |
0 | 5 |
#include "command.h" |
6 |
#include "player.h" |
|
7 |
#include "gfx.h" |
|
8 |
#include "window.h" |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1328
diff
changeset
|
9 |
#include "gui.h" |
0 | 10 |
#include "saveload.h" |
11 |
#include "economy.h" |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
12 |
#include "network.h" |
0 | 13 |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
14 |
/** Change the player's face. |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
15 |
* @param x,y unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
16 |
* @param p1 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
17 |
* @param p2 face bitmasked |
0 | 18 |
*/ |
19 |
int32 CmdSetPlayerFace(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
20 |
{ |
|
21 |
if (flags & DC_EXEC) { |
|
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1728
diff
changeset
|
22 |
GetPlayer(_current_player)->face = p2; |
0 | 23 |
MarkWholeScreenDirty(); |
24 |
} |
|
25 |
return 0; |
|
26 |
} |
|
27 |
||
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
28 |
/** Change the player's company-colour |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
29 |
* @param x,y unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
30 |
* @param p1 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
31 |
* @param p2 new colour for vehicles, property, etc. |
0 | 32 |
*/ |
33 |
int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
34 |
{ |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
35 |
Player *p, *pp; |
0 | 36 |
|
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1728
diff
changeset
|
37 |
p = GetPlayer(_current_player); |
0 | 38 |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
39 |
/* Ensure no two companies have the same colour */ |
0 | 40 |
FOR_ALL_PLAYERS(pp) { |
41 |
if (pp->is_active && pp != p && pp->player_color == (byte)p2) |
|
42 |
return CMD_ERROR; |
|
43 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
84
diff
changeset
|
44 |
|
0 | 45 |
if (flags & DC_EXEC) { |
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1728
diff
changeset
|
46 |
_player_colors[_current_player] = (byte)p2; |
0 | 47 |
p->player_color = (byte)p2; |
48 |
MarkWholeScreenDirty(); |
|
49 |
} |
|
50 |
return 0; |
|
51 |
} |
|
52 |
||
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
53 |
/** Increase the loan of your company. |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
54 |
* @param x,y unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
55 |
* @param p1 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
56 |
* @param p2 when set, loans the maximum amount in one go (press CTRL) |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
57 |
*/ |
0 | 58 |
int32 CmdIncreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
59 |
{ |
|
60 |
Player *p; |
|
61 |
||
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1728
diff
changeset
|
62 |
p = GetPlayer(_current_player); |
0 | 63 |
|
64 |
if (p->current_loan >= _economy.max_loan) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
65 |
SetDParam(0, _economy.max_loan); |
0 | 66 |
return_cmd_error(STR_702B_MAXIMUM_PERMITTED_LOAN); |
67 |
} |
|
68 |
||
69 |
if (flags & DC_EXEC) { |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
70 |
/* Loan the maximum amount or not? */ |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
71 |
int32 loan = (p2) ? _economy.max_loan - p->current_loan : IS_HUMAN_PLAYER(_current_player) ? 10000 : 50000; |
0 | 72 |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
73 |
p->money64 += loan; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
74 |
p->current_loan += loan; |
0 | 75 |
UpdatePlayerMoney32(p); |
76 |
InvalidatePlayerWindows(p); |
|
77 |
} |
|
78 |
||
79 |
return 0; |
|
80 |
} |
|
81 |
||
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
82 |
/** Decrease the loan of your company. |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
83 |
* @param x,y unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
84 |
* @param p1 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
85 |
* @param p2 when set, pays back the maximum loan permitting money (press CTRL) |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
86 |
*/ |
0 | 87 |
int32 CmdDecreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
88 |
{ |
|
89 |
Player *p; |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
90 |
int32 loan; |
0 | 91 |
|
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1728
diff
changeset
|
92 |
p = GetPlayer(_current_player); |
0 | 93 |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
94 |
if (p->current_loan == 0) return_cmd_error(STR_702D_LOAN_ALREADY_REPAYED); |
0 | 95 |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
96 |
loan = p->current_loan; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
97 |
|
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
98 |
/* p2 is true while CTRL is pressed (repay all possible loan, or max money you have) |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
99 |
* Repay any loan in chunks of 10.000 pounds */ |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
100 |
if (p2) { |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
101 |
loan = min(loan, p->player_money); |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
102 |
loan = max(loan, 10000); |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
103 |
loan -= loan % 10000; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
104 |
} else { |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
105 |
loan = (_patches.ainew_active) ? min(loan, 10000) : min(loan, IS_HUMAN_PLAYER(_current_player) ? 10000 : 50000); |
0 | 106 |
} |
107 |
||
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
108 |
if (p->player_money < loan) { |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
109 |
SetDParam(0, loan); |
0 | 110 |
return_cmd_error(STR_702E_REQUIRED); |
111 |
} |
|
112 |
||
113 |
if (flags & DC_EXEC) { |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
114 |
p->money64 -= loan; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
115 |
p->current_loan -= loan; |
0 | 116 |
UpdatePlayerMoney32(p); |
117 |
InvalidatePlayerWindows(p); |
|
118 |
} |
|
119 |
return 0; |
|
120 |
} |
|
121 |
||
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
122 |
/** Change the name of the company. |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
123 |
* @param x,y unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
124 |
* @param p1 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
125 |
* @param p2 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
126 |
*/ |
0 | 127 |
int32 CmdChangeCompanyName(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
128 |
{ |
|
1787
79730785d7e7
(svn r2291) - Fix (regression): When a client joined it changed the server-player's name. Funny effect; but not desired. Thanks for pointing it out Tron. It needed a bit of hacking, but is not less of a hack than the one used before :)
Darkvater
parents:
1786
diff
changeset
|
129 |
StringID str; |
0 | 130 |
Player *p; |
131 |
||
1328
e069d2db0e4c
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1317
diff
changeset
|
132 |
str = AllocateNameUnique((const char*)_decode_parameters, 4); |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
133 |
if (str == 0) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
84
diff
changeset
|
134 |
|
0 | 135 |
if (flags & DC_EXEC) { |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
136 |
p = DEREF_PLAYER(_current_player); |
1787
79730785d7e7
(svn r2291) - Fix (regression): When a client joined it changed the server-player's name. Funny effect; but not desired. Thanks for pointing it out Tron. It needed a bit of hacking, but is not less of a hack than the one used before :)
Darkvater
parents:
1786
diff
changeset
|
137 |
DeleteName(p->name_1); |
0 | 138 |
p->name_1 = str; |
139 |
MarkWholeScreenDirty(); |
|
1787
79730785d7e7
(svn r2291) - Fix (regression): When a client joined it changed the server-player's name. Funny effect; but not desired. Thanks for pointing it out Tron. It needed a bit of hacking, but is not less of a hack than the one used before :)
Darkvater
parents:
1786
diff
changeset
|
140 |
} else |
0 | 141 |
DeleteName(str); |
142 |
||
143 |
return 0; |
|
144 |
} |
|
145 |
||
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
146 |
/** Change the name of the president. |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
147 |
* @param x,y unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
148 |
* @param p1 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
149 |
* @param p2 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
150 |
*/ |
0 | 151 |
int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
152 |
{ |
|
1787
79730785d7e7
(svn r2291) - Fix (regression): When a client joined it changed the server-player's name. Funny effect; but not desired. Thanks for pointing it out Tron. It needed a bit of hacking, but is not less of a hack than the one used before :)
Darkvater
parents:
1786
diff
changeset
|
153 |
StringID str; |
0 | 154 |
Player *p; |
155 |
||
1328
e069d2db0e4c
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1317
diff
changeset
|
156 |
str = AllocateNameUnique((const char*)_decode_parameters, 4); |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
157 |
if (str == 0) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
84
diff
changeset
|
158 |
|
0 | 159 |
if (flags & DC_EXEC) { |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
160 |
p = DEREF_PLAYER(_current_player); |
1787
79730785d7e7
(svn r2291) - Fix (regression): When a client joined it changed the server-player's name. Funny effect; but not desired. Thanks for pointing it out Tron. It needed a bit of hacking, but is not less of a hack than the one used before :)
Darkvater
parents:
1786
diff
changeset
|
161 |
DeleteName(p->president_name_1); |
0 | 162 |
p->president_name_1 = str; |
163 |
||
164 |
if (p->name_1 == STR_SV_UNNAMED) { |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
165 |
ttd_strlcat((char*)_decode_parameters, " Transport", sizeof(_decode_parameters)); |
1787
79730785d7e7
(svn r2291) - Fix (regression): When a client joined it changed the server-player's name. Funny effect; but not desired. Thanks for pointing it out Tron. It needed a bit of hacking, but is not less of a hack than the one used before :)
Darkvater
parents:
1786
diff
changeset
|
166 |
DoCommandByTile(0, 0, 0, DC_EXEC, CMD_CHANGE_COMPANY_NAME); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
84
diff
changeset
|
167 |
} |
0 | 168 |
MarkWholeScreenDirty(); |
1787
79730785d7e7
(svn r2291) - Fix (regression): When a client joined it changed the server-player's name. Funny effect; but not desired. Thanks for pointing it out Tron. It needed a bit of hacking, but is not less of a hack than the one used before :)
Darkvater
parents:
1786
diff
changeset
|
169 |
} else |
0 | 170 |
DeleteName(str); |
171 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
84
diff
changeset
|
172 |
return 0; |
0 | 173 |
} |
174 |
||
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
175 |
/** Pause/Unpause the game (server-only). |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
176 |
* Increase or decrease the pause counter. If the counter is zero, |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
177 |
* the game is unpaused. A counter is used instead of a boolean value |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
178 |
* to have more control over the game when saving/loading, etc. |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
179 |
* @param x,y unused |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
180 |
* @param p1 0 = decrease pause counter; 1 = increase pause counter |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
181 |
* @param p2 unused |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
182 |
*/ |
0 | 183 |
int32 CmdPause(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
184 |
{ |
|
185 |
if (flags & DC_EXEC) { |
|
1147
3fae4b3e16a0
(svn r1648) -Fix: server can now pause and unpause a game through the console. Use 'pause' and 'unpause'
darkvater
parents:
1115
diff
changeset
|
186 |
_pause += (p1 == 1) ? 1 : -1; |
3fae4b3e16a0
(svn r1648) -Fix: server can now pause and unpause a game through the console. Use 'pause' and 'unpause'
darkvater
parents:
1115
diff
changeset
|
187 |
if (_pause == (byte)-1) _pause = 0; |
0 | 188 |
InvalidateWindow(WC_STATUS_BAR, 0); |
189 |
InvalidateWindow(WC_MAIN_TOOLBAR, 0); |
|
190 |
} |
|
191 |
return 0; |
|
192 |
} |
|
193 |
||
194 |
||
195 |
int32 CmdMoneyCheat(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
196 |
{ |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
84
diff
changeset
|
197 |
SET_EXPENSES_TYPE(EXPENSES_OTHER); |
0 | 198 |
return (int32)p1; |
199 |
} |
|
200 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
201 |
int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
202 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
203 |
SET_EXPENSES_TYPE(EXPENSES_OTHER); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
204 |
|
815
633faa72f094
(svn r1286) -Fix: oeps, I clamp'd some numbers wrong :$
truelight
parents:
813
diff
changeset
|
205 |
p1 = clamp(p1, 0, 0xFFFFFF); // Clamp between 16 million and 0 |
813
90d6adb8d4ad
(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
truelight
parents:
543
diff
changeset
|
206 |
|
90d6adb8d4ad
(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
truelight
parents:
543
diff
changeset
|
207 |
if (p1 == 0) |
90d6adb8d4ad
(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
truelight
parents:
543
diff
changeset
|
208 |
return CMD_ERROR; |
90d6adb8d4ad
(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
truelight
parents:
543
diff
changeset
|
209 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
210 |
if (flags & DC_EXEC) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
211 |
// Add money to player |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
212 |
byte old_cp = _current_player; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
213 |
_current_player = p2; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
214 |
SubtractMoneyFromPlayer(-(int32)p1); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
215 |
_current_player = old_cp; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
216 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
217 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
218 |
// Subtract money from local-player |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
219 |
return (int32)p1; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
220 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
221 |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
222 |
/** Change difficulty level/settings (server-only). |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
223 |
* We cannot really check for valid values of p2 (too much work mostly); stored |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
224 |
* in file 'settings_gui.c' _game_setting_info[]; we'll just trust the server it knows |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
225 |
* what to do and does this correctly |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
226 |
* @param x,y unused |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
227 |
* @param p1 the difficulty setting being changed. If it is -1, the difficulty level |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
228 |
* itself is changed. The new value is inside p2 |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
229 |
* @param p2 new value for a difficulty setting or difficulty level |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
230 |
*/ |
0 | 231 |
int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
232 |
{ |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
233 |
if (p1 >= GAME_DIFFICULTY_NUM) return CMD_ERROR; |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
234 |
|
0 | 235 |
if (flags & DC_EXEC) { |
236 |
if (p1 != (uint32)-1L) { |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1328
diff
changeset
|
237 |
((int*)&_opt_ptr->diff)[p1] = p2; |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
238 |
_opt_ptr->diff_level = 3; // custom difficulty level |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1328
diff
changeset
|
239 |
} else |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1328
diff
changeset
|
240 |
_opt_ptr->diff_level = p2; |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1328
diff
changeset
|
241 |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
242 |
/* If we are a network-client, update the difficult setting (if it is open). |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
243 |
* Use this instead of just dirtying the window because we need to load in |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1787
diff
changeset
|
244 |
* the new difficulty settings */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
245 |
if (_networking && !_network_server && FindWindowById(WC_GAME_OPTIONS, 0) != NULL) |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1328
diff
changeset
|
246 |
ShowGameDifficulty(); |
0 | 247 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
84
diff
changeset
|
248 |
return 0; |
0 | 249 |
} |