Set minimums on a few values to avoid camera zooming out past them. partly
issue #430. Might be worth defining a new constant for this.
--- a/hedgewars/GSHandlers.inc Fri Oct 26 13:50:03 2012 -0400
+++ b/hedgewars/GSHandlers.inc Fri Oct 26 14:06:42 2012 -0400
@@ -93,7 +93,10 @@
else
begin
if (gi^.State and gstMoving) = 0 then
+ begin
+ gi^.dX.isNegative:= X<gi^.X;
gi^.State := gi^.State or gstLoser;
+ end;
if d > r div 2 then
PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack)
@@ -195,8 +198,8 @@
// might need some testing/adjustments - just to avoid projectiles to fly forever (accelerated by wind/skips)
- if (hwRound(Gear^.X) < LAND_WIDTH div -2)
- or (hwRound(Gear^.X) > LAND_WIDTH * 3 div 2) then
+ if (hwRound(Gear^.X) < min(LAND_WIDTH div -2, -2048))
+ or (hwRound(Gear^.X) > max(LAND_WIDTH * 3 div 2, 6144)) then
Gear^.State := Gear^.State or gstCollision;
if Gear^.dY.isNegative then
@@ -986,8 +989,8 @@
// only extend if not under water
if hwRound(Bullet^.Y) < cWaterLine then
begin
- VGear^.dX := VGear^.dX + LAND_WIDTH * (VGear^.dX - VGear^.X);
- VGear^.dY := VGear^.dY + LAND_WIDTH * (VGear^.dY - VGear^.Y);
+ VGear^.dX := VGear^.dX + max(LAND_WIDTH,4096) * (VGear^.dX - VGear^.X);
+ VGear^.dY := VGear^.dY + max(LAND_WIDTH,4096) * (VGear^.dY - VGear^.Y);
end;
VGear^.Timer := 200;
@@ -2170,7 +2173,7 @@
if (GameTicks and $3F) = 0 then
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
- if (hwRound(Gear^.X) > (LAND_WIDTH+2048)) or (hwRound(Gear^.X) < -2048) then
+ if (hwRound(Gear^.X) > (max(LAND_WIDTH,4096)+2048)) or (hwRound(Gear^.X) < -2048) then
begin
// avoid to play forever (is this necessary?)
StopSoundChan(Gear^.SoundChannel);
@@ -2190,7 +2193,7 @@
else
begin
Gear^.Tag := -1;
- Gear^.X := int2hwFloat(LAND_WIDTH + 2048);
+ Gear^.X := int2hwFloat(max(LAND_WIDTH,4096) + 2048);
end;
Gear^.Y := int2hwFloat(topY-300);
@@ -3969,9 +3972,9 @@
end
else if (y > cWaterLine)
- or (y < -LAND_WIDTH)
- or (x > 2*LAND_WIDTH)
- or (x < -LAND_WIDTH) then
+ or (y < -max(LAND_WIDTH,4096))
+ or (x > 2*max(LAND_WIDTH,4096))
+ or (x < -max(LAND_WIDTH,4096)) then
loadNewPortalBall(Gear, true);
end;
@@ -5111,10 +5114,10 @@
X:= HHGear^.X;
Y:= HHGear^.Y
end;
- if (gX > LAND_WIDTH*2) or
- (gX < -LAND_WIDTH) or
- (gY < -LAND_HEIGHT) or
- (gY > LAND_HEIGHT+512) then
+ if (gX > max(LAND_WIDTH,4096)*2) or
+ (gX < -max(LAND_WIDTH,4096)) or
+ (gY < -max(LAND_HEIGHT,4096)) or
+ (gY > max(LAND_HEIGHT,4096)+512) then
begin
X:= HHGear^.X;
Y:= HHGear^.Y
--- a/hedgewars/uCommandHandlers.pas Fri Oct 26 13:50:03 2012 -0400
+++ b/hedgewars/uCommandHandlers.pas Fri Oct 26 14:06:42 2012 -0400
@@ -436,7 +436,8 @@
SendIPC(s)
end
else
- TryDo(CheckSum = lastTurnChecksum, 'Desync detected', true);
+ TryDo((lastTurnChecksum = 0) or (CheckSum = lastTurnChecksum), 'Desync detected', true);
+ lastTurnChecksum:= 0;
AddFileLog('Next turn: time '+inttostr(GameTicks));
end;
--- a/hedgewars/uGearsRender.pas Fri Oct 26 13:50:03 2012 -0400
+++ b/hedgewars/uGearsRender.pas Fri Oct 26 14:06:42 2012 -0400
@@ -321,8 +321,8 @@
// reached edge of land. assume infinite beam. Extend it way out past camera
if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
begin
- tx:= round(lx + ax * (LAND_WIDTH div 2));
- ty:= round(ly + ay * (LAND_WIDTH div 2));
+ tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2));
+ ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2));
end;
//if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
@@ -1086,9 +1086,9 @@
endX:= x - WorldDx;
endY:= y - WorldDy;
if Gear^.Tag < 0 then
- startX:= max(LAND_WIDTH + 1024, endX + 2048)
+ startX:= max(max(LAND_WIDTH,4096) + 1024, endX + 2048)
else
- startX:= max(-LAND_WIDTH - 1024, endX - 2048);
+ startX:= max(-max(LAND_WIDTH,4096) - 1024, endX - 2048);
startY:= endY - 256;
DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1))), startY + WorldDy + LongInt(round((endY - startY) * sqrt(1 - power((LongInt(Gear^.Timer)/2000)-1, 2)))), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
end
@@ -1097,9 +1097,9 @@
startX:= x - WorldDx;
startY:= y - WorldDy;
if Gear^.Tag > 0 then
- endX:= max(LAND_WIDTH + 1024, startX + 2048)
+ endX:= max(max(LAND_WIDTH,4096) + 1024, startX + 2048)
else
- endX:= max(-LAND_WIDTH - 1024, startX - 2048);
+ endX:= max(-max(LAND_WIDTH,4096) - 1024, startX - 2048);
endY:= startY + 256;
DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1)))) + hwRound(Gear^.dX * Gear^.Timer), startY + WorldDy + LongInt(round((endY - startY) * cos(LongInt(Gear^.Timer)/2000 * (Pi/2)) - (endY - startY))) + hwRound(Gear^.dY * Gear^.Timer), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
end;