File diff r5586:c50e3258a19f → r5587:034e5e185dc2
src/misc_cmd.cpp
Show inline comments
 
@@ -31,25 +31,25 @@ int32 CmdSetPlayerFace(TileIndex tile, u
 

	
 
/** Change the player's company-colour
 
 * @param tile unused
 
 * @param p1 bitstuffed:
 
 * p1 bits 0-7 scheme to set
 
 * p1 bits 8-9 set in use state or first/second colour
 
 * @param p2 new colour for vehicles, property, etc.
 
 */
 
int32 CmdSetPlayerColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p, *pp;
 
	byte colour;
 
	LiveryScheme scheme = GB(p1, 0, 8);
 
	LiveryScheme scheme = (LiveryScheme)GB(p1, 0, 8);
 
	byte state = GB(p1, 8, 2);
 

	
 
	if (p2 >= 16) return CMD_ERROR; // max 16 colours
 
	colour = p2;
 

	
 
	if (scheme >= LS_END || state >= 3) return CMD_ERROR;
 

	
 
	p = GetPlayer(_current_player);
 

	
 
	/* Ensure no two companies have the same primary colour */
 
	if (scheme == LS_DEFAULT && state == 0) {
 
		FOR_ALL_PLAYERS(pp) {
 
@@ -262,50 +262,50 @@ int32 CmdPause(TileIndex tile, uint32 fl
 
 * This is normally only enabled in offline mode, but if there is a debug
 
 * build, you can cheat (to test).
 
 * @param tile unused
 
 * @param p1 the amount of money to receive (if negative), or spend (if positive)
 
 * @param p2 unused
 
 */
 
int32 CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
#ifndef _DEBUG
 
	if (_networking) return CMD_ERROR;
 
#endif
 
	SET_EXPENSES_TYPE(EXPENSES_OTHER);
 
	return (int32)p1;
 
	return -(int32)p1;
 
}
 

	
 
/** Transfer funds (money) from one player to another.
 
 * To prevent abuse in multiplayer games you can only send money to other
 
 * players if you have paid off your loan (either explicitely, or implicitely
 
 * given the fact that you have more money than loan).
 
 * @param tile unused
 
 * @param p1 the amount of money to transfer; max 20.000.000
 
 * @param p2 the player to transfer the money to
 
 */
 
int32 CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	const Player *p = GetPlayer(_current_player);
 
	int32 amount = min((int32)p1, 20000000);
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_OTHER);
 

	
 
	/* You can only transfer funds that is in excess of your loan */
 
	if (p->money64 - p->current_loan < amount || amount <= 0) return CMD_ERROR;
 
	if (!_networking || !IsValidPlayer((PlayerID)p2)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		/* Add money to player */
 
		PlayerID old_cp = _current_player;
 
		_current_player = p2;
 
		_current_player = (PlayerID)p2;
 
		SubtractMoneyFromPlayer(-amount);
 
		_current_player = old_cp;
 
	}
 

	
 
	/* Subtract money from local-player */
 
	return amount;
 
}
 

	
 
/** 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