X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_game.pas;h=f678380c6b6a494b975f62a5669cefa8b21edee1;hb=70c6ae06da3e766e0303dca258b0b3f6e56a2dea;hp=40760c69eeb6c78d2ec0f81196bc8a1588c806d7;hpb=1fb71d901f9824644dc7cc750da7b6507cca3486;p=d2df-sdl.git diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 40760c6..f678380 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -106,6 +106,7 @@ function g_Game_IsTestMap(): Boolean; procedure g_Game_DeleteTestMap(); procedure GameCVars(P: SArray); procedure GameCommands(P: SArray); +procedure GameCheats(P: SArray); procedure DebugCommands(P: SArray); procedure g_Game_Process_Params; procedure g_Game_SetLoadingText(Text: String; Max: Integer; reWrite: Boolean); @@ -244,7 +245,7 @@ var gWinPosX, gWinPosY: Integer; gWinSizeX, gWinSizeY: Integer; gWinFrameX, gWinFrameY, gWinCaption: Integer; - gWinActive: Boolean = False; + gWinActive: Boolean = True; // by default window is active, lol gResolutionChange: Boolean = False; gRC_Width, gRC_Height: Word; gRC_FullScreen, gRC_Maximized: Boolean; @@ -295,7 +296,7 @@ uses g_triggers, MAPDEF, g_monsters, e_sound, CONFIG, BinEditor, g_language, g_net, SDL, ENet, e_fixedbuffer, g_netmsg, g_netmaster, GL, GLExt, - utils; + utils, sfs; type TEndCustomGameStat = record @@ -653,7 +654,7 @@ begin gDelayedEvents[n].DENum := Num; gDelayedEvents[n].DEStr := Str; if DEType = DE_GLOBEVENT then - gDelayedEvents[n].Time := (GetTimer() div 1000) + Time + gDelayedEvents[n].Time := (GetTimer() {div 1000}) + Time else gDelayedEvents[n].Time := gTime + Time; Result := n; @@ -1020,80 +1021,86 @@ begin gMapToDelete := ''; gTempDelete := False; - g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD+':TEXTURES\TITLE'); - g_Texture_CreateWADEx('INTER', GameWAD+':TEXTURES\INTER'); - g_Texture_CreateWADEx('ENDGAME_EN', GameWAD+':TEXTURES\ENDGAME_EN'); - g_Texture_CreateWADEx('ENDGAME_RU', GameWAD+':TEXTURES\ENDGAME_RU'); - - LoadStdFont('STDTXT', 'STDFONT', gStdFont); - LoadFont('MENUTXT', 'MENUFONT', gMenuFont); - LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont); - - 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_CONSOLE], 0, False); - g_Console_Init(); - - g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False); - g_PlayerModel_LoadData(); - - if FindFirst(ModelsDir+'*.wad', faAnyFile, SR) = 0 then - repeat - if not g_PlayerModel_Load(ModelsDir+SR.Name) then - e_WriteLog(Format('Error loading model %s', [SR.Name]), MSG_WARNING); - until FindNext(SR) <> 0; - FindClose(SR); - - if FindFirst(ModelsDir+'*.pk3', faAnyFile, SR) = 0 then - repeat - if not g_PlayerModel_Load(ModelsDir+SR.Name) then - e_WriteLog(Format('Error loading model %s', [SR.Name]), MSG_WARNING); - until FindNext(SR) <> 0; - FindClose(SR); - - if FindFirst(ModelsDir+'*.zip', faAnyFile, SR) = 0 then - repeat - if not g_PlayerModel_Load(ModelsDir+SR.Name) then - e_WriteLog(Format('Error loading model %s', [SR.Name]), MSG_WARNING); - until FindNext(SR) <> 0; - FindClose(SR); - - gGameOn := False; - gPause := False; - gTime := 0; - LastScreenShot := 0; - - {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); - g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD+':MUSIC\INTERMUS', True); - g_Sound_CreateWADEx('MUSIC_MENU', GameWAD+':MUSIC\MENU', True); - g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD+':MUSIC\ROUNDMUS', True); - g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD+':MUSIC\ENDMUS', True); - - g_Game_SetLoadingText(_lc[I_LOAD_MENUS], 0, False); - g_Menu_Init(); - - gMusic := TMusic.Create(); - gMusic.SetByName('MUSIC_MENU'); - gMusic.Play(); - - gGameSettings.WarmupTime := 30; - - gState := STATE_MENU; - - SetLength(gEvents, 6); - gEvents[0].Name := 'ongamestart'; - gEvents[1].Name := 'ongameend'; - gEvents[2].Name := 'onmapstart'; - gEvents[3].Name := 'onmapend'; - gEvents[4].Name := 'oninter'; - gEvents[5].Name := 'onwadend'; + sfsGCDisable(); // temporary disable removing of temporary volumes + + try + g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD+':TEXTURES\TITLE'); + g_Texture_CreateWADEx('INTER', GameWAD+':TEXTURES\INTER'); + g_Texture_CreateWADEx('ENDGAME_EN', GameWAD+':TEXTURES\ENDGAME_EN'); + g_Texture_CreateWADEx('ENDGAME_RU', GameWAD+':TEXTURES\ENDGAME_RU'); + + LoadStdFont('STDTXT', 'STDFONT', gStdFont); + LoadFont('MENUTXT', 'MENUFONT', gMenuFont); + LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont); + + 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_CONSOLE], 0, False); + g_Console_Init(); + + g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False); + g_PlayerModel_LoadData(); + + if FindFirst(ModelsDir+'*.wad', faAnyFile, SR) = 0 then + repeat + if not g_PlayerModel_Load(ModelsDir+SR.Name) then + e_WriteLog(Format('Error loading model %s', [SR.Name]), MSG_WARNING); + until FindNext(SR) <> 0; + FindClose(SR); + + if FindFirst(ModelsDir+'*.pk3', faAnyFile, SR) = 0 then + repeat + if not g_PlayerModel_Load(ModelsDir+SR.Name) then + e_WriteLog(Format('Error loading model %s', [SR.Name]), MSG_WARNING); + until FindNext(SR) <> 0; + FindClose(SR); + + if FindFirst(ModelsDir+'*.zip', faAnyFile, SR) = 0 then + repeat + if not g_PlayerModel_Load(ModelsDir+SR.Name) then + e_WriteLog(Format('Error loading model %s', [SR.Name]), MSG_WARNING); + until FindNext(SR) <> 0; + FindClose(SR); + + gGameOn := False; + gPause := False; + gTime := 0; + LastScreenShot := 0; + + {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); + g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD+':MUSIC\INTERMUS', True); + g_Sound_CreateWADEx('MUSIC_MENU', GameWAD+':MUSIC\MENU', True); + g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD+':MUSIC\ROUNDMUS', True); + g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD+':MUSIC\ENDMUS', True); + + g_Game_SetLoadingText(_lc[I_LOAD_MENUS], 0, False); + g_Menu_Init(); + + gMusic := TMusic.Create(); + gMusic.SetByName('MUSIC_MENU'); + gMusic.Play(); + + gGameSettings.WarmupTime := 30; + + gState := STATE_MENU; + + SetLength(gEvents, 6); + gEvents[0].Name := 'ongamestart'; + gEvents[1].Name := 'ongameend'; + gEvents[2].Name := 'onmapstart'; + gEvents[3].Name := 'onmapend'; + gEvents[4].Name := 'oninter'; + gEvents[5].Name := 'onwadend'; + finally + sfsGCEnable(); // enable releasing unused volumes + end; end; procedure g_Game_Free(); @@ -1747,7 +1754,7 @@ begin // Äåëàåì ñêðèíøîò (íå ÷àùå 200 ìèëëèñåêóíä): if e_KeyPressed(gGameControls.GameControls.TakeScreenshot) then - if (GetTimer()-LastScreenShot) > 200000 then + if (GetTimer()-LastScreenShot) > 200000 div 1000 then begin g_TakeScreenShot(); LastScreenShot := GetTimer(); @@ -1762,7 +1769,7 @@ begin KeyPress(IK_F10); end; - Time := GetTimer() div 1000; + Time := GetTimer() {div 1000}; // Îáðàáîòêà îòëîæåííûõ ñîáûòèé: if gDelayedEvents <> nil then @@ -2287,7 +2294,7 @@ begin end; end; -procedure DrawMinimap(p: TPlayer; RenderRect: TRect); +procedure DrawMinimap(p: TPlayer; RenderRect: e_graphics.TRect); var a, aX, aY, aX2, aY2, Scale, ScaleSz: Integer; begin @@ -2660,8 +2667,7 @@ begin p.DrawPain(); p.DrawPickup(); p.DrawRulez(); - //if gShowMap then - //DrawMinimap(p, _TRect(0, 0, 128, 128)); + if gShowMap then DrawMinimap(p, _TRect(0, 0, 128, 128)); if g_Debug_Player then g_Player_DrawDebug(p); p.DrawGUI(); @@ -2679,7 +2685,7 @@ var begin if gExit = EXIT_QUIT then Exit; - Time := GetTimer() div 1000; + Time := GetTimer() {div 1000}; FPSCounter := FPSCounter+1; if Time - FPSTime >= 1000 then begin @@ -4768,6 +4774,132 @@ begin g_Console_Add(_lc[I_MSG_NOT_DEBUG]); end; + +procedure GameCheats(P: SArray); +var + cmd: string; + f, a: Integer; + plr: TPlayer; +begin + if (not gGameOn) or (not gCheats) or ((gGameSettings.GameType <> GT_SINGLE) and + (gGameSettings.GameMode <> GM_COOP) and (not gDebugMode)) or g_Game_IsNet then + begin + g_Console_Add('not available'); + exit; + end; + plr := gPlayer1; + if plr = nil then + begin + g_Console_Add('where is the player?!'); + exit; + end; + cmd := LowerCase(P[0]); + // god + if cmd = 'god' then + begin + plr.GodMode := not plr.GodMode; + if plr.GodMode then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now'); + exit; + end; + // give + if cmd = 'give' then + begin + if length(P) < 2 then begin g_Console_Add('give what?!'); exit; end; + for f := 1 to High(P) do + begin + cmd := LowerCase(P[f]); + if cmd = 'health' then begin plr.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue; end; + if (cmd = 'all') or (cmd = 'weapons') then begin plr.AllRulez(False); g_Console_Add('player got the gifts'); continue; end; + if cmd = 'exit' then + begin + if gTriggers <> nil then + begin + for a := 0 to High(gTriggers) do + begin + if gTriggers[a].TriggerType = TRIGGER_EXIT then + begin + g_Console_Add('player left the map'); + gExitByTrigger := True; + g_Game_ExitLevel(gTriggers[a].Data.MapName); + break; + end; + end; + end; + continue; + end; + if cmd = 'air' then begin plr.GiveItem(ITEM_OXYGEN); g_Console_Add('player got some air'); continue; end; + if cmd = 'jetpack' then begin plr.GiveItem(ITEM_JETPACK); g_Console_Add('player got jetpack'); continue; end; + if cmd = 'suit' then begin plr.GiveItem(ITEM_SUIT); g_Console_Add('player got envirosuit'); continue; end; + if cmd = 'berserk' then begin plr.GiveItem(ITEM_MEDKIT_BLACK); g_Console_Add('player got berserk pack'); continue; end; + g_Console_Add('i don''t know how to give '''+cmd+'''!'); + end; + exit; + end; + // open + if cmd = 'open' then + begin + g_Console_Add('player activated sesame'); + g_Triggers_OpenAll(); + exit; + end; + // fly + if cmd = 'fly' then + begin + gFly := not gFly; + if gFly then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings'); + exit; + end; + // noclip + if cmd = 'noclip' then + begin + plr.SwitchNoClip; + g_Console_Add('wall hardeness adjusted'); + exit; + end; + // notarget + if cmd = 'notarget' then + begin + plr.NoTarget := not plr.NoTarget; + if plr.NoTarget then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again'); + exit; + end; + // noreload + if cmd = 'noreload' then + begin + plr.NoReload := not plr.NoReload; + if plr.NoReload then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now'); + exit; + end; + // speedy + if cmd = 'speedy' then + begin + MAX_RUNVEL := 32-MAX_RUNVEL; + g_Console_Add('speed adjusted'); + exit; + end; + // jumpy + if cmd = 'jumpy' then + begin + VEL_JUMP := 30-VEL_JUMP; + g_Console_Add('jump height adjusted'); + exit; + end; + // automap + if cmd = 'automap' then + begin + gShowMap := not gShowMap; + if gShowMap then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight'); + exit; + end; + // aimline + if cmd = 'aimline' then + begin + gAimLine := not gAimLine; + if gAimLine then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight'); + exit; + end; +end; + procedure GameCommands(P: SArray); var a, b: Integer; @@ -6301,7 +6433,7 @@ begin if (s <> '') then begin gMapToDelete := MapsDir + map; - e_WriteLog('"--testdelete" argument doesn''t supported anymore!', MSG_FATALERROR); + e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', MSG_FATALERROR); Halt(1); end;