Repair buggy error-handling in makeclass/getclass

This commit is contained in:
2021-12-27 16:44:12 -05:00
parent 82381ada2e
commit 9517b3e004
5 changed files with 170 additions and 76 deletions

View File

@@ -80,10 +80,9 @@ LuaDefine(tangible_setclass, "tan,class",
LuaStack LS(L, tanobj, classname, classtab, mt);
World *w = World::fetch_global_pointer(L);
w->tangible_get(LS, tanobj);
if (LS.classname(classname) != "") {
LS.set(classtab, classname);
} else {
LS.getclass(classtab, classname);
std::string err = LS.getclass(classtab, classname);
if (err != "") {
luaL_error(L, "%s", err.c_str());
}
LS.getmetatable(mt, tanobj);
LS.rawset(mt, "__index", classtab);
@@ -140,13 +139,9 @@ LuaDefine(tangible_build, "configtable",
LS.checktable(config);
// Get the class of the new tangible.
LS.rawget(classname, config, "class");
if (LS.isnil(classname)) {
luaL_error(L, "must specify a class name");
} else if (LS.classname(classname) != "") {
LS.set(classtab, classname);
} else {
LS.getclass(classtab, classname);
std::string err = LS.getclass(classtab, classname);
if (err != "") {
luaL_error(L, "%s", err.c_str());
}
// Parse the initial animation step.