(svn r1418) -Feature: [1098254] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)

pull/155/head
darkvater 20 years ago
parent c1757a0c5f
commit c2b59b2089

@ -1533,13 +1533,18 @@ int32 CmdBuyShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdSellShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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;

@ -1046,6 +1046,7 @@ STR_CONFIG_PATCHES_SERVINT_SHIPS_DISABLED :{LTBLUE}Default service interval fo
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

@ -506,14 +506,19 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
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);

@ -898,6 +898,7 @@ const SettingDesc patch_settings[] = {
{"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},

@ -685,6 +685,7 @@ static const PatchEntry _patches_economy[] = {
{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[] = {

@ -172,6 +172,7 @@ typedef struct Patches {
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

Loading…
Cancel
Save