From d06706b346854cd73631aeb6297418ff82cabdf9 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Wed, 14 May 2014 14:33:50 +1000 Subject: Actually implement LSL script resetting, and some associated fixes. --- src/LuaSL/LuaSL_main.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/LuaSL/LuaSL_main.c') diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index 33b15c6..cb2726e 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c @@ -45,10 +45,27 @@ static script *findThem(gameGlobals *ourGlobals, const char *base, const char *t static void resetScript(script *victim) { -// gameGlobals *ourGlobals = victim->game; - - PD("Resetting %s", victim->fileName); - // TODO - now what? + gameGlobals *ourGlobals = victim->game; + script *me; + char buf[PATH_MAX]; + + PD("RESETTING %s", victim->name); + sendToChannel(ourGlobals, victim->SID, "quit()"); + eina_hash_del(ourGlobals->scripts, victim->SID, NULL); + eina_hash_del(ourGlobals->names, victim->fileName, NULL); + + // The old one will eventually die, create a new one. + me = calloc(1, sizeof(script)); + gettimeofday(&me->startTime, NULL); + strncpy(me->SID, victim->SID, sizeof(me->SID)); + strncpy(me->fileName, victim->fileName, sizeof(me->fileName)); + me->name = &me->fileName[sizeof(PACKAGE_DATA_DIR)]; + me->game = ourGlobals; + me->client = victim->client; + eina_hash_add(ourGlobals->scripts, me->SID, me); + eina_hash_add(ourGlobals->names, me->fileName, me); + sprintf(buf, "%s.lua.out", me->fileName); + newProc(buf, TRUE, me); } void scriptSendBack(void * data) -- cgit v1.1