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
 
@@ -285,14 +285,14 @@ void UpdateLandscapingLimits()
 
}
 

	
 
/**
 
 * 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)) {
 
@@ -326,7 +326,7 @@ CommandCost CheckOwnership(Owner owner, 
 

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

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

	
 
@@ -346,7 +346,7 @@ CommandCost CheckTileOwnership(TileIndex
 
	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);
 
}
 

	
src/company_func.h
Show inline comments
 
@@ -17,7 +17,8 @@
 

	
 
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);
src/error_gui.cpp
Show inline comments
 
@@ -16,6 +16,7 @@
 
#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"
 
@@ -141,7 +142,7 @@ void ErrorMessageData::CopyOutDParams()
 
	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;
 
	}
 
}
src/misc_gui.cpp
Show inline comments
 
@@ -182,7 +182,7 @@ public:
 
			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]));
 
		}
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -2463,8 +2463,8 @@ CommandCost CmdConvertRoad(DoCommandFlag
 
				}
 

	
 
				if (rtt == RTT_ROAD && owner == OWNER_TOWN) {
 
					SetDParamsForOwnedBy(OWNER_TOWN, tile);
 
					error.MakeError(STR_ERROR_OWNED_BY);
 
					GetNameOfOwner(OWNER_TOWN, tile);
 
					continue;
 
				}
 
			}
 
@@ -2516,8 +2516,8 @@ CommandCost CmdConvertRoad(DoCommandFlag
 
				}
 

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