Codechange: Template DoCommandP 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.
This commit is contained in:
@@ -25,6 +25,9 @@
|
||||
#include "rail_gui.h"
|
||||
#include "road_gui.h"
|
||||
#include "widgets/dropdown_func.h"
|
||||
#include "autoreplace_cmd.h"
|
||||
#include "group_cmd.h"
|
||||
#include "settings_cmd.h"
|
||||
|
||||
#include "widgets/autoreplace_widget.h"
|
||||
|
||||
@@ -217,7 +220,7 @@ class ReplaceVehicleWindow : public Window {
|
||||
{
|
||||
EngineID veh_from = this->sel_engine[0];
|
||||
EngineID veh_to = this->sel_engine[1];
|
||||
DoCommandP(CMD_SET_AUTOREPLACE, 0, (replace_when_old ? 1 : 0) | (this->sel_group << 16), veh_from + (veh_to << 16));
|
||||
Command<CMD_SET_AUTOREPLACE>::Post(0, (replace_when_old ? 1 : 0) | (this->sel_group << 16), veh_from + (veh_to << 16), {});
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -541,10 +544,10 @@ public:
|
||||
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
|
||||
const Group *g = Group::GetIfValid(this->sel_group);
|
||||
if (g != nullptr) {
|
||||
DoCommandP(CMD_SET_GROUP_FLAG, 0, this->sel_group | (GroupFlags::GF_REPLACE_WAGON_REMOVAL << 16), (HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL) ? 0 : 1) | (_ctrl_pressed << 1));
|
||||
Command<CMD_SET_GROUP_FLAG>::Post(0, this->sel_group | (GroupFlags::GF_REPLACE_WAGON_REMOVAL << 16), (HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL) ? 0 : 1) | (_ctrl_pressed << 1), {});
|
||||
} else {
|
||||
// toggle renew_keep_length
|
||||
DoCommandP(CMD_CHANGE_COMPANY_SETTING, 0, 0, Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, "company.renew_keep_length");
|
||||
Command<CMD_CHANGE_COMPANY_SETTING>::Post(0, 0, Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, "company.renew_keep_length");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -562,7 +565,7 @@ public:
|
||||
|
||||
case WID_RV_STOP_REPLACE: { // Stop replacing
|
||||
EngineID veh_from = this->sel_engine[0];
|
||||
DoCommandP(CMD_SET_AUTOREPLACE, 0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16));
|
||||
Command<CMD_SET_AUTOREPLACE>::Post(0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16), {});
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -584,7 +587,7 @@ public:
|
||||
if (click_side == 0 && _ctrl_pressed && e != INVALID_ENGINE &&
|
||||
(GetGroupNumEngines(_local_company, sel_group, e) == 0 || GetGroupNumEngines(_local_company, ALL_GROUP, e) == 0)) {
|
||||
EngineID veh_from = e;
|
||||
DoCommandP(CMD_SET_AUTOREPLACE, 0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16));
|
||||
Command<CMD_SET_AUTOREPLACE>::Post(0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16), {});
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user