1
0
mirror of synced 2025-01-29 19:17:25 +01:00

背景のlua関係でメモリリークをしていた問題の修正 (#262)

This commit is contained in:
Takkkom 2022-06-21 12:30:16 +09:00 committed by GitHub
parent 52a0680bfa
commit 24b5152f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 9 deletions

View File

@ -66,6 +66,7 @@ namespace TJAPlayer3
private Lua LuaScript;
private LuaFunction LuaSetConstValues;
private LuaFunction LuaUpdateValues;
private LuaFunction LuaClearIn;
private LuaFunction LuaClearOut;
@ -95,6 +96,7 @@ namespace TJAPlayer3
}
}
LuaSetConstValues = LuaScript.GetFunction("setConstValues");
LuaUpdateValues = LuaScript.GetFunction("updateValues");
LuaClearIn = LuaScript.GetFunction("clearIn");
LuaClearOut = LuaScript.GetFunction("clearOut");
@ -104,15 +106,28 @@ namespace TJAPlayer3
}
public void Dispose()
{
var texs = Textures.ToArray();
for (int i = 0; i < texs.Length; i++)
List<CTexture> texs = new List<CTexture>();
foreach(var tex in Textures.Values)
{
TJAPlayer3.t安全にDisposeする(ref texs[i]);
texs.Add(tex);
}
for (int i = 0; i < texs.Count; i++)
{
var tex = texs[i];
TJAPlayer3.tテクスチャの解放(ref tex);
}
Textures.Clear();
LuaScript?.Dispose();
LuaSetConstValues?.Dispose();
LuaUpdateValues?.Dispose();
LuaClearIn?.Dispose();
LuaClearOut?.Dispose();
LuaInit?.Dispose();
LuaUpdate?.Dispose();
LuaDraw?.Dispose();
}
public void ClearIn(int player)
@ -146,12 +161,7 @@ namespace TJAPlayer3
if (LuaScript == null) return;
try
{
LuaScript["playerCount"] = TJAPlayer3.ConfigIni.nPlayerCount;
LuaScript["p1IsBlue"] = TJAPlayer3.P1IsBlue();
//LuaScript["isClear"] = new bool[4] { false, false, false, false };
//LuaScript["towerNightOpacity"] = 0;
//LuaScript["towerNightOpacity"] = (double)(255 * currentFloorPositionMax140);
LuaSetConstValues.Call(TJAPlayer3.ConfigIni.nPlayerCount, TJAPlayer3.P1IsBlue());
LuaUpdateValues.Call(TJAPlayer3.FPS.DeltaTime, TJAPlayer3.FPS.n現在のFPS, TJAPlayer3.stage演奏ドラム画面.bIsAlreadyCleared, 0);
LuaInit.Call();

View File

@ -1,8 +1,16 @@
local playerCount = 0
local p1IsBlue = false
local fps = 0
local deltaTime = 0
local isClear = { false, false }
local towerNightNum = 0
function setConstValues(_playerCount, _p1IsBlue)
playerCount = _playerCount
p1IsBlue = _p1IsBlue
end
function updateValues(_deltaTime, _fps, _isClear, _towerNightNum)
deltaTime = _deltaTime
fps = _fps