misc_cmd.c
changeset 543 e3b43338096b
parent 534 17ab2f22ff74
child 813 90d6adb8d4ad
--- a/misc_cmd.c	Sat Dec 04 15:02:45 2004 +0000
+++ b/misc_cmd.c	Sat Dec 04 17:54:56 2004 +0000
@@ -8,6 +8,7 @@
 #include "window.h"
 #include "saveload.h"
 #include "economy.h"
+#include "network.h"
 
 /* p1 = player
    p2 = face
@@ -124,7 +125,7 @@
 	StringID str,old_str;
 	Player *p;
 
-	str = AllocateName((byte*)_decode_parameters, 4);
+	str = AllocateNameUnique((byte*)_decode_parameters, 4);
 	if (str == 0)
 		return CMD_ERROR;
 
@@ -146,7 +147,7 @@
 	StringID str,old_str;
 	Player *p;
 
-	str = AllocateName((byte*)_decode_parameters, 4);
+	str = AllocateNameUnique((byte*)_decode_parameters, 4);
 	if (str == 0)
 		return CMD_ERROR;
 
@@ -228,7 +229,7 @@
 	SignStruct *ss;
 
 	if (_decode_parameters[0] != 0 && !p2) {
-		str = AllocateName((byte*)_decode_parameters, 0);
+		str = AllocateNameUnique((byte*)_decode_parameters, 0);
 		if (str == 0)
 			return CMD_ERROR;
 
@@ -280,6 +281,22 @@
 	return (int32)p1;
 }
 
+int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+{
+	SET_EXPENSES_TYPE(EXPENSES_OTHER);
+
+	if (flags & DC_EXEC) {
+		// Add money to player
+		byte old_cp = _current_player;
+		_current_player = p2;
+		SubtractMoneyFromPlayer(-(int32)p1);
+		_current_player = old_cp;
+	}
+
+	// Subtract money from local-player
+	return (int32)p1;
+}
+
 int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
 	if (flags & DC_EXEC) {
@@ -289,6 +306,9 @@
 		} else {
 			_opt_mod_ptr->diff_level = p2;
 		}
+		// If we are a network-client, update the difficult setting (if it is open)
+		if (_networking && !_network_server && FindWindowById(WC_GAME_OPTIONS, 0) != NULL)
+			memcpy(&_opt_mod_temp, _opt_mod_ptr, sizeof(GameOptions));
 		InvalidateWindow(WC_GAME_OPTIONS, 0);
 	}
 	return 0;