Remove: buying/selling/owning company shares (#10709)

pull/532/head
Patric Stout 1 year ago committed by GitHub
parent 1a24016964
commit 36a0818bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -271,8 +271,6 @@ enum Commands : uint16 {
CMD_PAUSE, ///< pause the game
CMD_BUY_SHARE_IN_COMPANY, ///< buy a share from a company
CMD_SELL_SHARE_IN_COMPANY, ///< sell a share from a company
CMD_BUY_COMPANY, ///< buy a company which is bankrupt
CMD_FOUND_TOWN, ///< found a town
@ -408,7 +406,7 @@ DECLARE_ENUM_AS_BIT_SET(CommandFlags)
enum CommandType {
CMDT_LANDSCAPE_CONSTRUCTION, ///< Construction and destruction of objects on the map.
CMDT_VEHICLE_CONSTRUCTION, ///< Construction, modification (incl. refit) and destruction of vehicles.
CMDT_MONEY_MANAGEMENT, ///< Management of money, i.e. loans and shares.
CMDT_MONEY_MANAGEMENT, ///< Management of money, i.e. loans.
CMDT_VEHICLE_MANAGEMENT, ///< Stopping, starting, sending to depot, turning around, replace orders etc.
CMDT_ROUTE_MANAGEMENT, ///< Modifications to route management (orders, groups, etc).
CMDT_OTHER_MANAGEMENT, ///< Renaming stuff, changing company colours, placing signs, etc.

@ -76,8 +76,6 @@ struct CompanyProperties {
TileIndex location_of_HQ; ///< Northern tile of HQ; #INVALID_TILE when there is none.
TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company.
std::array<Owner, MAX_COMPANY_SHARE_OWNERS> share_owners; ///< Owners of the shares of the company. #INVALID_OWNER if nobody has bought them yet.
TimerGameCalendar::Year inaugurated_year; ///< Year of starting the company.
byte months_of_bankruptcy; ///< Number of months that the company is unable to pay its debts
@ -110,7 +108,7 @@ struct CompanyProperties {
CompanyProperties()
: name_2(0), name_1(0), president_name_1(0), president_name_2(0),
face(0), money(0), money_fraction(0), current_loan(0), colour(0), block_preview(0),
location_of_HQ(0), last_build_coordinate(0), share_owners(), inaugurated_year(0),
location_of_HQ(0), last_build_coordinate(0), inaugurated_year(0),
months_of_bankruptcy(0), bankrupt_asked(0), bankrupt_timeout(0), bankrupt_value(0),
terraform_limit(0), clear_limit(0), tree_limit(0), build_object_limit(0), is_ai(false), engine_renew_list(nullptr) {}
};
@ -169,7 +167,6 @@ struct Company : CompanyProperties, CompanyPool::PoolItem<&_company_pool> {
};
Money CalculateCompanyValue(const Company *c, bool including_loan = true);
Money CalculateCompanyValueExcludingShares(const Company *c, bool including_loan = true);
extern uint _cur_company_tick_index;

@ -70,7 +70,6 @@ Company::Company(uint16 name_1, bool is_ai)
this->tree_limit = (uint32)_settings_game.construction.tree_frame_burst << 16;
this->build_object_limit = (uint32)_settings_game.construction.build_object_frame_burst << 16;
std::fill(this->share_owners.begin(), this->share_owners.end(), INVALID_OWNER);
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY);
}
@ -565,8 +564,6 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY)
/* Scale the initial loan based on the inflation rounded down to the loan interval. The maximum loan has already been inflation adjusted. */
c->money = c->current_loan = std::min<int64>((INITIAL_LOAN * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL, _economy.max_loan);
std::fill(c->share_owners.begin(), c->share_owners.end(), INVALID_OWNER);
c->avail_railtypes = GetCompanyRailtypes(c->index);
c->avail_roadtypes = GetCompanyRoadTypes(c->index);
c->inaugurated_year = TimerGameCalendar::year;

@ -2229,12 +2229,6 @@ static const NWidgetPart _nested_company_widgets[] = {
EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_C_SELECT_DESC_OWNERS),
NWidget(NWID_VERTICAL), SetPIP(5, 5, 4),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_DESC_OWNERS), SetMinimalTextLines(MAX_COMPANY_SHARE_OWNERS, 0),
NWidget(NWID_SPACER), SetFill(0, 1),
EndContainer(),
EndContainer(),
/* Multi player buttons. */
NWidget(NWID_VERTICAL), SetPIP(4, 2, 4),
NWidget(NWID_SPACER), SetFill(0, 1),
@ -2264,19 +2258,9 @@ static const NWidgetPart _nested_company_widgets[] = {
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_C_PRESIDENT_NAME), SetFill(1, 0), SetDataTip(STR_COMPANY_VIEW_PRESIDENT_NAME_BUTTON, STR_COMPANY_VIEW_PRESIDENT_NAME_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_C_COMPANY_NAME), SetFill(1, 0), SetDataTip(STR_COMPANY_VIEW_COMPANY_NAME_BUTTON, STR_COMPANY_VIEW_COMPANY_NAME_TOOLTIP),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_C_BUY_SHARE), SetFill(1, 0), SetDataTip(STR_COMPANY_VIEW_BUY_SHARE_BUTTON, STR_COMPANY_VIEW_BUY_SHARE_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_C_SELL_SHARE), SetFill(1, 0), SetDataTip(STR_COMPANY_VIEW_SELL_SHARE_BUTTON, STR_COMPANY_VIEW_SELL_SHARE_TOOLTIP),
EndContainer(),
EndContainer(),
};
int GetAmountOwnedBy(const Company *c, Owner owner)
{
auto share_owned_by = [owner](auto share_owner) { return share_owner == owner; };
return std::count_if(c->share_owners.begin(), c->share_owners.end(), share_owned_by);
}
/** Strings for the company vehicle counts */
static const StringID _company_view_vehicle_count_strings[] = {
STR_COMPANY_VIEW_TRAINS, STR_COMPANY_VIEW_ROAD_VEHICLES, STR_COMPANY_VIEW_SHIPS, STR_COMPANY_VIEW_AIRCRAFT
@ -2302,10 +2286,6 @@ struct CompanyWindow : Window
/* Display planes of the #WID_C_SELECT_RELOCATE selection widget. */
CWP_RELOCATE_SHOW = 0, ///< Show the relocate HQ button.
CWP_RELOCATE_HIDE, ///< Hide the relocate HQ button.
/* Display planes of the #WID_C_SELECT_BUTTONS selection widget. */
CWP_BUTTONS_LOCAL = 0, ///< Buttons of the local company.
CWP_BUTTONS_OTHER, ///< Buttons of the other companies.
};
CompanyWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
@ -2324,7 +2304,7 @@ struct CompanyWindow : Window
bool reinit = false;
/* Button bar selection. */
int plane = local ? CWP_BUTTONS_LOCAL : CWP_BUTTONS_OTHER;
int plane = local ? 0 : SZSP_NONE;
NWidgetStacked *wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_BUTTONS);
if (plane != wi->shown_plane) {
wi->SetDisplayedPlane(plane);
@ -2349,16 +2329,6 @@ struct CompanyWindow : Window
wi->SetDisplayedPlane(plane);
reinit = true;
}
/* Owners of company */
auto invalid_owner = [](auto owner) { return owner == INVALID_COMPANY; };
plane = std::all_of(c->share_owners.begin(), c->share_owners.end(), invalid_owner) ? SZSP_HORIZONTAL : 0;
wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_DESC_OWNERS);
if (plane != wi->shown_plane) {
wi->SetDisplayedPlane(plane);
reinit = true;
}
/* Enable/disable 'Give money' button. */
plane = ((local || _local_company == COMPANY_SPECTATOR || !_settings_game.economy.give_money) ? SZSP_NONE : 0);
wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_GIVE_MONEY);
@ -2426,16 +2396,6 @@ struct CompanyWindow : Window
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_NONE).width);
break;
case WID_C_DESC_OWNERS: {
for (const Company *c2 : Company::Iterate()) {
SetDParamMaxValue(0, 75);
SetDParam(1, c2->index);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_SHARES_OWNED_BY).width);
}
break;
}
case WID_C_VIEW_HQ:
case WID_C_BUILD_HQ:
case WID_C_RELOCATE_HQ:
@ -2551,22 +2511,6 @@ struct CompanyWindow : Window
DrawInfrastructureCountsWidget(r, c);
break;
case WID_C_DESC_OWNERS: {
uint y = r.top;
for (const Company *c2 : Company::Iterate()) {
uint amt = GetAmountOwnedBy(c, c2->index);
if (amt != 0) {
SetDParam(0, amt * 25);
SetDParam(1, c2->index);
DrawString(r.left, r.right, y, STR_COMPANY_VIEW_SHARES_OWNED_BY);
y += FONT_HEIGHT_NORMAL;
}
}
break;
}
case WID_C_HAS_PASSWORD:
if (_networking && NetworkCompanyIsPassworded(c->index)) {
DrawSprite(SPR_LOCK, PAL_NONE, r.left, r.top);
@ -2658,14 +2602,6 @@ struct CompanyWindow : Window
ShowQueryString(STR_EMPTY, STR_COMPANY_VIEW_GIVE_MONEY_QUERY_CAPTION, 30, this, CS_NUMERAL, QSF_NONE);
break;
case WID_C_BUY_SHARE:
Command<CMD_BUY_SHARE_IN_COMPANY>::Post(STR_ERROR_CAN_T_BUY_25_SHARE_IN_THIS, (CompanyID)this->window_number);
break;
case WID_C_SELL_SHARE:
Command<CMD_SELL_SHARE_IN_COMPANY>::Post(STR_ERROR_CAN_T_SELL_25_SHARE_IN, (CompanyID)this->window_number);
break;
case WID_C_COMPANY_PASSWORD:
if (this->window_number == _local_company) ShowNetworkCompanyPasswordWindow(this);
break;
@ -2734,36 +2670,6 @@ struct CompanyWindow : Window
break;
}
}
/**
* Some data on this window has become invalid.
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (this->window_number == _local_company) return;
if (_settings_game.economy.allow_shares) { // Shares are allowed
const Company *c = Company::Get(this->window_number);
/* If all shares are owned by someone (none by nobody), disable buy button */
this->SetWidgetDisabledState(WID_C_BUY_SHARE, GetAmountOwnedBy(c, INVALID_OWNER) == 0 ||
/* Only 25% left to buy. If the company is human, disable buying it up.. TODO issues! */
(GetAmountOwnedBy(c, INVALID_OWNER) == 1 && !c->is_ai) ||
/* Spectators cannot do anything of course */
_local_company == COMPANY_SPECTATOR);
/* If the company doesn't own any shares, disable sell button */
this->SetWidgetDisabledState(WID_C_SELL_SHARE, (GetAmountOwnedBy(c, _local_company) == 0) ||
/* Spectators cannot do anything of course */
_local_company == COMPANY_SPECTATOR);
} else { // Shares are not allowed, disable buy/sell buttons
this->DisableWidget(WID_C_BUY_SHARE);
this->DisableWidget(WID_C_SELL_SHARE);
}
}
};
static WindowDesc _company_desc(

@ -40,7 +40,6 @@ static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS = 32; ///< The maximum length
static const uint MAX_LENGTH_COMPANY_NAME_CHARS = 32; ///< The maximum length of a company name in characters including '\0'
static const uint MAX_HISTORY_QUARTERS = 24; ///< The maximum number of quarters kept as performance's history
static const uint MAX_COMPANY_SHARE_OWNERS = 4; ///< The maximum number of shares of a company that can be owned by another company.
static const uint MIN_COMPETITORS_INTERVAL = 0; ///< The minimum interval (in minutes) between competitors.
static const uint MAX_COMPETITORS_INTERVAL = 500; ///< The maximum interval (in minutes) between competitors.

@ -103,11 +103,9 @@ Economy _economy;
Prices _price;
static PriceMultipliers _price_base_multiplier;
extern int GetAmountOwnedBy(const Company *c, Owner owner);
/**
* Calculate the value of the company. That is the value of all
* assets (vehicles, stations, shares) and money minus the loan,
* assets (vehicles, stations) and money minus the loan,
* except when including_loan is \c false which is useful when
* we want to calculate the value for bankruptcy.
* @param c the company to get the value of.
@ -115,19 +113,6 @@ extern int GetAmountOwnedBy(const Company *c, Owner owner);
* @return the value of the company.
*/
Money CalculateCompanyValue(const Company *c, bool including_loan)
{
Money owned_shares_value = 0;
for (const Company *co : Company::Iterate()) {
int shares_owned = GetAmountOwnedBy(co, c->index);
if (shares_owned > 0) owned_shares_value += (CalculateCompanyValueExcludingShares(co) / 4) * shares_owned;
}
return owned_shares_value + CalculateCompanyValueExcludingShares(c);
}
Money CalculateCompanyValueExcludingShares(const Company *c, bool including_loan)
{
Owner owner = c->index;
@ -323,39 +308,6 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
assert(old_owner != new_owner);
/* See if the old_owner had shares in other companies */
for (const Company *c : Company::Iterate()) {
for (auto share_owner : c->share_owners) {
if (share_owner == old_owner) {
/* Sell its shares */
CommandCost res = Command<CMD_SELL_SHARE_IN_COMPANY>::Do(DC_EXEC | DC_BANKRUPT, c->index);
/* Because we are in a DoCommand, we can't just execute another one and
* expect the money to be removed. We need to do it ourself! */
SubtractMoneyFromCompany(res);
}
}
}
/* Sell all the shares that people have on this company */
Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
Company *c = Company::Get(old_owner);
for (auto &share_owner : c->share_owners) {
if (share_owner == INVALID_OWNER) continue;
if (c->bankrupt_value == 0 && share_owner == new_owner) {
/* You are the one buying the company; so don't sell the shares back to you. */
share_owner = INVALID_OWNER;
} else {
cur_company2.Change(share_owner);
/* Sell the shares */
CommandCost res = Command<CMD_SELL_SHARE_IN_COMPANY>::Do(DC_EXEC | DC_BANKRUPT, old_owner);
/* Because we are in a DoCommand, we can't just execute another one and
* expect the money to be removed. We need to do it ourself! */
SubtractMoneyFromCompany(res);
}
}
cur_company2.Restore();
/* Temporarily increase the company's money, to be sure that
* removing their property doesn't fail because of lack of money.
* Not too drastically though, because it could overflow */
@ -2031,85 +1983,6 @@ static void DoAcquireCompany(Company *c)
delete c;
}
/**
* Acquire shares in an opposing company.
* @param flags type of operation
* @param target_company company to buy the shares from
* @return the cost of this operation or an error
*/
CommandCost CmdBuyShareInCompany(DoCommandFlag flags, CompanyID target_company)
{
CommandCost cost(EXPENSES_OTHER);
Company *c = Company::GetIfValid(target_company);
/* Check if buying shares is allowed (protection against modified clients)
* Cannot buy own shares */
if (c == nullptr || !_settings_game.economy.allow_shares || _current_company == target_company) return CMD_ERROR;
/* Protect new companies from hostile takeovers */
if (TimerGameCalendar::year - c->inaugurated_year < _settings_game.economy.min_years_for_shares) return_cmd_error(STR_ERROR_PROTECTED);
/* Those lines are here for network-protection (clients can be slow) */
if (GetAmountOwnedBy(c, INVALID_OWNER) == 0) return cost;
if (GetAmountOwnedBy(c, INVALID_OWNER) == 1) {
if (!c->is_ai) return cost; // We can not buy out a real company (temporarily). TODO: well, enable it obviously.
if (GetAmountOwnedBy(c, _current_company) == 3 && !MayCompanyTakeOver(_current_company, target_company)) return_cmd_error(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME);
}
cost.AddCost(CalculateCompanyValue(c) >> 2);
if (flags & DC_EXEC) {
auto unowned_share = std::find(c->share_owners.begin(), c->share_owners.end(), INVALID_OWNER);
assert(unowned_share != c->share_owners.end()); // share owners is guaranteed to contain at least one INVALID_OWNER, i.e. unowned share
*unowned_share = _current_company;
auto current_company_owns_share = [](auto share_owner) { return share_owner == _current_company; };
if (std::all_of(c->share_owners.begin(), c->share_owners.end(), current_company_owns_share)) {
c->bankrupt_value = 0;
DoAcquireCompany(c);
}
InvalidateWindowData(WC_COMPANY, target_company);
CompanyAdminUpdate(c);
}
return cost;
}
/**
* Sell shares in an opposing company.
* @param flags type of operation
* @param target_company company to sell the shares from
* @return the cost of this operation or an error
*/
CommandCost CmdSellShareInCompany(DoCommandFlag flags, CompanyID target_company)
{
Company *c = Company::GetIfValid(target_company);
/* Cannot sell own shares */
if (c == nullptr || _current_company == target_company) return CMD_ERROR;
/* Check if selling shares is allowed (protection against modified clients).
* However, we must sell shares of companies being closed down. */
if (!_settings_game.economy.allow_shares && !(flags & DC_BANKRUPT)) return CMD_ERROR;
/* Those lines are here for network-protection (clients can be slow) */
if (GetAmountOwnedBy(c, _current_company) == 0) return CommandCost();
/* adjust it a little to make it less profitable to sell and buy */
Money cost = CalculateCompanyValue(c) >> 2;
cost = -(cost - (cost >> 7));
if (flags & DC_EXEC) {
auto our_owner = std::find(c->share_owners.begin(), c->share_owners.end(), _current_company);
assert(our_owner != c->share_owners.end()); // share owners is guaranteed to contain at least one INVALID_OWNER
*our_owner = INVALID_OWNER;
InvalidateWindowData(WC_COMPANY, target_company);
CompanyAdminUpdate(c);
}
return CommandCost(EXPENSES_OTHER, cost);
}
/**
* Buy up another company.
* When a competing company is gone bankrupt you get the chance to purchase

@ -13,12 +13,8 @@
#include "command_type.h"
#include "company_type.h"
CommandCost CmdBuyShareInCompany(DoCommandFlag flags, CompanyID target_company);
CommandCost CmdSellShareInCompany(DoCommandFlag flags, CompanyID target_company);
CommandCost CmdBuyCompany(DoCommandFlag flags, CompanyID target_company);
DEF_CMD_TRAIT(CMD_BUY_SHARE_IN_COMPANY, CmdBuyShareInCompany, 0, CMDT_MONEY_MANAGEMENT)
DEF_CMD_TRAIT(CMD_SELL_SHARE_IN_COMPANY, CmdSellShareInCompany, 0, CMDT_MONEY_MANAGEMENT)
DEF_CMD_TRAIT(CMD_BUY_COMPANY, CmdBuyCompany, 0, CMDT_MONEY_MANAGEMENT)
#endif /* ECONOMY_CMD_H */

@ -1804,15 +1804,6 @@ STR_CONFIG_SETTING_ECONOMY_TYPE_ORIGINAL :Original
STR_CONFIG_SETTING_ECONOMY_TYPE_SMOOTH :Smooth
STR_CONFIG_SETTING_ECONOMY_TYPE_FROZEN :Frozen
STR_CONFIG_SETTING_ALLOW_SHARES :Allow buying shares from other companies: {STRING2}
STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT :When enabled, allow buying and selling of company shares. Shares will only be available for companies reaching a certain age
STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES :Minimum company age to trade shares: {STRING2}
STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_HELPTEXT :Set the minimum age of a company for others to be able to buy and sell shares from them.
STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_VALUE :{COMMA} year{P "" s}
###setting-zero-is-special
STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_NO_MIN :No minimum
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE :Percentage of leg profit to pay in feeder systems: {STRING2}
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE_HELPTEXT :Percentage of income given to the intermediate legs in feeder systems, giving more control over the income
@ -3713,7 +3704,6 @@ STR_COMPANY_VIEW_AIRCRAFT :{WHITE}{COMMA}
STR_COMPANY_VIEW_SHIPS :{WHITE}{COMMA} ship{P "" s}
STR_COMPANY_VIEW_VEHICLES_NONE :{WHITE}None
STR_COMPANY_VIEW_COMPANY_VALUE :{GOLD}Company value: {WHITE}{CURRENCY_LONG}
STR_COMPANY_VIEW_SHARES_OWNED_BY :{WHITE}({COMMA}% owned by {COMPANY})
STR_COMPANY_VIEW_INFRASTRUCTURE :{GOLD}Infrastructure:
STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL :{WHITE}{COMMA} rail piece{P "" s}
STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD :{WHITE}{COMMA} road piece{P "" s}
@ -3742,11 +3732,6 @@ STR_COMPANY_VIEW_COMPANY_NAME_TOOLTIP :{BLACK}Change t
STR_COMPANY_VIEW_PRESIDENT_NAME_BUTTON :{BLACK}Manager Name
STR_COMPANY_VIEW_PRESIDENT_NAME_TOOLTIP :{BLACK}Change the manager's name
STR_COMPANY_VIEW_BUY_SHARE_BUTTON :{BLACK}Buy 25% share in company
STR_COMPANY_VIEW_SELL_SHARE_BUTTON :{BLACK}Sell 25% share in company
STR_COMPANY_VIEW_BUY_SHARE_TOOLTIP :{BLACK}Buy 25% share in this company. Shift+Click shows estimated cost without purchasing any share
STR_COMPANY_VIEW_SELL_SHARE_TOOLTIP :{BLACK}Sell 25% share in this company. Shift+Click shows estimated income without selling any share
STR_COMPANY_VIEW_COMPANY_NAME_QUERY_CAPTION :Company Name
STR_COMPANY_VIEW_PRESIDENT_S_NAME_QUERY_CAPTION :Manager's Name
STR_COMPANY_VIEW_GIVE_MONEY_QUERY_CAPTION :Enter the amount of money you want to give
@ -4775,9 +4760,6 @@ STR_ERROR_INSUFFICIENT_FUNDS :{WHITE}Can't gi
STR_ERROR_CAN_T_GIVE_MONEY :{WHITE}Can't give away money to this company...
STR_ERROR_CAN_T_BUY_COMPANY :{WHITE}Can't buy company...
STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS :{WHITE}Can't build company headquarters...
STR_ERROR_CAN_T_BUY_25_SHARE_IN_THIS :{WHITE}Can't buy 25% share in this company...
STR_ERROR_CAN_T_SELL_25_SHARE_IN :{WHITE}Can't sell 25% share in this company...
STR_ERROR_PROTECTED :{WHITE}This company is not old enough to trade shares yet...
# Town related errors
STR_ERROR_CAN_T_GENERATE_TOWN :{WHITE}Can't build any towns

@ -43,7 +43,7 @@ static const uint16 UDP_MTU = 1460; ///< Numbe
static const uint16 TCP_MTU = 32767; ///< Number of bytes we can pack in a single TCP packet
static const uint16 COMPAT_MTU = 1460; ///< Number of bytes we can pack in a single packet for backward compatibility
static const byte NETWORK_GAME_ADMIN_VERSION = 2; ///< What version of the admin network do we use?
static const byte NETWORK_GAME_ADMIN_VERSION = 3; ///< What version of the admin network do we use?
static const byte NETWORK_GAME_INFO_VERSION = 6; ///< What version of game-info do we use?
static const byte NETWORK_COORDINATOR_VERSION = 6; ///< What version of game-coordinator-protocol do we use?

@ -333,10 +333,6 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company
p->Send_bool (c->is_ai);
p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy
for (auto owner : c->share_owners) {
p->Send_uint8(owner);
}
this->SendPacket(p);
return NETWORK_RECV_STATUS_OKAY;
@ -360,10 +356,6 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyUpdate(const Compa
p->Send_bool (NetworkCompanyIsPassworded(c->index));
p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy
for (auto owner : c->share_owners) {
p->Send_uint8(owner);
}
this->SendPacket(p);
return NETWORK_RECV_STATUS_OKAY;

@ -1775,21 +1775,6 @@ bool AfterLoadGame()
}
}
if (IsSavegameVersionBefore(SLV_84)) {
/* Set all share owners to INVALID_COMPANY for
* 1) all inactive companies
* (when inactive companies were stored in the savegame - TTD, TTDP and some
* *really* old revisions of OTTD; else it is already set in InitializeCompanies())
* 2) shares that are owned by inactive companies or self
* (caused by cheating clients in earlier revisions) */
for (Company *c : Company::Iterate()) {
for (auto &share_owner : c->share_owners) {
if (share_owner == INVALID_COMPANY) continue;
if (!Company::IsValidID(share_owner) || share_owner == c->index) share_owner = INVALID_COMPANY;
}
}
}
/* The water class was moved/unified. */
if (IsSavegameVersionBefore(SLV_146)) {
for (auto t : Map::Iterate()) {

@ -470,8 +470,6 @@ static const SaveLoad _company_desc[] = {
SLE_CONDVAR(CompanyProperties, inaugurated_year, SLE_FILE_U8 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
SLE_CONDVAR(CompanyProperties, inaugurated_year, SLE_INT32, SLV_31, SL_MAX_VERSION),
SLE_ARR(CompanyProperties, share_owners, SLE_UINT8, 4),
SLE_CONDVAR(CompanyProperties, num_valid_stat_ent, SLE_UINT8, SL_MIN_VERSION, SLV_SAVELOAD_LIST_LENGTH),
SLE_VAR(CompanyProperties, months_of_bankruptcy, SLE_UINT8),

@ -106,7 +106,7 @@ const SaveLoadCompat _company_sl_compat[] = {
SLC_VAR("location_of_HQ"),
SLC_VAR("last_build_coordinate"),
SLC_VAR("inaugurated_year"),
SLC_VAR("share_owners"),
SLC_NULL(4, SL_MIN_VERSION, SLV_TABLE_CHUNKS),
SLC_VAR("num_valid_stat_ent"),
SLC_VAR("months_of_bankruptcy"),
SLC_VAR("bankrupt_asked"),

@ -154,8 +154,8 @@ const SaveLoadCompat _settings_sl_compat[] = {
SLC_NULL(4, SL_MIN_VERSION, SLV_105),
SLC_VAR("game_creation.ending_year"),
SLC_VAR("economy.type"),
SLC_VAR("economy.allow_shares"),
SLC_VAR("economy.min_years_for_shares"),
SLC_NULL(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS),
SLC_NULL(1, SLV_TRADING_AGE, SLV_TABLE_CHUNKS),
SLC_VAR("economy.feeder_payment_share"),
SLC_VAR("economy.town_growth_rate"),
SLC_VAR("economy.larger_towns"),

@ -950,10 +950,8 @@ static const OldChunks _company_chunk[] = {
OCL_CNULL( OC_TTD, 1 ), // Old AI
OCL_CNULL( OC_TTD, 1 ), // avail_railtypes
OCL_SVAR( OC_TILE, Company, location_of_HQ ),
OCL_SVAR( OC_TTD | OC_UINT8, Company, share_owners[0] ),
OCL_SVAR( OC_TTD | OC_UINT8, Company, share_owners[1] ),
OCL_SVAR( OC_TTD | OC_UINT8, Company, share_owners[2] ),
OCL_SVAR( OC_TTD | OC_UINT8, Company, share_owners[3] ),
OCL_NULL( 4 ), // Shares
OCL_CNULL( OC_TTD, 8 ), ///< junk at end of chunk

@ -1905,8 +1905,6 @@ static SettingsContainer &GetSettingsTree()
}
ai->Add(new SettingEntry("economy.give_money"));
ai->Add(new SettingEntry("economy.allow_shares"));
ai->Add(new SettingEntry("economy.min_years_for_shares"));
}
SettingsPage *network = main->Add(new SettingsPage(STR_CONFIG_SETTING_NETWORK));

@ -513,8 +513,6 @@ struct EconomySettings {
bool inflation; ///< disable inflation
bool bribe; ///< enable bribing the local authority
EconomyType type; ///< economy type (original/smooth/frozen)
bool allow_shares; ///< allow the buying/selling of shares
uint8 min_years_for_shares; ///< minimum age of a company for it to trade shares
uint8 feeder_payment_share; ///< percentage of leg payment to virtually pay in feeder systems
byte dist_local_authority; ///< distance for town local authority, default 20
bool exclusive_rights; ///< allow buying exclusive rights

@ -174,27 +174,6 @@ strval = STR_CONFIG_SETTING_ECONOMY_TYPE_ORIGINAL
post_cb = [](auto) { InvalidateWindowClassesData(WC_INDUSTRY_VIEW); }
cat = SC_BASIC
[SDT_BOOL]
var = economy.allow_shares
def = false
str = STR_CONFIG_SETTING_ALLOW_SHARES
strhelp = STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT
post_cb = [](auto) { InvalidateWindowClassesData(WC_COMPANY); }
[SDT_VAR]
var = economy.min_years_for_shares
type = SLE_UINT8
from = SLV_TRADING_AGE
flags = SF_GUI_0_IS_SPECIAL
def = 6
min = 0
max = 255
interval = 1
str = STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES
strhelp = STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_HELPTEXT
strval = STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_VALUE
cat = SC_EXPERT
[SDT_VAR]
var = economy.feeder_payment_share
type = SLE_UINT8

@ -26,16 +26,11 @@ enum CompanyWidgets {
WID_C_DESC_INFRASTRUCTURE, ///< Infrastructure.
WID_C_DESC_INFRASTRUCTURE_COUNTS, ///< Infrastructure count.
WID_C_SELECT_DESC_OWNERS, ///< Owners.
WID_C_DESC_OWNERS, ///< Owner in Owners.
WID_C_SELECT_BUTTONS, ///< Selection widget for the button bar.
WID_C_NEW_FACE, ///< Button to make new face.
WID_C_COLOUR_SCHEME, ///< Button to change colour scheme.
WID_C_PRESIDENT_NAME, ///< Button to change president name.
WID_C_COMPANY_NAME, ///< Button to change company name.
WID_C_BUY_SHARE, ///< Button to buy a share.
WID_C_SELL_SHARE, ///< Button to sell a share.
WID_C_SELECT_VIEW_BUILD_HQ, ///< Panel about HQ.
WID_C_VIEW_HQ, ///< Button to view the HQ.

Loading…
Cancel
Save