X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_game.pas;h=938e07175a779844898f0196219a362ea03e5151;hb=3349a0b38bc1fae71b758cb1686d4f6d0bf4f926;hp=f678380c6b6a494b975f62a5669cefa8b21edee1;hpb=70c6ae06da3e766e0303dca258b0b3f6e56a2dea;p=d2df-sdl.git diff --git a/src/game/g_game.pas b/src/game/g_game.pas index f678380..938e071 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -1,10 +1,26 @@ +(* 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) +{$MODE DELPHI} unit g_game; interface uses g_basic, g_player, e_graphics, Classes, g_res_downloader, - SysUtils, g_sound, g_gui, MAPSTRUCT, WADEDITOR, md5; + SysUtils, g_sound, g_gui, g_scripts, MAPSTRUCT, wadreader, md5; type TGameSettings = record @@ -470,7 +486,7 @@ end; function g_Game_GetMegaWADInfo(WAD: String): TMegaWADInfo; var - w: TWADEditor_1; + w: TWADFile; cfg: TConfig; p: Pointer; len: Integer; @@ -479,10 +495,10 @@ begin Result.description := ''; Result.author := ''; - w := TWADEditor_1.Create(); + w := TWADFile.Create(); w.ReadFile(WAD); - if not w.GetResource('', 'INTERSCRIPT', p, len) then + if not w.GetResource('INTERSCRIPT', p, len) then begin w.Free(); Exit; @@ -525,7 +541,7 @@ end; procedure g_Game_LoadWAD(WAD: string); var - w: TWADEditor_1; + w: TWADFile; cfg: TConfig; p: Pointer; {b, }len: Integer; @@ -538,10 +554,10 @@ begin MegaWAD.info := g_Game_GetMegaWADInfo(MapsDir + WAD); - w := TWADEditor_1.Create(); + w := TWADFile.Create(); w.ReadFile(MapsDir + WAD); - if not w.GetResource('', 'INTERSCRIPT', p, len) then + if not w.GetResource('INTERSCRIPT', p, len) then begin w.Free(); Exit; @@ -578,14 +594,14 @@ begin MegaWAD.endpic := cfg.ReadStr('megawad', 'endpic', ''); if MegaWAD.endpic <> '' then begin - g_ProcessResourceStr(MegaWAD.endpic, @s, nil, nil); + s := g_ExtractWadName(MegaWAD.endpic); if s = '' then s := MapsDir+WAD else s := GameDir+'/wads/'; g_Texture_CreateWADEx('TEXTURE_endpic', s+MegaWAD.endpic); end; MegaWAD.endmus := cfg.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ'); if MegaWAD.endmus <> '' then begin - g_ProcessResourceStr(MegaWAD.endmus, @s, nil, nil); + s := g_ExtractWadName(MegaWAD.endmus); if s = '' then s := MapsDir+WAD else s := GameDir+'/wads/'; g_Sound_CreateWADEx('MUSIC_endmus', s+MegaWAD.endmus, True); end; @@ -663,7 +679,7 @@ end; procedure EndGame(); var a: Integer; - FileName, SectionName, ResName: string; + FileName: string; begin if g_Game_IsNet and g_Game_IsServer then MH_SEND_GameEvent(NET_EV_MAPEND, Byte(gMissionFailed)); @@ -725,10 +741,10 @@ begin EXIT_ENDLEVELCUSTOM: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå begin // Ñòàòèñòèêà Ñâîåé èãðû: - g_ProcessResourceStr(gMapInfo.Map, FileName, SectionName, ResName); + FileName := g_ExtractWadName(gMapInfo.Map); CustomStat.GameTime := gTime; - CustomStat.Map := ExtractFileName(FileName)+':'+ResName; + CustomStat.Map := ExtractFileName(FileName)+':'+g_ExtractFileName(gMapInfo.Map); //ResName; CustomStat.MapName := gMapInfo.Name; CustomStat.GameMode := gGameSettings.GameMode; if gGameSettings.GameMode in [GM_TDM, GM_CTF] then @@ -840,8 +856,8 @@ begin e_DrawFillQuad(x, y, x+w-1, y+h-1, 64, 64, 64, 32); e_DrawQuad(x, y, x+w-1, y+h-1, 255, 127, 0); - g_ProcessResourceStr(gMapInfo.Map, @wad, nil, @map); - wad := ExtractFileName(wad); + wad := g_ExtractWadNameNoPath(gMapInfo.Map); + map := g_ExtractFileName(gMapInfo.Map); mapstr := wad + ':\' + map + ' - ' + gMapInfo.Name; case gGameSettings.GameMode of @@ -1082,6 +1098,9 @@ begin g_Game_SetLoadingText(_lc[I_LOAD_MENUS], 0, False); g_Menu_Init(); + + g_Scripts_Init(); + g_Scripts_Load('game.conprint("ass")'); gMusic := TMusic.Create(); gMusic.SetByName('MUSIC_MENU'); @@ -3661,7 +3680,7 @@ var begin if g_Game_IsClient then Exit; - g_ProcessResourceStr(gMapInfo.Map, nil, nil, @Map); + map := g_ExtractFileName(gMapInfo.Map); MessageTime := 0; gGameOn := False; @@ -3692,7 +3711,8 @@ begin if Pos(':\', Map) > 0 then begin - g_ProcessResourceStr(Map, @NewWAD, nil, @ResName); + NewWAD := g_ExtractWadName(Map); + ResName := g_ExtractFileName(Map); if g_Game_IsServer then begin gWADHash := MD5File(MapsDir + NewWAD); @@ -3870,7 +3890,7 @@ begin Exit; end; gExit := EXIT_ENDLEVELCUSTOM; - g_ProcessResourceStr(gMapInfo.Map, nil, nil, @Map); + Map := g_ExtractFileName(gMapInfo.Map); gNextMap := Map; end; @@ -4018,7 +4038,7 @@ begin if MapList = nil then Exit; - g_ProcessResourceStr(gMapInfo.Map, nil, nil, @Map); + Map := g_ExtractFileName(gMapInfo.Map); SortSArray(MapList); MapIndex := -255; @@ -4057,11 +4077,8 @@ begin end; function g_Game_IsTestMap(): Boolean; -var - FName, Sect, Res: String; begin - g_ProcessResourceStr(gMapInfo.Map, FName, Sect, Res); - Result := UpperCase(Res) = TEST_MAP_NAME; + result := StrEquCI1251(TEST_MAP_NAME, g_ExtractFileName(gMapInfo.Map)); end; procedure g_Game_DeleteTestMap(); @@ -4070,7 +4087,7 @@ var MapName: Char16; WadName: string; { - WAD: TWADEditor_1; + WAD: TWADFile; MapList: SArray; time: Integer; } @@ -4094,7 +4111,7 @@ begin if not gTempDelete then begin time := g_GetFileTime(WadName); - WAD := TWADEditor_1.Create(); + WAD := TWADFile.Create(); // ×èòàåì Wad-ôàéë: if not WAD.ReadFile(WadName) then @@ -5851,17 +5868,43 @@ end; procedure g_TakeScreenShot(); var a: Word; - FileName: String; + FileName: string; + ssdir, t: string; + st: TStream; + ok: Boolean; begin - for a := 1 to High(Word) do - begin - FileName := Format(GameDir+'/Screenshots/Screenshot%.3d.bmp', [a]); - if not FileExists(FileName) then + if e_NoGraphics then Exit; + ssdir := GameDir+'/screenshots'; + if not findFileCI(ssdir, true) then + begin + // try to create dir + try + CreateDir(ssdir); + except + end; + if not findFileCI(ssdir, true) then exit; // alas + end; + try + for a := 1 to High(Word) do begin - e_MakeScreenshot(FileName, gScreenWidth, gScreenHeight); - g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [ExtractFileName(FileName)])); - Break; + FileName := Format(ssdir+'screenshot%.3d.png', [a]); + t := FileName; + if findFileCI(t, true) then continue; + if not findFileCI(FileName) then + begin + ok := false; + st := createDiskFile(FileName); + try + e_MakeScreenshot(st, gScreenWidth, gScreenHeight); + ok := true; + finally + st.Free(); + end; + if not ok then try DeleteFile(FileName); except end else g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [ExtractFileName(FileName)])); + break; + end; end; + except end; end;