mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(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()
|
||||
{
|
||||
if (!IsValidCompanyID(_current_company)) return;
|
||||
if (!IsValidCompanyID(_local_company)) return;
|
||||
|
||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||
AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
|
||||
|
@ -166,7 +166,7 @@ struct CheatWindow : Window {
|
||||
case STR_CHEAT_CHANGE_COMPANY:
|
||||
SetDParam(0, val + 1);
|
||||
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;
|
||||
|
||||
/* Set correct string for switch climate cheat */
|
||||
|
@ -282,7 +282,7 @@ static const WindowDesc _build_docks_toolbar_desc = {
|
||||
|
||||
void ShowBuildDocksToolbar()
|
||||
{
|
||||
if (!IsValidCompanyID(_current_company)) return;
|
||||
if (!IsValidCompanyID(_local_company)) return;
|
||||
|
||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
|
||||
|
@ -417,7 +417,7 @@ public:
|
||||
|
||||
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;
|
||||
new BuildIndustryWindow();
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ void HandleOnEditText(const char *str)
|
||||
switch (_rename_what) {
|
||||
#ifdef ENABLE_NETWORK
|
||||
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));
|
||||
|
||||
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);
|
||||
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;
|
||||
(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
|
||||
(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
|
||||
|
@ -833,7 +833,7 @@ void ShowBuildRailToolbar(RailType railtype, int button)
|
||||
{
|
||||
BuildRailToolbarWindow *w;
|
||||
|
||||
if (!IsValidCompanyID(_current_company)) return;
|
||||
if (!IsValidCompanyID(_local_company)) return;
|
||||
if (!ValParamRailtype(railtype)) return;
|
||||
|
||||
// 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)
|
||||
{
|
||||
if (!IsValidCompanyID(_current_company)) return;
|
||||
if (!IsValidCompanyID(_local_company)) return;
|
||||
_cur_roadtype = roadtype;
|
||||
|
||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||
|
@ -952,16 +952,16 @@ struct StationViewWindow : public Window {
|
||||
|
||||
case SVW_PLANES: { // Show a list of scheduled aircraft to this station
|
||||
const Station *st = GetStation(this->window_number);
|
||||
/* Since oilrigs have no owners, show the scheduled aircraft of current company */
|
||||
Owner owner = (st->owner == OWNER_NONE) ? _current_company : st->owner;
|
||||
/* Since oilrigs have no owners, show the scheduled aircraft of local company */
|
||||
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
||||
ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)this->window_number);
|
||||
break;
|
||||
}
|
||||
|
||||
case SVW_SHIPS: { // Show a list of scheduled ships to this station
|
||||
const Station *st = GetStation(this->window_number);
|
||||
/* Since oilrigs/bouys have no owners, show the scheduled ships of current company */
|
||||
Owner owner = (st->owner == OWNER_NONE) ? _current_company : st->owner;
|
||||
/* Since oilrigs/bouys have no owners, show the scheduled ships of local company */
|
||||
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
||||
ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number);
|
||||
break;
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ static const WindowDesc _terraform_desc = {
|
||||
|
||||
void ShowTerraformToolbar(Window *link)
|
||||
{
|
||||
if (!IsValidCompanyID(_current_company)) return;
|
||||
if (!IsValidCompanyID(_local_company)) return;
|
||||
|
||||
Window *w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
|
||||
if (link == NULL) return;
|
||||
|
@ -529,7 +529,7 @@ static void MenuClickLeague(int index)
|
||||
static void ToolbarIndustryClick(Window *w)
|
||||
{
|
||||
/* 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)
|
||||
@ -1035,7 +1035,7 @@ struct MainToolbarWindow : Window {
|
||||
/* If spectator, disable all construction buttons
|
||||
* ie : Build road, rail, ships, airports and landscaping
|
||||
* 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 */
|
||||
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()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -180,6 +180,6 @@ static const WindowDesc _build_trees_desc = {
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -1786,7 +1786,7 @@ bool CanBuildVehicleInfrastructure(VehicleType 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;
|
||||
|
||||
UnitID max;
|
||||
|
Loading…
Reference in New Issue
Block a user