1
0
Fork 0

Codechange: Replace some p1/p2 parameter names with better names (#10658)

pull/10631/head
rubidium42 2023-04-15 15:11:41 +02:00 committed by GitHub
parent 387d5eb74f
commit b19f42ecd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 32 deletions

View File

@ -52,30 +52,30 @@ static int32 _money_cheat_amount = 10000000;
* Note that the amount of money of a company must be changed through a command * Note that the amount of money of a company must be changed through a command
* rather than by setting a variable. Since the cheat data structure expects a * rather than by setting a variable. Since the cheat data structure expects a
* variable, the amount of given/taken money is used for this purpose. * variable, the amount of given/taken money is used for this purpose.
* @param p1 not used. * @param new_value not used.
* @param p2 is -1 or +1 (down/up) * @param change_direction is -1 or +1 (down/up)
* @return Amount of money cheat. * @return Amount of money cheat.
*/ */
static int32 ClickMoneyCheat(int32 p1, int32 p2) static int32 ClickMoneyCheat(int32 new_value, int32 change_direction)
{ {
Command<CMD_MONEY_CHEAT>::Post(Money(_money_cheat_amount) * p2); Command<CMD_MONEY_CHEAT>::Post(Money(_money_cheat_amount) * change_direction);
return _money_cheat_amount; return _money_cheat_amount;
} }
/** /**
* Handle changing of company. * Handle changing of company.
* @param p1 company to set to * @param new_value company to set to
* @param p2 is -1 or +1 (down/up) * @param change_direction is -1 or +1 (down/up)
* @return The new company. * @return The new company.
*/ */
static int32 ClickChangeCompanyCheat(int32 p1, int32 p2) static int32 ClickChangeCompanyCheat(int32 new_value, int32 change_direction)
{ {
while ((uint)p1 < Company::GetPoolSize()) { while ((uint)new_value < Company::GetPoolSize()) {
if (Company::IsValidID((CompanyID)p1)) { if (Company::IsValidID((CompanyID)new_value)) {
SetLocalCompany((CompanyID)p1); SetLocalCompany((CompanyID)new_value);
return _local_company; return _local_company;
} }
p1 += p2; new_value += change_direction;
} }
return _local_company; return _local_company;
@ -83,13 +83,13 @@ static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
/** /**
* Allow (or disallow) changing production of all industries. * Allow (or disallow) changing production of all industries.
* @param p1 new value * @param new_value new value
* @param p2 unused * @param change_direction unused
* @return New value allowing change of industry production. * @return New value allowing change of industry production.
*/ */
static int32 ClickSetProdCheat(int32 p1, int32 p2) static int32 ClickSetProdCheat(int32 new_value, int32 change_direction)
{ {
_cheats.setup_prod.value = (p1 != 0); _cheats.setup_prod.value = (new_value != 0);
InvalidateWindowClassesData(WC_INDUSTRY_VIEW); InvalidateWindowClassesData(WC_INDUSTRY_VIEW);
return _cheats.setup_prod.value; return _cheats.setup_prod.value;
} }
@ -98,19 +98,19 @@ extern void EnginesMonthlyLoop();
/** /**
* Handle changing of the current year. * Handle changing of the current year.
* @param p1 Unused. * @param new_value Unused.
* @param p2 +1 (increase) or -1 (decrease). * @param change_direction +1 (increase) or -1 (decrease).
* @return New year. * @return New year.
*/ */
static int32 ClickChangeDateCheat(int32 p1, int32 p2) static int32 ClickChangeDateCheat(int32 new_value, int32 change_direction)
{ {
YearMonthDay ymd; YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd); ConvertDateToYMD(_date, &ymd);
p1 = Clamp(p1, MIN_YEAR, MAX_YEAR); new_value = Clamp(new_value, MIN_YEAR, MAX_YEAR);
if (p1 == _cur_year) return _cur_year; if (new_value == _cur_year) return _cur_year;
Date new_date = ConvertYMDToDate(p1, ymd.month, ymd.day); Date new_date = ConvertYMDToDate(new_value, ymd.month, ymd.day);
for (auto v : Vehicle::Iterate()) v->ShiftDates(new_date - _date); for (auto v : Vehicle::Iterate()) v->ShiftDates(new_date - _date);
LinkGraphSchedule::instance.ShiftDates(new_date - _date); LinkGraphSchedule::instance.ShiftDates(new_date - _date);
SetDate(new_date, _date_fract); SetDate(new_date, _date_fract);
@ -126,19 +126,19 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
/** /**
* Allow (or disallow) a change of the maximum allowed heightlevel. * Allow (or disallow) a change of the maximum allowed heightlevel.
* @param p1 new value * @param new_value new value
* @param p2 unused * @param change_direction unused
* @return New value (or unchanged old value) of the maximum * @return New value (or unchanged old value) of the maximum
* allowed heightlevel value. * allowed heightlevel value.
*/ */
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2) static int32 ClickChangeMaxHlCheat(int32 new_value, int32 change_direction)
{ {
p1 = Clamp(p1, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT); new_value = Clamp(new_value, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT);
/* Check if at least one mountain on the map is higher than the new value. /* Check if at least one mountain on the map is higher than the new value.
* If yes, disallow the change. */ * If yes, disallow the change. */
for (TileIndex t = 0; t < Map::Size(); t++) { for (TileIndex t = 0; t < Map::Size(); t++) {
if ((int32)TileHeight(t) > p1) { if ((int32)TileHeight(t) > new_value) {
ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR); ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
/* Return old, unchanged value */ /* Return old, unchanged value */
return _settings_game.construction.map_height_limit; return _settings_game.construction.map_height_limit;
@ -146,7 +146,7 @@ static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
} }
/* Execute the change and reload GRF Data */ /* Execute the change and reload GRF Data */
_settings_game.construction.map_height_limit = p1; _settings_game.construction.map_height_limit = new_value;
ReloadNewGRFData(); ReloadNewGRFData();
/* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */ /* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
@ -171,10 +171,10 @@ enum CheatNumbers {
/** /**
* Signature of handler function when user clicks at a cheat. * Signature of handler function when user clicks at a cheat.
* @param p1 The new value. * @param new_value The new value.
* @param p2 Change direction (+1, +1), \c 0 for boolean settings. * @param change_direction Change direction (+1, +1), \c 0 for boolean settings.
*/ */
typedef int32 CheckButtonClick(int32 p1, int32 p2); typedef int32 CheckButtonClick(int32 new_value, int32 change_direction);
/** Information of a cheat. */ /** Information of a cheat. */
struct CheatEntry { struct CheatEntry {

View File

@ -96,7 +96,7 @@ static void v_PositionStatusbar(int32 new_value)
/** /**
* Redraw the smallmap after a colour scheme change. * Redraw the smallmap after a colour scheme change.
* @param p1 Callback parameter. * @param new_value Callback parameter.
*/ */
static void RedrawSmallmap(int32 new_value) static void RedrawSmallmap(int32 new_value)
{ {
@ -112,7 +112,7 @@ static void UpdateLinkgraphColours(int32 new_value)
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
static void StationSpreadChanged(int32 p1) static void StationSpreadChanged(int32 new_value)
{ {
InvalidateWindowData(WC_SELECT_STATION, 0); InvalidateWindowData(WC_SELECT_STATION, 0);
InvalidateWindowData(WC_BUILD_STATION, 0); InvalidateWindowData(WC_BUILD_STATION, 0);