X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_game.pas;h=d7b9b2d020e1d2a2d12e4550da90fa192526ea12;hb=656407d4bcc9419011375f19ad756d9ab7254f89;hp=ff94b2860bfff29e190216ace14f71de42feffa8;hpb=a070ca5f8845641942cbd04fa53e11305c981c04;p=d2df-sdl.git diff --git a/src/game/g_game.pas b/src/game/g_game.pas index ff94b28..d7b9b2d 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -1,4 +1,4 @@ - (* Copyright (C) Doom 2D: Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -312,12 +312,9 @@ var gRC_FullScreen, gRC_Maximized: Boolean; gLanguageChange: Boolean = False; gDebugMode: Boolean = False; - g_debug_Sounds: Boolean = False; - g_debug_Frames: Boolean = False; g_debug_WinMsgs: Boolean = False; g_debug_MonsterOff: Boolean = False; g_debug_BotAIOff: Byte = 0; - g_debug_HealthBar: Boolean = False; g_Debug_Player: Boolean = False; gCoopMonstersKilled: Word = 0; gCoopSecretsFound: Word = 0; @@ -1031,12 +1028,9 @@ end; procedure ClearDebugCvars(); begin - g_debug_Sounds := False; - g_debug_Frames := False; g_debug_WinMsgs := False; g_debug_MonsterOff := False; g_debug_BotAIOff := 0; - g_debug_HealthBar := False; g_Debug_Player := False; end; @@ -1826,6 +1820,8 @@ procedure g_Game_Update(); var reliableUpdate: Boolean; + rSpectX0, rSpectY0: Integer; + rSpectX1, rSpectY1: Integer; begin g_ResetDynlights(); framePool.reset(); @@ -2102,7 +2098,15 @@ begin // process weapon switch queue end; // if server - // Наблюдатель + // Spectator + + {$IFDEF ENABLE_RENDER} + r_Render_GetSpectatorLimits(rSpectX0, rSpectY0, rSpectX1, rSpectY1); + {$ELSE} + rSpectX0 := 0; rSpectY0 := 0; + rSpectX1 := gMapInfo.Width - 1; rSpectY1 := gMapInfo.Height - 1; + {$ENDIF} + if (gPlayer1 = nil) and (gPlayer2 = nil) and (not gConsoleShow) and (not gChatShow) {$IFDEF ENABLE_MENU} @@ -2126,14 +2130,10 @@ begin if (gSpectMode = SPECT_MAPVIEW) and (not gSpectAuto) then begin - if gPlayerAction[0, ACTION_MOVELEFT] then - gSpectX := Max(gSpectX - gSpectStep, 0); - if gPlayerAction[0, ACTION_MOVERIGHT] then - gSpectX := Min(gSpectX + gSpectStep, gMapInfo.Width - gScreenWidth); - if gPlayerAction[0, ACTION_LOOKUP] then - gSpectY := Max(gSpectY - gSpectStep, 0); - if gPlayerAction[0, ACTION_LOOKDOWN] then - gSpectY := Min(gSpectY + gSpectStep, gMapInfo.Height - gScreenHeight); + if gPlayerAction[0, ACTION_MOVELEFT] then gSpectX := gSpectX - gSpectStep; + if gPlayerAction[0, ACTION_MOVERIGHT] then gSpectX := gSpectX + gSpectStep; + if gPlayerAction[0, ACTION_LOOKUP] then gSpectY := gSpectY - gSpectStep; + if gPlayerAction[0, ACTION_LOOKDOWN] then gSpectY := gSpectY + gSpectStep; if gWeaponAction[0, WP_PREV] then begin // decrease step @@ -2218,12 +2218,12 @@ begin begin if gSpectMode = SPECT_MAPVIEW then begin - i := Min(Max(gSpectX + gSpectAutoStepX, 0), gMapInfo.Width - gScreenWidth); + i := Min(Max(gSpectX + gSpectAutoStepX, rSpectX0), rSpectX1); if i = gSpectX then gSpectAutoNext := gTime else gSpectX := i; - i := Min(Max(gSpectY + gSpectAutoStepY, 0), gMapInfo.Height - gScreenHeight); + i := Min(Max(gSpectY + gSpectAutoStepY, rSpectY0), rSpectY1); if i = gSpectY then gSpectAutoNext := gTime else @@ -2237,15 +2237,15 @@ begin case gSpectMode of SPECT_MAPVIEW: begin - gSpectX := Random(gMapInfo.Width - gScreenWidth); - gSpectY := Random(gMapInfo.Height - gScreenHeight); + gSpectX := rSpectX0 + Random(rSpectX1 - rSpectX0); + gSpectY := rSpectY0 + Random(rSpectY1 - rSpectY0); gSpectAutoStepX := Random(9) - 4; gSpectAutoStepY := Random(9) - 4; - if ((gSpectX < 800) and (gSpectAutoStepX < 0)) or - ((gSpectX > gMapInfo.Width - gScreenWidth - 800) and (gSpectAutoStepX > 0)) then + if ((gSpectX < rSpectX0) and (gSpectAutoStepX < 0)) or + ((gSpectX > rSpectX1) and (gSpectAutoStepX > 0)) then gSpectAutoStepX := gSpectAutoStepX * -1; - if ((gSpectY < 800) and (gSpectAutoStepY < 0)) or - ((gSpectY > gMapInfo.Height - gScreenHeight - 800) and (gSpectAutoStepY > 0)) then + if ((gSpectY < rSpectY0) and (gSpectAutoStepY < 0)) or + ((gSpectY > rSpectY1) and (gSpectAutoStepY > 0)) then gSpectAutoStepY := gSpectAutoStepY * -1; end; SPECT_PLAYERS: @@ -2261,12 +2261,28 @@ begin end; end; end; + + if gSpectMode = SPECT_MAPVIEW then + begin + gSpectX := Max(gSpectX, rSpectX0); + gSpectX := Min(gSpectX, rSpectX1); + gSpectY := Max(gSpectY, rSpectY0); + gSpectY := Min(gSpectY, rSpectY1); + end; end; (* spectator state check from render *) - if (gPlayer1 = nil) and (gPlayer2 = nil) and (gSpectMode = SPECT_NONE) then - gSpectMode := SPECT_STATS; + if (gPlayer1 = nil) and (gPlayer2 = nil) then + begin + (* no local players -> automatically enable to spectator mode *) + if gSpectMode = SPECT_NONE then gSpectMode := SPECT_STATS; + end + else + begin + (* at least one local player -> automatically disable spectator mode *) + gSpectMode := SPECT_NONE; + end; if IsActivePlayer(g_Player_Get(gSpectPID1)) = false then gSpectPID1 := GetActivePlayerID_Next(); @@ -4668,22 +4684,6 @@ begin g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth, gScreenHeight])); g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth, gScreenHeight])); end - else if cmd = 'd_sounds' then - begin - if (Length(P) > 1) and - ((P[1] = '1') or (P[1] = '0')) then - g_Debug_Sounds := (P[1][1] = '1'); - - g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds)])); - end - else if cmd = 'd_frames' then - begin - if (Length(P) > 1) and - ((P[1] = '1') or (P[1] = '0')) then - g_Debug_Frames := (P[1][1] = '1'); - - g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames)])); - end else if cmd = 'd_winmsg' then begin if (Length(P) > 1) and @@ -4754,14 +4754,6 @@ begin end; end; end - else if (cmd = 'd_health') then - begin - if (Length(P) > 1) and - ((P[1] = '1') or (P[1] = '0')) then - g_debug_HealthBar := (P[1][1] = '1'); - - g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar)])); - end else if (cmd = 'd_player') then begin if (Length(P) > 1) and @@ -6997,7 +6989,6 @@ begin conRegVar('pf_coldet', @g_profile_collision, 'draw collision detection profiles', 'coldet profiles'); conRegVar('pf_los', @g_profile_los, 'draw monster LOS profiles', 'monster LOS profiles'); - conRegVar('r_sq_draw', @gdbg_map_use_accel_render, 'accelerated spatial queries in rendering', 'accelerated rendering'); conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet, 'accelerated spatial queries in map coldet', 'accelerated map coldet'); conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel, 'accelerated spatial queries for monsters', 'accelerated monster coldet'); conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');