I do believe the only thing that was *ever* wrong with camera shake was someone decided to use getRandom on something that had always been a visual effect anyway. Pretty sure WorldDx is in fact safe to modify.
authornemo
Sun, 11 Sep 2011 10:22:09 -0400
changeset 5855 74c621e12baa
parent 5854 2f52e422ce9e
child 5856 ed97138dc414
I do believe the only thing that was *ever* wrong with camera shake was someone decided to use getRandom on something that had always been a visual effect anyway. Pretty sure WorldDx is in fact safe to modify.
hedgewars/VGSHandlers.inc
hedgewars/uVisualGears.pas
hedgewars/uWorld.pas
--- a/hedgewars/VGSHandlers.inc	Sun Sep 11 16:18:49 2011 +0200
+++ b/hedgewars/VGSHandlers.inc	Sun Sep 11 10:22:09 2011 -0400
@@ -587,23 +587,15 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepBigExplosionWork(Gear: PVisualGear; Steps: Longword);
-//var maxMovement: LongInt;
+var maxMovement: LongInt;
 begin
 
 inc(Gear^.Timer, Steps);
-(*
-FIXME - This block desyncs due to the way WorldDx is important for various things network related.
-One possible solution is, instead of using WorldDx, to use straight gl/SDL calls to jitter the screen a bit.
-
-// a comment by unC0Rr: instead of changing WorldDx shake cursor coordinates, that should be safe
-// ... seems to still desync, and I tried banning when targetting too
-
 if (Gear^.Timer and 5) = 0 then
     begin
     maxMovement := max(1, 13 - ((Gear^.Timer * 15) div 250));
     ShakeCamera(maxMovement);
     end;
-*)
 
 if Gear^.Timer > 250 then DeleteVisualGear(Gear);
 end;
@@ -613,9 +605,9 @@
     gX,gY: LongInt;
     vg: PVisualGear;
 begin
-ScreenFade:= sfFromWhite;
-ScreenFadeValue:= round(60 * zoom * zoom);
-ScreenFadeSpeed:= 5;
+//ScreenFade:= sfFromWhite;
+//ScreenFadeValue:= round(60 * zoom * zoom);
+//ScreenFadeSpeed:= 5;
 gX:= round(Gear^.X);
 gY:= round(Gear^.Y);
 AddVisualGear(gX, gY, vgtSmokeRing);
--- a/hedgewars/uVisualGears.pas	Sun Sep 11 16:18:49 2011 +0200
+++ b/hedgewars/uVisualGears.pas	Sun Sep 11 10:22:09 2011 -0400
@@ -29,7 +29,7 @@
  * E.g.: background flakes, visual effects: explosion, smoke trails, etc.
  *)
 interface
-uses uConsts, uFloat, GLunit, uTypes;
+uses uConsts, uFloat, GLunit, uTypes, uWorld;
 
 procedure initModule;
 procedure freeModule;
--- a/hedgewars/uWorld.pas	Sun Sep 11 16:18:49 2011 +0200
+++ b/hedgewars/uWorld.pas	Sun Sep 11 10:22:09 2011 -0400
@@ -1315,11 +1315,11 @@
 procedure ShakeCamera(amount: LongWord);
 begin
     if isCursorVisible then exit;
-    amount:= Max(1, amount);
-    //WorldDx:= WorldDx - amount + LongInt(getRandom(1 + amount * 2));
-    //WorldDy:= WorldDy - amount + LongInt(getRandom(1 + amount * 2));
-    CursorPoint.X:= CursorPoint.X - amount + LongInt(getRandom(1 + amount * 2));
-    CursorPoint.Y:= CursorPoint.Y - amount + LongInt(getRandom(1 + amount * 2))
+    amount:= Max(1, round(amount*zoom/2));
+    WorldDx:= WorldDx - amount + LongInt(random(1 + amount * 2));
+    WorldDy:= WorldDy - amount + LongInt(random(1 + amount * 2));
+    //CursorPoint.X:= CursorPoint.X - amount + LongInt(random(1 + amount * 2));
+    //CursorPoint.Y:= CursorPoint.Y - amount + LongInt(random(1 + amount * 2))
 end;