equal
deleted
inserted
replaced
1800 CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1800 CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1801 { |
1801 { |
1802 Player *p; |
1802 Player *p; |
1803 CommandCost cost; |
1803 CommandCost cost; |
1804 |
1804 |
1805 /* Check if buying shares is allowed (protection against modified clients */ |
1805 /* Check if buying shares is allowed (protection against modified clients) */ |
1806 if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares) return CMD_ERROR; |
1806 /* Cannot buy own shares */ |
|
1807 if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR; |
|
1808 |
|
1809 p = GetPlayer((PlayerID)p1); |
|
1810 |
|
1811 /* Cannot buy shares of non-existent nor bankrupted company */ |
|
1812 if (!p->is_active) return CMD_ERROR; |
1807 |
1813 |
1808 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
1814 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
1809 p = GetPlayer((PlayerID)p1); |
|
1810 |
1815 |
1811 /* Protect new companies from hostile takeovers */ |
1816 /* Protect new companies from hostile takeovers */ |
1812 if (_cur_year - p->inaugurated_year < 6) return_cmd_error(STR_7080_PROTECTED); |
1817 if (_cur_year - p->inaugurated_year < 6) return_cmd_error(STR_7080_PROTECTED); |
1813 |
1818 |
1814 /* Those lines are here for network-protection (clients can be slow) */ |
1819 /* Those lines are here for network-protection (clients can be slow) */ |
1846 CommandCost CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1851 CommandCost CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1847 { |
1852 { |
1848 Player *p; |
1853 Player *p; |
1849 Money cost; |
1854 Money cost; |
1850 |
1855 |
1851 /* Check if buying shares is allowed (protection against modified clients */ |
1856 /* Check if selling shares is allowed (protection against modified clients) */ |
1852 if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares) return CMD_ERROR; |
1857 /* Cannot sell own shares */ |
|
1858 if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR; |
|
1859 |
|
1860 p = GetPlayer((PlayerID)p1); |
|
1861 |
|
1862 /* Cannot sell shares of non-existent nor bankrupted company */ |
|
1863 if (!p->is_active) return CMD_ERROR; |
1853 |
1864 |
1854 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
1865 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
1855 p = GetPlayer((PlayerID)p1); |
|
1856 |
1866 |
1857 /* Those lines are here for network-protection (clients can be slow) */ |
1867 /* Those lines are here for network-protection (clients can be slow) */ |
1858 if (GetAmountOwnedBy(p, _current_player) == 0) return CommandCost(); |
1868 if (GetAmountOwnedBy(p, _current_player) == 0) return CommandCost(); |
1859 |
1869 |
1860 /* adjust it a little to make it less profitable to sell and buy */ |
1870 /* adjust it a little to make it less profitable to sell and buy */ |