Lunatic: Fix compilation of C++ build, but not starting up yet.

BUILD_LUNATIC.

git-svn-id: https://svn.eduke32.com/eduke32@4286 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-01-31 21:13:03 +00:00
parent 60612d07f0
commit 842cce37b7
10 changed files with 56 additions and 14 deletions

View file

@ -470,6 +470,12 @@ ifneq ($(LUNATIC),0)
# chains! # chains!
override DISABLEINLINING=1 override DISABLEINLINING=1
ifneq ($(CPLUSPLUS),0)
# FIXME: Lunatic C++ doesn't build because otherwise it doesn't find
# INT32_MIN and the like.
BASECFLAGS+= -D__STDC_LIMIT_MACROS
endif
BASECOMMONFLAGS+= -I$(MAKEFILE_COMMON_DIR)/source/lunatic -DLUNATIC BASECOMMONFLAGS+= -I$(MAKEFILE_COMMON_DIR)/source/lunatic -DLUNATIC
ifneq ($(USE_LUAJIT_2_1),0) ifneq ($(USE_LUAJIT_2_1),0)
BASECOMMONFLAGS+= -DUSE_LUAJIT_2_1 BASECOMMONFLAGS+= -DUSE_LUAJIT_2_1

View file

@ -3,12 +3,20 @@
#ifndef ENGINE_LUNATIC_H_ #ifndef ENGINE_LUNATIC_H_
#define ENGINE_LUNATIC_H_ #define ENGINE_LUNATIC_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_LUAJIT_2_1 #ifdef USE_LUAJIT_2_1
# include <luajit-2.1/lua.h> # include <luajit-2.1/lua.h>
#else #else
# include <luajit-2.0/lua.h> # include <luajit-2.0/lua.h>
#endif #endif
#ifdef __cplusplus
}
#endif
typedef struct typedef struct
{ {
@ -25,9 +33,9 @@ void L_CheckAndRegisterFunction(lua_State *L, void *regkeyaddr);
int L_HandleError(lua_State *L, int errcode, void (*ErrorPrintFunc)(const char *)); int L_HandleError(lua_State *L, int errcode, void (*ErrorPrintFunc)(const char *));
// Callback on Lua error. <str> must be used immediately or strdup'd. // Callback on Lua error. <str> must be used immediately or strdup'd.
void (*L_ErrorFunc)(const char *str); extern void (*L_ErrorFunc)(const char *str);
// Out-of-memory handler, supposed to terminate the host program. // Out-of-memory handler, supposed to terminate the host program.
void (*L_OutOfMemFunc)(void); extern void (*L_OutOfMemFunc)(void);
int L_CreateState(L_State *estate, const char *name, void (*StateSetupFunc)(lua_State *)); int L_CreateState(L_State *estate, const char *name, void (*StateSetupFunc)(lua_State *));
void L_DestroyState(L_State *estate); void L_DestroyState(L_State *estate);

View file

@ -1,5 +1,9 @@
/* The Lunatic Interpreter, part of EDuke32. Common, engine-side stuff. */ /* The Lunatic Interpreter, part of EDuke32. Common, engine-side stuff. */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_LUAJIT_2_1 #ifdef USE_LUAJIT_2_1
# include <luajit-2.1/lua.h> # include <luajit-2.1/lua.h>
# include <luajit-2.1/lualib.h> # include <luajit-2.1/lualib.h>
@ -10,6 +14,10 @@
# include <luajit-2.0/lauxlib.h> # include <luajit-2.0/lauxlib.h>
#endif #endif
#ifdef __cplusplus
}
#endif
#include "cache1d.h" #include "cache1d.h"
#include "osd.h" #include "osd.h"
@ -66,7 +74,7 @@ static int32_t read_whole_file(const char *fn, char **retbufptr)
if (flen == 0) if (flen == 0)
return 5; return 5;
buf = Bmalloc(flen+1); buf = (char *)Bmalloc(flen+1);
if (!buf) if (!buf)
{ {
kclose(fid); kclose(fid);

View file

@ -9620,7 +9620,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
#ifdef LUNATIC #ifdef LUNATIC
g_argv = argv; g_argv = argv;
g_elModules = Bcalloc(argc+1, sizeof(char *)); g_elModules = (const char **)Bcalloc(argc+1, sizeof(char *));
Bassert(g_elModules); Bassert(g_elModules);
#endif #endif
ud.fta_on = 1; ud.fta_on = 1;
@ -10727,7 +10727,7 @@ LUNATIC_EXTERN void El_SetCON(const char *conluacode)
{ {
int32_t slen = Bstrlen(conluacode); int32_t slen = Bstrlen(conluacode);
g_elCON = Bmalloc(slen); g_elCON = (char *)Bmalloc(slen);
if (g_elCON == NULL) if (g_elCON == NULL)
G_GameExit("OUT OF MEMORY in El_SetCON!"); G_GameExit("OUT OF MEMORY in El_SetCON!");

View file

@ -29,7 +29,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define _gamevars_c_ #define _gamevars_c_
#if !defined LUNATIC #ifdef LUNATIC
int32_t g_noResetVars;
LUNATIC_CB void (*A_ResetVars)(int32_t iActor);
#else
# include "gamestructures.c" # include "gamestructures.c"
extern int32_t OSD_errors; extern int32_t OSD_errors;

View file

@ -112,8 +112,8 @@ void Gv_ResetVars(void);
int32_t Gv_ReadSave(int32_t fil,int32_t newbehav); int32_t Gv_ReadSave(int32_t fil,int32_t newbehav);
void Gv_WriteSave(FILE *fil,int32_t newbehav); void Gv_WriteSave(FILE *fil,int32_t newbehav);
#else #else
int32_t g_noResetVars; extern int32_t g_noResetVars;
LUNATIC_CB void (*A_ResetVars)(int32_t iActor); extern LUNATIC_CB void (*A_ResetVars)(int32_t iActor);
#endif #endif
void Gv_ResetSystemDefaults(void); void Gv_ResetSystemDefaults(void);

View file

@ -5,6 +5,10 @@
#include <errno.h> #include <errno.h>
#include <string.h> // strerror #include <string.h> // strerror
#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_LUAJIT_2_1 #ifdef USE_LUAJIT_2_1
# include <luajit-2.1/lualib.h> # include <luajit-2.1/lualib.h>
# include <luajit-2.1/lauxlib.h> # include <luajit-2.1/lauxlib.h>
@ -13,6 +17,10 @@
# include <luajit-2.0/lauxlib.h> # include <luajit-2.0/lauxlib.h>
#endif #endif
#ifdef __cplusplus
}
#endif
#include "build.h" // printext256 #include "build.h" // printext256
#include "lunatic_game.h" #include "lunatic_game.h"
@ -56,9 +64,18 @@ static uint8_t g_tweakTracebackMsg = 0;
static int32_t SetEvent_CF(lua_State *L); static int32_t SetEvent_CF(lua_State *L);
static int32_t SetActor_CF(lua_State *L); static int32_t SetActor_CF(lua_State *L);
#ifdef __cplusplus
extern "C" {
#endif
// in lpeg.o // in lpeg.o
extern int luaopen_lpeg(lua_State *L); extern int luaopen_lpeg(lua_State *L);
#ifdef __cplusplus
}
#endif
typedef struct { typedef struct {
uint32_t x, y, z, c; uint32_t x, y, z, c;
@ -103,7 +120,7 @@ void El_PrintTimes(void)
const int32_t baselen = Bstrlen(basefn); const int32_t baselen = Bstrlen(basefn);
const int32_t addnlen = Bstrlen(".actors.csv"); // MUST equal that of ".events.csv" const int32_t addnlen = Bstrlen(".actors.csv"); // MUST equal that of ".events.csv"
char *fullfn = Bmalloc(baselen + addnlen + 1); char *fullfn = (char *)Bmalloc(baselen + addnlen + 1);
BFILE *outf; BFILE *outf;
if (fullfn == NULL) if (fullfn == NULL)
@ -252,7 +269,7 @@ LUNATIC_EXTERN void El_OnError(const char *str)
// Otherwise, allocate storage for the potentially clipped error string... // Otherwise, allocate storage for the potentially clipped error string...
if (nl) if (nl)
{ {
errstr = Bmalloc(nl-str+1); errstr = (char *)Bmalloc(nl-str+1);
if (errstr) if (errstr)
{ {
Bmemcpy(errstr, str, nl-str); Bmemcpy(errstr, str, nl-str);
@ -413,7 +430,7 @@ DEFINE_VOID_CFUNC(G_ShowView, LARG(1), LARG(2), LARG(3), LARG(4), LARG(5), LARG(
#define CFUNC_REG(Name) { #Name, Name##_CF } #define CFUNC_REG(Name) { #Name, Name##_CF }
struct { const char *name; lua_CFunction func; } cfuncs[] = static struct { const char *name; lua_CFunction func; } cfuncs[] =
{ {
CFUNC_REG(P_AddWeaponMaybeSwitchI), CFUNC_REG(P_AddWeaponMaybeSwitchI),
CFUNC_REG(P_CheckWeaponI), CFUNC_REG(P_CheckWeaponI),

View file

@ -42,7 +42,7 @@ int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t iActor, int32_t
extern int8_t el_addNewErrors; // add new errors to display? extern int8_t el_addNewErrors; // add new errors to display?
void El_OnError(const char *str); void El_OnError(const char *str);
int32_t (*El_RestoreGamevars)(const char *savecode); extern int32_t (*El_RestoreGamevars)(const char *savecode);
static inline int32_t El_HaveEvent(int32_t eventidx) { return g_elEvents[eventidx]!=0; } static inline int32_t El_HaveEvent(int32_t eventidx) { return g_elEvents[eventidx]!=0; }
static inline int32_t El_HaveActor(int32_t actortile) { return g_elActors[actortile].haveit!=0; } static inline int32_t El_HaveActor(int32_t actortile) { return g_elActors[actortile].haveit!=0; }

View file

@ -1796,7 +1796,7 @@ static int32_t El_ReadSaveCode(int32_t fil)
if (slen > 0) if (slen > 0)
{ {
char *svcode = Bmalloc(slen+1); char *svcode = (char *)Bmalloc(slen+1);
if (svcode == NULL) if (svcode == NULL)
G_GameExit("OUT OF MEMORY in doloadplayer2()."); G_GameExit("OUT OF MEMORY in doloadplayer2().");

View file

@ -93,7 +93,7 @@ void G_Util_PtrToIdx(void *ptr, int32_t count, const void *base, int32_t mode);
void G_Util_PtrToIdx2(void *ptr, int32_t count, size_t stride, const void *base, int32_t mode); void G_Util_PtrToIdx2(void *ptr, int32_t count, size_t stride, const void *base, int32_t mode);
#ifdef LUNATIC #ifdef LUNATIC
const char *(*El_SerializeGamevars)(int32_t *slenptr, int32_t levelnum); extern const char *(*El_SerializeGamevars)(int32_t *slenptr, int32_t levelnum);
#endif #endif
#endif #endif