mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-20 12:09:32 +01:00
(svn r13240) -Codechange: More const-ness for GUI code.
This commit is contained in:
parent
60ae799321
commit
d9805b46b9
@ -144,16 +144,14 @@ void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
|||||||
{
|
{
|
||||||
if (!success) return;
|
if (!success) return;
|
||||||
|
|
||||||
Vehicle *v = GetVehicle(_new_vehicle_id);
|
const Vehicle *v = GetVehicle(_new_vehicle_id);
|
||||||
|
|
||||||
ShowVehicleViewWindow(v);
|
ShowVehicleViewWindow(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head)
|
static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Vehicle *head)
|
||||||
{
|
{
|
||||||
Vehicle *v;
|
const Vehicle *v = GetVehicle(sel);
|
||||||
|
|
||||||
v = GetVehicle(sel);
|
|
||||||
|
|
||||||
if (v == wagon) return;
|
if (v == wagon) return;
|
||||||
|
|
||||||
@ -397,8 +395,8 @@ struct DepotWindow : Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct GetDepotVehiclePtData {
|
struct GetDepotVehiclePtData {
|
||||||
Vehicle *head;
|
const Vehicle *head;
|
||||||
Vehicle *wagon;
|
const Vehicle *wagon;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DepotGUIAction {
|
enum DepotGUIAction {
|
||||||
@ -408,7 +406,7 @@ struct DepotWindow : Window {
|
|||||||
MODE_START_STOP,
|
MODE_START_STOP,
|
||||||
};
|
};
|
||||||
|
|
||||||
DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, Vehicle **veh, GetDepotVehiclePtData *d) const
|
DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, const Vehicle **veh, GetDepotVehiclePtData *d) const
|
||||||
{
|
{
|
||||||
Vehicle **vl = this->vehicle_list;
|
Vehicle **vl = this->vehicle_list;
|
||||||
uint xt, row, xm = 0, ym = 0;
|
uint xt, row, xm = 0, ym = 0;
|
||||||
@ -454,7 +452,7 @@ struct DepotWindow : Window {
|
|||||||
|
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
case VEH_TRAIN: {
|
case VEH_TRAIN: {
|
||||||
Vehicle *v = *veh;
|
const Vehicle *v = *veh;
|
||||||
d->head = d->wagon = v;
|
d->head = d->wagon = v;
|
||||||
|
|
||||||
/* either pressed the flag or the number, but only when it's a loco */
|
/* either pressed the flag or the number, but only when it's a loco */
|
||||||
@ -501,7 +499,7 @@ struct DepotWindow : Window {
|
|||||||
void DepotClick(int x, int y)
|
void DepotClick(int x, int y)
|
||||||
{
|
{
|
||||||
GetDepotVehiclePtData gdvp = { NULL, NULL };
|
GetDepotVehiclePtData gdvp = { NULL, NULL };
|
||||||
Vehicle *v = NULL;
|
const Vehicle *v = NULL;
|
||||||
DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
|
DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
|
||||||
|
|
||||||
/* share / copy orders */
|
/* share / copy orders */
|
||||||
@ -879,7 +877,7 @@ struct DepotWindow : Window {
|
|||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case DEPOT_WIDGET_MATRIX: {
|
case DEPOT_WIDGET_MATRIX: {
|
||||||
Vehicle *v = NULL;
|
const Vehicle *v = NULL;
|
||||||
VehicleID sel = this->sel;
|
VehicleID sel = this->sel;
|
||||||
|
|
||||||
this->sel = INVALID_VEHICLE;
|
this->sel = INVALID_VEHICLE;
|
||||||
@ -908,23 +906,20 @@ struct DepotWindow : Window {
|
|||||||
case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
|
case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
|
||||||
if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
|
if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
|
||||||
this->sel != INVALID_VEHICLE) {
|
this->sel != INVALID_VEHICLE) {
|
||||||
Vehicle *v;
|
|
||||||
uint command;
|
uint command;
|
||||||
int sell_cmd;
|
|
||||||
bool is_engine;
|
|
||||||
|
|
||||||
if (this->IsWidgetDisabled(widget)) return;
|
if (this->IsWidgetDisabled(widget)) return;
|
||||||
if (this->sel == INVALID_VEHICLE) return;
|
if (this->sel == INVALID_VEHICLE) return;
|
||||||
|
|
||||||
this->HandleButtonClick(widget);
|
this->HandleButtonClick(widget);
|
||||||
|
|
||||||
v = GetVehicle(this->sel);
|
const Vehicle *v = GetVehicle(this->sel);
|
||||||
this->sel = INVALID_VEHICLE;
|
this->sel = INVALID_VEHICLE;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
|
int sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
|
||||||
|
|
||||||
is_engine = (!(v->type == VEH_TRAIN && !IsFrontEngine(v)));
|
bool is_engine = (!(v->type == VEH_TRAIN && !IsFrontEngine(v)));
|
||||||
|
|
||||||
if (is_engine) {
|
if (is_engine) {
|
||||||
_backup_orders_tile = v->tile;
|
_backup_orders_tile = v->tile;
|
||||||
|
@ -28,8 +28,8 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
|||||||
if (!success) return;
|
if (!success) return;
|
||||||
|
|
||||||
/* find a locomotive in the depot. */
|
/* find a locomotive in the depot. */
|
||||||
Vehicle *found = NULL;
|
const Vehicle *found = NULL;
|
||||||
Vehicle *v;
|
const Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->type == VEH_TRAIN && IsFrontEngine(v) &&
|
if (v->type == VEH_TRAIN && IsFrontEngine(v) &&
|
||||||
v->tile == tile &&
|
v->tile == tile &&
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
#define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6))
|
#define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6))
|
||||||
|
|
||||||
VehicleID _vehicle_id_ctr_day;
|
VehicleID _vehicle_id_ctr_day;
|
||||||
Vehicle *_place_clicked_vehicle;
|
const Vehicle *_place_clicked_vehicle;
|
||||||
VehicleID _new_vehicle_id;
|
VehicleID _new_vehicle_id;
|
||||||
uint16 _returned_refit_capacity;
|
uint16 _returned_refit_capacity;
|
||||||
|
|
||||||
@ -531,6 +531,12 @@ Vehicle *GetLastVehicleInChain(Vehicle *v)
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Vehicle *GetLastVehicleInChain(const Vehicle *v)
|
||||||
|
{
|
||||||
|
while (v->Next() != NULL) v = v->Next();
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
uint CountVehiclesInChain(const Vehicle* v)
|
uint CountVehiclesInChain(const Vehicle* v)
|
||||||
{
|
{
|
||||||
uint count = 0;
|
uint count = 0;
|
||||||
|
@ -24,6 +24,7 @@ typedef void *VehicleFromPosProc(Vehicle *v, void *data);
|
|||||||
void VehicleServiceInDepot(Vehicle *v);
|
void VehicleServiceInDepot(Vehicle *v);
|
||||||
void VehiclePositionChanged(Vehicle *v);
|
void VehiclePositionChanged(Vehicle *v);
|
||||||
Vehicle *GetLastVehicleInChain(Vehicle *v);
|
Vehicle *GetLastVehicleInChain(Vehicle *v);
|
||||||
|
const Vehicle *GetLastVehicleInChain(const Vehicle *v);
|
||||||
uint CountVehiclesInChain(const Vehicle *v);
|
uint CountVehiclesInChain(const Vehicle *v);
|
||||||
bool IsEngineCountable(const Vehicle *v);
|
bool IsEngineCountable(const Vehicle *v);
|
||||||
void DeleteVehicleChain(Vehicle *v);
|
void DeleteVehicleChain(Vehicle *v);
|
||||||
@ -173,7 +174,7 @@ bool EnsureNoVehicleOnGround(TileIndex tile);
|
|||||||
void StopAllVehicles();
|
void StopAllVehicles();
|
||||||
|
|
||||||
extern VehicleID _vehicle_id_ctr_day;
|
extern VehicleID _vehicle_id_ctr_day;
|
||||||
extern Vehicle *_place_clicked_vehicle;
|
extern const Vehicle *_place_clicked_vehicle;
|
||||||
extern VehicleID _new_vehicle_id;
|
extern VehicleID _new_vehicle_id;
|
||||||
extern uint16 _returned_refit_capacity;
|
extern uint16 _returned_refit_capacity;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user