X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_playermodel.pas;h=b5978c926654f1c705cede3e42f2b2d7c1bf55e0;hb=1f680d4a7f8c68a3f205d09b7a83e9f11c8498c6;hp=283113e0dc5e4f4f33bfae98e848a7f0a78f4df0;hpb=88ce644db1b40111bdb380f4357fa59bdb5173be;p=d2df-sdl.git diff --git a/src/game/g_playermodel.pas b/src/game/g_playermodel.pas index 283113e..b5978c9 100644 --- a/src/game/g_playermodel.pas +++ b/src/game/g_playermodel.pas @@ -1,10 +1,25 @@ +(* 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_playermodel; interface uses - g_textures, g_basic, e_graphics, WADEDITOR, - WADSTRUCT, g_weapons; + g_textures, g_basic, g_weapons, e_graphics, wadreader; const A_STAND = 0; @@ -20,7 +35,7 @@ const MODELSOUND_PAIN = 0; MODELSOUND_DIE = 1; - + type TModelInfo = record Name: String; @@ -165,6 +180,8 @@ var s: String; begin Result := False; + x := 0; + y := 0; str := Trim(str); if Length(str) < 3 then @@ -229,11 +246,11 @@ end; function g_PlayerModel_Load(FileName: string): Boolean; var ID: DWORD; - a, b, len, aa, bb, f: Integer; + a, b, len, lenpd, lenpd2, aa, bb, f: Integer; cc: TDirection; config: TConfig; pData, pData2: Pointer; - WAD: TWADEditor_1; + WAD: TWADFile; s: string; prefix: string; ok: Boolean; @@ -242,21 +259,21 @@ begin Result := False; - WAD := TWADEditor_1.Create; + WAD := TWADFile.Create; WAD.ReadFile(FileName); - if WAD.GetLastError <> DFWAD_NOERROR then + if {WAD.GetLastError <> DFWAD_NOERROR} not WAD.isOpen then begin WAD.Free(); Exit; end; - if not WAD.GetResource('TEXT', 'MODEL', pData, len) then + if not WAD.GetResource('TEXT/MODEL', pData, len) then begin WAD.Free(); Exit; end; - + config := TConfig.CreateMem(pData, len); FreeMem(pData); @@ -266,7 +283,7 @@ begin config.Free(); WAD.Free(); Exit; - end; + end; SetLength(PlayerModelsArray, Length(PlayerModelsArray)+1); ID := High(PlayerModelsArray); @@ -356,12 +373,12 @@ begin SetLength(Gibs, ReadInt('Gibs', 'count', 0)); if (Gibs <> nil) and - (WAD.GetResource('TEXTURES', config.ReadStr('Gibs', 'resource', 'GIBS'), pData, len)) and - (WAD.GetResource('TEXTURES', config.ReadStr('Gibs', 'mask', 'GIBSMASK'), pData2, len)) then + (WAD.GetResource('TEXTURES/'+config.ReadStr('Gibs', 'resource', 'GIBS'), pData, lenpd)) and + (WAD.GetResource('TEXTURES/'+config.ReadStr('Gibs', 'mask', 'GIBSMASK'), pData2, lenpd2)) then begin for a := 0 to High(Gibs) do - if e_CreateTextureMemEx(pData, Gibs[a].ID, a*32, 0, 32, 32) and - e_CreateTextureMemEx(pData2, Gibs[a].MaskID, a*32, 0, 32, 32) then + if e_CreateTextureMemEx(pData, lenpd, Gibs[a].ID, a*32, 0, 32, 32) and + e_CreateTextureMemEx(pData2, lenpd2, Gibs[a].MaskID, a*32, 0, 32, 32) then begin Gibs[a].Rect := e_GetTextureSize2(Gibs[a].ID); with Gibs[a].Rect do @@ -561,6 +578,7 @@ function g_PlayerModel_GetInfo(ModelName: string): TModelInfo; var a: Integer; begin + FillChar(Result, SizeOf(Result), 0); if PlayerModelsArray = nil then Exit; for a := 0 to High(PlayerModelsArray) do @@ -579,7 +597,7 @@ begin for a := WEAPON_SAW to WEAPON_SUPERPULEMET do for b := W_POS_NORMAL to W_POS_DOWN do for c := W_ACT_NORMAL to W_ACT_FIRE do - e_DeleteTexture(WeaponID[a][b][c]); + e_DeleteTexture(WeaponID[a][b][c]); e_WriteLog('Releasing models...', MSG_NOTIFY); @@ -608,7 +626,7 @@ begin for b := 0 to High(Gibs) do begin e_DeleteTexture(Gibs[b].ID); - e_DeleteTexture(Gibs[b].MaskID); + e_DeleteTexture(Gibs[b].MaskID); end; end; @@ -780,7 +798,7 @@ begin end else begin - if (Level in [2, 3]) and (FSlopSound > 0) then + if (Level in [2, 3, 5]) and (FSlopSound > 0) then begin g_Sound_PlayExAt('SOUND_MONSTER_SLOP', X, Y); if FSlopSound = 1 then @@ -797,6 +815,12 @@ begin SetLength(TempArray, Length(TempArray)+1); TempArray[High(TempArray)] := FDieSounds[a].ID; end; + if (TempArray = nil) and (Level = 5) then + begin + g_Sound_PlayExAt('SOUND_MONSTER_SLOP', X, Y); + Result := True; + Exit; + end; end; if TempArray = nil then Exit;