Mercurial > hg > openttd
changeset 930:2c7548aaea56 draft
(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
author | darkvater <darkvater@openttd.org> |
---|---|
date | Fri, 07 Jan 2005 23:59:59 +0000 |
parents | 52cd2f236b44 |
children | 692bbab17557 |
files | economy.c lang/english.txt player_gui.c settings.c settings_gui.c variables.h |
diffstat | 6 files changed, 26 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/economy.c +++ b/economy.c @@ -1533,13 +1533,18 @@ SET_EXPENSES_TYPE(EXPENSES_OTHER); p = DEREF_PLAYER(p1); + /* Check if buying shares is allowed (protection against modified clients */ + if (!_patches.allow_shares) + return CMD_ERROR; + /* Those lines are here for network-protection (clients can be slow) */ if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) return 0; + /* We can not buy out a real player in networking */ if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) return 0; - + cost = CalculateCompanyValue(p) >> 2; if (flags & DC_EXEC) { b = p->share_owners; @@ -1567,6 +1572,10 @@ SET_EXPENSES_TYPE(EXPENSES_OTHER); p = DEREF_PLAYER(p1); + /* Check if selling shares is allowed (protection against modified clients */ + if (!_patches.allow_shares) + return CMD_ERROR; + /* Those lines are here for network-protection (clients can be slow) */ if (GetAmountOwnedBy(p, _current_player) == 0) return 0;
--- a/lang/english.txt +++ b/lang/english.txt @@ -1046,6 +1046,7 @@ STR_CONFIG_PATCHES_COLORED_NEWS_DATE :{LTBLUE}Coloured news appears in: {ORANGE}{STRING} STR_CONFIG_PATCHES_STARTING_DATE :{LTBLUE}Starting date: {ORANGE}{STRING} STR_CONFIG_PATCHES_SMOOTH_ECONOMY :{LTBLUE}Enable smooth economy (more, smaller changes) +STR_CONFIG_PATCHES_ALLOW_SHARES :{LTBLUE}Allow buying shares from other companies STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY :{LTBLUE}When dragging, place signals every: {ORANGE}{STRING} tile(s) STR_CONFIG_PATCHES_TOOLBAR_POS :{LTBLUE}Position of main toolbar: {ORANGE}{STRING} STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT :Left
--- a/player_gui.c +++ b/player_gui.c @@ -506,14 +506,19 @@ if (!IsWindowOfPrototype(w, _other_player_company_widgets)) { AssignWidgetToWindow(w, (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets); - if (!_networking) w->hidden_state |= (1 << 11); // hide company-password widget + if (!_networking) SETBIT(w->hidden_state, 11); // hide company-password widget } else { - if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) dis |= 1 << 9; - // Also disable the buy button if 25% is not-owned by someone - // and the player is not an AI - if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) dis |= 1 << 9; - if (GetAmountOwnedBy(p, _local_player) == 0) dis |= 1 << 10; - if (_local_player == OWNER_SPECTATOR) dis |= (1 << 9) | (1 << 10); + if (_patches.allow_shares) { /* shares are allowed */ + if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) SETBIT(dis, 9); + + /* We cannot buy out real players in a network game */ + if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) SETBIT(dis, 9); + + if (GetAmountOwnedBy(p, _local_player) == 0) SETBIT(dis, 10); + + if (_local_player == OWNER_SPECTATOR) dis |= (1 << 9) | (1 << 10); + } else /* shares are not allowed, disable buy/sell buttons */ + dis |= (1 << 9) | (1 << 10); } SetDParam(0, p->name_1);
--- a/settings.c +++ b/settings.c @@ -898,6 +898,7 @@ {"serviceathelipad", SDT_BOOL, (void*)true, &_patches.serviceathelipad, NULL}, {"smooth_economy", SDT_BOOL, (void*)true, &_patches.smooth_economy, NULL}, + {"allow_shares", SDT_BOOL, (void*)true, &_patches.allow_shares, NULL}, {"dist_local_authority",SDT_UINT8, (void*)20, &_patches.dist_local_authority, NULL}, {"wait_oneway_signal", SDT_UINT8, (void*)15, &_patches.wait_oneway_signal, NULL},
--- a/settings_gui.c +++ b/settings_gui.c @@ -685,6 +685,7 @@ {PE_INT32, PF_NOCOMMA, STR_CONFIG_PATCHES_STARTING_DATE, "starting_date", &_patches.starting_date, 1920,2100, 1, NULL}, {PE_BOOL, 0, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, "smooth_economy", &_patches.smooth_economy, 0, 0, 0, NULL}, + {PE_BOOL, 0, STR_CONFIG_PATCHES_ALLOW_SHARES, "allow_shares", &_patches.allow_shares, 0, 0, 0, NULL}, }; static const PatchEntry _patches_ai[] = {
--- a/variables.h +++ b/variables.h @@ -172,6 +172,7 @@ bool auto_euro; // automatically switch to euro in 2002 bool serviceathelipad; // service helicopters at helipads automatically (no need to send to depot) bool smooth_economy; // smooth economy + bool allow_shares; // allow the buying/selling of shares byte dist_local_authority; // distance for town local authority, default 20 byte wait_oneway_signal; //waitingtime in days before a oneway signal