DEADSOFTWARE

gl: fix typo
[d2df-sdl.git] / src / game / renders / opengl / r_map.pas
index d58daee2ce5516c22223cf3573623312d73f24ec..407431e8a4e7517cfb9e759924c10c85afd4b41d 100644 (file)
@@ -42,6 +42,7 @@ interface
   procedure r_Map_Update;
 
   procedure r_Map_Draw (x, y, w, h, camx, camy: Integer; player: TPlayer; out acx, acy: Integer);
+  procedure r_Map_GetSpectatorLimits (out x0, y0, x1, y1: Integer);
 
 implementation
 
@@ -69,6 +70,11 @@ implementation
   ;
 
   const
+    MAXGIBW = 32;
+    MAXGIBH = 32;
+
+    MAXMONW = 256;
+    MAXMONH = 128;
     MTABLE: array [0..MONSTER_MAN] of record
       w, h: Integer;
     end = (
@@ -97,6 +103,8 @@ implementation
     VILEFIRE_DX = 32;
     VILEFIRE_DY = 128;
 
+    MAXITEMW = 64;
+    MAXITEMH = 64;
     ItemAnim: array [0..ITEM_LAST] of record
       name: AnsiString;
       w, h: Integer;
@@ -462,7 +470,7 @@ implementation
       end;
     {$ENDIF}
     // --------- shots --------- //
-    r_Common_SetLoading('Weapon splahses', WEAPON_LAST + 1);
+    r_Common_SetLoading('Weapon splashes', WEAPON_LAST + 1);
     for i := 0 to WEAPON_LAST do
     begin
       if ShotAnim[i].anim.frames > 0 then
@@ -675,15 +683,20 @@ implementation
   begin
     if ggItems <> nil then
     begin
+      (* hack: prevent visual disappearance *)
+      x := x - MAXITEMW;
+      y := y - MAXITEMH;
+      w := w + MAXITEMW*2;
+      h := h + MAXITEMH*2;
       for i := 0 to High(ggItems) do
       begin
         it := @ggItems[i];
         if it.used and it.alive and (it.dropped = drop) and (it.ItemType > ITEM_NONE) and (it.ItemType <= ITEM_LAST) then
         begin
-          t := Items[it.ItemType].tex;
-          if g_Collide(it.obj.x, it.obj.y, t.width, t.height, x, y, w, h) then
+          r_Common_GetObjectPos(it.obj, xx, yy);
+          if g_Collide(xx + it.obj.rect.x, yy + it.obj.rect.y, it.obj.rect.width, it.obj.rect.height, x, y, w, h) then
           begin
-            r_Common_GetObjectPos(it.obj, xx, yy);
+            t := Items[it.ItemType].tex;
             tex := t.GetTexture(Items[it.ItemType].frame);
             r_Draw_TextureRepeat(tex, xx, yy, tex.width, tex.height, false, 255, 255, 255, 255, false);
             if DebugFrames then
@@ -703,7 +716,7 @@ implementation
   end;
 
   function r_Map_GetMonsterTexture (m, a: Integer; d: TDirection; out t: TGLMultiTexture; out dx, dy: Integer; out flip: Boolean): Boolean;
-    // var c: Integer;
+    var w: Integer;
   begin
     t := nil; dx := 0; dy := 0; flip := false;
     result := MonTextures[m, a, d] <> nil;
@@ -728,9 +741,8 @@ implementation
       end;
       if flip then
       begin
-//        c := (MONSTERTABLE[MonsterType].Rect.X - dx) + MONSTERTABLE[MonsterType].Rect.Width;
-//        dx := MTABLE[m].width - c - MONSTERTABLE[MonsterType].Rect.X;
-        dx := -dx;
+        if (m = MONSTER_SOUL) and (a = ANIM_DIE) then w := 64 else w := 0;
+        dx := -dx - w;
       end;
     end;
   end;
@@ -796,6 +808,11 @@ implementation
   begin
     if gMonsters <> nil then
     begin
+      (* hack: prevent visual disappearance *)
+      x := x - MAXMONW;
+      y := y - MAXMONH;
+      w := w + MAXMONW*2;
+      h := h + MAXMONH*2;
       for i := 0 to High(gMonsters) do
       begin
         m := gMonsters[i];
@@ -1073,6 +1090,11 @@ implementation
   begin
     if gGibs <> nil then
     begin
+      (* hack: prevent visual disappearance *)
+      x := x - MAXGIBW;
+      y := y - MAXGIBH;
+      w := w + MAXGIBW*2;
+      h := h + MAXGIBH*2;
       for i := 0 to High(gGibs) do
       begin
         if gGibs[i].alive then
@@ -1712,6 +1734,34 @@ implementation
     g_Anim_GetFrameByTime(FlagAnim, tick, count, FlagFrame);
   end;
 
+  procedure r_Map_GetSpectatorLimits (out x0, y0, x1, y1: Integer);
+    var w, h: Integer;
+  begin
+    w := Round(gScreenWidth / g_dbg_scale);
+    if gMapInfo.Width > w then
+    begin
+      x0 := w div 2;
+      x1 := gMapInfo.Width - w div 2 - 1;
+    end
+    else
+    begin
+      x0 := gMapInfo.Width div 2;
+      x1 := gMapInfo.Width div 2;
+    end;
+
+    h := Round(gScreenHeight / g_dbg_scale);
+    if gMapInfo.Height > h then
+    begin
+      y0 := h div 2;
+      y1 := gMapInfo.Height - h div 2 - 1;
+    end
+    else
+    begin
+      y0 := gMapInfo.Height div 2;
+      y1 := gMapInfo.Height div 2;
+    end;
+  end;
+
 initialization
   conRegVar('r_sq_draw', @UseAccel, 'accelerated spatial queries in rendering', 'accelerated rendering');
   conRegVar('r_debug_camera_scale', @DebugCameraScale, 0.0001, 1000.0, '', '');