Skip to content

Commit 789181f

Browse files
make sarg explicit in lua songman chartkey functions and return nil instead of a null object
1 parent a5ec3ed commit 789181f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/SongManager.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,14 +2305,22 @@ class LunaSongManager: public Luna<SongManager>
23052305
}
23062306
static int GetSongByChartKey(T* p, lua_State *L)
23072307
{
2308-
Song* pSong = p->GetSongByChartkey(SArg(1));
2309-
pSong->PushSelf(L);
2308+
RString ck = SArg(1);
2309+
Song* pSong = p->GetSongByChartkey(ck);
2310+
if (pSong)
2311+
pSong->PushSelf(L);
2312+
else
2313+
lua_pushnil(L);
23102314
return 1;
23112315
}
23122316
static int GetStepsByChartKey(T* p, lua_State *L)
23132317
{
2314-
Steps* pSteps = p->GetStepsByChartkey(SArg(1));
2315-
pSteps->PushSelf(L);
2318+
RString ck = SArg(1);
2319+
Steps* pSteps = p->GetStepsByChartkey(ck);
2320+
if (pSteps)
2321+
pSteps->PushSelf(L);
2322+
else
2323+
lua_pushnil(L);
23162324
return 1;
23172325
}
23182326

0 commit comments

Comments
 (0)