mirror of https://github.com/OpenTTD/OpenTTD.git
(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
This commit is contained in:
parent
203a84dd0b
commit
d17476b058
4
ai.c
4
ai.c
|
@ -3882,14 +3882,14 @@ static void AiAdjustLoan(Player *p)
|
|||
if (p->player_money > base * 1400) {
|
||||
// Decrease loan
|
||||
if (p->current_loan != 0) {
|
||||
DoCommandByTile(0, _current_player, 0, DC_EXEC, CMD_DECREASE_LOAN);
|
||||
DoCommandByTile(0, 0, 0, DC_EXEC, CMD_DECREASE_LOAN);
|
||||
}
|
||||
} else if (p->player_money < base * 500) {
|
||||
// Increase loan
|
||||
if (p->current_loan < _economy.max_loan &&
|
||||
p->num_valid_stat_ent >= 2 &&
|
||||
-(p->old_economy[0].expenses+p->old_economy[1].expenses) < base * 60) {
|
||||
DoCommandByTile(0, _current_player, 0, DC_EXEC, CMD_INCREASE_LOAN);
|
||||
DoCommandByTile(0, 0, 0, DC_EXEC, CMD_INCREASE_LOAN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
ai_new.c
2
ai_new.c
|
@ -1191,7 +1191,7 @@ static void AiNew_State_StartVehicle(Player *p) {
|
|||
static void AiNew_State_RepayMoney(Player *p) {
|
||||
int i;
|
||||
for (i=0;i<AI_LOAN_REPAY;i++)
|
||||
DoCommandByTile(0, _current_player, 0, DC_EXEC, CMD_DECREASE_LOAN);
|
||||
DoCommandByTile(0, 0, 0, DC_EXEC, CMD_DECREASE_LOAN);
|
||||
p->ainew.state = AI_STATE_ACTION_DONE;
|
||||
}
|
||||
|
||||
|
|
23
misc_cmd.c
23
misc_cmd.c
|
@ -18,7 +18,7 @@
|
|||
int32 CmdSetPlayerFace(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
DEREF_PLAYER(p1)->face = p2;
|
||||
GetPlayer(_current_player)->face = p2;
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
return 0;
|
||||
|
@ -31,11 +31,7 @@ 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);
|
||||
p = GetPlayer(_current_player);
|
||||
|
||||
/* ensure no dups */
|
||||
FOR_ALL_PLAYERS(pp) {
|
||||
|
@ -44,7 +40,7 @@ int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
_player_colors[p1] = (byte)p2;
|
||||
_player_colors[_current_player] = (byte)p2;
|
||||
p->player_color = (byte)p2;
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
|
@ -56,10 +52,7 @@ 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);
|
||||
p = GetPlayer(_current_player);
|
||||
|
||||
if (p->current_loan >= _economy.max_loan) {
|
||||
SetDParam(0, _economy.max_loan);
|
||||
|
@ -70,7 +63,7 @@ int32 CmdIncreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||
if (p2)
|
||||
size = _economy.max_loan - p->current_loan;
|
||||
else
|
||||
size = IS_HUMAN_PLAYER((byte)p1) ? 10000 : 50000;
|
||||
size = IS_HUMAN_PLAYER(_current_player) ? 10000 : 50000;
|
||||
|
||||
p->money64 += size;
|
||||
p->current_loan += size;
|
||||
|
@ -85,10 +78,8 @@ 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);
|
||||
p = GetPlayer(_current_player);
|
||||
|
||||
if (p->current_loan == 0)
|
||||
return_cmd_error(STR_702D_LOAN_ALREADY_REPAYED);
|
||||
|
@ -100,7 +91,7 @@ int32 CmdDecreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||
if (_patches.ainew_active)
|
||||
size = min(size, 10000);
|
||||
else
|
||||
size = min(size, IS_HUMAN_PLAYER((byte)p1) ? 10000 : 50000);
|
||||
size = min(size, IS_HUMAN_PLAYER(_current_player) ? 10000 : 50000);
|
||||
} else { // only repay in chunks of 10K
|
||||
size = min(size, p->player_money);
|
||||
size = max(size, 10000);
|
||||
|
|
8
player.h
8
player.h
|
@ -192,12 +192,18 @@ int64 CalculateCompanyValue(Player *p);
|
|||
void InvalidatePlayerWindows(Player *p);
|
||||
void AiDoGameLoop(Player *p);
|
||||
void UpdatePlayerMoney32(Player *p);
|
||||
#define DEREF_PLAYER(i) (&_players[i])
|
||||
#define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++)
|
||||
|
||||
#define MAX_PLAYERS 8
|
||||
VARDEF Player _players[MAX_PLAYERS];
|
||||
|
||||
#define DEREF_PLAYER(i) (GetPlayer(i))
|
||||
static inline Player* GetPlayer(uint i)
|
||||
{
|
||||
assert(i < lengthof(_players));
|
||||
return &_players[i];
|
||||
}
|
||||
|
||||
#define IS_HUMAN_PLAYER(p) (!DEREF_PLAYER((byte)(p))->is_ai)
|
||||
#define IS_INTERACTIVE_PLAYER(p) (((byte)p) == _local_player)
|
||||
|
||||
|
|
|
@ -168,11 +168,11 @@ static void PlayerFinancesWndProc(Window *w, WindowEvent *e)
|
|||
} break;
|
||||
|
||||
case 6: /* increase loan */
|
||||
DoCommandP(0, w->window_number, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
|
||||
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
|
||||
break;
|
||||
|
||||
case 7: /* repay loan */
|
||||
DoCommandP(0, w->window_number, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
|
||||
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -285,7 +285,7 @@ static void SelectPlayerColorWndProc(Window *w, WindowEvent *e)
|
|||
|
||||
for(i=0; i!=16; i++) {
|
||||
if (!(used_colors & 1) && --item < 0) {
|
||||
DoCommandP(0, w->window_number, i, NULL, CMD_SET_PLAYER_COLOR);
|
||||
DoCommandP(0, 0, i, NULL, CMD_SET_PLAYER_COLOR);
|
||||
DeleteWindow(w);
|
||||
break;
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e)
|
|||
switch(e->click.widget) {
|
||||
case 3: DeleteWindow(w); break;
|
||||
case 4: /* ok click */
|
||||
DoCommandP(0, w->window_number, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE);
|
||||
DoCommandP(0, 0, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE);
|
||||
DeleteWindow(w);
|
||||
break;
|
||||
case 5: /* male click */
|
||||
|
|
Loading…
Reference in New Issue