X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_game.pas;h=e3d9b7bb2bed0c13288230a0e9be989c17656068;hb=c7a5223f1e2520ab13b480b937af1e208201de15;hp=b89986206c82070ba81c5474530ab0bd96fffad8;hpb=910c7e1b07e907561ba67d61b53bb49dd9f175e1;p=d2df-sdl.git diff --git a/src/game/g_game.pas b/src/game/g_game.pas index b899862..e3d9b7b 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -240,6 +240,7 @@ var gPlayer2: TPlayer = nil; gPlayerDrawn: TPlayer = nil; gTime: LongWord; + gLerpFactor: Single = 1.0; gSwitchGameMode: Byte = GM_DM; gHearPoint1, gHearPoint2: THearPoint; gSoundEffectsDF: Boolean = False; @@ -2161,6 +2162,13 @@ begin end; end; + // these are in separate PreUpdate functions because they can interact during Update() + // we don't care that much about corpses and gibs + g_Player_PreUpdate(); + g_Monsters_PreUpdate(); + g_Items_PreUpdate(); + g_Weapon_PreUpdate(); + // Îáíîâëÿåì âñå îñòàëüíîå: g_Map_Update(); g_Items_Update(); @@ -3621,7 +3629,7 @@ end; procedure DrawPlayer(p: TPlayer); var - px, py, a, b, c, d, i: Integer; + px, py, a, b, c, d, i, fX, fY: Integer; //R: TRect; begin if (p = nil) or (p.FDummy) then @@ -3639,8 +3647,9 @@ begin glPushMatrix(); - px := p.GameX + PLAYER_RECT_CX; - py := p.GameY + PLAYER_RECT_CY+p.Obj.slopeUpLeft; + p.Obj.lerp(gLerpFactor, fX, fY); + px := fX + PLAYER_RECT_CX; + py := fY + PLAYER_RECT_CY+nlerp(p.SlopeOld, p.Obj.slopeUpLeft, gLerpFactor); if (g_dbg_scale = 1.0) and (not g_dbg_ignore_bounds) then begin @@ -3697,7 +3706,7 @@ begin p.IncCam := nclamp(p.IncCam, min(0, -120 - i), 0); end; - sY := sY - p.IncCam; + sY := sY - nlerp(p.IncCamOld, p.IncCam, gLerpFactor); if (not g_dbg_ignore_bounds) then begin @@ -3829,6 +3838,9 @@ begin FPSTime := Time; end; + e_SetRendertarget(True); + e_SetViewPort(0, 0, gScreenWidth, gScreenHeight); + if gGameOn or (gState = STATE_FOLD) then begin if (gPlayer1 <> nil) and (gPlayer2 <> nil) then @@ -4159,10 +4171,20 @@ begin if gGameOn then drawProfilers(); + // TODO: draw this after the FBO and remap mouse click coordinates + {$IFDEF ENABLE_HOLMES} g_Holmes_DrawUI(); {$ENDIF} + // blit framebuffer to screen + + e_SetRendertarget(False); + e_SetViewPort(0, 0, gWinSizeX, gWinSizeY); + e_BlitFramebuffer(gWinSizeX, gWinSizeY); + + // draw the overlay stuff on top of it + g_Touch_Draw; end; @@ -4251,6 +4273,10 @@ begin if ((not gGameOn) and (gState <> STATE_INTERCUSTOM)) or (not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT])) then Exit; + + if (gGameSettings.MaxLives > 0) and (gLMSRespawn = LMS_RESPAWN_NONE) then + Exit; + if gPlayer1 = nil then begin if g_Game_IsClient then @@ -4394,6 +4420,11 @@ begin gGameSettings.Options := gGameSettings.Options + GAME_OPTION_BOTVSMONSTER; gSwitchGameMode := GM_SINGLE; + gLMSRespawn := LMS_RESPAWN_NONE; + gLMSRespawnTime := 0; + gSpectLatchPID1 := 0; + gSpectLatchPID2 := 0; + g_Game_ExecuteEvent('ongamestart'); // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ: @@ -4473,6 +4504,11 @@ begin gAimLine := False; gShowMap := False; + gLMSRespawn := LMS_RESPAWN_NONE; + gLMSRespawnTime := 0; + gSpectLatchPID1 := 0; + gSpectLatchPID2 := 0; + g_Game_ExecuteEvent('ongamestart'); // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ: @@ -4572,6 +4608,11 @@ begin gAimLine := False; gShowMap := False; + gLMSRespawn := LMS_RESPAWN_NONE; + gLMSRespawnTime := 0; + gSpectLatchPID1 := 0; + gSpectLatchPID2 := 0; + g_Game_ExecuteEvent('ongamestart'); // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà @@ -5199,12 +5240,14 @@ begin else if gPlayers[i].Team = TEAM_BLUE then Inc(nb) end; - if (n < 2) or ((gGameSettings.GameMode = GM_TDM) and ((nr = 0) or (nb = 0))) then + if (n < 1) or ((gGameSettings.GameMode = GM_TDM) and ((nr = 0) or (nb = 0))) then begin // wait a second until the fuckers finally decide to join gLMSRespawn := LMS_RESPAWN_WARMUP; - gLMSRespawnTime := gTime + gGameSettings.WarmupTime; + gLMSRespawnTime := gTime + gGameSettings.WarmupTime*1000; gLMSSoftSpawn := NoMapRestart; + if g_Game_IsNet then + MH_SEND_GameEvent(NET_EV_LMS_WARMUP, gLMSRespawnTime - gTime); Exit; end; @@ -5494,6 +5537,12 @@ begin if g_Game_IsServer then begin gGameSettings.WarmupTime := gsWarmupTime; + // extend warmup if it's already going + if gLMSRespawn = LMS_RESPAWN_WARMUP then + begin + gLMSRespawnTime := gTime + gsWarmupTime * 1000; + if g_Game_IsNet then MH_SEND_GameEvent(NET_EV_LMS_WARMUP, gLMSRespawnTime - gTime); + end; if g_Game_IsNet then MH_SEND_GameSettings; end; end; @@ -7198,7 +7247,6 @@ begin end; 'r_reset': begin - sys_EnableVSync(gVSync); gRC_Width := Max(1, gRC_Width); gRC_Height := Max(1, gRC_Height); gBPP := Max(1, gBPP); @@ -7206,6 +7254,19 @@ begin e_LogWriteln('resolution changed') else e_LogWriteln('resolution not changed'); + sys_EnableVSync(gVSync); + end; + 'r_maxfps': + begin + if Length(p) = 2 then + begin + gMaxFPS := StrToIntDef(p[1], gMaxFPS); + if gMaxFPS > 0 then + gFrameTime := 1000 div gMaxFPS + else + gFrameTime := 0; + end; + e_LogWritefln('r_maxfps %d', [gMaxFPS]); end; 'g_language': begin