mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Check if enum-string conversions succeed in love.audio.get/setDistanceModel (bug #347)
This commit is contained in:
@@ -241,7 +241,8 @@ namespace audio
|
|||||||
{
|
{
|
||||||
const char *modelStr = luaL_checkstring(L, 1);
|
const char *modelStr = luaL_checkstring(L, 1);
|
||||||
Audio::DistanceModel distanceModel;
|
Audio::DistanceModel distanceModel;
|
||||||
Audio::getConstant(modelStr, distanceModel);
|
if (!Audio::getConstant(modelStr, distanceModel))
|
||||||
|
return luaL_error(L, "Invalid distance model: %s", modelStr);
|
||||||
instance->setDistanceModel(distanceModel);
|
instance->setDistanceModel(distanceModel);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -250,7 +251,8 @@ namespace audio
|
|||||||
{
|
{
|
||||||
Audio::DistanceModel distanceModel = instance->getDistanceModel();
|
Audio::DistanceModel distanceModel = instance->getDistanceModel();
|
||||||
const char *modelStr;
|
const char *modelStr;
|
||||||
Audio::getConstant(distanceModel, modelStr);
|
if (!Audio::getConstant(distanceModel, modelStr))
|
||||||
|
return 0;
|
||||||
lua_pushstring(L, modelStr);
|
lua_pushstring(L, modelStr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user