X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_game.pas;h=854938698fc7b37b254f7b58c4541d5a9bb3f39f;hb=refs%2Fheads%2Frenders_updated;hp=ce8c5787d770a68a1ca9adcf66b60b62931abb18;hpb=1a98ba3b2161596897c3219a19c4c0fbb9ca0a7f;p=d2df-sdl.git diff --git a/src/game/g_game.pas b/src/game/g_game.pas index ce8c578..8549386 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 @@ -132,9 +132,6 @@ procedure g_Game_Announce_KillCombo(Param: Integer); procedure g_Game_Announce_BodyKill(SpawnerUID: Word); procedure g_Game_StartVote(Command, Initiator: string); procedure g_Game_CheckVote; -{$IFDEF ENABLE_RENDER} - procedure g_TakeScreenShot(Filename: string = ''); -{$ENDIF} procedure g_FatalError(Text: String); procedure g_SimpleError(Text: String); function g_Game_IsTestMap(): Boolean; @@ -146,9 +143,6 @@ procedure GameCommands(P: SSArray); procedure GameCheats(P: SSArray); procedure DebugCommands(P: SSArray); procedure g_Game_Process_Params; -procedure g_Game_SetLoadingText(Text: String; Max: Integer; reWrite: Boolean); -procedure g_Game_StepLoading(Value: Integer = -1); -procedure g_Game_ClearLoading(); procedure g_Game_SetDebugMode(); function IsActivePlayer(p: TPlayer): Boolean; @@ -170,9 +164,6 @@ procedure SortGameStat(var stat: TPlayerStatArray); const GAME_TICK = 28; - LOADING_SHOW_STEP = 100; - LOADING_INTERLINE = 20; - GT_NONE = 0; GT_SINGLE = 1; GT_CUSTOM = 2; @@ -321,13 +312,8 @@ 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; gCoopTotalMonstersKilled: Word = 0; @@ -416,15 +402,6 @@ function gPause (): Boolean; inline; TotalSecrets: Integer; end; - TLoadingStat = record - CurValue: Integer; - MaxValue: Integer; - ShowCount: Integer; - Msgs: Array of String; - NextMsg: Word; - PBarWasHere: Boolean; // did we draw a progress bar for this message? - end; - TDynLight = record x, y, radius: Integer; r, g, b, a: Single; @@ -437,7 +414,6 @@ function gPause (): Boolean; inline; StatShotDone: Boolean; StatFilename: string = ''; // used by stat screenshot to save with the same name as the csv SingleStat: TEndSingleGameStat; - LoadingStat: TLoadingStat; MessageText: String; IsDrawStat: Boolean; EndingGameCounter: Byte; @@ -1050,13 +1026,8 @@ 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; function g_Game_ModeToText(Mode: Byte): string; @@ -1454,12 +1425,6 @@ begin sfsGCDisable(); // temporary disable removing of temporary volumes try - g_Game_ClearLoading(); - g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION]), 0, False); - g_Game_SetLoadingText('', 0, False); - -// g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False); - gGameOn := false; gPauseMain := false; gPauseHolmes := false; @@ -1467,7 +1432,6 @@ begin {e_MouseInfo.Accel := 1.0;} - g_Game_SetLoadingText(_lc[I_LOAD_GAME_DATA], 0, False); g_Game_LoadData(); g_Game_SetLoadingText(_lc[I_LOAD_MUSIC], 0, False); @@ -1507,7 +1471,7 @@ begin {$IFDEF ENABLE_GIBS} g_Gibs_RemoveAll; {$ENDIF} - {$IFDEF ENALBE_SHELLS} + {$IFDEF ENABLE_SHELLS} g_Shells_RemoveAll; {$ENDIF} {$IFDEF ENABLE_CORPSES} @@ -1852,6 +1816,8 @@ procedure g_Game_Update(); var reliableUpdate: Boolean; + rSpectX0, rSpectY0: Integer; + rSpectX1, rSpectY1: Integer; begin g_ResetDynlights(); framePool.reset(); @@ -2128,7 +2094,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} @@ -2152,14 +2126,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 @@ -2244,12 +2214,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 @@ -2263,15 +2233,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: @@ -2287,12 +2257,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(); @@ -2568,6 +2554,7 @@ begin if DataLoaded then Exit; e_WriteLog('Loading game data...', TMsgType.Notify); + g_Game_SetLoadingText(_lc[I_LOAD_GAME_DATA], 0, False); g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD+':SOUNDS\TELEPORT'); g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD+':SOUNDS\NOTELEPORT'); @@ -2650,10 +2637,8 @@ begin g_Game_LoadChatSounds(GameWAD+':CHATSND\SNDCFG'); - g_Game_SetLoadingText(_lc[I_LOAD_ITEMS_DATA], 0, False); g_Items_LoadData(); - g_Game_SetLoadingText(_lc[I_LOAD_WEAPONS_DATA], 0, False); g_Weapon_LoadData(); g_Monsters_LoadData(); @@ -3463,7 +3448,7 @@ begin {$IFDEF ENABLE_GIBS} g_Gibs_RemoveAll; {$ENDIF} - {$IFDEF ENALBE_SHELLS} + {$IFDEF ENABLE_SHELLS} g_Shells_RemoveAll; {$ENDIF} {$IFDEF ENABLE_CORPSES} @@ -3537,12 +3522,13 @@ begin begin //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName); result := g_Map_Load(NewWAD+':\'+ResName); - {$IFDEF ENABLE_RENDER} - r_Render_LoadTextures; - {$ENDIF} end; if Result then begin + {$IFDEF ENABLE_RENDER} + r_Render_LoadTextures; + r_Render_Reset; + {$ENDIF} g_Player_ResetAll(Force or gLastMap, gGameSettings.GameType = GT_SINGLE); gState := STATE_NONE; @@ -3801,7 +3787,7 @@ begin {$IFDEF ENABLE_GIBS} g_Gibs_RemoveAll; {$ENDIF} - {$IFDEF ENALBE_SHELLS} + {$IFDEF ENABLE_SHELLS} g_Shells_RemoveAll; {$ENDIF} {$IFDEF ENABLE_CORPSES} @@ -4694,30 +4680,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 - ((P[1] = '1') or (P[1] = '0')) then - g_Debug_WinMsgs := (P[1][1] = '1'); - - g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs)])); - end else if (cmd = 'd_monoff') and not g_Game_IsNet then begin if (Length(P) > 1) and @@ -4780,22 +4742,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 - ((P[1] = '1') or (P[1] = '0')) then - g_debug_Player := (P[1][1] = '1'); - - g_Console_Add(Format(cmd + ' is %d', [Byte(g_Debug_Player)])); - end else if (cmd = 'd_mem') then begin PrintHeapStats(); @@ -6004,7 +5950,7 @@ begin else if cmd = 'screenshot' then begin {$IFDEF ENABLE_RENDER} - g_TakeScreenShot; + r_Render_RequestScreenShot; {$ENDIF} end else if (cmd = 'weapnext') or (cmd = 'weapprev') then @@ -6338,29 +6284,6 @@ begin end; end; -{$IFDEF ENABLE_RENDER} -procedure g_TakeScreenShot(Filename: string = ''); - var t: TDateTime; dir, date, name: String; -begin - if e_NoGraphics then - Exit; - - dir := e_GetWriteableDir(ScreenshotDirs); - if Filename = '' then - begin - t := Now; - DateTimeToString(date, 'yyyy-mm-dd-hh-nn-ss', t); - Filename := 'screenshot-' + date; - end; - - name := e_CatPath(dir, Filename + '.png'); - if r_Render_WriteScreenShot(name) then - g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [name])) - else - g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [name])); -end; -{$ENDIF} - {$IFDEF ENABLE_MENU} procedure g_Game_InGameMenu(Show: Boolean); begin @@ -6812,81 +6735,6 @@ begin gCheats := True; end; -procedure g_Game_SetLoadingText(Text: String; Max: Integer; reWrite: Boolean); -var - i: Word; -begin - if Length(LoadingStat.Msgs) = 0 then - Exit; - - with LoadingStat do - begin - if not reWrite then - begin // Переходим на следующую строку или скроллируем: - if NextMsg = Length(Msgs) then - begin // scroll - for i := 0 to High(Msgs)-1 do - Msgs[i] := Msgs[i+1]; - end - else - Inc(NextMsg); - end else - if NextMsg = 0 then - Inc(NextMsg); - - Msgs[NextMsg-1] := Text; - CurValue := 0; - MaxValue := Max; - ShowCount := 0; - PBarWasHere := false; - end; - - {$IFDEF ENABLE_MENU} - g_ActiveWindow := nil; - {$ENDIF} - - ProcessLoading(true); -end; - -procedure g_Game_StepLoading(Value: Integer = -1); -begin - with LoadingStat do - begin - if Value = -1 then - begin - Inc(CurValue); - Inc(ShowCount); - end - else - CurValue := Value; - - if (ShowCount > LOADING_SHOW_STEP) or (Value > -1) then - begin - ShowCount := 0; - ProcessLoading(False); - end; - end; -end; - -procedure g_Game_ClearLoading(); -var - len: Word; -begin - with LoadingStat do - begin - CurValue := 0; - MaxValue := 0; - ShowCount := 0; - len := ((gScreenHeight div 3)*2 - 50) div LOADING_INTERLINE; - if len < 1 then len := 1; - SetLength(Msgs, len); - for len := Low(Msgs) to High(Msgs) do - Msgs[len] := ''; - NextMsg := 0; - PBarWasHere := false; - end; -end; - procedure Parse_Params(var pars: TParamStrValues); var i: Integer; @@ -7121,7 +6969,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');