mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r15336) -Fix: do not use _current_company in the GUI as there are no guarantees that _current_company is the same as _local_company.
This commit is contained in:
parent
09fca459a7
commit
7da743a0dc
|
@ -147,7 +147,7 @@ static const WindowDesc _air_toolbar_desc = {
|
||||||
|
|
||||||
void ShowBuildAirToolbar()
|
void ShowBuildAirToolbar()
|
||||||
{
|
{
|
||||||
if (!IsValidCompanyID(_current_company)) return;
|
if (!IsValidCompanyID(_local_company)) return;
|
||||||
|
|
||||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||||
AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
|
AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
|
||||||
|
|
|
@ -166,7 +166,7 @@ struct CheatWindow : Window {
|
||||||
case STR_CHEAT_CHANGE_COMPANY:
|
case STR_CHEAT_CHANGE_COMPANY:
|
||||||
SetDParam(0, val + 1);
|
SetDParam(0, val + 1);
|
||||||
GetString(buf, STR_CHEAT_CHANGE_COMPANY, lastof(buf));
|
GetString(buf, STR_CHEAT_CHANGE_COMPANY, lastof(buf));
|
||||||
DrawCompanyIcon(_current_company, 60 + GetStringBoundingBox(buf).width, y + 2);
|
DrawCompanyIcon(_local_company, 60 + GetStringBoundingBox(buf).width, y + 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Set correct string for switch climate cheat */
|
/* Set correct string for switch climate cheat */
|
||||||
|
|
|
@ -282,7 +282,7 @@ static const WindowDesc _build_docks_toolbar_desc = {
|
||||||
|
|
||||||
void ShowBuildDocksToolbar()
|
void ShowBuildDocksToolbar()
|
||||||
{
|
{
|
||||||
if (!IsValidCompanyID(_current_company)) return;
|
if (!IsValidCompanyID(_local_company)) return;
|
||||||
|
|
||||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||||
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
|
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
|
||||||
|
|
|
@ -417,7 +417,7 @@ public:
|
||||||
|
|
||||||
void ShowBuildIndustryWindow()
|
void ShowBuildIndustryWindow()
|
||||||
{
|
{
|
||||||
if (_game_mode != GM_EDITOR && !IsValidCompanyID(_current_company)) return;
|
if (_game_mode != GM_EDITOR && !IsValidCompanyID(_local_company)) return;
|
||||||
if (BringWindowToFrontById(WC_BUILD_INDUSTRY, 0)) return;
|
if (BringWindowToFrontById(WC_BUILD_INDUSTRY, 0)) return;
|
||||||
new BuildIndustryWindow();
|
new BuildIndustryWindow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ void HandleOnEditText(const char *str)
|
||||||
switch (_rename_what) {
|
switch (_rename_what) {
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
case 3: { // Give money, you can only give money in excess of loan
|
case 3: { // Give money, you can only give money in excess of loan
|
||||||
const Company *c = GetCompany(_current_company);
|
const Company *c = GetCompany(_local_company);
|
||||||
Money money = min(c->money - c->current_loan, (Money)(atoi(str) / _currency->rate));
|
Money money = min(c->money - c->current_loan, (Money)(atoi(str) / _currency->rate));
|
||||||
|
|
||||||
uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
|
uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
|
||||||
|
|
|
@ -350,7 +350,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
||||||
StationID st_index = GetStationIndex(tile);
|
StationID st_index = GetStationIndex(tile);
|
||||||
const Station *st = GetStation(st_index);
|
const Station *st = GetStation(st_index);
|
||||||
|
|
||||||
if (st->owner == _current_company || st->owner == OWNER_NONE) {
|
if (st->owner == _local_company || st->owner == OWNER_NONE) {
|
||||||
byte facil;
|
byte facil;
|
||||||
(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
|
(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
|
||||||
(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
|
(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
|
||||||
|
|
|
@ -833,7 +833,7 @@ void ShowBuildRailToolbar(RailType railtype, int button)
|
||||||
{
|
{
|
||||||
BuildRailToolbarWindow *w;
|
BuildRailToolbarWindow *w;
|
||||||
|
|
||||||
if (!IsValidCompanyID(_current_company)) return;
|
if (!IsValidCompanyID(_local_company)) return;
|
||||||
if (!ValParamRailtype(railtype)) return;
|
if (!ValParamRailtype(railtype)) return;
|
||||||
|
|
||||||
// don't recreate the window if we're clicking on a button and the window exists.
|
// don't recreate the window if we're clicking on a button and the window exists.
|
||||||
|
|
|
@ -678,7 +678,7 @@ static const WindowDesc _build_tramway_desc = {
|
||||||
|
|
||||||
void ShowBuildRoadToolbar(RoadType roadtype)
|
void ShowBuildRoadToolbar(RoadType roadtype)
|
||||||
{
|
{
|
||||||
if (!IsValidCompanyID(_current_company)) return;
|
if (!IsValidCompanyID(_local_company)) return;
|
||||||
_cur_roadtype = roadtype;
|
_cur_roadtype = roadtype;
|
||||||
|
|
||||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||||
|
|
|
@ -952,16 +952,16 @@ struct StationViewWindow : public Window {
|
||||||
|
|
||||||
case SVW_PLANES: { // Show a list of scheduled aircraft to this station
|
case SVW_PLANES: { // Show a list of scheduled aircraft to this station
|
||||||
const Station *st = GetStation(this->window_number);
|
const Station *st = GetStation(this->window_number);
|
||||||
/* Since oilrigs have no owners, show the scheduled aircraft of current company */
|
/* Since oilrigs have no owners, show the scheduled aircraft of local company */
|
||||||
Owner owner = (st->owner == OWNER_NONE) ? _current_company : st->owner;
|
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
||||||
ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)this->window_number);
|
ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)this->window_number);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SVW_SHIPS: { // Show a list of scheduled ships to this station
|
case SVW_SHIPS: { // Show a list of scheduled ships to this station
|
||||||
const Station *st = GetStation(this->window_number);
|
const Station *st = GetStation(this->window_number);
|
||||||
/* Since oilrigs/bouys have no owners, show the scheduled ships of current company */
|
/* Since oilrigs/bouys have no owners, show the scheduled ships of local company */
|
||||||
Owner owner = (st->owner == OWNER_NONE) ? _current_company : st->owner;
|
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
||||||
ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number);
|
ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,7 +334,7 @@ static const WindowDesc _terraform_desc = {
|
||||||
|
|
||||||
void ShowTerraformToolbar(Window *link)
|
void ShowTerraformToolbar(Window *link)
|
||||||
{
|
{
|
||||||
if (!IsValidCompanyID(_current_company)) return;
|
if (!IsValidCompanyID(_local_company)) return;
|
||||||
|
|
||||||
Window *w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
|
Window *w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
|
||||||
if (link == NULL) return;
|
if (link == NULL) return;
|
||||||
|
|
|
@ -529,7 +529,7 @@ static void MenuClickLeague(int index)
|
||||||
static void ToolbarIndustryClick(Window *w)
|
static void ToolbarIndustryClick(Window *w)
|
||||||
{
|
{
|
||||||
/* Disable build-industry menu if we are a spectator */
|
/* Disable build-industry menu if we are a spectator */
|
||||||
PopupMainToolbMenu(w, TBN_INDUSTRIES, STR_INDUSTRY_DIR, (_current_company == COMPANY_SPECTATOR) ? 1 : 2);
|
PopupMainToolbMenu(w, TBN_INDUSTRIES, STR_INDUSTRY_DIR, (_local_company == COMPANY_SPECTATOR) ? 1 : 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MenuClickIndustry(int index)
|
static void MenuClickIndustry(int index)
|
||||||
|
@ -1035,7 +1035,7 @@ struct MainToolbarWindow : Window {
|
||||||
/* If spectator, disable all construction buttons
|
/* If spectator, disable all construction buttons
|
||||||
* ie : Build road, rail, ships, airports and landscaping
|
* ie : Build road, rail, ships, airports and landscaping
|
||||||
* Since enabled state is the default, just disable when needed */
|
* Since enabled state is the default, just disable when needed */
|
||||||
this->SetWidgetsDisabledState(_current_company == COMPANY_SPECTATOR, TBN_RAILS, TBN_ROADS, TBN_WATER, TBN_AIR, TBN_LANDSCAPE, WIDGET_LIST_END);
|
this->SetWidgetsDisabledState(_local_company == COMPANY_SPECTATOR, TBN_RAILS, TBN_ROADS, TBN_WATER, TBN_AIR, TBN_LANDSCAPE, WIDGET_LIST_END);
|
||||||
/* disable company list drop downs, if there are no companies */
|
/* disable company list drop downs, if there are no companies */
|
||||||
this->SetWidgetsDisabledState(ActiveCompanyCount() == TBN_PAUSE, TBN_STATIONS, TBN_FINANCES, TBN_TRAINS, TBN_ROADVEHS, TBN_SHIPS, TBN_AIRCRAFTS, WIDGET_LIST_END);
|
this->SetWidgetsDisabledState(ActiveCompanyCount() == TBN_PAUSE, TBN_STATIONS, TBN_FINANCES, TBN_TRAINS, TBN_ROADVEHS, TBN_SHIPS, TBN_AIRCRAFTS, WIDGET_LIST_END);
|
||||||
|
|
||||||
|
|
|
@ -725,6 +725,6 @@ static const WindowDesc _scen_edit_town_gen_desc = {
|
||||||
|
|
||||||
void ShowBuildTownWindow()
|
void ShowBuildTownWindow()
|
||||||
{
|
{
|
||||||
if (_game_mode != GM_EDITOR && !IsValidCompanyID(_current_company)) return;
|
if (_game_mode != GM_EDITOR && !IsValidCompanyID(_local_company)) return;
|
||||||
AllocateWindowDescFront<ScenarioEditorTownGenerationWindow>(&_scen_edit_town_gen_desc, 0);
|
AllocateWindowDescFront<ScenarioEditorTownGenerationWindow>(&_scen_edit_town_gen_desc, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,6 +180,6 @@ static const WindowDesc _build_trees_desc = {
|
||||||
|
|
||||||
void ShowBuildTreesToolbar()
|
void ShowBuildTreesToolbar()
|
||||||
{
|
{
|
||||||
if (_game_mode != GM_EDITOR && !IsValidCompanyID(_current_company)) return;
|
if (_game_mode != GM_EDITOR && !IsValidCompanyID(_local_company)) return;
|
||||||
AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0);
|
AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1786,7 +1786,7 @@ bool CanBuildVehicleInfrastructure(VehicleType type)
|
||||||
{
|
{
|
||||||
assert(IsCompanyBuildableVehicleType(type));
|
assert(IsCompanyBuildableVehicleType(type));
|
||||||
|
|
||||||
if (!IsValidCompanyID(_current_company)) return false;
|
if (!IsValidCompanyID(_local_company)) return false;
|
||||||
if (_settings_client.gui.always_build_infrastructure) return true;
|
if (_settings_client.gui.always_build_infrastructure) return true;
|
||||||
|
|
||||||
UnitID max;
|
UnitID max;
|
||||||
|
|
Loading…
Reference in New Issue