--- a/hedgewars/uGearsList.pas Thu Dec 04 11:19:38 2014 -0500
+++ b/hedgewars/uGearsList.pas Thu Dec 04 20:15:03 2014 +0100
@@ -285,7 +285,12 @@
dx := -dx
end;
State:= State or gstInvisible;
- Health:= random(vobFrameTicks);
+ // use health field to store current frameticks
+ if vobFrameTicks > 0 then
+ Health:= random(vobFrameTicks)
+ else
+ Health:= 0;
+ // use timer to store currently displayed frame index
if gear^.Timer = 0 then Timer:= random(vobFramesCount);
Damage:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) * 8;
Tint:= ((ExplosionBorderColor and RMask) shl RShift) or
--- a/hedgewars/uVariables.pas Thu Dec 04 11:19:38 2014 -0500
+++ b/hedgewars/uVariables.pas Thu Dec 04 20:15:03 2014 +0100
@@ -2617,13 +2617,13 @@
dirtyLandTexCount:= 0;
- vobFrameTicks:= 99999;
+ vobFrameTicks:= 0;
vobFramesCount:= 4;
vobCount:= 0;
vobVelocity:= 10;
vobFallSpeed:= 100;
- vobSDFrameTicks:= 99999;
+ vobSDFrameTicks:= 0;
vobSDFramesCount:= 4;
vobSDCount:= 30 * cScreenSpace div LAND_WIDTH;
vobSDVelocity:= 15;
--- a/hedgewars/uVisualGearsHandlers.pas Thu Dec 04 11:19:38 2014 -0500
+++ b/hedgewars/uVisualGearsHandlers.pas Thu Dec 04 20:15:03 2014 +0100
@@ -80,35 +80,41 @@
procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
var sign: real;
moved: boolean;
+ vfc, vft: LongWord;
begin
if vobCount = 0 then exit;
sign:= 1;
with Gear^ do
begin
- if vobFrameTicks < 1000000 then
+
+ X:= X + (cWindSpeedf * 400 + dX + tdX) * Steps * Gear^.Scale;
+
+ if SuddenDeathDmg then
+ begin
+ Y:= Y + (dY + tdY + cGravityf * vobSDFallSpeed) * Steps * Gear^.Scale;
+ vfc:= vobSDFramesCount;
+ vft:= vobSDFrameTicks;
+ end
+ else
+ begin
+ Y:= Y + (dY + tdY + cGravityf * vobFallSpeed) * Steps * Gear^.Scale;
+ vfc:= vobFramesCount;
+ vft:= vobFrameTicks;
+ end;
+
+ if vft > 0 then
begin
inc(FrameTicks, Steps);
- if not SuddenDeathDmg and (FrameTicks > vobFrameTicks) then
+ if FrameTicks > vft then
begin
- dec(FrameTicks, vobFrameTicks);
+ dec(FrameTicks, vft);
inc(Frame);
- if Frame = vobFramesCount then
- Frame:= 0
- end
- else if SuddenDeathDmg and (FrameTicks > vobSDFrameTicks) then
- begin
- dec(FrameTicks, vobSDFrameTicks);
- inc(Frame);
- if Frame = vobSDFramesCount then
+ if Frame = vfc then
Frame:= 0
end;
end;
- X:= X + (cWindSpeedf * 400 + dX + tdX) * Steps * Gear^.Scale;
- if SuddenDeathDmg then
- Y:= Y + (dY + tdY + cGravityf * vobSDFallSpeed) * Steps * Gear^.Scale
- else
- Y:= Y + (dY + tdY + cGravityf * vobFallSpeed) * Steps * Gear^.Scale;
+
Angle:= Angle + dAngle * Steps;
if Angle > 360 then
Angle:= Angle - 360
--- a/hedgewars/uVisualGearsList.pas Thu Dec 04 11:19:38 2014 -0500
+++ b/hedgewars/uVisualGearsList.pas Thu Dec 04 20:15:03 2014 +0100
@@ -102,12 +102,14 @@
Scale:= 1.0;
if SuddenDeathDmg then
begin
- FrameTicks:= random(vobSDFrameTicks);
+ if vobSDFrameTicks > 0 then
+ FrameTicks:= random(vobSDFrameTicks);
Frame:= random(vobSDFramesCount);
end
else
begin
- FrameTicks:= random(vobFrameTicks);
+ if vobFrameTicks > 0 then
+ FrameTicks:= random(vobFrameTicks);
Frame:= random(vobFramesCount);
end;
Angle:= random(360);
--- a/project_files/hwc/rtl/system.c Thu Dec 04 11:19:38 2014 -0500
+++ b/project_files/hwc/rtl/system.c Thu Dec 04 20:15:03 2014 +0100
@@ -296,6 +296,11 @@
}
LongInt fpcrtl_random(LongInt l) {
+ // random(0) is undefined in docs but effectively returns 0 in free pascal
+ if (l == 0) {
+ printf("WARNING: random(0) called!");
+ return 0;
+ }
return (LongInt) (rand() / (double) RAND_MAX * l);
}
--- a/share/hedgewars/Data/Themes/Beach/theme.cfg Thu Dec 04 11:19:38 2014 -0500
+++ b/share/hedgewars/Data/Themes/Beach/theme.cfg Thu Dec 04 20:15:03 2014 +0100
@@ -15,4 +15,4 @@
spray = SprayObject29, 3
spray = SprayObject36, 2
spray = SprayObject4, 1
-flakes = 20, 1, 99999999, 0, 10
+flakes = 20, 1, 0, 0, 10
--- a/share/hedgewars/Data/Themes/Castle/theme.cfg Thu Dec 04 11:19:38 2014 -0500
+++ b/share/hedgewars/Data/Themes/Castle/theme.cfg Thu Dec 04 20:15:03 2014 +0100
@@ -9,4 +9,4 @@
object = Shield, 3, 0, 165, 163, 2, 1, 0, 0, 163, 140
object = Sword, 3, 240, 22, 17, 43, 1, 8, 21, 227, 80
object = Axe, 3, 25, 195, 90, 65, 1, 40, 5, 195, 175
-flakes = 25, 3, 99999999, 0, 750
+flakes = 25, 3, 0, 0, 750
--- a/share/hedgewars/Data/Themes/Cave/theme.cfg Thu Dec 04 11:19:38 2014 -0500
+++ b/share/hedgewars/Data/Themes/Cave/theme.cfg Thu Dec 04 20:15:03 2014 +0100
@@ -13,4 +13,4 @@
spray = CrystalSpray01, 2
spray = CrystalSpray02, 3
spray = CrystalSpray03, 4
-flakes = 8, 2, 99999999, 0, 1700
+flakes = 8, 2, 0, 0, 1700
--- a/share/hedgewars/Data/Themes/Christmas/theme.cfg Thu Dec 04 11:19:38 2014 -0500
+++ b/share/hedgewars/Data/Themes/Christmas/theme.cfg Thu Dec 04 20:15:03 2014 +0100
@@ -13,6 +13,6 @@
object = Snowman, 1, 38, 283, 119, 14, 1, 38, 21, 124, 216
spray = holly, 4
spray = holly2, 4
-flakes = 100, 3, 99999999, 100, 300
+flakes = 100, 3, 0, 100, 300
ice = yes
snow = yes
--- a/share/hedgewars/Data/Themes/Fruit/theme.cfg Thu Dec 04 11:19:38 2014 -0500
+++ b/share/hedgewars/Data/Themes/Fruit/theme.cfg Thu Dec 04 20:15:03 2014 +0100
@@ -10,4 +10,4 @@
object = Watermelon, 1, 87, 272, 77, 10, 1, 21, 2, 242, 219
object = Banana1, 1, 152, 191, 37, 24, 1, 2, 1, 163, 174
object = Banana2, 1, 1, 190, 37, 24, 1, 22, 0, 163, 174
-flakes = 20, 3, 999999999, 100, 260
+flakes = 20, 3, 0, 100, 260
--- a/share/hedgewars/Data/Themes/Golf/theme.cfg Thu Dec 04 11:19:38 2014 -0500
+++ b/share/hedgewars/Data/Themes/Golf/theme.cfg Thu Dec 04 20:15:03 2014 +0100
@@ -19,5 +19,5 @@
object = Ball, 3, 10, 0, 6, 16, 1, 0, 0, 6, 16
object = Bag, 1, 65, 0, 129, 44, 1, 0, 71, 234, 81
spray = Balldirt, 5
-flakes = 55, 40, 99999999, 30, 200
+flakes = 55, 40, 0, 30, 200
--- a/share/hedgewars/Data/Themes/Nature/theme.cfg Thu Dec 04 11:19:38 2014 -0500
+++ b/share/hedgewars/Data/Themes/Nature/theme.cfg Thu Dec 04 20:15:03 2014 +0100
@@ -16,4 +16,4 @@
object = snail, 3, 51, 94, 52, 3, 1, 0, 0, 135, 87
object = mushroom, 3, 14, 77, 24, 2, 1, 0, 0, 76, 73
object = mushroom2, 3, 24, 78, 48, 7, 2, 0, 0, 80, 36, 15, 38, 57, 30
-flakes = 55, 40, 99999999, 30, 200
+flakes = 55, 40, 0, 30, 200
--- a/share/hedgewars/Data/Themes/Snow/theme.cfg Thu Dec 04 11:19:38 2014 -0500
+++ b/share/hedgewars/Data/Themes/Snow/theme.cfg Thu Dec 04 20:15:03 2014 +0100
@@ -9,6 +9,6 @@
object = plant2, 3, 0, 85, 25, 25, 2, 0, 0, 170, 70, 50, 70, 120, 40
object = plant3, 3, 26, 0, 48, 1, 1, 25, 15, 50, 60
object = plant4, 3, 45, 4, 1, 45, 1, 20, 45, 20, 60
-flakes = 100, 3, 99999999, 100, 300
+flakes = 100, 3, 0, 100, 300
ice = yes
snow = yes
--- a/share/hedgewars/Data/Themes/Stage/theme.cfg Thu Dec 04 11:19:38 2014 -0500
+++ b/share/hedgewars/Data/Themes/Stage/theme.cfg Thu Dec 04 20:15:03 2014 +0100
@@ -15,4 +15,4 @@
spray = poster2, 2
spray = poster3, 2
spray = poster4, 2
-flakes = 100, 3, 99999999, 10, 20
+flakes = 100, 3, 0, 10, 20