Some changes to make login.init more consistent.

This commit is contained in:
2026-06-09 17:36:58 -04:00
parent 7d6898edb3
commit 0b5c47d8c7
5 changed files with 38 additions and 35 deletions

View File

@@ -310,10 +310,13 @@ int64_t World::connection_create() {
assert(stack_is_clear());
int64_t id = id_global_pool_.get_one();
{
LuaVar database, classtab, mt, func;
LuaExtStack LS(state(), database, classtab, mt, func);
LuaVar database, classtab, config, mt, func;
LuaExtStack LS(state(), database, classtab, config, mt, func);
Tangible *tan = tangible_make(LS, database, id);
// A blank config table to pass to 'init'
LS.newtable(config);
// Set the login flags.
if (is_authoritative()) {
tan->client_id_ = id;
@@ -327,7 +330,9 @@ int64_t World::connection_create() {
if (is_authoritative()) {
LS.rawget(func, classtab, "init");
spawn(LS, id, id, func, 0, false);
lua_pushvalue(state(), database.index());
lua_pushvalue(state(), config.index());
spawn(LS, id, id, func, 2, false);
}
}
connections_.emplace(id, id);
@@ -977,13 +982,18 @@ void World::invoke_lua_source(int64_t actor_id, int64_t place_id, std::string_vi
if (errors.empty()) {
{
lua_State *L = state();
LuaVar lclass, lfunc;
LuaExtStack LS(L, lclass, lfunc);
LuaVar lclass, lfunc, tangibles, actor, config;
LuaExtStack LS(L, lclass, lfunc, tangibles, actor, config);
LS.rawget(tangibles, LuaRegistry, "tangibles");
LS.rawget(actor, tangibles, actor_id);
LS.newtable(config);
LS.getclass(lclass, "world");
if (LS.classname(lclass) != "") {
LS.rawget(lfunc, lclass, "init");
spawn(LS, actor_id, place_id, lfunc, 0, false);
lua_pushvalue(L, actor.index());
lua_pushvalue(L, config.index());
spawn(LS, actor_id, place_id, lfunc, 2, false);
}
}
run_scheduled_threads();