DEADSOFTWARE

no more tree traces (i hope); still not working right
[d2df-sdl.git] / src / game / g_gfx.pas
index 4be9437ab278b002c609235a6865c85c3fadab02..c84ba47eda80a1e2c6097a134a78d5ba0929a212 100644 (file)
@@ -83,6 +83,8 @@ type
     State:              Byte;
     ParticleType:       Byte;
     offsetX, offsetY:   ShortInt;
+    // for bubbles
+    liquidTopY: Integer; // don't float higher than this
   end;
 
   TOnceAnim = record
@@ -316,7 +318,8 @@ begin
 end;
 
 
-procedure CorrectOffsets(id: Integer);
+{
+procedure CorrectOffsets(id: Integer); inline;
 var
   part: PParticle;
 begin
@@ -328,6 +331,7 @@ begin
   // check for left wall
   if isBlockedAt(part.X-1, part.Y) then part.offsetX := 1;
 end;
+}
 
 
 procedure g_GFX_SparkVel (fX, fY: Integer; Count: Word; VX, VY: Integer; DevX, DevY: Byte);
@@ -375,7 +379,7 @@ begin
       LiveTime := 30+Random(60);
       ParticleType := PARTICLE_SPARK;
 
-      CorrectOffsets(CurrentParticle);
+      {CorrectOffsets(CurrentParticle);}
     end;
 
     if CurrentParticle+2 > MaxParticles then
@@ -472,7 +476,7 @@ begin
       LiveTime := 120+Random(40);
       ParticleType := PARTICLE_BLOOD;
 
-      CorrectOffsets(CurrentParticle);
+      {CorrectOffsets(CurrentParticle);}
     end;
 
     if CurrentParticle >= MaxParticles-1 then
@@ -534,7 +538,7 @@ begin
       LiveTime := 30+Random(60);
       ParticleType := PARTICLE_SPARK;
 
-      CorrectOffsets(CurrentParticle);
+      {CorrectOffsets(CurrentParticle);}
     end;
 
     if CurrentParticle+2 > MaxParticles then
@@ -616,7 +620,7 @@ begin
       LiveTime := 60+Random(60);
       ParticleType := PARTICLE_WATER;
 
-      CorrectOffsets(CurrentParticle);
+      {CorrectOffsets(CurrentParticle);}
     end;
 
     if CurrentParticle+2 > MaxParticles then
@@ -701,7 +705,7 @@ begin
       LiveTime := 60+Random(60);
       ParticleType := PARTICLE_WATER;
 
-      CorrectOffsets(CurrentParticle);
+      {CorrectOffsets(CurrentParticle);}
     end;
 
     if CurrentParticle+2 > MaxParticles then
@@ -711,12 +715,13 @@ begin
   end;
 end;
 
+
 procedure g_GFX_Bubbles(fX, fY: Integer; Count: Word; DevX, DevY: Byte);
 var
   a: Integer;
   DevX1, DevX2,
   DevY1, DevY2: Byte;
-  l: Integer;
+  l, liquidx: Integer;
 begin
   l := Length(Particles);
   if l = 0 then
@@ -740,8 +745,15 @@ begin
          (Y >= gMapInfo.Height) or (Y <= 0) then
         Continue;
 
+      (*
+      // don't spawn bubbles outside of the liquid
       if not isLiquidAt(X, Y) {ByteBool(gCollideMap[Y, X] and MARK_LIQUID)} then
         Continue;
+      *)
+
+      // trace liquid, so we'll know where it ends; do it in 8px steps for speed
+      // tracer will return `false` if we started outside of the liquid
+      if not g_Map_TraceLiquid(X, Y, 0, -8, liquidx, liquidTopY) then continue;
 
       VelX := 0;
       VelY := -1-Random;
@@ -758,7 +770,7 @@ begin
       LiveTime := 65535;
       ParticleType := PARTICLE_BUBBLES;
 
-      CorrectOffsets(CurrentParticle);
+      {CorrectOffsets(CurrentParticle);}
     end;
 
     if CurrentParticle+2 > MaxParticles then
@@ -1306,7 +1318,7 @@ begin
             end;
           end; // case
 
-          CorrectOffsets(a);
+          {CorrectOffsets(a);}
         end; // with
       end; // if
     end; // for