Check gold before buying from natives.

This commit is contained in:
Mike Pope 2020-01-13 14:27:52 +10:30
parent a9e4b55a7c
commit 666809041a
2 changed files with 5 additions and 1 deletions

View File

@ -3987,7 +3987,8 @@ public final class InGameController extends FreeColClientHolder {
nt.setItem(nti);
}
TradeBuyAction tba = getGUI().getBuyChoice(unit, is,
nti.getGoods(), nti.getPrice(), true);
nti.getGoods(), nti.getPrice(),
unit.getOwner().checkGold(nti.getPrice()));
if (tba == TradeBuyAction.BUY) {
askServer().nativeTrade(NativeTradeAction.BUY, nt);
return;

View File

@ -3118,6 +3118,9 @@ public final class InGameController extends Controller {
item.goodsMatcher()) == null) {
return serverPlayer.clientError("Item missing for "
+ action + ": " + nt);
} else if (!serverPlayer.checkGold(item.getPrice())) {
return serverPlayer.clientError("Player can not afford item: "
+ nt);
}
nt.setItem(item);
cs.add(See.only(otherPlayer),