Far stricter error checking in scripts.
This commit is contained in:
parent
885b1cea4a
commit
70da276a58
1 changed files with 102 additions and 85 deletions
187
singe/singe.c
187
singe/singe.c
|
@ -231,7 +231,7 @@ int32_t apiDaphneGetHeight(lua_State *L);
|
||||||
int32_t apiDaphneGetWidth(lua_State *L);
|
int32_t apiDaphneGetWidth(lua_State *L);
|
||||||
int32_t apiDaphneScreenshot(lua_State *L);
|
int32_t apiDaphneScreenshot(lua_State *L);
|
||||||
|
|
||||||
int32_t apiDebugPrint32_t(lua_State *L);
|
int32_t apiDebugPrint(lua_State *L);
|
||||||
|
|
||||||
int32_t apiDiscAudio(lua_State *L);
|
int32_t apiDiscAudio(lua_State *L);
|
||||||
int32_t apiDiscChangeSpeed(lua_State *L);
|
int32_t apiDiscChangeSpeed(lua_State *L);
|
||||||
|
@ -252,7 +252,7 @@ int32_t apiDiscStepForward(lua_State *L);
|
||||||
int32_t apiDiscStop(lua_State *L);
|
int32_t apiDiscStop(lua_State *L);
|
||||||
|
|
||||||
int32_t apiFontLoad(lua_State *L);
|
int32_t apiFontLoad(lua_State *L);
|
||||||
int32_t apiFontPrint32_t(lua_State *L);
|
int32_t apiFontPrint(lua_State *L);
|
||||||
int32_t apiFontQuality(lua_State *L);
|
int32_t apiFontQuality(lua_State *L);
|
||||||
int32_t apiFontSelect(lua_State *L);
|
int32_t apiFontSelect(lua_State *L);
|
||||||
int32_t apiFontToSprite(lua_State *L);
|
int32_t apiFontToSprite(lua_State *L);
|
||||||
|
@ -375,7 +375,7 @@ int32_t apiColorBackground(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "colorBackground", "%d %d %d %d", _global.colorBackground.r, _global.colorBackground.g, _global.colorBackground.b, _global.colorBackground.a);
|
luaTrace(L, "colorBackground", "%d %d %d %d", _global.colorBackground.r, _global.colorBackground.g, _global.colorBackground.b, _global.colorBackground.a);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "colorBackground", "Failed!");
|
luaDie(L, "colorBackground", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -412,7 +412,7 @@ int32_t apiColorForeground(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "colorForeground", "%d %d %d %d", _global.colorForeground.r, _global.colorForeground.g, _global.colorForeground.b, _global.colorForeground.a);
|
luaTrace(L, "colorForeground", "%d %d %d %d", _global.colorForeground.r, _global.colorForeground.g, _global.colorForeground.b, _global.colorForeground.a);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "colorForeground", "Failed!");
|
luaDie(L, "colorForeground", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -444,8 +444,7 @@ int32_t apiControllerGetAxis(lua_State *L) {
|
||||||
luaTrace(L, "controllerGetAxis", "%d %d %d", c, a, v);
|
luaTrace(L, "controllerGetAxis", "%d %d %d", c, a, v);
|
||||||
lua_pushinteger(L, v);
|
lua_pushinteger(L, v);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "controllerGetAxis", "Failed!");
|
luaDie(L, "controllerGetAxis", "Failed!");
|
||||||
lua_pushinteger(L, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -521,7 +520,7 @@ int32_t apiDiscAudio(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "discAudio", "%d %d", left, right);
|
luaTrace(L, "discAudio", "%d %d", left, right);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "discAudio", "Failed!");
|
luaDie(L, "discAudio", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -607,7 +606,7 @@ int32_t apiDiscSearch(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "discSearch", "%ld", frame);
|
luaTrace(L, "discSearch", "%ld", frame);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "discSearch", "Failed!");
|
luaDie(L, "discSearch", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -653,14 +652,14 @@ int32_t apiDiscSkipBackward(lua_State *L) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "discSkipBackward", "Failed! Disc is stopped.");
|
luaDie(L, "discSkipBackward", "Failed! Disc is stopped.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "discSkipBackward", "%ld", frame);
|
luaTrace(L, "discSkipBackward", "%ld", frame);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "discSkipBackward", "Failed!");
|
luaDie(L, "discSkipBackward", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -697,14 +696,14 @@ int32_t apiDiscSkipForward(lua_State *L) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "discSkipForward", "Failed! Disc is stopped.");
|
luaDie(L, "discSkipForward", "Failed! Disc is stopped.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "discSkipForward", "%ld", frame);
|
luaTrace(L, "discSkipForward", "%ld", frame);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "discSkipForward", "Failed!");
|
luaDie(L, "discSkipForward", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -737,7 +736,7 @@ int32_t apiDiscSkipToFrame(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "discSkipToFrame", "%ld", frame);
|
luaTrace(L, "discSkipToFrame", "%ld", frame);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "discSkipToFrame", "Failed!");
|
luaDie(L, "discSkipToFrame", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -836,7 +835,7 @@ int32_t apiFontLoad(lua_State *L) {
|
||||||
if (result >= 0) {
|
if (result >= 0) {
|
||||||
luaTrace(L, "fontLoad", "%s %d", name, result);
|
luaTrace(L, "fontLoad", "%s %d", name, result);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "fontLoad", "Failed!");
|
luaDie(L, "fontLoad", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, result);
|
lua_pushnumber(L, result);
|
||||||
|
@ -872,6 +871,10 @@ int32_t apiFontPrint(lua_State *L) {
|
||||||
case FONT_QUALITY_BLENDED:
|
case FONT_QUALITY_BLENDED:
|
||||||
textSurface = TTF_RenderText_Blended(_global.fontCurrent->font, message, _global.colorForeground);
|
textSurface = TTF_RenderText_Blended(_global.fontCurrent->font, message, _global.colorForeground);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
luaDie(L, "fontPrint", "Unknown font quality!");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!textSurface) {
|
if (!textSurface) {
|
||||||
luaDie(L, "fontPrint", "Font surface is null!");
|
luaDie(L, "fontPrint", "Font surface is null!");
|
||||||
|
@ -891,7 +894,7 @@ int32_t apiFontPrint(lua_State *L) {
|
||||||
if (textSurface) {
|
if (textSurface) {
|
||||||
luaTrace(L, "fontPrint", "%s", message);
|
luaTrace(L, "fontPrint", "%s", message);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "fontPrint", "Failed!");
|
luaDie(L, "fontPrint", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -913,7 +916,7 @@ int32_t apiFontQuality(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "fontQuality", "%d", _global.fontQuality);
|
luaTrace(L, "fontQuality", "%d", _global.fontQuality);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "fontQuality", "Failed!");
|
luaDie(L, "fontQuality", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -941,7 +944,7 @@ int32_t apiFontSelect(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "fontSelect", "%d", _global.fontCurrent->id);
|
luaTrace(L, "fontSelect", "%d", _global.fontCurrent->id);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "fontSelect", "Failed!");
|
luaDie(L, "fontSelect", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -971,7 +974,7 @@ int32_t apiFontUnload(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "fontUnload", "%d", id);
|
luaTrace(L, "fontUnload", "%d", id);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "fontUnload", "Failed!");
|
luaDie(L, "fontUnload", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1003,6 +1006,10 @@ int32_t apiFontToSprite(lua_State *L) {
|
||||||
case 3:
|
case 3:
|
||||||
sprite->surface = TTF_RenderText_Blended(_global.fontCurrent->font, message, _global.colorForeground);
|
sprite->surface = TTF_RenderText_Blended(_global.fontCurrent->font, message, _global.colorForeground);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
luaDie(L, "fontToSprite", "Unknown font quality!");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sprite->surface) {
|
if (!sprite->surface) {
|
||||||
|
@ -1020,7 +1027,7 @@ int32_t apiFontToSprite(lua_State *L) {
|
||||||
if (sprite->surface) {
|
if (sprite->surface) {
|
||||||
luaTrace(L, "fontToSprite", "%d %s", result, message);
|
luaTrace(L, "fontToSprite", "%d %s", result, message);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "fontToSprite", "Failed!");
|
luaDie(L, "fontToSprite", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushinteger(L, result);
|
lua_pushinteger(L, result);
|
||||||
|
@ -1092,7 +1099,7 @@ int32_t apiOverlayCircle(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "overlayCircle", "%d %d %d", xo, yo, ro);
|
luaTrace(L, "overlayCircle", "%d %d %d", xo, yo, ro);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "overlayCircle", "Failed!");
|
luaDie(L, "overlayCircle", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1197,7 +1204,7 @@ int32_t apiOverlayEllipse(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "overlayEllipse", "%d %d %d %d", x0o, y0o, x1o, y1o);
|
luaTrace(L, "overlayEllipse", "%d %d %d %d", x0o, y0o, x1o, y1o);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "overlayEllipse", "Failed!");
|
luaDie(L, "overlayEllipse", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1307,7 +1314,7 @@ int32_t apiOverlayLine(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "overlayLine", "%d %d %d %d", x1, y1, x2, y2);
|
luaTrace(L, "overlayLine", "%d %d %d %d", x1, y1, x2, y2);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "overlayLine", "Failed!");
|
luaDie(L, "overlayLine", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1339,7 +1346,7 @@ int32_t apiOverlayPlot(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "overlayPlot", "%d %d", x1, y1);
|
luaTrace(L, "overlayPlot", "%d %d", x1, y1);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "overlayPlot", "Failed!");
|
luaDie(L, "overlayPlot", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1351,6 +1358,7 @@ int32_t apiOverlayPrint(lua_State *L) {
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
int32_t length = 0;
|
int32_t length = 0;
|
||||||
|
bool result = false;
|
||||||
SDL_Rect src;
|
SDL_Rect src;
|
||||||
SDL_Rect dst;
|
SDL_Rect dst;
|
||||||
|
|
||||||
|
@ -1376,11 +1384,14 @@ int32_t apiOverlayPrint(lua_State *L) {
|
||||||
SDL_BlitSurface(_global.consoleFontSurface, &src, _global.overlay, &dst);
|
SDL_BlitSurface(_global.consoleFontSurface, &src, _global.overlay, &dst);
|
||||||
dst.x += _global.consoleFontWidth;
|
dst.x += _global.consoleFontWidth;
|
||||||
}
|
}
|
||||||
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!result) luaDie(L, "overlayPrint", "Failed!");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1415,7 +1426,7 @@ int32_t apiOverlaySetResolution(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "overlaySetResolution", "%d %d", x, y);
|
luaTrace(L, "overlaySetResolution", "%d %d", x, y);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "overlaySetResolution", "Failed!");
|
luaDie(L, "overlaySetResolution", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1444,7 +1455,7 @@ int32_t apiSoundLoad(lua_State *L) {
|
||||||
if (sound) {
|
if (sound) {
|
||||||
luaTrace(L, "soundLoad", "%d %s", result, name);
|
luaTrace(L, "soundLoad", "%d %s", result, name);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "soundLoad", "Failed!");
|
luaDie(L, "soundLoad", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, result);
|
lua_pushnumber(L, result);
|
||||||
|
@ -1457,6 +1468,7 @@ int32_t apiSoundPlay(lua_State *L) {
|
||||||
int32_t result = -1;
|
int32_t result = -1;
|
||||||
int32_t id = -1;
|
int32_t id = -1;
|
||||||
double d = 0;
|
double d = 0;
|
||||||
|
bool r = false;
|
||||||
SoundT *sound = NULL;
|
SoundT *sound = NULL;
|
||||||
|
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
|
@ -1466,20 +1478,21 @@ int32_t apiSoundPlay(lua_State *L) {
|
||||||
HASH_FIND_INT(_global.soundList, &id, sound);
|
HASH_FIND_INT(_global.soundList, &id, sound);
|
||||||
if (!sound) luaDie(L, "soundPlay", "No sound at index %d in apiSoundPlay.", id);
|
if (!sound) luaDie(L, "soundPlay", "No sound at index %d in apiSoundPlay.", id);
|
||||||
// Play it (can gracefully fail if we run out of channels)
|
// Play it (can gracefully fail if we run out of channels)
|
||||||
result = Mix_PlayChannel(-1, sound->chunk, 0);
|
r = Mix_PlayChannel(-1, sound->chunk, 0);
|
||||||
if (result >= 0) {
|
if (r >= 0) {
|
||||||
Mix_Volume(result, _global.effectsVolume * 2);
|
Mix_Volume(result, _global.effectsVolume * 2);
|
||||||
}
|
}
|
||||||
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sound) {
|
if (sound) {
|
||||||
luaTrace(L, "soundPlay", "%d", result);
|
luaTrace(L, "soundPlay", "%d", r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "soundPlay", "Failed!");
|
luaDie(L, "soundPlay", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, result);
|
lua_pushnumber(L, r);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1499,23 +1512,25 @@ int32_t apiSoundPause(lua_State *L) {
|
||||||
int32_t n = lua_gettop(L);
|
int32_t n = lua_gettop(L);
|
||||||
int32_t channel = -1;
|
int32_t channel = -1;
|
||||||
double d = 0;
|
double d = 0;
|
||||||
|
bool r = false;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
if (lua_isnumber(L, 1)) {
|
if (lua_isnumber(L, 1)) {
|
||||||
d = lua_tonumber(L, 1); channel = (int32_t)d;
|
d = lua_tonumber(L, 1); channel = (int32_t)d;
|
||||||
|
r = Mix_Playing(channel);
|
||||||
Mix_Pause(channel);
|
Mix_Pause(channel);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "soundPause", "%d", channel);
|
luaTrace(L, "soundPause", "%d %d", channel, r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "soundPause", "Failed!");
|
luaDie(L, "soundPause", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushboolean(L, result);
|
lua_pushboolean(L, r);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1536,23 +1551,25 @@ int32_t apiSoundResume(lua_State *L) {
|
||||||
int32_t n = lua_gettop(L);
|
int32_t n = lua_gettop(L);
|
||||||
int32_t channel = -1;
|
int32_t channel = -1;
|
||||||
double d = 0;
|
double d = 0;
|
||||||
|
bool r = false;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
if (lua_isnumber(L, 1)) {
|
if (lua_isnumber(L, 1)) {
|
||||||
d = lua_tonumber(L, 1); channel = (int32_t)d;
|
d = lua_tonumber(L, 1); channel = (int32_t)d;
|
||||||
|
r = Mix_Paused(channel);
|
||||||
Mix_Resume(channel);
|
Mix_Resume(channel);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "soundResume", "%d", channel);
|
luaTrace(L, "soundResume", "%d %d", channel, r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "soundResume", "Failed!");
|
luaDie(L, "soundResume", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushboolean(L, result);
|
lua_pushboolean(L, r);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1572,22 +1589,23 @@ int32_t apiSoundIsPlaying(lua_State *L) {
|
||||||
int32_t n = lua_gettop(L);
|
int32_t n = lua_gettop(L);
|
||||||
int32_t channel = -1;
|
int32_t channel = -1;
|
||||||
double d = 0;
|
double d = 0;
|
||||||
|
bool r = false;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
if (lua_isnumber(L, 1)) {
|
if (lua_isnumber(L, 1)) {
|
||||||
d = lua_tonumber(L, 1); channel = (int32_t)d;
|
d = lua_tonumber(L, 1); channel = (int32_t)d;
|
||||||
result = (bool)Mix_Playing(channel);
|
r = (bool)Mix_Playing(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "soundIsPlaying", "%d %d", channel, result);
|
luaTrace(L, "soundIsPlaying", "%d %d", channel, r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "soundIsPlaying", "Failed!");
|
luaDie(L, "soundIsPlaying", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushboolean(L, result);
|
lua_pushboolean(L, r);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1610,23 +1628,25 @@ int32_t apiSoundStop(lua_State *L) {
|
||||||
int32_t n = lua_gettop(L);
|
int32_t n = lua_gettop(L);
|
||||||
int32_t channel = -1;
|
int32_t channel = -1;
|
||||||
double d = 0;
|
double d = 0;
|
||||||
|
bool r = false;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
if (lua_isnumber(L, 1)) {
|
if (lua_isnumber(L, 1)) {
|
||||||
d = lua_tonumber(L, 1); channel = (int32_t)d;
|
d = lua_tonumber(L, 1); channel = (int32_t)d;
|
||||||
|
r = Mix_Playing(channel);
|
||||||
Mix_HaltChannel(channel);
|
Mix_HaltChannel(channel);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "soundStop", "%d", channel);
|
luaTrace(L, "soundStop", "%d %d", channel, r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "soundStop", "Failed!");
|
luaDie(L, "soundStop", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushboolean(L, result);
|
lua_pushboolean(L, r);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1657,15 +1677,15 @@ int32_t apiSoundSetVolume(lua_State *L) {
|
||||||
luaDie(L, "soundSetVolume", "Invalid sound volume value.");
|
luaDie(L, "soundSetVolume", "Invalid sound volume value.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "soundSetVolume", "%d", _global.effectsVolume);
|
luaTrace(L, "soundSetVolume", "%d", _global.effectsVolume);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "soundSetVolume", "Failed!");
|
luaDie(L, "soundSetVolume", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushboolean(L, result);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1726,7 +1746,7 @@ int32_t apiSoundUnload(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "soundUnload", "%d", id);
|
luaTrace(L, "soundUnload", "%d", id);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "soundUnload", "Failed!");
|
luaDie(L, "soundUnload", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1760,7 +1780,7 @@ int32_t apiSpriteDraw(lua_State *L) {
|
||||||
if (id >= 0) {
|
if (id >= 0) {
|
||||||
luaTrace(L, "spriteDraw", "%d %d %d %d %d", id, dest.x, dest.y, dest.w, dest.h);
|
luaTrace(L, "spriteDraw", "%d %d %d %d %d", id, dest.x, dest.y, dest.w, dest.h);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "spriteDraw", "Failed!");
|
luaDie(L, "spriteDraw", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1787,7 +1807,7 @@ int32_t apiSpriteGetHeight(lua_State *L) {
|
||||||
if (result >= 0) {
|
if (result >= 0) {
|
||||||
luaTrace(L, "spriteGetHeight", "%d", result);
|
luaTrace(L, "spriteGetHeight", "%d", result);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "spriteGetHeight", "Failed!");
|
luaDie(L, "spriteGetHeight", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushinteger(L, result);
|
lua_pushinteger(L, result);
|
||||||
|
@ -1815,7 +1835,7 @@ int32_t apiSpriteGetWidth(lua_State *L) {
|
||||||
if (result >= 0) {
|
if (result >= 0) {
|
||||||
luaTrace(L, "spriteGetWidth", "%d", result);
|
luaTrace(L, "spriteGetWidth", "%d", result);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "spriteGetWidth", "Failed!");
|
luaDie(L, "spriteGetWidth", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushinteger(L, result);
|
lua_pushinteger(L, result);
|
||||||
|
@ -1846,7 +1866,7 @@ int32_t apiSpriteLoad(lua_State *L) {
|
||||||
if (sprite->surface) {
|
if (sprite->surface) {
|
||||||
luaTrace(L, "spriteLoad", "%d %s", result, name);
|
luaTrace(L, "spriteLoad", "%d %s", result, name);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "spriteLoad", "Failed!");
|
luaDie(L, "spriteLoad", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, result);
|
lua_pushnumber(L, result);
|
||||||
|
@ -1877,7 +1897,7 @@ int32_t apiSpriteUnload(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "spriteUnload", "%d", id);
|
luaTrace(L, "spriteUnload", "%d", id);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "spriteUnload", "Failed!");
|
luaDie(L, "spriteUnload", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1934,7 +1954,7 @@ int32_t apiVideoDraw(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoDraw", "%d %d %d %d %d %ld", id, dest.x, dest.y, dest.x + dest.w, dest.y + dest.h, frame);
|
luaTrace(L, "videoDraw", "%d %d %d %d %d %ld", id, dest.x, dest.y, dest.x + dest.w, dest.y + dest.h, frame);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoDraw", "Failed!");
|
luaDie(L, "videoDraw", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1963,7 +1983,7 @@ int32_t apiVideoGetFrame(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoGetFrame", "%d %ld", id, r);
|
luaTrace(L, "videoGetFrame", "%d %ld", id, r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoGetFrame", "Failed!");
|
luaDie(L, "videoGetFrame", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, r);
|
lua_pushnumber(L, r);
|
||||||
|
@ -1993,7 +2013,7 @@ int32_t apiVideoGetFrameCount(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoGetFrameCount", "%d %ld", id, r);
|
luaTrace(L, "videoGetFrameCount", "%d %ld", id, r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoGetFrameCount", "Failed!");
|
luaDie(L, "videoGetFrameCount", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, r);
|
lua_pushnumber(L, r);
|
||||||
|
@ -2023,7 +2043,7 @@ int32_t apiVideoGetHeight(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoGetHeight", "%d %d", id, r);
|
luaTrace(L, "videoGetHeight", "%d %d", id, r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoGetHeight", "Failed!");
|
luaDie(L, "videoGetHeight", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, r);
|
lua_pushnumber(L, r);
|
||||||
|
@ -2054,7 +2074,7 @@ int32_t apiVideoGetVolume(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoGetVolume", "%d %d %d", id, left, right);
|
luaTrace(L, "videoGetVolume", "%d %d %d", id, left, right);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoGetVolume", "Failed!");
|
luaDie(L, "videoGetVolume", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, left);
|
lua_pushnumber(L, left);
|
||||||
|
@ -2085,7 +2105,7 @@ int32_t apiVideoGetWidth(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoGetWidth", "%d %d", id, r);
|
luaTrace(L, "videoGetWidth", "%d %d", id, r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoGetWidth", "Failed!");
|
luaDie(L, "videoGetWidth", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, r);
|
lua_pushnumber(L, r);
|
||||||
|
@ -2115,7 +2135,7 @@ int32_t apiVideoIsPlaying(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoIsPlaying", "%d %d", id, r);
|
luaTrace(L, "videoIsPlaying", "%d %d", id, r);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoIsPlaying", "Failed!");
|
luaDie(L, "videoIsPlaying", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushnumber(L, r);
|
lua_pushnumber(L, r);
|
||||||
|
@ -2153,15 +2173,16 @@ int32_t apiVideoLoad(lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result >= 0) {
|
if (result >= 0) {
|
||||||
luaTrace(L, "fontVideo", "%s %s %d", name, data, result);
|
luaTrace(L, "videoLoad", "%s %s %d", name, data, result);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "fontVideo", "Failed!");
|
luaDie(L, "videoLoad", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
lua_pushnumber(L, result);
|
lua_pushnumber(L, result);
|
||||||
return 1;}
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t apiVideoPause(lua_State *L) {
|
int32_t apiVideoPause(lua_State *L) {
|
||||||
|
@ -2185,7 +2206,7 @@ int32_t apiVideoPause(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoPause", "%d", id);
|
luaTrace(L, "videoPause", "%d", id);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoPause", "Failed!");
|
luaDie(L, "videoPause", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2213,7 +2234,7 @@ int32_t apiVideoPlay(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoPlay", "%d", id);
|
luaTrace(L, "videoPlay", "%d", id);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoPlay", "Failed!");
|
luaDie(L, "videoPlay", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2245,7 +2266,7 @@ int32_t apiVideoSeek(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoSeek", "%d %ld", id, frame);
|
luaTrace(L, "videoSeek", "%d %ld", id, frame);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoSeek", "Failed!");
|
luaDie(L, "videoSeek", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2285,7 +2306,7 @@ int32_t apiVideoSetVolume(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoSetVolume", "%d", id, left, right);
|
luaTrace(L, "videoSetVolume", "%d", id, left, right);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoSetVolume", "Failed!");
|
luaDie(L, "videoSetVolume", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2316,7 +2337,7 @@ int32_t apiVideoUnload(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "videoUnload", "%d", id);
|
luaTrace(L, "videoUnload", "%d", id);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "videoUnload", "Failed!");
|
luaDie(L, "videoUnload", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2356,16 +2377,14 @@ int32_t apiVldpGetPixel(lua_State *L) {
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "vldpGetPixel", "%d %d %d %d %d", rect.x, rect.y, pixel[2], pixel[1], pixel[0]);
|
luaTrace(L, "vldpGetPixel", "%d %d %d %d %d", rect.x, rect.y, pixel[2], pixel[1], pixel[0]);
|
||||||
lua_pushinteger(L, (int32_t)pixel[2]); // R
|
|
||||||
lua_pushinteger(L, (int32_t)pixel[1]); // G
|
|
||||||
lua_pushinteger(L, (int32_t)pixel[0]); // B
|
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "vldpGetPixel", "Failed!");
|
luaDie(L, "vldpGetPixel", "Failed!");
|
||||||
lua_pushinteger(L, -1);
|
|
||||||
lua_pushinteger(L, -1);
|
|
||||||
lua_pushinteger(L, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lua_pushinteger(L, (int32_t)pixel[2]); // R
|
||||||
|
lua_pushinteger(L, (int32_t)pixel[1]); // G
|
||||||
|
lua_pushinteger(L, (int32_t)pixel[0]); // B
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2426,7 +2445,7 @@ int32_t apiKeyboardSetMode(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "keyboardSetMode", "%d", _global.keyboardMode);
|
luaTrace(L, "keyboardSetMode", "%d", _global.keyboardMode);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "keyboardSetMode", "Failed!");
|
luaDie(L, "keyboardSetMode", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2485,7 +2504,7 @@ int32_t apiMouseSetMode(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "mouseSetMode", "%d", _global.mouseMode);
|
luaTrace(L, "mouseSetMode", "%d", _global.mouseMode);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "mouseSetMode", "Failed!");
|
luaDie(L, "mouseSetMode", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushboolean(L, result);
|
lua_pushboolean(L, result);
|
||||||
|
@ -2513,14 +2532,13 @@ int32_t apiMouseGetPosition(lua_State *L) {
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "mouseGetPosition", "%d %d %d", m, x, y);
|
luaTrace(L, "mouseGetPosition", "%d %d %d", m, x, y);
|
||||||
lua_pushinteger(L, x);
|
|
||||||
lua_pushinteger(L, y);
|
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "mouseGetPosition", "Failed!");
|
luaDie(L, "mouseGetPosition", "Failed!");
|
||||||
lua_pushinteger(L, -1);
|
|
||||||
lua_pushinteger(L, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lua_pushinteger(L, x);
|
||||||
|
lua_pushinteger(L, y);
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2576,7 +2594,7 @@ int32_t apiScriptExecute(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "scriptExecute", "Success.");
|
luaTrace(L, "scriptExecute", "Success.");
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "scriptExecute", "Failed!");
|
luaDie(L, "scriptExecute", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2605,7 +2623,7 @@ int32_t apiScriptPush(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "scriptExecute", "Success.");
|
luaTrace(L, "scriptExecute", "Success.");
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "scriptExecute", "Failed!");
|
luaDie(L, "scriptExecute", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2646,7 +2664,7 @@ int32_t apiSingeSetPauseFlag(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "singeSetPauseFlag", "%d", _global.pauseState);
|
luaTrace(L, "singeSetPauseFlag", "%d", _global.pauseState);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "singeSetPauseFlag", "Failed!");
|
luaDie(L, "singeSetPauseFlag", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2717,10 +2735,9 @@ int32_t apiSingeSetGameName(lua_State *L) {
|
||||||
if (result) {
|
if (result) {
|
||||||
luaTrace(L, "singeSetGameName", "%s", thisName);
|
luaTrace(L, "singeSetGameName", "%s", thisName);
|
||||||
} else {
|
} else {
|
||||||
luaTrace(L, "singeSetGameName", "Failed!");
|
luaDie(L, "singeSetGameName", "Failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushboolean(L, result);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue