From 36687ab9865bd0142cd40c65881826cf54992b3d Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 7 Oct 2012 15:26:09 +0000 Subject: [PATCH] Lunatic-m32: take over load path. git-svn-id: https://svn.eduke32.com/eduke32@3059 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/cache1d.c | 12 ++++++++++ polymer/eduke32/source/lunatic/defs_m32.ilua | 23 +++++++++++++++++++ polymer/eduke32/source/lunatic/dynsymlist_m32 | 4 ++++ 3 files changed, 39 insertions(+) diff --git a/polymer/eduke32/build/src/cache1d.c b/polymer/eduke32/build/src/cache1d.c index 392e6cc88..fa375f0e8 100644 --- a/polymer/eduke32/build/src/cache1d.c +++ b/polymer/eduke32/build/src/cache1d.c @@ -263,6 +263,18 @@ static searchpath_t *searchpathhead = NULL; static size_t maxsearchpathlen = 0; int32_t pathsearchmode = 0; +char *listsearchpath(int32_t initp) +{ + static searchpath_t *sp; + + if (initp) + sp = searchpathhead; + else if (sp != NULL) + sp = sp->next; + + return sp ? sp->path : NULL; +} + int32_t addsearchpath(const char *p) { struct stat st; diff --git a/polymer/eduke32/source/lunatic/defs_m32.ilua b/polymer/eduke32/source/lunatic/defs_m32.ilua index 9a648825e..4dd362d44 100644 --- a/polymer/eduke32/source/lunatic/defs_m32.ilua +++ b/polymer/eduke32/source/lunatic/defs_m32.ilua @@ -29,3 +29,26 @@ sectorsofbunch = defs_c.sectorsofbunch getbunch = defs_c.getbunch hitscan = defs_c.hitscan + + +--== Mapster32-specific initialization + +ffi.cdef "char *listsearchpath(int32_t initp);" + +-- Add the search path directories to the Lua load path. +local initp = 1 +while (true) do + local sp_c = ffiC.listsearchpath(initp) + + if (sp_c == nil) then + break + end + + local sp = ffi.string(sp_c) + assert(sp:sub(-1)=='/') + package.path = sp..'?.lua;'..package.path + + initp = 0 +end + +--print('Lua load path: '..package.path) diff --git a/polymer/eduke32/source/lunatic/dynsymlist_m32 b/polymer/eduke32/source/lunatic/dynsymlist_m32 index 526d3342a..125db55df 100644 --- a/polymer/eduke32/source/lunatic/dynsymlist_m32 +++ b/polymer/eduke32/source/lunatic/dynsymlist_m32 @@ -32,4 +32,8 @@ hitscan; rotatesprite; gethitickms; + + + +listsearchpath; };