Files
@ r1069:72cdacf7c6d0
Branch filter:
Location: cpp/openttd-patchpack/source/misc_cmd.c - annotation
r1069:72cdacf7c6d0
4.9 KiB
text/x-c
(svn r1570) Make the gcc version test work with old versions of test (i.e. don't use the < operator)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r507:b1b0a0a3c313 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r84:ffa541707cbb r84:ffa541707cbb r84:ffa541707cbb r84:ffa541707cbb r84:ffa541707cbb r84:ffa541707cbb r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r534:46e9db8de483 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r815:512ebbfd6302 r813:ab04a7e5afc1 r813:ab04a7e5afc1 r813:ab04a7e5afc1 r813:ab04a7e5afc1 r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 |
#include "stdafx.h"
#include "ttd.h"
#include "table/strings.h"
#include "command.h"
#include "player.h"
#include "gfx.h"
#include "window.h"
#include "saveload.h"
#include "economy.h"
#include "network.h"
/* p1 = player
p2 = face
*/
int32 CmdSetPlayerFace(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) {
DEREF_PLAYER(p1)->face = p2;
MarkWholeScreenDirty();
}
return 0;
}
/* p1 = player
* p2 = color
*/
int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Player *p,*pp;
// /* can only set color for itself */
// if ( (byte)p1 != _current_player)
// return CMD_ERROR;
p = DEREF_PLAYER(p1);
/* ensure no dups */
FOR_ALL_PLAYERS(pp) {
if (pp->is_active && pp != p && pp->player_color == (byte)p2)
return CMD_ERROR;
}
if (flags & DC_EXEC) {
_player_colors[p1] = (byte)p2;
p->player_color = (byte)p2;
MarkWholeScreenDirty();
}
return 0;
}
int32 CmdIncreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Player *p;
int32 size;
if ( (byte)p1 != _current_player)
return CMD_ERROR;
p = DEREF_PLAYER(p1);
if (p->current_loan >= _economy.max_loan) {
SetDParam(0, _economy.max_loan);
return_cmd_error(STR_702B_MAXIMUM_PERMITTED_LOAN);
}
if (flags & DC_EXEC) {
if (p2)
size = _economy.max_loan - p->current_loan;
else
size = IS_HUMAN_PLAYER((byte)p1) ? 10000 : 50000;
p->money64 += size;
p->current_loan += size;
UpdatePlayerMoney32(p);
InvalidatePlayerWindows(p);
}
return 0;
}
int32 CmdDecreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Player *p;
int32 size;
if ( (byte)p1 != _current_player)
return CMD_ERROR;
p = DEREF_PLAYER(p1);
if (p->current_loan == 0)
return_cmd_error(STR_702D_LOAN_ALREADY_REPAYED);
size = p->current_loan;
// p2 is true while CTRL is pressed (repay all possible loan, or max money you have)
if (!p2) {
if (_patches.ainew_active)
size = min(size, 10000);
else
size = min(size, IS_HUMAN_PLAYER((byte)p1) ? 10000 : 50000);
} else { // only repay in chunks of 10K
size = min(size, p->player_money);
size = max(size, 10000);
size -= size % 10000;
}
if (p->player_money < size) {
SetDParam(0, size);
return_cmd_error(STR_702E_REQUIRED);
}
if (flags & DC_EXEC) {
p->money64 -= size;
p->current_loan -= size;
UpdatePlayerMoney32(p);
InvalidatePlayerWindows(p);
}
return 0;
}
int32 CmdChangeCompanyName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
StringID str,old_str;
Player *p;
str = AllocateNameUnique((byte*)_decode_parameters, 4);
if (str == 0)
return CMD_ERROR;
if (flags & DC_EXEC) {
p = DEREF_PLAYER(p1);
old_str = p->name_1;
p->name_1 = str;
DeleteName(old_str);
MarkWholeScreenDirty();
} else {
DeleteName(str);
}
return 0;
}
int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
StringID str,old_str;
Player *p;
str = AllocateNameUnique((byte*)_decode_parameters, 4);
if (str == 0)
return CMD_ERROR;
if (flags & DC_EXEC) {
p = DEREF_PLAYER(p1);
old_str = p->president_name_1;
p->president_name_1 = str;
DeleteName(old_str);
if (p->name_1 == STR_SV_UNNAMED) {
byte *s = " Transport";
byte *d = (byte*)_decode_parameters, b;
d--; do d++; while (*d);
do *d++ = b = *s++; while(d != (byte*)endof(_decode_parameters) && b != 0);
DoCommandByTile(0, p1, 0, DC_EXEC, CMD_CHANGE_COMPANY_NAME);
}
MarkWholeScreenDirty();
} else {
DeleteName(str);
}
return 0;
}
// p1 = 0 decrease pause counter
// p1 = 1 increase pause counter
int32 CmdPause(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) {
_pause += p1?1:-1;
if(_pause==(byte)-1) _pause = 0;
InvalidateWindow(WC_STATUS_BAR, 0);
InvalidateWindow(WC_MAIN_TOOLBAR, 0);
}
return 0;
}
int32 CmdResume(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
return 0;
}
int32 CmdMoneyCheat(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
SET_EXPENSES_TYPE(EXPENSES_OTHER);
return (int32)p1;
}
int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
SET_EXPENSES_TYPE(EXPENSES_OTHER);
p1 = clamp(p1, 0, 0xFFFFFF); // Clamp between 16 million and 0
if (p1 == 0)
return CMD_ERROR;
if (flags & DC_EXEC) {
// Add money to player
byte old_cp = _current_player;
_current_player = p2;
SubtractMoneyFromPlayer(-(int32)p1);
_current_player = old_cp;
}
// Subtract money from local-player
return (int32)p1;
}
int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) {
if (p1 != (uint32)-1L) {
((int*)&_opt_mod_ptr->diff)[p1] = p2;
_opt_mod_ptr->diff_level = 3;
} else {
_opt_mod_ptr->diff_level = p2;
}
// If we are a network-client, update the difficult setting (if it is open)
if (_networking && !_network_server && FindWindowById(WC_GAME_OPTIONS, 0) != NULL)
memcpy(&_opt_mod_temp, _opt_mod_ptr, sizeof(GameOptions));
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
return 0;
}
|