mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
Lunatic: beginning to glue things together. Introducing LUNATIC_ONLY.
git-svn-id: https://svn.eduke32.com/eduke32@3343 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4ad4f9ebb7
commit
80ee967b8e
9 changed files with 233 additions and 120 deletions
|
@ -421,7 +421,7 @@ ifneq ($(LUNATIC),0)
|
||||||
else
|
else
|
||||||
BASECOMMONFLAGS+= -I/usr/local/include/luajit-2.0
|
BASECOMMONFLAGS+= -I/usr/local/include/luajit-2.0
|
||||||
endif
|
endif
|
||||||
BASECOMMONFLAGS+= -I$(SRC)/lunatic -DLUNATIC
|
BASECOMMONFLAGS+= -I$(SRC)/lunatic -DLUNATIC -DLUNATIC_ONLY
|
||||||
|
|
||||||
ifeq ($(PLATFORM),WINDOWS)
|
ifeq ($(PLATFORM),WINDOWS)
|
||||||
BASELIBS+= -lluajit
|
BASELIBS+= -lluajit
|
||||||
|
|
|
@ -9488,7 +9488,7 @@ static void G_Cleanup(void)
|
||||||
if (g_sounds[i].filename != NULL) Bfree(g_sounds[i].filename);
|
if (g_sounds[i].filename != NULL) Bfree(g_sounds[i].filename);
|
||||||
if (g_sounds[i].filename1 != NULL) Bfree(g_sounds[i].filename1);
|
if (g_sounds[i].filename1 != NULL) Bfree(g_sounds[i].filename1);
|
||||||
}
|
}
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
if (label != NULL && label != (char *)&sprite[0]) Bfree(label);
|
if (label != NULL && label != (char *)&sprite[0]) Bfree(label);
|
||||||
if (labelcode != NULL && labelcode != (int32_t *)§or[0]) Bfree(labelcode);
|
if (labelcode != NULL && labelcode != (int32_t *)§or[0]) Bfree(labelcode);
|
||||||
if (script != NULL) Bfree(script);
|
if (script != NULL) Bfree(script);
|
||||||
|
@ -9500,6 +9500,7 @@ static void G_Cleanup(void)
|
||||||
hash_free(&h_arrays);
|
hash_free(&h_arrays);
|
||||||
hash_free(&h_labels);
|
hash_free(&h_labels);
|
||||||
hash_free(&h_gamefuncs);
|
hash_free(&h_gamefuncs);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -9532,15 +9533,18 @@ void G_Shutdown(void)
|
||||||
|
|
||||||
static void G_CompileScripts(void)
|
static void G_CompileScripts(void)
|
||||||
{
|
{
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
int32_t psm = pathsearchmode;
|
int32_t psm = pathsearchmode;
|
||||||
|
|
||||||
label = (char *)&sprite[0]; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816
|
label = (char *)&sprite[0]; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816
|
||||||
labelcode = (int32_t *)§or[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240
|
labelcode = (int32_t *)§or[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240
|
||||||
labeltype = (int32_t *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536
|
labeltype = (int32_t *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536
|
||||||
|
#endif
|
||||||
|
|
||||||
if (g_scriptNamePtr != NULL)
|
if (g_scriptNamePtr != NULL)
|
||||||
Bcorrectfilename(g_scriptNamePtr,0);
|
Bcorrectfilename(g_scriptNamePtr,0);
|
||||||
|
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
// if we compile for a V7 engine wall[] should be used for label names since it's bigger
|
// if we compile for a V7 engine wall[] should be used for label names since it's bigger
|
||||||
pathsearchmode = 1;
|
pathsearchmode = 1;
|
||||||
|
|
||||||
|
@ -9575,6 +9579,7 @@ static void G_CompileScripts(void)
|
||||||
|
|
||||||
VM_OnEvent(EVENT_INIT, -1, -1, -1, 0);
|
VM_OnEvent(EVENT_INIT, -1, -1, -1, 0);
|
||||||
pathsearchmode = psm;
|
pathsearchmode = psm;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void G_CheckGametype(void)
|
static inline void G_CheckGametype(void)
|
||||||
|
@ -10530,20 +10535,18 @@ int32_t app_main(int32_t argc, const char **argv)
|
||||||
OSD_Exec("autoexec.cfg");
|
OSD_Exec("autoexec.cfg");
|
||||||
|
|
||||||
#ifdef LUNATIC
|
#ifdef LUNATIC
|
||||||
i = El_CreateState(&g_ElState, "test");
|
if ((i = El_CreateState(&g_ElState, "test")))
|
||||||
if (i)
|
|
||||||
{
|
{
|
||||||
initprintf("Lunatic: Error initializing global ELua state (code %d)\n", i);
|
initprintf("Lunatic: Error initializing global ELua state (code %d)\n", i);
|
||||||
}
|
}
|
||||||
else
|
else if ((i = L_RunOnce(&g_ElState, "defs.ilua")))
|
||||||
{
|
{
|
||||||
i = L_RunOnce(&g_ElState, "defs.ilua");
|
initprintf("Lunatic: Error preparing global ELua state (code %d)\n", i);
|
||||||
if (i)
|
El_DestroyState(&g_ElState);
|
||||||
{
|
|
||||||
initprintf("Lunatic: Error preparing global ELua state (code %d)\n", i);
|
|
||||||
El_DestroyState(&g_ElState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i)
|
||||||
|
G_GameExit("Failure setting up Lunatic!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (g_networkMode != NET_DEDICATED_SERVER)
|
if (g_networkMode != NET_DEDICATED_SERVER)
|
||||||
|
|
|
@ -2057,6 +2057,47 @@ static void check_filename_case(const char *fn)
|
||||||
static void check_filename_case(const char *fn) { UNREFERENCED_PARAMETER(fn); }
|
static void check_filename_case(const char *fn) { UNREFERENCED_PARAMETER(fn); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void G_DoGameStartup(const int32_t *params)
|
||||||
|
{
|
||||||
|
int32_t j = 0;
|
||||||
|
|
||||||
|
ud.const_visibility = params[j++];
|
||||||
|
g_impactDamage = params[j++];
|
||||||
|
g_maxPlayerHealth = g_player[0].ps->max_player_health = g_player[0].ps->max_shield_amount = params[j++];
|
||||||
|
g_startArmorAmount = params[j++];
|
||||||
|
g_actorRespawnTime = params[j++];
|
||||||
|
g_itemRespawnTime = params[j++];
|
||||||
|
g_playerFriction = params[j++];
|
||||||
|
if (g_scriptVersion == 14) g_spriteGravity = params[j++];
|
||||||
|
g_rpgBlastRadius = params[j++];
|
||||||
|
g_pipebombBlastRadius = params[j++];
|
||||||
|
g_shrinkerBlastRadius = params[j++];
|
||||||
|
g_tripbombBlastRadius = params[j++];
|
||||||
|
g_morterBlastRadius = params[j++];
|
||||||
|
g_bouncemineBlastRadius = params[j++];
|
||||||
|
g_seenineBlastRadius = params[j++];
|
||||||
|
g_player[0].ps->max_ammo_amount[PISTOL_WEAPON] = params[j++];
|
||||||
|
g_player[0].ps->max_ammo_amount[SHOTGUN_WEAPON] = params[j++];
|
||||||
|
g_player[0].ps->max_ammo_amount[CHAINGUN_WEAPON] = params[j++];
|
||||||
|
g_player[0].ps->max_ammo_amount[RPG_WEAPON] = params[j++];
|
||||||
|
g_player[0].ps->max_ammo_amount[HANDBOMB_WEAPON] = params[j++];
|
||||||
|
g_player[0].ps->max_ammo_amount[SHRINKER_WEAPON] = params[j++];
|
||||||
|
g_player[0].ps->max_ammo_amount[DEVISTATOR_WEAPON] = params[j++];
|
||||||
|
g_player[0].ps->max_ammo_amount[TRIPBOMB_WEAPON] = params[j++];
|
||||||
|
g_player[0].ps->max_ammo_amount[FREEZE_WEAPON] = params[j++];
|
||||||
|
if (g_scriptVersion == 14) g_player[0].ps->max_ammo_amount[GROW_WEAPON] = params[j++];
|
||||||
|
g_damageCameras = params[j++];
|
||||||
|
g_numFreezeBounces = params[j++];
|
||||||
|
g_freezerSelfDamage = params[j++];
|
||||||
|
if (g_scriptVersion == 14)
|
||||||
|
{
|
||||||
|
g_spriteDeleteQueueSize = params[j++];
|
||||||
|
g_spriteDeleteQueueSize = clamp(g_spriteDeleteQueueSize, 0, 1024);
|
||||||
|
|
||||||
|
g_tripbombLaserMode = params[j++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t C_ParseCommand(int32_t loop)
|
static int32_t C_ParseCommand(int32_t loop)
|
||||||
{
|
{
|
||||||
int32_t i, j=0, k=0, tw, otw;
|
int32_t i, j=0, k=0, tw, otw;
|
||||||
|
@ -5678,42 +5719,7 @@ repeatcase:
|
||||||
TRIPBOMBLASERMODE
|
TRIPBOMBLASERMODE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
j = 0;
|
G_DoGameStartup(params);
|
||||||
ud.const_visibility = params[j++];
|
|
||||||
g_impactDamage = params[j++];
|
|
||||||
g_maxPlayerHealth = g_player[0].ps->max_player_health = g_player[0].ps->max_shield_amount = params[j++];
|
|
||||||
g_startArmorAmount = params[j++];
|
|
||||||
g_actorRespawnTime = params[j++];
|
|
||||||
g_itemRespawnTime = params[j++];
|
|
||||||
g_playerFriction = params[j++];
|
|
||||||
if (g_scriptVersion == 14) g_spriteGravity = params[j++];
|
|
||||||
g_rpgBlastRadius = params[j++];
|
|
||||||
g_pipebombBlastRadius = params[j++];
|
|
||||||
g_shrinkerBlastRadius = params[j++];
|
|
||||||
g_tripbombBlastRadius = params[j++];
|
|
||||||
g_morterBlastRadius = params[j++];
|
|
||||||
g_bouncemineBlastRadius = params[j++];
|
|
||||||
g_seenineBlastRadius = params[j++];
|
|
||||||
g_player[0].ps->max_ammo_amount[PISTOL_WEAPON] = params[j++];
|
|
||||||
g_player[0].ps->max_ammo_amount[SHOTGUN_WEAPON] = params[j++];
|
|
||||||
g_player[0].ps->max_ammo_amount[CHAINGUN_WEAPON] = params[j++];
|
|
||||||
g_player[0].ps->max_ammo_amount[RPG_WEAPON] = params[j++];
|
|
||||||
g_player[0].ps->max_ammo_amount[HANDBOMB_WEAPON] = params[j++];
|
|
||||||
g_player[0].ps->max_ammo_amount[SHRINKER_WEAPON] = params[j++];
|
|
||||||
g_player[0].ps->max_ammo_amount[DEVISTATOR_WEAPON] = params[j++];
|
|
||||||
g_player[0].ps->max_ammo_amount[TRIPBOMB_WEAPON] = params[j++];
|
|
||||||
g_player[0].ps->max_ammo_amount[FREEZE_WEAPON] = params[j++];
|
|
||||||
if (g_scriptVersion == 14) g_player[0].ps->max_ammo_amount[GROW_WEAPON] = params[j++];
|
|
||||||
g_damageCameras = params[j++];
|
|
||||||
g_numFreezeBounces = params[j++];
|
|
||||||
g_freezerSelfDamage = params[j++];
|
|
||||||
if (g_scriptVersion == 14)
|
|
||||||
{
|
|
||||||
g_spriteDeleteQueueSize = params[j++];
|
|
||||||
g_spriteDeleteQueueSize = clamp(g_spriteDeleteQueueSize, 0, 1024);
|
|
||||||
|
|
||||||
g_tripbombLaserMode = params[j++];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -5723,8 +5729,8 @@ repeatcase:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
/* Anything added with C_AddDefinition() cannot be overwritten in the CONs */
|
/* Anything added with C_AddDefinition() cannot be overwritten in the CONs */
|
||||||
|
|
||||||
static void C_AddDefinition(const char *lLabel,int32_t lValue,int32_t lType)
|
static void C_AddDefinition(const char *lLabel,int32_t lValue,int32_t lType)
|
||||||
{
|
{
|
||||||
Bstrcpy(label+(g_numLabels<<6),lLabel);
|
Bstrcpy(label+(g_numLabels<<6),lLabel);
|
||||||
|
@ -5863,12 +5869,14 @@ static void C_InitProjectiles(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int32_t g_numObituaries;
|
extern int32_t g_numObituaries;
|
||||||
extern int32_t g_numSelfObituaries;
|
extern int32_t g_numSelfObituaries;
|
||||||
|
|
||||||
void C_Compile(const char *filenam)
|
void C_Compile(const char *filenam)
|
||||||
{
|
{
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
char *mptr;
|
char *mptr;
|
||||||
int32_t i;
|
int32_t i;
|
||||||
int32_t fs,fp;
|
int32_t fs,fp;
|
||||||
|
@ -5880,7 +5888,9 @@ void C_Compile(const char *filenam)
|
||||||
Bmemset(&g_tile[i], 0, sizeof(tiledata_t));
|
Bmemset(&g_tile[i], 0, sizeof(tiledata_t));
|
||||||
|
|
||||||
C_InitHashes();
|
C_InitHashes();
|
||||||
|
#endif
|
||||||
Gv_Init();
|
Gv_Init();
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
C_InitProjectiles();
|
C_InitProjectiles();
|
||||||
|
|
||||||
fp = kopen4loadfrommod((char *)filenam,g_loadFromGroupOnly);
|
fp = kopen4loadfrommod((char *)filenam,g_loadFromGroupOnly);
|
||||||
|
@ -5890,7 +5900,7 @@ void C_Compile(const char *filenam)
|
||||||
|
|
||||||
if (g_loadFromGroupOnly == 1 || numgroupfiles == 0)
|
if (g_loadFromGroupOnly == 1 || numgroupfiles == 0)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
# ifdef WIN32
|
||||||
Bsprintf(tempbuf,"Duke Nukem 3D game data was not found. A valid copy of \"%s\" or other compatible data is needed to run EDuke32.\n\n"
|
Bsprintf(tempbuf,"Duke Nukem 3D game data was not found. A valid copy of \"%s\" or other compatible data is needed to run EDuke32.\n\n"
|
||||||
"You can find \"%s\" in the \"DN3DINST\" or \"ATOMINST\" directory on your Duke Nukem 3D installation CD-ROM.\n\n"
|
"You can find \"%s\" in the \"DN3DINST\" or \"ATOMINST\" directory on your Duke Nukem 3D installation CD-ROM.\n\n"
|
||||||
"If you don't already own a copy of Duke or haven't seen your disc in years, don't worry -- you can download the full, registered "
|
"If you don't already own a copy of Duke or haven't seen your disc in years, don't worry -- you can download the full, registered "
|
||||||
|
@ -5916,13 +5926,13 @@ void C_Compile(const char *filenam)
|
||||||
G_GameExit("Error launching default system browser!");
|
G_GameExit("Error launching default system browser!");
|
||||||
}
|
}
|
||||||
G_GameExit("");
|
G_GameExit("");
|
||||||
#else
|
# else
|
||||||
Bsprintf(tempbuf,"Duke Nukem 3D game data was not found. A valid copy of \"%s\" or other compatible data is needed to run EDuke32.\n"
|
Bsprintf(tempbuf,"Duke Nukem 3D game data was not found. A valid copy of \"%s\" or other compatible data is needed to run EDuke32.\n"
|
||||||
"You can find \"%s\" in the \"DN3DINST\" or \"ATOMINST\" directory on your Duke Nukem 3D installation CD-ROM.\n\n"
|
"You can find \"%s\" in the \"DN3DINST\" or \"ATOMINST\" directory on your Duke Nukem 3D installation CD-ROM.\n\n"
|
||||||
"EDuke32 will now close.",
|
"EDuke32 will now close.",
|
||||||
G_GrpFile(),G_GrpFile());
|
G_GrpFile(),G_GrpFile());
|
||||||
G_GameExit(tempbuf);
|
G_GameExit(tempbuf);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -6020,10 +6030,10 @@ void C_Compile(const char *filenam)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if (defined _WIN32 || (defined RENDERTYPESDL && ((defined __APPLE__ && defined OSX_STARTUPWINDOW) || defined HAVE_GTK2)))
|
# if (defined _WIN32 || (defined RENDERTYPESDL && ((defined __APPLE__ && defined OSX_STARTUPWINDOW) || defined HAVE_GTK2)))
|
||||||
while (!quitevent) // keep the window open so people can copy CON errors out of it
|
while (!quitevent) // keep the window open so people can copy CON errors out of it
|
||||||
handleevents();
|
handleevents();
|
||||||
#endif
|
# endif
|
||||||
G_GameExit("");
|
G_GameExit("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6175,6 +6185,7 @@ void C_Compile(const char *filenam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // !defined LUNATIC_ONLY
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_ReportError(int32_t iError)
|
void C_ReportError(int32_t iError)
|
||||||
|
|
|
@ -66,6 +66,7 @@ static void Gv_Free(void) /* called from Gv_ReadSave() and Gv_ResetVars() */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
static void Gv_Clear(void)
|
static void Gv_Clear(void)
|
||||||
{
|
{
|
||||||
// only call this function ONCE...
|
// only call this function ONCE...
|
||||||
|
@ -104,6 +105,7 @@ static void Gv_Clear(void)
|
||||||
hash_init(&h_arrays);
|
hash_init(&h_arrays);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t Gv_ReadSave(int32_t fil, int32_t newbehav)
|
int32_t Gv_ReadSave(int32_t fil, int32_t newbehav)
|
||||||
{
|
{
|
||||||
|
@ -558,12 +560,13 @@ void __fastcall A_ResetVars(register int32_t iActor)
|
||||||
while (i--);
|
while (i--);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
static int32_t Gv_GetVarIndex(const char *szGameLabel)
|
static int32_t Gv_GetVarIndex(const char *szGameLabel)
|
||||||
{
|
{
|
||||||
int32_t i = hash_find(&h_gamevars,szGameLabel);
|
int32_t i = hash_find(&h_gamevars,szGameLabel);
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
OSD_Printf(OSD_ERROR "Gv_GetVarDataPtr(): INTERNAL ERROR: couldn't find gamevar %s!\n",szGameLabel);
|
OSD_Printf(OSD_ERROR "Gv_GetVarIndex(): INTERNAL ERROR: couldn't find gamevar %s!\n",szGameLabel);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
@ -762,6 +765,7 @@ badindex:
|
||||||
aGameVars[id].szLabel,vm.g_i,vm.g_p);
|
aGameVars[id].szLabel,vm.g_i,vm.g_p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t __fastcall Gv_GetVarX(register int32_t id)
|
int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||||
{
|
{
|
||||||
|
@ -993,6 +997,13 @@ static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void G_InitProjectileData(void)
|
||||||
|
{
|
||||||
|
int32_t i;
|
||||||
|
for (i=MAXTILES-1; i>=0; i--)
|
||||||
|
Bmemcpy(&ProjectileData[i], &g_tile[i].defproj, sizeof(projectile_t));
|
||||||
|
}
|
||||||
|
|
||||||
void Gv_ResetSystemDefaults(void)
|
void Gv_ResetSystemDefaults(void)
|
||||||
{
|
{
|
||||||
// call many times...
|
// call many times...
|
||||||
|
@ -1051,6 +1062,7 @@ void Gv_ResetSystemDefaults(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
g_iReturnVarID=Gv_GetVarIndex("RETURN");
|
g_iReturnVarID=Gv_GetVarIndex("RETURN");
|
||||||
g_iWeaponVarID=Gv_GetVarIndex("WEAPON");
|
g_iWeaponVarID=Gv_GetVarIndex("WEAPON");
|
||||||
g_iWorksLikeVarID=Gv_GetVarIndex("WORKSLIKE");
|
g_iWorksLikeVarID=Gv_GetVarIndex("WORKSLIKE");
|
||||||
|
@ -1067,9 +1079,8 @@ void Gv_ResetSystemDefaults(void)
|
||||||
g_iWallVarID=Gv_GetVarIndex("wall");
|
g_iWallVarID=Gv_GetVarIndex("wall");
|
||||||
g_iPlayerVarID=Gv_GetVarIndex("player");
|
g_iPlayerVarID=Gv_GetVarIndex("player");
|
||||||
g_iActorVarID=Gv_GetVarIndex("actorvar");
|
g_iActorVarID=Gv_GetVarIndex("actorvar");
|
||||||
|
#endif
|
||||||
for (i=MAXTILES-1; i>=0; i--)
|
G_InitProjectileData();
|
||||||
Bmemcpy(&ProjectileData[i], &g_tile[i].defproj, sizeof(projectile_t));
|
|
||||||
|
|
||||||
//AddLog("EOF:ResetWeaponDefaults");
|
//AddLog("EOF:ResetWeaponDefaults");
|
||||||
}
|
}
|
||||||
|
@ -1252,7 +1263,7 @@ static void Gv_AddSystemVars(void)
|
||||||
ADDWEAPONVAR(i, SelectSound);
|
ADDWEAPONVAR(i, SelectSound);
|
||||||
ADDWEAPONVAR(i, FlashColor);
|
ADDWEAPONVAR(i, FlashColor);
|
||||||
}
|
}
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
Gv_NewVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM);
|
Gv_NewVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM);
|
||||||
Gv_NewVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM);
|
Gv_NewVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM);
|
||||||
|
|
||||||
|
@ -1362,14 +1373,15 @@ static void Gv_AddSystemVars(void)
|
||||||
Gv_NewVar("Numsprites",(intptr_t)&Numsprites, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY);
|
Gv_NewVar("Numsprites",(intptr_t)&Numsprites, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY);
|
||||||
|
|
||||||
Gv_NewVar("lastsavepos",(intptr_t)&g_lastSaveSlot, GAMEVAR_SYSTEM | GAMEVAR_INTPTR);
|
Gv_NewVar("lastsavepos",(intptr_t)&g_lastSaveSlot, GAMEVAR_SYSTEM | GAMEVAR_INTPTR);
|
||||||
#ifdef USE_OPENGL
|
# ifdef USE_OPENGL
|
||||||
Gv_NewVar("rendmode",(intptr_t)&rendmode, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
Gv_NewVar("rendmode",(intptr_t)&rendmode, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||||
#else
|
# else
|
||||||
Gv_NewVar("rendmode", 0, GAMEVAR_READONLY | GAMEVAR_SYSTEM);
|
Gv_NewVar("rendmode", 0, GAMEVAR_READONLY | GAMEVAR_SYSTEM);
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
Gv_NewArray("tilesizx", (void *)tilesizx, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
Gv_NewArray("tilesizx", (void *)tilesizx, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||||
Gv_NewArray("tilesizy", (void *)tilesizy, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
Gv_NewArray("tilesizy", (void *)tilesizy, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gv_Init(void)
|
void Gv_Init(void)
|
||||||
|
@ -1384,11 +1396,15 @@ void Gv_Init(void)
|
||||||
|
|
||||||
// initprintf("Initializing game variables\n");
|
// initprintf("Initializing game variables\n");
|
||||||
//AddLog("Gv_Init");
|
//AddLog("Gv_Init");
|
||||||
|
#ifdef LUNATIC_ONLY
|
||||||
|
Gv_AddSystemVars(); // set up weapon defaults, g_playerWeapon[][]
|
||||||
|
Gv_ResetSystemDefaults();
|
||||||
|
#else
|
||||||
Gv_Clear();
|
Gv_Clear();
|
||||||
Gv_AddSystemVars();
|
Gv_AddSystemVars();
|
||||||
Gv_InitWeaponPointers();
|
Gv_InitWeaponPointers();
|
||||||
Gv_ResetSystemDefaults();
|
Gv_ResetSystemDefaults();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gv_InitWeaponPointers(void)
|
void Gv_InitWeaponPointers(void)
|
||||||
|
@ -1452,6 +1468,7 @@ void Gv_InitWeaponPointers(void)
|
||||||
|
|
||||||
void Gv_RefreshPointers(void)
|
void Gv_RefreshPointers(void)
|
||||||
{
|
{
|
||||||
|
#if !defined LUNATIC_ONLY
|
||||||
aGameVars[Gv_GetVarIndex("RESPAWN_MONSTERS")].val.lValue = (intptr_t)&ud.respawn_monsters;
|
aGameVars[Gv_GetVarIndex("RESPAWN_MONSTERS")].val.lValue = (intptr_t)&ud.respawn_monsters;
|
||||||
aGameVars[Gv_GetVarIndex("RESPAWN_ITEMS")].val.lValue = (intptr_t)&ud.respawn_items;
|
aGameVars[Gv_GetVarIndex("RESPAWN_ITEMS")].val.lValue = (intptr_t)&ud.respawn_items;
|
||||||
aGameVars[Gv_GetVarIndex("RESPAWN_INVENTORY")].val.lValue = (intptr_t)&ud.respawn_inventory;
|
aGameVars[Gv_GetVarIndex("RESPAWN_INVENTORY")].val.lValue = (intptr_t)&ud.respawn_inventory;
|
||||||
|
@ -1531,7 +1548,8 @@ void Gv_RefreshPointers(void)
|
||||||
aGameVars[Gv_GetVarIndex("Numsprites")].val.lValue = (intptr_t)&Numsprites;
|
aGameVars[Gv_GetVarIndex("Numsprites")].val.lValue = (intptr_t)&Numsprites;
|
||||||
|
|
||||||
aGameVars[Gv_GetVarIndex("lastsavepos")].val.lValue = (intptr_t)&g_lastSaveSlot;
|
aGameVars[Gv_GetVarIndex("lastsavepos")].val.lValue = (intptr_t)&g_lastSaveSlot;
|
||||||
#ifdef USE_OPENGL
|
# ifdef USE_OPENGL
|
||||||
aGameVars[Gv_GetVarIndex("rendmode")].val.lValue = (intptr_t)&rendmode;
|
aGameVars[Gv_GetVarIndex("rendmode")].val.lValue = (intptr_t)&rendmode;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,15 +94,21 @@ extern gamearray_t aGameArrays[MAXGAMEARRAYS];
|
||||||
extern int32_t g_gameVarCount;
|
extern int32_t g_gameVarCount;
|
||||||
extern int32_t g_gameArrayCount;
|
extern int32_t g_gameArrayCount;
|
||||||
|
|
||||||
|
#if defined LUNATIC_ONLY
|
||||||
|
# define Gv_GetVar(id, iActor, iPlayer) (OSD_Printf("Gv_GetVar @ %s:%d\n", __FILE__, __LINE__), 0)
|
||||||
|
# define Gv_SetVar(id, lValue, iActor, iPlayer) OSD_Printf("Gv_SetVar @ %s:%d\n", __FILE__, __LINE__)
|
||||||
|
#else
|
||||||
int32_t __fastcall Gv_GetVar(register int32_t id,register int32_t iActor,register int32_t iPlayer);
|
int32_t __fastcall Gv_GetVar(register int32_t id,register int32_t iActor,register int32_t iPlayer);
|
||||||
|
void __fastcall Gv_SetVar(register int32_t id,register int32_t lValue,register int32_t iActor,register int32_t iPlayer);
|
||||||
|
#endif
|
||||||
int32_t __fastcall Gv_GetVarX(register int32_t id);
|
int32_t __fastcall Gv_GetVarX(register int32_t id);
|
||||||
|
void __fastcall Gv_SetVarX(register int32_t id,register int32_t lValue);
|
||||||
|
|
||||||
int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t lDefault,int32_t iActor,int32_t iPlayer);
|
int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t lDefault,int32_t iActor,int32_t iPlayer);
|
||||||
int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags);
|
int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags);
|
||||||
int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
|
int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
|
||||||
int32_t Gv_ReadSave(int32_t fil,int32_t newbehav);
|
int32_t Gv_ReadSave(int32_t fil,int32_t newbehav);
|
||||||
void __fastcall A_ResetVars(register int32_t iActor);
|
void __fastcall A_ResetVars(register int32_t iActor);
|
||||||
void __fastcall Gv_SetVar(register int32_t id,register int32_t lValue,register int32_t iActor,register int32_t iPlayer);
|
|
||||||
void __fastcall Gv_SetVarX(register int32_t id,register int32_t lValue);
|
|
||||||
void G_FreeMapState(int32_t mapnum);
|
void G_FreeMapState(int32_t mapnum);
|
||||||
void Gv_DumpValues(void);
|
void Gv_DumpValues(void);
|
||||||
void Gv_Init(void);
|
void Gv_Init(void);
|
||||||
|
|
|
@ -456,6 +456,7 @@ const int32_t playerswhenstarted;
|
||||||
int32_t lastvisinc;
|
int32_t lastvisinc;
|
||||||
int16_t g_spriteDeleteQueueSize;
|
int16_t g_spriteDeleteQueueSize;
|
||||||
int16_t BlimpSpawnSprites[15];
|
int16_t BlimpSpawnSprites[15];
|
||||||
|
int32_t g_scriptVersion;
|
||||||
|
|
||||||
int32_t A_IncurDamage(int32_t sn); // not bound-checked!
|
int32_t A_IncurDamage(int32_t sn); // not bound-checked!
|
||||||
void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int32_t weap);
|
void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int32_t weap);
|
||||||
|
@ -479,6 +480,9 @@ int32_t kopen4loadfrommod(const char *filename, char searchfirst);
|
||||||
int32_t kfilelength(int32_t handle);
|
int32_t kfilelength(int32_t handle);
|
||||||
void kclose(int32_t handle);
|
void kclose(int32_t handle);
|
||||||
int32_t kread(int32_t handle, void *buffer, int32_t leng);
|
int32_t kread(int32_t handle, void *buffer, int32_t leng);
|
||||||
|
|
||||||
|
const char *G_ConFile(void);
|
||||||
|
void G_DoGameStartup(const int32_t *params);
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -840,17 +844,17 @@ local modname_stack = {}
|
||||||
local ERRLEV = 5
|
local ERRLEV = 5
|
||||||
|
|
||||||
local function readintostr(fn)
|
local function readintostr(fn)
|
||||||
-- XXX: this is pretty much the same as the code in El_RunOnce()
|
-- XXX: this is pretty much the same as the code in L_RunOnce()
|
||||||
|
|
||||||
local fd = ffiC.kopen4loadfrommod(fn, 0) -- TODO: g_loadFromGroupOnly
|
local fd = ffiC.kopen4loadfrommod(fn, 0) -- TODO: g_loadFromGroupOnly
|
||||||
if (fd < 0) then
|
if (fd < 0) then
|
||||||
errorf(ERRLEV, "Couldn't open file \"%s\"", fn)
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local sz = ffiC.kfilelength(fd)
|
local sz = ffiC.kfilelength(fd)
|
||||||
if (sz == 0) then
|
if (sz == 0) then
|
||||||
ffiC.kclose(fd)
|
ffiC.kclose(fd)
|
||||||
errorf(ERRLEV, "Didn't load module \"%s\": zero-length file", fn)
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
if (sz < 0) then
|
if (sz < 0) then
|
||||||
|
@ -890,8 +894,11 @@ local function our_require(modname)
|
||||||
return package_loaded[modname]
|
return package_loaded[modname]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: better pattern-matching (permit "", ".lua", ".elua" ?)
|
local modfn = modname .. ".lua"
|
||||||
local str = readintostr(modname .. ".lua")
|
local str = readintostr(modfn)
|
||||||
|
if (str == nil) then
|
||||||
|
errorf(ERRLEV-1, "Couldn't open file \"%s\"", modfn)
|
||||||
|
end
|
||||||
|
|
||||||
local modfunc, errmsg = loadstring(str)
|
local modfunc, errmsg = loadstring(str)
|
||||||
if (modfunc == nil) then
|
if (modfunc == nil) then
|
||||||
|
@ -1099,8 +1106,16 @@ G_.player = player -- from above
|
||||||
|
|
||||||
---=== Lunatic interpreter setup ===---
|
---=== Lunatic interpreter setup ===---
|
||||||
|
|
||||||
local lunacon = require("lunacon")
|
local concode
|
||||||
|
|
||||||
|
--- Compile CONs
|
||||||
|
do
|
||||||
|
read_into_string = readintostr -- for lunacon
|
||||||
|
local lunacon = require("lunacon")
|
||||||
|
|
||||||
|
local confn = ffi.string(ffiC.G_ConFile())
|
||||||
|
concode = lunacon.compile(confn)
|
||||||
|
end
|
||||||
|
|
||||||
-- change the environment of this chunk to the table G_
|
-- change the environment of this chunk to the table G_
|
||||||
-- NOTE: all references to global variables from this point on
|
-- NOTE: all references to global variables from this point on
|
||||||
|
@ -1111,9 +1126,9 @@ setfenv(1, G_)
|
||||||
local function printkv(label, table)
|
local function printkv(label, table)
|
||||||
print("========== Keys and values of "..label.." ("..tostring(table)..")")
|
print("========== Keys and values of "..label.." ("..tostring(table)..")")
|
||||||
for k,v in pairs(table) do
|
for k,v in pairs(table) do
|
||||||
print(k .. ': ' .. tostring(v))
|
print(k .. ": " .. tostring(v))
|
||||||
end
|
end
|
||||||
print('----------')
|
print("----------")
|
||||||
end
|
end
|
||||||
|
|
||||||
--printkv('_G AFTER SETFENV', _G)
|
--printkv('_G AFTER SETFENV', _G)
|
||||||
|
@ -1124,8 +1139,8 @@ end
|
||||||
-- error(..., 2) is to blame the caller and get its line numbers
|
-- error(..., 2) is to blame the caller and get its line numbers
|
||||||
|
|
||||||
local tmpmt = {
|
local tmpmt = {
|
||||||
__index = function() error('dummy variable: read access forbidden', 2) end,
|
__index = function() error("dummy variable: read access forbidden", 2) end,
|
||||||
__newindex = function() error('dummy variable: write access forbidden', 2) end,
|
__newindex = function() error("dummy variable: write access forbidden", 2) end,
|
||||||
}
|
}
|
||||||
setmtonce(dummy_empty_table, tmpmt)
|
setmtonce(dummy_empty_table, tmpmt)
|
||||||
|
|
||||||
|
@ -1140,7 +1155,7 @@ setmtonce(gv, tmpmt)
|
||||||
defs_c.create_globals(_G)
|
defs_c.create_globals(_G)
|
||||||
|
|
||||||
---- indirect C array access ----
|
---- indirect C array access ----
|
||||||
actor = defs_c.creategtab(ffiC.actor, ffiC.MAXSPRITES, 'actor[]')
|
actor = defs_c.creategtab(ffiC.actor, ffiC.MAXSPRITES, "actor[]")
|
||||||
|
|
||||||
function TEMP_getvollev() -- REMOVE
|
function TEMP_getvollev() -- REMOVE
|
||||||
return ffiC.ud.volume_number+1, ffiC.ud.level_number+1
|
return ffiC.ud.volume_number+1, ffiC.ud.level_number+1
|
||||||
|
@ -1295,3 +1310,12 @@ setmetatable(
|
||||||
-- In particular, we need the functions defined after setting this chunk's
|
-- In particular, we need the functions defined after setting this chunk's
|
||||||
-- environment earlier.
|
-- environment earlier.
|
||||||
setfenv(0, _G)
|
setfenv(0, _G)
|
||||||
|
|
||||||
|
-- Finally, run the CON code translated into Lua.
|
||||||
|
if (concode) then
|
||||||
|
local confunc, conerrmsg = loadstring(concode, "CON")
|
||||||
|
if (confunc == nil) then
|
||||||
|
error("Failure loading translated CON code: "..conerrmsg)
|
||||||
|
end
|
||||||
|
confunc()
|
||||||
|
end
|
||||||
|
|
|
@ -63,6 +63,9 @@ kfilelength;
|
||||||
kclose;
|
kclose;
|
||||||
kread;
|
kread;
|
||||||
|
|
||||||
|
G_ConFile;
|
||||||
|
G_DoGameStartup;
|
||||||
|
|
||||||
actor;
|
actor;
|
||||||
ud;
|
ud;
|
||||||
g_player;
|
g_player;
|
||||||
|
@ -71,6 +74,7 @@ playerswhenstarted;
|
||||||
lastvisinc;
|
lastvisinc;
|
||||||
g_spriteDeleteQueueSize;
|
g_spriteDeleteQueueSize;
|
||||||
BlimpSpawnSprites;
|
BlimpSpawnSprites;
|
||||||
|
g_scriptVersion;
|
||||||
|
|
||||||
luaJIT_BC_lunacon;
|
luaJIT_BC_lunacon;
|
||||||
luaJIT_BC_con_lang;
|
luaJIT_BC_con_lang;
|
||||||
|
|
|
@ -21,6 +21,10 @@ local tostring = tostring
|
||||||
local type = type
|
local type = type
|
||||||
local unpack = unpack
|
local unpack = unpack
|
||||||
|
|
||||||
|
-- non-nil if running from EDuke32
|
||||||
|
-- (read_into_string~=nil iff string.dump==nil)
|
||||||
|
local read_into_string = read_into_string
|
||||||
|
|
||||||
if (string.dump) then
|
if (string.dump) then
|
||||||
require("strict")
|
require("strict")
|
||||||
end
|
end
|
||||||
|
@ -366,13 +370,22 @@ end
|
||||||
|
|
||||||
local function parse(contents) end -- fwd-decl
|
local function parse(contents) end -- fwd-decl
|
||||||
|
|
||||||
local function do_include_file(dirname, filename) end
|
local function do_include_file(dirname, filename)
|
||||||
local function cmd_include(filename) end
|
assert(type(filename)=="string")
|
||||||
|
|
||||||
if (not string.dump) then
|
if (g_have_file[filename] ~= nil) then
|
||||||
-- NOT IMPLEMENTED
|
printf("[%d] Fatal error: infinite loop including \"%s\"", filename)
|
||||||
else
|
g_numerrors = inf
|
||||||
function do_include_file(dirname, filename)
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local contents
|
||||||
|
|
||||||
|
if (read_into_string) then
|
||||||
|
-- running from EDuke32
|
||||||
|
contents = read_into_string(filename)
|
||||||
|
else
|
||||||
|
-- running stand-alone
|
||||||
local io = require("io")
|
local io = require("io")
|
||||||
|
|
||||||
local fd, msg = io.open(dirname..filename)
|
local fd, msg = io.open(dirname..filename)
|
||||||
|
@ -388,36 +401,30 @@ else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (g_have_file[filename] ~= nil) then
|
contents = fd:read("*all")
|
||||||
printf("[%d] Fatal error: infinite loop including \"%s\"", filename)
|
|
||||||
g_numerrors = inf
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local contents = fd:read("*all")
|
|
||||||
fd:close()
|
fd:close()
|
||||||
|
|
||||||
if (contents == nil) then
|
|
||||||
-- maybe that file name turned out to be a directory or other
|
|
||||||
-- special file accidentally
|
|
||||||
printf("[%d] Fatal error: couldn't read from \"%s\"",
|
|
||||||
g_recurslevel, dirname..filename)
|
|
||||||
g_numerrors = inf
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
printf("%s[%d] Translating file \"%s\"", (g_recurslevel==-1 and "\n---- ") or "",
|
|
||||||
g_recurslevel+1, dirname..filename);
|
|
||||||
|
|
||||||
local oldfilename = g_filename
|
|
||||||
g_filename = filename
|
|
||||||
parse(contents)
|
|
||||||
g_filename = oldfilename
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function cmd_include(filename)
|
if (contents == nil) then
|
||||||
do_include_file(g_directory, filename)
|
-- maybe that file name turned out to be a directory or other
|
||||||
|
-- special file accidentally
|
||||||
|
printf("[%d] Fatal error: couldn't read from \"%s\"",
|
||||||
|
g_recurslevel, dirname..filename)
|
||||||
|
g_numerrors = inf
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
printf("%s[%d] Translating file \"%s\"", (g_recurslevel==-1 and "\n---- ") or "",
|
||||||
|
g_recurslevel+1, dirname..filename);
|
||||||
|
|
||||||
|
local oldfilename = g_filename
|
||||||
|
g_filename = filename
|
||||||
|
parse(contents)
|
||||||
|
g_filename = oldfilename
|
||||||
|
end
|
||||||
|
|
||||||
|
function cmd_include(filename)
|
||||||
|
do_include_file(g_directory, filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Per-module game data
|
--- Per-module game data
|
||||||
|
@ -497,14 +504,26 @@ local function cmd_definequote(qnum, quotestr)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function cmd_gamestartup(...)
|
local function cmd_gamestartup(...)
|
||||||
local nums = {...}
|
local args = {...}
|
||||||
|
|
||||||
if (#nums ~= 26 and #nums ~= 30) then
|
if (#args ~= 26 and #args ~= 30) then
|
||||||
errprintf("must pass either 26 (1.3D) or 30 (1.5) values")
|
errprintf("must pass either 26 (1.3D) or 30 (1.5) values")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
g_data.startup = nums -- TODO: sanity-check them
|
if (string.dump == nil) then
|
||||||
|
-- running from EDuke32
|
||||||
|
local ffi = require("ffi")
|
||||||
|
local ffiC = ffi.C
|
||||||
|
|
||||||
|
if (args == 30) then
|
||||||
|
ffiC.g_scriptVersion = 14
|
||||||
|
end
|
||||||
|
local params = ffi.new("int32_t [30]", args)
|
||||||
|
ffiC.G_DoGameStartup(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
g_data.startup = args -- TODO: sanity-check them
|
||||||
end
|
end
|
||||||
|
|
||||||
local function cmd_definesound(sndnum, fn, ...)
|
local function cmd_definesound(sndnum, fn, ...)
|
||||||
|
@ -1609,6 +1628,10 @@ local function flatten_codetab(codetab)
|
||||||
return tmpcode
|
return tmpcode
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_code_string(codetab)
|
||||||
|
return table.concat(flatten_codetab(g_curcode), "\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---=== EXPORTED FUNCTIONS ===---
|
---=== EXPORTED FUNCTIONS ===---
|
||||||
|
|
||||||
|
@ -1707,8 +1730,21 @@ local function handle_cmdline_arg(str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function reset_all()
|
||||||
|
reset_labels()
|
||||||
|
reset_gamedata()
|
||||||
|
reset_codegen()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function print_on_failure(msg)
|
||||||
|
if (g_lastkwpos ~= nil) then
|
||||||
|
printf("LAST KEYWORD POSITION: %s, %s", linecolstr(g_lastkwpos), g_lastkw)
|
||||||
|
end
|
||||||
|
print(msg)
|
||||||
|
end
|
||||||
|
|
||||||
if (string.dump) then
|
if (string.dump) then
|
||||||
--- stand-alone
|
-- running stand-alone
|
||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
while (arg[i]) do
|
while (arg[i]) do
|
||||||
|
@ -1722,9 +1758,7 @@ if (string.dump) then
|
||||||
for argi=1,#arg do
|
for argi=1,#arg do
|
||||||
local filename = arg[argi]
|
local filename = arg[argi]
|
||||||
|
|
||||||
reset_labels()
|
reset_all()
|
||||||
reset_gamedata()
|
|
||||||
reset_codegen()
|
|
||||||
|
|
||||||
g_directory = filename:match("(.*/)") or ""
|
g_directory = filename:match("(.*/)") or ""
|
||||||
filename = filename:sub(#g_directory+1, -1)
|
filename = filename:sub(#g_directory+1, -1)
|
||||||
|
@ -1736,17 +1770,27 @@ if (string.dump) then
|
||||||
-- local ok, msg = true, do_include_file(g_directory, filename)
|
-- local ok, msg = true, do_include_file(g_directory, filename)
|
||||||
|
|
||||||
if (not ok) then
|
if (not ok) then
|
||||||
if (g_lastkwpos ~= nil) then
|
print_on_failure(msg)
|
||||||
printf("LAST KEYWORD POSITION: %s, %s", linecolstr(g_lastkwpos), g_lastkw)
|
|
||||||
end
|
|
||||||
print(msg)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (g_printcode) then
|
if (g_printcode) then
|
||||||
local file = require("io").stderr
|
local file = require("io").stderr
|
||||||
file:write(format("-- GENERATED CODE for \"%s\":\n", filename))
|
file:write(format("-- GENERATED CODE for \"%s\":\n", filename))
|
||||||
file:write(table.concat(flatten_codetab(g_curcode), "\n"))
|
file:write(get_code_string(g_curcode))
|
||||||
file:write("\n")
|
file:write("\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
-- running from EDuke32
|
||||||
|
function compile(filename)
|
||||||
|
-- TODO: pathsearchmode=1 set in G_CompileScripts
|
||||||
|
reset_all()
|
||||||
|
local ok, msg = pcall(do_include_file, "", filename)
|
||||||
|
if (not ok) then
|
||||||
|
print_on_failure(msg)
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
return get_code_string(g_curcode)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -89,6 +89,8 @@ if (vol==1 and lev==1) then -- E1L1
|
||||||
actor[562].flags = bit.bor(actor[562].flags, 2); -- pal 6 with goggles on front SEENINE
|
actor[562].flags = bit.bor(actor[562].flags, 2); -- pal 6 with goggles on front SEENINE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
-- TODO: better API for all TROR things?
|
||||||
if (vol==1 and lev==8) then
|
if (vol==1 and lev==8) then
|
||||||
print('tweaking bunch 1');
|
print('tweaking bunch 1');
|
||||||
-- trueror1.map
|
-- trueror1.map
|
||||||
|
@ -99,6 +101,7 @@ if (vol==1 and lev==8) then
|
||||||
sector[i].floorz = sector[i].floorz - 3*1024;
|
sector[i].floorz = sector[i].floorz - 3*1024;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--]]
|
||||||
|
|
||||||
local unsafe = pcall(function() string.UNSAFE=true; end)
|
local unsafe = pcall(function() string.UNSAFE=true; end)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue