Better login handling

This commit is contained in:
2026-06-08 14:23:55 -04:00
parent 8d88c88fa0
commit 536abb2231
4 changed files with 38 additions and 71 deletions

View File

@@ -282,8 +282,6 @@ LuaDefine(tangible_getclass, "tan",
LuaDefine(tangible_delete, "tan",
"|Delete the specified tangible."
"|"
"|This cannot be used to delete actor tangibles,"
"|To delete a actor, use tangible.deleteactor"
"|") {
LuaArg tanobj;
LuaDefStack LS(L, tanobj);
@@ -293,12 +291,7 @@ LuaDefine(tangible_delete, "tan",
luaL_error(L, "Not a tangible.");
return 0;
}
if (tan->is_controlled_) {
tan->delete_on_disconnect_ = true;
w->connection_redirect(tan, nullptr);
} else {
w->tangible_delete(tan->id());
}
w->tangible_delete(tan->id());
return LS.result();
}
@@ -324,10 +317,6 @@ LuaDefine(tangible_keepactor, "tan",
LuaDefStack LS(L, tanobj);
World *w = World::fetch_global_pointer(L);
Tangible *tan = w->tangible_get(LS, tanobj, true);
if ((tan == nullptr) || (!tan->is_controlled_)) {
luaL_error(L, "Tangible is not an actor.");
return 0;
}
tan->delete_on_disconnect_ = false;
return LS.result();
}
@@ -352,13 +341,11 @@ LuaDefine(tangible_redirect, "actor1, actor2",
World *w = World::fetch_global_pointer(L);
Tangible *actor1 = w->tangible_get(LS, lactor1, true);
Tangible *actor2 = w->tangible_get(LS, lactor2, true);
eng::string error = w->connection_redirect(actor1, actor2);
if (!error.empty()) {
eng::ostringstream oss;
oss << "redirect from " << actor1->id() << " to " << actor2->id() << " failed: " << error;
luaL_error(L, "%s", oss.str().c_str());
if (actor1->client_id_ == 0) {
luaL_error(L, "actor1 is not currently logged in.");
return LS.result();
}
w->connection_redirect(actor1, actor2);
return LS.result();
}
@@ -371,14 +358,8 @@ LuaDefine(tangible_forcedisconnect, "actor",
LuaDefStack LS(L, lactor1, lactor2);
World *w = World::fetch_global_pointer(L);
Tangible *actor = w->tangible_get(LS, lactor1, true);
if (actor->is_controlled_) {
eng::string error = w->connection_redirect(actor, nullptr);
if (!error.empty()) {
eng::ostringstream oss;
oss << "forcedisconnect of " << actor->id() << " failed: " << error;
luaL_error(L, "%s", oss.str().c_str());
return LS.result();
}
if (actor->client_id_ != 0) {
w->connection_delete(actor->client_id_);
}
return LS.result();
}