Changeset - r27568:cd0d4a85628d
[Not reviewed]
master
0 5 0
Rubidium - 12 months ago 2023-06-11 19:48:07
rubidium@openttd.org
Codechange: rename function to better describe what it is doing
5 files changed with 12 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -282,20 +282,20 @@ void UpdateLandscapingLimits()
 
		UpdateLandscapingLimit(c->tree_limit,         _settings_game.construction.tree_per_64k_frames,         _settings_game.construction.tree_frame_burst);
 
		UpdateLandscapingLimit(c->build_object_limit, _settings_game.construction.build_object_per_64k_frames, _settings_game.construction.build_object_frame_burst);
 
	}
 
}
 

	
 
/**
 
 * Set the right DParams to get the name of an owner.
 
 * Set the right DParams for STR_ERROR_OWNED_BY.
 
 * @param owner the owner to get the name of.
 
 * @param tile  optional tile to get the right town.
 
 * @pre if tile == 0, then owner can't be OWNER_TOWN.
 
 */
 
void GetNameOfOwner(Owner owner, TileIndex tile)
 
void SetDParamsForOwnedBy(Owner owner, TileIndex tile)
 
{
 
	SetDParam(2, owner);
 
	SetDParam(OWNED_BY_OWNER_IN_PARAMETERS_OFFSET, owner);
 

	
 
	if (owner != OWNER_TOWN) {
 
		if (!Company::IsValidID(owner)) {
 
			SetDParam(0, STR_COMPANY_SOMEONE);
 
		} else {
 
			SetDParam(0, STR_COMPANY_NAME);
 
@@ -323,13 +323,13 @@ CommandCost CheckOwnership(Owner owner, 
 
{
 
	assert(owner < OWNER_END);
 
	assert(owner != OWNER_TOWN || tile != 0);
 

	
 
	if (owner == _current_company) return CommandCost();
 

	
 
	GetNameOfOwner(owner, tile);
 
	SetDParamsForOwnedBy(owner, tile);
 
	return_cmd_error(STR_ERROR_OWNED_BY);
 
}
 

	
 
/**
 
 * Check whether the current owner owns the stuff on
 
 * the given tile.  If that isn't the case an
 
@@ -343,13 +343,13 @@ CommandCost CheckTileOwnership(TileIndex
 

	
 
	assert(owner < OWNER_END);
 

	
 
	if (owner == _current_company) return CommandCost();
 

	
 
	/* no need to get the name of the owner unless we're the local company (saves some time) */
 
	if (IsLocalCompany()) GetNameOfOwner(owner, tile);
 
	if (IsLocalCompany()) SetDParamsForOwnedBy(owner, tile);
 
	return_cmd_error(STR_ERROR_OWNED_BY);
 
}
 

	
 
/**
 
 * Generate the name of a company from the last build coordinate.
 
 * @param c Company to give a name.
src/company_func.h
Show inline comments
 
@@ -14,13 +14,14 @@
 
#include "company_type.h"
 
#include "gfx_type.h"
 
#include "vehicle_type.h"
 

	
 
bool MayCompanyTakeOver(CompanyID cbig, CompanyID small);
 
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
 
void GetNameOfOwner(Owner owner, TileIndex tile);
 
static const int OWNED_BY_OWNER_IN_PARAMETERS_OFFSET = 2; ///< The index in the parameters for the owner information.
 
void SetDParamsForOwnedBy(Owner owner, TileIndex tile);
 
void SetLocalCompany(CompanyID new_company);
 
void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover);
 
void CompanyAdminUpdate(const Company *company);
 
void CompanyAdminBankrupt(CompanyID company_id);
 
void UpdateLandscapingLimits();
 

	
src/error_gui.cpp
Show inline comments
 
@@ -13,12 +13,13 @@
 
#include "newgrf_text.h"
 
#include "error.h"
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "string_func.h"
 
#include "company_base.h"
 
#include "company_func.h"
 
#include "company_manager_face.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 
#include "window_func.h"
 
#include "console_func.h"
 
#include "window_gui.h"
 
@@ -138,13 +139,13 @@ void ErrorMessageData::CopyOutDParams()
 
	/* Get parameters using type information */
 
	if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack);
 
	CopyOutDParam(this->decode_params, this->strings, this->detailed_msg == INVALID_STRING_ID ? this->summary_msg : this->detailed_msg, lengthof(this->decode_params));
 
	if (this->textref_stack_size > 0) StopTextRefStackUsage();
 

	
 
	if (this->detailed_msg == STR_ERROR_OWNED_BY) {
 
		CompanyID company = (CompanyID)GetDParamX(this->decode_params, 2);
 
		CompanyID company = (CompanyID)GetDParamX(this->decode_params, OWNED_BY_OWNER_IN_PARAMETERS_OFFSET);
 
		if (company < MAX_COMPANIES) face = company;
 
	}
 
}
 

	
 
/**
 
 * Set a error string parameter.
src/misc_gui.cpp
Show inline comments
 
@@ -179,13 +179,13 @@ public:
 

	
 
		/* Up to four owners */
 
		for (uint i = 0; i < 4; i++) {
 
			if (td.owner_type[i] == STR_NULL) continue;
 

	
 
			SetDParam(0, STR_LAND_AREA_INFORMATION_OWNER_N_A);
 
			if (td.owner[i] != OWNER_NONE && td.owner[i] != OWNER_WATER) GetNameOfOwner(td.owner[i], tile);
 
			if (td.owner[i] != OWNER_NONE && td.owner[i] != OWNER_WATER) SetDParamsForOwnedBy(td.owner[i], tile);
 
			this->landinfo_data.push_back(GetString(td.owner_type[i]));
 
		}
 

	
 
		/* Cost to clear/revenue when cleared */
 
		StringID str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A;
 
		Company *c = Company::GetIfValid(_local_company);
src/road_cmd.cpp
Show inline comments
 
@@ -2460,14 +2460,14 @@ CommandCost CmdConvertRoad(DoCommandFlag
 
				if (ret.Failed()) {
 
					error = ret;
 
					continue;
 
				}
 

	
 
				if (rtt == RTT_ROAD && owner == OWNER_TOWN) {
 
					SetDParamsForOwnedBy(OWNER_TOWN, tile);
 
					error.MakeError(STR_ERROR_OWNED_BY);
 
					GetNameOfOwner(OWNER_TOWN, tile);
 
					continue;
 
				}
 
			}
 

	
 
			uint num_pieces = CountBits(GetAnyRoadBits(tile, rtt));
 
			if (tt == MP_STATION && IsStandardRoadStopTile(tile)) {
 
@@ -2513,14 +2513,14 @@ CommandCost CmdConvertRoad(DoCommandFlag
 
				if (ret.Failed()) {
 
					error = ret;
 
					continue;
 
				}
 

	
 
				if (rtt == RTT_ROAD && owner == OWNER_TOWN) {
 
					SetDParamsForOwnedBy(OWNER_TOWN, tile);
 
					error.MakeError(STR_ERROR_OWNED_BY);
 
					GetNameOfOwner(OWNER_TOWN, tile);
 
					continue;
 
				}
 
			}
 

	
 
			/* There are 2 pieces on *every* tile of the bridge or tunnel */
 
			uint num_pieces = (GetTunnelBridgeLength(tile, endtile) + 2) * 2;
0 comments (0 inline, 0 general)