equal
deleted
inserted
replaced
15 #include "economy.h" |
15 #include "economy.h" |
16 #include "network/network.h" |
16 #include "network/network.h" |
17 #include "variables.h" |
17 #include "variables.h" |
18 #include "livery.h" |
18 #include "livery.h" |
19 #include "player_face.h" |
19 #include "player_face.h" |
|
20 #include "strings.h" |
20 |
21 |
21 /** Change the player's face. |
22 /** Change the player's face. |
22 * @param tile unused |
23 * @param tile unused |
23 * @param flags operation to perform |
24 * @param flags operation to perform |
24 * @param p1 unused |
25 * @param p1 unused |
192 InvalidatePlayerWindows(p); |
193 InvalidatePlayerWindows(p); |
193 } |
194 } |
194 return CommandCost(); |
195 return CommandCost(); |
195 } |
196 } |
196 |
197 |
|
198 static bool IsUniqueCompanyName(const char *name) |
|
199 { |
|
200 const Player *p; |
|
201 char buf[512]; |
|
202 |
|
203 FOR_ALL_PLAYERS(p) { |
|
204 SetDParam(0, p->index); |
|
205 GetString(buf, STR_COMPANY_NAME, lastof(buf)); |
|
206 if (strcmp(buf, name) == 0) return false; |
|
207 } |
|
208 |
|
209 return true; |
|
210 } |
|
211 |
197 /** Change the name of the company. |
212 /** Change the name of the company. |
198 * @param tile unused |
213 * @param tile unused |
199 * @param flags operation to perform |
214 * @param flags operation to perform |
200 * @param p1 unused |
215 * @param p1 unused |
201 * @param p2 unused |
216 * @param p2 unused |
203 CommandCost CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
218 CommandCost CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
204 { |
219 { |
205 StringID str; |
220 StringID str; |
206 Player *p; |
221 Player *p; |
207 |
222 |
208 if (_cmd_text[0] == '\0') return CMD_ERROR; |
223 if (StrEmpty(_cmd_text)) return CMD_ERROR; |
209 |
224 |
210 str = AllocateNameUnique(_cmd_text, 4); |
225 if (!IsUniqueCompanyName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); |
|
226 |
|
227 str = AllocateName(_cmd_text, 4); |
211 if (str == 0) return CMD_ERROR; |
228 if (str == 0) return CMD_ERROR; |
212 |
229 |
213 if (flags & DC_EXEC) { |
230 if (flags & DC_EXEC) { |
214 p = GetPlayer(_current_player); |
231 p = GetPlayer(_current_player); |
215 DeleteName(p->name_1); |
232 DeleteName(p->name_1); |
220 } |
237 } |
221 |
238 |
222 return CommandCost(); |
239 return CommandCost(); |
223 } |
240 } |
224 |
241 |
|
242 static bool IsUniquePresidentName(const char *name) |
|
243 { |
|
244 const Player *p; |
|
245 char buf[512]; |
|
246 |
|
247 FOR_ALL_PLAYERS(p) { |
|
248 SetDParam(0, p->index); |
|
249 GetString(buf, STR_PLAYER_NAME, lastof(buf)); |
|
250 if (strcmp(buf, name) == 0) return false; |
|
251 } |
|
252 |
|
253 return true; |
|
254 } |
|
255 |
225 /** Change the name of the president. |
256 /** Change the name of the president. |
226 * @param tile unused |
257 * @param tile unused |
227 * @param flags operation to perform |
258 * @param flags operation to perform |
228 * @param p1 unused |
259 * @param p1 unused |
229 * @param p2 unused |
260 * @param p2 unused |
231 CommandCost CmdChangePresidentName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
262 CommandCost CmdChangePresidentName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
232 { |
263 { |
233 StringID str; |
264 StringID str; |
234 Player *p; |
265 Player *p; |
235 |
266 |
236 if (_cmd_text[0] == '\0') return CMD_ERROR; |
267 if (StrEmpty(_cmd_text)) return CMD_ERROR; |
237 |
268 |
238 str = AllocateNameUnique(_cmd_text, 4); |
269 if (!IsUniquePresidentName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); |
|
270 |
|
271 str = AllocateName(_cmd_text, 4); |
239 if (str == 0) return CMD_ERROR; |
272 if (str == 0) return CMD_ERROR; |
240 |
273 |
241 if (flags & DC_EXEC) { |
274 if (flags & DC_EXEC) { |
242 p = GetPlayer(_current_player); |
275 p = GetPlayer(_current_player); |
243 DeleteName(p->president_name_1); |
276 DeleteName(p->president_name_1); |