X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_game.pas;h=918a94714df9f810469a5204a8e83d817fac5074;hb=38ffc69cb8386eb4f610ad5838e776ac04c6c297;hp=ebb1387e79153cebaeeb33d2382545a2d2c44ebe;hpb=57a682f2f493bb3a3ac4072d0b7dd7b4863dc6cf;p=d2df-sdl.git diff --git a/src/game/g_game.pas b/src/game/g_game.pas index ebb1387..918a947 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -22,7 +22,7 @@ uses SysUtils, Classes, MAPDEF, g_basic, g_player, e_graphics, g_res_downloader, - g_sound, g_gui, utils, md5, xprofiler; + g_sound, g_gui, utils, md5, mempool, xprofiler; type TGameSettings = record @@ -310,8 +310,11 @@ var gVotesEnabled: Boolean = True; gEvents: Array of TGameEvent; gDelayedEvents: Array of TDelayedEvent; + gUseChatSounds: Boolean = True; gChatSounds: Array of TChatSound; + g_dbg_ignore_bounds: Boolean = false; + // move button values: // bits 0-1: l/r state: // 0: neither left, nor right pressed @@ -1540,6 +1543,8 @@ var reliableUpdate: Boolean; begin g_ResetDynlights(); + framePool.reset(); + // Ïîðà âûêëþ÷àòü èãðó: if gExit = EXIT_QUIT then Exit; @@ -1981,6 +1986,7 @@ begin e_WriteLog('Changing resolution', TMsgType.Notify); g_Game_ChangeResolution(gRC_Width, gRC_Height, gRC_FullScreen, gRC_Maximized); gResolutionChange := False; + g_ActiveWindow := nil; end; // Íóæíî ñìåíèòü ÿçûê: @@ -2091,7 +2097,7 @@ begin gChatSounds[i].Sound.SetByName('SOUND_CHAT_MACRO' + IntToStr(i)); SetLength(gChatSounds[i].Tags, tags); for j := 0 to tags - 1 do - gChatSounds[i].Tags[j] := LowerCase(cfg.ReadStr(IntToStr(i), 'Tag' + IntToStr(j), '')); + gChatSounds[i].Tags[j] := toLowerCase1251(cfg.ReadStr(IntToStr(i), 'Tag' + IntToStr(j), '')); gChatSounds[i].FullWord := cfg.ReadBool(IntToStr(i), 'FullWord', False); end; @@ -2161,6 +2167,7 @@ begin end; g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD+':TEXTURES\TELEPORT', 64, 64, 10, False); + g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD+':TEXTURES\PUNCH', 64, 64, 4, False); g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD+':SOUNDS\TELEPORT'); g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD+':SOUNDS\NOTELEPORT'); g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD+':SOUNDS\DOOROPEN'); @@ -2237,6 +2244,7 @@ begin g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE'); g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA'); g_Frames_DeleteByName('FRAMES_TELEPORT'); + g_Frames_DeleteByName('FRAMES_PUNCH'); g_Sound_Delete('SOUND_GAME_TELEPORT'); g_Sound_Delete('SOUND_GAME_NOTELEPORT'); g_Sound_Delete('SOUND_GAME_DOOROPEN'); @@ -3245,7 +3253,7 @@ begin px := p.GameX + PLAYER_RECT_CX; py := p.GameY + PLAYER_RECT_CY+p.Obj.slopeUpLeft; - if (g_dbg_scale = 1.0) then + if (g_dbg_scale = 1.0) and (not g_dbg_ignore_bounds) then begin if (px > (gPlayerScreenSize.X div 2)) then a := -px+(gPlayerScreenSize.X div 2) else a := 0; if (py > (gPlayerScreenSize.Y div 2)) then b := -py+(gPlayerScreenSize.Y div 2) else b := 0; @@ -3323,6 +3331,16 @@ begin //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]); fixViewportForScale(); //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]); + if (g_dbg_scale <> 1.0) and (not g_dbg_ignore_bounds) then + begin + if (sX+sWidth > gMapInfo.Width) then sX := gMapInfo.Width-sWidth; + if (sY+sHeight > gMapInfo.Height) then sY := gMapInfo.Height-sHeight; + if (sX < 0) then sX := 0; + if (sY < 0) then sY := 0; + + if (gBackSize.X <= gPlayerScreenSize.X) or (gMapInfo.Width <= sWidth) then c := 0 else c := trunc((gBackSize.X-gPlayerScreenSize.X)*sX/(gMapInfo.Width-sWidth)); + if (gBackSize.Y <= gPlayerScreenSize.Y) or (gMapInfo.Height <= sHeight) then d := 0 else d := trunc((gBackSize.Y-gPlayerScreenSize.Y)*sY/(gMapInfo.Height-sHeight)); + end; p.viewPortX := sX; p.viewPortY := sY; p.viewPortW := sWidth; @@ -3747,7 +3765,7 @@ begin g_PlayerModel_FreeData(); g_Texture_DeleteAll(); g_Frames_DeleteAll(); - g_Menu_Free(); + //g_Menu_Free(); //k8: this segfaults after resolution change; who cares? if NetInitDone then g_Net_Free; @@ -4189,6 +4207,10 @@ begin gPlayer2.Name := gPlayer2Settings.Name; end; + g_Game_SetLoadingText(_lc[I_LOAD_HOST], 0, False); + if NetForwardPorts then + g_Game_SetLoadingText(_lc[I_LOAD_PORTS], 0, False); + // Ñòàðòóåì ñåðâåð if not g_Net_Host(IPAddr, Port, NetMaxClients) then begin @@ -6958,30 +6980,45 @@ begin end; procedure g_Game_ChatSound(Text: String; Taunt: Boolean = True); +const + punct: Array[0..13] of String = + ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^'); var i, j: Integer; ok: Boolean; fpText: String; + function IsPunctuation(S: String): Boolean; + var + i: Integer; + begin + Result := False; + if Length(S) <> 1 then + Exit; + for i := Low(punct) to High(punct) do + if S = punct[i] then + begin + Result := True; + break; + end; + end; function FilterPunctuation(S: String): String; + var + i: Integer; begin - S := StringReplace(S, '.', ' ', [rfReplaceAll]); - S := StringReplace(S, ',', ' ', [rfReplaceAll]); - S := StringReplace(S, ':', ' ', [rfReplaceAll]); - S := StringReplace(S, ';', ' ', [rfReplaceAll]); - S := StringReplace(S, '!', ' ', [rfReplaceAll]); - S := StringReplace(S, '?', ' ', [rfReplaceAll]); + for i := Low(punct) to High(punct) do + S := StringReplace(S, punct[i], ' ', [rfReplaceAll]); Result := S; end; begin - g_Sound_PlayEx('SOUND_GAME_RADIO'); + ok := False; - if Taunt and (gChatSounds <> nil) and (Pos(': ', Text) > 0) then + if gUseChatSounds and Taunt and (gChatSounds <> nil) and (Pos(': ', Text) > 0) then begin // remove player name Delete(Text, 1, Pos(': ', Text) + 2 - 1); // for FullWord check - Text := LowerCase(' ' + Text + ' '); + Text := toLowerCase1251(' ' + Text + ' '); fpText := FilterPunctuation(Text); for i := 0 to Length(gChatSounds) - 1 do @@ -6989,10 +7026,7 @@ begin ok := True; for j := 0 to Length(gChatSounds[i].Tags) - 1 do begin - if gChatSounds[i].FullWord and - (gChatSounds[i].Tags[j] <> '.') and (gChatSounds[i].Tags[j] <> ',') and - (gChatSounds[i].Tags[j] <> ':') and (gChatSounds[i].Tags[j] <> ';') and - (gChatSounds[i].Tags[j] <> '!') and (gChatSounds[i].Tags[j] <> '?') then + if gChatSounds[i].FullWord and (not IsPunctuation(gChatSounds[i].Tags[j])) then ok := Pos(' ' + gChatSounds[i].Tags[j] + ' ', fpText) > 0 else ok := Pos(gChatSounds[i].Tags[j], Text) > 0; @@ -7006,6 +7040,8 @@ begin end; end; end; + if not ok then + g_Sound_PlayEx('SOUND_GAME_RADIO'); end; procedure g_Game_Announce_GoodShot(SpawnerUID: Word); @@ -7507,7 +7543,9 @@ begin conRegVar('dbg_holmes', @g_holmes_enabled, 'enable/disable Holmes', 'Holmes', true); - conRegVar('dbg_scale', @g_dbg_scale, 0.01, 100.0, 'experimental deBUG scale mode', '', false); + conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds, 'ignore level bounds', '', false); + + conRegVar('r_scale', @g_dbg_scale, 0.01, 100.0, 'render scale', '', false); conRegVar('light_enabled', @gwin_k8_enable_light_experiments, 'enable/disable dynamic lighting', 'lighting'); conRegVar('light_player_halo', @g_playerLight, 'enable/disable player halo', 'player light halo');