Skip to content
Snippets Groups Projects
Unverified Commit 5133c6c9 authored by John FrostFox's avatar John FrostFox :fox:
Browse files

LUA savestate loading optimization with hashtables

parent 336be738
Branches
No related tags found
No related merge requests found
...@@ -69,16 +69,13 @@ void mobjnum_ht_linkedList_AddEntry (thinker_t* thinker) ...@@ -69,16 +69,13 @@ void mobjnum_ht_linkedList_AddEntry (thinker_t* thinker)
{ {
if (!currentEntry->thinker) if (!currentEntry->thinker)
{ {
// CONS_Printf("mobj not exists, adding\n");
currentEntry->thinker = thinker; currentEntry->thinker = thinker;
break; break;
} }
else else
{ {
// CONS_Printf("mobj exists, go next\n");
if (!currentEntry->next) if (!currentEntry->next)
{ {
// CONS_Printf("next not exists, create\n");
currentEntry->next = malloc(sizeof(mobjnum_linkedList)); currentEntry->next = malloc(sizeof(mobjnum_linkedList));
currentEntry->next->thinker = thinker; currentEntry->next->thinker = thinker;
currentEntry->next->next = NULL; currentEntry->next->next = NULL;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "doomstat.h" #include "doomstat.h"
#include "g_state.h" #include "g_state.h"
#include "p_savenetrb.h" //for P_FindNewPosition_Hashtable
#include "hashtable.h" #include "hashtable.h"
lua_State *gL = NULL; lua_State *gL = NULL;
...@@ -1455,7 +1456,7 @@ static UINT8 UnArchiveValue(int TABLESINDEX) ...@@ -1455,7 +1456,7 @@ static UINT8 UnArchiveValue(int TABLESINDEX)
LUA_PushUserdata(gL, &states[READUINT16(save_p)], META_STATE); LUA_PushUserdata(gL, &states[READUINT16(save_p)], META_STATE);
break; break;
case ARCH_MOBJ: case ARCH_MOBJ:
LUA_PushUserdata(gL, P_FindNewPosition(READUINT32(save_p)), META_MOBJ); LUA_PushUserdata(gL, P_FindNewPosition_Hashtable(READUINT32(save_p)), META_MOBJ);
break; break;
case ARCH_PLAYER: case ARCH_PLAYER:
LUA_PushUserdata(gL, &players[READUINT8(save_p)], META_PLAYER); LUA_PushUserdata(gL, &players[READUINT8(save_p)], META_PLAYER);
......
...@@ -24,5 +24,6 @@ extern char netDebugText[10000]; ...@@ -24,5 +24,6 @@ extern char netDebugText[10000];
// TODO: Find GPLv2 hashtable library and optimize the lua object loading code // TODO: Find GPLv2 hashtable library and optimize the lua object loading code
void P_GameStateFreeMemory(savestate_t* savestate); void P_GameStateFreeMemory(savestate_t* savestate);
void P_SaveGameState(savestate_t* savestate); void P_SaveGameState(savestate_t* savestate);
mobj_t *P_FindNewPosition_Hashtable(UINT32 oldposition);
boolean P_LoadGameState(const savestate_t* savestate); boolean P_LoadGameState(const savestate_t* savestate);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment