X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Frenders%2Fopengl%2Fr_map.pas;h=e04405795493fda75933b7d211339e470ec91ad2;hb=fea837e895e2571f8ce3b5291f635d325e8c3756;hp=d58daee2ce5516c22223cf3573623312d73f24ec;hpb=d0374fd617aa1703e4aa31b8ff3b0f5228636021;p=d2df-sdl.git diff --git a/src/game/renders/opengl/r_map.pas b/src/game/renders/opengl/r_map.pas index d58daee..e044057 100644 --- a/src/game/renders/opengl/r_map.pas +++ b/src/game/renders/opengl/r_map.pas @@ -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; @@ -174,36 +182,37 @@ implementation ShotAnim: array [0..WEAPON_LAST] of record name: AnsiString; + x, y: Integer; w, h: Integer; anim: TAnimInfo; end = ( - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 0 KASTET - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 1 SAW - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 2 PISTOL - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 3 SHOTGUN1 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 4 SHOTGUN2 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 5 CHAINGUN - (name: 'BROCKET'; w: 64; h: 32; anim: (loop: true; delay: 1; frames: 1; back: false)), // 6 ROCKETLAUNCHER - (name: 'BPLASMA'; w: 16; h: 16; anim: (loop: true; delay: 5; frames: 2; back: false)), // 7 PLASMA - (name: 'BBFG'; w: 64; h: 64; anim: (loop: true; delay: 6; frames: 2; back: false)), // 8 BFG - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 9 SUPERPULEMET - (name: 'FLAME'; w: 32; h: 32; anim: (loop: true; delay: 6; frames: 0{11}; back: false)), // 10 FLAMETHROWER - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 11 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 12 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 13 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 14 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 15 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 16 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 17 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 18 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 19 - (name: ''; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 20 ZOMPY_PISTOL - (name: 'BIMPFIRE'; w: 16; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 21 IMP_FIRE - (name: 'BBSPFIRE'; w: 16; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 22 BSP_FIRE - (name: 'BCACOFIRE'; w: 16; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 23 CACO_FIRE - (name: 'BBARONFIRE'; w: 64; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 24 BARON_FIRE - (name: 'BMANCUBFIRE'; w: 64; h: 32; anim: (loop: true; delay: 4; frames: 2; back: false)), // 25 MANCUB_FIRE - (name: 'BSKELFIRE'; w: 64; h: 64; anim: (loop: true; delay: 5; frames: 2; back: false)) // 26 SKEL_FIRE + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 0 KASTET + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 1 SAW + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 2 PISTOL + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 3 SHOTGUN1 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 4 SHOTGUN2 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 5 CHAINGUN + (name: 'BROCKET'; x: 0; y: 0; w: 64; h: 32; anim: (loop: true; delay: 1; frames: 1; back: false)), // 6 ROCKETLAUNCHER + (name: 'BPLASMA'; x: 0; y: 0; w: 16; h: 16; anim: (loop: true; delay: 5; frames: 2; back: false)), // 7 PLASMA + (name: 'BBFG'; x: 6; y: 7; w: 64; h: 64; anim: (loop: true; delay: 6; frames: 2; back: false)), // 8 BFG + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 9 SUPERPULEMET + (name: 'FLAME'; x: 0; y: 0; w: 32; h: 32; anim: (loop: true; delay: 6; frames: 0{11}; back: false)), // 10 FLAMETHROWER + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 11 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 12 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 13 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 14 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 15 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 16 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 17 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 18 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 19 + (name: ''; x: 0; y: 0; w: 0; h: 0; anim: (loop: true; delay: 0; frames: 0; back: false)), // 20 ZOMPY_PISTOL + (name: 'BIMPFIRE'; x: 0; y: 0; w: 16; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 21 IMP_FIRE + (name: 'BBSPFIRE'; x: 0; y: 0; w: 16; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 22 BSP_FIRE + (name: 'BCACOFIRE'; x: 0; y: 0; w: 16; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 23 CACO_FIRE + (name: 'BBARONFIRE'; x: 0; y: 0; w: 64; h: 16; anim: (loop: true; delay: 4; frames: 2; back: false)), // 24 BARON_FIRE + (name: 'BMANCUBFIRE'; x: 0; y: 0; w: 64; h: 32; anim: (loop: true; delay: 4; frames: 2; back: false)), // 25 MANCUB_FIRE + (name: 'BSKELFIRE'; x: 0; y: 0; w: 64; h: 64; anim: (loop: true; delay: 5; frames: 2; back: false)) // 26 SKEL_FIRE ); {$IFDEF ENABLE_SHELLS} @@ -462,7 +471,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,18 +684,23 @@ 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 + if DebugFrames and not (gGameSettings.GameType in [GT_SERVER, GT_CLIENT]) then begin r_Draw_Rect( xx + it.obj.rect.x, // it.obj.x + it.obj.rect.x, @@ -703,7 +717,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 +742,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; @@ -768,7 +781,7 @@ implementation da := mon.GameDirection; r_Draw_MultiTextureRepeat(t, mon.DirAnim[a, da], false, xx + dx, yy + dy, t.width, t.height, flip, 255, 255, 255, 255, false); end; - if DebugFrames then + if DebugFrames and not (gGameSettings.GameType in [GT_SERVER, GT_CLIENT]) then begin r_Draw_Rect( xx + mon.obj.rect.x, // mon.obj.x + mon.obj.rect.x, @@ -778,7 +791,7 @@ implementation 0, 255, 0, 255 ); end; - if DebugHealth and mon.alive then + if DebugHealth and mon.alive and not (gGameSettings.GameType in [GT_SERVER, GT_CLIENT]) then begin r_Common_DrawText( IntToStr(mon.MonsterHealth), @@ -796,6 +809,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]; @@ -966,6 +984,46 @@ implementation end; end; + procedure r_Map_DrawAim (p: TPlayer); + var x0, y0, x1, y1, a, len: Integer; + begin + ASSERT(p <> nil); + r_Common_GetPlayerPos(p, x0, y0); + x0 := x0 + WEAPONPOINT[p.Direction].X + IfThen(p.Direction = TDirection.D_LEFT, 7, -7); + y0 := y0 + WEAPONPOINT[p.Direction].Y; + a := p.Angle_; + len := 1024; + case p.CurrWeap of + WEAPON_KASTET: len := 12; + WEAPON_SAW: len := 24; + WEAPON_PISTOL, WEAPON_SHOTGUN1, WEAPON_SHOTGUN2, WEAPON_CHAINGUN, + WEAPON_ROCKETLAUNCHER, WEAPON_SUPERPULEMET, WEAPON_FLAMETHROWER: + begin + if a = ANGLE_RIGHTUP then DEC(a, 2); + if a = ANGLE_RIGHTDOWN then INC(a, 4); + if a = ANGLE_LEFTUP then INC(a, 2); + if a = ANGLE_LEFTDOWN then DEC(a, 4); + end; + WEAPON_PLASMA: + begin + if a = ANGLE_RIGHTUP then DEC(a, 1); + if a = ANGLE_RIGHTDOWN then INC(a, 3); + if a = ANGLE_LEFTUP then INC(a, 1); + if a = ANGLE_LEFTDOWN then DEC(a, 3); + end; + WEAPON_BFG: + begin + if a = ANGLE_RIGHTUP then DEC(a, 1); + if a = ANGLE_RIGHTDOWN then INC(a, 2); + if a = ANGLE_LEFTUP then INC(a, 1); + if a = ANGLE_LEFTDOWN then DEC(a, 2); + end; + end; + x1 := x0 + Trunc(Cos(-DegToRad(a)) * len); + y1 := y0 + Trunc(Sin(-DegToRad(a)) * len); + r_Draw_Line(x0, y0, x1, y1, 255, 0, 0, 158); + end; + procedure r_Map_DrawPlayer (p, drawed: TPlayer); var x, y, ax, ay, w, h: Integer; b, flip: Boolean; t: TGLMultiTexture; tex: TGLTexture; alpha: Byte; count, frame: LongInt; begin @@ -1023,7 +1081,7 @@ implementation r_Map_DrawPlayerModel(p.Model, x, y, alpha); end; - if DebugFrames then + if DebugFrames and not (gGameSettings.GameType in [GT_SERVER, GT_CLIENT]) then begin r_Draw_Rect( x + p.obj.rect.x, // p.obj.x + p.obj.rect.x, @@ -1034,7 +1092,7 @@ implementation ); end; - if DebugHealth and p.alive then + if DebugHealth and p.alive and not (gGameSettings.GameType in [GT_SERVER, GT_CLIENT]) then begin r_Common_DrawText( IntToStr(p.health) + '/' + IntToStr(p.armor), @@ -1050,7 +1108,8 @@ implementation if (p.FMegaRulez[MR_INVIS] <= gTime) or ((drawed <> nil) and ((p = drawed) or (p.Team = drawed.Team) and (gGameSettings.GameMode <> GM_DM))) then r_Map_DrawTalkBubble(p); - // TODO draw aim + if gAimLine and p.alive and ((p = gPlayer1) or (p = gPlayer2)) then + r_Map_DrawAim(p); end; procedure r_Map_DrawPlayers (x, y, w, h: Integer; player: TPlayer); @@ -1073,6 +1132,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 @@ -1279,8 +1343,8 @@ implementation pY := Shots[i].Obj.Rect.Height div 2; g_Anim_GetFrameByTime(ShotAnim[typ].anim, (gTime - Shots[i].time) DIV GAME_TICK, count, frame); tex := t.GetTexture(frame); - r_Draw_TextureRepeatRotate(tex, xx, yy, tex.width, tex.height, false, 255, 255, 255, 255, false, pX, pY, a); - if DebugFrames then + r_Draw_TextureRepeatRotate(tex, xx - ShotAnim[typ].x, yy - ShotAnim[typ].y, tex.width, tex.height, false, 255, 255, 255, 255, false, pX, pY, a); + if DebugFrames and not (gGameSettings.GameType in [GT_SERVER, GT_CLIENT]) then begin r_Draw_Rect( xx + Shots[i].obj.rect.x, // Shots[i].obj.x + Shots[i].obj.rect.x, @@ -1311,7 +1375,7 @@ implementation t := FlagTextures[i]; tex := t.GetTexture(FlagFrame); r_Draw_TextureRepeat(tex, xx + dx, yy + 1, tex.width, tex.height, flip, 255, 255, 255, 255, false); - if DebugFrames then + if DebugFrames and not (gGameSettings.GameType in [GT_SERVER, GT_CLIENT]) then begin r_Draw_Rect( xx + gFlags[i].obj.rect.x, // gFlags[i].obj.x + gFlags[i].obj.rect.x, @@ -1647,6 +1711,7 @@ implementation if gDrawBackGround and (SkyTexture <> nil) then begin r_Map_CalcSkyParallax(cx, cy, w, h, SkyTexture.width, SkyTexture.height, gMapInfo.Width, gMapInfo.Height, sx, sy, sw, sh); + r_Draw_SetFilter(SkyTexture, gTextureFilter); r_Draw_Texture(SkyTexture, sx, sy, sw, sh, false, 255, 255, 255, 255, false); end; @@ -1712,6 +1777,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, '', '');