Merge branch 'next' into demos-refactor

# Conflicts:
#	src/g_game.c

(also update g_demo.c)
This commit is contained in:
Monster Iestyn 2020-03-20 17:48:31 +00:00
commit 7a585e2498
64 changed files with 1742 additions and 1411 deletions

View File

@ -51,8 +51,8 @@ jobs:
- /var/cache/apt/archives - /var/cache/apt/archives
- checkout - checkout
- run: - run:
name: Compile without network support and BLUA name: Compile without network support
command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 NO_LUA=1 command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1
- run: - run:
name: wipe build name: wipe build
command: make -C src LINUX=1 cleandep command: make -C src LINUX=1 cleandep

View File

@ -218,8 +218,6 @@ source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES})
### Configuration ### Configuration
set(SRB2_CONFIG_HAVE_BLUA ON CACHE BOOL
"Enable Lua interpreter support")
set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL
"Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.") "Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.")
set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
@ -243,92 +241,90 @@ if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
"Use SRB2's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).") "Use SRB2's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).")
endif() endif()
if(${SRB2_CONFIG_HAVE_BLUA}) set(SRB2_LUA_SOURCES
add_definitions(-DHAVE_BLUA) lua_baselib.c
set(SRB2_LUA_SOURCES lua_blockmaplib.c
lua_baselib.c lua_consolelib.c
lua_blockmaplib.c lua_hooklib.c
lua_consolelib.c lua_hudlib.c
lua_hooklib.c lua_infolib.c
lua_hudlib.c lua_maplib.c
lua_infolib.c lua_mathlib.c
lua_maplib.c lua_mobjlib.c
lua_mathlib.c lua_playerlib.c
lua_mobjlib.c lua_script.c
lua_playerlib.c lua_skinlib.c
lua_script.c lua_thinkerlib.c
lua_skinlib.c )
lua_thinkerlib.c set(SRB2_LUA_HEADERS
) lua_hook.h
set(SRB2_LUA_HEADERS lua_hud.h
lua_hook.h lua_libs.h
lua_hud.h lua_script.h
lua_libs.h )
lua_script.h
)
prepend_sources(SRB2_LUA_SOURCES) prepend_sources(SRB2_LUA_SOURCES)
prepend_sources(SRB2_LUA_HEADERS) prepend_sources(SRB2_LUA_HEADERS)
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS}) source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
set(SRB2_BLUA_SOURCES set(SRB2_BLUA_SOURCES
blua/lapi.c blua/lapi.c
blua/lauxlib.c blua/lauxlib.c
blua/lbaselib.c blua/lbaselib.c
blua/lcode.c blua/lcode.c
blua/ldebug.c blua/ldebug.c
blua/ldo.c blua/ldo.c
blua/ldump.c blua/ldump.c
blua/lfunc.c blua/lfunc.c
blua/lgc.c blua/lgc.c
blua/linit.c blua/linit.c
blua/llex.c blua/liolib.c
blua/lmem.c blua/llex.c
blua/lobject.c blua/lmem.c
blua/lopcodes.c blua/lobject.c
blua/lparser.c blua/lopcodes.c
blua/lstate.c blua/lparser.c
blua/lstring.c blua/lstate.c
blua/lstrlib.c blua/lstring.c
blua/ltable.c blua/lstrlib.c
blua/ltablib.c blua/ltable.c
blua/ltm.c blua/ltablib.c
blua/lundump.c blua/ltm.c
blua/lvm.c blua/lundump.c
blua/lzio.c blua/lvm.c
) blua/lzio.c
set(SRB2_BLUA_HEADERS )
blua/lapi.h set(SRB2_BLUA_HEADERS
blua/lauxlib.h blua/lapi.h
blua/lcode.h blua/lauxlib.h
blua/ldebug.h blua/lcode.h
blua/ldo.h blua/ldebug.h
blua/lfunc.h blua/ldo.h
blua/lgc.h blua/lfunc.h
blua/llex.h blua/lgc.h
blua/llimits.h blua/llex.h
blua/lmem.h blua/llimits.h
blua/lobject.h blua/lmem.h
blua/lopcodes.h blua/lobject.h
blua/lparser.h blua/lopcodes.h
blua/lstate.h blua/lparser.h
blua/lstring.h blua/lstate.h
blua/ltable.h blua/lstring.h
blua/ltm.h blua/ltable.h
blua/lua.h blua/ltm.h
blua/luaconf.h blua/lua.h
blua/lualib.h blua/luaconf.h
blua/lundump.h blua/lualib.h
blua/lvm.h blua/lundump.h
blua/lzio.h blua/lvm.h
) blua/lzio.h
)
prepend_sources(SRB2_BLUA_SOURCES) prepend_sources(SRB2_BLUA_SOURCES)
prepend_sources(SRB2_BLUA_HEADERS) prepend_sources(SRB2_BLUA_HEADERS)
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS}) source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
endif()
if(${SRB2_CONFIG_HAVE_GME}) if(${SRB2_CONFIG_HAVE_GME})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})

View File

@ -340,9 +340,7 @@ CFLAGS+=-DHAVE_MINIUPNPC
endif endif
endif endif
ifndef NO_LUA include blua/Makefile.cfg
include blua/Makefile.cfg
endif
ifdef NOMD5 ifdef NOMD5
OPTS+=-DNOMD5 OPTS+=-DNOMD5
@ -684,9 +682,7 @@ $(OBJDIR)/depend.dep:
ifndef NOHW ifndef NOHW
$(CC) $(CFLAGS) -MM hardware/*.c >> $(OBJDIR)/depend.ped $(CC) $(CFLAGS) -MM hardware/*.c >> $(OBJDIR)/depend.ped
endif endif
ifndef NO_LUA
$(CC) $(CFLAGS) -MM blua/*.c >> $(OBJDIR)/depend.ped $(CC) $(CFLAGS) -MM blua/*.c >> $(OBJDIR)/depend.ped
endif
@sed -e 's,\(.*\)\.o: ,$(subst /,\/,$(OBJDIR))\/&,g' < $(OBJDIR)/depend.ped > $(OBJDIR)/depend.dep @sed -e 's,\(.*\)\.o: ,$(subst /,\/,$(OBJDIR))\/&,g' < $(OBJDIR)/depend.ped > $(OBJDIR)/depend.dep
$(REMOVE) $(OBJDIR)/depend.ped $(REMOVE) $(OBJDIR)/depend.ped
@echo "Created dependency file, depend.dep" @echo "Created dependency file, depend.dep"

View File

@ -74,11 +74,9 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
if (!sonic || sonic->health <= 0) if (!sonic || sonic->health <= 0)
return; return;
#ifdef HAVE_BLUA
// Lua can handle it! // Lua can handle it!
if (LUAh_BotAI(sonic, tails, cmd)) if (LUAh_BotAI(sonic, tails, cmd))
return; return;
#endif
if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC) if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC)
{ {
@ -364,11 +362,9 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd)
// Bot AI isn't programmed in analog. // Bot AI isn't programmed in analog.
CV_SetValue(&cv_analog[1], false); CV_SetValue(&cv_analog[1], false);
#ifdef HAVE_BLUA
// Let Lua scripts build ticcmds // Let Lua scripts build ticcmds
if (LUAh_BotTiccmd(player, cmd)) if (LUAh_BotTiccmd(player, cmd))
return; return;
#endif
// We don't have any main character AI, sorry. D: // We don't have any main character AI, sorry. D:
if (player-players == consoleplayer) if (player-players == consoleplayer)

View File

@ -10,14 +10,13 @@ WFLAGS+=-Wno-logical-op
endif endif
endif endif
OPTS+=-DHAVE_BLUA
OBJS:=$(OBJS) \ OBJS:=$(OBJS) \
$(OBJDIR)/lapi.o \ $(OBJDIR)/lapi.o \
$(OBJDIR)/lbaselib.o \ $(OBJDIR)/lbaselib.o \
$(OBJDIR)/ldo.o \ $(OBJDIR)/ldo.o \
$(OBJDIR)/lfunc.o \ $(OBJDIR)/lfunc.o \
$(OBJDIR)/linit.o \ $(OBJDIR)/linit.o \
$(OBJDIR)/liolib.o \
$(OBJDIR)/llex.o \ $(OBJDIR)/llex.o \
$(OBJDIR)/lmem.o \ $(OBJDIR)/lmem.o \
$(OBJDIR)/lobject.o \ $(OBJDIR)/lobject.o \

View File

@ -17,6 +17,7 @@
static const luaL_Reg lualibs[] = { static const luaL_Reg lualibs[] = {
{"", luaopen_base}, {"", luaopen_base},
{LUA_TABLIBNAME, luaopen_table}, {LUA_TABLIBNAME, luaopen_table},
{LUA_IOLIBNAME, luaopen_io},
{LUA_STRLIBNAME, luaopen_string}, {LUA_STRLIBNAME, luaopen_string},
{NULL, NULL} {NULL, NULL}
}; };

635
src/blua/liolib.c Normal file
View File

@ -0,0 +1,635 @@
/*
** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define liolib_c
#define LUA_LIB
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include "../i_system.h"
#include "../g_game.h"
#include "../d_netfil.h"
#include "../lua_libs.h"
#include "../byteptr.h"
#include "../lua_script.h"
#include "../m_misc.h"
#define IO_INPUT 1
#define IO_OUTPUT 2
#define FILELIMIT (1024 * 1024) // Size limit for reading/writing files
#define FMT_FILECALLBACKID "file_callback_%d"
// Allow scripters to write files of these types to SRB2's folder
static const char *whitelist[] = {
".bmp",
".cfg",
".csv",
".dat",
".png",
".sav2",
".txt",
};
static int pushresult (lua_State *L, int i, const char *filename) {
int en = errno; /* calls to Lua API may change this value */
if (i) {
lua_pushboolean(L, 1);
return 1;
}
else {
lua_pushnil(L);
if (filename)
lua_pushfstring(L, "%s: %s", filename, strerror(en));
else
lua_pushfstring(L, "%s", strerror(en));
lua_pushinteger(L, en);
return 3;
}
}
#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
static int io_type (lua_State *L) {
void *ud;
luaL_checkany(L, 1);
ud = lua_touserdata(L, 1);
lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE);
if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1))
lua_pushnil(L); /* not a file */
else if (*((FILE **)ud) == NULL)
lua_pushliteral(L, "closed file");
else
lua_pushliteral(L, "file");
return 1;
}
static FILE *tofile (lua_State *L) {
FILE **f = tofilep(L);
if (*f == NULL)
luaL_error(L, "attempt to use a closed file");
return *f;
}
/*
** When creating file handles, always creates a `closed' file handle
** before opening the actual file; so, if there is a memory error, the
** file is not left opened.
*/
static FILE **newfile (lua_State *L) {
FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *));
*pf = NULL; /* file handle is currently `closed' */
luaL_getmetatable(L, LUA_FILEHANDLE);
lua_setmetatable(L, -2);
return pf;
}
/*
** function to (not) close the standard files stdin, stdout, and stderr
*/
static int io_noclose (lua_State *L) {
lua_pushnil(L);
lua_pushliteral(L, "cannot close standard file");
return 2;
}
/*
** function to close regular files
*/
static int io_fclose (lua_State *L) {
FILE **p = tofilep(L);
int ok = (fclose(*p) == 0);
*p = NULL;
return pushresult(L, ok, NULL);
}
static int aux_close (lua_State *L) {
lua_getfenv(L, 1);
lua_getfield(L, -1, "__close");
return (lua_tocfunction(L, -1))(L);
}
static int io_close (lua_State *L) {
if (lua_isnone(L, 1))
lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT);
tofile(L); /* make sure argument is a file */
return aux_close(L);
}
static int io_gc (lua_State *L) {
FILE *f = *tofilep(L);
/* ignore closed files */
if (f != NULL)
aux_close(L);
return 0;
}
static int io_tostring (lua_State *L) {
FILE *f = *tofilep(L);
if (f == NULL)
lua_pushliteral(L, "file (closed)");
else
lua_pushfstring(L, "file (%p)", f);
return 1;
}
// Create directories in the path
void MakePathDirs(char *path)
{
char *c;
for (c = path; *c; c++)
if (*c == '/' || *c == '\\')
{
char sep = *c;
*c = '\0';
I_mkdir(path, 0755);
*c = sep;
}
}
static int CheckFileName(lua_State *L, const char *filename)
{
int length = strlen(filename);
boolean pass = false;
size_t i;
if (strchr(filename, '\\'))
{
luaL_error(L, "access denied to %s: \\ is not allowed, use / instead", filename);
return pushresult(L,0,filename);
}
for (i = 0; i < (sizeof (whitelist) / sizeof(const char *)); i++)
if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i]))
{
pass = true;
break;
}
if (strstr(filename, "./")
|| strstr(filename, "..") || strchr(filename, ':')
|| filename[0] == '/'
|| !pass)
{
luaL_error(L, "access denied to %s", filename);
return pushresult(L,0,filename);
}
return 0;
}
static int io_open (lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
const char *mode = luaL_optstring(L, 2, "r");
int checkresult;
checkresult = CheckFileName(L, filename);
if (checkresult)
return checkresult;
luaL_checktype(L, 3, LUA_TFUNCTION);
if (!(strchr(mode, 'r') || strchr(mode, '+')))
luaL_error(L, "open() is only for reading, use openlocal() for writing");
AddLuaFileTransfer(filename, mode);
return 0;
}
static int io_openlocal (lua_State *L) {
FILE **pf;
const char *filename = luaL_checkstring(L, 1);
const char *mode = luaL_optstring(L, 2, "r");
char *realfilename;
luafiletransfer_t *filetransfer;
int checkresult;
checkresult = CheckFileName(L, filename);
if (checkresult)
return checkresult;
realfilename = va("%s" PATHSEP "%s", luafiledir, filename);
if (client && strnicmp(filename, "client/", strlen("client/")))
I_Error("Access denied to %s\n"
"Clients can only access files stored in luafiles/client/\n",
filename);
// Prevent access if the file is being downloaded
for (filetransfer = luafiletransfers; filetransfer; filetransfer = filetransfer->next)
if (!stricmp(filetransfer->filename, filename))
I_Error("Access denied to %s\n"
"Files can't be opened while being downloaded\n",
filename);
MakePathDirs(realfilename);
// Open and return the file
pf = newfile(L);
*pf = fopen(realfilename, mode);
return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
}
void Got_LuaFile(UINT8 **cp, INT32 playernum)
{
FILE **pf = NULL;
UINT8 success = READUINT8(*cp); // The first (and only) byte indicates whether the file could be opened
if (playernum != serverplayer)
{
CONS_Alert(CONS_WARNING, M_GetText("Illegal luafile command received from %s\n"), player_names[playernum]);
if (server)
SendKick(playernum, KICK_MSG_CON_FAIL);
return;
}
if (!luafiletransfers)
I_Error("No Lua file transfer\n");
// Retrieve the callback and push it on the stack
lua_pushfstring(gL, FMT_FILECALLBACKID, luafiletransfers->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
// Push the first argument (file handle or nil) on the stack
if (success)
{
pf = newfile(gL); // Create and push the file handle
*pf = fopen(luafiletransfers->realfilename, luafiletransfers->mode); // Open the file
if (!*pf)
I_Error("Can't open file \"%s\"\n", luafiletransfers->realfilename); // The file SHOULD exist
}
else
lua_pushnil(gL);
// Push the second argument (file name) on the stack
lua_pushstring(gL, luafiletransfers->filename);
// Call the callback
LUA_Call(gL, 2);
if (success)
{
// Close the file
if (*pf)
{
fclose(*pf);
*pf = NULL;
}
if (client)
remove(luafiletransfers->realfilename);
}
RemoveLuaFileTransfer();
if (server && luafiletransfers)
{
if (FIL_FileOK(luafiletransfers->realfilename))
SV_PrepareSendLuaFileToNextNode();
else
{
// Send a net command with 0 as its first byte to indicate the file couldn't be opened
success = 0;
SendNetXCmd(XD_LUAFILE, &success, 1);
}
}
}
void StoreLuaFileCallback(INT32 id)
{
lua_pushfstring(gL, FMT_FILECALLBACKID, id);
lua_pushvalue(gL, 3); // Parameter 3 is the callback
lua_settable(gL, LUA_REGISTRYINDEX); // registry[callbackid] = callback
}
void RemoveLuaFileCallback(INT32 id)
{
lua_pushfstring(gL, FMT_FILECALLBACKID, id);
lua_pushnil(gL);
lua_settable(gL, LUA_REGISTRYINDEX); // registry[callbackid] = nil
}
static int io_tmpfile (lua_State *L) {
FILE **pf = newfile(L);
*pf = tmpfile();
return (*pf == NULL) ? pushresult(L, 0, NULL) : 1;
}
static int io_readline (lua_State *L);
static void aux_lines (lua_State *L, int idx, int toclose) {
lua_pushvalue(L, idx);
lua_pushboolean(L, toclose); /* close/not close file when finished */
lua_pushcclosure(L, io_readline, 2);
}
static int f_lines (lua_State *L) {
tofile(L); /* check that it's a valid file handle */
aux_lines(L, 1, 0);
return 1;
}
/*
** {======================================================
** READ
** =======================================================
*/
static int read_number (lua_State *L, FILE *f) {
lua_Number d;
if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
lua_pushnumber(L, d);
return 1;
}
else return 0; /* read fails */
}
static int test_eof (lua_State *L, FILE *f) {
int c = getc(f);
ungetc(c, f);
lua_pushlstring(L, NULL, 0);
return (c != EOF);
}
static int read_line (lua_State *L, FILE *f) {
luaL_Buffer b;
luaL_buffinit(L, &b);
for (;;) {
size_t l;
char *p = luaL_prepbuffer(&b);
if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */
luaL_pushresult(&b); /* close buffer */
return (lua_objlen(L, -1) > 0); /* check whether read something */
}
l = strlen(p);
if (l == 0 || p[l-1] != '\n')
luaL_addsize(&b, l);
else {
luaL_addsize(&b, l - 1); /* do not include `eol' */
luaL_pushresult(&b); /* close buffer */
return 1; /* read at least an `eol' */
}
}
}
static int read_chars (lua_State *L, FILE *f, size_t n) {
size_t rlen; /* how much to read */
size_t nr; /* number of chars actually read */
luaL_Buffer b;
luaL_buffinit(L, &b);
rlen = LUAL_BUFFERSIZE; /* try to read that much each time */
do {
char *p = luaL_prepbuffer(&b);
if (rlen > n) rlen = n; /* cannot read more than asked */
nr = fread(p, sizeof(char), rlen, f);
luaL_addsize(&b, nr);
n -= nr; /* still have to read `n' chars */
} while (n > 0 && nr == rlen); /* until end of count or eof */
luaL_pushresult(&b); /* close buffer */
return (n == 0 || lua_objlen(L, -1) > 0);
}
static int g_read (lua_State *L, FILE *f, int first) {
int nargs = lua_gettop(L) - 1;
int success;
int n;
clearerr(f);
if (nargs == 0) { /* no arguments? */
success = read_line(L, f);
n = first+1; /* to return 1 result */
}
else { /* ensure stack space for all results and for auxlib's buffer */
luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
success = 1;
for (n = first; nargs-- && success; n++) {
if (lua_type(L, n) == LUA_TNUMBER) {
size_t l = (size_t)lua_tointeger(L, n);
success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
}
else {
const char *p = lua_tostring(L, n);
luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
switch (p[1]) {
case 'n': /* number */
success = read_number(L, f);
break;
case 'l': /* line */
success = read_line(L, f);
break;
case 'a': /* file */
read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */
success = 1; /* always success */
break;
default:
return luaL_argerror(L, n, "invalid format");
}
}
}
}
if (ferror(f))
return pushresult(L, 0, NULL);
if (!success) {
lua_pop(L, 1); /* remove last result */
lua_pushnil(L); /* push nil instead */
}
return n - first;
}
static int f_read (lua_State *L) {
return g_read(L, tofile(L), 2);
}
static int io_readline (lua_State *L) {
FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
int sucess;
if (f == NULL) /* file is already closed? */
luaL_error(L, "file is already closed");
sucess = read_line(L, f);
if (ferror(f))
return luaL_error(L, "%s", strerror(errno));
if (sucess) return 1;
else { /* EOF */
if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */
lua_settop(L, 0);
lua_pushvalue(L, lua_upvalueindex(1));
aux_close(L); /* close it */
}
return 0;
}
}
/* }====================================================== */
static int g_write (lua_State *L, FILE *f, int arg) {
int nargs = lua_gettop(L) - 1;
int status = 1;
for (; nargs--; arg++) {
if (lua_type(L, arg) == LUA_TNUMBER) {
/* optimization: could be done exactly as for strings */
status = status &&
fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
}
else {
size_t l;
const char *s = luaL_checklstring(L, arg, &l);
if (ftell(f) + l > FILELIMIT) {
luaL_error(L,"write limit bypassed in file. Changes have been discarded.");
break;
}
status = status && (fwrite(s, sizeof(char), l, f) == l);
}
}
return pushresult(L, status, NULL);
}
static int f_write (lua_State *L) {
return g_write(L, tofile(L), 2);
}
static int f_seek (lua_State *L) {
static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
static const char *const modenames[] = {"set", "cur", "end", NULL};
FILE *f = tofile(L);
int op = luaL_checkoption(L, 2, "cur", modenames);
long offset = luaL_optlong(L, 3, 0);
op = fseek(f, offset, mode[op]);
if (op)
return pushresult(L, 0, NULL); /* error */
else {
lua_pushinteger(L, ftell(f));
return 1;
}
}
static int f_setvbuf (lua_State *L) {
static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
static const char *const modenames[] = {"no", "full", "line", NULL};
FILE *f = tofile(L);
int op = luaL_checkoption(L, 2, NULL, modenames);
lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
int res = setvbuf(f, NULL, mode[op], sz);
return pushresult(L, res == 0, NULL);
}
static int f_flush (lua_State *L) {
return pushresult(L, fflush(tofile(L)) == 0, NULL);
}
static const luaL_Reg iolib[] = {
{"close", io_close},
{"open", io_open},
{"openlocal", io_openlocal},
{"tmpfile", io_tmpfile},
{"type", io_type},
{NULL, NULL}
};
static const luaL_Reg flib[] = {
{"close", io_close},
{"flush", f_flush},
{"lines", f_lines},
{"read", f_read},
{"seek", f_seek},
{"setvbuf", f_setvbuf},
{"write", f_write},
{"__gc", io_gc},
{"__tostring", io_tostring},
{NULL, NULL}
};
static void createmeta (lua_State *L) {
luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */
lua_pushvalue(L, -1); /* push metatable */
lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
luaL_register(L, NULL, flib); /* file methods */
}
static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) {
*newfile(L) = f;
if (k > 0) {
lua_pushvalue(L, -1);
lua_rawseti(L, LUA_ENVIRONINDEX, k);
}
lua_pushvalue(L, -2); /* copy environment */
lua_setfenv(L, -2); /* set it */
lua_setfield(L, -3, fname);
}
static void newfenv (lua_State *L, lua_CFunction cls) {
lua_createtable(L, 0, 1);
lua_pushcfunction(L, cls);
lua_setfield(L, -2, "__close");
}
LUALIB_API int luaopen_io (lua_State *L) {
createmeta(L);
/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
newfenv(L, io_fclose);
lua_replace(L, LUA_ENVIRONINDEX);
/* open library */
luaL_register(L, LUA_IOLIBNAME, iolib);
/* create (and set) default files */
newfenv(L, io_noclose); /* close function for default files */
createstdfile(L, stdin, IO_INPUT, "stdin");
createstdfile(L, stdout, IO_OUTPUT, "stdout");
createstdfile(L, stderr, 0, "stderr");
lua_pop(L, 1); /* pop environment for default files */
return 1;
}

View File

@ -21,6 +21,9 @@ LUALIB_API int (luaopen_base) (lua_State *L);
#define LUA_TABLIBNAME "table" #define LUA_TABLIBNAME "table"
LUALIB_API int (luaopen_table) (lua_State *L); LUALIB_API int (luaopen_table) (lua_State *L);
#define LUA_IOLIBNAME "io"
LUALIB_API int (luaopen_io) (lua_State *L);
#define LUA_STRLIBNAME "string" #define LUA_STRLIBNAME "string"
LUALIB_API int (luaopen_string) (lua_State *L); LUALIB_API int (luaopen_string) (lua_State *L);

View File

@ -481,13 +481,11 @@ void COM_AddCommand(const char *name, com_func_t func)
{ {
if (!stricmp(name, cmd->name)) //case insensitive now that we have lower and uppercase! if (!stricmp(name, cmd->name)) //case insensitive now that we have lower and uppercase!
{ {
#ifdef HAVE_BLUA
// don't I_Error for Lua commands // don't I_Error for Lua commands
// Lua commands can replace game commands, and they have priority. // Lua commands can replace game commands, and they have priority.
// BUT, if for some reason we screwed up and made two console commands with the same name, // BUT, if for some reason we screwed up and made two console commands with the same name,
// it's good to have this here so we find out. // it's good to have this here so we find out.
if (cmd->function != COM_Lua_f) if (cmd->function != COM_Lua_f)
#endif
I_Error("Command %s already exists\n", name); I_Error("Command %s already exists\n", name);
return; return;
@ -501,7 +499,6 @@ void COM_AddCommand(const char *name, com_func_t func)
com_commands = cmd; com_commands = cmd;
} }
#ifdef HAVE_BLUA
/** Adds a console command for Lua. /** Adds a console command for Lua.
* No I_Errors allowed; return a negative code instead. * No I_Errors allowed; return a negative code instead.
* *
@ -534,7 +531,6 @@ int COM_AddLuaCommand(const char *name)
com_commands = cmd; com_commands = cmd;
return 0; return 0;
} }
#endif
/** Tests if a command exists. /** Tests if a command exists.
* *
@ -1427,9 +1423,7 @@ finish:
} }
var->flags |= CV_MODIFIED; var->flags |= CV_MODIFIED;
// raise 'on change' code // raise 'on change' code
#ifdef HAVE_BLUA
LUA_CVarChanged(var->name); // let consolelib know what cvar this is. LUA_CVarChanged(var->name); // let consolelib know what cvar this is.
#endif
if (var->flags & CV_CALL && !stealth) if (var->flags & CV_CALL && !stealth)
var->func(); var->func();

View File

@ -1289,6 +1289,37 @@ static boolean CL_SendJoin(void)
return HSendPacket(servernode, true, 0, sizeof (clientconfig_pak)); return HSendPacket(servernode, true, 0, sizeof (clientconfig_pak));
} }
static INT32 FindRejoinerNum(SINT8 node)
{
char strippednodeaddress[64];
const char *nodeaddress;
char *port;
INT32 i;
// Make sure there is no dead dress before proceeding to the stripping
if (!I_GetNodeAddress)
return -1;
nodeaddress = I_GetNodeAddress(node);
if (!nodeaddress)
return -1;
// Strip the address of its port
strcpy(strippednodeaddress, nodeaddress);
port = strchr(strippednodeaddress, ':');
if (port)
*port = '\0';
// Check if any player matches the stripped address
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && playeraddress[i][0] && playernode[i] == UINT8_MAX
&& !strcmp(playeraddress[i], strippednodeaddress))
return i;
}
return -1;
}
static void SV_SendServerInfo(INT32 node, tic_t servertime) static void SV_SendServerInfo(INT32 node, tic_t servertime)
{ {
UINT8 *p; UINT8 *p;
@ -1306,6 +1337,16 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers(); netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers();
netbuffer->u.serverinfo.maxplayer = (UINT8)cv_maxplayers.value; netbuffer->u.serverinfo.maxplayer = (UINT8)cv_maxplayers.value;
if (FindRejoinerNum(node) != -1)
netbuffer->u.serverinfo.refusereason = 0;
else if (!cv_allownewplayer.value)
netbuffer->u.serverinfo.refusereason = 1;
else if (D_NumPlayers() >= cv_maxplayers.value)
netbuffer->u.serverinfo.refusereason = 2;
else
netbuffer->u.serverinfo.refusereason = 0;
strncpy(netbuffer->u.serverinfo.gametypename, Gametype_Names[gametype], strncpy(netbuffer->u.serverinfo.gametypename, Gametype_Names[gametype],
sizeof netbuffer->u.serverinfo.gametypename); sizeof netbuffer->u.serverinfo.gametypename);
netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame; netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame;
@ -1863,12 +1904,17 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
} }
// Quit here rather than downloading files and being refused later. // Quit here rather than downloading files and being refused later.
if (serverlist[i].info.numberofplayer >= serverlist[i].info.maxplayer) if (serverlist[i].info.refusereason)
{ {
D_QuitNetGame(); D_QuitNetGame();
CL_Reset(); CL_Reset();
D_StartTitle(); D_StartTitle();
M_StartMessage(va(M_GetText("Maximum players reached: %d\n\nPress ESC\n"), serverlist[i].info.maxplayer), NULL, MM_NOTHING); if (serverlist[i].info.refusereason == 1)
M_StartMessage(M_GetText("The server is not accepting\njoins for the moment.\n\nPress ESC\n"), NULL, MM_NOTHING);
else if (serverlist[i].info.refusereason == 2)
M_StartMessage(va(M_GetText("Maximum players reached: %d\n\nPress ESC\n"), serverlist[i].info.maxplayer), NULL, MM_NOTHING);
else
M_StartMessage(M_GetText("You can't join.\nI don't know why,\nbut you can't join.\n\nPress ESC\n"), NULL, MM_NOTHING);
return false; return false;
} }
@ -2439,14 +2485,14 @@ static void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
if (!playeringame[playernum]) if (!playeringame[playernum])
return; return;
if (server && !demoplayback) if (server && !demoplayback && playernode[playernum] != UINT8_MAX)
{ {
INT32 node = playernode[playernum]; INT32 node = playernode[playernum];
playerpernode[node]--; playerpernode[node]--;
if (playerpernode[node] <= 0) if (playerpernode[node] <= 0)
{ {
nodeingame[playernode[playernum]] = false; nodeingame[node] = false;
Net_CloseConnection(playernode[playernum]); Net_CloseConnection(node);
ResetNode(node); ResetNode(node);
} }
} }
@ -2501,20 +2547,14 @@ static void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
} }
} }
#ifdef HAVE_BLUA
LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting
#else
(void)reason;
#endif
// don't look through someone's view who isn't there // don't look through someone's view who isn't there
if (playernum == displayplayer) if (playernum == displayplayer)
{ {
#ifdef HAVE_BLUA
// Call ViewpointSwitch hooks here. // Call ViewpointSwitch hooks here.
// The viewpoint was forcibly changed. // The viewpoint was forcibly changed.
LUAh_ViewpointSwitch(&players[consoleplayer], &players[displayplayer], true); LUAh_ViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true);
#endif
displayplayer = consoleplayer; displayplayer = consoleplayer;
} }
@ -2535,9 +2575,7 @@ static void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
RemoveAdminPlayer(playernum); // don't stay admin after you're gone RemoveAdminPlayer(playernum); // don't stay admin after you're gone
} }
#ifdef HAVE_BLUA
LUA_InvalidatePlayer(&players[playernum]); LUA_InvalidatePlayer(&players[playernum]);
#endif
if (G_TagGametype()) //Check if you still have a game. Location flexible. =P if (G_TagGametype()) //Check if you still have a game. Location flexible. =P
P_CheckSurvivors(); P_CheckSurvivors();
@ -2792,16 +2830,13 @@ static void Command_Kick(void)
if (pn == -1 || pn == 0) if (pn == -1 || pn == 0)
return; return;
if (server) // Special case if we are trying to kick a player who is downloading the game state:
// trigger a timeout instead of kicking them, because a kick would only
// take effect after they have finished downloading
if (server && playernode[pn] != UINT8_MAX && sendingsavegame[playernode[pn]])
{ {
// Special case if we are trying to kick a player who is downloading the game state: Net_ConnectionTimeout(playernode[pn]);
// trigger a timeout instead of kicking them, because a kick would only return;
// take effect after they have finished downloading
if (sendingsavegame[playernode[pn]])
{
Net_ConnectionTimeout(playernode[pn]);
return;
}
} }
WRITESINT8(p, pn); WRITESINT8(p, pn);
@ -2859,7 +2894,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
// Is playernum authorized to make this kick? // Is playernum authorized to make this kick?
if (playernum != serverplayer && !IsPlayerAdmin(playernum) if (playernum != serverplayer && !IsPlayerAdmin(playernum)
&& !(playerpernode[playernode[playernum]] == 2 && !(playernode[playernum] != UINT8_MAX && playerpernode[playernode[playernum]] == 2
&& nodetoplayer2[playernode[playernum]] == pnum)) && nodetoplayer2[playernode[playernum]] == pnum))
{ {
// We received a kick command from someone who isn't the // We received a kick command from someone who isn't the
@ -3018,7 +3053,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
} }
else if (keepbody) else if (keepbody)
{ {
if (server && !demoplayback) if (server && !demoplayback && playernode[pnum] != UINT8_MAX)
{ {
INT32 node = playernode[pnum]; INT32 node = playernode[pnum];
playerpernode[node]--; playerpernode[node]--;
@ -3134,9 +3169,7 @@ void SV_ResetServer(void)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
#ifdef HAVE_BLUA
LUA_InvalidatePlayer(&players[i]); LUA_InvalidatePlayer(&players[i]);
#endif
playeringame[i] = false; playeringame[i] = false;
playernode[i] = UINT8_MAX; playernode[i] = UINT8_MAX;
memset(playeraddress[i], 0, sizeof(*playeraddress)); memset(playeraddress[i], 0, sizeof(*playeraddress));
@ -3197,6 +3230,8 @@ void D_QuitNetGame(void)
// abort send/receive of files // abort send/receive of files
CloseNetFile(); CloseNetFile();
RemoveAllLuaFileTransfers();
waitingforluafiletransfer = false;
if (server) if (server)
{ {
@ -3230,37 +3265,6 @@ void D_QuitNetGame(void)
#endif #endif
} }
static INT32 FindRejoinerNum(SINT8 node)
{
char strippednodeaddress[64];
const char *nodeaddress;
char *port;
INT32 i;
// Make sure there is no dead dress before proceeding to the stripping
if (!I_GetNodeAddress)
return -1;
nodeaddress = I_GetNodeAddress(node);
if (!nodeaddress)
return -1;
// Strip the address of its port
strcpy(strippednodeaddress, nodeaddress);
port = strchr(strippednodeaddress, ':');
if (port)
*port = '\0';
// Check if any player matches the stripped address
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && playeraddress[i][0] && playernode[i] == UINT8_MAX
&& !strcmp(playeraddress[i], strippednodeaddress))
return i;
}
return -1;
}
// Adds a node to the game (player will follow at map change or at savegame....) // Adds a node to the game (player will follow at map change or at savegame....)
static inline void SV_AddNode(INT32 node) static inline void SV_AddNode(INT32 node)
{ {
@ -3398,10 +3402,8 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
if (server && multiplayer && motd[0] != '\0') if (server && multiplayer && motd[0] != '\0')
COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); COM_BufAddText(va("sayto %d %s\n", newplayernum, motd));
#ifdef HAVE_BLUA
if (!rejoined) if (!rejoined)
LUAh_PlayerJoin(newplayernum); LUAh_PlayerJoin(newplayernum);
#endif
} }
static boolean SV_AddWaitingPlayers(const char *name, const char *name2) static boolean SV_AddWaitingPlayers(const char *name, const char *name2)
@ -3591,7 +3593,7 @@ static void HandleConnect(SINT8 node)
rejoinernum = FindRejoinerNum(node); rejoinernum = FindRejoinerNum(node);
if (bannednode && bannednode[node]) if (bannednode && bannednode[node])
SV_SendRefuse(node, M_GetText("You have been banned\nfrom the server")); SV_SendRefuse(node, M_GetText("You have been banned\nfrom the server."));
else if (netbuffer->u.clientcfg._255 != 255 || else if (netbuffer->u.clientcfg._255 != 255 ||
netbuffer->u.clientcfg.packetversion != PACKETVERSION) netbuffer->u.clientcfg.packetversion != PACKETVERSION)
SV_SendRefuse(node, "Incompatible packet formats."); SV_SendRefuse(node, "Incompatible packet formats.");
@ -3602,13 +3604,15 @@ static void HandleConnect(SINT8 node)
|| netbuffer->u.clientcfg.subversion != SUBVERSION) || netbuffer->u.clientcfg.subversion != SUBVERSION)
SV_SendRefuse(node, va(M_GetText("Different SRB2 versions cannot\nplay a netgame!\n(server version %d.%d.%d)"), VERSION/100, VERSION%100, SUBVERSION)); SV_SendRefuse(node, va(M_GetText("Different SRB2 versions cannot\nplay a netgame!\n(server version %d.%d.%d)"), VERSION/100, VERSION%100, SUBVERSION));
else if (!cv_allownewplayer.value && node && rejoinernum == -1) else if (!cv_allownewplayer.value && node && rejoinernum == -1)
SV_SendRefuse(node, M_GetText("The server is not accepting\njoins for the moment")); SV_SendRefuse(node, M_GetText("The server is not accepting\njoins for the moment."));
else if (D_NumPlayers() >= cv_maxplayers.value && rejoinernum == -1) else if (D_NumPlayers() >= cv_maxplayers.value && rejoinernum == -1)
SV_SendRefuse(node, va(M_GetText("Maximum players reached: %d"), cv_maxplayers.value)); SV_SendRefuse(node, va(M_GetText("Maximum players reached: %d"), cv_maxplayers.value));
else if (netgame && netbuffer->u.clientcfg.localplayers > 1) // Hacked client? else if (netgame && netbuffer->u.clientcfg.localplayers > 1) // Hacked client?
SV_SendRefuse(node, M_GetText("Too many players from\nthis node.")); SV_SendRefuse(node, M_GetText("Too many players from\nthis node."));
else if (netgame && !netbuffer->u.clientcfg.localplayers) // Stealth join? else if (netgame && !netbuffer->u.clientcfg.localplayers) // Stealth join?
SV_SendRefuse(node, M_GetText("No players from\nthis node.")); SV_SendRefuse(node, M_GetText("No players from\nthis node."));
else if (luafiletransfers)
SV_SendRefuse(node, M_GetText("The server is broadcasting a file\nrequested by a Lua script.\nPlease wait a bit and then\ntry rejoining."));
else else
{ {
#ifndef NONET #ifndef NONET
@ -4195,6 +4199,18 @@ static void HandlePacketFromPlayer(SINT8 node)
Net_CloseConnection(node); Net_CloseConnection(node);
nodeingame[node] = false; nodeingame[node] = false;
break; break;
case PT_ASKLUAFILE:
if (server && luafiletransfers && luafiletransfers->nodestatus[node] == LFTNS_ASKED)
{
char *name = va("%s" PATHSEP "%s", luafiledir, luafiletransfers->filename);
boolean textmode = !strchr(luafiletransfers->mode, 'b');
SV_SendLuaFile(node, name, textmode);
}
break;
case PT_HASLUAFILE:
if (server && luafiletransfers && luafiletransfers->nodestatus[node] == LFTNS_SENDING)
SV_HandleLuaFileSent(node);
break;
// -------------------------------------------- CLIENT RECEIVE ---------- // -------------------------------------------- CLIENT RECEIVE ----------
case PT_RESYNCHEND: case PT_RESYNCHEND:
// Only accept PT_RESYNCHEND from the server. // Only accept PT_RESYNCHEND from the server.
@ -4322,6 +4338,10 @@ static void HandlePacketFromPlayer(SINT8 node)
if (client) if (client)
Got_Filetxpak(); Got_Filetxpak();
break; break;
case PT_SENDINGLUAFILE:
if (client)
CL_PrepareDownloadLuaFile();
break;
default: default:
DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n",
netbuffer->packettype, node)); netbuffer->packettype, node));
@ -4943,7 +4963,7 @@ void NetUpdate(void)
PingUpdate(); PingUpdate();
// update node latency values so we can take an average later. // update node latency values so we can take an average later.
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i]) if (playeringame[i] && playernode[i] != UINT8_MAX)
realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i])); realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i]));
pingmeasurecount++; pingmeasurecount++;
} }

View File

@ -27,7 +27,7 @@ This version is independent of the mod name, and standard
version and subversion. It should only account for the version and subversion. It should only account for the
basic fields of the packet, and change infrequently. basic fields of the packet, and change infrequently.
*/ */
#define PACKETVERSION 2 #define PACKETVERSION 3
// Network play related stuff. // Network play related stuff.
// There is a data struct that stores network // There is a data struct that stores network
@ -36,7 +36,7 @@ basic fields of the packet, and change infrequently.
// be transmitted. // be transmitted.
// Networking and tick handling related. // Networking and tick handling related.
#define BACKUPTICS 32 #define BACKUPTICS 96
#define MAXTEXTCMD 256 #define MAXTEXTCMD 256
// //
// Packet structure // Packet structure
@ -67,6 +67,10 @@ typedef enum
PT_RESYNCHEND, // Player is now resynched and is being requested to remake the gametic PT_RESYNCHEND, // Player is now resynched and is being requested to remake the gametic
PT_RESYNCHGET, // Player got resynch packet PT_RESYNCHGET, // Player got resynch packet
PT_SENDINGLUAFILE, // Server telling a client Lua needs to open a file
PT_ASKLUAFILE, // Client telling the server they don't have the file
PT_HASLUAFILE, // Client telling the server they have the file
// Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility. // Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility.
PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL
@ -361,6 +365,7 @@ typedef struct
UINT8 subversion; UINT8 subversion;
UINT8 numberofplayer; UINT8 numberofplayer;
UINT8 maxplayer; UINT8 maxplayer;
UINT8 refusereason; // 0: joinable, 1: joins disabled, 2: full
char gametypename[24]; char gametypename[24];
UINT8 modifiedgame; UINT8 modifiedgame;
UINT8 cheatsenabled; UINT8 cheatsenabled;

View File

@ -91,9 +91,7 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "hardware/hw3sound.h" #include "hardware/hw3sound.h"
#endif #endif
#ifdef HAVE_BLUA
#include "lua_script.h" #include "lua_script.h"
#endif
// platform independant focus loss // platform independant focus loss
UINT8 window_notinfocus = false; UINT8 window_notinfocus = false;
@ -746,9 +744,7 @@ void D_SRB2Loop(void)
HW3S_EndFrameUpdate(); HW3S_EndFrameUpdate();
#endif #endif
#ifdef HAVE_BLUA
LUA_Step(); LUA_Step();
#endif
} }
} }
@ -1124,7 +1120,8 @@ void D_SRB2Main(void)
// can't use sprintf since there is %u in savegamename // can't use sprintf since there is %u in savegamename
strcatbf(savegamename, srb2home, PATHSEP); strcatbf(savegamename, srb2home, PATHSEP);
#else snprintf(luafiledir, sizeof luafiledir, "%s" PATHSEP "luafiles", srb2home);
#else // DEFAULTDIR
snprintf(srb2home, sizeof srb2home, "%s", userhome); snprintf(srb2home, sizeof srb2home, "%s", userhome);
snprintf(downloaddir, sizeof downloaddir, "%s", userhome); snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
if (dedicated) if (dedicated)
@ -1134,7 +1131,9 @@ void D_SRB2Main(void)
// can't use sprintf since there is %u in savegamename // can't use sprintf since there is %u in savegamename
strcatbf(savegamename, userhome, PATHSEP); strcatbf(savegamename, userhome, PATHSEP);
#endif
snprintf(luafiledir, sizeof luafiledir, "%s" PATHSEP "luafiles", userhome);
#endif // DEFAULTDIR
} }
configfile[sizeof configfile - 1] = '\0'; configfile[sizeof configfile - 1] = '\0';

View File

@ -715,6 +715,8 @@ void Net_CloseConnection(INT32 node)
InitNode(&nodes[node]); InitNode(&nodes[node]);
SV_AbortSendFiles(node); SV_AbortSendFiles(node);
if (server)
SV_AbortLuaFileTransfer(node);
I_NetFreeNodenum(node); I_NetFreeNodenum(node);
#endif #endif
} }
@ -799,6 +801,10 @@ static const char *packettypename[NUMPACKETTYPE] =
"RESYNCHEND", "RESYNCHEND",
"RESYNCHGET", "RESYNCHGET",
"SENDINGLUAFILE",
"ASKLUAFILE",
"HASLUAFILE",
"FILEFRAGMENT", "FILEFRAGMENT",
"TEXTCMD", "TEXTCMD",
"TEXTCMD2", "TEXTCMD2",

View File

@ -157,10 +157,8 @@ static void Command_Isgamemodified_f(void);
static void Command_Cheats_f(void); static void Command_Cheats_f(void);
#ifdef _DEBUG #ifdef _DEBUG
static void Command_Togglemodified_f(void); static void Command_Togglemodified_f(void);
#ifdef HAVE_BLUA
static void Command_Archivetest_f(void); static void Command_Archivetest_f(void);
#endif #endif
#endif
// ========================================================================= // =========================================================================
// CLIENT VARIABLES // CLIENT VARIABLES
@ -415,10 +413,9 @@ const char *netxcmdnames[MAXNETXCMD - 1] =
"DELFILE", // replace next time we add an XD "DELFILE", // replace next time we add an XD
"SETMOTD", "SETMOTD",
"SUICIDE", "SUICIDE",
#ifdef HAVE_BLUA
"LUACMD", "LUACMD",
"LUAVAR" "LUAVAR",
#endif "LUAFILE"
}; };
// ========================================================================= // =========================================================================
@ -451,9 +448,8 @@ void D_RegisterServerCommands(void)
RegisterNetXCmd(XD_PAUSE, Got_Pause); RegisterNetXCmd(XD_PAUSE, Got_Pause);
RegisterNetXCmd(XD_SUICIDE, Got_Suicide); RegisterNetXCmd(XD_SUICIDE, Got_Suicide);
RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd); RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd);
#ifdef HAVE_BLUA
RegisterNetXCmd(XD_LUACMD, Got_Luacmd); RegisterNetXCmd(XD_LUACMD, Got_Luacmd);
#endif RegisterNetXCmd(XD_LUAFILE, Got_LuaFile);
// Remote Administration // Remote Administration
COM_AddCommand("password", Command_Changepassword_f); COM_AddCommand("password", Command_Changepassword_f);
@ -502,9 +498,7 @@ void D_RegisterServerCommands(void)
COM_AddCommand("cheats", Command_Cheats_f); // test COM_AddCommand("cheats", Command_Cheats_f); // test
#ifdef _DEBUG #ifdef _DEBUG
COM_AddCommand("togglemodified", Command_Togglemodified_f); COM_AddCommand("togglemodified", Command_Togglemodified_f);
#ifdef HAVE_BLUA
COM_AddCommand("archivetest", Command_Archivetest_f); COM_AddCommand("archivetest", Command_Archivetest_f);
#endif
#endif #endif
// for master server connection // for master server connection
@ -913,7 +907,7 @@ void D_RegisterClientCommands(void)
#ifdef _DEBUG #ifdef _DEBUG
COM_AddCommand("causecfail", Command_CauseCfail_f); COM_AddCommand("causecfail", Command_CauseCfail_f);
#endif #endif
#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) #ifdef LUA_ALLOW_BYTECODE
COM_AddCommand("dumplua", Command_Dumplua_f); COM_AddCommand("dumplua", Command_Dumplua_f);
#endif #endif
} }
@ -2027,9 +2021,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
UINT8 flags; UINT8 flags;
INT32 resetplayer = 1, lastgametype; INT32 resetplayer = 1, lastgametype;
UINT8 skipprecutscene, FLS; UINT8 skipprecutscene, FLS;
#ifdef HAVE_BLUA
INT16 mapnumber; INT16 mapnumber;
#endif
if (playernum != serverplayer && !IsPlayerAdmin(playernum)) if (playernum != serverplayer && !IsPlayerAdmin(playernum))
{ {
@ -2091,10 +2083,8 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
CV_StealthSetValue(&cv_playercolor, players[0].skincolor); CV_StealthSetValue(&cv_playercolor, players[0].skincolor);
} }
#ifdef HAVE_BLUA
mapnumber = M_MapNumber(mapname[3], mapname[4]); mapnumber = M_MapNumber(mapname[3], mapname[4]);
LUAh_MapChange(mapnumber); LUAh_MapChange(mapnumber);
#endif
G_InitNew(ultimatemode, mapname, resetplayer, skipprecutscene, FLS); G_InitNew(ultimatemode, mapname, resetplayer, skipprecutscene, FLS);
if (demoplayback && !timingdemo) if (demoplayback && !timingdemo)
@ -2678,11 +2668,9 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
return; return;
} }
#ifdef HAVE_BLUA
// Don't switch team, just go away, please, go awaayyyy, aaauuauugghhhghgh // Don't switch team, just go away, please, go awaayyyy, aaauuauugghhhghgh
if (!LUAh_TeamSwitch(&players[playernum], NetPacket.packet.newteam, players[playernum].spectator, NetPacket.packet.autobalance, NetPacket.packet.scrambled)) if (!LUAh_TeamSwitch(&players[playernum], NetPacket.packet.newteam, players[playernum].spectator, NetPacket.packet.autobalance, NetPacket.packet.scrambled))
return; return;
#endif
//no status changes after hidetime //no status changes after hidetime
if ((gametyperules & GTR_HIDEFROZEN) && (leveltime >= (hidetime * TICRATE))) if ((gametyperules & GTR_HIDEFROZEN) && (leveltime >= (hidetime * TICRATE)))
@ -2839,12 +2827,10 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
//reset view if you are changed, or viewing someone who was changed. //reset view if you are changed, or viewing someone who was changed.
if (playernum == consoleplayer || displayplayer == playernum) if (playernum == consoleplayer || displayplayer == playernum)
{ {
#ifdef HAVE_BLUA
// Call ViewpointSwitch hooks here. // Call ViewpointSwitch hooks here.
// The viewpoint was forcibly changed. // The viewpoint was forcibly changed.
if (displayplayer != consoleplayer) // You're already viewing yourself. No big deal. if (displayplayer != consoleplayer) // You're already viewing yourself. No big deal.
LUAh_ViewpointSwitch(&players[playernum], &players[displayplayer], true); LUAh_ViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true);
#endif
displayplayer = consoleplayer; displayplayer = consoleplayer;
} }
@ -3342,10 +3328,6 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
boolean kick = false; boolean kick = false;
boolean toomany = false; boolean toomany = false;
INT32 i,j; INT32 i,j;
serverinfo_pak *dummycheck = NULL;
// Shut the compiler up.
(void)dummycheck;
READSTRINGN(*cp, filename, 240); READSTRINGN(*cp, filename, 240);
READMEM(*cp, md5sum, 16); READMEM(*cp, md5sum, 16);
@ -3753,11 +3735,11 @@ static void ExitMove_OnChange(void)
{ {
if (players[i].mo->target && players[i].mo->target->type == MT_SIGN) if (players[i].mo->target && players[i].mo->target->type == MT_SIGN)
P_SetTarget(&players[i].mo->target, NULL); P_SetTarget(&players[i].mo->target, NULL);
if (players[i].pflags & PF_FINISHED) if (players[i].pflags & PF_FINISHED)
P_GiveFinishFlags(&players[i]); P_GiveFinishFlags(&players[i]);
} }
CONS_Printf(M_GetText("Players can now move after completing the level.\n")); CONS_Printf(M_GetText("Players can now move after completing the level.\n"));
} }
else else
@ -4334,7 +4316,6 @@ static void Command_Togglemodified_f(void)
modifiedgame = !modifiedgame; modifiedgame = !modifiedgame;
} }
#ifdef HAVE_BLUA
extern UINT8 *save_p; extern UINT8 *save_p;
static void Command_Archivetest_f(void) static void Command_Archivetest_f(void)
{ {
@ -4379,7 +4360,6 @@ static void Command_Archivetest_f(void)
CONS_Printf("Done. No crash.\n"); CONS_Printf("Done. No crash.\n");
} }
#endif #endif
#endif
/** Makes a change to ::cv_forceskin take effect immediately. /** Makes a change to ::cv_forceskin take effect immediately.
* *

View File

@ -142,10 +142,9 @@ typedef enum
XD_SETMOTD, // 19 XD_SETMOTD, // 19
XD_SUICIDE, // 20 XD_SUICIDE, // 20
XD_DEMOTED, // 21 XD_DEMOTED, // 21
#ifdef HAVE_BLUA
XD_LUACMD, // 22 XD_LUACMD, // 22
XD_LUAVAR, // 23 XD_LUAVAR, // 23
#endif XD_LUAFILE, // 24
MAXNETXCMD MAXNETXCMD
} netxcmd_t; } netxcmd_t;

View File

@ -69,6 +69,7 @@ typedef struct filetx_s
UINT32 size; // Size of the file UINT32 size; // Size of the file
UINT8 fileid; UINT8 fileid;
INT32 node; // Destination INT32 node; // Destination
boolean textmode; // For files requested by Lua without the "b" option
struct filetx_s *next; // Next file in the list struct filetx_s *next; // Next file in the list
} filetx_t; } filetx_t;
@ -94,6 +95,11 @@ char downloaddir[512] = "DOWNLOAD";
INT32 lastfilenum = -1; INT32 lastfilenum = -1;
#endif #endif
luafiletransfer_t *luafiletransfers = NULL;
boolean waitingforluafiletransfer = false;
char luafiledir[256 + 16] = "luafiles";
/** Fills a serverinfo packet with information about wad files loaded. /** Fills a serverinfo packet with information about wad files loaded.
* *
* \todo Give this function a better name since it is in global scope. * \todo Give this function a better name since it is in global scope.
@ -159,6 +165,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr)
fileneeded[i].file = NULL; // The file isn't open yet fileneeded[i].file = NULL; // The file isn't open yet
READSTRINGN(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name READSTRINGN(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name
READMEM(p, fileneeded[i].md5sum, 16); // The last 16 bytes are the file checksum READMEM(p, fileneeded[i].md5sum, 16); // The last 16 bytes are the file checksum
fileneeded[i].textmode = false;
} }
} }
@ -170,6 +177,7 @@ void CL_PrepareDownloadSaveGame(const char *tmpsave)
fileneeded[0].file = NULL; fileneeded[0].file = NULL;
memset(fileneeded[0].md5sum, 0, 16); memset(fileneeded[0].md5sum, 0, 16);
strcpy(fileneeded[0].filename, tmpsave); strcpy(fileneeded[0].filename, tmpsave);
fileneeded[0].textmode = false;
} }
/** Checks the server to see if we CAN download all the files, /** Checks the server to see if we CAN download all the files,
@ -448,6 +456,162 @@ void CL_LoadServerFiles(void)
} }
} }
void AddLuaFileTransfer(const char *filename, const char *mode)
{
luafiletransfer_t **prevnext; // A pointer to the "next" field of the last transfer in the list
luafiletransfer_t *filetransfer;
static INT32 id;
//CONS_Printf("AddLuaFileTransfer \"%s\"\n", filename);
// Find the last transfer in the list and set a pointer to its "next" field
prevnext = &luafiletransfers;
while (*prevnext)
prevnext = &((*prevnext)->next);
// Allocate file transfer information and append it to the transfer list
filetransfer = malloc(sizeof(luafiletransfer_t));
if (!filetransfer)
I_Error("AddLuaFileTransfer: Out of memory\n");
*prevnext = filetransfer;
filetransfer->next = NULL;
// Allocate the file name
filetransfer->filename = strdup(filename);
if (!filetransfer->filename)
I_Error("AddLuaFileTransfer: Out of memory\n");
// Create and allocate the real file name
if (server)
filetransfer->realfilename = strdup(va("%s" PATHSEP "%s",
luafiledir, filename));
else
filetransfer->realfilename = strdup(va("%s" PATHSEP "client" PATHSEP "$$$%d%d.tmp",
luafiledir, rand(), rand()));
if (!filetransfer->realfilename)
I_Error("AddLuaFileTransfer: Out of memory\n");
strlcpy(filetransfer->mode, mode, sizeof(filetransfer->mode));
if (server)
{
INT32 i;
// Set status to "waiting" for everyone
for (i = 0; i < MAXNETNODES; i++)
filetransfer->nodestatus[i] = LFTNS_WAITING;
if (!luafiletransfers->next) // Only if there is no transfer already going on
{
if (FIL_ReadFileOK(filetransfer->realfilename))
SV_PrepareSendLuaFileToNextNode();
else
{
// Send a net command with 0 as its first byte to indicate the file couldn't be opened
UINT8 success = 0;
SendNetXCmd(XD_LUAFILE, &success, 1);
}
}
}
// Store the callback so it can be called once everyone has the file
filetransfer->id = id;
StoreLuaFileCallback(id);
id++;
if (waitingforluafiletransfer)
{
waitingforluafiletransfer = false;
CL_PrepareDownloadLuaFile();
}
}
void SV_PrepareSendLuaFileToNextNode(void)
{
INT32 i;
UINT8 success = 1;
// Find a client to send the file to
for (i = 1; i < MAXNETNODES; i++)
if (nodeingame[i] && luafiletransfers->nodestatus[i] == LFTNS_WAITING) // Node waiting
{
// Tell the client we're about to send them the file
netbuffer->packettype = PT_SENDINGLUAFILE;
if (!HSendPacket(i, true, 0, 0))
I_Error("Failed to send a PT_SENDINGLUAFILE packet\n"); // !!! Todo: Handle failure a bit better lol
luafiletransfers->nodestatus[i] = LFTNS_ASKED;
return;
}
// No client found, everyone has the file
// Send a net command with 1 as its first byte to indicate the file could be opened
SendNetXCmd(XD_LUAFILE, &success, 1);
}
void SV_HandleLuaFileSent(UINT8 node)
{
luafiletransfers->nodestatus[node] = LFTNS_SENT;
SV_PrepareSendLuaFileToNextNode();
}
void RemoveLuaFileTransfer(void)
{
luafiletransfer_t *filetransfer = luafiletransfers;
RemoveLuaFileCallback(filetransfer->id);
luafiletransfers = filetransfer->next;
free(filetransfer->filename);
free(filetransfer->realfilename);
free(filetransfer);
}
void RemoveAllLuaFileTransfers(void)
{
while (luafiletransfers)
RemoveLuaFileTransfer();
}
void SV_AbortLuaFileTransfer(INT32 node)
{
if (luafiletransfers
&& (luafiletransfers->nodestatus[node] == LFTNS_ASKED
|| luafiletransfers->nodestatus[node] == LFTNS_SENDING))
{
luafiletransfers->nodestatus[node] = LFTNS_WAITING;
SV_PrepareSendLuaFileToNextNode();
}
}
void CL_PrepareDownloadLuaFile(void)
{
// If there is no transfer in the list, this normally means the server
// called io.open before us, so we have to wait until we call it too
if (!luafiletransfers)
{
waitingforluafiletransfer = true;
return;
}
// Tell the server we are ready to receive the file
netbuffer->packettype = PT_ASKLUAFILE;
HSendPacket(servernode, true, 0, 0);
fileneedednum = 1;
fileneeded[0].status = FS_REQUESTED;
fileneeded[0].totalsize = UINT32_MAX;
fileneeded[0].file = NULL;
memset(fileneeded[0].md5sum, 0, 16);
strcpy(fileneeded[0].filename, luafiletransfers->realfilename);
fileneeded[0].textmode = !strchr(luafiletransfers->mode, 'b');
// Make sure all directories in the file path exist
MakePathDirs(fileneeded[0].filename);
}
// Number of files to send // Number of files to send
// Little optimization to quickly test if there is a file in the queue // Little optimization to quickly test if there is a file in the queue
static INT32 filestosend = 0; static INT32 filestosend = 0;
@ -458,6 +622,7 @@ static INT32 filestosend = 0;
* \param filename The file to send * \param filename The file to send
* \param fileid ??? * \param fileid ???
* \sa SV_SendRam * \sa SV_SendRam
* \sa SV_SendLuaFile
* *
*/ */
static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid) static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid)
@ -548,6 +713,7 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid)
* \param freemethod How to free the block after it has been sent * \param freemethod How to free the block after it has been sent
* \param fileid ??? * \param fileid ???
* \sa SV_SendFile * \sa SV_SendFile
* \sa SV_SendLuaFile
* *
*/ */
void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid) void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid)
@ -579,6 +745,55 @@ void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UI
filestosend++; filestosend++;
} }
/** Adds a file requested by Lua to the file list for a node
*
* \param node The node to send the file to
* \param filename The file to send
* \sa SV_SendFile
* \sa SV_SendRam
*
*/
boolean SV_SendLuaFile(INT32 node, const char *filename, boolean textmode)
{
filetx_t **q; // A pointer to the "next" field of the last file in the list
filetx_t *p; // The new file request
//INT32 i;
//char wadfilename[MAX_WADPATH];
luafiletransfers->nodestatus[node] = LFTNS_SENDING;
// Find the last file in the list and set a pointer to its "next" field
q = &transfer[node].txlist;
while (*q)
q = &((*q)->next);
// Allocate a file request and append it to the file list
p = *q = (filetx_t *)malloc(sizeof (filetx_t));
if (!p)
I_Error("SV_SendLuaFile: No more memory\n");
// Initialise with zeros
memset(p, 0, sizeof (filetx_t));
// Allocate the file name
p->id.filename = (char *)malloc(MAX_WADPATH); // !!!
if (!p->id.filename)
I_Error("SV_SendLuaFile: No more memory\n");
// Set the file name and get rid of the path
strlcpy(p->id.filename, filename, MAX_WADPATH); // !!!
//nameonly(p->id.filename);
// Open in text mode if required by the Lua script
p->textmode = textmode;
DEBFILE(va("Sending Lua file %s to %d\n", filename, node));
p->ram = SF_FILE; // It's a file, we need to close it and free its name once we're done sending it
p->next = NULL; // End of list
filestosend++;
return true;
}
/** Stops sending a file for a node, and removes the file request from the list, /** Stops sending a file for a node, and removes the file request from the list,
* either because the file has been fully sent or because the node was disconnected * either because the file has been fully sent or because the node was disconnected
* *
@ -684,7 +899,7 @@ void SV_FileSendTicker(void)
long filesize; long filesize;
transfer[i].currentfile = transfer[i].currentfile =
fopen(f->id.filename, "rb"); fopen(f->id.filename, f->textmode ? "r" : "rb");
if (!transfer[i].currentfile) if (!transfer[i].currentfile)
I_Error("File %s does not exist", I_Error("File %s does not exist",
@ -715,11 +930,20 @@ void SV_FileSendTicker(void)
size = f->size-transfer[i].position; size = f->size-transfer[i].position;
if (ram) if (ram)
M_Memcpy(p->data, &f->id.ram[transfer[i].position], size); M_Memcpy(p->data, &f->id.ram[transfer[i].position], size);
else if (fread(p->data, 1, size, transfer[i].currentfile) != size) else
I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->id.filename, transfer[i].position, M_FileError(transfer[i].currentfile)); {
size_t n = fread(p->data, 1, size, transfer[i].currentfile);
if (n != size) // Either an error or Windows turning CR-LF into LF
{
if (f->textmode && feof(transfer[i].currentfile))
size = n;
else if (fread(p->data, 1, size, transfer[i].currentfile) != size)
I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->id.filename, transfer[i].position, M_FileError(transfer[i].currentfile));
}
}
p->position = LONG(transfer[i].position); p->position = LONG(transfer[i].position);
// Put flag so receiver knows the total size // Put flag so receiver knows the total size
if (transfer[i].position + size == f->size) if (transfer[i].position + size == f->size || (f->textmode && feof(transfer[i].currentfile)))
p->position |= LONG(0x80000000); p->position |= LONG(0x80000000);
p->fileid = f->fileid; p->fileid = f->fileid;
p->size = SHORT((UINT16)size); p->size = SHORT((UINT16)size);
@ -728,7 +952,7 @@ void SV_FileSendTicker(void)
if (HSendPacket(i, true, 0, FILETXHEADER + size)) // Reliable SEND if (HSendPacket(i, true, 0, FILETXHEADER + size)) // Reliable SEND
{ // Success { // Success
transfer[i].position = (UINT32)(transfer[i].position + size); transfer[i].position = (UINT32)(transfer[i].position + size);
if (transfer[i].position == f->size) // Finish? if (transfer[i].position == f->size || (f->textmode && feof(transfer[i].currentfile))) // Finish?
SV_EndFileSend(i); SV_EndFileSend(i);
} }
else else
@ -772,7 +996,7 @@ void Got_Filetxpak(void)
{ {
if (file->file) if (file->file)
I_Error("Got_Filetxpak: already open file\n"); I_Error("Got_Filetxpak: already open file\n");
file->file = fopen(filename, "wb"); file->file = fopen(filename, file->textmode ? "w" : "wb");
if (!file->file) if (!file->file)
I_Error("Can't create file %s: %s", filename, strerror(errno)); I_Error("Can't create file %s: %s", filename, strerror(errno));
CONS_Printf("\r%s...\n",filename); CONS_Printf("\r%s...\n",filename);
@ -793,7 +1017,7 @@ void Got_Filetxpak(void)
} }
// We can receive packet in the wrong order, anyway all os support gaped file // We can receive packet in the wrong order, anyway all os support gaped file
fseek(file->file, pos, SEEK_SET); fseek(file->file, pos, SEEK_SET);
if (fwrite(netbuffer->u.filetxpak.data,size,1,file->file) != 1) if (size && fwrite(netbuffer->u.filetxpak.data,size,1,file->file) != 1)
I_Error("Can't write to %s: %s\n",filename, M_FileError(file->file)); I_Error("Can't write to %s: %s\n",filename, M_FileError(file->file));
file->currentsize += size; file->currentsize += size;
@ -805,6 +1029,12 @@ void Got_Filetxpak(void)
file->status = FS_FOUND; file->status = FS_FOUND;
CONS_Printf(M_GetText("Downloading %s...(done)\n"), CONS_Printf(M_GetText("Downloading %s...(done)\n"),
filename); filename);
if (luafiletransfers)
{
// Tell the server we have received the file
netbuffer->packettype = PT_HASLUAFILE;
HSendPacket(servernode, true, 0, 0);
}
} }
} }
else else

View File

@ -13,6 +13,7 @@
#ifndef __D_NETFIL__ #ifndef __D_NETFIL__
#define __D_NETFIL__ #define __D_NETFIL__
#include "d_net.h"
#include "w_wad.h" #include "w_wad.h"
typedef enum typedef enum
@ -43,6 +44,7 @@ typedef struct
UINT32 currentsize; UINT32 currentsize;
UINT32 totalsize; UINT32 totalsize;
filestatus_t status; // The value returned by recsearch filestatus_t status; // The value returned by recsearch
boolean textmode; // For files requested by Lua without the "b" option
} fileneeded_t; } fileneeded_t;
extern INT32 fileneedednum; extern INT32 fileneedednum;
@ -70,6 +72,42 @@ boolean CL_CheckDownloadable(void);
boolean CL_SendRequestFile(void); boolean CL_SendRequestFile(void);
boolean Got_RequestFilePak(INT32 node); boolean Got_RequestFilePak(INT32 node);
typedef enum
{
LFTNS_WAITING, // This node is waiting for the server to send the file
LFTNS_ASKED, // The server has told the node they're ready to send the file
LFTNS_SENDING, // The server is sending the file to this node
LFTNS_SENT // The node already has the file
} luafiletransfernodestatus_t;
typedef struct luafiletransfer_s
{
char *filename;
char *realfilename;
char mode[4]; // rb+/wb+/ab+ + null character
INT32 id; // Callback ID
luafiletransfernodestatus_t nodestatus[MAXNETNODES];
struct luafiletransfer_s *next;
} luafiletransfer_t;
extern luafiletransfer_t *luafiletransfers;
extern boolean waitingforluafiletransfer;
extern char luafiledir[256 + 16];
void AddLuaFileTransfer(const char *filename, const char *mode);
void SV_PrepareSendLuaFileToNextNode(void);
boolean SV_SendLuaFile(INT32 node, const char *filename, boolean textmode);
void SV_PrepareSendLuaFile(const char *filename);
void SV_HandleLuaFileSent(UINT8 node);
void RemoveLuaFileTransfer(void);
void RemoveAllLuaFileTransfers(void);
void SV_AbortLuaFileTransfer(INT32 node);
void CL_PrepareDownloadLuaFile(void);
void Got_LuaFile(UINT8 **cp, INT32 playernum);
void StoreLuaFileCallback(INT32 id);
void RemoveLuaFileCallback(INT32 id);
void MakePathDirs(char *path);
void SV_AbortSendFiles(INT32 node); void SV_AbortSendFiles(INT32 node);
void CloseNetFile(void); void CloseNetFile(void);

View File

@ -40,9 +40,7 @@
#include "m_cond.h" #include "m_cond.h"
#ifdef HAVE_BLUA
#include "v_video.h" // video flags (for lua) #include "v_video.h" // video flags (for lua)
#endif
#ifdef HWRENDER #ifdef HWRENDER
#include "hardware/hw_light.h" #include "hardware/hw_light.h"
@ -77,10 +75,8 @@ static UINT16 get_mus(const char *word, UINT8 dehacked_mode);
#endif #endif
static hudnum_t get_huditem(const char *word); static hudnum_t get_huditem(const char *word);
static menutype_t get_menutype(const char *word); static menutype_t get_menutype(const char *word);
#ifndef HAVE_BLUA //static INT16 get_gametype(const char *word);
static INT16 get_gametype(const char *word); //static powertype_t get_power(const char *word);
static powertype_t get_power(const char *word);
#endif
boolean deh_loaded = false; boolean deh_loaded = false;
static int dbg_line; static int dbg_line;
@ -1250,7 +1246,7 @@ static void readgametype(MYFILE *f, char *gtname)
newgttol = (UINT32)i; newgttol = (UINT32)i;
else else
{ {
UINT16 tol = 0; UINT32 tol = 0;
tmp = strtok(word2,","); tmp = strtok(word2,",");
do { do {
for (i = 0; TYPEOFLEVEL[i].name; i++) for (i = 0; TYPEOFLEVEL[i].name; i++)
@ -1416,7 +1412,6 @@ static void readlevelheader(MYFILE *f, INT32 num)
// Lua custom options also go above, contents may be case sensitive. // Lua custom options also go above, contents may be case sensitive.
if (fastncmp(word, "LUA.", 4)) if (fastncmp(word, "LUA.", 4))
{ {
#ifdef HAVE_BLUA
UINT8 j; UINT8 j;
customoption_t *modoption; customoption_t *modoption;
@ -1450,9 +1445,6 @@ static void readlevelheader(MYFILE *f, INT32 num)
modoption->option[31] = '\0'; modoption->option[31] = '\0';
strncpy(modoption->value, word2, 255); strncpy(modoption->value, word2, 255);
modoption->value[255] = '\0'; modoption->value[255] = '\0';
#else
// Silently ignore.
#endif
continue; continue;
} }
@ -1592,7 +1584,7 @@ static void readlevelheader(MYFILE *f, INT32 num)
mapheaderinfo[num-1]->typeoflevel = (UINT32)i; mapheaderinfo[num-1]->typeoflevel = (UINT32)i;
else else
{ {
UINT16 tol = 0; UINT32 tol = 0;
tmp = strtok(word2,","); tmp = strtok(word2,",");
do { do {
for (i = 0; TYPEOFLEVEL[i].name; i++) for (i = 0; TYPEOFLEVEL[i].name; i++)
@ -3124,22 +3116,20 @@ static void readframe(MYFILE *f, INT32 num)
} }
z = 0; z = 0;
#ifdef HAVE_BLUA
found = LUA_SetLuaAction(&states[num], actiontocompare); found = LUA_SetLuaAction(&states[num], actiontocompare);
if (!found) if (!found)
#endif while (actionpointers[z].name)
while (actionpointers[z].name)
{
if (fastcmp(actiontocompare, actionpointers[z].name))
{ {
states[num].action = actionpointers[z].action; if (fastcmp(actiontocompare, actionpointers[z].name))
states[num].action.acv = actionpointers[z].action.acv; // assign {
states[num].action.acp1 = actionpointers[z].action.acp1; states[num].action = actionpointers[z].action;
found = true; states[num].action.acv = actionpointers[z].action.acv; // assign
break; states[num].action.acp1 = actionpointers[z].action.acp1;
found = true;
break;
}
z++;
} }
z++;
}
if (!found) if (!found)
deh_warning("Unknown action %s", actiontocompare); deh_warning("Unknown action %s", actiontocompare);
@ -7478,7 +7468,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit
// Got Flag Sign // Got Flag Sign
"S_GOTFLAG", "S_GOTFLAG",
// Finish flag // Finish flag
"S_FINISHFLAG", "S_FINISHFLAG",
@ -8849,14 +8839,12 @@ static const char *const MOBJEFLAG_LIST[] = {
NULL NULL
}; };
#ifdef HAVE_BLUA
static const char *const MAPTHINGFLAG_LIST[4] = { static const char *const MAPTHINGFLAG_LIST[4] = {
"EXTRA", // Extra flag for objects. "EXTRA", // Extra flag for objects.
"OBJECTFLIP", // Reverse gravity flag for objects. "OBJECTFLIP", // Reverse gravity flag for objects.
"OBJECTSPECIAL", // Special flag used with certain objects. "OBJECTSPECIAL", // Special flag used with certain objects.
"AMBUSH" // Deaf monsters/do not react to sound. "AMBUSH" // Deaf monsters/do not react to sound.
}; };
#endif
static const char *const PLAYERFLAG_LIST[] = { static const char *const PLAYERFLAG_LIST[] = {
@ -8953,7 +8941,6 @@ static const char *const GAMETYPERULE_LIST[] = {
NULL NULL
}; };
#ifdef HAVE_BLUA
// Linedef flags // Linedef flags
static const char *const ML_LIST[16] = { static const char *const ML_LIST[16] = {
"IMPASSIBLE", "IMPASSIBLE",
@ -8973,7 +8960,6 @@ static const char *const ML_LIST[16] = {
"BOUNCY", "BOUNCY",
"TFERLINE" "TFERLINE"
}; };
#endif
// This DOES differ from r_draw's Color_Names, unfortunately. // This DOES differ from r_draw's Color_Names, unfortunately.
// Also includes Super colors // Also includes Super colors
@ -9272,11 +9258,7 @@ static const char *const MENUTYPES_LIST[] = {
struct { struct {
const char *n; const char *n;
// has to be able to hold both fixed_t and angle_t, so drastic measure!! // has to be able to hold both fixed_t and angle_t, so drastic measure!!
#ifdef HAVE_BLUA
lua_Integer v; lua_Integer v;
#else
INT64 v;
#endif
} const INT_CONST[] = { } const INT_CONST[] = {
// If a mod removes some variables here, // If a mod removes some variables here,
// please leave the names in-tact and just set // please leave the names in-tact and just set
@ -9532,7 +9514,6 @@ struct {
{"ME_ULTIMATE",ME_ULTIMATE}, {"ME_ULTIMATE",ME_ULTIMATE},
{"ME_PERFECT",ME_PERFECT}, {"ME_PERFECT",ME_PERFECT},
#ifdef HAVE_BLUA
// p_local.h constants // p_local.h constants
{"FLOATSPEED",FLOATSPEED}, {"FLOATSPEED",FLOATSPEED},
{"MAXSTEPMOVE",MAXSTEPMOVE}, {"MAXSTEPMOVE",MAXSTEPMOVE},
@ -9865,7 +9846,6 @@ struct {
{"TC_RAINBOW",TC_RAINBOW}, {"TC_RAINBOW",TC_RAINBOW},
{"TC_BLINK",TC_BLINK}, {"TC_BLINK",TC_BLINK},
{"TC_DASHMODE",TC_DASHMODE}, {"TC_DASHMODE",TC_DASHMODE},
#endif
{NULL,0} {NULL,0}
}; };
@ -10022,8 +10002,7 @@ static menutype_t get_menutype(const char *word)
return MN_NONE; return MN_NONE;
} }
#ifndef HAVE_BLUA /*static INT16 get_gametype(const char *word)
static INT16 get_gametype(const char *word)
{ // Returns the value of GT_ enumerations { // Returns the value of GT_ enumerations
INT16 i; INT16 i;
if (*word >= '0' && *word <= '9') if (*word >= '0' && *word <= '9')
@ -10049,7 +10028,7 @@ static powertype_t get_power(const char *word)
return i; return i;
deh_warning("Couldn't find power named 'pw_%s'",word); deh_warning("Couldn't find power named 'pw_%s'",word);
return pw_invulnerability; return pw_invulnerability;
} }*/
/// \todo Make ANY of this completely over-the-top math craziness obey the order of operations. /// \todo Make ANY of this completely over-the-top math craziness obey the order of operations.
static fixed_t op_mul(fixed_t a, fixed_t b) { return a*b; } static fixed_t op_mul(fixed_t a, fixed_t b) { return a*b; }
@ -10077,7 +10056,7 @@ struct {
}; };
// Returns the full word, cut at the first symbol or whitespace // Returns the full word, cut at the first symbol or whitespace
static char *read_word(const char *line) /*static char *read_word(const char *line)
{ {
// Part 1: You got the start of the word, now find the end. // Part 1: You got the start of the word, now find the end.
const char *p; const char *p;
@ -10237,7 +10216,7 @@ static fixed_t find_const(const char **rword)
free(word); free(word);
return r; return r;
} }
else if (fastncmp("GT_",word,4)) { else if (fastncmp("GT_",word,3)) {
r = get_gametype(word); r = get_gametype(word);
free(word); free(word);
return r; return r;
@ -10307,16 +10286,14 @@ static fixed_t find_const(const char **rword)
const_warning("constant",word); const_warning("constant",word);
free(word); free(word);
return 0; return 0;
} }*/
#endif
// Loops through every constant and operation in word and performs its calculations, returning the final value. // Loops through every constant and operation in word and performs its calculations, returning the final value.
fixed_t get_number(const char *word) fixed_t get_number(const char *word)
{ {
#ifdef HAVE_BLUA
return LUA_EvalMath(word); return LUA_EvalMath(word);
#else
// DESPERATELY NEEDED: Order of operations support! :x /*// DESPERATELY NEEDED: Order of operations support! :x
fixed_t i = find_const(&word); fixed_t i = find_const(&word);
INT32 o; INT32 o;
while(*word) { while(*word) {
@ -10326,8 +10303,7 @@ fixed_t get_number(const char *word)
else else
break; break;
} }
return i; return i;*/
#endif
} }
void DEH_Check(void) void DEH_Check(void)
@ -10352,7 +10328,6 @@ void DEH_Check(void)
#endif #endif
} }
#ifdef HAVE_BLUA
#include "lua_script.h" #include "lua_script.h"
#include "lua_libs.h" #include "lua_libs.h"
@ -10978,5 +10953,3 @@ void LUA_SetActionByName(void *state, const char *actiontocompare)
} }
} }
} }
#endif // HAVE_BLUA

View File

@ -34,11 +34,9 @@ void DEH_Check(void);
fixed_t get_number(const char *word); fixed_t get_number(const char *word);
#ifdef HAVE_BLUA
boolean LUA_SetLuaAction(void *state, const char *actiontocompare); boolean LUA_SetLuaAction(void *state, const char *actiontocompare);
const char *LUA_GetActionName(void *action); const char *LUA_GetActionName(void *action);
void LUA_SetActionByName(void *state, const char *actiontocompare); void LUA_SetActionByName(void *state, const char *actiontocompare);
#endif
extern boolean deh_loaded; extern boolean deh_loaded;

View File

@ -493,7 +493,6 @@ extern UINT16 emeralds;
#define EMERALD7 64 #define EMERALD7 64
#define ALL7EMERALDS(v) ((v & (EMERALD1|EMERALD2|EMERALD3|EMERALD4|EMERALD5|EMERALD6|EMERALD7)) == (EMERALD1|EMERALD2|EMERALD3|EMERALD4|EMERALD5|EMERALD6|EMERALD7)) #define ALL7EMERALDS(v) ((v & (EMERALD1|EMERALD2|EMERALD3|EMERALD4|EMERALD5|EMERALD6|EMERALD7)) == (EMERALD1|EMERALD2|EMERALD3|EMERALD4|EMERALD5|EMERALD6|EMERALD7))
// yes, even in non HAVE_BLUA
#define NUM_LUABANKS 16 // please only make this number go up between versions, never down. you'll break saves otherwise. also, must fit in UINT8 #define NUM_LUABANKS 16 // please only make this number go up between versions, never down. you'll break saves otherwise. also, must fit in UINT8
extern INT32 luabanks[NUM_LUABANKS]; extern INT32 luabanks[NUM_LUABANKS];

View File

@ -39,9 +39,7 @@
#include "fastcmp.h" #include "fastcmp.h"
#include "console.h" #include "console.h"
#ifdef HAVE_BLUA
#include "lua_hud.h" #include "lua_hud.h"
#endif
// Stage of animation: // Stage of animation:
// 0 = text, 1 = art screen // 0 = text, 1 = art screen
@ -2762,11 +2760,7 @@ void F_TitleScreenDrawer(void)
// rei|miru: use title pics? // rei|miru: use title pics?
hidepics = curhidepics; hidepics = curhidepics;
if (hidepics) if (hidepics)
#ifdef HAVE_BLUA
goto luahook; goto luahook;
#else
return;
#endif
switch(curttmode) switch(curttmode)
{ {
@ -3488,10 +3482,8 @@ void F_TitleScreenDrawer(void)
break; break;
} }
#ifdef HAVE_BLUA
luahook: luahook:
LUAh_TitleHUD(); LUAh_TitleHUD();
#endif
} }
// separate animation timer for backgrounds, since we also count // separate animation timer for backgrounds, since we also count

View File

@ -33,9 +33,7 @@
#include "doomstat.h" #include "doomstat.h"
#ifdef HAVE_BLUA
#include "lua_hud.h" // level title #include "lua_hud.h" // level title
#endif
#ifdef HWRENDER #ifdef HWRENDER
#include "hardware/hw_main.h" #include "hardware/hw_main.h"

View File

@ -60,7 +60,7 @@ typedef enum
#endif #endif
EXT_PK3, EXT_PK3,
EXT_SOC, EXT_SOC,
EXT_LUA, // allowed even if not HAVE_BLUA so that we can yell on load attempt EXT_LUA,
NUM_EXT, NUM_EXT,
NUM_EXT_TABLE = NUM_EXT-EXT_START, NUM_EXT_TABLE = NUM_EXT-EXT_START,
EXT_LOADED = 0x80 EXT_LOADED = 0x80

View File

@ -1941,9 +1941,7 @@ void G_DoPlayDemo(char *defdemoname)
// Set skin // Set skin
SetPlayerSkin(0, skin); SetPlayerSkin(0, skin);
#ifdef HAVE_BLUA
LUAh_MapChange(gamemap); LUAh_MapChange(gamemap);
#endif
displayplayer = consoleplayer = 0; displayplayer = consoleplayer = 0;
memset(playeringame,0,sizeof(playeringame)); memset(playeringame,0,sizeof(playeringame));
playeringame[0] = true; playeringame[0] = true;

View File

@ -46,9 +46,7 @@
#include "b_bot.h" #include "b_bot.h"
#include "m_cond.h" // condition sets #include "m_cond.h" // condition sets
#ifdef HAVE_BLUA
#include "lua_hud.h" #include "lua_hud.h"
#endif
gameaction_t gameaction; gameaction_t gameaction;
gamestate_t gamestate = GS_NULL; gamestate_t gamestate = GS_NULL;
@ -171,7 +169,7 @@ static boolean retryingmodeattack = false;
UINT8 stagefailed; // Used for GEMS BONUS? Also to see if you beat the stage. UINT8 stagefailed; // Used for GEMS BONUS? Also to see if you beat the stage.
UINT16 emeralds; UINT16 emeralds;
INT32 luabanks[NUM_LUABANKS]; // yes, even in non HAVE_BLUA INT32 luabanks[NUM_LUABANKS];
UINT32 token; // Number of tokens collected in a level UINT32 token; // Number of tokens collected in a level
UINT32 tokenlist; // List of tokens collected UINT32 tokenlist; // List of tokens collected
boolean gottoken; // Did you get a token? Used for end of act boolean gottoken; // Did you get a token? Used for end of act
@ -1661,11 +1659,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
if (ssplayer == 1 && (cmd->forwardmove || cmd->sidemove || cmd->buttons) if (ssplayer == 1 && (cmd->forwardmove || cmd->sidemove || cmd->buttons)
&& displayplayer != consoleplayer) && displayplayer != consoleplayer)
{ {
#ifdef HAVE_BLUA
// Call ViewpointSwitch hooks here. // Call ViewpointSwitch hooks here.
// The viewpoint was forcibly changed. // The viewpoint was forcibly changed.
LUAh_ViewpointSwitch(player, &players[displayplayer], true); LUAh_ViewpointSwitch(player, &players[consoleplayer], true);
#endif
displayplayer = consoleplayer; displayplayer = consoleplayer;
} }
} }
@ -2014,9 +2010,7 @@ boolean G_Responder(event_t *ev)
&& (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1]))
{ {
// ViewpointSwitch Lua hook. // ViewpointSwitch Lua hook.
#ifdef HAVE_BLUA
UINT8 canSwitchView = 0; UINT8 canSwitchView = 0;
#endif
if (splitscreen || !netgame) if (splitscreen || !netgame)
displayplayer = consoleplayer; displayplayer = consoleplayer;
@ -2032,14 +2026,12 @@ boolean G_Responder(event_t *ev)
if (!playeringame[displayplayer]) if (!playeringame[displayplayer])
continue; continue;
#ifdef HAVE_BLUA
// Call ViewpointSwitch hooks here. // Call ViewpointSwitch hooks here.
canSwitchView = LUAh_ViewpointSwitch(&players[consoleplayer], &players[displayplayer], false); canSwitchView = LUAh_ViewpointSwitch(&players[consoleplayer], &players[displayplayer], false);
if (canSwitchView == 1) // Set viewpoint to this player if (canSwitchView == 1) // Set viewpoint to this player
break; break;
else if (canSwitchView == 2) // Skip this player else if (canSwitchView == 2) // Skip this player
continue; continue;
#endif
if (players[displayplayer].spectator) if (players[displayplayer].spectator)
continue; continue;
@ -2639,9 +2631,7 @@ void G_SpawnPlayer(INT32 playernum)
P_SpawnPlayer(playernum); P_SpawnPlayer(playernum);
G_MovePlayerToSpawnOrStarpost(playernum); G_MovePlayerToSpawnOrStarpost(playernum);
#ifdef HAVE_BLUA
LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :)
#endif
} }
void G_MovePlayerToSpawnOrStarpost(INT32 playernum) void G_MovePlayerToSpawnOrStarpost(INT32 playernum)
@ -2995,9 +2985,7 @@ void G_DoReborn(INT32 playernum)
} }
else else
{ {
#ifdef HAVE_BLUA
LUAh_MapChange(gamemap); LUAh_MapChange(gamemap);
#endif
titlecardforreload = true; titlecardforreload = true;
G_DoLoadLevel(true); G_DoLoadLevel(true);
titlecardforreload = false; titlecardforreload = false;
@ -3557,7 +3545,7 @@ boolean G_CompetitionGametype(void)
* \return The typeoflevel flag to check for that gametype. * \return The typeoflevel flag to check for that gametype.
* \author Graue <graue@oceanbase.org> * \author Graue <graue@oceanbase.org>
*/ */
INT16 G_TOLFlag(INT32 pgametype) UINT32 G_TOLFlag(INT32 pgametype)
{ {
if (!multiplayer) if (!multiplayer)
return TOL_SP; return TOL_SP;
@ -3688,7 +3676,7 @@ static void G_DoCompleted(void)
&& (nextmap >= 0 && nextmap < NUMMAPS)) && (nextmap >= 0 && nextmap < NUMMAPS))
{ {
register INT16 cm = nextmap; register INT16 cm = nextmap;
INT16 tolflag = G_TOLFlag(gametype); UINT32 tolflag = G_TOLFlag(gametype);
UINT8 visitedmap[(NUMMAPS+7)/8]; UINT8 visitedmap[(NUMMAPS+7)/8];
memset(visitedmap, 0, sizeof (visitedmap)); memset(visitedmap, 0, sizeof (visitedmap));

View File

@ -246,6 +246,6 @@ FUNCMATH INT32 G_TicsToCentiseconds(tic_t tics);
FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics); FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics);
// Don't split up TOL handling // Don't split up TOL handling
INT16 G_TOLFlag(INT32 pgametype); UINT32 G_TOLFlag(INT32 pgametype);
#endif #endif

View File

@ -47,10 +47,8 @@
#include "hardware/hw_main.h" #include "hardware/hw_main.h"
#endif #endif
#ifdef HAVE_BLUA
#include "lua_hud.h" #include "lua_hud.h"
#include "lua_hook.h" #include "lua_hook.h"
#endif
// coords are scaled // coords are scaled
#define HU_INPUTX 0 #define HU_INPUTX 0
@ -688,10 +686,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first. // run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
#ifdef HAVE_BLUA
if (LUAh_PlayerMsg(playernum, target, flags, msg)) if (LUAh_PlayerMsg(playernum, target, flags, msg))
return; return;
#endif
if (spam_eatmsg) if (spam_eatmsg)
return; // don't proceed if we were supposed to eat the message. return; // don't proceed if we were supposed to eat the message.
@ -2177,18 +2173,14 @@ void HU_Drawer(void)
{ {
if (netgame || multiplayer) if (netgame || multiplayer)
{ {
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_rankings)) if (LUA_HudEnabled(hud_rankings))
#endif HU_DrawRankings();
HU_DrawRankings();
if (gametype == GT_COOP) if (gametype == GT_COOP)
HU_DrawNetplayCoopOverlay(); HU_DrawNetplayCoopOverlay();
} }
else else
HU_DrawCoopOverlay(); HU_DrawCoopOverlay();
#ifdef HAVE_BLUA
LUAh_ScoresHUD(); LUAh_ScoresHUD();
#endif
} }
if (gamestate != GS_LEVEL) if (gamestate != GS_LEVEL)
@ -3171,29 +3163,20 @@ static void HU_DrawRankings(void)
static void HU_DrawCoopOverlay(void) static void HU_DrawCoopOverlay(void)
{ {
if (token if (token && LUA_HudEnabled(hud_tokens))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_tokens)
#endif
)
{ {
V_DrawString(168, 176, 0, va("- %d", token)); V_DrawString(168, 176, 0, va("- %d", token));
V_DrawSmallScaledPatch(148, 172, 0, tokenicon); V_DrawSmallScaledPatch(148, 172, 0, tokenicon);
} }
#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_tabemblems) && (!modifiedgame || savemoddata))
if (LUA_HudEnabled(hud_tabemblems))
#endif
if (!modifiedgame || savemoddata)
{ {
V_DrawString(160, 144, 0, va("- %d/%d", M_CountEmblems(), numemblems+numextraemblems)); V_DrawString(160, 144, 0, va("- %d/%d", M_CountEmblems(), numemblems+numextraemblems));
V_DrawScaledPatch(128, 144 - SHORT(emblemicon->height)/4, 0, emblemicon); V_DrawScaledPatch(128, 144 - SHORT(emblemicon->height)/4, 0, emblemicon);
} }
#ifdef HAVE_BLUA
if (!LUA_HudEnabled(hud_coopemeralds)) if (!LUA_HudEnabled(hud_coopemeralds))
return; return;
#endif
if (emeralds & EMERALD1) if (emeralds & EMERALD1)
V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3)-32, 0, emeraldpics[0][0]); V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3)-32, 0, emeraldpics[0][0]);
@ -3215,20 +3198,14 @@ static void HU_DrawNetplayCoopOverlay(void)
{ {
int i; int i;
if (token if (token && LUA_HudEnabled(hud_tokens))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_tokens)
#endif
)
{ {
V_DrawString(168, 10, 0, va("- %d", token)); V_DrawString(168, 10, 0, va("- %d", token));
V_DrawSmallScaledPatch(148, 6, 0, tokenicon); V_DrawSmallScaledPatch(148, 6, 0, tokenicon);
} }
#ifdef HAVE_BLUA
if (!LUA_HudEnabled(hud_coopemeralds)) if (!LUA_HudEnabled(hud_coopemeralds))
return; return;
#endif
for (i = 0; i < 7; ++i) for (i = 0; i < 7; ++i)
{ {

View File

@ -11,7 +11,6 @@
/// \brief basic functions for Lua scripting /// \brief basic functions for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "fastcmp.h" #include "fastcmp.h"
#include "p_local.h" #include "p_local.h"
#include "p_setup.h" // So we can have P_SetupLevelSky #include "p_setup.h" // So we can have P_SetupLevelSky
@ -1040,11 +1039,60 @@ static int lib_pSetObjectMomZ(lua_State *L)
return 0; return 0;
} }
static int lib_pPlayJingle(lua_State *L)
{
player_t *player = NULL;
jingletype_t jingletype = luaL_checkinteger(L, 2);
//NOHUD
//INLEVEL
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
{
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
if (jingletype >= NUMJINGLES)
return luaL_error(L, "jingletype %d out of range (0 - %d)", jingletype, NUMJINGLES-1);
P_PlayJingle(player, jingletype);
return 0;
}
static int lib_pPlayJingleMusic(lua_State *L)
{
player_t *player = NULL;
const char *musnamearg = luaL_checkstring(L, 2);
char musname[7], *p = musname;
UINT16 musflags = luaL_optinteger(L, 3, 0);
boolean looping = lua_opttrueboolean(L, 4);
jingletype_t jingletype = luaL_optinteger(L, 5, JT_OTHER);
//NOHUD
//INLEVEL
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
{
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
if (jingletype >= NUMJINGLES)
return luaL_error(L, "jingletype %d out of range (0 - %d)", jingletype, NUMJINGLES-1);
musname[6] = '\0';
strncpy(musname, musnamearg, 6);
while (*p) {
*p = tolower(*p);
++p;
}
P_PlayJingleMusic(player, musname, musflags, looping, jingletype);
return 0;
}
static int lib_pRestoreMusic(lua_State *L) static int lib_pRestoreMusic(lua_State *L)
{ {
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
NOHUD //NOHUD
INLEVEL //INLEVEL
if (!player) if (!player)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
if (P_IsLocalPlayer(player)) if (P_IsLocalPlayer(player))
@ -1674,11 +1722,15 @@ static int lib_pPlayVictorySound(lua_State *L)
static int lib_pPlayLivesJingle(lua_State *L) static int lib_pPlayLivesJingle(lua_State *L)
{ {
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player_t *player = NULL;
NOHUD //NOHUD
INLEVEL //INLEVEL
if (!player) if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
return LUA_ErrInvalid(L, "player_t"); {
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
P_PlayLivesJingle(player); P_PlayLivesJingle(player);
return 0; return 0;
} }
@ -2342,7 +2394,7 @@ static int lib_sStartSound(lua_State *L)
const void *origin = NULL; const void *origin = NULL;
sfxenum_t sound_id = luaL_checkinteger(L, 2); sfxenum_t sound_id = luaL_checkinteger(L, 2);
player_t *player = NULL; player_t *player = NULL;
//NOHUD // kys @whoever did this. //NOHUD
if (sound_id >= NUMSFX) if (sound_id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1); return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1);
if (!lua_isnil(L, 1)) if (!lua_isnil(L, 1))
@ -2373,7 +2425,7 @@ static int lib_sStartSoundAtVolume(lua_State *L)
sfxenum_t sound_id = luaL_checkinteger(L, 2); sfxenum_t sound_id = luaL_checkinteger(L, 2);
INT32 volume = (INT32)luaL_checkinteger(L, 3); INT32 volume = (INT32)luaL_checkinteger(L, 3);
player_t *player = NULL; player_t *player = NULL;
NOHUD //NOHUD
if (!lua_isnil(L, 1)) if (!lua_isnil(L, 1))
{ {
@ -2397,7 +2449,7 @@ static int lib_sStartSoundAtVolume(lua_State *L)
static int lib_sStopSound(lua_State *L) static int lib_sStopSound(lua_State *L)
{ {
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD //NOHUD
if (!origin) if (!origin)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
S_StopSound(origin); S_StopSound(origin);
@ -2414,7 +2466,7 @@ static int lib_sChangeMusic(lua_State *L)
boolean looping; boolean looping;
player_t *player = NULL; player_t *player = NULL;
UINT16 music_flags = 0; UINT16 music_flags = 0;
NOHUD //NOHUD
if (lua_isnumber(L, 1)) if (lua_isnumber(L, 1))
{ {
@ -2443,7 +2495,7 @@ static int lib_sChangeMusic(lua_State *L)
boolean looping = (boolean)lua_opttrueboolean(L, 2); boolean looping = (boolean)lua_opttrueboolean(L, 2);
player_t *player = NULL; player_t *player = NULL;
UINT16 music_flags = 0; UINT16 music_flags = 0;
NOHUD //NOHUD
#endif #endif
if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) if (!lua_isnone(L, 3) && lua_isuserdata(L, 3))
@ -2474,7 +2526,7 @@ static int lib_sSpeedMusic(lua_State *L)
fixed_t fixedspeed = luaL_checkfixed(L, 1); fixed_t fixedspeed = luaL_checkfixed(L, 1);
float speed = FIXED_TO_FLOAT(fixedspeed); float speed = FIXED_TO_FLOAT(fixedspeed);
player_t *player = NULL; player_t *player = NULL;
NOHUD //NOHUD
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
{ {
player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
@ -2489,7 +2541,7 @@ static int lib_sSpeedMusic(lua_State *L)
static int lib_sStopMusic(lua_State *L) static int lib_sStopMusic(lua_State *L)
{ {
player_t *player = NULL; player_t *player = NULL;
NOHUD //NOHUD
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
{ {
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
@ -2505,7 +2557,7 @@ static int lib_sSetInternalMusicVolume(lua_State *L)
{ {
UINT32 volume = (UINT32)luaL_checkinteger(L, 1); UINT32 volume = (UINT32)luaL_checkinteger(L, 1);
player_t *player = NULL; player_t *player = NULL;
NOHUD //NOHUD
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
{ {
player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
@ -2525,7 +2577,7 @@ static int lib_sSetInternalMusicVolume(lua_State *L)
static int lib_sStopFadingMusic(lua_State *L) static int lib_sStopFadingMusic(lua_State *L)
{ {
player_t *player = NULL; player_t *player = NULL;
NOHUD //NOHUD
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
{ {
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
@ -2548,7 +2600,7 @@ static int lib_sFadeMusic(lua_State *L)
UINT32 ms; UINT32 ms;
INT32 source_volume; INT32 source_volume;
player_t *player = NULL; player_t *player = NULL;
NOHUD //NOHUD
if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) if (!lua_isnone(L, 3) && lua_isuserdata(L, 3))
{ {
player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER)); player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER));
@ -2576,8 +2628,6 @@ static int lib_sFadeMusic(lua_State *L)
ms = (UINT32)luaL_checkinteger(L, 3); ms = (UINT32)luaL_checkinteger(L, 3);
} }
NOHUD
if (!player || P_IsLocalPlayer(player)) if (!player || P_IsLocalPlayer(player))
lua_pushboolean(L, S_FadeMusicFromVolume(target_volume, source_volume, ms)); lua_pushboolean(L, S_FadeMusicFromVolume(target_volume, source_volume, ms));
else else
@ -2589,7 +2639,7 @@ static int lib_sFadeOutStopMusic(lua_State *L)
{ {
UINT32 ms = (UINT32)luaL_checkinteger(L, 1); UINT32 ms = (UINT32)luaL_checkinteger(L, 1);
player_t *player = NULL; player_t *player = NULL;
NOHUD //NOHUD
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
{ {
player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
@ -2605,10 +2655,29 @@ static int lib_sFadeOutStopMusic(lua_State *L)
return 1; return 1;
} }
static int lib_sGetMusicLength(lua_State *L)
{
lua_pushinteger(L, S_GetMusicLength());
return 1;
}
static int lib_sGetMusicPosition(lua_State *L)
{
lua_pushinteger(L, S_GetMusicPosition());
return 1;
}
static int lib_sSetMusicPosition(lua_State *L)
{
UINT32 pos = (UINT32)luaL_checkinteger(L, 1);
lua_pushboolean(L, S_SetMusicPosition(pos));
return 1;
}
static int lib_sOriginPlaying(lua_State *L) static int lib_sOriginPlaying(lua_State *L)
{ {
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD //NOHUD
INLEVEL INLEVEL
if (!origin) if (!origin)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -2619,7 +2688,7 @@ static int lib_sOriginPlaying(lua_State *L)
static int lib_sIdPlaying(lua_State *L) static int lib_sIdPlaying(lua_State *L)
{ {
sfxenum_t id = luaL_checkinteger(L, 1); sfxenum_t id = luaL_checkinteger(L, 1);
NOHUD //NOHUD
if (id >= NUMSFX) if (id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", id, NUMSFX-1); return luaL_error(L, "sfx %d out of range (0 - %d)", id, NUMSFX-1);
lua_pushboolean(L, S_IdPlaying(id)); lua_pushboolean(L, S_IdPlaying(id));
@ -2630,7 +2699,7 @@ static int lib_sSoundPlaying(lua_State *L)
{ {
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
sfxenum_t id = luaL_checkinteger(L, 2); sfxenum_t id = luaL_checkinteger(L, 2);
NOHUD //NOHUD
INLEVEL INLEVEL
if (!origin) if (!origin)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -2648,7 +2717,7 @@ static int lib_sStartMusicCaption(lua_State *L)
const char *caption = luaL_checkstring(L, 1); const char *caption = luaL_checkstring(L, 1);
UINT16 lifespan = (UINT16)luaL_checkinteger(L, 2); UINT16 lifespan = (UINT16)luaL_checkinteger(L, 2);
//HUDSAFE //HUDSAFE
INLEVEL //INLEVEL
if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) if (!lua_isnone(L, 3) && lua_isuserdata(L, 3))
{ {
@ -3069,6 +3138,8 @@ static luaL_Reg lib[] = {
{"P_InSpaceSector",lib_pInSpaceSector}, {"P_InSpaceSector",lib_pInSpaceSector},
{"P_InQuicksand",lib_pInQuicksand}, {"P_InQuicksand",lib_pInQuicksand},
{"P_SetObjectMomZ",lib_pSetObjectMomZ}, {"P_SetObjectMomZ",lib_pSetObjectMomZ},
{"P_PlayJingle",lib_pPlayJingle},
{"P_PlayJingleMusic",lib_pPlayJingleMusic},
{"P_RestoreMusic",lib_pRestoreMusic}, {"P_RestoreMusic",lib_pRestoreMusic},
{"P_SpawnShieldOrb",lib_pSpawnShieldOrb}, {"P_SpawnShieldOrb",lib_pSpawnShieldOrb},
{"P_SpawnGhostMobj",lib_pSpawnGhostMobj}, {"P_SpawnGhostMobj",lib_pSpawnGhostMobj},
@ -3189,6 +3260,9 @@ static luaL_Reg lib[] = {
{"S_StopFadingMusic",lib_sStopFadingMusic}, {"S_StopFadingMusic",lib_sStopFadingMusic},
{"S_FadeMusic",lib_sFadeMusic}, {"S_FadeMusic",lib_sFadeMusic},
{"S_FadeOutStopMusic",lib_sFadeOutStopMusic}, {"S_FadeOutStopMusic",lib_sFadeOutStopMusic},
{"S_GetMusicLength",lib_sGetMusicLength},
{"S_GetMusicPosition",lib_sGetMusicPosition},
{"S_SetMusicPosition",lib_sSetMusicPosition},
{"S_OriginPlaying",lib_sOriginPlaying}, {"S_OriginPlaying",lib_sOriginPlaying},
{"S_IdPlaying",lib_sIdPlaying}, {"S_IdPlaying",lib_sIdPlaying},
{"S_SoundPlaying",lib_sSoundPlaying}, {"S_SoundPlaying",lib_sSoundPlaying},
@ -3237,5 +3311,3 @@ int LUA_BaseLib(lua_State *L)
luaL_register(L, NULL, lib); luaL_register(L, NULL, lib);
return 0; return 0;
} }
#endif

View File

@ -11,7 +11,6 @@
/// \brief blockmap library for Lua scripting /// \brief blockmap library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "p_local.h" #include "p_local.h"
#include "r_main.h" // validcount #include "r_main.h" // validcount
#include "lua_script.h" #include "lua_script.h"
@ -264,5 +263,3 @@ int LUA_BlockmapLib(lua_State *L)
lua_register(L, "searchBlockmap", lib_searchBlockmap); lua_register(L, "searchBlockmap", lib_searchBlockmap);
return 0; return 0;
} }
#endif

View File

@ -11,7 +11,6 @@
/// \brief console modifying/etc library for Lua scripting /// \brief console modifying/etc library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "fastcmp.h" #include "fastcmp.h"
#include "p_local.h" #include "p_local.h"
#include "g_game.h" #include "g_game.h"
@ -551,5 +550,3 @@ int LUA_ConsoleLib(lua_State *L)
luaL_register(L, NULL, lib); luaL_register(L, NULL, lib);
return 0; return 0;
} }
#endif

View File

@ -10,8 +10,6 @@
/// \file lua_hook.h /// \file lua_hook.h
/// \brief hooks for Lua scripting /// \brief hooks for Lua scripting
#ifdef HAVE_BLUA
#include "r_defs.h" #include "r_defs.h"
#include "d_player.h" #include "d_player.h"
@ -58,6 +56,7 @@ enum hook {
hook_ViewpointSwitch, hook_ViewpointSwitch,
hook_SeenPlayer, hook_SeenPlayer,
hook_PlayerThink, hook_PlayerThink,
hook_ShouldJingleContinue,
hook_MAX // last hook hook_MAX // last hook
}; };
@ -110,5 +109,4 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean
boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK
#endif #endif
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing
#endif

View File

@ -11,7 +11,6 @@
/// \brief hooks for Lua scripting /// \brief hooks for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "doomstat.h" #include "doomstat.h"
#include "p_mobj.h" #include "p_mobj.h"
#include "g_game.h" #include "g_game.h"
@ -69,6 +68,7 @@ const char *const hookNames[hook_MAX+1] = {
"ViewpointSwitch", "ViewpointSwitch",
"SeenPlayer", "SeenPlayer",
"PlayerThink", "PlayerThink",
"ShouldJingleContinue",
NULL NULL
}; };
@ -81,6 +81,7 @@ struct hook_s
union { union {
mobjtype_t mt; mobjtype_t mt;
char *skinname; char *skinname;
char *musname;
char *funcname; char *funcname;
} s; } s;
boolean error; boolean error;
@ -142,12 +143,14 @@ static int lib_addHook(lua_State *L)
case hook_HurtMsg: case hook_HurtMsg:
case hook_MobjMoveBlocked: case hook_MobjMoveBlocked:
case hook_MapThingSpawn: case hook_MapThingSpawn:
case hook_FollowMobj:
hook.s.mt = MT_NULL; hook.s.mt = MT_NULL;
if (lua_isnumber(L, 2)) if (lua_isnumber(L, 2))
hook.s.mt = lua_tonumber(L, 2); hook.s.mt = lua_tonumber(L, 2);
luaL_argcheck(L, hook.s.mt < NUMMOBJTYPES, 2, "invalid mobjtype_t"); luaL_argcheck(L, hook.s.mt < NUMMOBJTYPES, 2, "invalid mobjtype_t");
break; break;
case hook_BotAI: case hook_BotAI:
case hook_ShouldJingleContinue:
hook.s.skinname = NULL; hook.s.skinname = NULL;
if (lua_isstring(L, 2)) if (lua_isstring(L, 2))
{ // lowercase copy { // lowercase copy
@ -203,6 +206,7 @@ static int lib_addHook(lua_State *L)
case hook_MobjRemoved: case hook_MobjRemoved:
case hook_MobjMoveBlocked: case hook_MobjMoveBlocked:
case hook_MapThingSpawn: case hook_MapThingSpawn:
case hook_FollowMobj:
lastp = &mobjhooks[hook.s.mt]; lastp = &mobjhooks[hook.s.mt];
break; break;
case hook_JumpSpecial: case hook_JumpSpecial:
@ -210,7 +214,6 @@ static int lib_addHook(lua_State *L)
case hook_SpinSpecial: case hook_SpinSpecial:
case hook_JumpSpinSpecial: case hook_JumpSpinSpecial:
case hook_PlayerSpawn: case hook_PlayerSpawn:
case hook_FollowMobj:
case hook_PlayerCanDamage: case hook_PlayerCanDamage:
case hook_TeamSwitch: case hook_TeamSwitch:
case hook_ViewpointSwitch: case hook_ViewpointSwitch:
@ -1364,7 +1367,34 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj)
lua_settop(gL, 0); lua_settop(gL, 0);
for (hookp = playerhooks; hookp; hookp = hookp->next) // Look for all generic mobj follow item hooks
for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next)
{
if (hookp->type != hook_FollowMobj)
continue;
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, player, META_PLAYER);
LUA_PushUserdata(gL, mobj, META_MOBJ);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -3);
lua_pushvalue(gL, -3);
if (lua_pcall(gL, 2, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (lua_toboolean(gL, -1))
hooked = true;
lua_pop(gL, 1);
}
for (hookp = mobjhooks[mobj->type]; hookp; hookp = hookp->next)
{ {
if (hookp->type != hook_FollowMobj) if (hookp->type != hook_FollowMobj)
continue; continue;
@ -1632,4 +1662,45 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend)
} }
#endif // SEENAMES #endif // SEENAMES
#endif boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname)
{
hook_p hookp;
boolean keepplaying = false;
if (!gL || !(hooksAvailable[hook_ShouldJingleContinue/8] & (1<<(hook_ShouldJingleContinue%8))))
return true;
lua_settop(gL, 0);
hud_running = true; // local hook
for (hookp = roothook; hookp; hookp = hookp->next)
{
if (hookp->type != hook_ShouldJingleContinue
|| (hookp->s.musname && strcmp(hookp->s.musname, musname)))
continue;
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, player, META_PLAYER);
lua_pushstring(gL, musname);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -3);
lua_pushvalue(gL, -3);
if (lua_pcall(gL, 2, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (!lua_isnil(gL, -1) && lua_toboolean(gL, -1))
keepplaying = true; // Keep playing this boolean
lua_pop(gL, 1);
}
lua_settop(gL, 0);
hud_running = false;
return keepplaying;
}

View File

@ -11,7 +11,6 @@
/// \brief custom HUD rendering library for Lua scripting /// \brief custom HUD rendering library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "fastcmp.h" #include "fastcmp.h"
#include "r_defs.h" #include "r_defs.h"
#include "r_local.h" #include "r_local.h"
@ -1466,5 +1465,3 @@ void LUAh_IntermissionHUD(void)
lua_pop(gL, -1); lua_pop(gL, -1);
hud_running = false; hud_running = false;
} }
#endif

View File

@ -11,7 +11,6 @@
/// \brief infotable editing library for Lua scripting /// \brief infotable editing library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "fastcmp.h" #include "fastcmp.h"
#include "info.h" #include "info.h"
#include "dehacked.h" #include "dehacked.h"
@ -1651,5 +1650,3 @@ int LUA_InfoLib(lua_State *L)
return 0; return 0;
} }
#endif

View File

@ -10,8 +10,6 @@
/// \file lua_libs.h /// \file lua_libs.h
/// \brief libraries for Lua scripting /// \brief libraries for Lua scripting
#ifdef HAVE_BLUA
extern lua_State *gL; extern lua_State *gL;
#define LREG_VALID "VALID_USERDATA" #define LREG_VALID "VALID_USERDATA"
@ -88,5 +86,3 @@ int LUA_ThinkerLib(lua_State *L);
int LUA_MapLib(lua_State *L); int LUA_MapLib(lua_State *L);
int LUA_BlockmapLib(lua_State *L); int LUA_BlockmapLib(lua_State *L);
int LUA_HudLib(lua_State *L); int LUA_HudLib(lua_State *L);
#endif

View File

@ -11,7 +11,6 @@
/// \brief game map library for Lua scripting /// \brief game map library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "r_state.h" #include "r_state.h"
#include "p_local.h" #include "p_local.h"
#include "p_setup.h" #include "p_setup.h"
@ -2337,5 +2336,3 @@ int LUA_MapLib(lua_State *L)
lua_setglobal(L, "mapheaderinfo"); lua_setglobal(L, "mapheaderinfo");
return 0; return 0;
} }
#endif

View File

@ -11,7 +11,6 @@
/// \brief basic math library for Lua scripting /// \brief basic math library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
//#include "fastcmp.h" //#include "fastcmp.h"
#include "tables.h" #include "tables.h"
#include "p_local.h" #include "p_local.h"
@ -217,5 +216,3 @@ int LUA_MathLib(lua_State *L)
luaL_register(L, NULL, lib); luaL_register(L, NULL, lib);
return 0; return 0;
} }
#endif

View File

@ -11,7 +11,6 @@
/// \brief mobj/thing library for Lua scripting /// \brief mobj/thing library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "fastcmp.h" #include "fastcmp.h"
#include "r_skins.h" #include "r_skins.h"
#include "p_local.h" #include "p_local.h"
@ -915,5 +914,3 @@ int LUA_MobjLib(lua_State *L)
lua_setglobal(L, "mapthings"); lua_setglobal(L, "mapthings");
return 0; return 0;
} }
#endif

View File

@ -11,7 +11,6 @@
/// \brief player object library for Lua scripting /// \brief player object library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "fastcmp.h" #include "fastcmp.h"
#include "p_mobj.h" #include "p_mobj.h"
#include "d_player.h" #include "d_player.h"
@ -97,6 +96,10 @@ static int player_get(lua_State *L)
lua_pushboolean(L, true); lua_pushboolean(L, true);
else if (fastcmp(field,"name")) else if (fastcmp(field,"name"))
lua_pushstring(L, player_names[plr-players]); lua_pushstring(L, player_names[plr-players]);
else if (fastcmp(field,"realmo"))
LUA_PushUserdata(L, plr->mo, META_MOBJ);
// Kept for backward-compatibility
// Should be fixed to work like "realmo" later
else if (fastcmp(field,"mo")) else if (fastcmp(field,"mo"))
{ {
if (plr->spectator) if (plr->spectator)
@ -398,7 +401,7 @@ static int player_set(lua_State *L)
if (hud_running) if (hud_running)
return luaL_error(L, "Do not alter player_t in HUD rendering code!"); return luaL_error(L, "Do not alter player_t in HUD rendering code!");
if (fastcmp(field,"mo")) { if (fastcmp(field,"mo") || fastcmp(field,"realmo")) {
mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
plr->mo->player = NULL; // remove player pointer from old mobj plr->mo->player = NULL; // remove player pointer from old mobj
(newmo->player = plr)->mo = newmo; // set player pointer for new mobj, and set new mobj as the player's mobj (newmo->player = plr)->mo = newmo; // set player pointer for new mobj, and set new mobj as the player's mobj
@ -874,5 +877,3 @@ int LUA_PlayerLib(lua_State *L)
lua_setglobal(L, "players"); lua_setglobal(L, "players");
return 0; return 0;
} }
#endif

View File

@ -11,7 +11,6 @@
/// \brief Lua scripting basics /// \brief Lua scripting basics
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "fastcmp.h" #include "fastcmp.h"
#include "dehacked.h" #include "dehacked.h"
#include "z_zone.h" #include "z_zone.h"
@ -1423,5 +1422,3 @@ int Lua_optoption(lua_State *L, int narg,
return i; return i;
return -1; return -1;
} }
#endif // HAVE_BLUA

View File

@ -10,8 +10,6 @@
/// \file lua_script.h /// \file lua_script.h
/// \brief Lua scripting basics /// \brief Lua scripting basics
#ifdef HAVE_BLUA
#include "m_fixed.h" #include "m_fixed.h"
#include "doomtype.h" #include "doomtype.h"
#include "d_player.h" #include "d_player.h"
@ -102,5 +100,3 @@ void COM_Lua_f(void);
#define INLEVEL if (gamestate != GS_LEVEL && !titlemapinaction)\ #define INLEVEL if (gamestate != GS_LEVEL && !titlemapinaction)\
return luaL_error(L, "This can only be used in a level!"); return luaL_error(L, "This can only be used in a level!");
#endif

View File

@ -11,7 +11,6 @@
/// \brief player skin structure library for Lua scripting /// \brief player skin structure library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "fastcmp.h" #include "fastcmp.h"
#include "r_skins.h" #include "r_skins.h"
#include "sounds.h" #include "sounds.h"
@ -358,5 +357,3 @@ int LUA_SkinLib(lua_State *L)
return 0; return 0;
} }
#endif

View File

@ -11,7 +11,6 @@
/// \brief thinker library for Lua scripting /// \brief thinker library for Lua scripting
#include "doomdef.h" #include "doomdef.h"
#ifdef HAVE_BLUA
#include "p_local.h" #include "p_local.h"
#include "lua_script.h" #include "lua_script.h"
#include "lua_libs.h" #include "lua_libs.h"
@ -139,5 +138,3 @@ int LUA_ThinkerLib(lua_State *L)
lua_setglobal(L, "mobjs"); lua_setglobal(L, "mobjs");
return 0; return 0;
} }
#endif

View File

@ -788,7 +788,7 @@ void Command_CauseCfail_f(void)
} }
#endif #endif
#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) #ifdef LUA_ALLOW_BYTECODE
void Command_Dumplua_f(void) void Command_Dumplua_f(void)
{ {
if (modifiedgame) if (modifiedgame)
@ -1062,9 +1062,7 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c
mapthing_t *mt = mapthings; mapthing_t *mt = mapthings;
sector_t *sec = player->mo->subsector->sector; sector_t *sec = player->mo->subsector->sector;
#ifdef HAVE_BLUA
LUA_InvalidateMapthings(); LUA_InvalidateMapthings();
#endif
mapthings = Z_Realloc(mapthings, ++nummapthings * sizeof (*mapthings), PU_LEVEL, NULL); mapthings = Z_Realloc(mapthings, ++nummapthings * sizeof (*mapthings), PU_LEVEL, NULL);

View File

@ -68,7 +68,7 @@ void Command_Toggletwod_f(void);
#ifdef _DEBUG #ifdef _DEBUG
void Command_CauseCfail_f(void); void Command_CauseCfail_f(void);
#endif #endif
#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) #ifdef LUA_ALLOW_BYTECODE
void Command_Dumplua_f(void); void Command_Dumplua_f(void);
#endif #endif

View File

@ -6657,12 +6657,6 @@ static void M_HandleAddons(INT32 choice)
M_AddonExec(KEY_ENTER); M_AddonExec(KEY_ENTER);
break; break;
case EXT_LUA: case EXT_LUA:
#ifndef HAVE_BLUA
S_StartSound(NULL, sfx_lose);
M_StartMessage(va("%c%s\x80\nThis copy of SRB2 was compiled\nwithout support for .lua files.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING);
break;
#endif
/* FALLTHRU */
case EXT_SOC: case EXT_SOC:
case EXT_WAD: case EXT_WAD:
#ifdef USE_KART #ifdef USE_KART
@ -10394,7 +10388,7 @@ static void M_DrawConnectMenu(void)
for (i = 0; i < min(serverlistcount - serverlistpage * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++) for (i = 0; i < min(serverlistcount - serverlistpage * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++)
{ {
INT32 slindex = i + serverlistpage * SERVERS_PER_PAGE; INT32 slindex = i + serverlistpage * SERVERS_PER_PAGE;
UINT32 globalflags = ((serverlist[slindex].info.numberofplayer >= serverlist[slindex].info.maxplayer) ? V_TRANSLUCENT : 0) UINT32 globalflags = (serverlist[slindex].info.refusereason ? V_TRANSLUCENT : 0)
|((itemOn == FIRSTSERVERLINE+i) ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE; |((itemOn == FIRSTSERVERLINE+i) ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE;
V_DrawString(currentMenu->x, S_LINEY(i), globalflags, serverlist[slindex].info.servername); V_DrawString(currentMenu->x, S_LINEY(i), globalflags, serverlist[slindex].info.servername);

File diff suppressed because it is too large Load Diff

View File

@ -365,10 +365,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (special->flags & (MF_ENEMY|MF_BOSS) && special->flags2 & MF2_FRET) if (special->flags & (MF_ENEMY|MF_BOSS) && special->flags2 & MF2_FRET)
return; return;
#ifdef HAVE_BLUA
if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special)) if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special))
return; return;
#endif
// 0 = none, 1 = elemental pierce, 2 = bubble bounce // 0 = none, 1 = elemental pierce, 2 = bubble bounce
elementalpierce = (((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL || (player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) && (player->pflags & PF_SHIELDABILITY) elementalpierce = (((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL || (player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) && (player->pflags & PF_SHIELDABILITY)
@ -1919,10 +1917,8 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour
if (!netgame) if (!netgame)
return; // Presumably it's obvious what's happening in splitscreen. return; // Presumably it's obvious what's happening in splitscreen.
#ifdef HAVE_BLUA
if (LUAh_HurtMsg(player, inflictor, source, damagetype)) if (LUAh_HurtMsg(player, inflictor, source, damagetype))
return; return;
#endif
deadtarget = (player->mo->health <= 0); deadtarget = (player->mo->health <= 0);
@ -2395,10 +2391,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL);
target->health = 0; // This makes it easy to check if something's dead elsewhere. target->health = 0; // This makes it easy to check if something's dead elsewhere.
#ifdef HAVE_BLUA
if (LUAh_MobjDeath(target, inflictor, source, damagetype) || P_MobjWasRemoved(target)) if (LUAh_MobjDeath(target, inflictor, source, damagetype) || P_MobjWasRemoved(target))
return; return;
#endif
// Let EVERYONE know what happened to a player! 01-29-2002 Tails // Let EVERYONE know what happened to a player! 01-29-2002 Tails
if (target->player && !target->player->spectator) if (target->player && !target->player->spectator)
@ -3441,7 +3435,7 @@ void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source)
if (player->powers[pw_invulnerability] || player->powers[pw_flashing] || player->powers[pw_super]) if (player->powers[pw_invulnerability] || player->powers[pw_flashing] || player->powers[pw_super])
return; return;
if (!cv_friendlyfire.value) if (!cv_friendlyfire.value && source && source->player)
{ {
if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK)) if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK))
{ {
@ -3456,7 +3450,7 @@ void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source)
return; return;
} }
if (inflictor->type == MT_LHRT) if (inflictor && inflictor->type == MT_LHRT)
return; return;
if (player->powers[pw_shield] || player->bot) //If One-Hit Shield if (player->powers[pw_shield] || player->bot) //If One-Hit Shield
@ -3511,11 +3505,7 @@ void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source)
boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype)
{ {
player_t *player; player_t *player;
#ifdef HAVE_BLUA
boolean force = false; boolean force = false;
#else
static const boolean force = false;
#endif
if (objectplacing) if (objectplacing)
return false; return false;
@ -3533,7 +3523,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
return false; return false;
} }
#ifdef HAVE_BLUA
// Everything above here can't be forced. // Everything above here can't be forced.
if (!metalrecording) if (!metalrecording)
{ {
@ -3545,7 +3534,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
else if (shouldForce == 2) else if (shouldForce == 2)
return false; return false;
} }
#endif
if (!force) if (!force)
{ {
@ -3579,10 +3567,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (!force && target->flags2 & MF2_FRET) // Currently flashing from being hit if (!force && target->flags2 & MF2_FRET) // Currently flashing from being hit
return false; return false;
#ifdef HAVE_BLUA
if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype) || P_MobjWasRemoved(target)) if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype) || P_MobjWasRemoved(target))
return true; return true;
#endif
if (target->health > 1) if (target->health > 1)
target->flags2 |= MF2_FRET; target->flags2 |= MF2_FRET;
@ -3631,10 +3617,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|| (G_GametypeHasTeams() && player->ctfteam == source->player->ctfteam))) || (G_GametypeHasTeams() && player->ctfteam == source->player->ctfteam)))
return false; // Don't run eachother over in special stages and team games and such return false; // Don't run eachother over in special stages and team games and such
} }
#ifdef HAVE_BLUA
if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype))
return true; return true;
#endif
P_NiGHTSDamage(target, source); // -5s :( P_NiGHTSDamage(target, source); // -5s :(
return true; return true;
} }
@ -3687,18 +3671,14 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (force if (force
|| (inflictor && inflictor->flags & MF_MISSILE && inflictor->flags2 & MF2_SUPERFIRE)) // Super Sonic is stunned! || (inflictor && inflictor->flags & MF_MISSILE && inflictor->flags2 & MF2_SUPERFIRE)) // Super Sonic is stunned!
{ {
#ifdef HAVE_BLUA
if (!LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) if (!LUAh_MobjDamage(target, inflictor, source, damage, damagetype))
#endif
P_SuperDamage(player, inflictor, source, damage); P_SuperDamage(player, inflictor, source, damage);
return true; return true;
} }
return false; return false;
} }
#ifdef HAVE_BLUA
else if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) else if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype))
return true; return true;
#endif
else if (player->powers[pw_shield] || (player->bot && !ultimatemode)) //If One-Hit Shield else if (player->powers[pw_shield] || (player->bot && !ultimatemode)) //If One-Hit Shield
{ {
P_ShieldDamage(player, inflictor, source, damage, damagetype); P_ShieldDamage(player, inflictor, source, damage, damagetype);

View File

@ -250,7 +250,7 @@ extern jingle_t jingleinfo[NUMJINGLES];
#define JINGLEPOSTFADE 1000 #define JINGLEPOSTFADE 1000
void P_PlayJingle(player_t *player, jingletype_t jingletype); void P_PlayJingle(player_t *player, jingletype_t jingletype);
boolean P_EvaluateMusicStatus(UINT16 status); boolean P_EvaluateMusicStatus(UINT16 status, const char *musname);
void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, boolean looping, UINT16 status); void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, boolean looping, UINT16 status);
// //

View File

@ -756,11 +756,9 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (tmthing->z + tmthing->height < thing->z) if (tmthing->z + tmthing->height < thing->z)
return true; // underneath return true; // underneath
#ifdef HAVE_BLUA
// REX HAS SEEN YOU // REX HAS SEEN YOU
if (!LUAh_SeenPlayer(tmthing->target->player, thing->player)) if (!LUAh_SeenPlayer(tmthing->target->player, thing->player))
return false; return false;
#endif
seenplayer = thing->player; seenplayer = thing->player;
return false; return false;
@ -948,7 +946,6 @@ static boolean PIT_CheckThing(mobj_t *thing)
return true; // the line doesn't cross between either pair of opposite corners return true; // the line doesn't cross between either pair of opposite corners
} }
#ifdef HAVE_BLUA
{ {
UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type
if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing))
@ -957,9 +954,8 @@ static boolean PIT_CheckThing(mobj_t *thing)
return false; // force collide return false; // force collide
else if (shouldCollide == 2) else if (shouldCollide == 2)
return true; // force no collide return true; // force no collide
}
{ shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type
UINT8 shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type
if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing))
return true; // one of them was removed??? return true; // one of them was removed???
if (shouldCollide == 1) if (shouldCollide == 1)
@ -967,7 +963,6 @@ static boolean PIT_CheckThing(mobj_t *thing)
else if (shouldCollide == 2) else if (shouldCollide == 2)
return true; // force no collide return true; // force no collide
} }
#endif
if (tmthing->type == MT_LAVAFALL_LAVA && (thing->type == MT_RING || thing->type == MT_REDTEAMRING || thing->type == MT_BLUETEAMRING || thing->type == MT_FLINGRING)) if (tmthing->type == MT_LAVAFALL_LAVA && (thing->type == MT_RING || thing->type == MT_REDTEAMRING || thing->type == MT_BLUETEAMRING || thing->type == MT_FLINGRING))
{ {
@ -1946,7 +1941,6 @@ static boolean PIT_CheckLine(line_t *ld)
// this line is out of the if so upper and lower textures can be hit by a splat // this line is out of the if so upper and lower textures can be hit by a splat
blockingline = ld; blockingline = ld;
#ifdef HAVE_BLUA
{ {
UINT8 shouldCollide = LUAh_MobjLineCollide(tmthing, blockingline); // checks hook for thing's type UINT8 shouldCollide = LUAh_MobjLineCollide(tmthing, blockingline); // checks hook for thing's type
if (P_MobjWasRemoved(tmthing)) if (P_MobjWasRemoved(tmthing))
@ -1956,7 +1950,6 @@ static boolean PIT_CheckLine(line_t *ld)
else if (shouldCollide == 2) else if (shouldCollide == 2)
return true; // force no collide return true; // force no collide
} }
#endif
if (!ld->backsector) // one sided line if (!ld->backsector) // one sided line
{ {

View File

@ -62,9 +62,7 @@ void P_RunCachedActions(void)
{ {
var1 = states[ac->statenum].var1; var1 = states[ac->statenum].var1;
var2 = states[ac->statenum].var2; var2 = states[ac->statenum].var2;
#ifdef HAVE_BLUA
astate = &states[ac->statenum]; astate = &states[ac->statenum];
#endif
if (ac->mobj && !P_MobjWasRemoved(ac->mobj)) // just in case... if (ac->mobj && !P_MobjWasRemoved(ac->mobj)) // just in case...
states[ac->statenum].action.acp1(ac->mobj); states[ac->statenum].action.acp1(ac->mobj);
next = ac->next; next = ac->next;
@ -459,9 +457,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
{ {
var1 = st->var1; var1 = st->var1;
var2 = st->var2; var2 = st->var2;
#ifdef HAVE_BLUA
astate = st; astate = st;
#endif
st->action.acp1(mobj); st->action.acp1(mobj);
// woah. a player was removed by an action. // woah. a player was removed by an action.
@ -585,9 +581,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
{ {
var1 = st->var1; var1 = st->var1;
var2 = st->var2; var2 = st->var2;
#ifdef HAVE_BLUA
astate = st; astate = st;
#endif
st->action.acp1(mobj); st->action.acp1(mobj);
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return false; return false;
@ -1906,15 +1900,12 @@ void P_XYMovement(mobj_t *mo)
B_MoveBlocked(player); B_MoveBlocked(player);
} }
#ifdef HAVE_BLUA
if (LUAh_MobjMoveBlocked(mo)) if (LUAh_MobjMoveBlocked(mo))
{ {
if (P_MobjWasRemoved(mo)) if (P_MobjWasRemoved(mo))
return; return;
} }
else else if (P_MobjWasRemoved(mo))
#endif
if (P_MobjWasRemoved(mo))
return; return;
else if (mo->flags & MF_BOUNCE) else if (mo->flags & MF_BOUNCE)
{ {
@ -7643,12 +7634,10 @@ static void P_RosySceneryThink(mobj_t *mobj)
static void P_MobjSceneryThink(mobj_t *mobj) static void P_MobjSceneryThink(mobj_t *mobj)
{ {
#ifdef HAVE_BLUA
if (LUAh_MobjThinker(mobj)) if (LUAh_MobjThinker(mobj))
return; return;
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return; return;
#endif
if ((mobj->flags2 & MF2_SHIELD) && !P_AddShield(mobj)) if ((mobj->flags2 & MF2_SHIELD) && !P_AddShield(mobj))
return; return;
@ -7993,9 +7982,7 @@ static void P_MobjSceneryThink(mobj_t *mobj)
if (!mobj->fuse) if (!mobj->fuse)
{ {
#ifdef HAVE_BLUA
if (!LUAh_MobjFuse(mobj)) if (!LUAh_MobjFuse(mobj))
#endif
P_RemoveMobj(mobj); P_RemoveMobj(mobj);
return; return;
} }
@ -8054,9 +8041,7 @@ static void P_MobjSceneryThink(mobj_t *mobj)
mobj->fuse--; mobj->fuse--;
if (!mobj->fuse) if (!mobj->fuse)
{ {
#ifdef HAVE_BLUA
if (!LUAh_MobjFuse(mobj)) if (!LUAh_MobjFuse(mobj))
#endif
P_RemoveMobj(mobj); P_RemoveMobj(mobj);
return; return;
} }
@ -8085,7 +8070,6 @@ static boolean P_MobjPushableThink(mobj_t *mobj)
static boolean P_MobjBossThink(mobj_t *mobj) static boolean P_MobjBossThink(mobj_t *mobj)
{ {
#ifdef HAVE_BLUA
if (LUAh_BossThinker(mobj)) if (LUAh_BossThinker(mobj))
{ {
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
@ -8094,7 +8078,6 @@ static boolean P_MobjBossThink(mobj_t *mobj)
else if (P_MobjWasRemoved(mobj)) else if (P_MobjWasRemoved(mobj))
return false; return false;
else else
#endif
switch (mobj->type) switch (mobj->type)
{ {
case MT_EGGMOBILE: case MT_EGGMOBILE:
@ -10004,113 +9987,110 @@ static boolean P_FuseThink(mobj_t *mobj)
if (mobj->fuse) if (mobj->fuse)
return true; return true;
#ifdef HAVE_BLUA
if (LUAh_MobjFuse(mobj) || P_MobjWasRemoved(mobj)) if (LUAh_MobjFuse(mobj) || P_MobjWasRemoved(mobj))
; ;
else else if (mobj->info->flags & MF_MONITOR)
#endif {
if (mobj->info->flags & MF_MONITOR) P_MonitorFuseThink(mobj);
return false;
}
else switch (mobj->type)
{
// gargoyle and snowman handled in P_PushableThinker, not here
case MT_THROWNGRENADE:
case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE:
P_SetMobjState(mobj, mobj->info->deathstate);
break;
case MT_LHRT:
P_KillMobj(mobj, NULL, NULL, 0);
break;
case MT_BLUEFLAG:
case MT_REDFLAG:
P_FlagFuseThink(mobj);
P_RemoveMobj(mobj);
return false;
case MT_FANG:
if (mobj->flags2 & MF2_SLIDEPUSH)
{ {
P_MonitorFuseThink(mobj); var1 = 0;
var2 = 0;
A_BossDeath(mobj);
return false; return false;
} }
else switch (mobj->type) P_SetMobjState(mobj, mobj->state->nextstate);
if (P_MobjWasRemoved(mobj))
return false;
break;
case MT_METALSONIC_BATTLE:
break; // don't remove
case MT_SPIKE:
P_SetMobjState(mobj, mobj->state->nextstate);
mobj->fuse = mobj->info->speed;
if (mobj->spawnpoint)
mobj->fuse += mobj->spawnpoint->angle;
break;
case MT_WALLSPIKE:
P_SetMobjState(mobj, mobj->state->nextstate);
mobj->fuse = mobj->info->speed;
if (mobj->spawnpoint)
mobj->fuse += (mobj->spawnpoint->angle / 360);
break;
case MT_NIGHTSCORE:
P_RemoveMobj(mobj);
return false;
case MT_LAVAFALL:
if (mobj->state - states == S_LAVAFALL_DORMANT)
{ {
// gargoyle and snowman handled in P_PushableThinker, not here mobj->fuse = 30;
case MT_THROWNGRENADE: P_SetMobjState(mobj, S_LAVAFALL_TELL);
case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: S_StartSound(mobj, mobj->info->seesound);
P_SetMobjState(mobj, mobj->info->deathstate); }
else if (mobj->state - states == S_LAVAFALL_TELL)
{
mobj->fuse = 40;
P_SetMobjState(mobj, S_LAVAFALL_SHOOT);
S_StopSound(mobj);
S_StartSound(mobj, mobj->info->attacksound);
}
else
{
mobj->fuse = 30;
P_SetMobjState(mobj, S_LAVAFALL_DORMANT);
S_StopSound(mobj);
}
return false;
case MT_PYREFLY:
if (mobj->health <= 0)
break; break;
case MT_LHRT:
P_KillMobj(mobj, NULL, NULL, 0);
break;
case MT_BLUEFLAG:
case MT_REDFLAG:
P_FlagFuseThink(mobj);
P_RemoveMobj(mobj);
return false;
case MT_FANG:
if (mobj->flags2 & MF2_SLIDEPUSH)
{
var1 = 0;
var2 = 0;
A_BossDeath(mobj);
return false;
}
P_SetMobjState(mobj, mobj->state->nextstate);
if (P_MobjWasRemoved(mobj))
return false;
break;
case MT_METALSONIC_BATTLE:
break; // don't remove
case MT_SPIKE:
P_SetMobjState(mobj, mobj->state->nextstate);
mobj->fuse = mobj->info->speed;
if (mobj->spawnpoint)
mobj->fuse += mobj->spawnpoint->angle;
break;
case MT_WALLSPIKE:
P_SetMobjState(mobj, mobj->state->nextstate);
mobj->fuse = mobj->info->speed;
if (mobj->spawnpoint)
mobj->fuse += (mobj->spawnpoint->angle / 360);
break;
case MT_NIGHTSCORE:
P_RemoveMobj(mobj);
return false;
case MT_LAVAFALL:
if (mobj->state - states == S_LAVAFALL_DORMANT)
{
mobj->fuse = 30;
P_SetMobjState(mobj, S_LAVAFALL_TELL);
S_StartSound(mobj, mobj->info->seesound);
}
else if (mobj->state - states == S_LAVAFALL_TELL)
{
mobj->fuse = 40;
P_SetMobjState(mobj, S_LAVAFALL_SHOOT);
S_StopSound(mobj);
S_StartSound(mobj, mobj->info->attacksound);
}
else
{
mobj->fuse = 30;
P_SetMobjState(mobj, S_LAVAFALL_DORMANT);
S_StopSound(mobj);
}
return false;
case MT_PYREFLY:
if (mobj->health <= 0)
break;
mobj->extravalue2 = (mobj->extravalue2 + 1) % 3; mobj->extravalue2 = (mobj->extravalue2 + 1) % 3;
if (mobj->extravalue2 == 0) if (mobj->extravalue2 == 0)
{ {
P_SetMobjState(mobj, mobj->info->spawnstate); P_SetMobjState(mobj, mobj->info->spawnstate);
mobj->fuse = 100; mobj->fuse = 100;
S_StopSound(mobj); S_StopSound(mobj);
S_StartSound(mobj, sfx_s3k8c); S_StartSound(mobj, sfx_s3k8c);
}
else if (mobj->extravalue2 == 1)
{
mobj->fuse = 50;
S_StartSound(mobj, sfx_s3ka3);
}
else
{
P_SetMobjState(mobj, mobj->info->meleestate);
mobj->fuse = 100;
S_StopSound(mobj);
S_StartSound(mobj, sfx_s3kc2l);
}
return false;
case MT_PLAYER:
break; // don't remove
default:
P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL.
break;
// Looking for monitors? They moved to a special condition above.
} }
else if (mobj->extravalue2 == 1)
{
mobj->fuse = 50;
S_StartSound(mobj, sfx_s3ka3);
}
else
{
P_SetMobjState(mobj, mobj->info->meleestate);
mobj->fuse = 100;
S_StopSound(mobj);
S_StartSound(mobj, sfx_s3kc2l);
}
return false;
case MT_PLAYER:
break; // don't remove
default:
P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL.
break;
// Looking for monitors? They moved to a special condition above.
}
return !P_MobjWasRemoved(mobj); return !P_MobjWasRemoved(mobj);
} }
@ -10179,7 +10159,6 @@ void P_MobjThinker(mobj_t *mobj)
return; return;
} }
#ifdef HAVE_BLUA
// Check for a Lua thinker first // Check for a Lua thinker first
if (!mobj->player) if (!mobj->player)
{ {
@ -10193,7 +10172,7 @@ void P_MobjThinker(mobj_t *mobj)
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return; return;
} }
#endif
// if it's pushable, or if it would be pushable other than temporary disablement, use the // if it's pushable, or if it would be pushable other than temporary disablement, use the
// separate thinker // separate thinker
if (mobj->flags & MF_PUSHABLE || (mobj->info->flags & MF_PUSHABLE && mobj->fuse)) if (mobj->flags & MF_PUSHABLE || (mobj->info->flags & MF_PUSHABLE && mobj->fuse))
@ -10656,7 +10635,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
// Set shadowscale here, before spawn hook so that Lua can change it // Set shadowscale here, before spawn hook so that Lua can change it
mobj->shadowscale = P_DefaultMobjShadowScale(mobj); mobj->shadowscale = P_DefaultMobjShadowScale(mobj);
#ifdef HAVE_BLUA
// DANGER! This can cause P_SpawnMobj to return NULL! // DANGER! This can cause P_SpawnMobj to return NULL!
// Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks! // Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks!
if (LUAh_MobjSpawn(mobj)) if (LUAh_MobjSpawn(mobj))
@ -10667,7 +10645,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
else if (P_MobjWasRemoved(mobj)) else if (P_MobjWasRemoved(mobj))
return NULL; return NULL;
else else
#endif
switch (mobj->type) switch (mobj->type)
{ {
case MT_ALTVIEWMAN: case MT_ALTVIEWMAN:
@ -10937,9 +10914,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
{ {
var1 = st->var1; var1 = st->var1;
var2 = st->var2; var2 = st->var2;
#ifdef HAVE_BLUA
astate = st; astate = st;
#endif
st->action.acp1(mobj); st->action.acp1(mobj);
// DANGER! This can cause P_SpawnMobj to return NULL! // DANGER! This can cause P_SpawnMobj to return NULL!
// Avoid using MF_RUNSPAWNFUNC on mobjs whose spawn state expects target or tracer to already be set! // Avoid using MF_RUNSPAWNFUNC on mobjs whose spawn state expects target or tracer to already be set!
@ -11037,16 +11012,12 @@ size_t iquehead, iquetail;
void P_RemoveMobj(mobj_t *mobj) void P_RemoveMobj(mobj_t *mobj)
{ {
I_Assert(mobj != NULL); I_Assert(mobj != NULL);
#ifdef HAVE_BLUA
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return; // something already removing this mobj. return; // something already removing this mobj.
mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing. mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing.
LUAh_MobjRemoved(mobj); LUAh_MobjRemoved(mobj);
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work. mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work.
#else
I_Assert(!P_MobjWasRemoved(mobj));
#endif
// Rings only, please! // Rings only, please!
if (mobj->spawnpoint && if (mobj->spawnpoint &&
@ -12710,7 +12681,6 @@ static boolean P_SetupBooster(mapthing_t* mthing, mobj_t* mobj, boolean strong)
static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean *doangle) static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean *doangle)
{ {
#ifdef HAVE_BLUA
boolean override = LUAh_MapThingSpawn(mobj, mthing); boolean override = LUAh_MapThingSpawn(mobj, mthing);
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
@ -12718,7 +12688,6 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
if (override) if (override)
return true; return true;
#endif
switch (mobj->type) switch (mobj->type)
{ {

View File

@ -4183,8 +4183,6 @@ void P_SaveGame(void)
{ {
P_ArchiveMisc(); P_ArchiveMisc();
P_ArchivePlayer(); P_ArchivePlayer();
// yes, even in non HAVE_BLUA
P_ArchiveLuabanksAndConsistency(); P_ArchiveLuabanksAndConsistency();
} }
@ -4220,9 +4218,7 @@ void P_SaveNetGame(void)
P_NetArchiveSpecials(); P_NetArchiveSpecials();
P_NetArchiveColormaps(); P_NetArchiveColormaps();
} }
#ifdef HAVE_BLUA
LUA_Archive(); LUA_Archive();
#endif
P_ArchiveLuabanksAndConsistency(); P_ArchiveLuabanksAndConsistency();
} }
@ -4264,9 +4260,7 @@ boolean P_LoadNetGame(void)
P_RelinkPointers(); P_RelinkPointers();
P_FinishMobjs(); P_FinishMobjs();
} }
#ifdef HAVE_BLUA
LUA_UnArchive(); LUA_UnArchive();
#endif
// This is stupid and hacky, but maybe it'll work! // This is stupid and hacky, but maybe it'll work!
P_SetRandSeed(P_GetInitSeed()); P_SetRandSeed(P_GetInitSeed());

View File

@ -57,9 +57,7 @@
#include "filesrch.h" // refreshdirmenu #include "filesrch.h" // refreshdirmenu
#ifdef HAVE_BLUA
#include "lua_hud.h" // level title #include "lua_hud.h" // level title
#endif
#include "f_finale.h" // wipes #include "f_finale.h" // wipes
@ -3096,7 +3094,7 @@ static void P_InitTagGametype(void)
//Also, you'd never have to loop through all 32 players slots to find anything ever again. //Also, you'd never have to loop through all 32 players slots to find anything ever again.
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (playeringame[i] && !(players[i].spectator && players[i].quittime)) if (playeringame[i] && !(players[i].spectator || players[i].quittime))
{ {
playersactive[realnumplayers] = i; //stores the player's node in the array. playersactive[realnumplayers] = i; //stores the player's node in the array.
realnumplayers++; realnumplayers++;
@ -3526,9 +3524,7 @@ boolean P_LoadLevel(boolean fromnetsave)
// Close text prompt before freeing the old level // Close text prompt before freeing the old level
F_EndTextPrompt(false, true); F_EndTextPrompt(false, true);
#ifdef HAVE_BLUA
LUA_InvalidateLevel(); LUA_InvalidateLevel();
#endif
for (ss = sectors; sectors+numsectors != ss; ss++) for (ss = sectors; sectors+numsectors != ss; ss++)
{ {
@ -3665,9 +3661,7 @@ boolean P_LoadLevel(boolean fromnetsave)
G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1);
} }
P_PreTicker(2); P_PreTicker(2);
#ifdef HAVE_BLUA
LUAh_MapLoad(); LUAh_MapLoad();
#endif
} }
// No render mode, stop here. // No render mode, stop here.
@ -3859,10 +3853,8 @@ boolean P_AddWadFile(const char *wadfilename)
// Update the detected resources. // Update the detected resources.
// Note: ALWAYS load Lua scripts first, SOCs right after, and the remaining resources afterwards. // Note: ALWAYS load Lua scripts first, SOCs right after, and the remaining resources afterwards.
#ifdef HAVE_BLUA
// if (luaNum) // Lua scripts. // if (luaNum) // Lua scripts.
// P_LoadLuaScrRange(wadnum, luaPos, luaNum); // P_LoadLuaScrRange(wadnum, luaPos, luaNum);
#endif
// if (socNum) // SOCs. // if (socNum) // SOCs.
// P_LoadDehackRange(wadnum, socPos, socNum); // P_LoadDehackRange(wadnum, socPos, socNum);
if (sfxNum) // Sounds. TODO: Function currently only updates already existing sounds, the rest is handled somewhere else. if (sfxNum) // Sounds. TODO: Function currently only updates already existing sounds, the rest is handled somewhere else.

View File

@ -3366,14 +3366,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
} }
case 443: // Calls a named Lua function case 443: // Calls a named Lua function
#ifdef HAVE_BLUA
if (line->text) if (line->text)
LUAh_LinedefExecute(line, mo, callsec); LUAh_LinedefExecute(line, mo, callsec);
else else
CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(line-lines)); CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(line-lines));
#else
CONS_Alert(CONS_ERROR, "The map is trying to run a Lua script, but this exe was not compiled with Lua support!\n");
#endif
break; break;
case 444: // Earthquake camera case 444: // Earthquake camera

View File

@ -269,9 +269,7 @@ void P_RemoveThinkerDelayed(thinker_t *thinker)
// //
void P_RemoveThinker(thinker_t *thinker) void P_RemoveThinker(thinker_t *thinker)
{ {
#ifdef HAVE_BLUA
LUA_InvalidateUserdata(thinker); LUA_InvalidateUserdata(thinker);
#endif
thinker->function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; thinker->function.acp1 = (actionf_p1)P_RemoveThinkerDelayed;
} }
@ -643,9 +641,7 @@ void P_Ticker(boolean run)
if (demoplayback) if (demoplayback)
G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0); G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0);
#ifdef HAVE_BLUA
LUAh_PreThinkFrame(); LUAh_PreThinkFrame();
#endif
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
@ -671,9 +667,7 @@ void P_Ticker(boolean run)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
P_PlayerAfterThink(&players[i]); P_PlayerAfterThink(&players[i]);
#ifdef HAVE_BLUA
LUAh_ThinkFrame(); LUAh_ThinkFrame();
#endif
} }
// Run shield positioning // Run shield positioning
@ -745,9 +739,7 @@ void P_Ticker(boolean run)
if (modeattacking) if (modeattacking)
G_GhostTicker(); G_GhostTicker();
#ifdef HAVE_BLUA
LUAh_PostThinkFrame(); LUAh_PostThinkFrame();
#endif
} }
P_MapEnd(); P_MapEnd();
@ -767,9 +759,8 @@ void P_PreTicker(INT32 frames)
{ {
P_MapStart(); P_MapStart();
#ifdef HAVE_BLUA
LUAh_PreThinkFrame(); LUAh_PreThinkFrame();
#endif
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
{ {
@ -793,9 +784,7 @@ void P_PreTicker(INT32 frames)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
P_PlayerAfterThink(&players[i]); P_PlayerAfterThink(&players[i]);
#ifdef HAVE_BLUA
LUAh_ThinkFrame(); LUAh_ThinkFrame();
#endif
// Run shield positioning // Run shield positioning
P_RunShields(); P_RunShields();
@ -804,9 +793,7 @@ void P_PreTicker(INT32 frames)
P_UpdateSpecials(); P_UpdateSpecials();
P_RespawnSpecials(); P_RespawnSpecials();
#ifdef HAVE_BLUA
LUAh_PostThinkFrame(); LUAh_PostThinkFrame();
#endif
P_MapEnd(); P_MapEnd();
} }

View File

@ -395,7 +395,7 @@ void P_GiveFinishFlags(player_t *player)
mobj_t* flag = P_SpawnMobjFromMobj(player->mo, xoffs, yoffs, 0, MT_FINISHFLAG); mobj_t* flag = P_SpawnMobjFromMobj(player->mo, xoffs, yoffs, 0, MT_FINISHFLAG);
flag->angle = angle; flag->angle = angle;
angle += FixedAngle(120*FRACUNIT); angle += FixedAngle(120*FRACUNIT);
P_SetTarget(&flag->target, player->mo); P_SetTarget(&flag->target, player->mo);
} }
} }
@ -1109,7 +1109,6 @@ boolean P_PlayerCanDamage(player_t *player, mobj_t *thing)
if (!player->mo || player->spectator || !thing || P_MobjWasRemoved(thing)) if (!player->mo || player->spectator || !thing || P_MobjWasRemoved(thing))
return false; return false;
#ifdef HAVE_BLUA
{ {
UINT8 shouldCollide = LUAh_PlayerCanDamage(player, thing); UINT8 shouldCollide = LUAh_PlayerCanDamage(player, thing);
if (P_MobjWasRemoved(thing)) if (P_MobjWasRemoved(thing))
@ -1119,7 +1118,6 @@ boolean P_PlayerCanDamage(player_t *player, mobj_t *thing)
else if (shouldCollide == 2) else if (shouldCollide == 2)
return false; // force no return false; // force no
} }
#endif
// Invinc/super. Not for Monitors. // Invinc/super. Not for Monitors.
if (!(thing->flags & MF_MONITOR) && (player->powers[pw_invulnerability] || player->powers[pw_super])) if (!(thing->flags & MF_MONITOR) && (player->powers[pw_invulnerability] || player->powers[pw_super]))
@ -1521,7 +1519,7 @@ void P_PlayJingle(player_t *player, jingletype_t jingletype)
char newmusic[7]; char newmusic[7];
strncpy(newmusic, musname, 7); strncpy(newmusic, musname, 7);
#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) #ifdef HAVE_LUA_MUSICPLUS
if(LUAh_MusicJingle(jingletype, newmusic, &musflags, &looping)) if(LUAh_MusicJingle(jingletype, newmusic, &musflags, &looping))
return; return;
#endif #endif
@ -1536,7 +1534,7 @@ void P_PlayJingle(player_t *player, jingletype_t jingletype)
void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, boolean looping, UINT16 status) void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, boolean looping, UINT16 status)
{ {
// If gamestate != GS_LEVEL, always play the jingle (1-up intermission) // If gamestate != GS_LEVEL, always play the jingle (1-up intermission)
if (gamestate == GS_LEVEL && !P_IsLocalPlayer(player)) if (gamestate == GS_LEVEL && player && !P_IsLocalPlayer(player))
return; return;
S_RetainMusic(musname, musflags, looping, 0, status); S_RetainMusic(musname, musflags, looping, 0, status);
@ -1544,7 +1542,7 @@ void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, b
S_ChangeMusicInternal(musname, looping); S_ChangeMusicInternal(musname, looping);
} }
boolean P_EvaluateMusicStatus(UINT16 status) boolean P_EvaluateMusicStatus(UINT16 status, const char *musname)
{ {
// \todo lua hook // \todo lua hook
int i; int i;
@ -1601,8 +1599,11 @@ boolean P_EvaluateMusicStatus(UINT16 status)
result = (players[i].nightstime && players[i].nightstime <= 10*TICRATE); result = (players[i].nightstime && players[i].nightstime <= 10*TICRATE);
break; break;
case JT_NONE: // Null state
case JT_OTHER: // Other state case JT_OTHER: // Other state
result = LUAh_ShouldJingleContinue(&players[i], musname);
break;
case JT_NONE: // Null state
case JT_MASTER: // Main level music case JT_MASTER: // Main level music
default: default:
result = true; result = true;
@ -1865,10 +1866,8 @@ void P_SpawnShieldOrb(player_t *player)
I_Error("P_SpawnShieldOrb: player->mo is NULL!\n"); I_Error("P_SpawnShieldOrb: player->mo is NULL!\n");
#endif #endif
#ifdef HAVE_BLUA
if (LUAh_ShieldSpawn(player)) if (LUAh_ShieldSpawn(player))
return; return;
#endif
if (player->powers[pw_shield] & SH_FORCE) if (player->powers[pw_shield] & SH_FORCE)
orbtype = MT_FORCE_ORB; orbtype = MT_FORCE_ORB;
@ -4633,13 +4632,11 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd)
&& (player->pflags & PF_JUMPSTASIS || player->mo->state-states != S_PLAY_GLIDE_LANDING)) && (player->pflags & PF_JUMPSTASIS || player->mo->state-states != S_PLAY_GLIDE_LANDING))
return; return;
#ifdef HAVE_BLUA
if (cmd->buttons & BT_USE) if (cmd->buttons & BT_USE)
{ {
if (LUAh_SpinSpecial(player)) if (LUAh_SpinSpecial(player))
return; return;
} }
#endif
#ifdef ESLOPE #ifdef ESLOPE
canstand = (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2); canstand = (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2);
@ -5125,11 +5122,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
} }
} }
} }
if (cmd->buttons & BT_USE // Spin button effects if (cmd->buttons & BT_USE && !LUAh_ShieldSpecial(player)) // Spin button effects
#ifdef HAVE_BLUA
&& !LUAh_ShieldSpecial(player)
#endif
)
{ {
// Force stop // Force stop
if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE)
@ -5207,51 +5200,48 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
// and you don't have a shield, do it! // and you don't have a shield, do it!
P_DoSuperTransformation(player, false); P_DoSuperTransformation(player, false);
} }
else else if (!LUAh_JumpSpinSpecial(player))
#ifdef HAVE_BLUA switch (player->charability)
if (!LUAh_JumpSpinSpecial(player)) {
#endif case CA_THOK:
switch (player->charability) if (player->powers[pw_super]) // Super Sonic float
{
case CA_THOK:
if (player->powers[pw_super]) // Super Sonic float
{
if ((player->speed > 5*player->mo->scale) // FixedMul(5<<FRACBITS, player->mo->scale), but scale is FRACUNIT-based
&& (P_MobjFlip(player->mo)*player->mo->momz <= 0))
{ {
if (player->panim != PA_RUN && player->panim != PA_WALK) if ((player->speed > 5*player->mo->scale) // FixedMul(5<<FRACBITS, player->mo->scale), but scale is FRACUNIT-based
&& (P_MobjFlip(player->mo)*player->mo->momz <= 0))
{ {
if (player->speed >= FixedMul(player->runspeed, player->mo->scale)) if (player->panim != PA_RUN && player->panim != PA_WALK)
P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT_RUN); {
else if (player->speed >= FixedMul(player->runspeed, player->mo->scale))
P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT); P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT_RUN);
} else
P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT);
}
player->mo->momz = 0; player->mo->momz = 0;
player->pflags &= ~(PF_STARTJUMP|PF_SPINNING); player->pflags &= ~(PF_STARTJUMP|PF_SPINNING);
}
} }
} break;
break; case CA_TELEKINESIS:
case CA_TELEKINESIS: if (!(player->pflags & (PF_THOKKED|PF_USEDOWN)) || (player->charflags & SF_MULTIABILITY))
if (!(player->pflags & (PF_THOKKED|PF_USEDOWN)) || (player->charflags & SF_MULTIABILITY)) {
{ P_Telekinesis(player,
P_Telekinesis(player, -FixedMul(player->actionspd, player->mo->scale), // -ve thrust (pulling towards player)
-FixedMul(player->actionspd, player->mo->scale), // -ve thrust (pulling towards player) FixedMul(384*FRACUNIT, player->mo->scale));
FixedMul(384*FRACUNIT, player->mo->scale)); }
} break;
break; case CA_TWINSPIN:
case CA_TWINSPIN: if ((player->charability2 == CA2_MELEE) && (!(player->pflags & (PF_THOKKED|PF_USEDOWN)) || player->charflags & SF_MULTIABILITY))
if ((player->charability2 == CA2_MELEE) && (!(player->pflags & (PF_THOKKED|PF_USEDOWN)) || player->charflags & SF_MULTIABILITY)) {
{ player->pflags |= PF_THOKKED;
player->pflags |= PF_THOKKED; S_StartSound(player->mo, sfx_s3k42);
S_StartSound(player->mo, sfx_s3k42); player->mo->frame = 0;
player->mo->frame = 0; P_SetPlayerMobjState(player->mo, S_PLAY_TWINSPIN);
P_SetPlayerMobjState(player->mo, S_PLAY_TWINSPIN); }
} break;
break; default:
default: break;
break; }
}
} }
} }
@ -5287,16 +5277,13 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
if (cmd->buttons & BT_JUMP && !player->exiting && !P_PlayerInPain(player)) if (cmd->buttons & BT_JUMP && !player->exiting && !P_PlayerInPain(player))
{ {
#ifdef HAVE_BLUA
if (LUAh_JumpSpecial(player)) if (LUAh_JumpSpecial(player))
; ;
else // all situations below this require jump button not to be pressed already
#endif else if (player->pflags & PF_JUMPDOWN)
if (player->pflags & PF_JUMPDOWN) // all situations below this require jump button not to be pressed already
; ;
else
// Jump S3&K style while in quicksand. // Jump S3&K style while in quicksand.
if (P_InQuicksand(player->mo)) else if (P_InQuicksand(player->mo))
{ {
P_DoJump(player, true); P_DoJump(player, true);
player->secondjump = 0; player->secondjump = 0;
@ -5308,9 +5295,8 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
P_SetTarget(&player->mo->tracer, NULL); P_SetTarget(&player->mo->tracer, NULL);
player->powers[pw_flashing] = TICRATE/4; player->powers[pw_flashing] = TICRATE/4;
} }
else
// can't jump while in air, can't jump while jumping // can't jump while in air, can't jump while jumping
if (onground || player->climbing || player->powers[pw_carry]) else if (onground || player->climbing || player->powers[pw_carry])
{ {
P_DoJump(player, true); P_DoJump(player, true);
player->secondjump = 0; player->secondjump = 0;
@ -5326,9 +5312,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
}*/ }*/
else if (player->pflags & PF_JUMPED) else if (player->pflags & PF_JUMPED)
{ {
#ifdef HAVE_BLUA
if (!LUAh_AbilitySpecial(player)) if (!LUAh_AbilitySpecial(player))
#endif
switch (player->charability) switch (player->charability)
{ {
case CA_THOK: case CA_THOK:
@ -5523,30 +5507,28 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
} }
else if (player->pflags & PF_THOKKED) else if (player->pflags & PF_THOKKED)
{ {
#ifdef HAVE_BLUA
if (!LUAh_AbilitySpecial(player)) if (!LUAh_AbilitySpecial(player))
#endif switch (player->charability)
switch (player->charability) {
{ case CA_FLY:
case CA_FLY: case CA_SWIM: // Swim
case CA_SWIM: // Swim if (player->charability == CA_SWIM && !(player->mo->eflags & MFE_UNDERWATER))
if (player->charability == CA_SWIM && !(player->mo->eflags & MFE_UNDERWATER)) ; // Can't do anything if you're a fish out of water!
; // Can't do anything if you're a fish out of water! else if (player->powers[pw_tailsfly]) // If currently flying, give an ascend boost.
else if (player->powers[pw_tailsfly]) // If currently flying, give an ascend boost. {
{ player->fly1 = 20;
player->fly1 = 20;
if (player->charability == CA_SWIM) if (player->charability == CA_SWIM)
player->fly1 /= 2; player->fly1 /= 2;
// Slow down! // Slow down!
if (player->speed > FixedMul(8*FRACUNIT, player->mo->scale) && player->speed > FixedMul(player->normalspeed>>1, player->mo->scale)) if (player->speed > FixedMul(8*FRACUNIT, player->mo->scale) && player->speed > FixedMul(player->normalspeed>>1, player->mo->scale))
P_Thrust(player->mo, R_PointToAngle2(0,0,player->mo->momx,player->mo->momy), FixedMul(-4*FRACUNIT, player->mo->scale)); P_Thrust(player->mo, R_PointToAngle2(0,0,player->mo->momx,player->mo->momy), FixedMul(-4*FRACUNIT, player->mo->scale));
} }
break; break;
default: default:
break; break;
} }
} }
else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super]) else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super])
P_DoJumpShield(player); P_DoJumpShield(player);
@ -10633,10 +10615,8 @@ boolean P_SpectatorJoinGame(player_t *player)
else else
changeto = (P_RandomFixed() & 1) + 1; changeto = (P_RandomFixed() & 1) + 1;
#ifdef HAVE_BLUA
if (!LUAh_TeamSwitch(player, changeto, true, false, false)) if (!LUAh_TeamSwitch(player, changeto, true, false, false))
return false; return false;
#endif
if (player->mo) if (player->mo)
{ {
@ -10650,11 +10630,9 @@ boolean P_SpectatorJoinGame(player_t *player)
//Reset away view //Reset away view
if (P_IsLocalPlayer(player) && displayplayer != consoleplayer) if (P_IsLocalPlayer(player) && displayplayer != consoleplayer)
{ {
#ifdef HAVE_BLUA
// Call ViewpointSwitch hooks here. // Call ViewpointSwitch hooks here.
// The viewpoint was forcibly changed. // The viewpoint was forcibly changed.
LUAh_ViewpointSwitch(player, &players[displayplayer], true); LUAh_ViewpointSwitch(player, &players[consoleplayer], true);
#endif
displayplayer = consoleplayer; displayplayer = consoleplayer;
} }
@ -10672,10 +10650,8 @@ boolean P_SpectatorJoinGame(player_t *player)
// respawn in place and sit there for the rest of the round. // respawn in place and sit there for the rest of the round.
if (!((gametyperules & GTR_HIDEFROZEN) && leveltime > (hidetime * TICRATE))) if (!((gametyperules & GTR_HIDEFROZEN) && leveltime > (hidetime * TICRATE)))
{ {
#ifdef HAVE_BLUA
if (!LUAh_TeamSwitch(player, 3, true, false, false)) if (!LUAh_TeamSwitch(player, 3, true, false, false))
return false; return false;
#endif
if (player->mo) if (player->mo)
{ {
P_RemoveMobj(player->mo); P_RemoveMobj(player->mo);
@ -10699,11 +10675,9 @@ boolean P_SpectatorJoinGame(player_t *player)
//Reset away view //Reset away view
if (P_IsLocalPlayer(player) && displayplayer != consoleplayer) if (P_IsLocalPlayer(player) && displayplayer != consoleplayer)
{ {
#ifdef HAVE_BLUA
// Call ViewpointSwitch hooks here. // Call ViewpointSwitch hooks here.
// The viewpoint was forcibly changed. // The viewpoint was forcibly changed.
LUAh_ViewpointSwitch(player, &players[displayplayer], true); LUAh_ViewpointSwitch(player, &players[consoleplayer], true);
#endif
displayplayer = consoleplayer; displayplayer = consoleplayer;
} }
@ -11626,9 +11600,7 @@ void P_PlayerThink(player_t *player)
} }
if (player->playerstate == PST_REBORN) if (player->playerstate == PST_REBORN)
{ {
#ifdef HAVE_BLUA
LUAh_PlayerThink(player); LUAh_PlayerThink(player);
#endif
return; return;
} }
} }
@ -11732,9 +11704,7 @@ void P_PlayerThink(player_t *player)
if (player->playerstate == PST_DEAD) if (player->playerstate == PST_DEAD)
{ {
#ifdef HAVE_BLUA
LUAh_PlayerThink(player); LUAh_PlayerThink(player);
#endif
return; return;
} }
} }
@ -11857,9 +11827,7 @@ void P_PlayerThink(player_t *player)
{ {
player->mo->flags2 &= ~MF2_SHADOW; player->mo->flags2 &= ~MF2_SHADOW;
P_DeathThink(player); P_DeathThink(player);
#ifdef HAVE_BLUA
LUAh_PlayerThink(player); LUAh_PlayerThink(player);
#endif
return; return;
} }
@ -11901,9 +11869,7 @@ void P_PlayerThink(player_t *player)
{ {
if (P_SpectatorJoinGame(player)) if (P_SpectatorJoinGame(player))
{ {
#ifdef HAVE_BLUA
LUAh_PlayerThink(player); LUAh_PlayerThink(player);
#endif
return; // player->mo was removed. return; // player->mo was removed.
} }
} }
@ -12008,9 +11974,7 @@ void P_PlayerThink(player_t *player)
if (!player->mo) if (!player->mo)
{ {
#ifdef HAVE_BLUA
LUAh_PlayerThink(player); LUAh_PlayerThink(player);
#endif
return; // P_MovePlayer removed player->mo. return; // P_MovePlayer removed player->mo.
} }
@ -12452,9 +12416,7 @@ void P_PlayerThink(player_t *player)
} }
#undef dashmode #undef dashmode
#ifdef HAVE_BLUA
LUAh_PlayerThink(player); LUAh_PlayerThink(player);
#endif
/* /*
// Colormap verification // Colormap verification
@ -13004,11 +12966,9 @@ void P_PlayerAfterThink(player_t *player)
if (player->followmobj) if (player->followmobj)
{ {
#ifdef HAVE_BLUA
if (LUAh_FollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj)) if (LUAh_FollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj))
{;} {;}
else else
#endif
{ {
switch (player->followmobj->type) switch (player->followmobj->type)
{ {

View File

@ -40,7 +40,7 @@ extern INT32 msg_id;
#include "m_misc.h" // for tunes command #include "m_misc.h" // for tunes command
#include "m_cond.h" // for conditionsets #include "m_cond.h" // for conditionsets
#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) #ifdef HAVE_LUA_MUSICPLUS
#include "lua_hook.h" // MusicChange hook #include "lua_hook.h" // MusicChange hook
#endif #endif
@ -2045,7 +2045,7 @@ static musicstack_t *S_GetMusicStackEntry(UINT16 status, boolean fromfirst, INT1
if (!status || mst->status == status) if (!status || mst->status == status)
{ {
if (P_EvaluateMusicStatus(mst->status)) if (P_EvaluateMusicStatus(mst->status, mst->musname))
{ {
if (!S_MusicExists(mst->musname, !midi_disabled, !digital_disabled)) // paranoia if (!S_MusicExists(mst->musname, !midi_disabled, !digital_disabled)) // paranoia
S_RemoveMusicStackEntry(mst); // then continue S_RemoveMusicStackEntry(mst); // then continue
@ -2314,7 +2314,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
return; return;
strncpy(newmusic, mmusic, 7); strncpy(newmusic, mmusic, 7);
#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) #ifdef HAVE_LUA_MUSICPLUS
if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms))
return; return;
#endif #endif

View File

@ -50,7 +50,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;" AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;"
PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
@ -145,7 +145,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;" AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;"
PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
@ -248,7 +248,7 @@
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;" AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;"
PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
StringPooling="true" StringPooling="true"
RuntimeLibrary="0" RuntimeLibrary="0"
PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch" PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch"
@ -350,7 +350,7 @@
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;" AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;"
PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
StringPooling="true" StringPooling="true"
RuntimeLibrary="0" RuntimeLibrary="0"
PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch" PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch"

View File

@ -1272,7 +1272,6 @@
HAVE_SDL, HAVE_SDL,
HAVE_MIXER, HAVE_MIXER,
HAVE_PNG, HAVE_PNG,
HAVE_BLUA,
LUA_USE_POSIX, LUA_USE_POSIX,
COMPVERSION, COMPVERSION,
HWRENDER, HWRENDER,
@ -1395,7 +1394,6 @@
HAVE_SDL, HAVE_SDL,
HAVE_MIXER, HAVE_MIXER,
HAVE_PNG, HAVE_PNG,
HAVE_BLUA,
LUA_USE_POSIX, LUA_USE_POSIX,
COMPVERSION, COMPVERSION,
HWRENDER, HWRENDER,

View File

@ -42,9 +42,7 @@
#include "hardware/hw_main.h" #include "hardware/hw_main.h"
#endif #endif
#ifdef HAVE_BLUA
#include "lua_hud.h" #include "lua_hud.h"
#endif
UINT16 objectsdrawn = 0; UINT16 objectsdrawn = 0;
@ -969,11 +967,7 @@ static void ST_drawLivesArea(void)
V_DrawThinString(hudinfo[HUD_LIVES].x+18, hudinfo[HUD_LIVES].y, v_colmap, skins[stplyr->skin].hudname); V_DrawThinString(hudinfo[HUD_LIVES].x+18, hudinfo[HUD_LIVES].y, v_colmap, skins[stplyr->skin].hudname);
// Power Stones collected // Power Stones collected
if (G_RingSlingerGametype() if (G_RingSlingerGametype() && LUA_HudEnabled(hud_powerstones))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_powerstones)
#endif
)
{ {
INT32 workx = hudinfo[HUD_LIVES].x+1, j; INT32 workx = hudinfo[HUD_LIVES].x+1, j;
if ((leveltime & 1) && stplyr->powers[pw_invulnerability] && (stplyr->powers[pw_sneakers] == stplyr->powers[pw_invulnerability])) // hack; extremely unlikely to be activated unintentionally if ((leveltime & 1) && stplyr->powers[pw_invulnerability] && (stplyr->powers[pw_sneakers] == stplyr->powers[pw_invulnerability])) // hack; extremely unlikely to be activated unintentionally
@ -1341,17 +1335,11 @@ void ST_drawTitleCard(void)
if (!G_IsTitleCardAvailable()) if (!G_IsTitleCardAvailable())
return; return;
#ifdef HAVE_BLUA
if (!LUA_HudEnabled(hud_stagetitle)) if (!LUA_HudEnabled(hud_stagetitle))
goto luahook; goto luahook;
#endif
if (lt_ticker >= (lt_endtime + TICRATE)) if (lt_ticker >= (lt_endtime + TICRATE))
#ifdef HAVE_BLUA
goto luahook; goto luahook;
#else
return;
#endif
if ((lt_ticker-lt_lasttic) > 1) if ((lt_ticker-lt_lasttic) > 1)
lt_ticker = lt_lasttic+1; lt_ticker = lt_lasttic+1;
@ -1396,10 +1384,8 @@ void ST_drawTitleCard(void)
lt_lasttic = lt_ticker; lt_lasttic = lt_ticker;
#ifdef HAVE_BLUA
luahook: luahook:
LUAh_TitleCardHUD(stplyr); LUAh_TitleCardHUD(stplyr);
#endif
} }
// //
@ -1444,7 +1430,7 @@ static void ST_drawPowerupHUD(void)
if (stplyr->spectator || stplyr->playerstate != PST_LIVE) if (stplyr->spectator || stplyr->playerstate != PST_LIVE)
return; return;
// --------- // ---------
// Finish icon // Finish icon
// --------- // ---------
@ -1785,11 +1771,7 @@ static void ST_drawNiGHTSHUD(void)
const boolean oldspecialstage = (G_IsSpecialStage(gamemap) && !(maptol & TOL_NIGHTS)); const boolean oldspecialstage = (G_IsSpecialStage(gamemap) && !(maptol & TOL_NIGHTS));
// Drill meter // Drill meter
if ( if (LUA_HudEnabled(hud_nightsdrill) && stplyr->powers[pw_carry] == CR_NIGHTSMODE)
#ifdef HAVE_BLUA
LUA_HudEnabled(hud_nightsdrill) &&
#endif
stplyr->powers[pw_carry] == CR_NIGHTSMODE)
{ {
INT32 locx = 16, locy = 180; INT32 locx = 16, locy = 180;
INT32 dfill; INT32 dfill;
@ -1831,9 +1813,7 @@ static void ST_drawNiGHTSHUD(void)
if (!oldspecialstage if (!oldspecialstage
// Don't display when the score is showing (it popping up for a split second when exiting a map is intentional) // Don't display when the score is showing (it popping up for a split second when exiting a map is intentional)
&& !(stplyr->texttimer && stplyr->textvar == 4) && !(stplyr->texttimer && stplyr->textvar == 4)
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_nightslink) && LUA_HudEnabled(hud_nightslink)
#endif
&& ((cv_debug & DBG_NIGHTSBASIC) || stplyr->linkcount > 1)) // When debugging, show "0 Link". && ((cv_debug & DBG_NIGHTSBASIC) || stplyr->linkcount > 1)) // When debugging, show "0 Link".
{ {
ST_drawNiGHTSLink(); ST_drawNiGHTSLink();
@ -1847,10 +1827,8 @@ static void ST_drawNiGHTSHUD(void)
} }
// Begin drawing brackets/chip display // Begin drawing brackets/chip display
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_nightsspheres)) if (LUA_HudEnabled(hud_nightsspheres))
{ {
#endif
ST_DrawTopLeftOverlayPatch(16, 8, nbracket); ST_DrawTopLeftOverlayPatch(16, 8, nbracket);
if (G_IsSpecialStage(gamemap)) if (G_IsSpecialStage(gamemap))
ST_DrawTopLeftOverlayPatch(24, 16, ( ST_DrawTopLeftOverlayPatch(24, 16, (
@ -1987,24 +1965,14 @@ static void ST_drawNiGHTSHUD(void)
V_DrawTallNum((total_spherecount >= 1000) ? 76 : 72, 8 + 11, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTOLEFT|V_HUDTRANS, total_spherecount); V_DrawTallNum((total_spherecount >= 1000) ? 76 : 72, 8 + 11, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTOLEFT|V_HUDTRANS, total_spherecount);
else else
V_DrawTallNum(68, 8 + 11, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTOLEFT|V_HUDTRANS, total_spherecount); V_DrawTallNum(68, 8 + 11, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTOLEFT|V_HUDTRANS, total_spherecount);
#ifdef HAVE_BLUA
} }
#endif
// Score // Score
if (!stplyr->exiting && !oldspecialstage if (!stplyr->exiting && !oldspecialstage && LUA_HudEnabled(hud_nightsscore))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_nightsscore)
#endif
)
ST_DrawNightsOverlayNum(304<<FRACBITS, 14<<FRACBITS, FRACUNIT, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTORIGHT, stplyr->marescore, nightsnum, SKINCOLOR_AZURE); ST_DrawNightsOverlayNum(304<<FRACBITS, 14<<FRACBITS, FRACUNIT, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTORIGHT, stplyr->marescore, nightsnum, SKINCOLOR_AZURE);
if (!stplyr->exiting
#ifdef HAVE_BLUA
// TODO give this its own section for Lua // TODO give this its own section for Lua
&& LUA_HudEnabled(hud_nightsscore) if (!stplyr->exiting && LUA_HudEnabled(hud_nightsscore))
#endif
)
{ {
if (modeattacking == ATTACKING_NIGHTS) if (modeattacking == ATTACKING_NIGHTS)
{ {
@ -2027,11 +1995,7 @@ static void ST_drawNiGHTSHUD(void)
} }
// Ideya time remaining // Ideya time remaining
if (!stplyr->exiting && stplyr->nightstime > 0 if (!stplyr->exiting && stplyr->nightstime > 0 && LUA_HudEnabled(hud_nightstime))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_nightstime)
#endif
)
{ {
INT32 realnightstime = stplyr->nightstime/TICRATE; INT32 realnightstime = stplyr->nightstime/TICRATE;
INT32 numbersize; INT32 numbersize;
@ -2122,10 +2086,8 @@ static void ST_drawNiGHTSHUD(void)
} }
// Records/extra text // Records/extra text
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_nightsrecords)) if (LUA_HudEnabled(hud_nightsrecords))
#endif ST_drawNightsRecords();
ST_drawNightsRecords();
} }
} }
@ -2403,20 +2365,16 @@ static void ST_drawTeamHUD(void)
else else
p = bmatcico; p = bmatcico;
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_teamscores)) if (LUA_HudEnabled(hud_teamscores))
#endif V_DrawSmallScaledPatch(BASEVIDWIDTH/2 - SEP - SHORT(p->width)/4, 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p);
V_DrawSmallScaledPatch(BASEVIDWIDTH/2 - SEP - SHORT(p->width)/4, 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p);
if (gametyperules & GTR_TEAMFLAGS) if (gametyperules & GTR_TEAMFLAGS)
p = rflagico; p = rflagico;
else else
p = rmatcico; p = rmatcico;
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_teamscores)) if (LUA_HudEnabled(hud_teamscores))
#endif V_DrawSmallScaledPatch(BASEVIDWIDTH/2 + SEP - SHORT(p->width)/4, 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p);
V_DrawSmallScaledPatch(BASEVIDWIDTH/2 + SEP - SHORT(p->width)/4, 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p);
if (!(gametyperules & GTR_TEAMFLAGS)) if (!(gametyperules & GTR_TEAMFLAGS))
goto num; goto num;
@ -2427,18 +2385,12 @@ static void ST_drawTeamHUD(void)
// Show which flags aren't at base. // Show which flags aren't at base.
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (players[i].gotflag & GF_BLUEFLAG // Blue flag isn't at base // Blue flag isn't at base
#ifdef HAVE_BLUA if (players[i].gotflag & GF_BLUEFLAG && LUA_HudEnabled(hud_teamscores))
&& LUA_HudEnabled(hud_teamscores)
#endif
)
V_DrawScaledPatch(BASEVIDWIDTH/2 - SEP - SHORT(nonicon->width)/2, 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon); V_DrawScaledPatch(BASEVIDWIDTH/2 - SEP - SHORT(nonicon->width)/2, 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon);
if (players[i].gotflag & GF_REDFLAG // Red flag isn't at base // Red flag isn't at base
#ifdef HAVE_BLUA if (players[i].gotflag & GF_REDFLAG && LUA_HudEnabled(hud_teamscores))
&& LUA_HudEnabled(hud_teamscores)
#endif
)
V_DrawScaledPatch(BASEVIDWIDTH/2 + SEP - SHORT(nonicon2->width)/2, 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon2); V_DrawScaledPatch(BASEVIDWIDTH/2 + SEP - SHORT(nonicon2->width)/2, 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon2);
whichflag |= players[i].gotflag; whichflag |= players[i].gotflag;
@ -2449,32 +2401,20 @@ static void ST_drawTeamHUD(void)
// Display a countdown timer showing how much time left until the flag returns to base. // Display a countdown timer showing how much time left until the flag returns to base.
{ {
if (blueflag && blueflag->fuse > 1 if (blueflag && blueflag->fuse > 1 && LUA_HudEnabled(hud_teamscores))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_teamscores)
#endif
)
V_DrawCenteredString(BASEVIDWIDTH/2 - SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (blueflag->fuse / TICRATE))); V_DrawCenteredString(BASEVIDWIDTH/2 - SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (blueflag->fuse / TICRATE)));
if (redflag && redflag->fuse > 1 if (redflag && redflag->fuse > 1 && LUA_HudEnabled(hud_teamscores))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_teamscores)
#endif
)
V_DrawCenteredString(BASEVIDWIDTH/2 + SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (redflag->fuse / TICRATE))); V_DrawCenteredString(BASEVIDWIDTH/2 + SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (redflag->fuse / TICRATE)));
} }
} }
num: num:
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_teamscores)) if (LUA_HudEnabled(hud_teamscores))
#endif V_DrawCenteredString(BASEVIDWIDTH/2 - SEP, 16, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", bluescore));
V_DrawCenteredString(BASEVIDWIDTH/2 - SEP, 16, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", bluescore));
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_teamscores)) if (LUA_HudEnabled(hud_teamscores))
#endif V_DrawCenteredString(BASEVIDWIDTH/2 + SEP, 16, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", redscore));
V_DrawCenteredString(BASEVIDWIDTH/2 + SEP, 16, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", redscore));
#undef SEP #undef SEP
} }
@ -2661,24 +2601,14 @@ static void ST_overlayDrawer(void)
ST_drawNiGHTSHUD(); ST_drawNiGHTSHUD();
else else
{ {
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_score)) if (LUA_HudEnabled(hud_score))
#endif ST_drawScore();
ST_drawScore();
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_time)) if (LUA_HudEnabled(hud_time))
#endif ST_drawTime();
ST_drawTime();
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_rings)) if (LUA_HudEnabled(hud_rings))
#endif ST_drawRings();
ST_drawRings();
if (!modeattacking if (!modeattacking && LUA_HudEnabled(hud_lives))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_lives)
#endif
)
ST_drawLivesArea(); ST_drawLivesArea();
} }
} }
@ -2753,11 +2683,7 @@ static void ST_overlayDrawer(void)
// Draw Match-related stuff // Draw Match-related stuff
//\note Match HUD is drawn no matter what gametype. //\note Match HUD is drawn no matter what gametype.
// ... just not if you're a spectator. // ... just not if you're a spectator.
if (!stplyr->spectator if (!stplyr->spectator && LUA_HudEnabled(hud_weaponrings))
#ifdef HAVE_BLUA
&& (LUA_HudEnabled(hud_weaponrings))
#endif
)
ST_drawMatchHUD(); ST_drawMatchHUD();
// Race HUD Stuff // Race HUD Stuff
@ -2798,20 +2724,14 @@ static void ST_overlayDrawer(void)
else if (!(netgame || multiplayer) && cv_powerupdisplay.value == 2) else if (!(netgame || multiplayer) && cv_powerupdisplay.value == 2)
ST_drawPowerupHUD(); // same as it ever was... ST_drawPowerupHUD(); // same as it ever was...
#ifdef HAVE_BLUA
if (!(netgame || multiplayer) || !hu_showscores) if (!(netgame || multiplayer) || !hu_showscores)
LUAh_GameHUD(stplyr); LUAh_GameHUD(stplyr);
#endif
// draw level title Tails // draw level title Tails
if (stagetitle && (!WipeInAction) && (!WipeStageTitle)) if (stagetitle && (!WipeInAction) && (!WipeStageTitle))
ST_drawTitleCard(); ST_drawTitleCard();
if (!hu_showscores && (netgame || multiplayer) if (!hu_showscores && (netgame || multiplayer) && LUA_HudEnabled(hud_textspectator))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_textspectator)
#endif
)
ST_drawTextHUD(); ST_drawTextHUD();
if (modeattacking && !(demoplayback && hu_showscores)) if (modeattacking && !(demoplayback && hu_showscores))

View File

@ -189,7 +189,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum, boolean mainfile) static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum, boolean mainfile)
{ {
UINT16 posStart, posEnd; UINT16 posStart, posEnd;
#ifdef HAVE_BLUA
posStart = W_CheckNumForFolderStartPK3("Lua/", wadnum, 0); posStart = W_CheckNumForFolderStartPK3("Lua/", wadnum, 0);
if (posStart != INT16_MAX) if (posStart != INT16_MAX)
{ {
@ -198,7 +198,7 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum, boolean mainfile)
for (; posStart < posEnd; posStart++) for (; posStart < posEnd; posStart++)
LUA_LoadLump(wadnum, posStart); LUA_LoadLump(wadnum, posStart);
} }
#endif
posStart = W_CheckNumForFolderStartPK3("SOC/", wadnum, 0); posStart = W_CheckNumForFolderStartPK3("SOC/", wadnum, 0);
if (posStart != INT16_MAX) if (posStart != INT16_MAX)
{ {
@ -224,7 +224,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum, boolean mainfile)
{ {
UINT16 lump; UINT16 lump;
#ifdef HAVE_BLUA
// Find Lua scripts before SOCs to allow new A_Actions in SOC editing. // Find Lua scripts before SOCs to allow new A_Actions in SOC editing.
{ {
lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo;
@ -232,7 +231,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum, boolean mainfile)
if (memcmp(lump_p->name,"LUA_",4)==0) if (memcmp(lump_p->name,"LUA_",4)==0)
LUA_LoadLump(wadnum, lump); LUA_LoadLump(wadnum, lump);
} }
#endif
{ {
lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo;
@ -749,11 +747,9 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
case RET_SOC: case RET_SOC:
lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "OBJCTCFG"); lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "OBJCTCFG");
break; break;
#ifdef HAVE_BLUA
case RET_LUA: case RET_LUA:
lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "LUA_INIT"); lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "LUA_INIT");
break; break;
#endif
case RET_PK3: case RET_PK3:
lumpinfo = ResGetLumpsZip(handle, &numlumps); lumpinfo = ResGetLumpsZip(handle, &numlumps);
break; break;
@ -818,11 +814,9 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
CONS_Printf(M_GetText("Loading SOC from %s\n"), wadfile->filename); CONS_Printf(M_GetText("Loading SOC from %s\n"), wadfile->filename);
DEH_LoadDehackedLumpPwad(numwadfiles - 1, 0, mainfile); DEH_LoadDehackedLumpPwad(numwadfiles - 1, 0, mainfile);
break; break;
#ifdef HAVE_BLUA
case RET_LUA: case RET_LUA:
LUA_LoadLump(numwadfiles - 1, 0); LUA_LoadLump(numwadfiles - 1, 0);
break; break;
#endif
default: default:
break; break;
} }
@ -1860,10 +1854,7 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist,
{ {
// detect wad file by the absence of the other supported extensions // detect wad file by the absence of the other supported extensions
if (stricmp(&filename[strlen(filename) - 4], ".soc") if (stricmp(&filename[strlen(filename) - 4], ".soc")
#ifdef HAVE_BLUA && stricmp(&filename[strlen(filename) - 4], ".lua"))
&& stricmp(&filename[strlen(filename) - 4], ".lua")
#endif
)
{ {
goodfile = W_VerifyWAD(handle, checklist, status); goodfile = W_VerifyWAD(handle, checklist, status);
} }

View File

@ -55,7 +55,7 @@
Optimization="0" Optimization="0"
OmitFramePointers="false" OmitFramePointers="false"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;" AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;"
PreprocessorDefinitions="_DEBUG;_WINDOWS;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" PreprocessorDefinitions="_DEBUG;_WINDOWS;USEASM;HAVE_PNG;COMPVERSION;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
MinimalRebuild="true" MinimalRebuild="true"
RuntimeLibrary="1" RuntimeLibrary="1"
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"
@ -153,7 +153,7 @@
Optimization="0" Optimization="0"
OmitFramePointers="false" OmitFramePointers="false"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;" AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;"
PreprocessorDefinitions="_DEBUG;_WINDOWS;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" PreprocessorDefinitions="_DEBUG;_WINDOWS;HAVE_PNG;COMPVERSION;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
SmallerTypeCheck="true" SmallerTypeCheck="true"
@ -256,7 +256,7 @@
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;" AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;"
PreprocessorDefinitions="NDEBUG;_WINDOWS;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" PreprocessorDefinitions="NDEBUG;_WINDOWS;USEASM;HAVE_PNG;COMPVERSION;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
StringPooling="true" StringPooling="true"
RuntimeLibrary="0" RuntimeLibrary="0"
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"
@ -356,7 +356,7 @@
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;" AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\libs\libpng-src&quot;;&quot;$(ProjectDir)..\..\libs\zlib&quot;"
PreprocessorDefinitions="NDEBUG;_WINDOWS;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" PreprocessorDefinitions="NDEBUG;_WINDOWS;HAVE_PNG;COMPVERSION;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
StringPooling="true" StringPooling="true"
RuntimeLibrary="0" RuntimeLibrary="0"
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"

View File

@ -37,9 +37,7 @@
#include "m_cond.h" // condition sets #include "m_cond.h" // condition sets
#include "lua_hook.h" // IntermissionThinker hook #include "lua_hook.h" // IntermissionThinker hook
#ifdef HAVE_BLUA
#include "lua_hud.h" #include "lua_hud.h"
#endif
#ifdef HWRENDER #ifdef HWRENDER
#include "hardware/hw_main.h" #include "hardware/hw_main.h"
@ -330,9 +328,7 @@ void Y_IntermissionDrawer(void)
if (intertype == int_none) if (intertype == int_none)
{ {
#ifdef HAVE_BLUA
LUAh_IntermissionHUD(); LUAh_IntermissionHUD();
#endif
return; return;
} }
@ -384,11 +380,9 @@ void Y_IntermissionDrawer(void)
else else
V_DrawPatchFill(bgtile); V_DrawPatchFill(bgtile);
#ifdef HAVE_BLUA
LUAh_IntermissionHUD(); LUAh_IntermissionHUD();
if (!LUA_HudEnabled(hud_intermissiontally)) if (!LUA_HudEnabled(hud_intermissiontally))
goto skiptallydrawer; goto skiptallydrawer;
#endif
dontdrawbg: dontdrawbg:
if (intertype == int_coop) if (intertype == int_coop)
@ -944,11 +938,9 @@ dontdrawbg:
} }
} }
#ifdef HAVE_BLUA
skiptallydrawer: skiptallydrawer:
if (!LUA_HudEnabled(hud_intermissionmessages)) if (!LUA_HudEnabled(hud_intermissionmessages))
return; return;
#endif
if (timer) if (timer)
V_DrawCenteredString(BASEVIDWIDTH/2, 188, V_YELLOWMAP, V_DrawCenteredString(BASEVIDWIDTH/2, 188, V_YELLOWMAP,
@ -973,9 +965,7 @@ void Y_Ticker(void)
if (paused || P_AutoPause()) if (paused || P_AutoPause())
return; return;
#ifdef HAVE_BLUA
LUAh_IntermissionThinker(); LUAh_IntermissionThinker();
#endif
intertic++; intertic++;

View File

@ -217,11 +217,9 @@ void Z_Free(void *ptr)
CONS_Debug(DBG_MEMORY, "Z_Free at %s:%d\n", file, line); CONS_Debug(DBG_MEMORY, "Z_Free at %s:%d\n", file, line);
#endif #endif
#ifdef HAVE_BLUA
// anything that isn't by lua gets passed to lua just in case. // anything that isn't by lua gets passed to lua just in case.
if (block->tag != PU_LUA) if (block->tag != PU_LUA)
LUA_InvalidateUserdata(ptr); LUA_InvalidateUserdata(ptr);
#endif
// TODO: if zdebugging, make sure no other block has a user // TODO: if zdebugging, make sure no other block has a user
// that is about to be freed. // that is about to be freed.