From 15d188d7f83e3d090ccd8f24807d55dd4dc56946 Mon Sep 17 00:00:00 2001 From: truelight Date: Tue, 28 Dec 2004 09:24:02 +0000 Subject: [PATCH] (svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money) --- main_gui.c | 3 +++ misc_cmd.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/main_gui.c b/main_gui.c index 03c4db8453..7873908702 100644 --- a/main_gui.c +++ b/main_gui.c @@ -87,6 +87,9 @@ void HandleOnEditText(WindowEvent *e) { // Give money int32 money = atoi(e->edittext.str) / GetCurrentCurrencyRate(); char msg[100]; + + money = clamp(money, 0, 0xFFFFFFFF); // Clamp between 4 billion and 0 + // Give 'id' the money, and substract it from ourself if (!DoCommandP(0, money, id, NULL, CMD_GIVE_MONEY)) break; diff --git a/misc_cmd.c b/misc_cmd.c index defba53ea5..1ea3ffeef3 100644 --- a/misc_cmd.c +++ b/misc_cmd.c @@ -285,6 +285,11 @@ int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2) { SET_EXPENSES_TYPE(EXPENSES_OTHER); + p1 = clamp(p1, 0, 0xFFFFFFFF); // Clamp between 4 billion and 0 + + if (p1 == 0) + return CMD_ERROR; + if (flags & DC_EXEC) { // Add money to player byte old_cp = _current_player;