Fix bug with cursor coordinates sent via net (or demo/save file)
authorunc0rr
Sat, 28 Nov 2009 15:22:28 +0000
changeset 2645 89aa2aa89066
parent 2644 52b7c4776af9
child 2646 6a1185633872
Fix bug with cursor coordinates sent via net (or demo/save file)
hedgewars/CCHandlers.inc
hedgewars/uIO.pas
--- a/hedgewars/CCHandlers.inc	Sat Nov 28 02:46:15 2009 +0000
+++ b/hedgewars/CCHandlers.inc	Sat Nov 28 15:22:28 2009 +0000
@@ -518,6 +518,11 @@
 				TargetPoint.Y:= cScreenHeight - CursorPoint.Y - WorldDy;
 				end;
 			SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
+			end
+		else
+			begin
+			TargetPoint.X:= putX;
+			TargetPoint.Y:= putY
 			end;
 		{$IFDEF DEBUGFILE}AddFilelog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));{$ENDIF}
 		State:= State and not gstHHChooseTarget;
--- a/hedgewars/uIO.pas	Sat Nov 28 02:46:15 2009 +0000
+++ b/hedgewars/uIO.pas	Sat Nov 28 15:22:28 2009 +0000
@@ -261,6 +261,7 @@
 procedure NetGetNextCmd;
 var tmpflag: boolean;
 	s: shortstring;
+	x16, y16: SmallInt;
 begin
 tmpflag:= true;
 
@@ -307,16 +308,16 @@
 			{$IFDEF DEBUGFILE}AddFileLog('got cmd "N": time '+inttostr(hiTicks shl 16 + headcmd^.loTime)){$ENDIF}
 			end;
 		'p': begin
-			TargetPoint.X:= SDLNet_Read16(@(headcmd^.X));
-			TargetPoint.Y:= SDLNet_Read16(@(headcmd^.Y));
-			doPut(TargetPoint.X, TargetPoint.Y, true)
+			x16:= SDLNet_Read16(@(headcmd^.X));
+			y16:= SDLNet_Read16(@(headcmd^.Y));
+			doPut(x16, y16, false)
 			end;
 		'P': begin
 			// these are equations solved for CursorPoint
 			// SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx;
 			// SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy;
-			CursorPoint.X:= SDLNet_Read16(@(headcmd^.X)) + WorldDx;
-			CursorPoint.Y:= cScreenHeight - SDLNet_Read16(@(headcmd^.Y)) - WorldDy;
+			CursorPoint.X:= SmallInt(SDLNet_Read16(@(headcmd^.X))) + WorldDx;
+			CursorPoint.Y:= cScreenHeight - SmallInt(SDLNet_Read16(@(headcmd^.Y))) - WorldDy;
 			end;
 		'w': ParseCommand('setweap ' + headcmd^.str[2], true);
 		't': ParseCommand('taunt ' + headcmd^.str[2], true);