summaryrefslogtreecommitdiff
path: root/src/group_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-09-08 21:37:13 +0000
committerrubidium <rubidium@openttd.org>2010-09-08 21:37:13 +0000
commitf5128695c54ad634e1ac45ae4271c1db5ed15fad (patch)
tree7fe3411110d924b4c2d879f3c32ceb5a0ddd4f00 /src/group_gui.cpp
parent881c6c679ff2606111cb890847147556142c3451 (diff)
downloadopenttd-f5128695c54ad634e1ac45ae4271c1db5ed15fad.tar.xz
(svn r20772) -Codechange: use packed VehicleListIdentifiers as window numbers
Diffstat (limited to 'src/group_gui.cpp')
-rw-r--r--src/group_gui.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index f51025e6f..f413046a2 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -173,7 +173,8 @@ public:
this->vscroll = this->GetScrollbar(GRP_WIDGET_LIST_VEHICLE_SCROLLBAR);
this->group_sb = this->GetScrollbar(GRP_WIDGET_LIST_GROUP_SCROLLBAR);
- this->vehicle_type = (VehicleType)GB(window_number, 11, 5);
+ VehicleListIdentifier vli(window_number);
+ this->vehicle_type = vli.vtype;
switch (this->vehicle_type) {
default: NOT_REACHED();
case VEH_TRAIN: this->sorting = &_sorting.train; break;
@@ -186,11 +187,9 @@ public:
this->vehicle_sel = INVALID_VEHICLE;
this->group_rename = INVALID_GROUP;
- const Owner owner = (Owner)GB(window_number, 0, 8);
this->vehicles.SetListing(*this->sorting);
this->vehicles.ForceRebuild();
this->vehicles.NeedResort();
- VehicleListIdentifier vli(IsAllGroupID(this->group_sel) ? VL_STANDARD : VL_GROUP_LIST, this->vehicle_type, owner, this->group_sel);
this->BuildVehicleList(vli);
this->SortVehicleList();
@@ -208,7 +207,7 @@ public:
this->GetWidget<NWidgetCore>(GRP_WIDGET_REPLACE_PROTECTION)->widget_data += this->vehicle_type;
this->FinishInitNested(desc, window_number);
- this->owner = owner;
+ this->owner = vli.company;
}
~VehicleGroupWindow()
@@ -299,11 +298,11 @@ public:
virtual void OnPaint()
{
- const Owner owner = (Owner)GB(this->window_number, 0, 8);
+ VehicleListIdentifier vli(this->window_number);
+ const Owner owner = vli.company;
/* If we select the all vehicles, this->list will contain all vehicles of the owner
* else this->list will contain all vehicles which belong to the selected group */
- VehicleListIdentifier vli(IsAllGroupID(this->group_sel) ? VL_STANDARD : VL_GROUP_LIST, this->vehicle_type, owner, this->group_sel);
this->BuildVehicleList(vli);
this->SortVehicleList();
@@ -659,7 +658,7 @@ void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type)
{
if (!Company::IsValidID(company)) return;
- WindowNumber num = (vehicle_type << 11) | VLW_GROUP_LIST | company;
+ WindowNumber num = VehicleListIdentifier(VL_GROUP_LIST, vehicle_type, company).Pack();
if (vehicle_type == VEH_TRAIN) {
AllocateWindowDescFront<VehicleGroupWindow>(&_train_group_desc, num);
} else {
@@ -676,7 +675,7 @@ void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type)
*/
static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner owner)
{
- return (VehicleGroupWindow *)FindWindowById(GetWindowClassForVehicleType(vt), (vt << 11) | VLW_GROUP_LIST | owner);
+ return (VehicleGroupWindow *)FindWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, owner).Pack());
}
/**