summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-10-30 01:31:46 +0200
committerMichael Lutz <michi@icosahedron.de>2021-12-16 22:28:32 +0100
commite740c24eb7a90bc771f5976d64d80639ee7576e5 (patch)
treeb3c8f0c87419cb11c106ba1cb58d6ae0648beef4 /src/economy.cpp
parentc88b104ec662ea80bec89f58aa7ad9d0baac7704 (diff)
downloadopenttd-e740c24eb7a90bc771f5976d64d80639ee7576e5.tar.xz
Codechange: Template DoCommand to automagically reflect the parameters of the command proc.
When finished, this will allow each command handler to take individually different parameters, obliviating the need for bit-packing.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 39e98342f..e7daf8e3d 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -49,6 +49,7 @@
#include "story_base.h"
#include "linkgraph/refresh.h"
#include "economy_cmd.h"
+#include "vehicle_cmd.h"
#include "table/strings.h"
#include "table/pricebase.h"
@@ -313,7 +314,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
for (i = 0; i < 4; i++) {
if (c->share_owners[i] == old_owner) {
/* Sell its shares */
- CommandCost res = DoCommand(DC_EXEC | DC_BANKRUPT, CMD_SELL_SHARE_IN_COMPANY, 0, c->index, 0);
+ CommandCost res = Command<CMD_SELL_SHARE_IN_COMPANY>::Do(DC_EXEC | DC_BANKRUPT, 0, c->index, 0, {});
/* Because we are in a DoCommand, we can't just execute another one and
* expect the money to be removed. We need to do it ourself! */
SubtractMoneyFromCompany(res);
@@ -333,7 +334,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
} else {
cur_company2.Change(c->share_owners[i]);
/* Sell the shares */
- CommandCost res = DoCommand(DC_EXEC | DC_BANKRUPT, CMD_SELL_SHARE_IN_COMPANY, 0, old_owner, 0);
+ CommandCost res = Command<CMD_SELL_SHARE_IN_COMPANY>::Do(DC_EXEC | DC_BANKRUPT, 0, old_owner, 0, {});
/* Because we are in a DoCommand, we can't just execute another one and
* expect the money to be removed. We need to do it ourself! */
SubtractMoneyFromCompany(res);
@@ -449,7 +450,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
* However, do not rely on that behaviour.
*/
int interval = CompanyServiceInterval(new_company, v->type);
- DoCommand(DC_EXEC | DC_BANKRUPT, CMD_CHANGE_SERVICE_INT, v->tile, v->index, interval | (new_company->settings.vehicle.servint_ispercent << 17));
+ Command<CMD_CHANGE_SERVICE_INT>::Do(DC_EXEC | DC_BANKRUPT, v->tile, v->index, interval | (new_company->settings.vehicle.servint_ispercent << 17), {});
}
v->owner = new_owner;
@@ -1486,7 +1487,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
if (st->goods[cid].cargo.HasCargoFor(next_station)) {
/* Try to find out if auto-refitting would succeed. In case the refit is allowed,
* the returned refit capacity will be greater than zero. */
- DoCommand(DC_QUERY_COST, CMD_REFIT_VEHICLE, v_start->tile, v_start->index, cid | 1U << 24 | 0xFF << 8 | 1U << 16); // Auto-refit and only this vehicle including artic parts.
+ Command<CMD_REFIT_VEHICLE>::Do(DC_QUERY_COST, v_start->tile, v_start->index, cid | 1U << 24 | 0xFF << 8 | 1U << 16, {}); // Auto-refit and only this vehicle including artic parts.
/* Try to balance different loadable cargoes between parts of the consist, so that
* all of them can be loaded. Avoid a situation where all vehicles suddenly switch
* to the first loadable cargo for which there is only one packet. If the capacities
@@ -1509,7 +1510,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
* "via any station" before reserving. We rather produce some more "any station" cargo than
* misrouting it. */
IterateVehicleParts(v_start, ReturnCargoAction(st, INVALID_STATION));
- CommandCost cost = DoCommand(DC_EXEC, CMD_REFIT_VEHICLE, v_start->tile, v_start->index, new_cid | 1U << 24 | 0xFF << 8 | 1U << 16); // Auto-refit and only this vehicle including artic parts.
+ CommandCost cost = Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, v_start->tile, v_start->index, new_cid | 1U << 24 | 0xFF << 8 | 1U << 16, {}); // Auto-refit and only this vehicle including artic parts.
if (cost.Succeeded()) v->First()->profit_this_year -= cost.GetCost() << 8;
}