(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
authortruelight
Tue, 28 Dec 2004 09:24:02 +0000
changeset 813 640a517dc129
parent 812 65ecc321b3db
child 814 217997e8aae4
(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
main_gui.c
misc_cmd.c
--- 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;