From: DeaDDooMER Date: Thu, 9 Jun 2022 16:23:15 +0000 (+0300) Subject: gl: fix player model unload X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=433e88c77b966a3fafc7c7f1704d9648713d5092;p=d2df-sdl.git gl: fix player model unload --- diff --git a/src/game/renders/opengl/r_map.pas b/src/game/renders/opengl/r_map.pas index fe9769d..2ca5f3e 100644 --- a/src/game/renders/opengl/r_map.pas +++ b/src/game/renders/opengl/r_map.pas @@ -296,11 +296,40 @@ implementation StubShotAnim.Invalidate; end; + procedure r_Map_FreeModel (i: Integer); + var a: Integer; d: TDirection; + begin + for d := TDirection.D_LEFT to TDirection.D_RIGHT do + begin + for a := A_STAND to A_LAST do + begin + if Models[i].anim[d, a].base <> nil then + Models[i].anim[d, a].base.Free; + if Models[i].anim[d, a].mask <> nil then + Models[i].anim[d, a].mask.Free; + Models[i].anim[d, a].base := nil; + Models[i].anim[d, a].mask := nil; + end; + end; + {$IFDEF ENABLE_GIBS} + if Models[i].gibs.base <> nil then + for a := 0 to High(Models[i].gibs.base) do + Models[i].gibs.base[a].Free; + if Models[i].gibs.mask <> nil then + for a := 0 to High(Models[i].gibs.mask) do + Models[i].gibs.mask[a].Free; + Models[i].gibs.base := nil; + Models[i].gibs.mask := nil; + Models[i].gibs.rect := nil; + {$ENDIF} + end; + procedure r_Map_LoadModel (i: Integer); var prefix: AnsiString; a: Integer; d: TDirection; m: ^TPlayerModelInfo; begin ASSERT(i < Length(Models)); ASSERT(i < Length(PlayerModelsArray)); + r_Map_FreeModel(i); m := @PlayerModelsArray[i]; prefix := m.FileName + ':TEXTURES/'; for d := TDirection.D_LEFT to TDirection.D_RIGHT do @@ -476,18 +505,9 @@ implementation end; end; end; - for d := TDirection.D_LEFT to TDirection.D_RIGHT do - begin - for a := A_STAND to A_LAST do - begin - if Models[i].anim[d, a].base <> nil then - Models[i].anim[d, a].base.Free; - if Models[i].anim[d, a].mask <> nil then - Models[i].anim[d, a].mask.Free; - Models[i].anim[d, a].base := nil; - Models[i].anim[d, a].mask := nil; - end; - end; + if Models <> nil then + for i := 0 to High(Models) do + r_Map_FreeModel(i); for i := MONSTER_DEMON to MONSTER_MAN do begin for j := 0 to ANIM_LAST do