(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
--- a/main_gui.c Mon Dec 27 18:18:44 2004 +0000
+++ b/main_gui.c Tue Dec 28 09:24:02 2004 +0000
@@ -87,6 +87,9 @@
// 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;
--- a/misc_cmd.c Mon Dec 27 18:18:44 2004 +0000
+++ b/misc_cmd.c Tue Dec 28 09:24:02 2004 +0000
@@ -285,6 +285,11 @@
{
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;