Merge remote-tracking branch 'srb2/next'

This commit is contained in:
James R 2021-04-05 01:21:31 -07:00
commit 08348fcd43
56 changed files with 574 additions and 218 deletions

2
dep/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
#All folders
*.d

2
dep/FreeBSD/SDL/Debug/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/FreeBSD/SDL/Release/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Linux/SDL/Debug/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Linux/SDL/Release/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Linux64/SDL/Debug/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Linux64/SDL/Release/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/MasterClient/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/MasterServer/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Mingw/Debug/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Mingw/Release/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Mingw/SDL/Debug/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Mingw/SDL/Release/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Mingw64/Debug/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Mingw64/Release/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Mingw64/SDL/Debug/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/Mingw64/SDL/Release/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/SDL/Release/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/VC/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/VC9/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/cygwin/Debug/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/cygwin/Release/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

2
dep/dummy/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# DON'T REMOVE
# This keeps the folder from disappearing

View file

@ -2,7 +2,7 @@
# GNU Make makefile for SRB2 # GNU Make makefile for SRB2
############################################################################# #############################################################################
# Copyright (C) 1998-2000 by DooM Legacy Team. # Copyright (C) 1998-2000 by DooM Legacy Team.
# Copyright (C) 2003-2020 by Sonic Team Junior. # Copyright (C) 2003-2021 by Sonic Team Junior.
# #
# This program is free software distributed under the # This program is free software distributed under the
# terms of the GNU General Public License, version 2. # terms of the GNU General Public License, version 2.
@ -24,7 +24,9 @@
# clean # clean
# Remove all object files # Remove all object files
# cleandep # cleandep
# Remove depend.dep # Remove dependency files
# distclean
# Remove autogenerated files
# dll # dll
# compile primary HW render DLL/SO # compile primary HW render DLL/SO
# all_dll # all_dll
@ -80,6 +82,17 @@
# #
############################################################################# #############################################################################
,=,
ifeq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all)))
CLEANONLY=1
else ifndef SILENT
echo=@echo "$(1)"
ifndef MAKE_RESTARTS
print=$(info $(1))
endif
endif
ALL_SYSTEMS=\ ALL_SYSTEMS=\
PANDORA\ PANDORA\
LINUX64\ LINUX64\
@ -99,7 +112,7 @@ ALL_SYSTEMS=\
ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES)))
ifeq ($(OS),Windows_NT) # all windows are Windows_NT... ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
$(info Detected a Windows system, compiling for 32-bit MinGW SDL2...) $(call print,Detected a Windows system$(,) compiling for 32-bit MinGW SDL2...)
# go for a 32-bit sdl mingw exe by default # go for a 32-bit sdl mingw exe by default
MINGW=1 MINGW=1
@ -124,7 +137,7 @@ else # if you on the *nix
new_system:=$(new_system)64 new_system:=$(new_system)64
endif endif
$(info Detected $(system) ($(new_system))...) $(call print,Detected $(system) ($(new_system))...)
$(new_system)=1 $(new_system)=1
endif endif
@ -242,6 +255,12 @@ endif
MSGFMT?=msgfmt MSGFMT?=msgfmt
ifdef WINDOWSHELL
COMPTIME=-..\comptime.bat
else
COMPTIME=-../comptime.sh
endif
ifndef ECHO ifndef ECHO
NASM:=@$(NASM) NASM:=@$(NASM)
REMOVE:=@$(REMOVE) REMOVE:=@$(REMOVE)
@ -256,6 +275,7 @@ ifndef ECHO
MSGFMT:=@$(MSGFMT) MSGFMT:=@$(MSGFMT)
UPX:=@$(UPX) UPX:=@$(UPX)
UPX_OPTS+=-q UPX_OPTS+=-q
COMPTIME:=@$(COMPTIME)
endif endif
ifdef NONET ifdef NONET
@ -475,7 +495,6 @@ DBGNAME?=$(EXENAME).debug
# not too sophisticated dependency # not too sophisticated dependency
# SRB2kart kart.o on line 433 below # SRB2kart kart.o on line 433 below
OBJS:=$(i_main_o) \ OBJS:=$(i_main_o) \
$(OBJDIR)/comptime.o \
$(OBJDIR)/string.o \ $(OBJDIR)/string.o \
$(OBJDIR)/d_main.o \ $(OBJDIR)/d_main.o \
$(OBJDIR)/d_clisrv.o \ $(OBJDIR)/d_clisrv.o \
@ -579,7 +598,10 @@ OBJS:=$(i_main_o) \
$(i_sound_o) \ $(i_sound_o) \
$(OBJS) $(OBJS)
DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(filter %.o,$(OBJS)))
OBJS+=$(OBJDIR)/comptime.o
ifndef SILENT
ifndef ECHO ifndef ECHO
ifndef NOECHOFILENAMES ifndef NOECHOFILENAMES
define echoName = define echoName =
@ -587,6 +609,7 @@ define echoName =
endef endef
endif endif
endif endif
endif
# List of languages to compile. # List of languages to compile.
# For reference, this is the command I use to build a srb2.pot file from the source code. # For reference, this is the command I use to build a srb2.pot file from the source code.
@ -599,12 +622,12 @@ OPTS+=-DGETTEXT
endif endif
ifdef PANDORA ifdef PANDORA
all: pre-build $(BIN)/$(PNDNAME) all: $(BIN)/$(PNDNAME)
endif endif
ifdef SDL ifdef SDL
all: pre-build $(BIN)/$(EXENAME) all: $(BIN)/$(EXENAME)
endif endif
ifdef DUMMY ifdef DUMMY
@ -612,20 +635,15 @@ all: $(BIN)/$(EXENAME)
endif endif
cleandep: cleandep:
$(REMOVE) $(OBJDIR)/depend.dep $(REMOVE) $(DEPS)
$(REMOVE) comptime.h $(REMOVE) comptime.h
pre-build:
ifdef WINDOWSHELL
-..\comptime.bat .
else
-@../comptime.sh .
endif
clean: clean:
$(REMOVE) *~ *.flc $(REMOVE) *~ *.flc
$(REMOVE) $(OBJDIR)/*.o $(REMOVE) $(OBJDIR)/*.o
distclean: clean cleandep
ifdef MINGW ifdef MINGW
$(REMOVE) $(OBJDIR)/*.res $(REMOVE) $(OBJDIR)/*.res
endif endif
@ -645,11 +663,11 @@ asm:
$(BIN)/$(EXENAME): $(POS) $(OBJS) $(BIN)/$(EXENAME): $(POS) $(OBJS)
-$(MKDIR) $(BIN) -$(MKDIR) $(BIN)
@echo Linking $(EXENAME)... $(call echo,Linking $(EXENAME)...)
$(LD) $(LDFLAGS) $(OBJS) -o $(BIN)/$(EXENAME) $(LIBS) $(LD) $(LDFLAGS) $(OBJS) -o $(BIN)/$(EXENAME) $(LIBS)
ifndef VALGRIND ifndef VALGRIND
ifndef NOOBJDUMP ifndef NOOBJDUMP
@echo Dumping debugging info $(call echo,Dumping debugging info)
$(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(EXENAME) > $(BIN)/$(DBGNAME).txt $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(EXENAME) > $(BIN)/$(DBGNAME).txt
ifdef WINDOWSHELL ifdef WINDOWSHELL
-$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt
@ -668,10 +686,10 @@ ifndef NOUPX
-$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME)
endif endif
endif endif
@echo Build is done, please look for $(EXENAME) in $(BIN), \(checking for post steps\) $(call echo,Build is done$(,) please look for $(EXENAME) in $(BIN)$(,) (checking for post steps))
reobjdump: reobjdump:
@echo Redumping debugging info $(call echo,Redumping debugging info)
$(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(DBGNAME) > $(BIN)/$(DBGNAME).txt $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(DBGNAME) > $(BIN)/$(DBGNAME).txt
ifdef WINDOWSHELL ifdef WINDOWSHELL
-$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt
@ -707,24 +725,40 @@ endif
endif endif
#dependecy made by gcc itself ! #dependecy made by gcc itself !
$(OBJS):
ifndef DUMMY ifndef DUMMY
-include $(OBJDIR)/depend.dep ifndef CLEANONLY
$(call print,Checking dependency files...)
-include $(DEPS)
endif
endif endif
$(OBJDIR)/depend.dep: undefine deps_rule
@echo "Creating dependency file, depend.dep"
@echo > comptime.h # windows makes it too hard !
-$(MKDIR) $(OBJDIR) ifndef WINDOWSHELL
$(CC) $(CFLAGS) -MM *.c > $(OBJDIR)/depend.ped ifdef echoName
$(CC) $(CFLAGS) -MM $(INTERFACE)/*.c >> $(OBJDIR)/depend.ped define deps_rule =
ifndef NOHW @printf "%-20.20s\r" $<
$(CC) $(CFLAGS) -MM hardware/*.c >> $(OBJDIR)/depend.ped
endef
endif endif
$(CC) $(CFLAGS) -MM blua/*.c >> $(OBJDIR)/depend.ped endif
@sed -e 's,\(.*\)\.o: ,$(subst /,\/,$(OBJDIR))\/&,g' < $(OBJDIR)/depend.ped > $(OBJDIR)/depend.dep
$(REMOVE) $(OBJDIR)/depend.ped define deps_rule +=
@echo "Created dependency file, depend.dep" $(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$< $<
endef
$(DEPDIR)/%.d: %.c
$(deps_rule)
$(DEPDIR)/%.d: $(INTERFACE)/%.c
$(deps_rule)
$(DEPDIR)/%.d: hardware/%.c
$(deps_rule)
$(DEPDIR)/%.d: blua/%.c
$(deps_rule)
ifdef VALGRIND ifdef VALGRIND
$(OBJDIR)/z_zone.o: z_zone.c $(OBJDIR)/z_zone.o: z_zone.c
@ -732,9 +766,12 @@ $(OBJDIR)/z_zone.o: z_zone.c
$(CC) $(CFLAGS) $(WFLAGS) -DHAVE_VALGRIND $(VALGRIND_CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(WFLAGS) -DHAVE_VALGRIND $(VALGRIND_CFLAGS) -c $< -o $@
endif endif
$(OBJDIR)/comptime.o: comptime.c pre-build $(OBJDIR)/comptime.o::
$(echoName) ifdef echoName
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ @echo -- comptime.c ...
endif
$(COMPTIME) .
$(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@
$(BIN)/%.mo: locale/%.po $(BIN)/%.mo: locale/%.po
-$(MKDIR) $(BIN) -$(MKDIR) $(BIN)

View file

@ -47,7 +47,8 @@ ifdef MACOSX
endif endif
# Automatically set version flag, but not if one was manually set # Automatically set version flag, but not if one was manually set
ifeq (,$(filter GCC%,$(.VARIABLES))) # And don't bother if this is a clean only run
ifeq (,$(filter GCC% CLEANONLY,$(.VARIABLES)))
version:=$(shell $(CC) --version) version:=$(shell $(CC) --version)
# check if this is in fact GCC # check if this is in fact GCC
ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version)))) ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version))))
@ -60,12 +61,14 @@ ifeq (,$(filter GCC%,$(.VARIABLES)))
# If this version is not in the list, default to the latest supported # If this version is not in the list, default to the latest supported
ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS)))
$(info\ define line =
Your compiler version, GCC $(version), is not supported by the Makefile.\ Your compiler version, GCC $(version), is not supported by the Makefile.
The Makefile will assume GCC $(LATEST_GCC_VERSION).) The Makefile will assume GCC $(LATEST_GCC_VERSION).))
endef
$(call print,$(line))
GCC$(subst .,,$(LATEST_GCC_VERSION))=1 GCC$(subst .,,$(LATEST_GCC_VERSION))=1
else else
$(info Detected GCC $(version) (GCC$(v))) $(call print,Detected GCC $(version) (GCC$(v)))
GCC$(v)=1 GCC$(v)=1
endif endif
endif endif
@ -365,6 +368,7 @@ i_main_o=$(OBJDIR)/i_main.o
#set OBJDIR and BIN's starting place #set OBJDIR and BIN's starting place
OBJDIR=../objs OBJDIR=../objs
BIN=../bin BIN=../bin
DEPDIR=../dep
#Nasm ASM and rm #Nasm ASM and rm
ifdef YASM ifdef YASM
NASM?=yasm NASM?=yasm
@ -387,6 +391,7 @@ ifdef DUMMY
INTERFACE=dummy INTERFACE=dummy
OBJDIR:=$(OBJDIR)/dummy OBJDIR:=$(OBJDIR)/dummy
BIN:=$(BIN)/dummy BIN:=$(BIN)/dummy
DEPDIR:=$(DEPDIR)/dummy
else else
ifdef LINUX ifdef LINUX
NASMFORMAT=elf -DLINUX NASMFORMAT=elf -DLINUX
@ -394,9 +399,11 @@ ifdef LINUX
ifdef LINUX64 ifdef LINUX64
OBJDIR:=$(OBJDIR)/Linux64 OBJDIR:=$(OBJDIR)/Linux64
BIN:=$(BIN)/Linux64 BIN:=$(BIN)/Linux64
DEPDIR:=$(DEPDIR)/Linux64
else else
OBJDIR:=$(OBJDIR)/Linux OBJDIR:=$(OBJDIR)/Linux
BIN:=$(BIN)/Linux BIN:=$(BIN)/Linux
DEPDIR:=$(DEPDIR)/Linux
endif endif
else else
ifdef FREEBSD ifdef FREEBSD
@ -406,6 +413,7 @@ ifdef FREEBSD
OBJDIR:=$(OBJDIR)/FreeBSD OBJDIR:=$(OBJDIR)/FreeBSD
BIN:=$(BIN)/FreeBSD BIN:=$(BIN)/FreeBSD
DEPDIR:=$(DEPDIR)/Linux
else else
ifdef SOLARIS ifdef SOLARIS
INTERFACE=sdl INTERFACE=sdl
@ -414,6 +422,7 @@ ifdef SOLARIS
OBJDIR:=$(OBJDIR)/Solaris OBJDIR:=$(OBJDIR)/Solaris
BIN:=$(BIN)/Solaris BIN:=$(BIN)/Solaris
DEPDIR:=$(DEPDIR)/Solaris
else else
ifdef CYGWIN32 ifdef CYGWIN32
INTERFACE=sdl INTERFACE=sdl
@ -422,18 +431,21 @@ ifdef CYGWIN32
OBJDIR:=$(OBJDIR)/cygwin OBJDIR:=$(OBJDIR)/cygwin
BIN:=$(BIN)/Cygwin BIN:=$(BIN)/Cygwin
DEPDIR:=$(DEPDIR)/Cygwin
else else
ifdef MINGW64 ifdef MINGW64
#NASMFORMAT=win64 #NASMFORMAT=win64
SDL=1 SDL=1
OBJDIR:=$(OBJDIR)/Mingw64 OBJDIR:=$(OBJDIR)/Mingw64
BIN:=$(BIN)/Mingw64 BIN:=$(BIN)/Mingw64
DEPDIR:=$(DEPDIR)/Mingw64
else else
ifdef MINGW ifdef MINGW
NASMFORMAT=win32 NASMFORMAT=win32
SDL=1 SDL=1
OBJDIR:=$(OBJDIR)/Mingw OBJDIR:=$(OBJDIR)/Mingw
BIN:=$(BIN)/Mingw BIN:=$(BIN)/Mingw
DEPDIR:=$(DEPDIR)/Mingw
endif endif
endif endif
endif endif
@ -445,6 +457,7 @@ endif
ifdef ARCHNAME ifdef ARCHNAME
OBJDIR:=$(OBJDIR)/$(ARCHNAME) OBJDIR:=$(OBJDIR)/$(ARCHNAME)
BIN:=$(BIN)/$(ARCHNAME) BIN:=$(BIN)/$(ARCHNAME)
DEPDIR:=$(DEPDIR)/$(ARCHNAME)
endif endif
OBJDUMP_OPTS?=--wide --source --line-numbers OBJDUMP_OPTS?=--wide --source --line-numbers
@ -453,14 +466,17 @@ LD=$(CC)
ifdef SDL ifdef SDL
INTERFACE=sdl INTERFACE=sdl
OBJDIR:=$(OBJDIR)/SDL OBJDIR:=$(OBJDIR)/SDL
DEPDIR:=$(DEPDIR)/SDL
endif endif
ifndef DUMMY ifndef DUMMY
ifdef DEBUGMODE ifdef DEBUGMODE
OBJDIR:=$(OBJDIR)/Debug OBJDIR:=$(OBJDIR)/Debug
BIN:=$(BIN)/Debug BIN:=$(BIN)/Debug
DEPDIR:=$(DEPDIR)/Debug
else else
OBJDIR:=$(OBJDIR)/Release OBJDIR:=$(OBJDIR)/Release
BIN:=$(BIN)/Release BIN:=$(BIN)/Release
DEPDIR:=$(DEPDIR)/Release
endif endif
endif endif

View file

@ -624,7 +624,7 @@ static void SV_PrepareSendLuaFileToNextNode(void)
// Find a client to send the file to // Find a client to send the file to
for (i = 1; i < MAXNETNODES; i++) for (i = 1; i < MAXNETNODES; i++)
if (nodeingame[i] && luafiletransfers->nodestatus[i] == LFTNS_WAITING) // Node waiting if (luafiletransfers->nodestatus[i] == LFTNS_WAITING) // Node waiting
{ {
// Tell the client we're about to send them the file // Tell the client we're about to send them the file
netbuffer->packettype = PT_SENDINGLUAFILE; netbuffer->packettype = PT_SENDINGLUAFILE;
@ -632,6 +632,7 @@ static void SV_PrepareSendLuaFileToNextNode(void)
I_Error("Failed to send a PT_SENDINGLUAFILE packet\n"); // !!! Todo: Handle failure a bit better lol I_Error("Failed to send a PT_SENDINGLUAFILE packet\n"); // !!! Todo: Handle failure a bit better lol
luafiletransfers->nodestatus[i] = LFTNS_ASKED; luafiletransfers->nodestatus[i] = LFTNS_ASKED;
luafiletransfers->nodetimeouts[i] = I_GetTime() + 30 * TICRATE;
return; return;
} }
@ -650,7 +651,7 @@ void SV_PrepareSendLuaFile(void)
// Set status to "waiting" for everyone // Set status to "waiting" for everyone
for (i = 0; i < MAXNETNODES; i++) for (i = 0; i < MAXNETNODES; i++)
luafiletransfers->nodestatus[i] = LFTNS_WAITING; luafiletransfers->nodestatus[i] = (nodeingame[i] ? LFTNS_WAITING : LFTNS_NONE);
if (FIL_ReadFileOK(luafiletransfers->realfilename)) if (FIL_ReadFileOK(luafiletransfers->realfilename))
{ {
@ -711,13 +712,15 @@ void RemoveAllLuaFileTransfers(void)
void SV_AbortLuaFileTransfer(INT32 node) void SV_AbortLuaFileTransfer(INT32 node)
{ {
if (luafiletransfers if (luafiletransfers)
&& (luafiletransfers->nodestatus[node] == LFTNS_ASKED {
|| luafiletransfers->nodestatus[node] == LFTNS_SENDING)) if (luafiletransfers->nodestatus[node] == LFTNS_ASKED
|| luafiletransfers->nodestatus[node] == LFTNS_SENDING)
{ {
luafiletransfers->nodestatus[node] = LFTNS_WAITING;
SV_PrepareSendLuaFileToNextNode(); SV_PrepareSendLuaFileToNextNode();
} }
luafiletransfers->nodestatus[node] = LFTNS_NONE;
}
} }
void CL_PrepareDownloadLuaFile(void) void CL_PrepareDownloadLuaFile(void)
@ -990,6 +993,22 @@ void FileSendTicker(void)
filetx_t *f; filetx_t *f;
INT32 packetsent, ram, i, j; INT32 packetsent, ram, i, j;
// If someone is taking too long to download, kick them with a timeout
// to prevent blocking the rest of the server...
if (luafiletransfers)
{
for (i = 1; i < MAXNETNODES; i++)
{
luafiletransfernodestatus_t status = luafiletransfers->nodestatus[i];
if (status != LFTNS_NONE && status != LFTNS_WAITING && status != LFTNS_SENT
&& I_GetTime() > luafiletransfers->nodetimeouts[i])
{
Net_ConnectionTimeout(i);
}
}
}
if (!filestosend) // No file to send if (!filestosend) // No file to send
return; return;

View file

@ -107,6 +107,7 @@ boolean PT_RequestFile(INT32 node);
typedef enum typedef enum
{ {
LFTNS_NONE, // This node is not connected
LFTNS_WAITING, // This node is waiting for the server to send the file 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_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_SENDING, // The server is sending the file to this node
@ -121,6 +122,7 @@ typedef struct luafiletransfer_s
INT32 id; // Callback ID INT32 id; // Callback ID
boolean ongoing; boolean ongoing;
luafiletransfernodestatus_t nodestatus[MAXNETNODES]; luafiletransfernodestatus_t nodestatus[MAXNETNODES];
tic_t nodetimeouts[MAXNETNODES];
struct luafiletransfer_s *next; struct luafiletransfer_s *next;
} luafiletransfer_t; } luafiletransfer_t;

View file

@ -335,18 +335,9 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
if (!(option & V_SCALEPATCHMASK)) if (!(option & V_SCALEPATCHMASK))
{ {
// if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) // if it's meant to cover the whole screen, black out the rest
// cx and cy are possibly *slightly* off from float maths // no the patch is cropped do not do this ever
// This is done before here compared to software because we directly alter cx and cy to centre
if (cx >= -0.1f && cx <= 0.1f && gpatch->width == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && gpatch->height == BASEVIDHEIGHT)
{
const column_t *column = (const column_t *)((const UINT8 *)(gpatch->columns) + (gpatch->columnofs[0]));
if (!column->topdelta)
{
const UINT8 *source = (const UINT8 *)(column) + 3;
HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0]));
}
}
// centre screen // centre screen
if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f)
{ {
@ -368,11 +359,11 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
fwidth = w; fwidth = w;
fheight = h; fheight = h;
if (fwidth > gpatch->width) if (sx + w > gpatch->width)
fwidth = gpatch->width; fwidth = gpatch->width - sx;
if (fheight > gpatch->height) if (sy + h > gpatch->height)
fheight = gpatch->height; fheight = gpatch->height - sy;
if (pscale != FRACUNIT) if (pscale != FRACUNIT)
{ {
@ -404,13 +395,13 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
v[0].s = v[3].s = ((sx)/(float)(gpatch->width))*hwrPatch->max_s; v[0].s = v[3].s = ((sx)/(float)(gpatch->width))*hwrPatch->max_s;
if (sx + w > gpatch->width) if (sx + w > gpatch->width)
v[2].s = v[1].s = hwrPatch->max_s - ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s; v[2].s = v[1].s = hwrPatch->max_s;
else else
v[2].s = v[1].s = ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s; v[2].s = v[1].s = ((sx+w)/(float)(gpatch->width))*hwrPatch->max_s;
v[0].t = v[1].t = ((sy)/(float)(gpatch->height))*hwrPatch->max_t; v[0].t = v[1].t = ((sy)/(float)(gpatch->height))*hwrPatch->max_t;
if (sy + h > gpatch->height) if (sy + h > gpatch->height)
v[2].t = v[3].t = hwrPatch->max_t - ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t; v[2].t = v[3].t = hwrPatch->max_t;
else else
v[2].t = v[3].t = ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t; v[2].t = v[3].t = ((sy+h)/(float)(gpatch->height))*hwrPatch->max_t;

View file

@ -3742,7 +3742,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts, const boolean precip) static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts, const boolean precip)
{ {
if (cv_glspritebillboarding.value if (cv_glspritebillboarding.value
&& spr && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE) && spr && spr->mobj && !R_ThingIsPaperSprite(spr->mobj)
&& wallVerts) && wallVerts)
{ {
float basey = FIXED_TO_FLOAT(spr->mobj->z); float basey = FIXED_TO_FLOAT(spr->mobj->z);
@ -3784,7 +3784,6 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
FBITFIELD blend = 0; FBITFIELD blend = 0;
FBITFIELD occlusion; FBITFIELD occlusion;
boolean use_linkdraw_hack = false; boolean use_linkdraw_hack = false;
boolean splat = R_ThingIsFloorSprite(spr->mobj);
UINT8 alpha; UINT8 alpha;
INT32 i; INT32 i;
@ -3843,8 +3842,6 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
baseWallVerts[0].t = baseWallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t; baseWallVerts[0].t = baseWallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t;
} }
if (!splat)
{
// if it has a dispoffset, push it a little towards the camera // if it has a dispoffset, push it a little towards the camera
if (spr->dispoffset) { if (spr->dispoffset) {
float co = -gl_viewcos*(0.05f*spr->dispoffset); float co = -gl_viewcos*(0.05f*spr->dispoffset);
@ -3857,7 +3854,6 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
// Let dispoffset work first since this adjust each vertex // Let dispoffset work first since this adjust each vertex
HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); HWR_RotateSpritePolyToAim(spr, baseWallVerts, false);
}
realtop = top = baseWallVerts[3].y; realtop = top = baseWallVerts[3].y;
realbot = bot = baseWallVerts[0].y; realbot = bot = baseWallVerts[0].y;
@ -3994,7 +3990,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
// The x and y only need to be adjusted in the case that it's not a papersprite // The x and y only need to be adjusted in the case that it's not a papersprite
if (cv_glspritebillboarding.value if (cv_glspritebillboarding.value
&& spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE)) && spr->mobj && !R_ThingIsPaperSprite(spr->mobj))
{ {
// Get the x and z of the vertices so billboarding draws correctly // Get the x and z of the vertices so billboarding draws correctly
realheight = realbot - realtop; realheight = realbot - realtop;
@ -4063,7 +4059,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
static void HWR_DrawSprite(gl_vissprite_t *spr) static void HWR_DrawSprite(gl_vissprite_t *spr)
{ {
FOutVector wallVerts[4]; FOutVector wallVerts[4];
patch_t *gpatch; // sprite patch converted to hardware patch_t *gpatch;
FSurfaceInfo Surf; FSurfaceInfo Surf;
const boolean splat = R_ThingIsFloorSprite(spr->mobj); const boolean splat = R_ThingIsFloorSprite(spr->mobj);
@ -4367,7 +4363,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
{ {
FBITFIELD blend = 0; FBITFIELD blend = 0;
FOutVector wallVerts[4]; FOutVector wallVerts[4];
patch_t *gpatch; // sprite patch converted to hardware patch_t *gpatch;
FSurfaceInfo Surf; FSurfaceInfo Surf;
if (!spr->mobj) if (!spr->mobj)
@ -4420,14 +4416,16 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
// Always use the light at the top instead of whatever I was doing before // Always use the light at the top instead of whatever I was doing before
INT32 light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); INT32 light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false);
lightlevel = *sector->lightlist[light].lightlevel; if (!R_ThingIsFullBright(spr->mobj))
lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel;
if (*sector->lightlist[light].extra_colormap) if (*sector->lightlist[light].extra_colormap)
colormap = *sector->lightlist[light].extra_colormap; colormap = *sector->lightlist[light].extra_colormap;
} }
else else
{ {
lightlevel = sector->lightlevel; if (!R_ThingIsFullBright(spr->mobj))
lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel;
if (sector->extra_colormap) if (sector->extra_colormap)
colormap = sector->extra_colormap; colormap = sector->extra_colormap;
@ -5044,8 +5042,8 @@ static void HWR_ProjectSprite(mobj_t *thing)
angle_t ang; angle_t ang;
INT32 heightsec, phs; INT32 heightsec, phs;
const boolean papersprite = R_ThingIsPaperSprite(thing);
const boolean splat = R_ThingIsFloorSprite(thing); const boolean splat = R_ThingIsFloorSprite(thing);
const boolean papersprite = (R_ThingIsPaperSprite(thing) && !splat);
angle_t mobjangle = (thing->player ? thing->player->drawangle : thing->angle); angle_t mobjangle = (thing->player ? thing->player->drawangle : thing->angle);
float z1, z2; float z1, z2;

View file

@ -1326,14 +1326,16 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before
lightlevel = *sector->lightlist[light].lightlevel; if (!R_ThingIsFullBright(spr->mobj))
lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel;
if (*sector->lightlist[light].extra_colormap) if (*sector->lightlist[light].extra_colormap)
colormap = *sector->lightlist[light].extra_colormap; colormap = *sector->lightlist[light].extra_colormap;
} }
else else
{ {
lightlevel = sector->lightlevel; if (!R_ThingIsFullBright(spr->mobj))
lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel;
if (sector->extra_colormap) if (sector->extra_colormap)
colormap = sector->extra_colormap; colormap = sector->extra_colormap;
@ -1356,10 +1358,9 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL;
INT32 durs = spr->mobj->state->tics; INT32 durs = spr->mobj->state->tics;
INT32 tics = spr->mobj->tics; INT32 tics = spr->mobj->tics;
//mdlframe_t *next = NULL; const boolean papersprite = (R_ThingIsPaperSprite(spr->mobj) && !R_ThingIsFloorSprite(spr->mobj));
const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(spr->mobj));
const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !(spr->mobj->frame & FF_VERTICALFLIP)); const UINT8 hflip = (UINT8)(!(spr->mobj->mirrored) != !R_ThingHorizontallyFlipped(spr->mobj));
const UINT8 hflip = (UINT8)(!(spr->mobj->mirrored) != !(spr->mobj->frame & FF_HORIZONTALFLIP));
spritedef_t *sprdef; spritedef_t *sprdef;
spriteframe_t *sprframe; spriteframe_t *sprframe;
INT32 mod; INT32 mod;
@ -1444,6 +1445,11 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|| ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile))) || ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile)))
md2_loadBlendTexture(md2); md2_loadBlendTexture(md2);
// Load it again, because it isn't being loaded into blendgpatch after md2_loadblendtexture...
blendgpatch = md2->blendgrpatch;
if (blendgpatch)
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
if (md2->error) if (md2->error)
return false; // we already failed loading this before :( return false; // we already failed loading this before :(
if (!md2->model) if (!md2->model)

View file

@ -993,8 +993,6 @@ EXPORT boolean HWRAPI(CompileShaders) (void)
} }
} }
SetShader(SHADER_DEFAULT);
return true; return true;
#else #else
return false; return false;

View file

@ -1388,6 +1388,26 @@ static int lib_pSwitchShield(lua_State *L)
return 0; return 0;
} }
static int lib_pPlayerCanEnterSpinGaps(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
lua_pushboolean(L, P_PlayerCanEnterSpinGaps(player));
return 1;
}
static int lib_pPlayerShouldUseSpinHeight(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
lua_pushboolean(L, P_PlayerShouldUseSpinHeight(player));
return 1;
}
// P_MAP // P_MAP
/////////// ///////////
@ -3859,6 +3879,8 @@ static luaL_Reg lib[] = {
{"P_ReturnThrustY",lib_pReturnThrustY}, {"P_ReturnThrustY",lib_pReturnThrustY},
{"P_NukeEnemies",lib_pNukeEnemies}, {"P_NukeEnemies",lib_pNukeEnemies},
{"P_SwitchShield",lib_pSwitchShield}, {"P_SwitchShield",lib_pSwitchShield},
{"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps},
{"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight},
// p_map // p_map
{"P_CheckPosition",lib_pCheckPosition}, {"P_CheckPosition",lib_pCheckPosition},

View file

@ -59,6 +59,8 @@ enum hook {
hook_ShouldJingleContinue, hook_ShouldJingleContinue,
hook_GameQuit, hook_GameQuit,
hook_PlayerCmd, hook_PlayerCmd,
hook_PlayerHeight,
hook_PlayerCanEnterSpinGaps,
// SRB2Kart // SRB2Kart
hook_IntermissionThinker, hook_IntermissionThinker,
@ -125,3 +127,5 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean
#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 boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing
void LUAh_GameQuit(boolean quitting); // Hook for game quitting void LUAh_GameQuit(boolean quitting); // Hook for game quitting
fixed_t LUAh_PlayerHeight(player_t *player);
UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player);

View file

@ -75,6 +75,8 @@ const char *const hookNames[hook_MAX+1] = {
"ShouldJingleContinue", "ShouldJingleContinue",
"GameQuit", "GameQuit",
"PlayerCmd", "PlayerCmd",
"PlayerHeight",
"PlayerCanEnterSpinGaps",
// SRB2Kart // SRB2Kart
"IntermissionThinker", "IntermissionThinker",
@ -223,6 +225,8 @@ static int lib_addHook(lua_State *L)
case hook_ShieldSpawn: case hook_ShieldSpawn:
case hook_ShieldSpecial: case hook_ShieldSpecial:
case hook_PlayerThink: case hook_PlayerThink:
case hook_PlayerHeight:
case hook_PlayerCanEnterSpinGaps:
lastp = &playerhooks; lastp = &playerhooks;
break; break;
case hook_LinedefExecute: case hook_LinedefExecute:
@ -1875,6 +1879,92 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo
return hooked; return hooked;
} }
// Hook for determining player height
fixed_t LUAh_PlayerHeight(player_t *player)
{
hook_p hookp;
fixed_t newheight = -1;
if (!gL || !(hooksAvailable[hook_PlayerHeight/8] & (1<<(hook_PlayerHeight%8))))
return newheight;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
for (hookp = playerhooks; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PlayerHeight)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
LUA_PushUserdata(gL, player, META_PLAYER);
PushHook(gL, hookp);
lua_pushvalue(gL, -2);
if (lua_pcall(gL, 1, 1, 1)) {
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))
{
fixed_t returnedheight = lua_tonumber(gL, -1);
// 0 height has... strange results, but it's not problematic like negative heights are.
// when an object's height is set to a negative number directly with lua, it's forced to 0 instead.
// here, I think it's better to ignore negatives so that they don't replace any results of previous hooks!
if (returnedheight >= 0)
newheight = returnedheight;
}
lua_pop(gL, 1);
}
lua_settop(gL, 0);
return newheight;
}
// Hook for determining whether players are allowed passage through spin gaps
UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player)
{
hook_p hookp;
UINT8 canEnter = 0; // 0 = default, 1 = force yes, 2 = force no.
if (!gL || !(hooksAvailable[hook_PlayerCanEnterSpinGaps/8] & (1<<(hook_PlayerCanEnterSpinGaps%8))))
return 0;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
for (hookp = playerhooks; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PlayerCanEnterSpinGaps)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
LUA_PushUserdata(gL, player, META_PLAYER);
PushHook(gL, hookp);
lua_pushvalue(gL, -2);
if (lua_pcall(gL, 1, 1, 1)) {
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))
{ // if nil, leave canEnter = 0.
if (lua_toboolean(gL, -1))
canEnter = 1; // Force yes
else
canEnter = 2; // Force no
}
lua_pop(gL, 1);
}
lua_settop(gL, 0);
return canEnter;
}
// Hook for Y_VoteTicker // Hook for Y_VoteTicker
void LUAh_VoteThinker(void) void LUAh_VoteThinker(void)
{ {

View file

@ -585,7 +585,7 @@ static int sector_get(lua_State *L)
lua_pushinteger(L, sector->special); lua_pushinteger(L, sector->special);
return 1; return 1;
case sector_tag: case sector_tag:
lua_pushinteger(L, Tag_FGet(&sector->tags)); lua_pushinteger(L, (UINT16)Tag_FGet(&sector->tags));
return 1; return 1;
case sector_taglist: case sector_taglist:
LUA_PushUserdata(L, &sector->tags, META_SECTORTAGLIST); LUA_PushUserdata(L, &sector->tags, META_SECTORTAGLIST);
@ -830,6 +830,17 @@ static int line_get(lua_State *L)
lua_pushinteger(L, line->special); lua_pushinteger(L, line->special);
return 1; return 1;
case line_tag: case line_tag:
// HELLO
// THIS IS LJ SONIC
// HOW IS YOUR DAY?
// BY THE WAY WHEN 2.3 OR 3.0 OR 4.0 OR SRB3 OR SRB4 OR WHATEVER IS OUT
// YOU SHOULD REMEMBER TO CHANGE THIS SO IT ALWAYS RETURNS A UNSIGNED VALUE
// HAVE A NICE DAY
//
//
//
//
// you are ugly
lua_pushinteger(L, Tag_FGet(&line->tags)); lua_pushinteger(L, Tag_FGet(&line->tags));
return 1; return 1;
case line_taglist: case line_taglist:

View file

@ -165,7 +165,9 @@ consvar_t cv_zlib_window_bitsa = CVAR_INIT ("apng_window_size", "32k", CV_SAVE,
consvar_t cv_apng_delay = CVAR_INIT ("apng_speed", "1x", CV_SAVE, apng_delay_t, NULL); consvar_t cv_apng_delay = CVAR_INIT ("apng_speed", "1x", CV_SAVE, apng_delay_t, NULL);
consvar_t cv_apng_downscale = CVAR_INIT ("apng_downscale", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_apng_downscale = CVAR_INIT ("apng_downscale", "On", CV_SAVE, CV_OnOff, NULL);
#ifdef USE_APNG
static boolean apng_downscale = false; // So nobody can do something dumb like changing cvars mid output static boolean apng_downscale = false; // So nobody can do something dumb like changing cvars mid output
#endif
boolean takescreenshot = false; // Take a screenshot this tic boolean takescreenshot = false; // Take a screenshot this tic

View file

@ -1659,7 +1659,7 @@ void A_SnailerThink(mobj_t *actor)
fixed_t dist; fixed_t dist;
fixed_t dx, dy; fixed_t dx, dy;
dist = R_PointToDist2(0, 0, actor->x - actor->target->x, actor->y - actor->target->y); dist = P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y);
if (an > ANGLE_45 && an <= ANGLE_90) // fire at 45 degrees to the left if (an > ANGLE_45 && an <= ANGLE_90) // fire at 45 degrees to the left
{ {
@ -8903,21 +8903,22 @@ void A_Custom3DRotate(mobj_t *actor)
if (LUA_CallAction(A_CUSTOM3DROTATE, actor)) if (LUA_CallAction(A_CUSTOM3DROTATE, actor))
return; return;
if (!actor->target) // Ensure we actually have a target first.
{
CONS_Printf("Error: A_Custom3DRotate: Object has no target.\n");
P_RemoveMobj(actor);
return;
}
if (actor->target->health == 0) if (actor->target->health == 0)
{ {
P_RemoveMobj(actor); P_RemoveMobj(actor);
return; return;
} }
if (!actor->target) // This should NEVER happen.
{
if (cv_debug)
CONS_Printf("Error: Object has no target\n");
P_RemoveMobj(actor);
return;
}
if (hspeed==0 && vspeed==0) if (hspeed==0 && vspeed==0)
{ {
if (cv_debug)
CONS_Printf("Error: A_Custom3DRotate: Object has no speed.\n"); CONS_Printf("Error: A_Custom3DRotate: Object has no speed.\n");
return; return;
} }

View file

@ -157,6 +157,8 @@ void P_SetPlayerAngle(player_t *player, angle_t angle);
angle_t P_GetLocalAngle(player_t *player); angle_t P_GetLocalAngle(player_t *player);
void P_ForceLocalAngle(player_t *player, angle_t angle); void P_ForceLocalAngle(player_t *player, angle_t angle);
boolean P_PlayerFullbright(player_t *player); boolean P_PlayerFullbright(player_t *player);
boolean P_PlayerCanEnterSpinGaps(player_t *player);
boolean P_PlayerShouldUseSpinHeight(player_t *player);
boolean P_IsObjectInGoop(mobj_t *mo); boolean P_IsObjectInGoop(mobj_t *mo);
boolean P_IsObjectOnGround(mobj_t *mo); boolean P_IsObjectOnGround(mobj_t *mo);

View file

@ -2479,7 +2479,10 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
if (thing->type == MT_SKIM) if (thing->type == MT_SKIM)
maxstep = 0; maxstep = 0;
if (tmceilingz - tmfloorz < thing->height) if (tmceilingz - tmfloorz < thing->height
|| (thing->player
&& tmceilingz - tmfloorz < P_GetPlayerHeight(thing->player)
&& !P_PlayerCanEnterSpinGaps(thing->player)))
{ {
if (tmfloorthing) if (tmfloorthing)
tmhitthing = tmfloorthing; tmhitthing = tmfloorthing;
@ -3136,6 +3139,11 @@ static boolean PTR_LineIsBlocking(line_t *li)
if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, mapobjectscale)) if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, mapobjectscale))
return true; // too big a step up return true; // too big a step up
if (slidemo->player
&& openrange < P_GetPlayerHeight(slidemo->player)
&& !P_PlayerCanEnterSpinGaps(slidemo->player))
return true; // nonspin character should not take this path
return false; return false;
} }

View file

@ -4030,7 +4030,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
#ifdef HWRENDER #ifdef HWRENDER
// Free GPU textures before freeing patches. // Free GPU textures before freeing patches.
if (vid.glstate == VID_GL_LIBRARY_LOADED) if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED))
HWR_ClearAllTextures(); HWR_ClearAllTextures();
#endif #endif
@ -4457,7 +4457,7 @@ boolean P_AddWadFile(const char *wadfilename)
#ifdef HWRENDER #ifdef HWRENDER
// Free GPU textures before freeing patches. // Free GPU textures before freeing patches.
if (vid.glstate == VID_GL_LIBRARY_LOADED) if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED))
HWR_ClearAllTextures(); HWR_ClearAllTextures();
#endif #endif

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -30,10 +30,6 @@
#include "byteptr.h" #include "byteptr.h"
#include "dehacked.h" #include "dehacked.h"
#ifdef _WIN32
#include <malloc.h> // alloca(sizeof)
#endif
// //
// Graphics. // Graphics.
// SRB2 graphics for walls and sprites // SRB2 graphics for walls and sprites

View file

@ -149,6 +149,40 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask;
static UINT8 **translationtablecache[TT_CACHE_SIZE] = {NULL}; static UINT8 **translationtablecache[TT_CACHE_SIZE] = {NULL};
UINT8 skincolor_modified[MAXSKINCOLORS]; UINT8 skincolor_modified[MAXSKINCOLORS];
static INT32 SkinToCacheIndex(INT32 skinnum)
{
switch (skinnum)
{
case TC_DEFAULT: return DEFAULT_TT_CACHE_INDEX;
case TC_BOSS: return BOSS_TT_CACHE_INDEX;
case TC_METALSONIC: return METALSONIC_TT_CACHE_INDEX;
case TC_ALLWHITE: return ALLWHITE_TT_CACHE_INDEX;
case TC_RAINBOW: return RAINBOW_TT_CACHE_INDEX;
case TC_BLINK: return BLINK_TT_CACHE_INDEX;
case TC_DASHMODE: return DASHMODE_TT_CACHE_INDEX;
default: break;
}
return skinnum;
}
static INT32 CacheIndexToSkin(INT32 ttc)
{
switch (ttc)
{
case DEFAULT_TT_CACHE_INDEX: return TC_DEFAULT;
case BOSS_TT_CACHE_INDEX: return TC_BOSS;
case METALSONIC_TT_CACHE_INDEX: return TC_METALSONIC;
case ALLWHITE_TT_CACHE_INDEX: return TC_ALLWHITE;
case RAINBOW_TT_CACHE_INDEX: return TC_RAINBOW;
case BLINK_TT_CACHE_INDEX: return TC_BLINK;
case DASHMODE_TT_CACHE_INDEX: return TC_DASHMODE;
default: break;
}
return ttc;
}
CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1];
CV_PossibleValue_t Followercolor_cons_t[MAXSKINCOLORS+3]; // +3 to account for "Match", "Opposite" & NULL CV_PossibleValue_t Followercolor_cons_t[MAXSKINCOLORS+3]; // +3 to account for "Match", "Opposite" & NULL
@ -273,25 +307,11 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel)
UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags) UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags)
{ {
UINT8* ret; UINT8* ret;
INT32 skintableindex; INT32 skintableindex = SkinToCacheIndex(skinnum); // Adjust if we want the default colormap
INT32 i; INT32 i;
// Adjust if we want the default colormap
switch (skinnum)
{
case TC_DEFAULT: skintableindex = DEFAULT_TT_CACHE_INDEX; break;
case TC_BOSS: skintableindex = BOSS_TT_CACHE_INDEX; break;
case TC_METALSONIC: skintableindex = METALSONIC_TT_CACHE_INDEX; break;
case TC_ALLWHITE: skintableindex = ALLWHITE_TT_CACHE_INDEX; break;
case TC_RAINBOW: skintableindex = RAINBOW_TT_CACHE_INDEX; break;
case TC_BLINK: skintableindex = BLINK_TT_CACHE_INDEX; break;
case TC_DASHMODE: skintableindex = DASHMODE_TT_CACHE_INDEX; break;
default: skintableindex = skinnum; break;
}
if (flags & GTC_CACHE) if (flags & GTC_CACHE)
{ {
// Allocate table for skin if necessary // Allocate table for skin if necessary
if (!translationtablecache[skintableindex]) if (!translationtablecache[skintableindex])
translationtablecache[skintableindex] = Z_Calloc(MAXSKINCOLORS * sizeof(UINT8**), PU_STATIC, NULL); translationtablecache[skintableindex] = Z_Calloc(MAXSKINCOLORS * sizeof(UINT8**), PU_STATIC, NULL);
@ -304,7 +324,7 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags
{ {
for (i = 0; i < (INT32)(sizeof(translationtablecache) / sizeof(translationtablecache[0])); i++) for (i = 0; i < (INT32)(sizeof(translationtablecache) / sizeof(translationtablecache[0])); i++)
if (translationtablecache[i] && translationtablecache[i][color]) if (translationtablecache[i] && translationtablecache[i][color])
K_GenerateKartColormap(translationtablecache[i][color], i>=MAXSKINS ? MAXSKINS-i-1 : i, color); K_GenerateKartColormap(translationtablecache[i][color], CacheIndexToSkin(i), color);
skincolor_modified[color] = false; skincolor_modified[color] = false;
} }
} }

View file

@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -1447,10 +1447,7 @@ void R_DrawFloorSprite_8 (void)
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
// have the uber complicated math to calculate it now, so that was a memory write we didn't // have the uber complicated math to calculate it now, so that was a memory write we didn't
// need! // need!
//
// <Callum> 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size)
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[0] = colormap[translation[val & 0xFF]]; dest[0] = colormap[translation[val & 0xFF]];
@ -1458,7 +1455,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[1] = colormap[translation[val & 0xFF]]; dest[1] = colormap[translation[val & 0xFF]];
@ -1466,7 +1462,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[2] = colormap[translation[val & 0xFF]]; dest[2] = colormap[translation[val & 0xFF]];
@ -1474,7 +1469,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[3] = colormap[translation[val & 0xFF]]; dest[3] = colormap[translation[val & 0xFF]];
@ -1482,7 +1476,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[4] = colormap[translation[val & 0xFF]]; dest[4] = colormap[translation[val & 0xFF]];
@ -1490,7 +1483,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[5] = colormap[translation[val & 0xFF]]; dest[5] = colormap[translation[val & 0xFF]];
@ -1498,7 +1490,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[6] = colormap[translation[val & 0xFF]]; dest[6] = colormap[translation[val & 0xFF]];
@ -1506,7 +1497,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[7] = colormap[translation[val & 0xFF]]; dest[7] = colormap[translation[val & 0xFF]];

View file

@ -1158,8 +1158,6 @@ subsector_t *R_PointInSubsectorOrNull(fixed_t x, fixed_t y)
// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) // 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out)
static void R_SetupFreelook(player_t *player, boolean skybox) static void R_SetupFreelook(player_t *player, boolean skybox)
{ {
INT32 dy = 0;
#ifndef HWRENDER #ifndef HWRENDER
(void)player; (void)player;
(void)skybox; (void)skybox;
@ -1178,14 +1176,15 @@ static void R_SetupFreelook(player_t *player, boolean skybox)
G_SoftwareClipAimingPitch((INT32 *)&aimingangle); G_SoftwareClipAimingPitch((INT32 *)&aimingangle);
} }
if (rendermode == render_soft) centeryfrac = (viewheight/2)<<FRACBITS;
{
dy = (AIMINGTODY(aimingangle)>>FRACBITS) * viewwidth/BASEVIDWIDTH;
yslope = &yslopetab[viewssnum][viewheight*8 - (viewheight/2 + dy)];
}
centery = (viewheight/2) + dy; if (rendermode == render_soft)
centeryfrac = centery<<FRACBITS; centeryfrac += FixedMul(AIMINGTODY(aimingangle), FixedDiv(viewwidth<<FRACBITS, BASEVIDWIDTH<<FRACBITS));
centery = FixedInt(FixedRound(centeryfrac));
if (rendermode == render_soft)
yslope = &yslopetab[viewssnum][viewheight*8 - centery];
} }
void R_SetupFrame(player_t *player) void R_SetupFrame(player_t *player)

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -154,14 +154,10 @@ static void R_UpdatePlaneRipple(void)
// R_MapPlane // R_MapPlane
// //
// Uses global vars: // Uses global vars:
// planeheight
// basexscale // basexscale
// baseyscale // baseyscale
// centerx // centerx
// viewx
// viewy
// viewsin
// viewcos
// viewheight
void R_MapPlane(INT32 y, INT32 x1, INT32 x2) void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
{ {
@ -590,7 +586,7 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop)
// //
void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2)
{ {
// Alam: from r_splats's R_RenderFloorSplat // Alam: from r_splats's R_RasterizeFloorSplat
if (t1 >= vid.height) t1 = vid.height-1; if (t1 >= vid.height) t1 = vid.height-1;
if (b1 >= vid.height) b1 = vid.height-1; if (b1 >= vid.height) b1 = vid.height-1;
if (t2 >= vid.height) t2 = vid.height-1; if (t2 >= vid.height) t2 = vid.height-1;
@ -617,7 +613,6 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2)
void R_DrawPlanes(void) void R_DrawPlanes(void)
{ {
visplane_t *pl; visplane_t *pl;
angle_t va = viewangle;
INT32 i; INT32 i;
R_UpdatePlaneRipple(); R_UpdatePlaneRipple();
@ -632,8 +627,6 @@ void R_DrawPlanes(void)
R_DrawSinglePlane(pl); R_DrawSinglePlane(pl);
} }
} }
viewangle = va;
} }
// R_DrawSkyPlane // R_DrawSkyPlane

View file

@ -1674,23 +1674,26 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// left // left
temp = xtoviewangle[viewssnum][start]+viewangle; temp = xtoviewangle[viewssnum][start]+viewangle;
#define FIXED_TO_DOUBLE(x) (((double)(x)) / ((double)FRACUNIT))
#define DOUBLE_TO_FIXED(x) (fixed_t)((x) * ((double)FRACUNIT))
{ {
// Both lines can be written in slope-intercept form, so figure out line intersection // Both lines can be written in slope-intercept form, so figure out line intersection
float a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector... double a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector...
///TODO: convert to FPU ///TODO: convert to fixed point
a1 = FIXED_TO_FLOAT(curline->v2->y-curline->v1->y); a1 = FIXED_TO_DOUBLE(curline->v2->y-curline->v1->y);
b1 = FIXED_TO_FLOAT(curline->v1->x-curline->v2->x); b1 = FIXED_TO_DOUBLE(curline->v1->x-curline->v2->x);
c1 = a1*FIXED_TO_FLOAT(curline->v1->x) + b1*FIXED_TO_FLOAT(curline->v1->y); c1 = a1*FIXED_TO_DOUBLE(curline->v1->x) + b1*FIXED_TO_DOUBLE(curline->v1->y);
a2 = -FIXED_TO_FLOAT(FINESINE(temp>>ANGLETOFINESHIFT)); a2 = -FIXED_TO_DOUBLE(FINESINE(temp>>ANGLETOFINESHIFT));
b2 = FIXED_TO_FLOAT(FINECOSINE(temp>>ANGLETOFINESHIFT)); b2 = FIXED_TO_DOUBLE(FINECOSINE(temp>>ANGLETOFINESHIFT));
c2 = a2*FIXED_TO_FLOAT(viewx) + b2*FIXED_TO_FLOAT(viewy); c2 = a2*FIXED_TO_DOUBLE(viewx) + b2*FIXED_TO_DOUBLE(viewy);
det = a1*b2 - a2*b1; det = a1*b2 - a2*b1;
ds_p->leftpos.x = segleft.x = FLOAT_TO_FIXED((b2*c1 - b1*c2)/det); ds_p->leftpos.x = segleft.x = DOUBLE_TO_FIXED((b2*c1 - b1*c2)/det);
ds_p->leftpos.y = segleft.y = FLOAT_TO_FIXED((a1*c2 - a2*c1)/det); ds_p->leftpos.y = segleft.y = DOUBLE_TO_FIXED((a1*c2 - a2*c1)/det);
} }
// right // right
@ -1698,22 +1701,26 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{ {
// Both lines can be written in slope-intercept form, so figure out line intersection // Both lines can be written in slope-intercept form, so figure out line intersection
float a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector... double a1, b1, c1, a2, b2, c2, det; // 1 is the seg, 2 is the view angle vector...
///TODO: convert to FPU ///TODO: convert to fixed point
a1 = FIXED_TO_FLOAT(curline->v2->y-curline->v1->y); a1 = FIXED_TO_DOUBLE(curline->v2->y-curline->v1->y);
b1 = FIXED_TO_FLOAT(curline->v1->x-curline->v2->x); b1 = FIXED_TO_DOUBLE(curline->v1->x-curline->v2->x);
c1 = a1*FIXED_TO_FLOAT(curline->v1->x) + b1*FIXED_TO_FLOAT(curline->v1->y); c1 = a1*FIXED_TO_DOUBLE(curline->v1->x) + b1*FIXED_TO_DOUBLE(curline->v1->y);
a2 = -FIXED_TO_FLOAT(FINESINE(temp>>ANGLETOFINESHIFT)); a2 = -FIXED_TO_DOUBLE(FINESINE(temp>>ANGLETOFINESHIFT));
b2 = FIXED_TO_FLOAT(FINECOSINE(temp>>ANGLETOFINESHIFT)); b2 = FIXED_TO_DOUBLE(FINECOSINE(temp>>ANGLETOFINESHIFT));
c2 = a2*FIXED_TO_FLOAT(viewx) + b2*FIXED_TO_FLOAT(viewy); c2 = a2*FIXED_TO_DOUBLE(viewx) + b2*FIXED_TO_DOUBLE(viewy);
det = a1*b2 - a2*b1; det = a1*b2 - a2*b1;
ds_p->rightpos.x = segright.x = FLOAT_TO_FIXED((b2*c1 - b1*c2)/det); ds_p->rightpos.x = segright.x = DOUBLE_TO_FIXED((b2*c1 - b1*c2)/det);
ds_p->rightpos.y = segright.y = FLOAT_TO_FIXED((a1*c2 - a2*c1)/det); ds_p->rightpos.y = segright.y = DOUBLE_TO_FIXED((a1*c2 - a2*c1)/det);
} }
#undef FIXED_TO_DOUBLE
#undef DOUBLE_TO_FIXED
} }

View file

@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -28,11 +28,12 @@ static void prepare_rastertab(void);
// FLOOR SPLATS // FLOOR SPLATS
// ========================================================================== // ==========================================================================
static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis);
#ifdef USEASM #ifdef USEASM
void ASMCALL rasterize_segment_tex_asm(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir); void ASMCALL rasterize_segment_tex_asm(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir);
#endif #endif
// Lactozilla
static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir) static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir)
{ {
#ifdef USEASM #ifdef USEASM
@ -137,7 +138,7 @@ static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32
} }
} }
void R_DrawFloorSprite(vissprite_t *spr) void R_DrawFloorSplat(vissprite_t *spr)
{ {
floorsplat_t splat; floorsplat_t splat;
mobj_t *mobj = spr->mobj; mobj_t *mobj = spr->mobj;
@ -187,7 +188,7 @@ void R_DrawFloorSprite(vissprite_t *spr)
if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD) if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD)
splatangle = mobj->angle; splatangle = mobj->angle;
else else
splatangle = viewangle; splatangle = spr->viewangle;
if (!(spr->cut & SC_ISROTATED)) if (!(spr->cut & SC_ISROTATED))
splatangle += mobj->rollangle; splatangle += mobj->rollangle;
@ -265,7 +266,6 @@ void R_DrawFloorSprite(vissprite_t *spr)
if (splat.tilted) if (splat.tilted)
{ {
// Lactozilla: Just copy the entire slope LMFAOOOO
pslope_t *s = &splat.slope; pslope_t *s = &splat.slope;
s->o.x = slope->o.x; s->o.x = slope->o.x;
@ -330,7 +330,7 @@ void R_DrawFloorSprite(vissprite_t *spr)
v2d[i].y = (centeryfrac + FixedMul(rot_z, yscale))>>FRACBITS; v2d[i].y = (centeryfrac + FixedMul(rot_z, yscale))>>FRACBITS;
} }
R_RenderFloorSplat(&splat, v2d, spr); R_RasterizeFloorSplat(&splat, v2d, spr);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -338,7 +338,7 @@ void R_DrawFloorSprite(vissprite_t *spr)
// fill the polygon with linear interpolation, call span drawer for each // fill the polygon with linear interpolation, call span drawer for each
// scan line // scan line
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis) static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis)
{ {
// rasterizing // rasterizing
INT32 miny = viewheight + 1, maxy = 0; INT32 miny = viewheight + 1, maxy = 0;
@ -416,11 +416,10 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis
if (R_CheckPowersOfTwo()) if (R_CheckPowersOfTwo())
R_CheckFlatLength(ds_flatwidth * ds_flatheight); R_CheckFlatLength(ds_flatwidth * ds_flatheight);
// Lactozilla: I don't know what I'm doing
if (pSplat->tilted) if (pSplat->tilted)
{ {
R_SetTiltedSpan(0); R_SetTiltedSpan(0);
R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, viewangle, pSplat->angle, 1.0f); R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewangle, pSplat->angle, 1.0f);
spanfunctype = SPANDRAWFUNC_TILTEDSPRITE; spanfunctype = SPANDRAWFUNC_TILTEDSPRITE;
} }
else else
@ -533,7 +532,7 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis
fixed_t xstep, ystep; fixed_t xstep, ystep;
fixed_t distance, span; fixed_t distance, span;
angle_t angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT; angle_t angle = (vis->viewangle + pSplat->angle)>>ANGLETOFINESHIFT;
angle_t planecos = FINECOSINE(angle); angle_t planecos = FINECOSINE(angle);
angle_t planesin = FINESINE(angle); angle_t planesin = FINESINE(angle);
@ -543,17 +542,13 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis
distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]); distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]);
span = abs(centery - y); span = abs(centery - y);
if (span) // don't divide by zero if (span) // Don't divide by zero
{ {
xstep = FixedMul(planesin, planeheight) / span; xstep = FixedMul(planesin, planeheight) / span;
ystep = FixedMul(planecos, planeheight) / span; ystep = FixedMul(planecos, planeheight) / span;
} }
else else
{ xstep = ystep = FRACUNIT;
// ah
xstep = FRACUNIT;
ystep = FRACUNIT;
}
cachedxstep[y] = xstep; cachedxstep[y] = xstep;
cachedystep[y] = ystep; cachedystep[y] = ystep;

View file

@ -42,7 +42,6 @@ typedef struct floorsplat_s
mobj_t *mobj; // Mobj it is tied to mobj_t *mobj; // Mobj it is tied to
} floorsplat_t; } floorsplat_t;
void R_DrawFloorSprite(vissprite_t *spr); void R_DrawFloorSplat(vissprite_t *spr);
void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis);
#endif /*__R_SPLATS_H__*/ #endif /*__R_SPLATS_H__*/

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -28,11 +28,6 @@
#include "byteptr.h" #include "byteptr.h"
#include "dehacked.h" #include "dehacked.h"
// I don't know what this is even for, but r_data.c had it.
#ifdef _WIN32
#include <malloc.h> // alloca(sizeof)
#endif
#ifdef HWRENDER #ifdef HWRENDER
#include "hardware/hw_glob.h" // HWR_LoadMapTextures #include "hardware/hw_glob.h" // HWR_LoadMapTextures
#endif #endif
@ -626,7 +621,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
// //
// R_CheckPowersOfTwo // R_CheckPowersOfTwo
// //
// Self-explanatory? // Sets ds_powersoftwo true if the flat's dimensions are powers of two, and returns that.
// //
boolean R_CheckPowersOfTwo(void) boolean R_CheckPowersOfTwo(void)
{ {

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior. // Copyright (C) 1999-2021 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -779,7 +779,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
INT32 pwidth; INT32 pwidth;
fixed_t frac; fixed_t frac;
patch_t *patch = vis->patch; patch_t *patch = vis->patch;
fixed_t this_scale = vis->mobj->scale; fixed_t this_scale = vis->thingscale;
INT32 x1, x2; INT32 x1, x2;
INT64 overflow_test; INT64 overflow_test;
@ -1304,6 +1304,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000 shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000
shadow->scale = FixedMul(yscale, shadowyscale); shadow->scale = FixedMul(yscale, shadowyscale);
shadow->thingscale = thing->scale;
shadow->sector = vis->sector; shadow->sector = vis->sector;
shadow->szt = (INT16)((centeryfrac - FixedMul(shadow->gzt - viewz, yscale))>>FRACBITS); shadow->szt = (INT16)((centeryfrac - FixedMul(shadow->gzt - viewz, yscale))>>FRACBITS);
shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS); shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS);
@ -1405,7 +1406,6 @@ static void R_ProjectSprite(mobj_t *thing)
fixed_t sheartan = 0; fixed_t sheartan = 0;
fixed_t shadowscale = FRACUNIT; fixed_t shadowscale = FRACUNIT;
fixed_t basetx, basetz; // drop shadows fixed_t basetx, basetz; // drop shadows
boolean shadowdraw, shadoweffects, shadowskew; boolean shadowdraw, shadoweffects, shadowskew;
@ -1942,6 +1942,7 @@ static void R_ProjectSprite(mobj_t *thing)
vis->paperoffset = paperoffset; vis->paperoffset = paperoffset;
vis->paperdistance = paperdistance; vis->paperdistance = paperdistance;
vis->centerangle = centerangle; vis->centerangle = centerangle;
vis->viewangle = viewangle;
vis->shear.tan = sheartan; vis->shear.tan = sheartan;
vis->shear.offset = 0; vis->shear.offset = 0;
@ -1962,6 +1963,7 @@ static void R_ProjectSprite(mobj_t *thing)
vis->xscale = FixedMul(spritexscale, xscale); //SoM: 4/17/2000 vis->xscale = FixedMul(spritexscale, xscale); //SoM: 4/17/2000
vis->scale = FixedMul(spriteyscale, yscale); //<<detailshift; vis->scale = FixedMul(spriteyscale, yscale); //<<detailshift;
vis->thingscale = oldthing->scale;
vis->spritexscale = spritexscale; vis->spritexscale = spritexscale;
vis->spriteyscale = spriteyscale; vis->spriteyscale = spriteyscale;
@ -2767,7 +2769,7 @@ static void R_DrawSprite(vissprite_t *spr)
mceilingclip = spr->cliptop; mceilingclip = spr->cliptop;
if (spr->cut & SC_SPLAT) if (spr->cut & SC_SPLAT)
R_DrawFloorSprite(spr); R_DrawFloorSplat(spr);
else else
R_DrawVisSprite(spr); R_DrawVisSprite(spr);
} }

View file

@ -157,7 +157,8 @@ typedef struct vissprite_s
fixed_t pz, pzt; // physical bottom/top fixed_t pz, pzt; // physical bottom/top
fixed_t startfrac; // horizontal position of x1 fixed_t startfrac; // horizontal position of x1
fixed_t scale; fixed_t xscale, scale; // projected horizontal and vertical scales
fixed_t thingscale; // the object's scale
fixed_t sortscale; // sortscale only differs from scale for paper sprites, floor sprites, and MF2_LINKDRAW fixed_t sortscale; // sortscale only differs from scale for paper sprites, floor sprites, and MF2_LINKDRAW
fixed_t sortsplat; // the sortscale from behind the floor sprite fixed_t sortsplat; // the sortscale from behind the floor sprite
fixed_t scalestep; // only for paper sprites, 0 otherwise fixed_t scalestep; // only for paper sprites, 0 otherwise
@ -165,6 +166,7 @@ typedef struct vissprite_s
fixed_t xiscale; // negative if flipped fixed_t xiscale; // negative if flipped
angle_t centerangle; // for paper sprites angle_t centerangle; // for paper sprites
angle_t viewangle; // for floor sprites, the viewpoint's current angle
struct { struct {
fixed_t tan; // The amount to shear the sprite vertically per row fixed_t tan; // The amount to shear the sprite vertically per row
@ -185,8 +187,6 @@ typedef struct vissprite_s
extracolormap_t *extra_colormap; // global colormaps extracolormap_t *extra_colormap; // global colormaps
fixed_t xscale;
// Precalculated top and bottom screen coords for the sprite. // Precalculated top and bottom screen coords for the sprite.
fixed_t thingheight; // The actual height of the thing fixed_t thingheight; // The actual height of the thing
sector_t *sector; // The sector containing the thing. sector_t *sector; // The sector containing the thing.

View file

@ -33,6 +33,11 @@
#include "s_sound.h" // ditto #include "s_sound.h" // ditto
#include "g_game.h" // ditto #include "g_game.h" // ditto
#include "p_local.h" // P_AutoPause() #include "p_local.h" // P_AutoPause()
#ifdef HWRENDER
#include "hardware/hw_main.h"
#include "hardware/hw_light.h"
#include "hardware/hw_model.h"
#endif
#if defined (USEASM) && !defined (NORUSEASM)//&& (!defined (_MSC_VER) || (_MSC_VER <= 1200)) #if defined (USEASM) && !defined (NORUSEASM)//&& (!defined (_MSC_VER) || (_MSC_VER <= 1200))
@ -427,6 +432,10 @@ void SCR_ChangeRenderer(void)
CONS_Alert(CONS_ERROR, "OpenGL never loaded\n"); CONS_Alert(CONS_ERROR, "OpenGL never loaded\n");
return; return;
} }
if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) // Clear these out before switching to software
HWR_ClearAllTextures();
#endif #endif
// Set the new render mode // Set the new render mode

View file

@ -137,6 +137,12 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <errno.h> #include <errno.h>
#endif #endif
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#include <execinfo.h>
#include <time.h>
#define UNIXBACKTRACE
#endif
// Locations for searching for main.kart // Locations for searching for main.kart
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2Kart" #define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2Kart"
@ -220,6 +226,71 @@ SDL_bool framebuffer = SDL_FALSE;
UINT8 keyboard_started = false; UINT8 keyboard_started = false;
#ifdef UNIXBACKTRACE
#define STDERR_WRITE(string) if (fd != -1) I_OutputMsg("%s", string)
#define CRASHLOG_WRITE(string) if (fd != -1) write(fd, string, strlen(string))
#define CRASHLOG_STDERR_WRITE(string) \
if (fd != -1)\
write(fd, string, strlen(string));\
I_OutputMsg("%s", string)
static void write_backtrace(INT32 signal)
{
int fd = -1;
size_t size;
time_t rawtime;
struct tm timeinfo;
enum { BT_SIZE = 1024, STR_SIZE = 32 };
void *array[BT_SIZE];
char timestr[STR_SIZE];
const char *error = "An error occurred within SRB2! Send this stack trace to someone who can help!\n";
const char *error2 = "(Or find crash-log.txt in your SRB2 directory.)\n"; // Shown only to stderr.
fd = open(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), O_CREAT|O_APPEND|O_RDWR, S_IRUSR|S_IWUSR);
if (fd == -1)
I_OutputMsg("\nWARNING: Couldn't open crash log for writing! Make sure your permissions are correct. Please save the below report!\n");
// Get the current time as a string.
time(&rawtime);
localtime_r(&rawtime, &timeinfo);
strftime(timestr, STR_SIZE, "%a, %d %b %Y %T %z", &timeinfo);
CRASHLOG_WRITE("------------------------\n"); // Nice looking seperator
CRASHLOG_STDERR_WRITE("\n"); // Newline to look nice for both outputs.
CRASHLOG_STDERR_WRITE(error); // "Oops, SRB2 crashed" message
STDERR_WRITE(error2); // Tell the user where the crash log is.
// Tell the log when we crashed.
CRASHLOG_WRITE("Time of crash: ");
CRASHLOG_WRITE(timestr);
CRASHLOG_WRITE("\n");
// Give the crash log the cause and a nice 'Backtrace:' thing
// The signal is given to the user when the parent process sees we crashed.
CRASHLOG_WRITE("Cause: ");
CRASHLOG_WRITE(strsignal(signal));
CRASHLOG_WRITE("\n"); // Newline for the signal name
CRASHLOG_STDERR_WRITE("\nBacktrace:\n");
// Flood the output and log with the backtrace
size = backtrace(array, BT_SIZE);
backtrace_symbols_fd(array, size, fd);
backtrace_symbols_fd(array, size, STDERR_FILENO);
CRASHLOG_WRITE("\n"); // Write another newline to the log so it looks nice :)
close(fd);
}
#undef STDERR_WRITE
#undef CRASHLOG_WRITE
#undef CRASHLOG_STDERR_WRITE
#endif // UNIXBACKTRACE
static void I_ReportSignal(int num, int coredumped) static void I_ReportSignal(int num, int coredumped)
{ {
//static char msg[] = "oh no! back to reality!\r\n"; //static char msg[] = "oh no! back to reality!\r\n";
@ -279,6 +350,9 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num)
{ {
D_QuitNetGame(); // Fix server freezes D_QuitNetGame(); // Fix server freezes
CL_AbortDownloadResume(); CL_AbortDownloadResume();
#ifdef UNIXBACKTRACE
write_backtrace(num);
#endif
I_ReportSignal(num, 0); I_ReportSignal(num, 0);
I_ShutdownSystem(); I_ShutdownSystem();
signal(num, SIG_DFL); //default signal action signal(num, SIG_DFL); //default signal action
@ -669,6 +743,28 @@ static void I_RegisterSignals (void)
#endif #endif
} }
#ifdef NEWSIGNALHANDLER
static void signal_handler_child(INT32 num)
{
#ifdef UNIXBACKTRACE
write_backtrace(num);
#endif
signal(num, SIG_DFL); //default signal action
raise(num);
}
static void I_RegisterChildSignals(void)
{
// If these defines don't exist,
// then compilation would have failed above us...
signal(SIGILL , signal_handler_child);
signal(SIGSEGV , signal_handler_child);
signal(SIGABRT , signal_handler_child);
signal(SIGFPE , signal_handler_child);
}
#endif
// //
//I_OutputMsg //I_OutputMsg
// //
@ -1620,6 +1716,7 @@ static void I_Fork(void)
newsignalhandler_Warn("fork()"); newsignalhandler_Warn("fork()");
break; break;
case 0: case 0:
I_RegisterChildSignals();
break; break;
default: default:
if (logstream) if (logstream)

View file

@ -1271,7 +1271,7 @@ boolean I_PlaySong(boolean looping)
if (gme) if (gme)
{ {
gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0};
#if GME_VERSION >= 0x000603 #if defined (GME_VERSION) && GME_VERSION >= 0x000603
if (looping) if (looping)
gme_set_autoload_playback_limit(gme, 0); gme_set_autoload_playback_limit(gme, 0);
#endif #endif

View file

@ -802,7 +802,8 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
} }
if (important && !mainfile) if (important && !mainfile)
G_SetGameModified(true, false); //G_SetGameModified(true, false);
modifiedgame = true; // avoid savemoddata being set to false
// //
// link wad file to search files // link wad file to search files