diff --git a/LUASTUFF.md b/LUASTUFF.md index 2ccd71dcb..05ca33bd0 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -2,7 +2,7 @@ ## mobj.localskin and player.localskin fields -Allow reading and assigning localskins to players. Local skins for other objects aren't supported currently. +Allow reading and assigning localskins. ## mobj.rollsum field @@ -20,9 +20,38 @@ Changes vote background texture prefix (game looks for PREFIX + "W" or "C" (depe ## hud.add(fn, "vote") and hud.add(fn, "intermission") Hud hooks for vote screen and intermission screen. They only get drawer (`v`) as argument. -To check if those hooks are available, check if globals FEATURE\_VOTEHUD and FEATURE\_INERMISSIONHUD +To check if those hooks are available, check if globals FEATURE\_VOTEHUD and FEATURE\_INTERMISSIONHUD exist. +## x, y = hud.getOffsets(item) + +Returns the values of the given HUD item's `xoffset`/`yoffset` cvars. +Available for any HUD item with offset cvars. + +## x, y, flags = v.getDrawInfo(item) + +Returns the X, Y and flags where the given HUD item will be drawn for the current displayplayer. +Available for `item`, `gametypeinfo` and `minimap`. + +## patch, colormap = v.getColorHudPatch(item) + +Returns the patch and colormap to use for the given HUD item. Colorization is based on the user's settings. +Available for `item` and `itemmul`. +Extra arguments for some items: +### item +* `small`: true for small item box, false for big item box. +* `dark`: true to darken item box. Depends on `darkitembox`. +### itemmul +* `small`: true for small sticker, false for big sticker. + +## hudcolor = v.getHudColor() + +Returns the displayplayer's HUD color. + +## colorize = v.useColorHud() + +Returns true if colorization is enabled, false otherwise. + ## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields Same fields as in SRB2 2.2 diff --git a/libs/dll-binaries/i686/libopenmpt.dll b/libs/dll-binaries/i686/libopenmpt.dll index 479114bcd..b3fa2eeab 100644 Binary files a/libs/dll-binaries/i686/libopenmpt.dll and b/libs/dll-binaries/i686/libopenmpt.dll differ diff --git a/libs/dll-binaries/i686/openmpt-mpg123.dll b/libs/dll-binaries/i686/openmpt-mpg123.dll deleted file mode 100644 index 60bc3b958..000000000 Binary files a/libs/dll-binaries/i686/openmpt-mpg123.dll and /dev/null differ diff --git a/libs/dll-binaries/i686/openmpt-ogg.dll b/libs/dll-binaries/i686/openmpt-ogg.dll deleted file mode 100644 index 32df3461a..000000000 Binary files a/libs/dll-binaries/i686/openmpt-ogg.dll and /dev/null differ diff --git a/libs/dll-binaries/i686/openmpt-vorbis.dll b/libs/dll-binaries/i686/openmpt-vorbis.dll deleted file mode 100644 index bb154d167..000000000 Binary files a/libs/dll-binaries/i686/openmpt-vorbis.dll and /dev/null differ diff --git a/libs/dll-binaries/i686/openmpt-zlib.dll b/libs/dll-binaries/i686/openmpt-zlib.dll deleted file mode 100644 index 948bc80f5..000000000 Binary files a/libs/dll-binaries/i686/openmpt-zlib.dll and /dev/null differ diff --git a/libs/dll-binaries/x86_64/libopenmpt.dll b/libs/dll-binaries/x86_64/libopenmpt.dll index 05c4237a7..97f768a62 100644 Binary files a/libs/dll-binaries/x86_64/libopenmpt.dll and b/libs/dll-binaries/x86_64/libopenmpt.dll differ diff --git a/libs/dll-binaries/x86_64/openmpt-mpg123.dll b/libs/dll-binaries/x86_64/openmpt-mpg123.dll deleted file mode 100644 index c917604df..000000000 Binary files a/libs/dll-binaries/x86_64/openmpt-mpg123.dll and /dev/null differ diff --git a/libs/dll-binaries/x86_64/openmpt-ogg.dll b/libs/dll-binaries/x86_64/openmpt-ogg.dll deleted file mode 100644 index de503b03f..000000000 Binary files a/libs/dll-binaries/x86_64/openmpt-ogg.dll and /dev/null differ diff --git a/libs/dll-binaries/x86_64/openmpt-vorbis.dll b/libs/dll-binaries/x86_64/openmpt-vorbis.dll deleted file mode 100644 index 5f21dee26..000000000 Binary files a/libs/dll-binaries/x86_64/openmpt-vorbis.dll and /dev/null differ diff --git a/libs/dll-binaries/x86_64/openmpt-zlib.dll b/libs/dll-binaries/x86_64/openmpt-zlib.dll deleted file mode 100644 index 1ae938ff7..000000000 Binary files a/libs/dll-binaries/x86_64/openmpt-zlib.dll and /dev/null differ diff --git a/libs/libopenmpt/SRB2NOTE.md b/libs/libopenmpt/SRB2NOTE.md new file mode 100644 index 000000000..95541107c --- /dev/null +++ b/libs/libopenmpt/SRB2NOTE.md @@ -0,0 +1,54 @@ +# libopenmpt mingw-w64 binary info + +Current built version as of 2019/01/03 is 0.4.0+r11103.pkg + +mingw binaries (.dll): `bin/[x86 or x86_64]/mingw` +mingw import libraries (.dll.a): `lib/[x86 or x86_64]/mingw` + +# Building libopenmpt with mingw-w64 + +libopenmpt must be built from the Makefile / Android dev package in the +[Downloads page](https://lib.openmpt.org/libopenmpt/download/#all-downloads) + +Use the mingw-w64 distributions from +[SourceForge](https://sourceforge.net/projects/mingw-w64/files/#readme). + +You can download the appropriate 7-zip archive, extract to a folder of +your choice, remove any existing mingw directories from your PATH, +then call `mingw32-make.exe` from its direct location. + +FOR LIBOPENMPT, YOU MUST USE A MINGW PACKAGE THAT SUPPORTS THE POSIX +THREADING MODEL! DO NOT COMPILE WITH A WIN32 THREADING MODEL! + +I use GCC 7.3.0: + +* [x86_64-posix-seh](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z) +* [i686-posix-dwarf](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/7.3.0/threads-posix/dwarf/i686-7.3.0-release-posix-dwarf-rt_v5-rev0.7z) + +## x86 build instructions + +``` +set CFLAGS=-march=pentium -static-libgcc +set CXXFLAGS=-march=pentium -static-libgcc -static-libstdc++ +set LDFLAGS=-Wl,--out-implib,bin/libopenmpt.dll.a -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive + +cd [libopenmpt-make-src] +[x86-mingw-w64-bin]/mingw32-make.exe CONFIG=mingw64-win32 +``` + +`libopenmpt.dll` and `libopenmpt.dll.a` will be built in the +`bin/` folder. + +## x86_64 build instructions + +``` +set CFLAGS=-march=nocona -static-libgcc +set CXXFLAGS=-march=nocona -static-libgcc -static-libstdc++ +set LDFLAGS=-Wl,--out-implib,bin/libopenmpt.dll.a -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive + +cd [libopenmpt-make-src] +[x86_64-mingw-w64-bin]/mingw32-make.exe CONFIG=mingw64-win64 +``` + +`libopenmpt.dll` and `libopenmpt.dll.a` will be built in the +`bin/` folder. \ No newline at end of file diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt.h index 912cf04da..88425b5bb 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt.h +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt.h @@ -1421,7 +1421,7 @@ LIBOPENMPT_API const char * openmpt_module_highlight_pattern_row_channel( openmp * - subsong (integer): The current subsong. Setting it has identical semantics as openmpt_module_select_subsong(), getting it returns the currently selected subsong. * - play.at_end (text): Chooses the behaviour when the end of song is reached. The song end is considered to be reached after the number of reptitions set by openmpt_module_set_repeat_count was played, so if the song is set to repeat infinitely, its end is never considered to be reached. * - "fadeout": Fades the module out for a short while. Subsequent reads after the fadeout will return 0 rendered frames. - * - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the loop start (if the song is not programmed to loop, playback resumsed from the song start). + * - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the loop start (if the song is not programmed to loop, playback resumed from the song start). * - "stop": Returns 0 rendered frames when the song end is reached. Subsequent reads will return 0 rendered frames. * - play.tempo_factor (floatingpoint): Set a floating point tempo factor. "1.0" is the default tempo. * - play.pitch_factor (floatingpoint): Set a floating point pitch factor. "1.0" is the default pitch. diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp b/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp index 69784e8ea..35b19a9e5 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp @@ -1074,7 +1074,7 @@ public: - subsong (integer): The current subsong. Setting it has identical semantics as openmpt::module::select_subsong(), getting it returns the currently selected subsong. - play.at_end (text): Chooses the behaviour when the end of song is reached. The song end is considered to be reached after the number of reptitions set by openmpt::module::set_repeat_count was played, so if the song is set to repeat infinitely, its end is never considered to be reached. - "fadeout": Fades the module out for a short while. Subsequent reads after the fadeout will return 0 rendered frames. - - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the loop start (if the song is not programmed to loop, playback resumsed from the song start). + - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the loop start (if the song is not programmed to loop, playback resumed from the song start). - "stop": Returns 0 rendered frames when the song end is reached. Subsequent reads will return 0 rendered frames. - play.tempo_factor (floatingpoint): Set a floating point tempo factor. "1.0" is the default tempo. - play.pitch_factor (floatingpoint): Set a floating point pitch factor. "1.0" is the default pitch. diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h index d006c9ed3..08ff71169 100644 --- a/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h @@ -21,7 +21,7 @@ /*! \brief libopenmpt minor version number */ #define OPENMPT_API_VERSION_MINOR 7 /*! \brief libopenmpt patch version number */ -#define OPENMPT_API_VERSION_PATCH 3 +#define OPENMPT_API_VERSION_PATCH 5 /*! \brief libopenmpt pre-release tag */ #define OPENMPT_API_VERSION_PREREL "" /*! \brief libopenmpt pre-release flag */ diff --git a/libs/libopenmpt/lib/x86/libopenmpt.lib b/libs/libopenmpt/lib/x86/libopenmpt.lib index 6f42fb2b0..5cc0d1ab9 100644 Binary files a/libs/libopenmpt/lib/x86/libopenmpt.lib and b/libs/libopenmpt/lib/x86/libopenmpt.lib differ diff --git a/libs/libopenmpt/lib/x86/mingw/libopenmpt.dll.a b/libs/libopenmpt/lib/x86/mingw/libopenmpt.dll.a new file mode 100644 index 000000000..4b1d695e7 Binary files /dev/null and b/libs/libopenmpt/lib/x86/mingw/libopenmpt.dll.a differ diff --git a/libs/libopenmpt/lib/x86_64/libopenmpt.lib b/libs/libopenmpt/lib/x86_64/libopenmpt.lib index e2d30a94d..7699529fb 100644 Binary files a/libs/libopenmpt/lib/x86_64/libopenmpt.lib and b/libs/libopenmpt/lib/x86_64/libopenmpt.lib differ diff --git a/libs/libopenmpt/lib/x86_64/mingw/libopenmpt.dll.a b/libs/libopenmpt/lib/x86_64/mingw/libopenmpt.dll.a new file mode 100644 index 000000000..19e90d8c0 Binary files /dev/null and b/libs/libopenmpt/lib/x86_64/mingw/libopenmpt.dll.a differ diff --git a/srb2.png b/srb2.png index fccde9c3f..682809888 100644 Binary files a/srb2.png and b/srb2.png differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3743118c8..7811f9032 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -466,7 +466,6 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_trick.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.c ) diff --git a/src/Makefile b/src/Makefile index a9b706f44..bc4eb6f3d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -102,6 +102,7 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... MINGW=1 SDL=1 WINDOWSHELL=1 + NOUPX=1 else # if you on the *nix @@ -272,7 +273,7 @@ ifdef NOHW else OPTS+=-DHWRENDER OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o $(OBJDIR)/hw_light.o \ - $(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o $(OBJDIR)/hw_trick.o \ + $(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o \ $(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o $(OBJDIR)/hw_shaders.o endif @@ -389,9 +390,7 @@ CFLAGS+=-DHAVE_DISCORDRPC -DUSE_STUN OBJS+=$(OBJDIR)/discord.o $(OBJDIR)/stun.o endif -ifndef NO_LUA include blua/Makefile.cfg -endif ifdef NOMD5 OPTS+=-DNOMD5 @@ -461,6 +460,7 @@ DBGNAME?=$(EXENAME).debug # SRB2kart kart.o on line 433 below OBJS:=$(i_main_o) \ $(OBJDIR)/comptime.o \ + $(OBJDIR)/qs22j.o \ $(OBJDIR)/string.o \ $(OBJDIR)/d_main.o \ $(OBJDIR)/d_protocol.o \ @@ -721,9 +721,9 @@ $(OBJDIR)/depend.dep: ifndef NOHW $(CC) $(CFLAGS) -MM hardware/*.c >> $(OBJDIR)/depend.ped endif -ifndef NO_LUA + $(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 @echo "Created dependency file, depend.dep" diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 9de48f299..04a57de0e 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -338,7 +338,7 @@ endif WFLAGS+=-Wfloat-equal #WFLAGS+=-Wtraditional ifdef VCHELP - WFLAGS+=-Wdeclaration-after-statement + #WFLAGS+=-Wdeclaration-after-statement WFLAGS+=-Wno-error=declaration-after-statement endif WFLAGS+=-Wundef diff --git a/src/android/i_system.c b/src/android/i_system.c index c0b49a886..f190699a4 100644 --- a/src/android/i_system.c +++ b/src/android/i_system.c @@ -233,11 +233,6 @@ INT32 I_mkdir(const char *dirname, INT32 unixright) return -1; } -const CPUInfoFlags *I_CPUInfo(void) -{ - return NULL; -} - const char *I_LocateWad(void) { return "/sdcard/srb2"; diff --git a/src/b_bot.c b/src/b_bot.c index 7c14c44a3..edaf477ad 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -35,11 +35,9 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm if (!sonic || sonic->health <= 0) return; -#ifdef HAVE_BLUA // Lua can handle it! if (LUAh_BotAI(sonic, tails, cmd)) return; -#endif if (tails->player->pflags & (PF_MACESPIN|PF_ITEMHANG)) { @@ -123,11 +121,9 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) // Bot AI isn't programmed in analog. //CV_SetValue(&cv_analog2, false); -#ifdef HAVE_BLUA // Let Lua scripts build ticcmds if (LUAh_BotTiccmd(player, cmd)) return; -#endif // We don't have any main character AI, sorry. D: if (player-players == consoleplayer) diff --git a/src/blua/Makefile.cfg b/src/blua/Makefile.cfg index a7146c79e..19b34383c 100644 --- a/src/blua/Makefile.cfg +++ b/src/blua/Makefile.cfg @@ -10,8 +10,6 @@ WFLAGS+=-Wno-logical-op endif endif -OPTS+=-DHAVE_BLUA - OBJS:=$(OBJS) \ $(OBJDIR)/lapi.o \ $(OBJDIR)/lbaselib.o \ diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 46a015c1e..c6269966c 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -134,7 +134,7 @@ void luaV_gettable (lua_State *L, TValue *t, TValue *key, StkId val) { void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { int loop; for (loop = 0; loop < MAXTAGLOOP; loop++) { - TValue *tm; + TValue *tm = NULL; if (ttistable(t)) { /* `t' is a table? */ Table *h = hvalue(t); TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ diff --git a/src/command.c b/src/command.c index 165cbb584..af5d936ca 100644 --- a/src/command.c +++ b/src/command.c @@ -459,13 +459,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! { -#ifdef HAVE_BLUA // don't I_Error for Lua commands // 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, // it's good to have this here so we find out. if (cmd->function != COM_Lua_f) -#endif I_Error("Command %s already exists\n", name); return; @@ -479,7 +477,6 @@ void COM_AddCommand(const char *name, com_func_t func) com_commands = cmd; } -#ifdef HAVE_BLUA /** Adds a console command for Lua. * No I_Errors allowed; return a negative code instead. * @@ -512,7 +509,6 @@ int COM_AddLuaCommand(const char *name) com_commands = cmd; return 0; } -#endif /** Tests if a command exists. * @@ -1445,17 +1441,6 @@ found: var->value = atoi(var->string); finish: - // See the note above. -/* if (var->flags & CV_CHEAT) - { - boolean newcheats = CV_CheatsEnabled(); - - if (!prevcheats && newcheats) - CONS_Printf(M_GetText("Cheats have been enabled.\n")); - else if (prevcheats && !newcheats) - CONS_Printf(M_GetText("Cheats have been disabled.\n")); - } */ - if (var->flags & CV_SHOWMODIFONETIME || var->flags & CV_SHOWMODIF) { CONS_Printf(M_GetText("%s set to %s\n"), var->name, var->string); @@ -1466,10 +1451,10 @@ finish: DEBFILE(va("%s set to %s\n", var->name, var->string)); } var->flags |= CV_MODIFIED; + // raise 'on change' code -#ifdef HAVE_BLUA LUA_CVarChanged(var->name); // let consolelib know what cvar this is. -#endif + if (var->flags & CV_CALL && !stealth) var->func(); diff --git a/src/console.c b/src/console.c index 73eac9ff9..1327e561f 100644 --- a/src/console.c +++ b/src/console.c @@ -66,8 +66,8 @@ static INT32 con_curlines; // vid lines currently used by console INT32 con_clipviewtop; // (useless) -static INT32 con_hudlines; // number of console heads up message lines -static INT32 con_hudtime[MAXHUDLINES]; // remaining time of display for hud msg lines +static UINT8 con_hudlines; // number of console heads up message lines +static UINT32 con_hudtime[MAXHUDLINES]; // remaining time of display for hud msg lines INT32 con_clearlines; // top screen lines to refresh when view reduced boolean con_hudupdate; // when messages scroll, we need a backgrnd refresh @@ -117,11 +117,13 @@ static void CONS_backcolor_Change(void); static char con_buffer[CON_BUFFERSIZE]; -// how many seconds the hud messages lasts on the screen -static consvar_t cons_msgtimeout = {"con_hudtime", "5", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +// CV_Unsigned can overflow when multiplied by TICRATE later, so let's use a 3-year limit instead +static CV_PossibleValue_t hudtime_cons_t[] = {{0, "MIN"}, {99999999, "MAX"}, {0, NULL}}; +static consvar_t cons_hudtime = {"con_hudtime", "5", CV_SAVE, hudtime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // number of lines displayed on the HUD -static consvar_t cons_hudlines = {"con_hudlines", "5", CV_CALL|CV_SAVE, CV_Unsigned, CONS_hudlines_Change, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t hudlines_cons_t[] = {{0, "MIN"}, {MAXHUDLINES, "MAX"}, {0, NULL}}; +static consvar_t cons_hudlines = {"con_hudlines", "5", CV_CALL|CV_SAVE, hudlines_cons_t, CONS_hudlines_Change, 0, NULL, NULL, 0, 0, NULL}; // number of lines console move per frame // (con_speed needs a limit, apparently) @@ -181,11 +183,6 @@ static void CONS_hudlines_Change(void) for (i = 0; i < con_hudlines; i++) con_hudtime[i] = 0; - if (cons_hudlines.value < 1) - cons_hudlines.value = 1; - else if (cons_hudlines.value > MAXHUDLINES) - cons_hudlines.value = MAXHUDLINES; - con_hudlines = cons_hudlines.value; Unlock_state(); @@ -426,7 +423,7 @@ void CON_Init(void) Unlock_state(); - CV_RegisterVar(&cons_msgtimeout); + CV_RegisterVar(&cons_hudtime); CV_RegisterVar(&cons_hudlines); CV_RegisterVar(&cons_speed); CV_RegisterVar(&cons_height); @@ -743,9 +740,8 @@ void CON_Ticker(void) // make overlay messages disappear after a while for (i = 0; i < con_hudlines; i++) { - con_hudtime[i]--; - if (con_hudtime[i] < 0) - con_hudtime[i] = 0; + if (con_hudtime[i]) + con_hudtime[i]--; } Unlock_state(); @@ -1244,7 +1240,8 @@ boolean CON_Responder(event_t *ev) static void CON_Linefeed(void) { // set time for heads up messages - con_hudtime[con_cy%con_hudlines] = cons_msgtimeout.value*TICRATE; + if (con_hudlines) + con_hudtime[con_cy%con_hudlines] = cons_hudtime.value*TICRATE; con_cy++; con_cx = 0; @@ -1600,7 +1597,7 @@ static void CON_DrawHudlines(void) INT32 charwidth = 8 * con_scalefactor; INT32 charheight = 8 * con_scalefactor; - if (con_hudlines <= 0) + if (!con_hudlines) return; if (chat_on && OLDCHAT) @@ -1608,7 +1605,7 @@ static void CON_DrawHudlines(void) else y = 0; - for (i = con_cy - con_hudlines+1; i <= con_cy; i++) + for (i = con_cy - con_hudlines; i <= con_cy; i++) { size_t c; INT32 x; diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 248afd2f9..1a24ae1c8 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -139,7 +139,7 @@ static UINT8 localtextcmd3[MAXTEXTCMD]; // splitscreen == 2 static UINT8 localtextcmd4[MAXTEXTCMD]; // splitscreen == 3 static tic_t neededtic; SINT8 servernode = 0; // the number of the server node -char connectedservername[MAXSERVERNAME]; +char connectedservername[MAXSERVERNAME+1]; /// \brief do we accept new players? /// \todo WORK! boolean acceptnewnode = true; @@ -208,7 +208,6 @@ static inline void *G_ScpyTiccmd(ticcmd_t* dest, void* src, const size_t n) } - // Some software don't support largest packet // (original sersetup, not exactely, but the probability of sending a packet // of 512 bytes is like 0.1) @@ -1138,7 +1137,7 @@ static void GetPackets(void); static cl_mode_t cl_mode = CL_SEARCHING; #ifdef HAVE_CURL -char http_source[MAX_MIRROR_LENGTH]; +char http_source[MAX_MIRROR_LENGTH+1]; #endif static UINT16 cl_lastcheckedfilecount = 0; // used for full file list @@ -1625,7 +1624,12 @@ static void SV_SendPlayerInfo(INT32 node) } netbuffer->u.playerinfo[i].node = i; + + // Can't really change this because net compatibility, but the warning is annoying +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" strncpy(netbuffer->u.playerinfo[i].name, (const char *)&player_names[i], MAXPLAYERNAME+1); +#pragma GCC diagnostic pop netbuffer->u.playerinfo[i].name[MAXPLAYERNAME] = '\0'; //fetch IP address @@ -2164,6 +2168,18 @@ static void M_ConfirmConnect(event_t *ev) #endif } +static void AbortConnection(void) +{ + CURLAbortFile(); + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + + // Will be reset by caller. Signals refusal. + cl_mode = CL_ABORTED; +} + + static boolean CL_FinishedFileList(void) { INT32 i; @@ -2176,9 +2192,7 @@ static boolean CL_FinishedFileList(void) } else if (i == 3) // too many files { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); + AbortConnection(); M_StartMessage(M_GetText( "You have too many WAD files loaded\n" "to add ones the server is using.\n" @@ -2189,9 +2203,7 @@ static boolean CL_FinishedFileList(void) } else if (i == 2) // cannot join for some reason { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); + AbortConnection(); M_StartMessage(M_GetText( "You have the wrong addons loaded.\n\n" "To play on this server, restart\n" @@ -2228,9 +2240,7 @@ static boolean CL_FinishedFileList(void) { if (!CL_CheckDownloadable()) // nope! { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); + AbortConnection(); M_StartMessage(M_GetText( "An error occured when trying to\n" "download missing addons.\n" @@ -2455,9 +2465,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic break; } - if (curl_running) - CURLGetFile(); - if (waitmore) break; // exit the case @@ -2491,9 +2498,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { CONS_Printf(M_GetText("Legacy downloader request packet failed.\n")); CONS_Printf(M_GetText("Network game synchronization aborted.\n")); - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); + AbortConnection(); M_StartMessage(M_GetText( "The direct download encountered an error.\n" "See the logfile for more info.\n" @@ -2520,9 +2525,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { CONS_Printf("%d minute wait time exceeded.\n", cv_connectawaittime.value); CONS_Printf(M_GetText("Network game synchronization aborted.\n")); - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); + AbortConnection(); M_StartMessage(va( "%d minute wait time exceeded.\n" "You may retry connection.\n" @@ -2591,12 +2594,10 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic key = I_GetKey(); // Only ESC and non-keyboard keys abort connection - if (!modeattacking && (key == KEY_ESCAPE || key >= KEY_MOUSE1 || cl_mode == CL_ABORTED)) + if (!modeattacking && (key == KEY_ESCAPE || key == KEY_JOY1+1 || cl_mode == CL_ABORTED)) { CONS_Printf(M_GetText("Network game synchronization aborted.\n")); - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); + AbortConnection(); return false; } @@ -3186,11 +3187,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) } } -#ifdef HAVE_BLUA LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting -#else - (void)reason; -#endif // Reset player data CL_ClearPlayer(playernum); @@ -3214,13 +3211,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) if (playernum == displayplayers[0] && !demo.playback) displayplayers[0] = consoleplayer; // don't look through someone's view who isn't there -#ifdef HAVE_BLUA LUA_InvalidatePlayer(&players[playernum]); -#endif - /*if (G_TagGametype()) //Check if you still have a game. Location flexible. =P - P_CheckSurvivors(); - else*/ if (G_BattleGametype()) // SRB2Kart + if (G_BattleGametype()) // SRB2Kart K_CheckBumpers(); else if (G_RaceGametype()) P_CheckRacers(); @@ -3836,9 +3829,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) #ifdef DUMPCONSISTENCY if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); #endif - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); + AbortConnection(); if (msg == KICK_MSG_CON_FAIL) M_StartMessage(M_GetText("Server closed connection\n(Synch failure)\nPress ESC\n"), NULL, MM_NOTHING); @@ -4097,9 +4088,7 @@ void SV_ResetServer(void) for (i = 0; i < MAXPLAYERS; i++) { -#ifdef HAVE_BLUA LUA_InvalidatePlayer(&players[i]); -#endif playeringame[i] = false; playernode[i] = UINT8_MAX; sprintf(player_names[i], "Player %d", i + 1); @@ -4285,9 +4274,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) if (server && multiplayer && motd[0] != '\0') COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); -#ifdef HAVE_BLUA LUAh_PlayerJoin(newplayernum); -#endif #ifdef HAVE_DISCORDRPC DRPC_UpdatePresence(); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index b1bc9ffcc..b969fff9d 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -553,7 +553,7 @@ extern boolean dedicated; // For dedicated server extern UINT16 software_MAXPACKETLENGTH; extern boolean acceptnewnode; extern SINT8 servernode; -extern char connectedservername[MAXSERVERNAME]; +extern char connectedservername[MAXSERVERNAME+1]; void Command_Ping_f(void); extern tic_t connectiontimeout; diff --git a/src/d_main.c b/src/d_main.c index 1bddb9d07..7892dd899 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -70,6 +70,8 @@ #include "d_protocol.h" #include "m_perfstats.h" +#include "lua_script.h" + #ifdef CMAKECONFIG #include "config.h" #else @@ -84,10 +86,6 @@ #include "hardware/hw3sound.h" #endif -#ifdef HAVE_BLUA -#include "lua_script.h" -#endif - #ifdef HAVE_DISCORDRPC #include "discord.h" #endif @@ -529,7 +527,7 @@ static void D_Display(void) else py = viewwindowy + 4; patch = W_CachePatchName("M_PAUSE", PU_CACHE); - V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - SHORT(patch->width))/2, py, 0, patch); + V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - SHORT(patch->width))/2, py, V_SNAPTOTOP, patch); } if (demo.rewinding) @@ -771,9 +769,7 @@ void D_SRB2Loop(void) HW3S_EndFrameUpdate(); #endif -#ifdef HAVE_BLUA LUA_Step(); -#endif #ifdef HAVE_DISCORDRPC if (! dedicated) @@ -970,7 +966,7 @@ static void D_FindAddonsToAutoload(void) INT32 i, len; boolean hasprefix = false; - char wadsToAutoload[256] = "", renameAutoloadStrings[256] = ""; + char wadsToAutoload[256] = ""; // does it exist tho autoloadpath = va("%s"PATHSEP"%s",srb2home,AUTOLOADCONFIGFILENAME); @@ -1074,6 +1070,7 @@ static boolean AddIWAD(void) } } +// extra graphic patches for saturn specific thingies boolean found_extra_kart; boolean found_extra2_kart; @@ -1084,8 +1081,10 @@ boolean achi_speedo_clr; // extra speedometer colour check boolean clr_hud; // colour hud check boolean big_lap; // bigger lap counter boolean big_lap_color; // bigger lap counter but colour -boolean kartzspeedo; // kartZ speedometer -boolean statdp; // New stat +boolean kartzspeedo; // kartZ speedo +boolean statdp; // stat display for extended player setup +boolean nametaggfx; // Nametag stuffs +boolean driftgaugegfx; static void IdentifyVersion(void) { @@ -1485,6 +1484,13 @@ void D_SRB2Main(void) if (W_CheckMultipleLumps("K_STATNB", "K_STATN1", "K_STATN2", "K_STATN3", "K_STATN4", \ "K_STATN5", "K_STATN6", NULL)) statdp = true; + + // Nametag stuffs + if (W_CheckMultipleLumps("NTLINE", "NTLINEV", "NTSP", "NTWH", NULL)) + nametaggfx = true; + + if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) + driftgaugegfx = true; } // diff --git a/src/d_main.h b/src/d_main.h index fde388921..45a2e5221 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -34,9 +34,12 @@ extern boolean achi_speedo; // achiiro speedometer check extern boolean achi_speedo_clr; // extra speedometer colour check extern boolean clr_hud; // colour hud check extern boolean big_lap; // bigger lap counter -extern boolean big_lap_color; //bigger lap counter but colour -extern boolean kartzspeedo; //kartZ speedo -extern boolean statdp; //stat display for extended player setup +extern boolean big_lap_color; // bigger lap counter but colour +extern boolean kartzspeedo; // kartZ speedo +extern boolean statdp; // stat display for extended player setup +extern boolean nametaggfx; // Nametag stuffs +extern boolean driftgaugegfx; + extern boolean autoloading; extern boolean autoloaded; diff --git a/src/d_net.c b/src/d_net.c index b0bb637c4..1b4550d35 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1010,7 +1010,7 @@ void Command_Droprate(void) static boolean ShouldDropPacket(void) { return (packetdropquantity[netbuffer->packettype]) - || (packetdroprate != 0 && rand() < (RAND_MAX * (packetdroprate / 100.f))) || packetdroprate == 100; + || (packetdroprate != 0 && rand() < (((double)RAND_MAX) * (packetdroprate / 100.f))) || packetdroprate == 100; } #endif #endif diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 21f60b7cd..2db4024bc 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -73,9 +73,6 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum); static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum); static void Got_PickVotecmd(UINT8 **cp, INT32 playernum); static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum); -#ifdef DELFILE -static void Got_Delfilecmd(UINT8 **cp, INT32 playernum); -#endif static void Got_Addfilecmd(UINT8 **cp, INT32 playernum); static void Got_Pause(UINT8 **cp, INT32 playernum); static void Got_Respawn(UINT8 **cp, INT32 playernum); @@ -144,9 +141,6 @@ static void Command_Addfile(void); static void Command_Addskins(void); static void Command_GLocalSkin(void); static void Command_ListWADS_f(void); -#ifdef DELFILE -static void Command_Delfile(void); -#endif static void Command_RunSOC(void); static void Command_Pause(void); static void Command_Respawn(void); @@ -199,10 +193,8 @@ static void Command_SkinSearch(void); #ifdef _DEBUG static void Command_Togglemodified_f(void); -#ifdef HAVE_BLUA static void Command_Archivetest_f(void); #endif -#endif // ========================================================================= // CLIENT VARIABLES @@ -460,7 +452,7 @@ static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, " consvar_t cv_basenumlaps = {"basenumlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_forceskin = {"forceskin", "Off", CV_NETVAR|CV_CALL|CV_CHEAT, Forceskin_cons_t, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fakelocalskin = {"fakelocalskin", "None", CV_SAVE, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fakelocalskin = {"fakelocalskin", "None", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_downloading = {"downloading", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowexitlevel = {"allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -513,6 +505,45 @@ consvar_t cv_mute = {"mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange, consvar_t cv_sleep = {"cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL, -1, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t nametagtrans_cons_t[] = { + {0, "Never"}, {1, "Far only"}, {2, "Dynamic"}, {3, "Always"}, {4, "HUD Trans."}, {0, NULL}}; +/*static CV_PossibleValue_t nametagscaling_cons_t[] = { + {0, "MIN"}, {320, "MAX"}, {0, NULL}};*/ +static CV_PossibleValue_t nametagdistance_cons_t[] = { + {0, "MIN"}, {640, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t nametagmaxplayer_cons_t[] = { + {1, "MIN"}, {MAXPLAYERS, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t nametagsize_cons_t[] = { + {0, "Off"}, {1, "Small"}, {2, "Minimal"}, {0, NULL}}; +static CV_PossibleValue_t nametagrestat_cons_t[] = { + {0, "Off"}, {1, "Restat"}, {2, "Always"}, {0, NULL}}; + +consvar_t cv_nametag = {"kartnametag", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagtrans = {"kartnametagtransparency", "Dynamic", CV_SAVE, nametagtrans_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagfacerank = {"kartnametagfacerank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagrestat = {"kartnametagrestat", "Restat", CV_SAVE, nametagrestat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagdist = {"kartnametagdist", "320", CV_SAVE, nametagdistance_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagmaxplayers = {"kartnametagmaxplayers", "3", CV_SAVE, nametagmaxplayer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagmaxlenght = {"kartnametagmaxlenght", "12", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +//consvar_t cv_nametagscaling = {"nametagscaling", "160", CV_SAVE, nametagscaling_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showownnametag = {"kartnametagshowown", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_smallnametags = {"kartnametagsmall", "Off", CV_SAVE, nametagsize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametaghop = {"kartnametaghop", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shownametagfinish = {"kartshownametagfinished", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t driftgaugeoffset_cons_t[] = { + {-FRACUNIT*128, "MIN"}, {FRACUNIT*128, "MAX"}, {0, NULL}}; + +static CV_PossibleValue_t driftgaugestyle_cons_t[] = { + {1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}}; + +consvar_t cv_driftgauge = {"kartdriftgauge", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_driftgaugeofs = {"kartdriftgaugeoffset", "-20", CV_FLOAT|CV_SAVE, driftgaugeoffset_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_driftgaugetrans = {"kartdriftgaugetransparency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_driftgaugestyle = {"kartdriftgaugestyle", "1", CV_SAVE, driftgaugestyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t skinselectspin_cons_t[] = { {0, "Off"}, {1, "Slow"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"}, {8, "8"}, {9, "9"}, {10, "Fast"}, {SKINSELECTSPIN_PAIN, "Pain"}, {0, NULL}}; consvar_t cv_skinselectspin = {"skinselectspin", "5", CV_SAVE, skinselectspin_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -573,7 +604,7 @@ const char *netxcmdnames[MAXNETXCMD - 1] = "RANDOMSEED", "RUNSOC", "REQADDFILE", - "DELFILE", + "DELFILE", // sigh well this prob needs to be still here to not screw up maxnetxcmd "SETMOTD", "RESPAWN", "DEMOTED", @@ -581,10 +612,8 @@ const char *netxcmdnames[MAXNETXCMD - 1] = "MODIFYVOTE", "PICKVOTE", "REMOVEPLAYER", -#ifdef HAVE_BLUA "LUACMD", "LUAVAR" -#endif }; // ========================================================================= @@ -622,15 +651,10 @@ void D_RegisterServerCommands(void) RegisterNetXCmd(XD_EXITLEVEL, Got_ExitLevelcmd); RegisterNetXCmd(XD_ADDFILE, Got_Addfilecmd); RegisterNetXCmd(XD_REQADDFILE, Got_RequestAddfilecmd); -#ifdef DELFILE - RegisterNetXCmd(XD_DELFILE, Got_Delfilecmd); -#endif RegisterNetXCmd(XD_PAUSE, Got_Pause); RegisterNetXCmd(XD_RESPAWN, Got_Respawn); RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd); -#ifdef HAVE_BLUA RegisterNetXCmd(XD_LUACMD, Got_Luacmd); -#endif RegisterNetXCmd(XD_SETUPVOTE, Got_SetupVotecmd); RegisterNetXCmd(XD_MODIFYVOTE, Got_ModifyVotecmd); @@ -667,9 +691,6 @@ void D_RegisterServerCommands(void) COM_AddCommand("localskin", Command_GLocalSkin); COM_AddCommand("listwad", Command_ListWADS_f); -#ifdef DELFILE - COM_AddCommand("delfile", Command_Delfile); -#endif COM_AddCommand("runsoc", Command_RunSOC); COM_AddCommand("pause", Command_Pause); COM_AddCommand("respawn", Command_Respawn); @@ -690,9 +711,7 @@ void D_RegisterServerCommands(void) COM_AddCommand("cheats", Command_Cheats_f); // test #ifdef _DEBUG COM_AddCommand("togglemodified", Command_Togglemodified_f); -#ifdef HAVE_BLUA COM_AddCommand("archivetest", Command_Archivetest_f); -#endif #endif COM_AddCommand("replaymarker", Command_ReplayMarker); @@ -732,19 +751,6 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_competitionboxes); CV_RegisterVar(&cv_matchboxes); - /*CV_RegisterVar(&cv_recycler); - CV_RegisterVar(&cv_teleporters); - CV_RegisterVar(&cv_superring); - CV_RegisterVar(&cv_supersneakers); - CV_RegisterVar(&cv_invincibility); - CV_RegisterVar(&cv_jumpshield); - CV_RegisterVar(&cv_watershield); - CV_RegisterVar(&cv_ringshield); - CV_RegisterVar(&cv_forceshield); - CV_RegisterVar(&cv_bombshield); - CV_RegisterVar(&cv_1up); - CV_RegisterVar(&cv_eggmanbox);*/ - K_RegisterKartStuff(); // SRB2kart CV_RegisterVar(&cv_ringslinger); @@ -814,6 +820,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_recordmultiplayerdemos); CV_RegisterVar(&cv_netdemosyncquality); CV_RegisterVar(&cv_maxdemosize); + CV_RegisterVar(&cv_nativekeyboard); } // ========================================================================= @@ -1103,6 +1110,26 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_scr_height); CV_RegisterVar(&cv_soundtest); + + CV_RegisterVar(&cv_nametag); + CV_RegisterVar(&cv_nametagtrans); + CV_RegisterVar(&cv_nametagfacerank); + CV_RegisterVar(&cv_nametagmaxplayers); + CV_RegisterVar(&cv_nametagmaxlenght); + //CV_RegisterVar(&cv_nametagscaling); + CV_RegisterVar(&cv_nametagdist); + CV_RegisterVar(&cv_showownnametag); + CV_RegisterVar(&cv_smallnametags); + CV_RegisterVar(&cv_nametagrestat); + CV_RegisterVar(&cv_nametaghop); + CV_RegisterVar(&cv_nametagscore); + CV_RegisterVar(&cv_shownametagfinish); + CV_RegisterVar(&cv_shownametagspectator); + + CV_RegisterVar(&cv_driftgauge); + CV_RegisterVar(&cv_driftgaugeofs); + CV_RegisterVar(&cv_driftgaugetrans); + CV_RegisterVar(&cv_driftgaugestyle); CV_RegisterVar(&cv_perfstats); CV_RegisterVar(&cv_ps_thinkframe_page); @@ -1120,8 +1147,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_speed); CV_RegisterVar(&cv_opflags); CV_RegisterVar(&cv_mapthingnum); -// CV_RegisterVar(&cv_grid); -// CV_RegisterVar(&cv_snapto); + //CV_RegisterVar(&cv_grid); + //CV_RegisterVar(&cv_snapto); // add cheat commands COM_AddCommand("noclip", Command_CheatNoClip_f); @@ -1147,7 +1174,7 @@ void D_RegisterClientCommands(void) #ifdef _DEBUG COM_AddCommand("causecfail", Command_CauseCfail_f); #endif -#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) +#if defined(LUA_ALLOW_BYTECODE) COM_AddCommand("dumplua", Command_Dumplua_f); #endif @@ -2915,9 +2942,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) INT32 resetplayer = 1, lastgametype; UINT8 skipprecutscene, FLS; boolean pencoremode; -/*#ifdef HAVE_BLUA - INT16 mapnumber; -#endif*/ + //INT16 mapnumber; forceresetplayers = deferencoremode = false; @@ -2983,10 +3008,8 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) if (modeattacking) // i remember moving this here in internal fixed a heisenbug so SetPlayerSkinByNum(0, cv_chooseskin.value-1); -/*#ifdef HAVE_BLUA - mapnumber = M_MapNumber(mapname[3], mapname[4]); - LUAh_MapChange(mapnumber); -#endif*/ + //mapnumber = M_MapNumber(mapname[3], mapname[4]); + //LUAh_MapChange(mapnumber); demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING; demo.savebutton = 0; @@ -4745,42 +4768,6 @@ static void Command_GLocalSkin (void) } } -#ifdef DELFILE -/** removes the last added pwad at runtime. - * Searches for sounds, maps, music and images to remove - */ -static void Command_Delfile(void) -{ - if (gamestate == GS_LEVEL) - { - CONS_Printf(M_GetText("You must NOT be in a level to use this.\n")); - return; - } - - if (netgame && !(server || adminplayer == consoleplayer)) - { - CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); - return; - } - - if (numwadfiles <= mainwads) - { - CONS_Printf(M_GetText("No additional WADs are loaded.\n")); - return; - } - - if (!(netgame || multiplayer)) - { - P_DelWadFile(); - if (mainwads == numwadfiles && modifiedgame) - modifiedgame = false; - return; - } - - SendNetXCmd(XD_DELFILE, NULL, 0); -} -#endif - static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; @@ -4849,33 +4836,6 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) COM_BufAddText(va("addfile %s\n", filename)); } -#ifdef DELFILE -static void Got_Delfilecmd(UINT8 **cp, INT32 playernum) -{ - if (playernum != serverplayer && playernum != adminplayer) - { - CONS_Alert(CONS_WARNING, M_GetText("Illegal delfile command received from %s\n"), player_names[playernum]); - if (server) - { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); - } - return; - } - (void)cp; - - if (numwadfiles <= mainwads) //sanity - return; - - P_DelWadFile(); - if (mainwads == numwadfiles && modifiedgame) - modifiedgame = false; -} -#endif - static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; @@ -5790,7 +5750,6 @@ static void Command_Togglemodified_f(void) modifiedgame = !modifiedgame; } -#ifdef HAVE_BLUA extern UINT8 *save_p; static void Command_Archivetest_f(void) { @@ -5835,7 +5794,6 @@ static void Command_Archivetest_f(void) CONS_Printf("Done. No crash.\n"); } #endif -#endif /** Makes a change to ::cv_forceskin take effect immediately. * diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 8fbdf1d5f..ebe3d12d4 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -173,9 +173,29 @@ extern consvar_t cv_skipmapcheck; extern consvar_t cv_sleep; +extern consvar_t cv_nametag; +extern consvar_t cv_nametagtrans; +extern consvar_t cv_nametagfacerank; +extern consvar_t cv_nametagmaxplayers; +extern consvar_t cv_nametagmaxlenght; +//extern consvar_t cv_nametagscaling; +extern consvar_t cv_nametagdist; +extern consvar_t cv_showownnametag; +extern consvar_t cv_smallnametags; +extern consvar_t cv_nametagrestat; +extern consvar_t cv_nametaghop; +extern consvar_t cv_nametagscore; +extern consvar_t cv_shownametagfinish; +extern consvar_t cv_shownametagspectator; + #define SKINSELECTSPIN_PAIN 25 extern consvar_t cv_skinselectspin; +extern consvar_t cv_driftgauge; +extern consvar_t cv_driftgaugeofs; +extern consvar_t cv_driftgaugetrans; +extern consvar_t cv_driftgaugestyle; + extern consvar_t cv_perfstats; extern consvar_t cv_ps_thinkframe_page; extern consvar_t cv_ps_samplesize; @@ -233,10 +253,8 @@ typedef enum XD_PICKVOTE, // 24 XD_REMOVEPLAYER,// 25 XD_DISCORD, // 26 -#ifdef HAVE_BLUA XD_LUACMD, // 27 XD_LUAVAR, // 28 -#endif MAXNETXCMD } netxcmd_t; diff --git a/src/d_netfil.c b/src/d_netfil.c index a51d44f80..dc8987b03 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -825,7 +825,6 @@ void SV_FileSendTicker(void) size_t size; filetx_t *f; INT32 packetsent, ram, i, j; - INT32 maxpacketsent; if (!filestosend) // No file to send return; @@ -1237,10 +1236,13 @@ void CURLPrepareFile(const char* url, int dfilenum) I_Error("Attempted to download files in -nodownload mode"); #endif - curl_global_init(CURL_GLOBAL_ALL); + if (!multi_handle) + { + curl_global_init(CURL_GLOBAL_ALL); + multi_handle = curl_multi_init(); + } http_handle = curl_easy_init(); - multi_handle = curl_multi_init(); if (http_handle && multi_handle) { @@ -1296,98 +1298,113 @@ void CURLPrepareFile(const char* url, int dfilenum) curl_multi_perform(multi_handle, &curl_runninghandles); curl_starttime = time(NULL); + curl_running = true; + + I_spawn_thread("http-download", (I_thread_fn)CURLGetFile, NULL); } } +void CURLAbortFile(void) +{ + curl_running = false; +} + void CURLGetFile(void) { CURLMcode mc; /* return code used by curl_multi_wait() */ CURLcode easyres; /* Return from easy interface */ - int numfds; CURLMsg *m; /* for picking up messages with the transfer status */ CURL *e; int msgs_left; /* how many messages are left */ const char *easy_handle_error; + boolean running = true; long response_code = 0; static char *filename; - if (curl_runninghandles) + while (running && curl_running) { - curl_multi_perform(multi_handle, &curl_runninghandles); - - /* wait for activity, timeout or "nothing" */ - mc = curl_multi_wait(multi_handle, NULL, 0, 1000, &numfds); - - if (mc != CURLM_OK) + if (curl_runninghandles) { - CONS_Alert(CONS_WARNING, "curl_multi_wait() failed, code %d.\n", mc); - return; - } - curl_curfile->currentsize = curl_dlnow; - curl_curfile->totalsize = curl_dltotal; - } + curl_multi_perform(multi_handle, &curl_runninghandles); - /* See how the transfers went */ - while ((m = curl_multi_info_read(multi_handle, &msgs_left))) - { - if (m && (m->msg == CURLMSG_DONE)) - { - e = m->easy_handle; - easyres = m->data.result; - filename = Z_StrDup(curl_realname); - nameonly(filename); - if (easyres != CURLE_OK) + /* wait for activity, timeout or "nothing" */ + mc = curl_multi_wait(multi_handle, NULL, 0, 1000, NULL); + + if (mc != CURLM_OK) { - if (easyres == CURLE_HTTP_RETURNED_ERROR) - curl_easy_getinfo(e, CURLINFO_RESPONSE_CODE, &response_code); - - easy_handle_error = (response_code) ? va("HTTP response code %ld", response_code) : curl_easy_strerror(easyres); - curl_curfile->status = FS_FALLBACK; - curl_curfile->currentsize = curl_origfilesize; - curl_curfile->totalsize = curl_origtotalfilesize; - curl_failedwebdownload = true; - fclose(curl_curfile->file); - remove(curl_curfile->filename); - CONS_Printf(M_GetText("Failed to download %s (%s)\n"), filename, easy_handle_error); + CONS_Alert(CONS_WARNING, "curl_multi_wait() failed, code %d.\n", mc); + continue; } - else - { - fclose(curl_curfile->file); + curl_curfile->currentsize = curl_dlnow; + curl_curfile->totalsize = curl_dltotal; + } - if (checkfilemd5(curl_curfile->filename, curl_curfile->md5sum) == FS_MD5SUMBAD) + /* See how the transfers went */ + while ((m = curl_multi_info_read(multi_handle, &msgs_left))) + { + if (m && (m->msg == CURLMSG_DONE)) + { + running = false; + e = m->easy_handle; + easyres = m->data.result; + + filename = Z_StrDup(curl_realname); + nameonly(filename); + + if (easyres != CURLE_OK) { - CONS_Alert(CONS_ERROR, M_GetText("HTTP Download of %s finished but is corrupt or has been modified\n"), filename); + if (easyres == CURLE_HTTP_RETURNED_ERROR) + curl_easy_getinfo(e, CURLINFO_RESPONSE_CODE, &response_code); + + easy_handle_error = (response_code) ? va("HTTP response code %ld", response_code) : curl_easy_strerror(easyres); curl_curfile->status = FS_FALLBACK; + curl_curfile->currentsize = curl_origfilesize; + curl_curfile->totalsize = curl_origtotalfilesize; curl_failedwebdownload = true; + fclose(curl_curfile->file); + remove(curl_curfile->filename); + CONS_Printf(M_GetText("Failed to download %s (%s)\n"), filename, easy_handle_error); } else { - CONS_Printf(M_GetText("Finished HTTP download of %s\n"), filename); - downloadcompletednum++; - downloadcompletedsize += curl_curfile->totalsize; - curl_curfile->status = FS_FOUND; + fclose(curl_curfile->file); + + if (checkfilemd5(curl_curfile->filename, curl_curfile->md5sum) == FS_MD5SUMBAD) + { + CONS_Alert(CONS_ERROR, M_GetText("HTTP Download of %s finished but is corrupt or has been modified\n"), filename); + curl_curfile->status = FS_FALLBACK; + curl_failedwebdownload = true; + } + else + { + CONS_Printf(M_GetText("Finished HTTP download of %s\n"), filename); + downloadcompletednum++; + downloadcompletedsize += curl_curfile->totalsize; + curl_curfile->status = FS_FOUND; + } } + + + Z_Free(filename); + curl_curfile->file = NULL; + curl_transfers--; + curl_multi_remove_handle(multi_handle, e); + curl_easy_cleanup(e); + + if (!curl_transfers) + break; } - - - Z_Free(filename); - curl_curfile->file = NULL; - curl_running = false; - curl_transfers--; - curl_multi_remove_handle(multi_handle, e); - curl_easy_cleanup(e); - - if (!curl_transfers) - break; } } - if (!curl_transfers) + if (!curl_transfers || !curl_running) { curl_multi_cleanup(multi_handle); curl_global_cleanup(); + multi_handle = NULL; } + curl_running = false; } HTTP_login * diff --git a/src/d_netfil.h b/src/d_netfil.h index bcf1f6670..bd54b7661 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -107,6 +107,7 @@ size_t nameonlylength(const char *s); #ifdef HAVE_CURL void CURLPrepareFile(const char* url, int dfilenum); +void CURLAbortFile(void); void CURLGetFile(void); HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next); size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); diff --git a/src/dehacked.c b/src/dehacked.c index c443e839c..c42b191a4 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -31,19 +31,19 @@ #include "r_data.h" #include "r_patch.h" #include "r_sky.h" +#include "r_draw.h" // translation colormap consts (for lua) #include "fastcmp.h" #include "lua_script.h" #include "lua_glib.h" #include "lua_hook.h" #include "d_clisrv.h" +#include "v_video.h" // video flags (for lua) + +#include "lua_script.h" +#include "lua_libs.h" #include "m_cond.h" -#ifdef HAVE_BLUA -#include "v_video.h" // video flags (for lua) -#include "r_draw.h" // translation colormap consts (for lua) -#endif - #define REQUIRE_MATHLIB_GUID "{748fcbc8-6480-4013-ac4e-7afce6cab766}" // Free slot names @@ -67,104 +67,10 @@ static sfxenum_t get_sfx(const char *word); static UINT16 get_mus(const char *word, UINT8 dehacked_mode); #endif static hudnum_t get_huditem(const char *word); -#ifndef HAVE_BLUA -static powertype_t get_power(const char *word); -#endif boolean deh_loaded = false; static int dbg_line; -#ifdef DELFILE -typedef struct undehacked_s -{ - char *undata; - struct undehacked_s *next; -} undehacked_t; - -static UINT16 unsocwad; -static undehacked_t *unsocdata[MAX_WADFILES]; -static boolean disableundo = false; - -void DEH_WriteUndoline(const char *value, const char *data, undotype_f flags) -{ - const char *eqstr = " = "; - const char *space = " "; - const char *pader = eqstr; - undehacked_t *newdata; - - if (disableundo || !unsocwad) - return; - - if ((newdata = malloc(sizeof(*newdata))) == NULL) - I_Error("Out of memory for unsoc line"); - - if (flags & UNDO_SPACE) - pader = space; - - if (flags & UNDO_ENDTEXT && !data) - data = space; - - if (value) - { - const size_t plen = strlen(pader); - const char *pound = "#"; - char *undata = NULL; - const size_t elen = strlen(pound); - size_t vlen = strlen(value), dlen = 0, len = 1; - - if (*(value+vlen-1) == '\n') - vlen--; // lnet not copy the ending \n - - if (flags & UNDO_ENDTEXT) - len += elen; // let malloc more space - - if (flags & UNDO_NEWLINE) - len++; // more space for the beginning \n - - if (data) - { - dlen = strlen(data); - if (flags & UNDO_CUTLINE && *(data+dlen-1) == '\n') - dlen--; // let not copy the ending \n - newdata->undata = malloc(vlen+plen+dlen+len); - newdata->undata[vlen+plen+dlen+len-1] = '\0'; - } - else - { - newdata->undata = malloc(vlen+len); - newdata->undata[vlen+len-1] = '\0'; - } - - if (newdata->undata) - { - undata = newdata->undata; - *undata = '\0'; - } - else - { - free(newdata); - I_Error("Out of memory for unsoc data"); - } - - if (flags & UNDO_NEWLINE) // let start with \n - strcat(undata, "\n"); - - strncat(undata, value, vlen); - - if (data) // value+pader+data - strncat(strncat(undata, pader, plen), data, dlen); - - if (flags & UNDO_ENDTEXT) // let end the text - strncat(undata, pound, elen); - } - else - newdata->undata = NULL; - - newdata->next = unsocdata[unsocwad]; - unsocdata[unsocwad] = newdata; -} -#endif - ATTRINLINE static FUNCINLINE char myfget_color(MYFILE *f) { char c = *f->curpos++; @@ -361,56 +267,6 @@ static void clear_levels(void) P_AllocMapHeader(gamemap-1); } -/* -// Edits an animated texture slot on the array -// Tails 12-27-2003 -static void readAnimTex(MYFILE *f, INT32 num) -{ - char s[MAXLINELEN]; - char *word; - char *word2; - INT32 i; - - do { - if (myfgets(s, sizeof s, f) != NULL) - { - if (s[0] == '\n') break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - // set the value in the appropriate field - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - word2 = strtok(NULL, " = "); - if (word2) - strupr(word2); - else - break; - - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - - i = atoi(word2); - - if (fastcmp(word, "START")) - strncpy(harddefs[num].startname, word2, 8); - if (fastcmp(word, "END")) - strncpy(harddefs[num].endname, word2, 8); - else if (fastcmp(word, "SPEED")) harddefs[num].speed = i; - else if (fastcmp(word, "ISTEXTURE")) harddefs[num].istexture = i; - - else deh_warning("readAnimTex %d: unknown word '%s'", num, word); - } - } while (s[0] != '\n' && !myfeof(f)); //finish when the line is empty -} -*/ - static boolean findFreeSlot(INT32 *num) { // Send the character select entry to a free slot. @@ -502,29 +358,7 @@ static void readPlayer(MYFILE *f, INT32 num) word2[strlen(word2)-1] = '\0'; i = atoi(word2); - /*if (fastcmp(word, "PLAYERNAME")) - { - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - DEH_WriteUndoline(word, description[num].text, UNDO_NONE); - strlcpy(description[num].text, word2, sizeof (description[num].text)); - for (word2 = description[num].text; *word2; word2++) - if (*word2 == '_') - *word2 = ' '; - PlayerMenu[num].text = description[num].text; - }*/ -/* else if (fastcmp(word, "MENUPOSITION")) - { // Make sure you make MENUPOSITION the first thing under CHARACTER if you're using it! - // This is to manually choose a slot and overwrite existing characters! It is NOT necessary for most individual character wads!! -#ifdef DELFILE - if (disableundo) -#endif - { - slotfound = true; - num = i; - } - } */ - /*else*/ if (fastcmp(word, "PICNAME")) + if (fastcmp(word, "PICNAME")) { if (!slotfound && (slotfound = findFreeSlot(&num)) == false) goto done; @@ -571,11 +405,6 @@ static void readPlayer(MYFILE *f, INT32 num) } } while (!myfeof(f)); // finish when the line is empty -#ifdef DELFILE - if (slotfound) - DEH_WriteUndoline("MENUPOSITION", va("%d", num), UNDO_NONE); -#endif - done: Z_Free(s); } @@ -963,7 +792,6 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) // Lua custom options also go above, contents may be case sensitive. if (fastncmp(word, "LUA.", 4)) { -#ifdef HAVE_BLUA UINT8 j; customoption_t *modoption; @@ -997,9 +825,6 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) modoption->option[31] = '\0'; strncpy(modoption->value, word2, 255); modoption->value[255] = '\0'; -#else - // Silently ignore. -#endif continue; } @@ -1091,7 +916,7 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) if (i && i <= 1035) snprintf(mapheaderinfo[num-1]->musname, 7, "%sM", G_BuildMapName(i)); else if (i && i <= 1050) - strncpy(mapheaderinfo[num-1]->musname, compat_special_music_slots[i - 1036], 7); + strncpy(mapheaderinfo[num-1]->musname, compat_special_music_slots[i - 1036], 6); else mapheaderinfo[num-1]->musname[0] = 0; // becomes empty string mapheaderinfo[num-1]->musname[6] = 0; @@ -1116,7 +941,7 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) else if (fastcmp(word, "SKYNUM")) mapheaderinfo[num-1]->skynum = (INT16)i; else if (fastcmp(word, "INTERSCREEN")) - strncpy(mapheaderinfo[num-1]->interscreen, word2, 8); + memcpy(mapheaderinfo[num-1]->interscreen, word2, 8); else if (fastcmp(word, "PRECUTSCENENUM")) mapheaderinfo[num-1]->precutscenenum = (UINT8)i; else if (fastcmp(word, "CUTSCENENUM")) @@ -1479,9 +1304,6 @@ static void readcutscene(MYFILE *f, INT32 num) char *word2; char *tmp; INT32 value; -#ifdef DELFILE - const INT32 oldnumscenes = cutscenes[num]->numscenes; -#endif // Allocate memory for this cutscene if we don't yet have any if (!cutscenes[num]) @@ -1919,10 +1741,8 @@ static void readframe(MYFILE *f, INT32 num) } z = 0; -#ifdef HAVE_BLUA found = LUA_SetLuaAction(&states[num], actiontocompare); if (!found) -#endif while (actionpointers[z].name) { if (fastcmp(actiontocompare, actionpointers[z].name)) @@ -1973,21 +1793,7 @@ static void readsound(MYFILE *f, INT32 num, const char *savesfxnames[]) else break; -/* if (fastcmp(word, "OFFSET")) - { - value -= 150360; - if (value <= 64) - value /= 8; - else if (value <= 260) - value = (value+4)/8; - else - value = (value+8)/8; - if (value >= -1 && value < sfx_freeslot0 - 1) - S_sfx[num].name = savesfxnames[value+1]; - else - deh_warning("Sound %d: offset out of bounds", num); - } - else */if (fastcmp(word, "SINGULAR")) + if (fastcmp(word, "SINGULAR")) { DEH_WriteUndoline(word, va("%d", S_sfx[num].singularity), UNDO_NONE); S_sfx[num].singularity = value; @@ -2171,10 +1977,6 @@ static void reademblemdata(MYFILE *f, INT32 num) // Default sprite and color definitions for lazy people like me if (!emblemlocations[num-1].sprite) switch (emblemlocations[num-1].type) { - /*case ET_RINGS: - emblemlocations[num-1].sprite = 'R'; break; - case ET_SCORE: case ET_NGRADE: - emblemlocations[num-1].sprite = 'S'; break;*/ case ET_TIME: //case ET_NTIME: emblemlocations[num-1].sprite = 'B'; break; default: @@ -2182,12 +1984,6 @@ static void reademblemdata(MYFILE *f, INT32 num) } if (!emblemlocations[num-1].color) switch (emblemlocations[num-1].type) { - /*case ET_RINGS: - emblemlocations[num-1].color = SKINCOLOR_GOLD; break; - case ET_SCORE: - emblemlocations[num-1].color = SKINCOLOR_BROWN; break; - case ET_NGRADE: - emblemlocations[num-1].color = SKINCOLOR_TEAL; break;*/ case ET_TIME: //case ET_NTIME: emblemlocations[num-1].color = SKINCOLOR_GREY; break; default: @@ -2494,34 +2290,6 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) return; } } - /*else if ((offset=0) || fastcmp(params[0], "NIGHTSSCORE") - || (++offset && fastcmp(params[0], "NIGHTSTIME")) - || (++offset && fastcmp(params[0], "NIGHTSGRADE"))) - { - PARAMCHECK(2); // one optional one - - ty = UC_NIGHTSSCORE + offset; - re = atoi(params[2 + !!(params[3])]); - - // Convert to map number if it appears to be one - if (params[1][0] >= 'A' && params[1][0] <= 'Z') - x1 = (INT16)M_MapNumber(params[1][0], params[1][1]); - else - x1 = (INT16)atoi(params[1]); - - if (x1 < 0 || x1 >= NUMMAPS) - { - deh_warning("Level number %d out of range (1 - %d)", re, NUMMAPS); - return; - } - - // Mare number (0 for overall) - if (params[3]) // Only if we actually got 3 params (so the second one == mare and not requirement) - x2 = (INT16)atoi(params[2]); - else - x2 = 0; - - }*/ else if (fastcmp(params[0], "TRIGGER")) { PARAMCHECK(1); @@ -2719,15 +2487,6 @@ static void readpatch(MYFILE *f, const char *name, UINT16 wad) } } while (!myfeof(f)); - // Error checking. - /* // Irrelevant. Origins cannot be unsigned. - if (patch.originx == UINT16_MAX) - I_Error("Patch %s on texture %s has no X position!\n", name, textures[i]->name); - - if (patch.originy == UINT16_MAX) - I_Error("Patch %s on texture %s has no Y position!\n", name, textures[i]->name); -*/ - // Set the patch as that patch number. textures[i]->patches[j] = patch; @@ -2944,7 +2703,7 @@ static void readmaincfg(MYFILE *f) // Also save a time attack folder filenamelen = strlen(gamedatafilename)-4; // Strip off the extension filenamelen = min(filenamelen, sizeof (timeattackfolder)); - strncpy(timeattackfolder, gamedatafilename, filenamelen); + memcpy(timeattackfolder, gamedatafilename, filenamelen); timeattackfolder[min(filenamelen, sizeof (timeattackfolder) - 1)] = '\0'; strcpy(savegamename, timeattackfolder); @@ -3338,29 +3097,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } DEH_WriteUndoline(word, word2, UNDO_HEADER); } - // Added translations to this just in case its re-enabled -/* else if (fastcmp(word, "POINTER")) - { - word = strtok(NULL, " "); // get frame - word = strtok(NULL, ")"); - if (word) - { - i = atoi(word); - if (i < NUMSTATES && i >= 0) - { - if (myfgets(s, MAXLINELEN, f)) - states[i].action = saveactions[searchvalue(s)]; - } - else - { - deh_warning("Pointer: Frame %d doesn't exist", i); - ignorelines(f); - } - } - else - deh_warning("pointer (Frame %d) : missing ')'", i); - G_SetGameModified(multiplayer, true); - }*/ else if (fastcmp(word, "SOUND")) { if (i == 0 && word2[0] != '0') // If word2 isn't a number @@ -3375,27 +3111,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) DEH_WriteUndoline(word, word2, UNDO_HEADER); // This is not a major mod. } -/* else if (fastcmp(word, "SPRITE")) - { - if (i < NUMSPRITES && i >= 0) - { - if (myfgets(s, MAXLINELEN, f)) - { - INT32 k; - k = (searchvalue(s) - 151328)/8; - if (k >= 0 && k < NUMSPRITES) - sprnames[i] = savesprnames[k]; - else - { - deh_warning("Sprite %d: offset out of bounds", i); - ignorelines(f); - } - } - } - else - deh_warning("Sprite %d doesn't exist",i); - // This is not a major mod. - }*/ else if (fastcmp(word, "HUDITEM")) { if (i == 0 && word2[0] != '0') // If word2 isn't a number @@ -3540,9 +3255,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("No word in this line: %s", s); } // end while - /*if (gamedataadded) -- REFRESHDIR_GAMEDATA murdered this - G_LoadGameData();*/ - dbg_line = -1; if (deh_num_warning) { @@ -3563,9 +3275,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump) { MYFILE f; -#ifdef DELFILE - unsocwad = wad; -#endif f.wad = wad; f.size = W_LumpLengthPwad(wad, lump); f.data = Z_Malloc(f.size + 1, PU_STATIC, NULL); @@ -3582,67 +3291,6 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum) DEH_LoadDehackedLumpPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum)); } -#ifdef DELFILE -#define DUMPUNDONE - -// read (un)dehacked lump in wad's memory -void DEH_UnloadDehackedWad(UINT16 wad) -{ - undehacked_t *tmp, *curundo = unsocdata[wad]; - MYFILE f; - size_t len = 0; - char *data; -#ifdef DUMPUNDONE - FILE *UNDO = fopen("undo.soc", "wt"); -#endif - CONS_Printf(M_GetText("Unloading WAD SOC edits\n")); - while (curundo) - { - data = curundo->undata; - curundo = curundo->next; - if (data) - len += strlen(data); - len += 1; -#ifdef DUMPUNDONE - if (UNDO) - { - if (data) - fprintf(UNDO, "%s\n", data); - else - fprintf(UNDO, "\n"); - } -#endif - } -#ifndef DUMPUNDONE - if (UNDO) fclose(UNDO); -#endif - if (!len) return; - f.size = len; - data = f.data = Z_Malloc(f.size + 1, PU_STATIC, NULL); - curundo = unsocdata[wad]; - unsocdata[wad] = NULL; - while (curundo) - { - tmp = curundo; - curundo = curundo->next; - if (tmp->undata) - data += sprintf(data, "%s\n", tmp->undata); - else - data += sprintf(data, "\n"); - if (tmp->undata) free(tmp->undata); - free(tmp); - } - f.wad = wad; - f.curpos = f.data; - f.data[f.size] = 0; - disableundo = true; - DEH_LoadDehackedFile(&f); - disableundo = false; - Z_Free(f.data); -} -#endif //DELFILE - - //////////////////////////////////////////////////////////////////////////////// // CRAZY LIST OF STATE NAMES AND ALL FROM HERE DOWN // TODO: Make this all a seperate file or something, like part of info.c?? @@ -3696,63 +3344,6 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_KART_SPIN", "S_KART_PAIN", "S_KART_SQUISH", - /* - "S_PLAY_STND", - "S_PLAY_TAP1", - "S_PLAY_TAP2", - "S_PLAY_RUN1", - "S_PLAY_RUN2", - "S_PLAY_RUN3", - "S_PLAY_RUN4", - "S_PLAY_RUN5", - "S_PLAY_RUN6", - "S_PLAY_RUN7", - "S_PLAY_RUN8", - "S_PLAY_SPD1", - "S_PLAY_SPD2", - "S_PLAY_SPD3", - "S_PLAY_SPD4", - "S_PLAY_ATK1", - "S_PLAY_ATK2", - "S_PLAY_ATK3", - "S_PLAY_ATK4", - "S_PLAY_SPRING", - "S_PLAY_FALL1", - "S_PLAY_FALL2", - "S_PLAY_ABL1", - "S_PLAY_ABL2", - "S_PLAY_SPC1", - "S_PLAY_SPC2", - "S_PLAY_SPC3", - "S_PLAY_SPC4", - "S_PLAY_CLIMB1", - "S_PLAY_CLIMB2", - "S_PLAY_CLIMB3", - "S_PLAY_CLIMB4", - "S_PLAY_CLIMB5", - "S_PLAY_GASP", - "S_PLAY_PAIN", - "S_PLAY_DIE", - "S_PLAY_TEETER1", - "S_PLAY_TEETER2", - "S_PLAY_CARRY", - "S_PLAY_SUPERSTAND", - "S_PLAY_SUPERWALK1", - "S_PLAY_SUPERWALK2", - "S_PLAY_SUPERFLY1", - "S_PLAY_SUPERFLY2", - "S_PLAY_SUPERTEETER", - "S_PLAY_SUPERHIT", - "S_PLAY_SUPERTRANS1", - "S_PLAY_SUPERTRANS2", - "S_PLAY_SUPERTRANS3", - "S_PLAY_SUPERTRANS4", - "S_PLAY_SUPERTRANS5", - "S_PLAY_SUPERTRANS6", - "S_PLAY_SUPERTRANS7", - "S_PLAY_SUPERTRANS8", - "S_PLAY_SUPERTRANS9", // This has special significance in the code. If you add more frames, search for it and make the appropriate changes. - */ // technically the player goes here but it's an infinite tic state "S_OBJPLACE_DUMMY", @@ -7803,14 +7394,12 @@ static const char *const MOBJEFLAG_LIST[] = { NULL }; -#ifdef HAVE_BLUA static const char *const MAPTHINGFLAG_LIST[4] = { NULL, "OBJECTFLIP", // Reverse gravity flag for objects. "OBJECTSPECIAL", // Special flag used with certain objects. "AMBUSH" // Deaf monsters/do not react to sound. }; -#endif static const char *const PLAYERFLAG_LIST[] = { // Flip camera angle with gravity flip prefrence. @@ -7883,7 +7472,6 @@ static const char *const PLAYERFLAG_LIST[] = { NULL // stop loop here. }; -#ifdef HAVE_BLUA // Linedef flags static const char *const ML_LIST[16] = { "IMPASSIBLE", @@ -7903,7 +7491,6 @@ static const char *const ML_LIST[16] = { "BOUNCY", "TFERLINE" }; -#endif // This DOES differ from r_draw's Color_Names, unfortunately. // Also includes Super colors @@ -8110,7 +7697,6 @@ static const char *const POWERS_LIST[] = { "INGOOP" // In goop }; -#ifdef HAVE_BLUA static const char *const KARTSTUFF_LIST[] = { "POSITION", "OLDPOSITION", @@ -8197,7 +7783,6 @@ static const char *const KARTSTUFF_LIST[] = { "SPECTATEWAIT", "GROWCANCEL" }; -#endif static const char *const HUDITEMS_LIST[] = { "LIVESNAME", @@ -8240,11 +7825,7 @@ static const char *const HUDITEMS_LIST[] = { struct { const char *n; // has to be able to hold both fixed_t and angle_t, so drastic measure!! -#ifdef HAVE_BLUA lua_Integer v; -#else - INT64 v; -#endif } const INT_CONST[] = { // If a mod removes some variables here, // please leave the names in-tact and just set @@ -8433,7 +8014,6 @@ struct { {"SF_NOINTERRUPT",SF_NOINTERRUPT}, {"SF_X2AWAYSOUND",SF_X2AWAYSOUND}, -#ifdef HAVE_BLUA // p_local.h constants {"FLOATSPEED",FLOATSPEED}, {"MAXSTEPMOVE",MAXSTEPMOVE}, @@ -8741,7 +8321,6 @@ struct { // Custom client features exposed to lua {"FEATURE_INTERMISSIONHUD",1}, {"FEATURE_VOTEHUD",1}, -#endif {NULL,0} }; @@ -8870,249 +8449,10 @@ static hudnum_t get_huditem(const char *word) return HUD_LIVESNAME; } -#ifndef HAVE_BLUA -static powertype_t get_power(const char *word) -{ // Returns the vlaue of pw_ enumerations - powertype_t i; - if (*word >= '0' && *word <= '9') - return atoi(word); - if (fastncmp("PW_",word,3)) - word += 3; // take off the pw_ - for (i = 0; i < NUMPOWERS; i++) - if (fastcmp(word, POWERS_LIST[i])) - return i; - deh_warning("Couldn't find power named 'pw_%s'",word); - return pw_invulnerability; -} - -/// \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_div(fixed_t a, fixed_t b) { return a/b; } -static fixed_t op_add(fixed_t a, fixed_t b) { return a+b; } -static fixed_t op_sub(fixed_t a, fixed_t b) { return a-b; } -static fixed_t op_or(fixed_t a, fixed_t b) { return a|b; } -static fixed_t op_and(fixed_t a, fixed_t b) { return a&b; } -static fixed_t op_lshift(fixed_t a, fixed_t b) { return a<>b; } - -struct { - const char c; - fixed_t (*v)(fixed_t,fixed_t); -} OPERATIONS[] = { - {'*',op_mul}, - {'/',op_div}, - {'+',op_add}, - {'-',op_sub}, - {'|',op_or}, - {'&',op_and}, - {'<',op_lshift}, - {'>',op_rshift}, - {0,NULL} -}; - -// Returns the full word, cut at the first symbol or whitespace -static char *read_word(const char *line) -{ - // Part 1: You got the start of the word, now find the end. - const char *p; - INT32 i; - for (p = line+1; *p; p++) { - if (*p == ' ' || *p == '\t') - break; - for (i = 0; OPERATIONS[i].c; i++) - if (*p == OPERATIONS[i].c) { - i = -1; - break; - } - if (i == -1) - break; - } - - // Part 2: Make a copy of the word and return it. - { - size_t len = (p-line); - char *word = malloc(len+1); - M_Memcpy(word,line,len); - word[len] = '\0'; - return word; - } -} - -static INT32 operation_pad(const char **word) -{ // Brings word the next operation and returns the operation number. - INT32 i; - for (; **word; (*word)++) { - if (**word == ' ' || **word == '\t') - continue; - for (i = 0; OPERATIONS[i].c; i++) - if (**word == OPERATIONS[i].c) - { - if ((**word == '<' && *(*word+1) == '<') || (**word == '>' && *(*word+1) == '>')) (*word)++; // These operations are two characters long. - else if (**word == '<' || **word == '>') continue; // ... do not accept one character long. - (*word)++; - return i; - } - deh_warning("Unknown operation '%c'",**word); - return -1; - } - return -1; -} - -static void const_warning(const char *type, const char *word) -{ - deh_warning("Couldn't find %s named '%s'",type,word); -} - -static fixed_t find_const(const char **rword) -{ // Finds the value of constants and returns it, bringing word to the next operation. - INT32 i; - fixed_t r; - char *word = read_word(*rword); - *rword += strlen(word); - if ((*word >= '0' && *word <= '9') || *word == '-') { // Parse a number - r = atoi(word); - free(word); - return r; - } - if (!*(word+1) && // Turn a single A-z symbol into numbers, like sprite frames. - ((*word >= 'A' && *word <= 'Z') || (*word >= 'a' && *word <= 'z'))) { - r = R_Char2Frame(*word); - free(word); - return r; - } - if (fastncmp("MF_", word, 3)) { - char *p = word+3; - for (i = 0; MOBJFLAG_LIST[i]; i++) - if (fastcmp(p, MOBJFLAG_LIST[i])) { - free(word); - return (1< 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) // >= GCC 3.1 #define FUNCDEAD __attribute__ ((deprecated)) #define FUNCINLINE __attribute__((always_inline)) + #define PUREFUNC __attribute__((pure)) #define FUNCNONNULL __attribute__((nonnull)) #endif @@ -321,6 +322,9 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #ifndef ATTRNOINLINE #define ATTRNOINLINE #endif +#ifndef PUREFUNC +#define PUREFUNC +#endif /* Miscellaneous types that don't fit anywhere else (Can this be changed?) */ diff --git a/src/dummy/i_system.c b/src/dummy/i_system.c index cf8144b90..f0c7e48ef 100644 --- a/src/dummy/i_system.c +++ b/src/dummy/i_system.c @@ -137,11 +137,6 @@ INT32 I_mkdir(const char *dirname, INT32 unixright) return -1; } -const CPUInfoFlags *I_CPUInfo(void) -{ - return NULL; -} - const char *I_LocateWad(void) { return NULL; diff --git a/src/filesrch.c b/src/filesrch.c index e2acdf324..55d40d811 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -414,11 +414,13 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want strcpy(&searchpath[searchpathindex[depthleft]],dent->d_name); #if defined(__linux__) || defined(__FreeBSD__) - if (dent->d_type == DT_UNKNOWN) - if (lstat(searchpath,&fsstat) == 0 && S_ISDIR(fsstat.st_mode)) + if (dent->d_type == DT_UNKNOWN && lstat(searchpath,&fsstat) == 0) + { + if (S_ISDIR(fsstat.st_mode)) dent->d_type = DT_DIR; - else if (lstat(searchpath,&fsstat) == 0 && S_ISLNK(fsstat.st_mode)) + else if (S_ISLNK(fsstat.st_mode)) dent->d_type = DT_LNK; + } // Symlinks aren't always directory symlinks. Dunno if this would resolve recursive // symlinks, but i think stat already does that diff --git a/src/filesrch.h b/src/filesrch.h index b991e8b16..dd0fb404a 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -57,7 +57,7 @@ typedef enum #endif EXT_PK3, EXT_SOC, - EXT_LUA, // allowed even if not HAVE_BLUA so that we can yell on load attempt + EXT_LUA, NUM_EXT, NUM_EXT_TABLE = NUM_EXT-EXT_START, EXT_LOADED = 0x80 diff --git a/src/g_game.c b/src/g_game.c index 38f063f62..5d9f35038 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -832,7 +832,8 @@ const char *G_BuildMapName(INT32 map) map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false, NULL)+1; } - if (map < 100) + + if (map < 100 && map >= 0) // ...but why use signed integer in first place? idk but this prevents warning (and potential buffer overflow lol) sprintf(&mapname[3], "%.2d", map); else { @@ -1621,10 +1622,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) -Making some galaxy brain autopilot Lua if you're a masochist -Making a Mario Kart 8 Deluxe tier baby mode that steers you away from walls and whatnot. You know what, do what you want! */ -#ifdef HAVE_BLUA if (gamestate == GS_LEVEL) LUAh_PlayerCmd(player, cmd); -#endif //Reset away view if a command is given. if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) @@ -2954,9 +2953,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) if (starpost) //Don't even bother with looking for a place to spawn. { P_MovePlayerToStarpost(playernum); -#ifdef HAVE_BLUA LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) -#endif return; } @@ -3012,10 +3009,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) } P_MovePlayerToSpawn(playernum, spawnpoint); -#ifdef HAVE_BLUA LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) -#endif - } mapthing_t *G_FindCTFStart(INT32 playernum) @@ -3310,9 +3304,7 @@ void G_DoReborn(INT32 playernum) } else { -#ifdef HAVE_BLUA LUAh_MapChange(gamemap); -#endif G_DoLoadLevel(true); } }*/ @@ -4784,9 +4776,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool F_StartCustomCutscene(mapheaderinfo[gamemap-1]->precutscenenum-1, true, resetplayer); else { -#ifdef HAVE_BLUA LUAh_MapChange(gamemap); -#endif G_DoLoadLevel(resetplayer); } @@ -5032,10 +5022,8 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc) INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) { boolean usemapcode = false; - INT32 newmapnum; - + INT32 newmapnum = -1; size_t mapnamelen = strlen(mapname); - char *p; if (mapnamelen == 1) @@ -5109,9 +5097,7 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) #define DF_NIGHTSATTACK 0x04 // This demo is from NiGHTS attack and contains its time left, score, and mares! #define DF_ATTACKMASK 0x06 // This demo is from ??? attack and contains ??? -#ifdef HAVE_BLUA #define DF_LUAVARS 0x20 // this demo contains extra lua vars; this is mostly used for backwards compability -#endif #define DF_ATTACKSHIFT 1 #define DF_ENCORE 0x40 @@ -5274,7 +5260,6 @@ void G_ReadDemoExtraData(void) kartspeed = READUINT8(demo_p); kartweight = READUINT8(demo_p); - if (stricmp(skins[players[p].skin].name, name) != 0) FindClosestSkinForStats(p, kartspeed, kartweight); @@ -5383,7 +5368,7 @@ void G_ReadDemoExtraData(void) void G_WriteDemoExtraData(void) { INT32 i; - char name[16]; + char name[17]; for (i = 0; i < MAXPLAYERS; i++) { @@ -5416,7 +5401,7 @@ void G_WriteDemoExtraData(void) { // Name memset(name, 0, 16); - strncpy(name, player_names[i], 16); + memcpy(name, player_names[i], 15); // Keeping 1 null byte for safety, sorry players with name containing more than 15 characters M_Memcpy(demo_p,name,16); demo_p += 16; } @@ -6763,7 +6748,7 @@ void G_RecordMetal(void) void G_BeginRecording(void) { UINT8 i, p; - char name[16]; + char name[17]; player_t *player = &players[consoleplayer]; char *filename; @@ -6780,11 +6765,9 @@ void G_BeginRecording(void) if (encoremode) demoflags |= DF_ENCORE; -#ifdef HAVE_BLUA if (!modeattacking && gL) // Ghosts don't read luavars, and you shouldn't ever need to save Lua in replays, you doof! // SERIOUSLY THOUGH WHY WOULD YOU LOAD HOSTMOD AND RECORD A GHOST WITH IT !???? demoflags |= DF_LUAVARS; -#endif // Setup header. M_Memcpy(demo_p, DEMOHEADER, 12); demo_p += 12; @@ -6864,7 +6847,7 @@ void G_BeginRecording(void) // Name memset(name, 0, 16); - strncpy(name, player_names[p], 16); + memcpy(name, player_names[p], 15); M_Memcpy(demo_p,name,16); demo_p += 16; @@ -6892,11 +6875,9 @@ void G_BeginRecording(void) WRITEUINT8(demo_p, 0xFF); // Denote the end of the player listing -#ifdef HAVE_BLUA // player lua vars, always saved even if empty... Unless it's record attack. if (demoflags & DF_LUAVARS) LUA_ArchiveDemo(); -#endif memset(&oldcmd,0,sizeof(oldcmd)); memset(&oldghost,0,sizeof(oldghost)); @@ -6951,7 +6932,7 @@ void G_BeginMetal(void) void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT32 val) { - char temp[16]; + char temp[17]; if (demoinfo_p && *(UINT32 *)demoinfo_p == 0) { @@ -7007,7 +6988,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp) UINT8 totalfiles; char filename[MAX_WADPATH]; UINT8 md5sum[16]; - filestatus_t ncs; + filestatus_t ncs = FS_NOTFOUND; boolean toomany = false; boolean alreadyloaded; UINT8 i, j; @@ -7882,9 +7863,8 @@ void G_DoPlayDemo(char *defdemoname) // didn't start recording right away. demo.deferstart = false; -/*#ifdef HAVE_BLUA - LUAh_MapChange(gamemap); -#endif*/ + //LUAh_MapChange(gamemap); + displayplayers[0] = consoleplayer = 0; memset(playeringame,0,sizeof(playeringame)); @@ -7971,7 +7951,6 @@ void G_DoPlayDemo(char *defdemoname) // end of player read (the 0xFF marker) // so this is where we are to read our lua variables (if possible!) -#ifdef HAVE_BLUA if (demoflags & DF_LUAVARS) // again, used for compability, lua shit will be saved to replays regardless of if it's even been loaded { if (!gL) // No Lua state! ...I guess we'll just start one... @@ -7980,7 +7959,6 @@ void G_DoPlayDemo(char *defdemoname) // No modeattacking check, DF_LUAVARS won't be present here. LUA_UnArchiveDemo(); } -#endif splitscreen = 0; diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 388bb2023..e0afb6054 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -15,17 +15,8 @@ #include "hw_main.h" #include "../i_system.h" -typedef struct -{ - FSurfaceInfo surf; // surf also has its own polyflags for some reason, but it seems unused - unsigned int vertsIndex; // location of verts in unsortedVertices - FUINT numVerts; - FBITFIELD polyFlags; - GLMipmap_t *texture; - int shader; - // this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls - boolean horizonSpecial; -} DrawCallInfo; +#include "../qs22j.h" + // The texture for the next polygon given to HWR_ProcessPolygon. // Set with HWR_SetCurrentTexture. @@ -33,36 +24,23 @@ GLMipmap_t *current_texture = NULL; boolean currently_batching = false; -// Dynamic arrays for: -// - unsorted draw calls -// - sorted order of draw calls -// - unsorted vertices -// - final (sorted) vertices -// - vertex indices for sorted vertices +FOutVector* finalVertexArray = NULL;// contains subset of sorted vertices and texture coordinates to be sent to gpu +UINT32* finalVertexIndexArray = NULL;// contains indexes for glDrawElements, taking into account fan->triangles conversion +// NOTE have this alloced as 3x finalVertexArray size +int finalVertexArrayAllocSize = 65536; +//GLubyte* colorArray = NULL;// contains color data to be sent to gpu, if needed +//int colorArrayAllocSize = 65536; +// not gonna use this for now, just sort by color and change state when it changes +// later maybe when using vertex attributes if it's needed -// contains the draw calls from DrawPolygon, waiting to be processed -DrawCallInfo* drawCalls = NULL; -int drawCallsSize = 0; -int drawCallsCapacity = 65536; +PolygonArrayEntry* polygonArray = NULL;// contains the polygon data from DrawPolygon, waiting to be processed +int polygonArraySize = 0; +UINT32* polygonIndexArray = NULL;// contains sorting pointers for polygonArray +int polygonArrayAllocSize = 65536; -// contains sorted order (array indices) for drawCalls -// (therefore size and capacity shared with it) -UINT32* drawCallOrder = NULL; - -// contains unsorted vertices and texture coordinates from DrawPolygon -FOutVector* unsortedVertices = NULL; -int unsortedVerticesSize = 0; -int unsortedVerticesCapacity = 65536; - -// contains subset of sorted vertices and texture coordinates to be sent to gpu -FOutVector* finalVertices = NULL; -int finalVerticesSize = 0; -int finalVerticesCapacity = 65536; - -// contains vertex indices into finalVertices for glDrawElements, -// taking into account fan->triangles conversion -UINT32* finalIndices = NULL; // this is alloced with 3x finalVertices size -int finalIndicesSize = 0; +FOutVector* unsortedVertexArray = NULL;// contains unsorted vertices and texture coordinates from DrawPolygon +int unsortedVertexArraySize = 0; +int unsortedVertexArrayAllocSize = 65536; // Enables batching mode. HWR_ProcessPolygon will collect polygons instead of passing them directly to the rendering backend. // Call HWR_RenderBatches to render all the collected geometry. @@ -72,13 +50,13 @@ void HWR_StartBatching(void) I_Error("Repeat call to HWR_StartBatching without HWR_RenderBatches"); // init arrays if that has not been done yet - if (!finalVertices) + if (!finalVertexArray) { - finalVertices = malloc(finalVerticesCapacity * sizeof(FOutVector)); - finalIndices = malloc(finalVerticesCapacity * 3 * sizeof(UINT32)); - drawCalls = malloc(drawCallsCapacity * sizeof(DrawCallInfo)); - drawCallOrder = malloc(drawCallsCapacity * sizeof(UINT32)); - unsortedVertices = malloc(unsortedVerticesCapacity * sizeof(FOutVector)); + finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector)); + finalVertexIndexArray = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32)); + polygonArray = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry)); + polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32)); + unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector)); } currently_batching = true; @@ -89,55 +67,14 @@ void HWR_StartBatching(void) // Doing this was easier than getting a texture pointer to HWR_ProcessPolygon. void HWR_SetCurrentTexture(GLMipmap_t *texture) { - if (currently_batching) - current_texture = texture; - else - HWD.pfnSetTexture(texture); -} - -static void HWR_CollectDrawCallInfo(FSurfaceInfo *pSurf, FUINT iNumPts, FBITFIELD PolyFlags, int shader_target, boolean horizonSpecial) -{ - // make sure dynamic array has capacity - if (drawCallsSize == drawCallsCapacity) - { - DrawCallInfo* new_array; - // ran out of space, make new array double the size - drawCallsCapacity *= 2; - new_array = malloc(drawCallsCapacity * sizeof(DrawCallInfo)); - memcpy(new_array, drawCalls, drawCallsSize * sizeof(DrawCallInfo)); - free(drawCalls); - drawCalls = new_array; - // also need to redo the index array, dont need to copy it though - free(drawCallOrder); - drawCallOrder = malloc(drawCallsCapacity * sizeof(UINT32)); - } - // add entry to array - drawCalls[drawCallsSize].surf = *pSurf; - drawCalls[drawCallsSize].vertsIndex = unsortedVerticesSize; - drawCalls[drawCallsSize].numVerts = iNumPts; - drawCalls[drawCallsSize].polyFlags = PolyFlags; - drawCalls[drawCallsSize].texture = current_texture; - drawCalls[drawCallsSize].shader = (shader_target != -1) ? HWR_GetShaderFromTarget(shader_target) : shader_target; - drawCalls[drawCallsSize].horizonSpecial = horizonSpecial; - drawCallsSize++; -} - -static void HWR_CollectDrawCallVertices(FOutVector *pOutVerts, FUINT iNumPts) -{ - // make sure dynamic array has capacity - while (unsortedVerticesSize + (int)iNumPts > unsortedVerticesCapacity) - { - FOutVector* new_array; - // need more space for vertices in unsortedVertices - unsortedVerticesCapacity *= 2; - new_array = malloc(unsortedVerticesCapacity * sizeof(FOutVector)); - memcpy(new_array, unsortedVertices, unsortedVerticesSize * sizeof(FOutVector)); - free(unsortedVertices); - unsortedVertices = new_array; - } - // add vertices to array - memcpy(&unsortedVertices[unsortedVerticesSize], pOutVerts, iNumPts * sizeof(FOutVector)); - unsortedVerticesSize += iNumPts; + if (currently_batching) + { + current_texture = texture; + } + else + { + HWD.pfnSetTexture(texture); + } } // If batching is enabled, this function collects the polygon data and the chosen texture @@ -145,16 +82,48 @@ static void HWR_CollectDrawCallVertices(FOutVector *pOutVerts, FUINT iNumPts) // render the polygon immediately. void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader_target, boolean horizonSpecial) { - if (currently_batching) + if (currently_batching) { if (!pSurf) + I_Error("Got a null FSurfaceInfo in batching");// nulls should not come in the stuff that batching currently applies to + if (polygonArraySize == polygonArrayAllocSize) { - // handling null FSurfaceInfo is not implemented - I_Error("Got a null FSurfaceInfo in batching"); + PolygonArrayEntry* new_array; + // ran out of space, make new array double the size + polygonArrayAllocSize *= 2; + new_array = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry)); + memcpy(new_array, polygonArray, polygonArraySize * sizeof(PolygonArrayEntry)); + free(polygonArray); + polygonArray = new_array; + // also need to redo the index array, dont need to copy it though + free(polygonIndexArray); + polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32)); } - HWR_CollectDrawCallInfo(pSurf, iNumPts, PolyFlags, shader_target, horizonSpecial); - HWR_CollectDrawCallVertices(pOutVerts, iNumPts); + while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize) + { + FOutVector* new_array; + // need more space for vertices in unsortedVertexArray + unsortedVertexArrayAllocSize *= 2; + new_array = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector)); + memcpy(new_array, unsortedVertexArray, unsortedVertexArraySize * sizeof(FOutVector)); + free(unsortedVertexArray); + unsortedVertexArray = new_array; + } + + // add the polygon data to the arrays + + polygonArray[polygonArraySize].surf = *pSurf; + polygonArray[polygonArraySize].vertsIndex = unsortedVertexArraySize; + polygonArray[polygonArraySize].numVerts = iNumPts; + polygonArray[polygonArraySize].polyFlags = PolyFlags; + polygonArray[polygonArraySize].texture = current_texture; + polygonArray[polygonArraySize].shader = (shader_target != -1) ? HWR_GetShaderFromTarget(shader_target) : shader_target; + polygonArray[polygonArraySize].horizonSpecial = horizonSpecial; + polygonArraySize++; + + memcpy(&unsortedVertexArray[unsortedVertexArraySize], pOutVerts, iNumPts * sizeof(FOutVector)); + unsortedVertexArraySize += iNumPts; } else { @@ -163,12 +132,12 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt } } -static int compareDrawCalls(const void *p1, const void *p2) +static int comparePolygons(const void *p1, const void *p2) { - UINT32 index1 = *(const UINT32*)p1; - UINT32 index2 = *(const UINT32*)p2; - DrawCallInfo* poly1 = &drawCalls[index1]; - DrawCallInfo* poly2 = &drawCalls[index2]; + unsigned int index1 = *(const unsigned int*)p1; + unsigned int index2 = *(const unsigned int*)p2; + PolygonArrayEntry* poly1 = &polygonArray[index1]; + PolygonArrayEntry* poly2 = &polygonArray[index2]; int diff; INT64 diff64; UINT32 downloaded1 = 0; @@ -213,12 +182,12 @@ static int compareDrawCalls(const void *p1, const void *p2) return diff; } -static int compareDrawCallsNoShaders(const void *p1, const void *p2) +static int comparePolygonsNoShaders(const void *p1, const void *p2) { - UINT32 index1 = *(const UINT32*)p1; - UINT32 index2 = *(const UINT32*)p2; - DrawCallInfo* poly1 = &drawCalls[index1]; - DrawCallInfo* poly2 = &drawCalls[index2]; + unsigned int index1 = *(const unsigned int*)p1; + unsigned int index2 = *(const unsigned int*)p2; + PolygonArrayEntry* poly1 = &polygonArray[index1]; + PolygonArrayEntry* poly2 = &polygonArray[index2]; int diff; INT64 diff64; @@ -249,155 +218,60 @@ static int compareDrawCallsNoShaders(const void *p1, const void *p2) return 0; } -static void HWR_CollectVerticesIntoBatch(DrawCallInfo *drawCall) -{ - int firstVIndex; - int lastVIndex; - int numVerts = drawCall->numVerts; - // before writing, check if there is enough room - // using 'while' instead of 'if' here makes sure that there will *always* be enough room. - // probably never will this loop run more than once though - while (finalVerticesSize + numVerts > finalVerticesCapacity) - { - FOutVector* new_array; - UINT32* new_index_array; - finalVerticesCapacity *= 2; - new_array = malloc(finalVerticesCapacity * sizeof(FOutVector)); - memcpy(new_array, finalVertices, finalVerticesSize * sizeof(FOutVector)); - free(finalVertices); - finalVertices = new_array; - // also increase size of index array, 3x of vertex array since - // going from fans to triangles increases vertex count to 3x - new_index_array = malloc(finalVerticesCapacity * 3 * sizeof(UINT32)); - memcpy(new_index_array, finalIndices, finalIndicesSize * sizeof(UINT32)); - free(finalIndices); - finalIndices = new_index_array; - } - // write the vertices of the polygon - memcpy(&finalVertices[finalVerticesSize], &unsortedVertices[drawCall->vertsIndex], - numVerts * sizeof(FOutVector)); - // write the indexes, pointing to the fan vertexes but in triangles format - firstVIndex = finalVerticesSize; - lastVIndex = finalVerticesSize + numVerts; - finalVerticesSize += 2; - while (finalVerticesSize < lastVIndex) - { - finalIndices[finalIndicesSize++] = firstVIndex; - finalIndices[finalIndicesSize++] = finalVerticesSize - 1; - finalIndices[finalIndicesSize++] = finalVerticesSize++; - } -} - -static GLMipmap_t *HWR_GetDrawCallTexture(DrawCallInfo *dc) -{ - return (dc->polyFlags & PF_NoTexture) ? NULL : dc->texture; -} - -// flags returned by HWR_MarkStateChanges -#define SHADER_CHANGED 1 -#define TEXTURE_CHANGED 2 -#define POLYFLAGS_CHANGED 4 -#define SURFACEINFO_CHANGED 8 - -static unsigned int HWR_MarkStateChanges(DrawCallInfo *current, DrawCallInfo *next) -{ - unsigned int stateChanges = 0; - FSurfaceInfo *currentSI = ¤t->surf; - FSurfaceInfo *nextSI = &next->surf; - - // check if a state change is required and flag it to stateChanges - - if (current->shader != next->shader && cv_grshaders.value && gr_shadersavailable) - stateChanges |= SHADER_CHANGED; - if (HWR_GetDrawCallTexture(current) != HWR_GetDrawCallTexture(next)) - stateChanges |= TEXTURE_CHANGED; - if (current->polyFlags != next->polyFlags) - stateChanges |= POLYFLAGS_CHANGED; - if (cv_grshaders.value && gr_shadersavailable) - { - if (currentSI->PolyColor.rgba != nextSI->PolyColor.rgba || - currentSI->TintColor.rgba != nextSI->TintColor.rgba || - currentSI->FadeColor.rgba != nextSI->FadeColor.rgba || - currentSI->LightInfo.light_level != nextSI->LightInfo.light_level || - currentSI->LightInfo.fade_start != nextSI->LightInfo.fade_start || - currentSI->LightInfo.fade_end != nextSI->LightInfo.fade_end) - { - stateChanges |= SURFACEINFO_CHANGED; - } - } - else - { - if (currentSI->PolyColor.rgba != nextSI->PolyColor.rgba) - stateChanges |= SURFACEINFO_CHANGED; - } - - return stateChanges; -} - -static void HWR_ExecuteStateChanges(unsigned int stateChanges, DrawCallInfo *dc) -{ - if ((stateChanges & SHADER_CHANGED) && cv_grshaders.value && gr_shadersavailable) - { - HWD.pfnSetShader(dc->shader); - ps_hw_numshaders.value.i++; - } - if (stateChanges & TEXTURE_CHANGED) - { - // for PF_NoTexture the texture is set in DrawIndexedTriangles - if (!(dc->polyFlags & PF_NoTexture)) - { - // texture should be already ready for use from calls to - // SetTexture during batch collection - HWD.pfnSetTexture(dc->texture); - } - ps_hw_numtextures.value.i++; - } - // these two are just parameters to DrawIndexedTriangles - // (changes to polyflags states are tracked in r_opengl.c though) - if (stateChanges & POLYFLAGS_CHANGED) - ps_hw_numpolyflags.value.i++; - if (stateChanges & SURFACEINFO_CHANGED) - ps_hw_numcolors.value.i++; -} - - -static void HWR_InitBatchingStats(void) -{ - ps_hw_numpolys.value.i = drawCallsSize; - ps_hw_numcalls.value.i = ps_hw_numverts.value.i - = ps_hw_numshaders.value.i = ps_hw_numtextures.value.i - = ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 0; -} - -// This function organizes the geometry and draw calls collected by HWR_ProcessPolygon -// calls into batches and uses the rendering backend to draw them. +// This function organizes the geometry collected by HWR_ProcessPolygon calls into batches and uses +// the rendering backend to draw them. void HWR_RenderBatches(void) { - int drawCallReadPos = 0; // position in drawCallOrder + int finalVertexWritePos = 0;// position in finalVertexArray + int finalIndexWritePos = 0;// position in finalVertexIndexArray + + int polygonReadPos = 0;// position in polygonIndexArray + + int currentShader; + int nextShader = 0; + GLMipmap_t *currentTexture; + GLMipmap_t *nextTexture = NULL; + FBITFIELD currentPolyFlags = 0; + FBITFIELD nextPolyFlags = 0; + FSurfaceInfo currentSurfaceInfo; + FSurfaceInfo nextSurfaceInfo; + int i; - if (!currently_batching) + if (!currently_batching) I_Error("HWR_RenderBatches called without starting batching"); - currently_batching = false; // no longer collecting batches + nextSurfaceInfo.LightInfo.fade_end = 0; + nextSurfaceInfo.LightInfo.fade_start = 0; + nextSurfaceInfo.LightInfo.light_level = 0; - HWR_InitBatchingStats(); + currently_batching = false;// no longer collecting batches + if (!polygonArraySize) + { + ps_hw_numpolys.value.i = ps_hw_numcalls.value.i = ps_hw_numshaders.value.i + = ps_hw_numtextures.value.i = ps_hw_numpolyflags.value.i + = ps_hw_numcolors.value.i = 0; + return;// nothing to draw + } + // init stats vars + ps_hw_numpolys.value.i = polygonArraySize; + ps_hw_numcalls.value.i = ps_hw_numverts.value.i = 0; + ps_hw_numshaders.value.i = ps_hw_numtextures.value.i + = ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1; + // init polygonIndexArray + for (i = 0; i < polygonArraySize; i++) + { + polygonIndexArray[i] = i; + } - if (!drawCallsSize) - return; // nothing to draw - - // init drawCallOrder - for (i = 0; i < drawCallsSize; i++) - drawCallOrder[i] = i; - - // sort the draw calls + // sort polygons PS_START_TIMING(ps_hw_batchsorttime); if (cv_grshaders.value && gr_shadersavailable) - qsort(drawCallOrder, drawCallsSize, sizeof(UINT32), compareDrawCalls); + qs22j(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons); else - qsort(drawCallOrder, drawCallsSize, sizeof(UINT32), compareDrawCallsNoShaders); + qs22j(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders); PS_STOP_TIMING(ps_hw_batchsorttime); - // sort grouping order + // sort order // 1. shader // 2. texture // 3. polyflags @@ -406,57 +280,191 @@ void HWR_RenderBatches(void) PS_START_TIMING(ps_hw_batchdrawtime); + currentShader = polygonArray[polygonIndexArray[0]].shader; + currentTexture = polygonArray[polygonIndexArray[0]].texture; + currentPolyFlags = polygonArray[polygonIndexArray[0]].polyFlags; + currentSurfaceInfo = polygonArray[polygonIndexArray[0]].surf; + // For now, will sort and track the colors. Vertex attributes could be used instead of uniforms + // and a color array could replace the color calls. + // set state for first batch - HWR_ExecuteStateChanges(0xFFFF, &drawCalls[drawCallOrder[0]]); - // - iterate through draw calls - // - accumulate converted vertices and indices into finalVertices and finalIndices - // and send them as a combined draw call when a state change occurs - while (1) + if (cv_grshaders.value && gr_shadersavailable) { + HWD.pfnSetShader(currentShader); + } + + if (currentPolyFlags & PF_NoTexture) + currentTexture = NULL; + else + HWD.pfnSetTexture(currentTexture); + + while (1)// note: remember handling notexture polyflag as having texture number 0 (also in comparePolygons) + { + int firstIndex; + int lastIndex; + boolean stopFlag = false; - unsigned int stateChanges = 0; // flags defined above HWR_MarkStateChanges - DrawCallInfo *currentDrawCall = &drawCalls[drawCallOrder[drawCallReadPos++]]; - DrawCallInfo *nextDrawCall = NULL; + boolean changeState = false; + boolean changeShader = false; + boolean changeTexture = false; + boolean changePolyFlags = false; + boolean changeSurfaceInfo = false; - HWR_CollectVerticesIntoBatch(currentDrawCall); + // steps: + // write vertices + // check for changes or end, otherwise go back to writing + // changes will affect the next vars and the change bools + // end could set flag for stopping + // execute draw call + // could check ending flag here + // change states according to next vars and change bools, updating the current vars and reseting the bools + // reset write pos + // repeat loop - if (drawCallReadPos >= drawCallsSize) // was that the last draw call? + int index = polygonIndexArray[polygonReadPos++]; + int numVerts = polygonArray[index].numVerts; + // before writing, check if there is enough room + // using 'while' instead of 'if' here makes sure that there will *always* be enough room. + // probably never will this loop run more than once though + while (finalVertexWritePos + numVerts > finalVertexArrayAllocSize) + { + FOutVector* new_array; + unsigned int* new_index_array; + finalVertexArrayAllocSize *= 2; + new_array = malloc(finalVertexArrayAllocSize * sizeof(FOutVector)); + memcpy(new_array, finalVertexArray, finalVertexWritePos * sizeof(FOutVector)); + free(finalVertexArray); + finalVertexArray = new_array; + // also increase size of index array, 3x of vertex array since + // going from fans to triangles increases vertex count to 3x + new_index_array = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32)); + memcpy(new_index_array, finalVertexIndexArray, finalIndexWritePos * sizeof(UINT32)); + free(finalVertexIndexArray); + finalVertexIndexArray = new_index_array; + } + // write the vertices of the polygon + memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[polygonArray[index].vertsIndex], + numVerts * sizeof(FOutVector)); + // write the indexes, pointing to the fan vertexes but in triangles format + firstIndex = finalVertexWritePos; + lastIndex = finalVertexWritePos + numVerts; + finalVertexWritePos += 2; + while (finalVertexWritePos < lastIndex) + { + finalVertexIndexArray[finalIndexWritePos++] = firstIndex; + finalVertexIndexArray[finalIndexWritePos++] = finalVertexWritePos - 1; + finalVertexIndexArray[finalIndexWritePos++] = finalVertexWritePos++; + } + + if (polygonReadPos >= polygonArraySize) { stopFlag = true; } else { - nextDrawCall = &drawCalls[drawCallOrder[drawCallReadPos]]; - stateChanges = HWR_MarkStateChanges(currentDrawCall, nextDrawCall); + // check if a state change is required, set the change bools and next vars + int nextIndex = polygonIndexArray[polygonReadPos]; + nextShader = polygonArray[nextIndex].shader; + nextTexture = polygonArray[nextIndex].texture; + nextPolyFlags = polygonArray[nextIndex].polyFlags; + nextSurfaceInfo = polygonArray[nextIndex].surf; + if (nextPolyFlags & PF_NoTexture) + nextTexture = 0; + if (currentShader != nextShader && cv_grshaders.value && gr_shadersavailable) + { + changeState = true; + changeShader = true; + } + if (currentTexture != nextTexture) + { + changeState = true; + changeTexture = true; + } + if (currentPolyFlags != nextPolyFlags) + { + changeState = true; + changePolyFlags = true; + } + if (cv_grshaders.value && gr_shadersavailable) + { + if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba || + currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba || + currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba || + currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level || + currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start || + currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end) + { + changeState = true; + changeSurfaceInfo = true; + } + } + else + { + if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba) + { + changeState = true; + changeSurfaceInfo = true; + } + } } - if (stateChanges || stopFlag) + if (changeState || stopFlag) { - // execute combined draw call - HWD.pfnDrawIndexedTriangles(¤tDrawCall->surf, finalVertices, - finalIndicesSize, currentDrawCall->polyFlags, finalIndices); + // execute draw call + HWD.pfnDrawIndexedTriangles(¤tSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray); // update stats ps_hw_numcalls.value.i++; - ps_hw_numverts.value.i += finalIndicesSize; - // reset final geometry collection arrays - finalVerticesSize = 0; - finalIndicesSize = 0; + ps_hw_numverts.value.i += finalIndexWritePos; + // reset write positions + finalVertexWritePos = 0; + finalIndexWritePos = 0; } - else - continue; + else continue; // if we're here then either its time to stop or time to change state - if (stopFlag) - break; - else - HWR_ExecuteStateChanges(stateChanges, nextDrawCall); + if (stopFlag) break; + + // change state according to change bools and next vars, update current vars and reset bools + if (changeShader) + { + HWD.pfnSetShader(nextShader); + currentShader = nextShader; + changeShader = false; + + ps_hw_numshaders.value.i++; + } + if (changeTexture) + { + // texture should be already ready for use from calls to SetTexture during batch collection + HWD.pfnSetTexture(nextTexture); + currentTexture = nextTexture; + changeTexture = false; + + ps_hw_numtextures.value.i++; + } + if (changePolyFlags) + { + currentPolyFlags = nextPolyFlags; + changePolyFlags = false; + + ps_hw_numpolyflags.value.i++; + } + if (changeSurfaceInfo) + { + currentSurfaceInfo = nextSurfaceInfo; + changeSurfaceInfo = false; + + ps_hw_numcolors.value.i++; + } + // and that should be it? } // reset the arrays (set sizes to 0) - drawCallsSize = 0; - unsortedVerticesSize = 0; + polygonArraySize = 0; + unsortedVertexArraySize = 0; PS_STOP_TIMING(ps_hw_batchdrawtime); } + #endif // HWRENDER diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index b4e4bd9e3..7c108a4bd 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -17,11 +17,21 @@ #include "hw_data.h" #include "hw_drv.h" +typedef struct +{ + FSurfaceInfo surf;// surf also has its own polyflags for some reason, but it seems unused + unsigned int vertsIndex;// location of verts in unsortedVertexArray + FUINT numVerts; + FBITFIELD polyFlags; + GLMipmap_t *texture; + int shader; + // this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls + boolean horizonSpecial; +} PolygonArrayEntry; + void HWR_StartBatching(void); void HWR_SetCurrentTexture(GLMipmap_t *texture); void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial); void HWR_RenderBatches(void); -extern boolean currently_batching; - #endif diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index ff7e035f8..ebf18ed14 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -809,12 +809,10 @@ static void AdjustSegs(void) float distv1,distv2,tmp; nearv1 = nearv2 = MYMAX; -#ifdef POLYOBJECTS // Don't touch polyobject segs. We'll compensate // for this when we go about drawing them. if (lseg->polyseg) continue; -#endif if (p) { for (j = 0; j < p->numpts; j++) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c32870fed..888a8414e 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -32,6 +32,7 @@ INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes INT32 textureformat = GL_TEXFMT_P_8; // use chromakey for hole RGBA_t mapPalette[256] = {0}; // the palette for the currently loaded level or menu etc. + // Returns a pointer to the palette which should be used for caching textures. RGBA_t *HWR_GetTexturePalette(void) { @@ -85,7 +86,6 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm position = originy + topdelta; yfrac = 0; - //yfracstep = (patchcol->length << FRACBITS) / count; if (position < 0) { yfrac = -position<>FRACBITS]; - alpha = 0xff; //Hurdler: not perfect, but better than holes if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX && (mipmap->flags & TF_CHROMAKEYED)) alpha = 0x00; - //texel = HWR_CHROMAKEY_EQUIVALENTCOLORINDEX; - // Lat: Don't do that, some weirdos still use CYAN on their WALLTEXTURES for translucency :V - //Hurdler: 25/04/2000: now support colormap in hardware mode - else if (mipmap->colormap) + if (mipmap->colormap) texel = mipmap->colormap[texel]; // hope compiler will get this switch out of the loops (dreams...) @@ -172,15 +168,10 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, palette = HWR_GetTexturePalette(); - //ncols = (pwidth * pblockwidth) / pwidth; ncols = pwidth; // source advance xfrac = 0; - //xfracstep = (pwidth << FRACBITS) / pblockwidth; - //yfracstep = (pheight << FRACBITS) / pblockheight; - //scale_y = (pblockheight << FRACBITS) / pheight; - xfracstep = FRACUNIT; yfracstep = FRACUNIT; scale_y = FRACUNIT; @@ -254,14 +245,6 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, col = x * pblockwidth / texture->width; ncols = ((x2 - x) * pblockwidth) / texture->width; -/* - CONS_Debug(DBG_RENDER, "patch %dx%d texture %dx%d block %dx%d\n", - width, height, - texture->width, texture->height, - pblockwidth, pblockheight); - CONS_Debug(DBG_RENDER, " col %d ncols %d x %d\n", col, ncols, x); -*/ - // source advance xfrac = 0; if (x1 < 0) @@ -291,7 +274,6 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, } } - static UINT8 *MakeBlock(GLMipmap_t *grMipmap) { UINT8 *block; @@ -299,8 +281,8 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap) UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX); INT32 blocksize = (grMipmap->width * grMipmap->height); -bpp = format2bpp(grMipmap->format); - block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data));; + bpp = format2bpp(grMipmap->format); + block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data)); switch (bpp) { @@ -309,7 +291,6 @@ bpp = format2bpp(grMipmap->format); // fill background with chromakey, alpha = 0 for (i = 0; i < blocksize; i++) memcpy(block+i*sizeof(UINT16), &bu16, sizeof(UINT16)); - break; case 4: memset(block, 0x00, blocksize*sizeof(UINT32)); break; } @@ -502,6 +483,9 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch) // Set the first colormap to the one that comes after it. next = pat->mipmap->nextcolormap; + if (!next) + break; + pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. @@ -646,6 +630,9 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) { GLMipmap_t *grmip; + + if (flatlumpnum == LUMPERROR) + return; grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap; @@ -662,7 +649,6 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grmip->downloaded) HWD.pfnSetTexture(grmip); - HWR_SetCurrentTexture(grmip); // The system-memory data can be purged now. @@ -888,7 +874,6 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum) // I DO need to convert this because it isn't power of 2 and we need the alpha } - void HWR_GetFadeMask(lumpnum_t fademasklumpnum) { GLMipmap_t *grmip; @@ -1085,8 +1070,7 @@ UINT32 HWR_GetLightTableID(extracolormap_t *colormap) // call become invalid and must not be used. void HWR_ClearLightTables(void) { - //if (vid.glstate == VID_GL_LIBRARY_LOADED) // we have pfnInit which is essentially the same, but it doesent work here for whatever reason, since this should not be done in software renderer ever! - if (rendermode == render_opengl) + if (vid.glstate == VID_GL_LIBRARY_LOADED) HWD.pfnClearLightTables(); } diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 8ef5636aa..926f68fc6 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -68,6 +68,7 @@ ** */ + #include #include "../v_video.h" #include "hw_main.h" @@ -76,13 +77,7 @@ #include "../r_state.h" #include "../tables.h" #include "r_opengl/r_opengl.h" -#include "../r_main.h" // for cv_fov -#ifdef HAVE_SPHEREFRUSTRUM -static GLdouble viewMatrix[16]; -static GLdouble projMatrix[16]; -float frustum[6][4]; -#endif typedef struct clipnode_s { @@ -323,17 +318,12 @@ void gld_clipper_Clear(void) angle_t gld_FrustumAngle(angle_t tiltangle) { + double clipfov; double floatangle; angle_t a1; float tilt = (float)fabs(((double)(int)tiltangle) / ANG1); - // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function - - float render_fov = FIXED_TO_FLOAT(cv_fov.value); - float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right? - float render_multiplier = 64.0f / render_fovratio / RMUL; - if (tilt > 90.0f) tilt = 90.0f; @@ -343,22 +333,28 @@ angle_t gld_FrustumAngle(angle_t tiltangle) // ok, this is a gross hack that barely works... // but at least it doesn't overestimate too much... - floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * (float)render_fov * 48.0f / render_multiplier / 90.0f; - a1 = ANG1 * (int)floatangle; - if (a1 >= ANGLE_180) + clipfov = atan(1 / projMatrix[0]) * 360 / M_PIl; + floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * clipfov / 90.0f; + if (floatangle >= 180.0) return 0xffffffff; + a1 = ANG1 * (int)floatangle; return a1; } + // SRB2CB I don't think used any of this stuff, let's disable for now since SRB2 probably doesn't want it either // compiler complains about (p)glGetFloatv anyway, in case anyone wants this // only r_opengl.c can use the base gl funcs as it turns out, that's a problem for whoever wants sphere frustum checks // btw to renable define HAVE_SPHEREFRUSTRUM in hw_clip.h #ifdef HAVE_SPHEREFRUSTRUM // -// gld_FrustrumSetup +// gld_FrustumSetup // +static GLdouble viewMatrix[16]; +static GLdouble projMatrix[16]; +float frustum[6][4]; + #define CALCMATRIX(a, b, c, d, e, f, g, h)\ (float)(viewMatrix[a] * projMatrix[b] + \ viewMatrix[c] * projMatrix[d] + \ @@ -375,7 +371,7 @@ frustum[i][1] /= t; \ frustum[i][2] /= t; \ frustum[i][3] /= t -void gld_FrustrumSetup(void) +void gld_FrustumSetup(void) { float t; float clip[16]; diff --git a/src/hardware/hw_clip.h b/src/hardware/hw_clip.h index 27a2ed1ef..dfaa87f81 100644 --- a/src/hardware/hw_clip.h +++ b/src/hardware/hw_clip.h @@ -19,6 +19,6 @@ void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle); void gld_clipper_Clear(void); angle_t gld_FrustumAngle(angle_t tiltangle); #ifdef HAVE_SPHEREFRUSTRUM -void gld_FrustrumSetup(void); +void gld_FrustumSetup(void); boolean gld_SphereInFrustum(float x, float y, float z, float radius); #endif diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index f5d0c9a18..b7c46b2e1 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -165,7 +165,6 @@ typedef struct FLOAT s,t; } FOutVector; -#ifdef GL_SHADERS // Shader targets used to render specific types of geometry. // A shader target is resolved to an actual shader with HWR_GetShaderFromTarget. // The shader returned may be a base shader or a custom shader. @@ -203,7 +202,6 @@ enum hwdshaderstage typedef enum hwdshaderstage hwdshaderstage_t; -#endif // ========================================================================== // RENDER MODES diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8ff2ca972..ee0fd0b85 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -234,7 +234,7 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { - if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) + if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); @@ -385,7 +385,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { - if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) + if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index df4d431f9..7d58dc495 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -59,7 +59,7 @@ EXPORT void HWRAPI(FlushScreenTextures) (void); EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd); EXPORT void HWRAPI(DrawScreenTexture) (int tex, FSurfaceInfo *surf, FBITFIELD polyflags); EXPORT void HWRAPI(MakeScreenTexture) (int tex); -EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, int width, int height); +EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, INT32 width, INT32 height); EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 742fd82ae..a5b66a429 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -92,8 +92,6 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); -void HWR_RenderDrawNodes(void); - // -------- // hw_shaders.c // -------- diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bb80441af..4c1d34dde 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -15,6 +15,8 @@ #include "../doomstat.h" +#include "../qs22j.h" + #ifdef HWRENDER #include "hw_main.h" #include "hw_glob.h" @@ -44,10 +46,7 @@ #include "../i_system.h" #include "../m_cheat.h" #include "../m_argv.h" // parm functions for msaa - -#ifdef ESLOPE #include "../p_slopes.h" -#endif #include // qsort @@ -77,62 +76,6 @@ static void CV_grshaders_OnChange(void); static void CV_grpaletterendering_OnChange(void); static void CV_grpalettedepth_OnChange(void); -static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "Standard"}, {2, "Smooth"}, {0, NULL}}; - -static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"}, - {HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"}, - {HWD_SET_TEXTUREFILTER_MIXED1, "Linear_Nearest"}, - {HWD_SET_TEXTUREFILTER_MIXED2, "Nearest_Linear"}, - {HWD_SET_TEXTUREFILTER_MIXED3, "Nearest_Mipmap"}, - {0, NULL}}; -CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; - -consvar_t cv_grfiltermode = {"gr_filtermode", "Nearest", CV_CALL|CV_SAVE, grfiltermode_cons_t, - CV_filtermode_ONChange, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_granisotropicmode = {"gr_anisotropicmode", "1", CV_CALL|CV_SAVE, granisotropicmode_cons_t, - CV_anisotropic_ONChange, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_grcorrecttricks = {"gr_correcttricks", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_grfofcut = {"gr_fofcut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_fofzfightfix = {"fofzfightfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_splitwallfix = {"splitwallfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_slopepegfix = {"slopepegfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -static CV_PossibleValue_t grrenderdistance_cons_t[] = { - {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, - {6, "12288"}, {7, "16384"}, {0, NULL}}; -consvar_t cv_grrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, grrenderdistance_cons_t, - NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_grportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nostencil = {"nostencil", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_portalline = {"portalline", "0", 0, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_portalonly = {"portalonly", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -CV_PossibleValue_t secbright_cons_t[] = {{0, "MIN"}, {255, "MAX"}, {0, NULL}}; - -consvar_t cv_secbright = {"secbright", "0", CV_SAVE, secbright_cons_t, - NULL, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - - -// values for the far clipping plane -static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; -// values for bsp culling -// slightly higher than the far clipping plane to compensate for impreciseness -static INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, - (6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT}; - -static INT32 current_bsp_culling_distance = 0; - // The current screen texture implementation is inefficient and disabling it can result in significant // performance gains on lower end hardware. The game is still quite playable without this functionality. // Features that break when disabling this: @@ -142,26 +85,58 @@ static INT32 current_bsp_culling_distance = 0; consvar_t cv_grscreentextures = {"gr_screentextures", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_screentextures_ONChange, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t grshaders_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Ignore custom shaders"}, {0, NULL}}; -consvar_t cv_grshaders = {"gr_shaders", "On", CV_CALL|CV_SAVE, grshaders_cons_t, CV_grshaders_OnChange, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_grpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_grpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; - -static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 bits"}, {0, NULL}}; -consvar_t cv_grpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_grpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; - -consvar_t cv_grflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_grpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_grmdls = {"gr_mdls", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grfallbackplayermodel = {"gr_fallbackplayermodel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grshearing = {"gr_shearing", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t grshaders_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Ignore custom shaders"}, {0, NULL}}; +consvar_t cv_grshaders = {"gr_shaders", "On", CV_CALL|CV_SAVE, grshaders_cons_t, CV_grshaders_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_grpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 bits"}, {0, NULL}}; +consvar_t cv_grpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_grpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_grpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "Standard"}, {2, "Smooth"}, {0, NULL}}; consvar_t cv_grfakecontrast = {"gr_fakecontrast", "Standard", CV_SAVE, grfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grslopecontrast = {"gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +CV_PossibleValue_t secbright_cons_t[] = {{0, "MIN"}, {255, "MAX"}, {0, NULL}}; +consvar_t cv_secbright = {"secbright", "0", CV_SAVE, secbright_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grhorizonlines = {"gr_horizonlines", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"}, + {HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"}, + {HWD_SET_TEXTUREFILTER_MIXED1, "Linear_Nearest"}, + {HWD_SET_TEXTUREFILTER_MIXED2, "Nearest_Linear"}, + {HWD_SET_TEXTUREFILTER_MIXED3, "Nearest_Mipmap"}, + {0, NULL}}; +CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; +consvar_t cv_grfiltermode = {"gr_filtermode", "Nearest", CV_CALL|CV_SAVE, grfiltermode_cons_t, + CV_filtermode_ONChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_granisotropicmode = {"gr_anisotropicmode", "1", CV_CALL|CV_SAVE, granisotropicmode_cons_t, + CV_anisotropic_ONChange, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t grrenderdistance_cons_t[] = { + {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, + {6, "12288"}, {7, "16384"}, {0, NULL}}; +consvar_t cv_grrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, grrenderdistance_cons_t, + NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grshearing = {"gr_shearing", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nostencil = {"nostencil", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_portalline = {"portalline", "0", 0, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_portalonly = {"portalonly", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grhorizonlines = {"gr_horizonlines", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grfofcut = {"gr_fofcut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fofzfightfix = {"fofzfightfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_splitwallfix = {"splitwallfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_slopepegfix = {"slopepegfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #define ONLY_IF_GL_LOADED if (vid.glstate != VID_GL_LIBRARY_LOADED) return; @@ -216,7 +191,7 @@ static void CV_grpalettedepth_OnChange(void) // void HWR_SetShaderState(void) { - HWD.pfnSetSpecialState(HWD_SET_SHADERS, (INT32)HWR_UseShader()); + HWD.pfnSetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); } // ========================================================================== @@ -241,7 +216,6 @@ static float gr_windowcentery; static float gr_pspritexscale, gr_pspriteyscale; - static seg_t *gr_curline; static side_t *gr_sidedef; static line_t *gr_linedef; @@ -267,6 +241,15 @@ ps_metric_t ps_hw_numcolors = {0}; ps_metric_t ps_hw_batchsorttime = {0}; ps_metric_t ps_hw_batchdrawtime = {0}; +// values for the far clipping plane +static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; +// values for bsp culling +// slightly higher than the far clipping plane to compensate for impreciseness +static INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, + (6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT}; + +static INT32 current_bsp_culling_distance = 0; + // ========================================================================== // View position // ========================================================================== @@ -277,8 +260,6 @@ FTransform atransform; static float gr_viewx, gr_viewy, gr_viewz; float gr_viewsin, gr_viewcos; -static fixed_t dup_viewx, dup_viewy, dup_viewz; - static angle_t gr_aimingangle; static float gr_viewludsin, gr_viewludcos; @@ -656,9 +637,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc angle_t angle = 0; FSurfaceInfo Surf; fixed_t tempxsow, tempytow; -#ifdef ESLOPE pslope_t *slope = NULL; -#endif static FOutVector *planeVerts = NULL; static UINT16 numAllocedPlaneVerts = 0; @@ -668,8 +647,13 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc // no convex poly were generated for this subsector if (!xsub->planepoly) return; + + pv = xsub->planepoly->pts; + nrPlaneVerts = xsub->planepoly->numpts; + + if (nrPlaneVerts < 3) //not even a triangle ? + return; -#ifdef ESLOPE // Get the slope pointer to simplify future code if (FOFsector) { @@ -689,16 +673,9 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc // Set fixedheight to the slope's height from our viewpoint, if we have a slope if (slope) fixedheight = P_GetZAt(slope, viewx, viewy); -#endif height = FIXED_TO_FLOAT(fixedheight); - pv = xsub->planepoly->pts; - nrPlaneVerts = xsub->planepoly->numpts; - - if (nrPlaneVerts < 3) //not even a triangle ? - return; - // Allocate plane-vertex buffer if we need to if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts) { @@ -776,10 +753,8 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc } } - if (angle) // Only needs to be done if there's an altered angle { - angle = InvAngle(angle)>>ANGLETOFINESHIFT; // This needs to be done so that it scrolls in a different direction after rotation like software @@ -823,10 +798,8 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc for (i = 0, v3d = planeVerts; i < nrPlaneVerts; i++,v3d++,pv++) SETUP3DVERT(v3d, pv->x, pv->y); -#ifdef ESLOPE if (slope) lightlevel = HWR_CalcSlopeLight(lightlevel, R_PointToAngle2(0, 0, slope->normal.x, slope->normal.y), abs(slope->zdelta)); -#endif HWR_Lighting(&Surf, lightlevel, planecolormap); @@ -868,7 +841,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc for (i = 0; i < subsector->numlines; i++, line++) { - if (line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(dup_viewx, dup_viewy, line) == 0) + if (line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(viewx, viewy, line) == 0) { P_ClosestPointOnLine(viewx, viewy, line->linedef, &v); dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y)); @@ -1044,7 +1017,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend if (HWR_UseShader()) { - shader = SHADER_WALL; // wall shader + shader = SHADER_WALL; blendmode |= PF_ColorMapped; } @@ -1055,7 +1028,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend blendmode &= ~PF_Masked; } - HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, shader, false); // wall shader + HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, shader, false); #ifdef WALLSPLATS if (gr_curline->linedef->splats && cv_splats.value) @@ -1074,18 +1047,14 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, float pegt, pegb, pegmul; float height = 0.0f, bheight = 0.0f; -#ifdef ESLOPE float endrealtop, endrealbot, endtop, endbot; float endpegt, endpegb, endpegmul; float endheight = 0.0f, endbheight = 0.0f; - - float diff; fixed_t v1x = FloatToFixed(wallVerts[0].x); fixed_t v1y = FloatToFixed(wallVerts[0].z); fixed_t v2x = FloatToFixed(wallVerts[1].x); fixed_t v2y = FloatToFixed(wallVerts[1].z); -#endif const UINT8 alpha = Surf->PolyColor.s.alpha; FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y); @@ -1093,34 +1062,30 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, realtop = top = wallVerts[3].y; realbot = bot = wallVerts[0].y; - - diff = top - bot; - pegt = wallVerts[3].t; pegb = wallVerts[0].t; // Lactozilla: If both heights of a side lay on the same position, then this wall is a triangle. // To avoid division by zero, which would result in a NaN, we check if the vertical difference // between the two vertices is not zero. - if (fpclassify(diff) == FP_ZERO) + if (fpclassify(top - bot) == FP_ZERO && cv_splitwallfix.value) pegmul = 0.0; else - pegmul = (pegb - pegt) / diff; + pegmul = (pegb - pegt) / (top - bot); -#ifdef ESLOPE endrealtop = endtop = wallVerts[2].y; - endrealbot = endbot = wallVerts[1].y; + endrealbot = endbot = wallVerts[1].y; endpegt = wallVerts[2].t; endpegb = wallVerts[1].t; - endpegmul = (endpegb - endpegt) / (endtop - endbot); -#endif + + if (fpclassify(endtop - endbot) == FP_ZERO && cv_splitwallfix.value) + endpegmul = 0.0; + else + endpegmul = (endpegb - endpegt) / (endtop - endbot); for (INT32 i = 0; i < sector->numlights; i++) { -#ifdef ESLOPE - if (endtop < endrealbot) -#endif - if (top < realbot) + if (endtop < endrealbot && top < realbot) return; lightlist_t *list = sector->lightlist; @@ -1170,114 +1135,62 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else solid = false; -#ifdef ESLOPE - if (list[i].slope) - { - height = FixedToFloat(P_GetZAt(list[i].slope, v1x, v1y)); - endheight = FixedToFloat(P_GetZAt(list[i].slope, v2x, v2y)); - } - else - height = endheight = FIXED_TO_FLOAT(list[i].height); - - if (solid) - { - if (*list[i].caster->b_slope) - { - bheight = FixedToFloat(P_GetZAt(*list[i].caster->b_slope, v1x, v1y)); - endbheight = FixedToFloat(P_GetZAt(*list[i].caster->b_slope, v2x, v2y)); - } - else - bheight = endbheight = FIXED_TO_FLOAT(*list[i].caster->bottomheight); - } -#else - height = FIXED_TO_FLOAT(list[i].height); - if (solid) - bheight = FIXED_TO_FLOAT(*list[i].caster->bottomheight); -#endif + height = FixedToFloat(P_GetLightZAt(&list[i], v1x, v1y)); + endheight = FixedToFloat(P_GetLightZAt(&list[i], v2x, v2y)); -#ifdef ESLOPE - if (endheight >= endtop) -#endif - if (height >= top) + if (solid) + { + bheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v1x, v1y)); + endbheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v2x, v2y)); + } + + if (endheight >= endtop && height >= top) { if (solid && top > bheight) top = bheight; -#ifdef ESLOPE if (solid && endtop > endbheight) endtop = endbheight; -#endif } -#ifdef ESLOPE if (i + 1 < sector->numlights) { - if (list[i+1].slope) - { - bheight = FixedToFloat(P_GetZAt(list[i+1].slope, v1x, v1y)); - endbheight = FixedToFloat(P_GetZAt(list[i+1].slope, v2x, v2y)); - } - else - bheight = endbheight = FIXED_TO_FLOAT(list[i+1].height); + bheight = FixedToFloat(P_GetLightZAt(&list[i+1], v1x, v1y)); + endbheight = FixedToFloat(P_GetLightZAt(&list[i+1], v2x, v2y)); } else { bheight = realbot; endbheight = endrealbot; } -#else - if (i + 1 < sector->numlights) + + if (cv_splitwallfix.value) { - bheight = FIXED_TO_FLOAT(list[i+1].height); + if (endbheight > endtop) + endbot = endtop; } + + if ((endbheight >= endtop && bheight >= top && !cv_splitwallfix.value) || (bheight >= top && cv_splitwallfix.value)) + continue; + + // Found a break + // The heights are clamped to ensure the polygon doesn't cross itself. + bot = bheight; + + if (bot < realbot) + bot = realbot; + + if (cv_splitwallfix.value) + endbot = min(max(endbheight, endrealbot), endtop); else { - bheight = realbot; + endbot = endbheight; + + if (endbot < endrealbot) + endbot = endrealbot; } -#endif - - if (cv_splitwallfix.value) - { -#ifdef ESLOPE - if (endbheight > endtop) - endbot = endtop; -#endif - if (bheight >= top) - continue; - - //Found a break; - bot = bheight; - - if (bot < realbot) - bot = realbot; - -#ifdef ESLOPE - endbot = min(max(endbheight, endrealbot), endtop); -#endif - }else{ -#ifdef ESLOPE - if (endbheight >= endtop) -#endif - if (bheight >= top) - continue; - - //Found a break; - bot = bheight; - - if (bot < realbot) - bot = realbot; - -#ifdef ESLOPE - endbot = endbheight; - - if (endbot < endrealbot) - endbot = endrealbot; -#endif - } - Surf->PolyColor.s.alpha = alpha; -#ifdef ESLOPE wallVerts[3].t = pegt + ((realtop - top) * pegmul); wallVerts[2].t = endpegt + ((endrealtop - endtop) * endpegmul); wallVerts[0].t = pegt + ((realtop - bot) * pegmul); @@ -1288,49 +1201,25 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, wallVerts[2].y = endtop; wallVerts[0].y = bot; wallVerts[1].y = endbot; -#else - wallVerts[3].t = wallVerts[2].t = pegt + ((realtop - top) * pegmul); - wallVerts[0].t = wallVerts[1].t = pegt + ((realtop - bot) * pegmul); - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = top; - wallVerts[0].y = wallVerts[1].y = bot; -#endif - if (cv_fofzfightfix.value) - { - if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); - else - HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); - }else{ - if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent, false, lightnum, colormap); - else - HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); - } - + if (cutflag & FF_FOG) + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); + else if (cutflag & FF_TRANSLUCENT) + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); + else + HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); top = bot; -#ifdef ESLOPE endtop = endbot; -#endif } bot = realbot; -#ifdef ESLOPE endbot = endrealbot; - if (endtop <= endrealbot) -#endif - if (top <= realbot) + if (endtop <= endrealbot && top <= realbot) return; Surf->PolyColor.s.alpha = alpha; -#ifdef ESLOPE wallVerts[3].t = pegt + ((realtop - top) * pegmul); wallVerts[2].t = endpegt + ((endrealtop - endtop) * endpegmul); wallVerts[0].t = pegt + ((realtop - bot) * pegmul); @@ -1341,31 +1230,13 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, wallVerts[2].y = endtop; wallVerts[0].y = bot; wallVerts[1].y = endbot; -#else - wallVerts[3].t = wallVerts[2].t = pegt + ((realtop - top) * pegmul); - wallVerts[0].t = wallVerts[1].t = pegt + ((realtop - bot) * pegmul); - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = top; - wallVerts[0].y = wallVerts[1].y = bot; -#endif - - if (cv_fofzfightfix.value) - { - if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); - else - HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); - }else{ - if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent, false, lightnum, colormap); - else - HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); - } + if (cutflag & FF_FOG) + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); + else if (cutflag & FF_TRANSLUCENT) + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); + else + HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); } // skywall list system for fixing portal issues by postponing skywall rendering (and using stencil buffer for them) @@ -1444,6 +1315,88 @@ void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) // PF_Occlude is set in HWR_ProjectWall to draw into the depth buffer } +// Returns true if the midtexture is visible, and false if... it isn't... +static boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) +{ + FUINT blendmode = PF_Masked; + + pSurf->PolyColor.s.alpha = 0xFF; + + if (!gr_curline->polyseg) + { + // set alpha for transparent walls + switch (gr_linedef->special) + { + case 900: + blendmode = HWR_TranstableToAlpha(tr_trans10, pSurf); + break; + case 901: + blendmode = HWR_TranstableToAlpha(tr_trans20, pSurf); + break; + case 902: + blendmode = HWR_TranstableToAlpha(tr_trans30, pSurf); + break; + case 903: + blendmode = HWR_TranstableToAlpha(tr_trans40, pSurf); + break; + case 904: + blendmode = HWR_TranstableToAlpha(tr_trans50, pSurf); + break; + case 905: + blendmode = HWR_TranstableToAlpha(tr_trans60, pSurf); + break; + case 906: + blendmode = HWR_TranstableToAlpha(tr_trans70, pSurf); + break; + case 907: + blendmode = HWR_TranstableToAlpha(tr_trans80, pSurf); + break; + case 908: + blendmode = HWR_TranstableToAlpha(tr_trans90, pSurf); + break; + // Translucent + case 102: + case 121: + case 123: + case 124: + case 125: + case 141: + case 142: + case 144: + case 145: + case 174: + case 175: + case 192: + case 195: + case 221: + case 253: + case 256: + blendmode = PF_Translucent; + break; + default: + blendmode = PF_Masked; + break; + } + } + else if (gr_curline->polyseg->translucency > 0) + { + // Polyobject translucency is shared between all of its lines + if (gr_curline->polyseg->translucency >= NUMTRANSMAPS) // wall not drawn + return false; + //Surf.PolyColor.s.alpha = 0x00; // This shouldn't draw anything regardless of blendmode + //blendmode = PF_Masked; + else + blendmode = HWR_TranstableToAlpha(gr_curline->polyseg->translucency, pSurf); + } + + if (blendmode != PF_Masked && pSurf->PolyColor.s.alpha == 0x00) + return false; + + pSurf->PolyFlags = blendmode; + + return true; +} + // // HWR_ProcessSeg // A portion or all of a wall segment will be drawn, from startfrac to endfrac, @@ -1458,29 +1411,23 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t worldtop, worldbottom; fixed_t worldhigh = 0, worldlow = 0; -#ifdef ESLOPE fixed_t worldtopslope, worldbottomslope; fixed_t worldhighslope = 0, worldlowslope = 0; fixed_t v1x, v1y, v2x, v2y; -#endif - GLMapTexture_t *grTex = NULL; float cliplow = 0.0f, cliphigh = 0.0f; - INT32 gr_midtexture; fixed_t h, l; // 3D sides and 2s middle textures -#ifdef ESLOPE fixed_t hS, lS; -#endif FUINT lightnum = 0; // shut up compiler extracolormap_t *colormap; FSurfaceInfo Surf; - + boolean noencore = false; gr_sidedef = gr_curline->sidedef; gr_linedef = gr_curline->linedef; - + if (gr_curline->pv1) { vs.x = ((polyvertex_t *)gr_curline->pv1)->x; @@ -1502,13 +1449,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom ve.y = FIXED_TO_FLOAT(gr_curline->v2->y); } -#ifdef ESLOPE v1x = FLOAT_TO_FIXED(vs.x); v1y = FLOAT_TO_FIXED(vs.y); v2x = FLOAT_TO_FIXED(ve.x); v2y = FLOAT_TO_FIXED(ve.y); -#endif -#ifdef ESLOPE #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ @@ -1519,10 +1463,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom SLOPEPARAMS(gr_frontsector->c_slope, worldtop, worldtopslope, gr_frontsector->ceilingheight) SLOPEPARAMS(gr_frontsector->f_slope, worldbottom, worldbottomslope, gr_frontsector->floorheight) -#else - worldtop = gr_frontsector->ceilingheight; - worldbottom = gr_frontsector->floorheight; -#endif // remember vertices ordering // 3--2 @@ -1537,40 +1477,37 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].z = wallVerts[1].z = ve.y; // x offset the texture - { - fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset; - cliplow = (float)texturehpeg; - cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); - } + fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset; + cliplow = (float)texturehpeg; + cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); if (HWR_ShouldUsePaletteRendering()) { lightnum = SOFTLIGHT(gr_frontsector->lightlevel); colormap = gr_frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); - }else{ + } + else + { lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = gr_frontsector->extra_colormap; } - + if (gr_linedef->flags & ML_TFERLINE) noencore = true; - if (gr_frontsector) - Surf.PolyColor.s.alpha = 255; + Surf.PolyColor.s.alpha = 255; + + INT32 gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); + GLMapTexture_t *grTex = NULL; + // two sided line if (gr_backsector) { INT32 gr_toptexture, gr_bottomtexture; - // two sided line -#ifdef ESLOPE SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight) -#else - worldhigh = gr_backsector->ceilingheight; - worldlow = gr_backsector->floorheight; -#endif // Sky culling if (!gr_curline->polyseg) // Don't do it for polyobjects @@ -1588,36 +1525,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom && (worldhigh != worldtop || worldhighslope != worldtopslope)) // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race { -#ifdef ESLOPE wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); -#else - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldhigh); -#endif HWR_DrawSkyWall(wallVerts, &Surf); } } else { // Only the frontsector is sky, just draw a skywall from the front ceiling -#ifdef ESLOPE wallVerts[0].y = FIXED_TO_FLOAT(worldtop); wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); -#else - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop); -#endif HWR_DrawSkyWall(wallVerts, &Surf); } } else if (gr_backsector->ceilingpic == skyflatnum) { // Only the backsector is sky, just draw a skywall from the front ceiling -#ifdef ESLOPE wallVerts[0].y = FIXED_TO_FLOAT(worldtop); wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); -#else - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop); -#endif HWR_DrawSkyWall(wallVerts, &Surf); } @@ -1637,42 +1562,26 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race && !(gr_sidedef->bottomtexture)) { -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldlow); wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); -#else - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(worldlow); -#endif - HWR_DrawSkyWall(wallVerts, &Surf); } } else { // Only the backsector has sky, just draw a skywall from the back floor -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); -#else - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(worldbottom); -#endif - HWR_DrawSkyWall(wallVerts, &Surf); } } else if ((gr_backsector->floorpic == skyflatnum) && !(gr_sidedef->bottomtexture)) { // Only the backsector has sky, just draw a skywall from the back floor if there's no bottomtexture -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldlow); wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); -#else - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(worldlow); -#endif - HWR_DrawSkyWall(wallVerts, &Surf); } - } // hack to allow height changes in outdoor areas @@ -1681,21 +1590,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom && gr_backsector->ceilingpic == skyflatnum) { worldtop = worldhigh; -#ifdef ESLOPE worldtopslope = worldhighslope; -#endif } gr_toptexture = R_GetTextureNum(gr_sidedef->toptexture); gr_bottomtexture = R_GetTextureNum(gr_sidedef->bottomtexture); // check TOP TEXTURE - if (( -#ifdef ESLOPE - worldhighslope < worldtopslope || -#endif - worldhigh < worldtop - ) && gr_toptexture) + if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gr_toptexture) { { fixed_t texturevpegtop; // top @@ -1705,15 +1607,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // PEGGING if (gr_linedef->flags & ML_DONTPEGTOP) texturevpegtop = 0; -#ifdef ESLOPE else if (gr_linedef->flags & ML_EFFECT1) texturevpegtop = worldhigh + textureheight[gr_sidedef->toptexture] - worldtop; else texturevpegtop = gr_backsector->ceilingheight + textureheight[gr_sidedef->toptexture] - gr_frontsector->ceilingheight; -#else - else - texturevpegtop = worldhigh + textureheight[gr_sidedef->toptexture] - worldtop; -#endif texturevpegtop += gr_sidedef->rowoffset; @@ -1725,7 +1622,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; -#ifdef ESLOPE // Adjust t value for sloped walls if (!(gr_linedef->flags & ML_EFFECT1)) { @@ -1748,19 +1644,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * grTex->scaleY; } -#endif } // set top/bottom coords -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); -#else - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldhigh); -#endif if (!gl_drawing_stencil && gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); @@ -1771,11 +1661,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // check BOTTOM TEXTURE - if (( -#ifdef ESLOPE - worldlowslope > worldbottomslope || -#endif - worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! + if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! { { fixed_t texturevpegbottom = 0; // bottom @@ -1783,19 +1669,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); // PEGGING -#ifdef ESLOPE if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) texturevpegbottom = 0; else if (gr_linedef->flags & ML_EFFECT1) texturevpegbottom = worldbottom - worldlow; else texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; -#else - if (gr_linedef->flags & ML_DONTPEGBOTTOM) - texturevpegbottom = worldbottom - worldlow; - else - texturevpegbottom = 0; -#endif texturevpegbottom += gr_sidedef->rowoffset; @@ -1807,7 +1686,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; -#ifdef ESLOPE // Adjust t value for sloped walls if (!(gr_linedef->flags & ML_EFFECT1)) { @@ -1830,19 +1708,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; } -#endif } // set top/bottom coords -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldlow); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); -#else - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldlow); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldbottom); -#endif if (!gl_drawing_stencil && gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); @@ -1851,8 +1723,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } - gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); - if (gr_midtexture || gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH || gl_drawing_stencil) + + if ((gr_midtexture && HWR_BlendMidtextureSurface(&Surf)) || gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH || gl_drawing_stencil) { sector_t *front, *back; INT32 repeats; @@ -1901,7 +1773,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // heights of the polygon, and h & l, are the final (clipped) // poly coords. -#ifdef POLYOBJECTS // NOTE: With polyobjects, whenever you need to check the properties of the polyobject sector it belongs to, // you must use the linedef's backsector to be correct // From CB @@ -1911,21 +1782,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom popenbottom = popenbottomslope = back->floorheight; } else -#endif { -#ifdef ESLOPE popentop = min(worldtop, worldhigh); popenbottom = max(worldbottom, worldlow); popentopslope = min(worldtopslope, worldhighslope); popenbottomslope = max(worldbottomslope, worldlowslope); -#else - popentop = min(front->ceilingheight, back->ceilingheight); - popenbottom = max(front->floorheight, back->floorheight); -#endif } -#ifdef ESLOPE if (gr_linedef->flags & ML_EFFECT2) { if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) @@ -1944,9 +1808,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) -#else - if (gr_linedef->flags & ML_DONTPEGBOTTOM) -#endif { polybottom = popenbottom + gr_sidedef->rowoffset; polytop = polybottom + midtexheight; @@ -1963,7 +1824,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // CB -#ifdef POLYOBJECTS // NOTE: With polyobjects, whenever you need to check the properties of the polyobject sector it belongs to, // you must use the linedef's backsector to be correct if (gr_curline->polyseg) @@ -1973,7 +1833,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lowcutslope = polybottomslope; highcutslope = polytopslope; } -#endif else { // The cut-off values of a linedef can always be constant, since every line has an absoulute front and or back sector @@ -2024,11 +1883,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // PEGGING -#ifdef ESLOPE if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) -#else - if (gr_linedef->flags & ML_DONTPEGBOTTOM) -#endif texturevpeg = textureheight[gr_sidedef->midtexture]*repeats - h + polybottom; else texturevpeg = polytop - h; @@ -2044,7 +1899,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(h); wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(l); -#ifdef ESLOPE // Correct to account for slopes { fixed_t midtextureslant; @@ -2087,77 +1941,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(h); wallVerts[1].y = FIXED_TO_FLOAT(l); } -#endif } - // set alpha for transparent walls (new boom and legacy linedef types) - FBITFIELD blendmode; - - switch (gr_linedef->special) - { - case 900: - blendmode = HWR_TranstableToAlpha(tr_trans10, &Surf); - break; - case 901: - blendmode = HWR_TranstableToAlpha(tr_trans20, &Surf); - break; - case 902: - blendmode = HWR_TranstableToAlpha(tr_trans30, &Surf); - break; - case 903: - blendmode = HWR_TranstableToAlpha(tr_trans40, &Surf); - break; - case 904: - blendmode = HWR_TranstableToAlpha(tr_trans50, &Surf); - break; - case 905: - blendmode = HWR_TranstableToAlpha(tr_trans60, &Surf); - break; - case 906: - blendmode = HWR_TranstableToAlpha(tr_trans70, &Surf); - break; - case 907: - blendmode = HWR_TranstableToAlpha(tr_trans80, &Surf); - break; - case 908: - blendmode = HWR_TranstableToAlpha(tr_trans90, &Surf); - break; - // Translucent - case 102: - case 121: - case 123: - case 124: - case 125: - case 141: - case 142: - case 144: - case 145: - case 174: - case 175: - case 192: - case 195: - case 221: - case 253: - case 256: - blendmode = PF_Translucent; - break; - default: - blendmode = PF_Masked; - break; - } - -#ifdef POLYOBJECTS - if (gr_curline->polyseg && gr_curline->polyseg->translucency > 0) - { - if (gr_curline->polyseg->translucency >= NUMTRANSMAPS) // wall not drawn - { - Surf.PolyColor.s.alpha = 0x00; // This shouldn't draw anything regardless of blendmode - blendmode = PF_Masked; - } - else - blendmode = HWR_TranstableToAlpha(gr_curline->polyseg->translucency, &Surf); - } -#endif + // TODO: Actually use the surface's flags so that I don't have to do this + FUINT blendmode = Surf.PolyFlags; // Render midtextures on two-sided lines with a z-buffer offset. // This will cause the midtexture appear on top, if a FOF overlaps with it. @@ -2166,22 +1953,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (!gl_drawing_stencil && gr_frontsector->numlights) { - if (cv_fofzfightfix.value) - { - if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); - else - { - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, PF_Decal); - } - }else{ - if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, 0); - else - { - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); - } - } + if (!(blendmode & PF_Masked)) + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, cv_fofzfightfix.value ? PF_Decal : 0); + else + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, cv_fofzfightfix.value ? PF_Decal : 0); } else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); @@ -2192,18 +1967,15 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // Single sided line... Deal only with the middletexture (if one exists) - gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); + if (gr_midtexture && gr_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL { { fixed_t texturevpeg; // PEGGING -#ifdef ESLOPE if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; - else -#endif - if (gr_linedef->flags & ML_DONTPEGBOTTOM) + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; else // top of texture at top @@ -2216,7 +1988,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; -#ifdef ESLOPE // Texture correction for slopes if (gr_linedef->flags & ML_EFFECT2) { wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; @@ -2230,19 +2001,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; } -#endif } -#ifdef ESLOPE //Set textures properly on single sided walls that are sloped wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); -#else - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldbottom); -#endif if (gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); @@ -2257,23 +2021,16 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } else { -#ifdef ESLOPE //Set textures properly on single sided walls that are sloped wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); -#else - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldbottom); -#endif // When there's no midtexture, draw a skywall to prevent rendering behind it HWR_DrawSkyWall(wallVerts, &Surf); } - // Single sided lines are simple for skywalls, just need to draw from the top or bottom of the sector if there's // a sky flat if (!gr_curline->polyseg) @@ -2281,22 +2038,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gr_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector { wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(INT32_MAX); -#ifdef ESLOPE wallVerts[0].y = FIXED_TO_FLOAT(worldtop); wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); -#else - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop); -#endif HWR_DrawSkyWall(wallVerts, &Surf); } if (gr_frontsector->floorpic == skyflatnum) { -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); -#else - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(worldbottom); -#endif wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); HWR_DrawSkyWall(wallVerts, &Surf); @@ -2304,7 +2053,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } - //Hurdler: 3d-floors test if (!gl_drawing_stencil && gr_frontsector && gr_backsector && gr_frontsector->tag != gr_backsector->tag && (gr_backsector->ffloors || gr_frontsector->ffloors)) { @@ -2333,7 +2081,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom highcutslope = min(worldtopslope, worldhighslope); } - if (gr_backsector->ffloors) { for (rover = gr_backsector->ffloors; rover; rover = rover->next) @@ -2355,23 +2102,20 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom continue; } - texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); if (rover->master->flags & ML_TFERLINE) { - size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); + size_t linenum = min((size_t)(gr_curline->linedef-gr_backsector->lines[0]), rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } -#ifdef ESLOPE - h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight; - hS = *rover->t_slope ? P_GetZAt(*rover->t_slope, v2x, v2y) : *rover->topheight; - l = *rover->b_slope ? P_GetZAt(*rover->b_slope, v1x, v1y) : *rover->bottomheight; - lS = *rover->b_slope ? P_GetZAt(*rover->b_slope, v2x, v2y) : *rover->bottomheight; - - + h = P_GetFFloorTopZAt (rover, v1x, v1y); + hS = P_GetFFloorTopZAt (rover, v2x, v2y); + l = P_GetFFloorBottomZAt(rover, v1x, v1y); + lS = P_GetFFloorBottomZAt(rover, v2x, v2y); + if (!cv_grfofcut.value) { if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) @@ -2394,7 +2138,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } - //Hurdler: HW code starts here //FIXME: check if peging is correct // set top/bottom coords @@ -2403,19 +2146,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(hS); wallVerts[0].y = FIXED_TO_FLOAT(l); wallVerts[1].y = FIXED_TO_FLOAT(lS); -#else - h = *rover->topheight; - l = *rover->bottomheight; - if (h > highcut) - h = highcut; - if (l < lowcut) - l = lowcut; - //Hurdler: HW code starts here - //FIXME: check if peging is correct - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(l); -#endif + if (rover->flags & FF_FOG) { wallVerts[3].t = wallVerts[2].t = 0; @@ -2427,9 +2158,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { fixed_t texturevpeg; boolean attachtobottom = false; -#ifdef ESLOPE boolean slopeskew = false; // skew FOF walls with slopes? -#endif // Wow, how was this missing from OpenGL for so long? // ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software @@ -2438,22 +2167,17 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { texturevpeg = sides[newline->sidenum[0]].rowoffset; attachtobottom = !!(newline->flags & ML_DONTPEGBOTTOM); -#ifdef ESLOPE slopeskew = !!(newline->flags & ML_DONTPEGTOP); -#endif } else { texturevpeg = sides[rover->master->sidenum[0]].rowoffset; attachtobottom = !!(gr_linedef->flags & ML_DONTPEGBOTTOM); -#ifdef ESLOPE slopeskew = !!(rover->master->flags & ML_DONTPEGTOP); -#endif } grTex = HWR_GetTexture(texnum, noencore); -#ifdef ESLOPE if (!slopeskew) // no skewing { if (attachtobottom) @@ -2478,12 +2202,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].t = wallVerts[1].t - (hS - lS) * grTex->scaleY; } } -#else - if (attachtobottom) - texturevpeg -= *rover->topheight - *rover->bottomheight; - wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + texturevpeg) * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (*rover->topheight - l + texturevpeg) * grTex->scaleY; -#endif wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; @@ -2560,16 +2278,16 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->master->flags & ML_TFERLINE) { - size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); + size_t linenum = min((size_t)(gr_curline->linedef-gr_backsector->lines[0]), rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } -#ifdef ESLOPE //backsides - h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight; - hS = *rover->t_slope ? P_GetZAt(*rover->t_slope, v2x, v2y) : *rover->topheight; - l = *rover->b_slope ? P_GetZAt(*rover->b_slope, v1x, v1y) : *rover->bottomheight; - lS = *rover->b_slope ? P_GetZAt(*rover->b_slope, v2x, v2y) : *rover->bottomheight; - + + h = P_GetFFloorTopZAt (rover, v1x, v1y); + hS = P_GetFFloorTopZAt (rover, v2x, v2y); + l = P_GetFFloorBottomZAt(rover, v1x, v1y); + lS = P_GetFFloorBottomZAt(rover, v2x, v2y); + if (!cv_grfofcut.value) { if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) @@ -2600,19 +2318,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(hS); wallVerts[0].y = FIXED_TO_FLOAT(l); wallVerts[1].y = FIXED_TO_FLOAT(lS); -#else - h = *rover->topheight; - l = *rover->bottomheight; - if (h > highcut) - h = highcut; - if (l < lowcut) - l = lowcut; - //Hurdler: HW code starts here - //FIXME: check if peging is correct - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(l); -#endif + if (rover->flags & FF_FOG) { wallVerts[3].t = wallVerts[2].t = 0; @@ -2669,7 +2375,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; + Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); } if (gr_backsector->numlights) @@ -2705,7 +2411,6 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) // GZDoom method of sloped line clipping -#ifdef ESLOPE if (afrontsector->f_slope || afrontsector->c_slope || abacksector->f_slope || abacksector->c_slope) { fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t @@ -2745,7 +2450,6 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) #undef SLOPEPARAMS } else -#endif { frontf1 = frontf2 = afrontsector->floorheight; frontc1 = frontc2 = afrontsector->ceilingheight; @@ -2841,7 +2545,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) // HWR_AddLine // Clips the given segment and adds any visible pieces to the line list. -void HWR_AddLine(seg_t *line) +static void HWR_AddLine(seg_t *line) { angle_t angle1, angle2; @@ -2851,10 +2555,9 @@ void HWR_AddLine(seg_t *line) fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t boolean dont_draw = false; -#ifdef POLYOBJECTS + if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) return; -#endif gr_curline = line; @@ -2880,8 +2583,28 @@ void HWR_AddLine(seg_t *line) } // OPTIMIZE: quickly reject orthogonal back sides. - angle1 = R_PointToAngle64(v1x, v1y); - angle2 = R_PointToAngle64(v2x, v2y); + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(v1x, v1y); + angle2 = R_PointToAngle64(v2x, v2y); + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, v1x, v1y); + angle2 = R_PointToAngleEx(viewx, viewy, v2x, v2y); + } + + // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! + if (angle2 - angle1 < ANGLE_180) + return; + + // PrBoom: use REAL clipping math YAYYYYYYY!!! + if (!gld_clipper_SafeCheckRange(angle2, angle1)) + return; + + checkforemptylines = true; + + gr_backsector = line->backsector; // do an extra culling check when rendering portals // check if any line vertex is on the viewable side of the portal target line @@ -2915,18 +2638,6 @@ void HWR_AddLine(seg_t *line) goto doaddline; } - // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! - if (angle2 - angle1 < ANGLE_180) - return; - - // PrBoom: use REAL clipping math YAYYYYYYY!!! - if (!gld_clipper_SafeCheckRange(angle2, angle1)) - return; - - checkforemptylines = true; - - gr_backsector = line->backsector; - if (line->linedef->special == 40) { if (line->side == 0) @@ -2956,6 +2667,7 @@ doaddline: else { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); + if (CheckClip(gr_frontsector, gr_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); @@ -2982,7 +2694,7 @@ doaddline: // // modified to use local variables -boolean HWR_CheckBBox(fixed_t *bspcoord) +static boolean HWR_CheckBBox(const fixed_t *bspcoord) { INT32 boxpos; fixed_t px1, py1, px2, py2; @@ -3076,12 +2788,20 @@ boolean HWR_CheckBBox(fixed_t *bspcoord) if (mindist > current_bsp_culling_distance) return false; } - angle1 = R_PointToAngle64(px1, py1); - angle2 = R_PointToAngle64(px2, py2); + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(px1, py1); + angle2 = R_PointToAngle64(px2, py2); + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, px1, py1); + angle2 = R_PointToAngleEx(viewx, viewy, px2, py2); + } + return gld_clipper_SafeCheckRange(angle2, angle1); } -#ifdef POLYOBJECTS // // HWR_AddPolyObjectSegs @@ -3120,7 +2840,6 @@ void HWR_AddPolyObjectSegs(void) } } -#ifdef POLYOBJECTS_PLANES void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap) { float height; //constant y for all points on the convex flat polygon @@ -3353,15 +3072,54 @@ void HWR_AddPolyObjectPlanes(void) } } } -#endif -#endif + + +// +// HWR_DoCulling +// Hardware version of R_DoCulling +// (see r_main.c) +static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float vz, float bottomh, float toph) +{ + float cullplane; + + if (!cullheight) + return false; + + cullplane = FIXED_TO_FLOAT(cullheight->frontsector->floorheight); + if (cullheight->flags & ML_NOCLIMB) // Group culling + { + if (!viewcullheight) + return false; + + // Make sure this is part of the same group + if (viewcullheight->frontsector == cullheight->frontsector) + { + // OK, we can cull + if (vz > cullplane && toph < cullplane) // Cull if below plane + return true; + + if (bottomh > cullplane && vz <= cullplane) // Cull if above plane + return true; + } + } + else // Quick culling + { + if (vz > cullplane && toph < cullplane) // Cull if below plane + return true; + + if (bottomh > cullplane && vz <= cullplane) // Cull if above plane + return true; + } + + return false; +} // -----------------+ // HWR_Subsector : Determine floor/ceiling planes. // : Add sprites of things in sector. // : Draw one or more line segments. // -----------------+ -void HWR_Subsector(size_t num) +static void HWR_Subsector(size_t num) { INT16 count; seg_t *line; @@ -3416,46 +3174,10 @@ void HWR_Subsector(size_t num) floorcolormap = ceilingcolormap = gr_frontsector->extra_colormap; -// ----- for special tricks with HW renderer ----- - if (gr_frontsector->pseudoSector) - { - cullFloorHeight = locFloorHeight = gr_frontsector->virtualFloorheight; - cullCeilingHeight = locCeilingHeight = gr_frontsector->virtualCeilingheight; - } - else if (gr_frontsector->virtualFloor) - { - ///@TODO Is this whole virtualFloor mess even useful? I don't think it even triggers ever. - cullFloorHeight = locFloorHeight = gr_frontsector->virtualFloorheight; - if (gr_frontsector->virtualCeiling) - cullCeilingHeight = locCeilingHeight = gr_frontsector->virtualCeilingheight; - else - cullCeilingHeight = locCeilingHeight = gr_frontsector->ceilingheight; - } - else if (gr_frontsector->virtualCeiling) - { - cullCeilingHeight = locCeilingHeight = gr_frontsector->virtualCeilingheight; - cullFloorHeight = locFloorHeight = gr_frontsector->floorheight; - } - else - { - cullFloorHeight = locFloorHeight = gr_frontsector->floorheight; - cullCeilingHeight = locCeilingHeight = gr_frontsector->ceilingheight; - -#ifdef ESLOPE - if (gr_frontsector->f_slope) - { - cullFloorHeight = P_GetZAt(gr_frontsector->f_slope, viewx, viewy); - locFloorHeight = P_GetZAt(gr_frontsector->f_slope, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - } - - if (gr_frontsector->c_slope) - { - cullCeilingHeight = P_GetZAt(gr_frontsector->c_slope, viewx, viewy); - locCeilingHeight = P_GetZAt(gr_frontsector->c_slope, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - } -#endif - } -// ----- end special tricks ----- + cullFloorHeight = P_GetSectorFloorZAt (gr_frontsector, viewx, viewy); + cullCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, viewx, viewy); + locFloorHeight = P_GetSectorFloorZAt (gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); + locCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); if (gr_frontsector->ffloors) { @@ -3537,34 +3259,36 @@ void HWR_Subsector(size_t num) for (rover = gr_frontsector->ffloors; rover; rover = rover->next) { - fixed_t cullHeight, centerHeight; - - // bottom plane -#ifdef ESLOPE - if (*rover->b_slope) - { - cullHeight = P_GetZAt(*rover->b_slope, viewx, viewy); - centerHeight = P_GetZAt(*rover->b_slope, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - } - else -#endif - cullHeight = centerHeight = *rover->bottomheight; + fixed_t bottomCullHeight, topCullHeight, centerHeight; if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) continue; if (sub->validcount == validcount) continue; + + // rendering heights for bottom and top planes + // yes there were functions for this stuff, no idea why it wasnt used but bleh + bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); + topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - if (centerHeight <= locCeilingHeight && - centerHeight >= locFloorHeight && - ((viewz < cullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > cullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + if (gr_frontsector->cullheight) + { + if (HWR_DoCulling(gr_frontsector->cullheight, viewsector->cullheight, gr_viewz, FIXED_TO_FLOAT(*rover->bottomheight), FIXED_TO_FLOAT(*rover->topheight))) + continue; + } + + // bottom plane + centerHeight = P_GetFFloorBottomZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); + + if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight && + ((viewz < bottomCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { UINT8 alpha; - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); @@ -3578,7 +3302,7 @@ void HWR_Subsector(size_t num) } else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) // SoM: Flags are more efficient { - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum, &extrasubsectors[num], false, @@ -3590,33 +3314,25 @@ void HWR_Subsector(size_t num) else { HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gr_frontsector, false)); - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->bottompic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } } // top plane -#ifdef ESLOPE - if (*rover->t_slope) - { - cullHeight = P_GetZAt(*rover->t_slope, viewx, viewy); - centerHeight = P_GetZAt(*rover->t_slope, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - } - else -#endif - cullHeight = centerHeight = *rover->topheight; + centerHeight = P_GetFFloorTopZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight && - ((viewz > cullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < cullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + ((viewz > topCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { UINT8 alpha; - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false); alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); @@ -3630,7 +3346,7 @@ void HWR_Subsector(size_t num) } else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false); HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, &extrasubsectors[num], true, @@ -3642,7 +3358,7 @@ void HWR_Subsector(size_t num) else { HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, true)); - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false); HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->toppic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } @@ -3650,7 +3366,6 @@ void HWR_Subsector(size_t num) } } -#ifdef POLYOBJECTS // Draw all the polyobjects in this subsector if (sub->polyList) { @@ -3674,15 +3389,12 @@ void HWR_Subsector(size_t num) // Draw polyobject lines. HWR_AddPolyObjectSegs(); -#ifdef POLYOBJECTS_PLANES if (sub->validcount != validcount) // This validcount situation seems to let us know that the floors have already been drawn. { // Draw polyobject planes HWR_AddPolyObjectPlanes(); } -#endif } -#endif skip_stuff_for_portals: @@ -3707,9 +3419,7 @@ skip_stuff_for_portals: while (count--) { -#ifdef POLYOBJECTS if (!line->polyseg) // ignore segs that belong to polyobjects -#endif HWR_AddLine(line); line++; } @@ -3737,7 +3447,7 @@ skip_stuff_for_portals: // use returned value as multiplier for the added values from p_thrust thing // P_InterceptVector needs divlines which need dx and dy, dx=x2-x1 dy=y2-y1 -static boolean HWR_PortalCheckBBox(fixed_t *bspcoord) +static boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) { vertex_t closest_point; if (!portalclipline) @@ -3782,44 +3492,37 @@ static boolean HWR_PortalCheckBBox(fixed_t *bspcoord) // traversing subtree recursively. // Just call with BSP root. -void HWR_RenderBSPNode(INT32 bspnum) +static void HWR_RenderBSPNode(INT32 bspnum) { - node_t *bsp = &nodes[bspnum]; - - // Decide which side the view point is on - INT32 side; - ps_numbspcalls.value.i++; - // Found a subsector? - if (bspnum & NF_SUBSECTOR) + while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? { - // PORTAL CULLING - if (portalclipline) - { - sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector; - if (portalcullsector) - { - if (sect != portalcullsector) - return; - portalcullsector = NULL; - } - } - if (bspnum != -1) - HWR_Subsector(bspnum&(~NF_SUBSECTOR)); - return; + const node_t *bsp = &nodes[bspnum]; + + // Decide which side the view point is on. + INT32 side = R_PointOnSide(viewx, viewy, bsp); + + // Recursively divide front space. + if (HWR_PortalCheckBBox(bsp->bbox[side])) + HWR_RenderBSPNode(bsp->children[side]); + + // Possibly divide back space + if (!(HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1]))) + return; + + bspnum = bsp->children[side^1]; } - // Decide which side the view point is on. - side = R_PointOnSide(viewx, viewy, bsp); - - // Recursively divide front space. - if (HWR_PortalCheckBBox(bsp->bbox[side])) - HWR_RenderBSPNode(bsp->children[side]); - - // Possibly divide back space. - if (HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1])) - HWR_RenderBSPNode(bsp->children[side^1]); + // PORTAL CULLING + if (portalclipline && portalcullsector) + { + if (portalcullsector != subsectors[bspnum & ~NF_SUBSECTOR].sector) + return; + portalcullsector = NULL; + } + // e6y: support for extended nodes + HWR_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR); } // ========================================================================== @@ -3896,45 +3599,6 @@ static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t hei return floorz; } -// -// HWR_DoCulling -// Hardware version of R_DoCulling -// (see r_main.c) -static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float vz, float bottomh, float toph) -{ - float cullplane; - - if (!cullheight) - return false; - - cullplane = FIXED_TO_FLOAT(cullheight->frontsector->floorheight); - if (cullheight->flags & ML_NOCLIMB) // Group culling - { - if (!viewcullheight) - return false; - - // Make sure this is part of the same group - if (viewcullheight->frontsector == cullheight->frontsector) - { - // OK, we can cull - if (vz > cullplane && toph < cullplane) // Cull if below plane - return true; - - if (bottomh > cullplane && vz <= cullplane) // Cull if above plane - return true; - } - } - else // Quick culling - { - if (vz > cullplane && toph < cullplane) // Cull if below plane - return true; - - if (bottomh > cullplane && vz <= cullplane) // Cull if above plane - return true; - } - - return false; -} static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float this_scale) { @@ -4112,9 +3776,13 @@ static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts // uncapped/interpolation interpmobjstate_t interp = {0}; float basey, lowy; + INT32 dist = -1; + + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(spr->mobj->x, spr->mobj->y); // do interpolation - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { if (precip) { @@ -4188,13 +3856,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) float realheight, heightmult; const sector_t *sector = spr->mobj->subsector->sector; const lightlist_t *list = sector->lightlist; -#ifdef ESLOPE float endrealtop, endrealbot, endtop, endbot; float endbheight; float endrealheight; fixed_t temp; fixed_t v1x, v1y, v2x, v2y; -#endif INT32 shader = SHADER_NONE; @@ -4279,10 +3945,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) towbot = baseWallVerts[0].t; towmult = (towbot - towtop) / (top - bot); -#ifdef ESLOPE endrealtop = endtop = baseWallVerts[2].y; endrealbot = endbot = baseWallVerts[1].y; -#endif // copy the contents of baseWallVerts into the drawn wallVerts array // baseWallVerts is used to know the final shape to easily get the vertex @@ -4324,11 +3988,9 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (spr->mobj->frame & FF_FULLBRIGHT) lightlevel = 255; -#ifdef ESLOPE for (i = 1; i < sector->numlights; i++) { - fixed_t h = sector->lightlist[i].slope ? P_GetZAt(sector->lightlist[i].slope, spr->mobj->x, spr->mobj->y) - : sector->lightlist[i].height; + fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); if (h <= temp) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) @@ -4337,19 +3999,10 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) break; } } -#else - i = R_GetPlaneLight(sector, temp, false); - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i].lightlevel); - colormap = list[i].extra_colormap; -#endif for (i = 0; i < sector->numlights; i++) { -#ifdef ESLOPE - if (endtop < endrealbot) -#endif - if (top < realbot) + if (endtop < endrealbot && top < realbot) return; // even if we aren't changing colormap or lightlevel, we still need to continue drawing down the sprite @@ -4360,39 +4013,20 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) colormap = list[i].extra_colormap; } -#ifdef ESLOPE if (i + 1 < sector->numlights) { - if (list[i+1].slope) - { - temp = P_GetZAt(list[i+1].slope, v1x, v1y); - bheight = FIXED_TO_FLOAT(temp); - temp = P_GetZAt(list[i+1].slope, v2x, v2y); - endbheight = FIXED_TO_FLOAT(temp); - } - else - bheight = endbheight = FIXED_TO_FLOAT(list[i+1].height); + temp = P_GetLightZAt(&list[i+1], v1x, v1y); + bheight = FIXED_TO_FLOAT(temp); + temp = P_GetLightZAt(&list[i+1], v2x, v2y); + endbheight = FIXED_TO_FLOAT(temp); } else { bheight = realbot; endbheight = endrealbot; } -#else - if (i + 1 < sector->numlights) - { - bheight = FIXED_TO_FLOAT(list[i+1].height); - } - else - { - bheight = realbot; - } -#endif -#ifdef ESLOPE - if (endbheight >= endtop) -#endif - if (bheight >= top) + if (endbheight >= endtop && bheight >= top) continue; bot = bheight; @@ -4400,14 +4034,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (bot < realbot) bot = realbot; -#ifdef ESLOPE endbot = endbheight; if (endbot < endrealbot) endbot = endrealbot; -#endif -#ifdef ESLOPE wallVerts[3].t = towtop + ((realtop - top) * towmult); wallVerts[2].t = towtop + ((endrealtop - endtop) * towmult); wallVerts[0].t = towtop + ((realtop - bot) * towmult); @@ -4440,31 +4071,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; } -#else - wallVerts[3].t = wallVerts[2].t = towtop + ((realtop - top) * towmult); - wallVerts[0].t = wallVerts[1].t = towtop + ((realtop - bot) * towmult); - - wallVerts[2].y = wallVerts[3].y = top; - wallVerts[0].y = wallVerts[1].y = bot; - - // The x and y only need to be adjusted in the case that it's not a papersprite - if (cv_grspritebillboarding.value && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE)) - { - // Get the x and z of the vertices so billboarding draws correctly - realheight = realbot - realtop; - heightmult = (realtop - top) / realheight; - wallVerts[3].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; - wallVerts[3].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; - wallVerts[2].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; - wallVerts[2].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; - - heightmult = (realtop - bot) / realheight; - wallVerts[0].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; - wallVerts[0].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; - wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; - wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; - } -#endif HWR_Lighting(&Surf, lightlevel, colormap); @@ -4479,21 +4085,16 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); // sprite shader top = bot; -#ifdef ESLOPE endtop = endbot; -#endif } bot = realbot; -#ifdef ESLOPE endbot = endrealbot; - if (endtop <= endrealbot) -#endif - if (top <= realbot) + + if (endtop <= endrealbot && top <= realbot) return; // If we're ever down here, somehow the above loop hasn't draw all the light levels of sprite -#ifdef ESLOPE wallVerts[3].t = towtop + ((realtop - top) * towmult); wallVerts[2].t = towtop + ((endrealtop - endtop) * towmult); wallVerts[0].t = towtop + ((realtop - bot) * towmult); @@ -4503,13 +4104,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[2].y = endtop; wallVerts[0].y = bot; wallVerts[1].y = endbot; -#else - wallVerts[3].t = wallVerts[2].t = towtop + ((realtop - top) * towmult); - wallVerts[0].t = wallVerts[1].t = towtop + ((realtop - bot) * towmult); - - wallVerts[2].y = wallVerts[3].y = top; - wallVerts[0].y = wallVerts[1].y = bot; -#endif HWR_Lighting(&Surf, lightlevel, colormap); @@ -4537,12 +4131,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) FSurfaceInfo Surf; INT32 shader = SHADER_NONE; - - const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); - if (spr->mobj) - this_scale = FIXED_TO_FLOAT(spr->mobj->scale); - if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); if (!spr->mobj) return; @@ -4556,6 +4144,12 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) return; } + const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); + if (spr->mobj) + this_scale = FIXED_TO_FLOAT(spr->mobj->scale); + if (hires) + this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); + // cache sprite graphics //12/12/99: Hurdler: // OK, I don't change anything for MD2 support because I want to be @@ -4577,7 +4171,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) wallVerts[2].y = wallVerts[3].y = spr->gzt; wallVerts[0].y = wallVerts[1].y = spr->gz; - // make a wall polygon (with 2 triangles), using the floor/ceiling heights, // and the 2d map coords of start/end vertices wallVerts[0].z = wallVerts[3].z = spr->z1; @@ -4681,7 +4274,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) shader = SHADER_SPRITE; // sprite shader blend |= PF_ColorMapped; } - + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); } } @@ -4827,7 +4420,7 @@ static void HWR_SortVisSprites(void) { gr_vsprorder[i] = HWR_GetVisSprite(i); } - qsort(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); + qs22j(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); } // A drawnode is something that points to a 3D floor, 3D side, or masked @@ -4994,7 +4587,7 @@ static int CompareDrawNodePlanes(const void *p1, const void *p2) // // HWR_RenderDrawNodes // Sorts and renders the list of drawnodes for the scene being rendered. -void HWR_RenderDrawNodes(void) +static void HWR_RenderDrawNodes(void) { INT32 i = 0, run_start = 0; @@ -5035,7 +4628,7 @@ void HWR_RenderDrawNodes(void) if (run_end > run_start) // if there are multiple consecutive planes, not just one { // consecutive run of planes found, now sort it - qsort(sortindex + run_start, run_end - run_start + 1, sizeof(INT32), CompareDrawNodePlanes); + qs22j(sortindex + run_start, run_end - run_start + 1, sizeof(INT32), CompareDrawNodePlanes); } run_start = run_end + 1; // continue looking for runs coming right after this one } @@ -5310,10 +4903,11 @@ void HWR_ProjectSprite(mobj_t *thing) UINT8 flip; boolean mirrored = thing->mirrored; boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - + angle_t ang, camang; const boolean papersprite = (thing->frame & FF_PAPERSPRITE); INT32 heightsec, phs; + INT32 dist = -1; fixed_t spr_width, spr_height; fixed_t spr_offset, spr_topoffset; @@ -5330,7 +4924,10 @@ void HWR_ProjectSprite(mobj_t *thing) if (!thing) return; - if (R_UsingFrameInterpolation() && !paused) + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); + + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolateMobjState(thing, rendertimefrac, &interp); } @@ -5545,7 +5142,6 @@ void HWR_ProjectSprite(mobj_t *thing) x1 = tr_x + x1 * rightcos; x2 = tr_x - x2 * rightcos; - if (thing->eflags & MFE_VERTICALFLIP) { gz = FIXED_TO_FLOAT(interp.z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale); @@ -5602,7 +5198,7 @@ void HWR_ProjectSprite(mobj_t *thing) vis->gpatch = (GLPatch_t *)rotsprite; else #endif - vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); vis->mobj = thing; @@ -5667,15 +5263,19 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) size_t lumpoff; unsigned rot = 0; UINT8 flip; + INT32 dist = -1; if (!thing) return; - + + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); + // uncapped/interpolation interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp); } @@ -5763,9 +5363,9 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif // set top/bottom coords - vis->ty = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); + vis->ty = FIXED_TO_FLOAT(interp.z + spritecachedinfo[lumpoff].topoffset); - vis->gzt = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); + vis->gzt = FIXED_TO_FLOAT(interp.z + spritecachedinfo[lumpoff].topoffset); vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height); vis->precip = true; @@ -5868,11 +5468,6 @@ void HWR_SetTransform(float fpov, player_t *player) postimg_t *postprocessor = &postimgtype[0]; INT32 i; - // copy view cam position for local use - dup_viewx = viewx; - dup_viewy = viewy; - dup_viewz = viewz; - gr_viewx = FIXED_TO_FLOAT(viewx); gr_viewy = FIXED_TO_FLOAT(viewy); gr_viewz = FIXED_TO_FLOAT(viewz); @@ -5941,7 +5536,7 @@ void HWR_ClearClipper(void) gld_clipper_Clear(); gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); #ifdef HAVE_SPHEREFRUSTRUM - gld_FrustrumSetup(); + gld_FrustumSetup(); #endif } @@ -5952,8 +5547,16 @@ static void HWR_PortalClipping(gl_portal_t *portal) line_t *line = &lines[portal->clipline]; - angle1 = R_PointToAngle64(line->v1->x, line->v1->y); - angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(line->v1->x, line->v1->y); + angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, line->v1->x, line->v1->y); + angle2 = R_PointToAngleEx(viewx, viewy, line->v2->x, line->v2->y); + } // clip things that are not inside the portal window from our viewpoint gld_clipper_SafeAddClipRange(angle2, angle1); @@ -6051,7 +5654,9 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe portalclipline = NULL; else HWR_PortalClipping(rootportal); + validcount++; + HWR_RenderBSPNode((INT32)numnodes-1);// no actual rendering happens // for each found portal: @@ -6069,11 +5674,12 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); if (!cv_portalonly.value || rootportal) - { + { + HWR_SetTransform(fpov, player); + HWR_ClearClipper(); HWR_ClearSprites(); - // the frame should be correct, set by either the for loop or the above layer in recursion - HWR_SetTransform(fpov, player); + if (!rootportal) portalclipline = NULL; else @@ -6081,7 +5687,10 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe HWR_PortalFrame(rootportal);// for portalclipsector, it could have gone null from search HWR_PortalClipping(rootportal); } - //drawcount = 0; + + // Set transform. + HWD.pfnSetTransform(&atransform); + validcount++; if (cv_grbatching.value) @@ -6157,8 +5766,6 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) { const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd); - postimg_t *postprocessor = &postimgtype[0]; - INT32 i; // set window position gr_centerx = gr_basecenterx; @@ -6197,67 +5804,8 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) // check for new console commands. NetUpdate(); - gr_viewx = FIXED_TO_FLOAT(viewx); - gr_viewy = FIXED_TO_FLOAT(viewy); - gr_viewz = FIXED_TO_FLOAT(viewz); - gr_viewsin = FIXED_TO_FLOAT(viewsin); - gr_viewcos = FIXED_TO_FLOAT(viewcos); - - memset(&atransform, 0x00, sizeof(FTransform)); - - // Set T&L transform - atransform.x = gr_viewx; - atransform.y = gr_viewy; - atransform.z = gr_viewz; - - atransform.scalex = 1; - atransform.scaley = (float)vid.width/vid.height; - atransform.scalez = 1; - - // 14042019 - gr_aimingangle = aimingangle; - atransform.shearing = false; - atransform.viewaiming = aimingangle; - - if (cv_grshearing.value) - { - gr_aimingangle = 0; - atransform.shearing = true; - } - - gr_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gr_aimingangle>>ANGLETOFINESHIFT)); - gr_viewludcos = FIXED_TO_FLOAT(-FINESINE(gr_aimingangle>>ANGLETOFINESHIFT)); - - atransform.anglex = (float)(gr_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); - atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); - - atransform.fovxangle = fpov; // Tails - atransform.fovyangle = fpov; // Tails - if (player->viewrollangle != 0) - { - fixed_t rol = AngleFixed(player->viewrollangle); - atransform.rollangle = FIXED_TO_FLOAT(rol); - atransform.roll = true; - } - atransform.splitscreen = splitscreen; - - for (i = 0; i <= splitscreen; i++) - { - if (player == &players[displayplayers[i]]) - postprocessor = &postimgtype[i]; - } - - atransform.flip = false; - if (*postprocessor == postimg_flip) - atransform.flip = true; - - atransform.mirror = false; - if (*postprocessor == postimg_mirror) - atransform.mirror = true; - // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); - HWR_ClearSprites(); ST_doPaletteStuff(); @@ -6278,16 +5826,8 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) current_bsp_culling_distance = bsp_culling_distances[cv_grrenderdistance.value - 1]; } - HWR_ClearClipper(); - - // Reset the shader state. - //HWR_SetShaderState(); - - validcount++; - portalclipline = NULL; HWR_RenderViewpoint(NULL, fpov, player, 0, !skybox); - HWR_SetTransform(fpov, player);// not sure if needed // Unset transform and shader HWD.pfnSetTransform(NULL); @@ -6393,7 +5933,6 @@ void HWR_AddCommands(void) { CV_RegisterVar(&cv_grfiltermode); CV_RegisterVar(&cv_granisotropicmode); - CV_RegisterVar(&cv_grcorrecttricks); CV_RegisterVar(&cv_grsolvetjoin); CV_RegisterVar(&cv_grbatching); @@ -6565,7 +6104,7 @@ void HWR_DoPostProcessor(player_t *player) return; // Capture the screen for intermission and screen waving - if(gamestate != GS_INTERMISSION) + if (gamestate != GS_INTERMISSION) HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); if (splitscreen) // Not supported in splitscreen - someone want to add support? @@ -6668,7 +6207,7 @@ void HWR_MakeScreenFinalTexture(void) HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); } -void HWR_DrawScreenFinalTexture(int width, int height) +void HWR_DrawScreenFinalTexture(INT32 width, INT32 height) { HWD.pfnDrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height); } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 4725c720b..3530c2915 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -115,19 +115,15 @@ void HWR_DrawIntermissionBG(void); void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum); void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); void HWR_MakeScreenFinalTexture(void); -void HWR_DrawScreenFinalTexture(int width, int height); +void HWR_DrawScreenFinalTexture(INT32 width, INT32 height); // hw_main.c: Planes void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap); -#ifdef POLYOBJECTS -#ifdef POLYOBJECTS_PLANES void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); void HWR_AddPolyObjectPlanes(void); void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); -#endif -#endif // hw_main.c: Segs void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom @@ -138,16 +134,7 @@ void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 t void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf); void HWR_DrawSkyBackground(float fpov); -#ifdef POLYOBJECTS void HWR_AddPolyObjectSegs(void); -#endif - -// hw_main.c: BSP -void HWR_RenderBSPNode(INT32 bspnum); -void HWR_Subsector(size_t num); -void HWR_AddLine(seg_t *line); -boolean HWR_CheckBBox(fixed_t *bspcoord); -void HWR_RenderDrawNodes(void); // hw_main.c: Sprites void HWR_AddSprites(sector_t *sec); @@ -163,9 +150,6 @@ extern boolean gr_maphasportals; void HWR_LoadTextures(size_t pnumtextures); RGBA_t *HWR_GetTexturePalette(void); -// hw_trick.c -void HWR_CorrectSWTricks(void); - void HWR_SetShaderState(void); // Console variables diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 96a9d12da..79ca9bf92 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1163,7 +1163,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr) angle_t ang; interpmobjstate_t interp; - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || R_QuickCamDist(spr->mobj->x, spr->mobj->y) < cv_grmaxinterpdist.value)) { R_InterpolateMobjState(spr->mobj, rendertimefrac, &interp); } @@ -1260,30 +1260,30 @@ void HWR_DrawMD2(gr_vissprite_t *spr) md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap->format && gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height) { - INT32 skinnum = TC_DEFAULT; + INT32 tcskinnum = TC_DEFAULT; if ((spr->mobj->flags & MF_BOSS) && (spr->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { if (spr->mobj->type == MT_CYBRAKDEMON) - skinnum = TC_ALLWHITE; + tcskinnum = TC_ALLWHITE; else if (spr->mobj->type == MT_METALSONIC_BATTLE) - skinnum = TC_METALSONIC; + tcskinnum = TC_METALSONIC; else - skinnum = TC_BOSS; + tcskinnum = TC_BOSS; } else if (spr->mobj->color) { if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { if (spr->mobj->colorized) - skinnum = TC_RAINBOW; + tcskinnum = TC_RAINBOW; else { - skinnum = (INT32)((skin_t*)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ) - ( (spr->mobj->skinlocal) ? localskins : skins )); + tcskinnum = (INT32)((skin_t*)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ) - ( (spr->mobj->skinlocal) ? localskins : skins )); } } - else skinnum = TC_DEFAULT; + else tcskinnum = TC_DEFAULT; } - HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color); + HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, tcskinnum, spr->colormap, (skincolors_t)spr->mobj->color); } else { diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index f9c755b0d..427bd1540 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -439,7 +439,7 @@ void HWR_LoadAllCustomShaders(void) // read every custom shader for (i = 0; i < numwadfiles; i++) - HWR_LoadCustomShadersFromFile(i, (wadfiles[i]->type == RET_PK3)); + HWR_LoadCustomShadersFromFile(i, W_FileHasFolders(wadfiles[i])); } void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) @@ -454,7 +454,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) int i; boolean modified_shaders[NUMSHADERTARGETS] = {0}; - if (!HWR_UseShader()) + if (!gr_shadersavailable) return; lump = HWR_FindShaderDefs(wadnum); diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index eb705c34c..efd908226 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -76,7 +76,7 @@ #define GLSL_SOFTWARE_TINT_EQUATION \ "if (tint_color.a > 0.0) {\n" \ "float color_bright = sqrt((base_color.r * base_color.r) + (base_color.g * base_color.g) + (base_color.b * base_color.b));\n" \ - "float strength = sqrt(9.0 * tint_color.a);\n" \ + "float strength = sqrt(tint_color.a);\n" \ "final_color.r = clamp((color_bright * (tint_color.r * strength)) + (base_color.r * (1.0 - strength)), 0.0, 1.0);\n" \ "final_color.g = clamp((color_bright * (tint_color.g * strength)) + (base_color.g * (1.0 - strength)), 0.0, 1.0);\n" \ "final_color.b = clamp((color_bright * (tint_color.b * strength)) + (base_color.b * (1.0 - strength)), 0.0, 1.0);\n" \ diff --git a/src/hardware/hw_trick.c b/src/hardware/hw_trick.c deleted file mode 100644 index de4a76c59..000000000 --- a/src/hardware/hw_trick.c +++ /dev/null @@ -1,919 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2001 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief special trick routines to make some SW tricks look OK with -/// HW rendering. This includes: -/// - deepwatereffect (e.g. tnt/map02) -/// - invisible staircase (e.g. eternal/map02) -/// - floating ceilings (e.g. eternal/map03) -/// -/// It is not guaranteed that it looks identical to the SW mode, -/// but it looks in most of the cases far better than having -/// holes in the architecture, HOM, etc. -/// -/// It fixes as well missing textures, which are replaced by either -/// a default texture or the midtexture. -/// -/// words of notice: -/// pseudosectors, as mentioned in this file, are sectors where both -/// sidedefs point to the same sector. This expression is also used -/// for sectors which are enclosed by another sector but have no -/// correct sidedefs at all -/// -/// if a vertex is inside a poly is determined by the angles between -/// this vertex and all angles on the linedefs (imagine walking along -/// a circle always facing a certain point inside/outside the circle; -/// if inside, angle have taken all values [0..pi), otherwise the -/// range was < pi/2 - -#include -#include "../doomdef.h" -#include "../doomstat.h" - -#ifdef HWRENDER -#include "hw_main.h" -#include "hw_glob.h" -#include "hw_dll.h" -#include "../r_local.h" -#include "../i_system.h" - -// -// add a line to a sectors list of lines -// -static void addLineToChain(sector_t *sector, line_t *line) -{ - linechain_t *thisElem = NULL, *nextElem; - - if (!sector) - return; - - nextElem = sector->sectorLines; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - } - - // add a new element into the chain - if (thisElem) - { - thisElem->next = malloc(sizeof (linechain_t)); - if (thisElem->next) - { - thisElem->next->line = line; - thisElem->next->next = NULL; - } - else - { - I_Error("Out of memory in addLineToChain(.)\n"); - } - } - else // first element in chain - { - sector->sectorLines = malloc(sizeof (linechain_t)); - if (sector->sectorLines) - { - sector->sectorLines->line = line; - sector->sectorLines->next = NULL; - } - else - { - I_Error("Out of memory in addLineToChain(.)\n"); - } - } -} - -// -// We dont want a memory hole, do we?;-) -// -static void releaseLineChains(void) -{ - linechain_t *thisElem, *nextElem; - sector_t *sector; - size_t i; - - for (i = 0; i < numsectors; i++) - { - sector = §ors[i]; - nextElem = sector->sectorLines; - - while (nextElem) - { - thisElem = nextElem; - nextElem = thisElem->next; - free(thisElem); - } - - sector->sectorLines = NULL; - } -} - -// -// check if a pseudo sector is valid by checking all its linedefs -// -static boolean isPSectorValid(sector_t *sector) -{ - linechain_t *thisElem, *nextElem; - - if (!sector->pseudoSector) // check only pseudosectors, others dont care - { -#ifdef PARANOIA - CONS_Debug(DBG_RENDER, "Alert! non-pseudosector fed to isPSectorClosed()\n"); -#endif - return false; - } - - nextElem = sector->sectorLines; - - while (nextElem) - { - thisElem = nextElem; - nextElem = thisElem->next; - if (thisElem->line->frontsector != thisElem->line->backsector) - return false; - } - return true; -} - -// -// angles are always phiMax-phiMin [0...2\pi) -// -FUNCMATH static double phiDiff(double phiMin, double phiMax) -{ - double result; - - result = phiMax-phiMin; - - if (result < 0.0l) - result += 2.0l*M_PIl; - - return result; -} - -// -// sort phi's so that enclosed angle < \pi -// -static void sortPhi(double phi1, double phi2, double *phiMin, double *phiMax) -{ - if (phiDiff(phi1, phi2) < M_PIl) - { - *phiMin = phi1; - *phiMax = phi2; - } - else - { - *phiMin = phi2; - *phiMax = phi1; - } -} - -// -// return if angle(phi1, phi2) is bigger than \pi -// if so, the vertex lies inside the poly -// -FUNCMATH static boolean biggerThanPi(double phi1, double phi2) -{ - if (phiDiff(phi1, phi2) > M_PIl) - return true; - - return false; -} - -#define DELTAPHI (M_PIl/100.0l) // some small phi << \pi - -// -// calculate bounds for minimum angle -// -static void phiBounds(double phi1, double phi2, double *phiMin, double *phiMax) -{ - double phi1Tmp, phi2Tmp; - double psi1, psi2, psi3, psi4, psi5, psi6, psi7; // for optimization - - sortPhi(phi1, phi2, &phi1Tmp, &phi2Tmp); - phi1 = phi1Tmp; - phi2 = phi2Tmp; - - // check start condition - if (*phiMin > M_PIl || *phiMax > M_PIl) - { - *phiMin = phi1; - *phiMax = phi2; - return; - } - - // 6 cases: - // new angles inbetween phiMin, phiMax -> forget it - // new angles enclose phiMin -> set phiMin - // new angles enclose phiMax -> set phiMax - // new angles completely outside phiMin, phiMax -> leave largest area free - // new angles close the range completely! - // new angles enlarges range on both sides - - psi1 = phiDiff(*phiMin, phi1); - psi2 = phiDiff(*phiMin, phi2); - psi3 = phiDiff(*phiMax, phi1); - psi4 = phiDiff(*phiMax, phi2); - psi5 = phiDiff(*phiMin, *phiMax); - psi6 = (double)(2.0l*M_PIl - psi5); // phiDiff(*phiMax, *phiMin); - psi7 = (double)(2.0l*M_PIl - psi2); // phiDiff(phi2, *phiMin); - - // case 1 & 5! - if ((psi1 <= psi5) && (psi2 <= psi5)) - { - if (psi1 <= psi2) // case 1 - { - return; - } - else // case 5 - { - // create some artificial interval here not to get into numerical trouble - // in fact we know now the sector is completely enclosed -> base for computational optimization - *phiMax = 0.0l; - *phiMin = DELTAPHI; - return; - } - } - - // case 2 - if ((psi1 >= psi5) && (psi2 <= psi5)) - { - *phiMin = phi1; - return; - } - - // case 3 - if ((psi3 >= psi6) && (psi4 <= psi6)) - { - *phiMax = phi2; - return; - } - - // case 4 & 6 -#ifdef PARANOIA - if ((psi3 <= psi6) && (psi4 <= psi6)) // FIXME: isn't this case implicitly true anyway?? -#endif - { - if (psi3 <= psi4) //case 4 - { - if (psi3 >= psi7) - { - *phiMin = phi1; - return; - } - else - { - *phiMax = phi2; - return; - } - } - else // case 6 - { - *phiMin = phi1; - *phiMax = phi2; - return; - } - } - -#ifdef PARANOIA - CONS_Debug(DBG_RENDER, "phiMin = %f, phiMax = %f, phi1 = %f, phi2 = %f\n", *phiMin, *phiMax, phi1, phi2); - I_Error("phiBounds() out of range!\n"); -#endif -} - -// -// Check if a vertex lies inside a sector -// This works for "well-behaved" convex polygons -// If we need it mathematically correct, we need to sort the -// linedefs first so we have them in a row, then walk along the linedefs, -// but this is a bit overdone -// -static inline boolean isVertexInside(vertex_t *vertex, sector_t *sector) -{ - double xa, ya, xe, ye; - linechain_t *chain; - double phiMin, phiMax; - double phi1, phi2; - - chain = sector->sectorLines; - phiMin = phiMax = 10.0l*M_PIl; // some value > \pi - - while (chain) - { - // start and end vertex - xa = (double)chain->line->v1->x - (double)vertex->x; - ya = (double)chain->line->v1->y - (double)vertex->y; - xe = (double)chain->line->v2->x - (double)vertex->x; - ye = (double)chain->line->v2->y - (double)vertex->y; - - // angle phi of connection between the vertices and the x-axis - phi1 = atan2(ya, xa); - phi2 = atan2(ye, xe); - - // if we have just started, we can have to create start bounds for phi - - phiBounds(phi1, phi2, &phiMin, &phiMax); - chain = chain->next; - } - - return biggerThanPi(phiMin, phiMax); -} - - -#define MAXSTACK 256 // Not more than 256 polys in each other? -// -// generate a list of sectors which enclose the given sector -// -static void generateStacklist(sector_t *thisSector) -{ - size_t i, stackCnt = 0; - sector_t *locStacklist[MAXSTACK]; - sector_t *checkSector; - - for (i = 0; i < numsectors; i++) - { - checkSector = §ors[i]; - - if (checkSector == thisSector) // dont check self - continue; - - // buggy sector? - if (!thisSector->sectorLines) - continue; - - // check if an arbitrary vertex of thisSector lies inside the checkSector - if (isVertexInside(thisSector->sectorLines->line->v1, checkSector)) - { - // if so, the thisSector lies inside the checkSector - locStacklist[stackCnt] = checkSector; - stackCnt++; - - if (MAXSTACK-1 == stackCnt) // beware of the SIGSEGV! and consider terminating NULL! - break; - } - } - - thisSector->stackList = malloc(sizeof (sector_t *) * (stackCnt+1)); - if (NULL == thisSector->stackList) - { - I_Error("Out of memory error in generateStacklist()"); - } - - locStacklist[stackCnt] = NULL; // terminating NULL - - memcpy(thisSector->stackList, locStacklist, sizeof (sector_t *) * (stackCnt+1)); -} - -// -// Bubble sort the stacklist with rising lineoutlengths -// -static void sortStacklist(sector_t *sector) -{ - sector_t **list; - sector_t *sec1, *sec2; - boolean finished; - size_t i; - - list = sector->stackList; - finished = false; - - if (!*list) - return; // nothing to sort - - while (!finished) - { - i = 0; - finished = true; - - while (*(list+i+1)) - { - sec1 = *(list+i); - sec2 = *(list+i+1); - - if (sec1->lineoutLength > sec2->lineoutLength) - { - *(list+i) = sec2; - *(list+i+1) = sec1; - finished = false; - } - i++; - } - } -} - -// -// length of a line in euclidian sense -// -static double lineLength(line_t *line) -{ - double dx, dy, length; - - dx = (double) line->v1->x - (double) line->v2->x; - dy = (double) line->v1->y - (double) line->v2->y; - - length = hypot(dx, dy); - - return length; -} - - -// -// length of the sector lineout -// -static double calcLineoutLength(sector_t *sector) -{ - linechain_t *chain; - double length = 0.0L; - chain = sector->sectorLines; - - while (chain) // sum up lengths of all lines - { - length += lineLength(chain->line); - chain = chain->next; - } - return length; -} - -// -// Calculate length of the sectors lineout -// -static void calcLineouts(sector_t *sector) -{ - size_t secCount = 0; - sector_t *encSector = *(sector->stackList); - - while (encSector) - { - if (encSector->lineoutLength < 0.0L) // if length has not yet been calculated - { - encSector->lineoutLength = calcLineoutLength(encSector); - } - - secCount++; - encSector = *((sector->stackList) + secCount); - } -} - -// -// Free Stacklists of all sectors -// -static void freeStacklists(void) -{ - size_t i; - - for (i = 0; i < numsectors; i++) - { - if (sectors[i].stackList) - { - free(sectors[i].stackList); - sectors[i].stackList = NULL; - } - } -} - -// -// if more than half of the toptextures are missing -// -static boolean areToptexturesMissing(sector_t *thisSector) -{ - linechain_t *thisElem, *nextElem = thisSector->sectorLines; - sector_t *frontSector, *backSector; - size_t nomiss = 0; - side_t *sidel, *sider; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - - frontSector = thisElem->line->frontsector; - backSector = thisElem->line->backsector; - - if (frontSector == backSector) // skip damn renderer tricks here - continue; - - if (!frontSector || !backSector) - continue; - - sider = &sides[thisElem->line->sidenum[0]]; - sidel = &sides[thisElem->line->sidenum[1]]; - - if (backSector->ceilingheight < frontSector->ceilingheight) - { - if (sider->toptexture != 0) - { - nomiss++; - break; // we can stop here if decision criterium is ==0 - } - } - else if (backSector->ceilingheight > frontSector->ceilingheight) - { - if (sidel->toptexture != 0) - { - nomiss++; - break; // we can stop here if decision criterium is ==0 - } - } - } - - return nomiss == 0; -} - -// -// are more textures missing than present? -// -static boolean areBottomtexturesMissing(sector_t *thisSector) -{ - linechain_t *thisElem, *nextElem = thisSector->sectorLines; - sector_t *frontSector, *backSector; - size_t nomiss = 0; - side_t *sidel, *sider; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - - frontSector = thisElem->line->frontsector; - backSector = thisElem->line->backsector; - - if (frontSector == backSector) // skip damn renderer tricks here - continue; - - if (!frontSector || !backSector) - continue; - - sider = &sides[thisElem->line->sidenum[0]]; - sidel = &sides[thisElem->line->sidenum[1]]; - - if (backSector->floorheight > frontSector->floorheight) - { - if (sider->bottomtexture != 0) - { - nomiss++; - break; // we can stop here if decision criterium is ==0 - } - } - - else if (backSector->floorheight < frontSector->floorheight) - { - if (sidel->bottomtexture != 0) - { - nomiss++; - break; // we can stop here if decision criterium is ==0 - } - } - } - - // return missing >= nomiss; - return nomiss == 0; -} - -// -// check if no adjacent sector has same ceiling height -// -static boolean isCeilingFloating(sector_t *thisSector) -{ - sector_t *adjSector, *refSector = NULL, *frontSector, *backSector; - linechain_t *thisElem, *nextElem; - - if (!thisSector) - return false; - - nextElem = thisSector->sectorLines; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - - frontSector = thisElem->line->frontsector; - backSector = thisElem->line->backsector; - - if (frontSector == thisSector) - adjSector = backSector; - else - adjSector = frontSector; - - if (!adjSector) // assume floating sectors have surrounding sectors - return false; - -#ifdef ESLOPE - if (adjSector->c_slope) // Don't bother with slopes - return false; -#endif - - if (!refSector) - { - refSector = adjSector; - continue; - } - - // if adjacent sector has same height or more than one adjacent sector exists -> stop - if (thisSector->ceilingheight == adjSector->ceilingheight || refSector != adjSector) - return false; - } - - // now check for walltextures - if (!areToptexturesMissing(thisSector)) - return false; - - return true; -} - -// -// check if no adjacent sector has same ceiling height -// FIXME: throw that together with isCeilingFloating?? -// -static boolean isFloorFloating(sector_t *thisSector) -{ - sector_t *adjSector, *refSector = NULL, *frontSector, *backSector; - linechain_t *thisElem, *nextElem; - - if (!thisSector) - return false; - - nextElem = thisSector->sectorLines; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - - frontSector = thisElem->line->frontsector; - backSector = thisElem->line->backsector; - - if (frontSector == thisSector) - adjSector = backSector; - else - adjSector = frontSector; - - if (!adjSector) // assume floating sectors have surrounding sectors - return false; - -#ifdef ESLOPE - if (adjSector->f_slope) // Don't bother with slopes - return false; -#endif - - if (!refSector) - { - refSector = adjSector; - continue; - } - - // if adjacent sector has same height or more than one adjacent sector exists -> stop - if (thisSector->floorheight == adjSector->floorheight || refSector != adjSector) - return false; - } - - // now check for walltextures - if (!areBottomtexturesMissing(thisSector)) - return false; - - return true; -} - -// -// estimate ceilingheight according to height of adjacent sector -// -static fixed_t estimateCeilHeight(sector_t *thisSector) -{ - sector_t *adjSector; - - if (!thisSector || !thisSector->sectorLines || !thisSector->sectorLines->line) - return 0; - - adjSector = thisSector->sectorLines->line->frontsector; - if (adjSector == thisSector) - adjSector = thisSector->sectorLines->line->backsector; - - if (!adjSector) - return 0; - - return adjSector->ceilingheight; -} - -// -// estimate ceilingheight according to height of adjacent sector -// -static fixed_t estimateFloorHeight(sector_t *thisSector) -{ - sector_t *adjSector; - - if (!thisSector || !thisSector->sectorLines || !thisSector->sectorLines->line) - return 0; - - adjSector = thisSector->sectorLines->line->frontsector; - if (adjSector == thisSector) - adjSector = thisSector->sectorLines->line->backsector; - - if (!adjSector) - return 0; - - return adjSector->floorheight; -} - -#define CORRECT_FLOAT_EXPERIMENTAL - -// -------------------------------------------------------------------------- -// Some levels have missing sidedefs, which produces HOM, so lets try to compensate for that -// and some levels have deep water trick, invisible staircases etc. -// -------------------------------------------------------------------------- -// FIXME: put some nice default texture in legacy.dat and use it -void HWR_CorrectSWTricks(void) -{ - size_t i; - size_t k; - line_t *ld; - side_t *sidel = NULL, *sider; - sector_t *secl, *secr; - sector_t **sectorList; - sector_t *outSector; - - if ((0 == cv_grcorrecttricks.value)) - return; - - // determine lines for sectors - for (i = 0; i < numlines; i++) - { - ld = &lines[i]; - secr = ld->frontsector; - secl = ld->backsector; - - if (secr == secl) - { - secr->pseudoSector = true; // special renderer trick? - addLineToChain(secr, ld); - } - else - { - addLineToChain(secr, ld); - addLineToChain(secl, ld); - } - } - - // preprocessing - for (i = 0; i < numsectors; i++) - { - sector_t *checkSector; - - checkSector = §ors[i]; - - // identify real pseudosectors first - if (checkSector->pseudoSector) - { - if (!isPSectorValid(checkSector)) // drop invalid pseudo sectors - { - checkSector->pseudoSector = false; - } - } - - // determine enclosing sectors for pseudosectors ... used later - if (checkSector->pseudoSector) - { - generateStacklist(checkSector); - calcLineouts(checkSector); - sortStacklist(checkSector); - } - } - - // set virtual floor heights for pseudo sectors - // required for deep water effect e.g. - for (i = 0; i < numsectors; i++) - { - if (sectors[i].pseudoSector) - { - sectorList = sectors[i].stackList; - k = 0; - while (*(sectorList+k)) - { - outSector = *(sectorList+k); - if (!outSector->pseudoSector) - { - sectors[i].virtualFloorheight = outSector->floorheight; - sectors[i].virtualCeilingheight = outSector->ceilingheight; - break; - } - k++; - } - if (*(sectorList+k) == NULL) // sorry, did not work :( - { - sectors[i].virtualFloorheight = sectors[i].floorheight; - sectors[i].virtualCeilingheight = sectors[i].ceilingheight; - } - } - } -#ifdef CORRECT_FLOAT_EXPERIMENTAL - // correct ceiling/floor heights of totally floating sectors - for (i = 0; i < numsectors; i++) - { - sector_t *floatSector; - - floatSector = §ors[i]; - - // correct height of floating sectors - if (isCeilingFloating(floatSector)) - { - floatSector->virtualCeilingheight = estimateCeilHeight(floatSector); - floatSector->virtualCeiling = true; - } - if (isFloorFloating(floatSector)) - { - floatSector->virtualFloorheight = estimateFloorHeight(floatSector); - floatSector->virtualFloor = true; - } - } -#endif - - // now for the missing textures - for (i = 0; i < numlines; i++) - { - ld = &lines[i]; - sider = &sides[ld->sidenum[0]]; - if (ld->sidenum[1] != 0xffff) - sidel = &sides[ld->sidenum[1]]; - - secr = ld->frontsector; - secl = ld->backsector; - - if (secr == secl) // special renderer trick - continue; // we cant correct missing textures here - - if (secl) // only if there is a backsector - { - if (secr->pseudoSector || secl->pseudoSector) - continue; - if (!secr->virtualFloor && !secl->virtualFloor) - { - if (secl->floorheight > secr->floorheight) - { - // now check if r-sidedef is correct - if (sider->bottomtexture == 0) - { - if (sider->midtexture == 0) - sider->bottomtexture = 0; // Tails // More redwall sky shenanigans - else - sider->bottomtexture = sider->midtexture; - } - } - else if (secl->floorheight < secr->floorheight) - { - // now check if l-sidedef is correct - if (sidel->bottomtexture == 0) - { - if (sidel->midtexture == 0) - sidel->bottomtexture = 0; // Tails // More redwall sky shenanigans - else - sidel->bottomtexture = sidel->midtexture; - } - } - } - - if (!secr->virtualCeiling && !secl->virtualCeiling) - { - if (secl->ceilingheight < secr->ceilingheight) - { - // now check if r-sidedef is correct - if (sider->toptexture == 0) - { - if (sider->midtexture == 0) - sider->toptexture = 0; // Tails // When this was REDWALL it was causing issues in the sky sometimes - else - sider->toptexture = sider->midtexture; - } - } - else if (secl->ceilingheight > secr->ceilingheight) - { - // now check if l-sidedef is correct - if (sidel->toptexture == 0) - { - if (sidel->midtexture == 0) - sidel->toptexture = 0; // Tails // When this was REDWALL it was causing issues in the sky sometimes - else - sidel->toptexture = sidel->midtexture; - } - } - } - } // if (NULL != secl) - } // for (i = 0; i < numlines; i++) - - // release all linechains - releaseLineChains(); - freeStacklists(); -} - -#endif // HWRENDER diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index f137a7cc8..d82676585 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -8,7 +8,7 @@ // terms of the GNU General Public License, version 2. // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- -/// \file +/// \file r_opengl.c /// \brief OpenGL API for Sonic Robo Blast 2 #if defined (_WIN32) @@ -26,8 +26,9 @@ #include "../../r_local.h" // For rendertimefrac, used for the leveltime shader uniform #include "r_opengl.h" #include "r_vbo.h" - +#include "../hw_shaders.h" #include "../hw_main.h" +#include "../hw_clip.h" // Eeeeh not sure is this right way, but it works < sry :c < sry again it had to go :c @@ -110,7 +111,7 @@ const GLubyte *gl_extensions = NULL; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) static GLfloat modelMatrix[16]; -static GLfloat projMatrix[16]; +GLfloat projMatrix[16]; static GLint viewport[4]; @@ -567,7 +568,6 @@ static PFNglStencilFuncSeparate pglStencilFuncSeparate; typedef void (APIENTRY *PFNglStencilOpSeparate) (GLenum, GLenum, GLenum, GLenum); static PFNglStencilOpSeparate pglStencilOpSeparate; -#ifdef GL_SHADERS typedef GLuint (APIENTRY *PFNglCreateShader) (GLenum); typedef void (APIENTRY *PFNglShaderSource) (GLuint, GLsizei, const GLchar**, GLint*); typedef void (APIENTRY *PFNglCompileShader) (GLuint); @@ -674,31 +674,6 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; -// -// Generic vertex shader -// - -#define GLSL_FALLBACK_VERTEX_SHADER \ - "void main()\n" \ - "{\n" \ - "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_FrontColor = gl_Color;\n" \ - "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ - "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ - "}\0" - -// -// Generic fragment shader -// - -#define GLSL_FALLBACK_FRAGMENT_SHADER \ - "uniform sampler2D tex;\n" \ - "uniform vec4 poly_color;\n" \ - "void main(void) {\n" \ - "gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \ - "}\0" - -#endif // GL_SHADERS void SetupGLFunc4(void) { @@ -720,7 +695,6 @@ void SetupGLFunc4(void) pglStencilFuncSeparate = GetGLFunc("glStencilFuncSeparate"); pglStencilOpSeparate = GetGLFunc("glStencilOpSeparate"); -#ifdef GL_SHADERS pglCreateShader = GetGLFunc("glCreateShader"); pglShaderSource = GetGLFunc("glShaderSource"); pglCompileShader = GetGLFunc("glCompileShader"); @@ -742,7 +716,6 @@ void SetupGLFunc4(void) pglUniform2fv = GetGLFunc("glUniform2fv"); pglUniform3fv = GetGLFunc("glUniform3fv"); pglGetUniformLocation = GetGLFunc("glGetUniformLocation"); -#endif #ifdef GL_VERSION_3_0 pglGenerateMipmap = GetGLFunc("glGenerateMipmap"); @@ -751,7 +724,6 @@ void SetupGLFunc4(void) EXPORT boolean HWRAPI(InitShaders) (void) { -#ifdef GL_SHADERS if (!pglUseProgram) return false; @@ -765,14 +737,10 @@ EXPORT boolean HWRAPI(InitShaders) (void) } return true; -#else - return false; -#endif } EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage) { -#ifdef GL_SHADERS gl_shader_t *shader; if (slot < 0 || slot >= HWR_MAXSHADERS) @@ -794,16 +762,10 @@ EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage) I_Error("LoadShader: invalid shader stage"); #undef LOADSHADER -#else - (void)slot; - (void)code; - (void)stage; -#endif } EXPORT boolean HWRAPI(CompileShader) (int slot) { -#ifdef GL_SHADERS if (slot < 0 || slot >= HWR_MAXSHADERS) I_Error("CompileShader: Invalid slot %d", slot); @@ -816,10 +778,6 @@ EXPORT boolean HWRAPI(CompileShader) (int slot) gl_shaders[slot].program = 0; return false; } -#else - (void)slot; - return false; -#endif } // @@ -829,7 +787,6 @@ EXPORT boolean HWRAPI(CompileShader) (int slot) EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) { -#ifdef GL_SHADERS switch (info) { case HWD_SHADERINFO_LEVELTIME: @@ -838,15 +795,15 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) default: break; } -#else - (void)info; - (void)value; -#endif } EXPORT void HWRAPI(SetShader) (int slot) { -#ifdef GL_SHADERS + if (slot == SHADER_NONE) + { + UnSetShader(); + return; + } if (gl_allowshaders) { gl_shader_t *next_shader = &gl_shaders[slot]; // the gl_shader_t we are going to switch to @@ -867,26 +824,26 @@ EXPORT void HWRAPI(SetShader) (int slot) return; } -#else - (void)slot; -#endif + gl_shadersenabled = false; } EXPORT void HWRAPI(UnSetShader) (void) { -#ifdef GL_SHADERS - gl_shaderstate.current = NULL; - gl_shaderstate.type = 0; - gl_shaderstate.program = 0; + if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed + { + gl_shaderstate.current = NULL; + gl_shaderstate.type = 0; + gl_shaderstate.program = 0; - if (pglUseProgram) - pglUseProgram(0); -#endif + if (pglUseProgram) + pglUseProgram(0); + } gl_shadersenabled = false; } + // -----------------+ // SetNoTexture : Disable texture // -----------------+ @@ -914,7 +871,7 @@ static void GLPerspective(GLfloat fovy, GLfloat aspect) const GLfloat zNear = NEAR_CLIPPING_PLANE; const GLfloat zFar = FAR_CLIPPING_PLANE; const GLfloat radians = (GLfloat)(fovy / 2.0f * M_PIl / 180.0f); - const GLfloat sine = sin(radians); + const GLfloat sine = (GLfloat)sin(radians); const GLfloat deltaZ = zFar - zNear; GLfloat cotangent; @@ -928,9 +885,11 @@ static void GLPerspective(GLfloat fovy, GLfloat aspect) m[1][1] = cotangent; m[2][2] = -(zFar + zNear) / deltaZ; m[3][2] = -2.0f * zNear * zFar / deltaZ; + pglMultMatrixf(&m[0][0]); } + // -----------------+ // SetModelView : // -----------------+ @@ -1639,7 +1598,6 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade) { -#ifdef GL_SHADERS gl_shader_t *shader = gl_shaderstate.current; if (gl_shadersenabled && (shader != NULL) && pglUseProgram) @@ -1687,9 +1645,9 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF if (Surface != NULL) { - UNIFORM_1(shader->uniforms[gluniform_lighting], Surface->LightInfo.light_level, pglUniform1f); - UNIFORM_1(shader->uniforms[gluniform_fade_start], Surface->LightInfo.fade_start, pglUniform1f); - UNIFORM_1(shader->uniforms[gluniform_fade_end], Surface->LightInfo.fade_end, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_lighting], (GLfloat)Surface->LightInfo.light_level, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_fade_start], (GLfloat)Surface->LightInfo.fade_start, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_fade_end], (GLfloat)Surface->LightInfo.fade_end, pglUniform1f); } UNIFORM_1(shader->uniforms[gluniform_leveltime], ((float)shader_leveltime) / TICRATE, pglUniform1f); @@ -1699,12 +1657,6 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF #undef UNIFORM_3 #undef UNIFORM_4 } -#else - (void)Surface; - (void)poly; - (void)tint; - (void)fade; -#endif } static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) @@ -1843,7 +1795,7 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) // code that is common between DrawPolygon and DrawIndexedTriangles // DrawScreenTexture also can use this function for fancier screen texture drawing // the corona thing is there too, i have no idea if that stuff works with DrawIndexedTriangles and batching -static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD PolyFlags) +static void PreparePolygon(FSurfaceInfo *pSurf, FBITFIELD PolyFlags) { static GLRGBAFloat poly = {0,0,0,0}; static GLRGBAFloat tint = {0,0,0,0}; @@ -1851,39 +1803,41 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD SetBlend(PolyFlags); //TODO: inline (#pragma..) - // PolyColor if (pSurf) { - // If Modulated, mix the surface colour to the texture + // If modulated, mix the surface colour to the texture if (CurrentPolyFlags & PF_Modulated) - { - // Poly color - poly.red = byte2float[pSurf->PolyColor.s.red]; - poly.green = byte2float[pSurf->PolyColor.s.green]; - poly.blue = byte2float[pSurf->PolyColor.s.blue]; - poly.alpha = byte2float[pSurf->PolyColor.s.alpha]; - pglColor4ubv((GLubyte*)&pSurf->PolyColor.s); + + // If the surface is either modulated or colormapped, or both + if (CurrentPolyFlags & (PF_Modulated | PF_ColorMapped)) + { + poly.red = byte2float[pSurf->PolyColor.s.red]; + poly.green = byte2float[pSurf->PolyColor.s.green]; + poly.blue = byte2float[pSurf->PolyColor.s.blue]; + poly.alpha = byte2float[pSurf->PolyColor.s.alpha]; } - // Tint color - tint.red = byte2float[pSurf->TintColor.s.red]; - tint.green = byte2float[pSurf->TintColor.s.green]; - tint.blue = byte2float[pSurf->TintColor.s.blue]; - tint.alpha = byte2float[pSurf->TintColor.s.alpha]; - - // Fade color - fade.red = byte2float[pSurf->FadeColor.s.red]; - fade.green = byte2float[pSurf->FadeColor.s.green]; - fade.blue = byte2float[pSurf->FadeColor.s.blue]; - fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; - - if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded) + // Only if the surface is colormapped + if (CurrentPolyFlags & PF_ColorMapped) { - pglActiveTexture(GL_TEXTURE2); - pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId); - pglActiveTexture(GL_TEXTURE0); - lt_downloaded = pSurf->LightTableId; + tint.red = byte2float[pSurf->TintColor.s.red]; + tint.green = byte2float[pSurf->TintColor.s.green]; + tint.blue = byte2float[pSurf->TintColor.s.blue]; + tint.alpha = byte2float[pSurf->TintColor.s.alpha]; + + fade.red = byte2float[pSurf->FadeColor.s.red]; + fade.green = byte2float[pSurf->FadeColor.s.green]; + fade.blue = byte2float[pSurf->FadeColor.s.blue]; + fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; + + if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded) + { + pglActiveTexture(GL_TEXTURE2); + pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId); + pglActiveTexture(GL_TEXTURE0); + lt_downloaded = pSurf->LightTableId; + } } } @@ -1895,7 +1849,7 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD // -----------------+ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags) { - PreparePolygon(pSurf, pOutVerts, PolyFlags); + PreparePolygon(pSurf, PolyFlags); pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x); pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].s); @@ -1913,7 +1867,7 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray) { - PreparePolygon(pSurf, pOutVerts, PolyFlags); + PreparePolygon(pSurf, PolyFlags); pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x); pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].s); @@ -2089,7 +2043,7 @@ static void gld_BuildSky(int row_count, int col_count) // //----------------------------------------------------------------------------- -static void RenderDome(INT32 skytexture) +static void RenderDome(INT32 skytexnum) { int i, j; int vbosize; @@ -2101,7 +2055,7 @@ static void RenderDome(INT32 skytexture) vbosize = 2 * rows * (columns * 2 + 2) + columns * 2; // Build the sky dome! Yes! - if (lasttex != skytexture) + if (lasttex != skytexnum) { // delete VBO when already exists if (gl_ext_arb_vertex_buffer_object) @@ -2110,7 +2064,7 @@ static void RenderDome(INT32 skytexture) pglDeleteBuffers(1, &vbo->id); } - lasttex = skytexture; + lasttex = skytexnum; gld_BuildSky(rows, columns); if (gl_ext_arb_vertex_buffer_object) @@ -2774,7 +2728,9 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) static boolean special_splitscreen; GLdouble used_fov; boolean shearing = false; + pglLoadIdentity(); + if (stransform) { used_fov = stransform->fovxangle; @@ -2795,7 +2751,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) if (stransform->roll) pglRotatef(stransform->rollangle, 0.0f, 0.0f, 1.0f); - pglRotatef(stransform->anglex, 1.0f, 0.0f, 0.0f); + pglRotatef(stransform->anglex , 1.0f, 0.0f, 0.0f); pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f); pglTranslatef(-stransform->x, -stransform->z, -stransform->y); @@ -2829,6 +2785,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) } else GLPerspective((GLfloat)used_fov, ASPECT_RATIO); + pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer) pglMatrixMode(GL_MODELVIEW); @@ -2995,7 +2952,7 @@ EXPORT void HWRAPI(DrawScreenTexture)(int tex, FSurfaceInfo *surf, FBITFIELD pol pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]); - PreparePolygon(surf, NULL, surf ? polyflags : (PF_NoDepthTest)); + PreparePolygon(surf, surf ? polyflags : (PF_NoDepthTest)); if (!surf) pglColor4ubv(white); @@ -3305,7 +3262,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int tex, int width, int height) pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); if (HWR_ShouldUsePaletteRendering()) - UnSetShader(); + pglUseProgram(0); tex_downloaded = screenTextures[tex]; } diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index ba3cccbce..34b2d3cf7 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -123,6 +123,8 @@ extern GLint maximumAnisotropy; extern INT32 oglflags; extern GLint textureformatGL; +extern GLfloat projMatrix[16]; + typedef enum { GLF_NOZBUFREAD = 0x01, diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 08c2d7c33..eb9fdfa92 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -42,19 +42,17 @@ #include "p_local.h" // camera[] #include "p_tick.h" -#ifdef HWRENDER -#include "hardware/hw_main.h" -#endif - -#ifdef HAVE_BLUA #include "lua_hud.h" #include "lua_hudlib_drawlist.h" #include "lua_hook.h" -#endif #include "s_sound.h" // song credits #include "k_kart.h" +#ifdef HWRENDER +#include "hardware/hw_main.h" +#endif + // coords are scaled #define HU_INPUTX 0 #define HU_INPUTY 0 @@ -94,9 +92,7 @@ static boolean headsupactive = false; boolean hu_showscores; // draw rankings static char hu_tick; -#ifdef HAVE_BLUA static huddrawlist_h luahuddrawlist_scores; -#endif patch_t *rflagico; patch_t *bflagico; @@ -349,9 +345,7 @@ void HU_Init(void) // set shift translation table shiftxform = english_shiftxform; -#ifdef HAVE_BLUA luahuddrawlist_scores = LUA_HUD_CreateDrawList(); -#endif HU_LoadGraphics(); } @@ -555,7 +549,8 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) const char *newmsg; INT32 spc = 1; // used if nodenum[1] is a space. char *nodenum = (char*) malloc(3); - strncpy(nodenum, msg+3, 3); + memcpy(nodenum, msg+3, 2); + nodenum[2] = '\0'; // check for undesirable characters in our "number" if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) { @@ -571,15 +566,15 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) } } // I'm very bad at C, I swear I am, additional checks eww! - if (spc != 0) + if (spc != 0) + { + if (msg[5] != ' ') { - if (msg[5] != ' ') - { - HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - free(nodenum); - return; - } + HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); + free(nodenum); + return; } + } target = atoi((const char*) nodenum); // turn that into a number free(nodenum); @@ -887,10 +882,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. -#ifdef HAVE_BLUA if (LUAh_PlayerMsg(playernum, target, flags, msg, spam_eatmsg)) return; -#endif if (spam_eatmsg) return; // don't proceed if we were supposed to eat the message. @@ -1233,7 +1226,8 @@ static void HU_queueChatChar(INT32 c) return; } - strncpy(nodenum, msg+3, 3); + memcpy(nodenum, msg+3, 2); + nodenum[2] = '\0'; // check for undesirable characters in our "number" if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) @@ -1944,7 +1938,8 @@ static void HU_DrawChat(void) nodenum = (char*) malloc(3); - strncpy(nodenum, w_chat+3, 3); + memcpy(nodenum, w_chat+3, 2); + nodenum[2] = '\0'; n = atoi((const char*) nodenum); // turn that into a number free(nodenum); // special cases: @@ -2425,19 +2420,18 @@ void HU_Drawer(void) { if (netgame || multiplayer) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_rankings)) -#endif HU_DrawRankings(); -#ifdef HAVE_BLUA - if (renderisnewtic) - { - LUA_HUD_ClearDrawList(luahuddrawlist_scores); - LUAh_ScoresHUD(luahuddrawlist_scores); - } - LUA_HUD_DrawList(luahuddrawlist_scores); -#endif + + if (renderisnewtic) + { + LUA_HUD_ClearDrawList(luahuddrawlist_scores); + LUAh_ScoresHUD(luahuddrawlist_scores); + } + + LUA_HUD_DrawList(luahuddrawlist_scores); } + if (demo.playback) { HU_DrawDemoInfo(); @@ -2585,7 +2579,7 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags) UINT8 barcolor = 31; // color we use for the bars (green, yellow, red or black) SINT8 i = 0; SINT8 yoffset = 6; - INT32 dx; + //INT32 dx; gfxnum = Ping_gfx_num(lag); @@ -2932,7 +2926,10 @@ void HU_DoCEcho(const char *msg) I_OutputMsg("%s\n", msg); // print to log +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" // This is fine, we set null byte later strncpy(cechotext, msg, sizeof(cechotext)); +#pragma GCC diagnostic pop strncat(cechotext, "\\", sizeof(cechotext) - strlen(cechotext) - 1); cechotext[sizeof(cechotext) - 1] = '\0'; cechotimer = cechoduration; diff --git a/src/i_system.h b/src/i_system.h index 87198c923..a78eb5c5e 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -296,40 +296,6 @@ char *I_GetUserName(void); */ INT32 I_mkdir(const char *dirname, INT32 unixright); -typedef struct { - int FPU : 1; ///< FPU availabile - int CPUID : 1; ///< CPUID instruction - int RDTSC : 1; ///< RDTSC instruction - int MMX : 1; ///< MMX features - int MMXExt : 1; ///< MMX Ext. features - int CMOV : 1; ///< Pentium Pro's "cmov" - int AMD3DNow : 1; ///< 3DNow features - int AMD3DNowExt: 1; ///< 3DNow! Ext. features - int SSE : 1; ///< SSE features - int SSE2 : 1; ///< SSE2 features - int SSE3 : 1; ///< SSE3 features - int IA64 : 1; ///< Running on IA64 - int AMD64 : 1; ///< Running on AMD64 - int AltiVec : 1; ///< AltiVec features - int FPPE : 1; ///< floating-point precision error - int PFC : 1; ///< TBD? - int cmpxchg : 1; ///< ? - int cmpxchg16b : 1; ///< ? - int cmp8xchg16 : 1; ///< ? - int FPE : 1; ///< FPU Emu - int DEP : 1; ///< Data excution prevent - int PPCMM64 : 1; ///< PowerPC Movemem 64bit ok? - int ALPHAbyte : 1; ///< ? - int PAE : 1; ///< Physical Address Extension - int CPUs : 8; -} CPUInfoFlags; - - -/** \brief Info about CPU - \return CPUInfo in bits -*/ -const CPUInfoFlags *I_CPUInfo(void); - /** \brief Find main WAD \return path to main WAD */ diff --git a/src/k_kart.c b/src/k_kart.c index b9f74de90..4024a75dd 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5,16 +5,27 @@ /// All of the SRB2kart-unique stuff. #include "doomdef.h" +#include "doomstat.h" +#include "doomtype.h" +#include "command.h" +#include "d_netcmd.h" +#include "d_player.h" #include "hu_stuff.h" #include "g_game.h" +#include "m_fixed.h" #include "m_random.h" #include "m_menu.h" // ffdhidshfuisduifigergho9igj89dgodhfih AAAAAAAAAA #include "p_local.h" #include "p_slopes.h" +#include "r_defs.h" #include "r_draw.h" #include "r_local.h" +#include "r_state.h" +#include "r_things.h" #include "s_sound.h" +#include "screen.h" #include "st_stuff.h" +#include "tables.h" #include "v_video.h" #include "z_zone.h" #include "m_misc.h" @@ -25,6 +36,12 @@ #include "lua_hook.h" // For MobjDamage and ShouldDamage #include "d_main.h" // found_extra_kart +#include "i_video.h" + +#ifdef HWRENDER +#include "hardware/hw_main.h" +#endif + // Hud offset cvars #define IMPL_HUD_OFFSET_X(name)\ consvar_t cv_##name##_xoffset = {"hud_" #name "_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -592,7 +609,7 @@ UINT8 K_GetKartColorByName(const char *name) } UINT8 K_GetHudColor(void) -{ +{ if (cv_colorizedhud.value){ if (cv_colorizedhudcolor.value) return cv_colorizedhudcolor.value; } @@ -2210,7 +2227,6 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto { UINT8 scoremultiply = 1; // PS: Inflictor is unused for all purposes here and is actually only ever relevant to Lua. It may be nil too. -#ifdef HAVE_BLUA boolean force = false; // Used to check if Lua ShouldSpin should get us damaged reguardless of flashtics or heck knows what. UINT8 shouldForce = LUAh_ShouldSpin(player, inflictor, source); if (P_MobjWasRemoved(player->mo)) @@ -2219,11 +2235,6 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto force = true; else if (shouldForce == 2) return; -#else - static const boolean force = false; - (void)inflictor; // in case some weirdo doesn't want Lua. -#endif - if (!trapitem && G_BattleGametype()) { @@ -2247,10 +2258,8 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto } } -#ifdef HAVE_BLUA if (LUAh_PlayerSpin(player, inflictor, source)) // Let Lua do its thing or overwrite if it wants to. Make sure to let any possible instashield happen because we didn't get "damaged" in this case. return; -#endif if (source && source != player->mo && source->player) K_PlayHitEmSound(source); @@ -2356,7 +2365,6 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor) { UINT8 scoremultiply = 1; // PS: Inflictor is unused for all purposes here and is actually only ever relevant to Lua. It may be nil too. -#ifdef HAVE_BLUA boolean force = false; // Used to check if Lua ShouldSquish should get us damaged reguardless of flashtics or heck knows what. UINT8 shouldForce = LUAh_ShouldSquish(player, inflictor, source); if (P_MobjWasRemoved(player->mo)) @@ -2365,10 +2373,6 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor) force = true; else if (shouldForce == 2) return; -#else - static const boolean force = false; - (void)inflictor; // Please stop forgetting to put inflictor in yer functions thank -Lat' -#endif if (G_BattleGametype()) { @@ -2392,10 +2396,8 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor) } } -#ifdef HAVE_BLUA if (LUAh_PlayerSquish(player, inflictor, source)) // Let Lua do its thing or overwrite if it wants to. Make sure to let any possible instashield happen because we didn't get "damaged" in this case. return; -#endif player->kartstuff[k_sneakertimer] = 0; player->kartstuff[k_driftboost] = 0; @@ -2474,7 +2476,6 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b { fixed_t upgoer; UINT8 scoremultiply = 1; -#ifdef HAVE_BLUA boolean force = false; // Used to check if Lua ShouldExplode should get us damaged reguardless of flashtics or heck knows what. UINT8 shouldForce = LUAh_ShouldExplode(player, inflictor, source); @@ -2485,10 +2486,6 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b else if (shouldForce == 2) return; -#else - static const boolean force = false; -#endif - if (G_BattleGametype()) { if (K_IsPlayerWanted(player)) @@ -2511,10 +2508,8 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b } } -#ifdef HAVE_BLUA if (LUAh_PlayerExplode(player, inflictor, source)) // Same thing. Also make sure to let Instashield happen blah blah return; -#endif if (source && source != player->mo && source->player) K_PlayHitEmSound(source); @@ -4392,6 +4387,8 @@ void K_RepairOrbitChain(mobj_t *orbit) // Then recount to make sure item amount is correct if (orbit->target && orbit->target->player) { + player_t *player = orbit->target->player; + INT32 num = 0; mobj_t *cur = orbit->target->hnext; @@ -4401,14 +4398,14 @@ void K_RepairOrbitChain(mobj_t *orbit) { prev = cur; cur = cur->hnext; - if (++num > orbit->target->player->kartstuff[k_itemamount]) + if (++num > player->kartstuff[k_itemamount]) P_RemoveMobj(prev); else prev->movedir = num; } - if (orbit->target->player->kartstuff[k_itemamount] != num) - orbit->target->player->kartstuff[k_itemamount] = num; + if (player->kartstuff[k_itemamount] != num) + player->kartstuff[k_itemamount] = num; } } @@ -6923,7 +6920,7 @@ static patch_t *kp_lapsticker; static patch_t *kp_lapstickerbig; static patch_t *kp_lapstickerbig2; static patch_t *kp_lapstickerwide; -static patch_t *kp_lapstickernarrow; +//static patch_t *kp_lapstickernarrow; static patch_t *kp_splitlapflag; static patch_t *kp_bumpersticker; static patch_t *kp_bumperstickerwide; @@ -6938,7 +6935,7 @@ static patch_t *kp_lapstickerclr; static patch_t *kp_lapstickerbigclr; static patch_t *kp_lapstickerbig2clr; static patch_t *kp_lapstickerwideclr; -static patch_t *kp_lapstickernarrowclr; +//static patch_t *kp_lapstickernarrowclr; static patch_t *kp_bumperstickerclr; static patch_t *kp_bumperstickerwideclr; static patch_t *kp_karmastickerclr; @@ -7011,6 +7008,16 @@ static patch_t *kp_lapanim_number[10][3]; static patch_t *kp_lapanim_emblem[2]; static patch_t *kp_lapanim_hand[3]; +static patch_t *nametagpic; +static patch_t *nametagline; +static patch_t *nametagspeed; +static patch_t *nametagweight; + +static patch_t *driftgauge; +static patch_t *driftgaugecolor; +static patch_t *driftgaugesmall; +static patch_t *driftgaugesmallcolor; + static patch_t *kp_yougotem; static patch_t *skp_smallsticker; @@ -7034,7 +7041,7 @@ void K_LoadKartHUDGraphics(void) kp_timestickerwide = W_CachePatchName("K_STTIMW", PU_HUDGFX); kp_lapsticker = W_CachePatchName("K_STLAPS", PU_HUDGFX); kp_lapstickerwide = W_CachePatchName("K_STLAPW", PU_HUDGFX); - kp_lapstickernarrow = W_CachePatchName("K_STLAPN", PU_HUDGFX); + //kp_lapstickernarrow = W_CachePatchName("K_STLAPN", PU_HUDGFX); kp_splitlapflag = W_CachePatchName("K_SPTLAP", PU_HUDGFX); kp_bumpersticker = W_CachePatchName("K_STBALN", PU_HUDGFX); kp_bumperstickerwide = W_CachePatchName("K_STBALW", PU_HUDGFX); @@ -7067,7 +7074,7 @@ void K_LoadKartHUDGraphics(void) kp_lapstickerbig2 = W_CachePatchName("K_STLA2B", PU_HUDGFX); } - //Colourized hud + // Colourized hud if (clr_hud) { kp_timestickerclr = W_CachePatchName("K_SCTIME", PU_HUDGFX); @@ -7103,7 +7110,7 @@ void K_LoadKartHUDGraphics(void) } } - //KartZ speedo + // KartZ speedo if (kartzspeedo) { kp_kartzspeedo[0] = W_CachePatchName("K_KZSP1", PU_HUDGFX); @@ -7132,7 +7139,24 @@ void K_LoadKartHUDGraphics(void) kp_kartzspeedo[23] = W_CachePatchName("K_KZSP24", PU_HUDGFX); kp_kartzspeedo[24] = W_CachePatchName("K_KZSP25", PU_HUDGFX); } + + // Nametags + if (nametaggfx) + { + + nametagpic = W_CachePatchName("NTLINE", PU_HUDGFX); + nametagline = W_CachePatchName("NTLINEV", PU_HUDGFX); + nametagspeed = W_CachePatchName("NTSP", PU_HUDGFX); + nametagweight = W_CachePatchName("NTWH", PU_HUDGFX); + } + if (driftgaugegfx){ + driftgauge = W_CachePatchName("K_DGAU", PU_HUDGFX); + driftgaugecolor = W_CachePatchName("K_DCAU", PU_HUDGFX); + driftgaugesmall = W_CachePatchName("K_DGSU", PU_HUDGFX); + driftgaugesmallcolor = W_CachePatchName("K_DCSU", PU_HUDGFX); + } + // Starting countdown kp_startcountdown[0] = W_CachePatchName("K_CNT3A", PU_HUDGFX); kp_startcountdown[1] = W_CachePatchName("K_CNT2A", PU_HUDGFX); @@ -7525,7 +7549,7 @@ static void K_initKartHUD(void) ITEM2_X = BASEVIDWIDTH-39 + cv_item_xoffset.value; ITEM2_Y = -8 + cv_item_yoffset.value; - LAPS2_X = BASEVIDWIDTH-40 + cv_laps_xoffset.value; + LAPS2_X = BASEVIDWIDTH-3 + cv_laps_xoffset.value; LAPS2_Y = (BASEVIDHEIGHT/2)-13 + cv_laps_yoffset.value; POSI2_X = BASEVIDWIDTH -4 + cv_posi_xoffset.value; @@ -7592,6 +7616,91 @@ INT32 K_calcSplitFlags(INT32 snapflags) return (splitflags|snapflags); } +void K_getItemBoxDrawinfo(drawinfo_t *out) +{ + INT32 fx, fy, fflags; + + // pain and suffering defined below + if (splitscreen < 2) // don't change shit for THIS splitscreen. + { + fx = ITEM_X; + fy = ITEM_Y; + fflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); + } + else // now we're having a fun game. + { + if (!(stplyrnum & 1)) // If we are P1 or P3... + { + fx = ITEM_X; + fy = ITEM_Y; + fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + fx = ITEM2_X; + fy = ITEM2_Y; + fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom + } + } + + out->x = fx; + out->y = fy; + out->flags = fflags; +} + +void K_getLapsDrawinfo(drawinfo_t *out) +{ + INT32 fx, fy, fflags; + + // pain and suffering defined below + if (splitscreen < 2) // don't change shit for THIS splitscreen. + { + fx = LAPS_X; + fy = LAPS_Y; + fflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); + } + else + { + if (!(stplyrnum & 1)) // If we are P1 or P3... + { + fx = LAPS_X; + fy = LAPS_Y; + fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + fx = LAPS2_X; + fy = LAPS2_Y; + fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + } + } + + out->x = fx; + out->y = fy; + out->flags = fflags; +} + +void K_getMinimapDrawinfo(drawinfo_t *out) +{ + INT32 fx = MINI_X, fy = MINI_Y, fflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) + + out->x = fx; + out->y = fy; + out->flags = fflags; +} + +patch_t *K_getItemBoxPatch(boolean small, boolean dark) +{ + UINT8 ofs = (cv_darkitembox.value && dark ? 1 : 0) + (small ? 2 : 0); + return (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[ofs] : kp_itembg[ofs]; +} + +patch_t *K_getItemMulPatch(boolean small) +{ + UINT8 ofs = small ? 1 : 0; + return K_UseColorHud() ? kp_itemmulstickerclr[ofs] : kp_itemmulsticker[ofs]; +} + static void K_drawKartStats(void) { INT32 x, y, spdoffset, flags; @@ -7609,13 +7718,10 @@ static void K_drawKartStats(void) if (stplyr == &players[displayplayers[splitnum]]) break; } - -#ifdef HAVE_BLUA + if (!LUA_HudEnabled(hud_statdisplay)) return; -#endif - - + // I tried my best, but this is still mess :/ if (splitscreen) { @@ -7717,12 +7823,8 @@ static void K_drawKartItem(void) const UINT8 offset = ((splitscreen > 1) ? 1 : 0); patch_t *localpatch = kp_nodraw; patch_t *localbg; - - if (cv_colorizeditembox.value && K_UseColorHud()) - localbg = ((offset) ? kp_itembgclr[2] : kp_itembgclr[0]); - else - localbg = ((offset) ? kp_itembg[2] : kp_itembg[0]); - + boolean dark = false; + patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]); INT32 fx = 0, fy = 0, fflags = 0; // final coords for hud and flags... //INT32 splitflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); @@ -7733,9 +7835,9 @@ static void K_drawKartItem(void) UINT8 localcolor = SKINCOLOR_NONE; SINT8 colormode = TC_RAINBOW; UINT8 *colmap = NULL; - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - boolean flipamount = false; // Used for 3P/4P splitscreen to flip item amount stuff + UINT8 *colormap = NULL; + + boolean flipamount = splitscreen > 1 && stplyrnum & 1; // Used for 3P/4P splitscreen to flip item amount stuff if (stplyr->kartstuff[k_itemroulette]) { @@ -7882,8 +7984,7 @@ static void K_drawKartItem(void) break; case KITEM_INVINCIBILITY: localpatch = localinv; - if (cv_darkitembox.value) - localbg = (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[offset + 1] : kp_itembg[offset + 1]; + dark = true; break; case KITEM_BANANA: localpatch = kp_banana[offset]; @@ -7905,8 +8006,7 @@ static void K_drawKartItem(void) break; case KITEM_SPB: localpatch = kp_selfpropelledbomb[offset]; - if (cv_darkitembox.value) - localbg = (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[offset + 1] : kp_itembg[offset + 1]; + dark = true; break; case KITEM_GROW: localpatch = kp_grow[offset]; @@ -7916,8 +8016,7 @@ static void K_drawKartItem(void) break; case KITEM_THUNDERSHIELD: localpatch = kp_thundershield[offset]; - if (cv_darkitembox.value) - localbg = (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[offset + 1] : kp_itembg[offset + 1]; + dark = true; break; case KITEM_HYUDORO: localpatch = kp_hyudoro[offset]; @@ -7958,47 +8057,25 @@ static void K_drawKartItem(void) } } - // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. - { - fx = ITEM_X; - fy = ITEM_Y; - fflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); - } - else // now we're having a fun game. - { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... - { - fx = ITEM_X; - fy = ITEM_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = ITEM2_X; - fy = ITEM2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom - flipamount = true; - } - } + localbg = K_getItemBoxPatch((boolean)offset, dark); + drawinfo_t info; + K_getItemBoxDrawinfo(&info); + fx = info.x; + fy = info.y; + fflags = info.flags; if (localcolor != SKINCOLOR_NONE) colmap = R_GetTranslationColormap(colormode, localcolor, GTC_CACHE); + if (K_UseColorHud()) + colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - if (cv_colorizeditembox.value && K_UseColorHud()) - V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg,colormap); - else - V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, localbg); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg, cv_colorizeditembox.value ? colormap : NULL); // Then, the numbers: if (stplyr->kartstuff[k_itemamount] >= numberdisplaymin && !stplyr->kartstuff[k_itemroulette]) { - if (!K_UseColorHud()) - V_DrawScaledPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), kp_itemmulsticker[offset]); - else //Colourized hud - V_DrawMappedPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), kp_itemmulstickerclr[offset], colormap); // flip this graphic for p2 and p4 in split and shift it. - + localbg = K_getItemMulPatch((boolean)offset); + V_DrawMappedPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), localbg, colormap); // flip this graphic for p2 and p4 in split and shift it. V_DrawFixedPatch(fx< 0) { V_DrawMappedPatch(bumperx-2, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[0], colormap); @@ -8451,9 +8521,7 @@ static boolean K_drawKartPositionFaces(void) V_DrawMappedPatch(bumperx, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[1], colormap); } } -#ifdef HAVE_BLUA } // A new level of stupidity: checking if lua is enabled to close a bracket. :Fascinating: -#endif } if (i == strank) @@ -8603,35 +8671,17 @@ static void K_drawKartLaps(void) { INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); INT32 fx = 0, fy = 0, fflags = 0; // stuff for 3p / 4p splitscreen. - boolean flipstring = false; // used for 3p or 4p + boolean flipstring = splitscreen > 1 && stplyrnum & 1; // used for 3p or 4p INT32 stringw = 0; // used with the above - + + drawinfo_t info; + K_getLapsDrawinfo(&info); + fx = info.x; + fy = info.y; + fflags = info.flags; + if (splitscreen > 1) { - // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = splitflags; - } - else - { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = LAPS2_X; - fy = LAPS2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom - flipstring = true; // make the string right aligned and other shit - } - } - if (stplyr->exiting) // draw stuff as god intended. { V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, kp_splitlapflag); @@ -8642,8 +8692,8 @@ static void K_drawKartLaps(void) { stringw = V_StringWidth(va("%d/%d", stplyr->laps+1, cv_numlaps.value), 0); - V_DrawScaledPatch(BASEVIDWIDTH-stringw-16, fy, V_HUDTRANS|fflags, kp_splitlapflag); - V_DrawRightAlignedString(BASEVIDWIDTH-3, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); + V_DrawScaledPatch(fx-stringw-13, fy, V_HUDTRANS|fflags, kp_splitlapflag); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); } else // draw stuff NORMALLY. { @@ -8656,23 +8706,23 @@ static void K_drawKartLaps(void) if (!K_UseColorHud()) { if (K_BigLapSticker()) - V_DrawScaledPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig)); + V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig)); else - V_DrawScaledPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, kp_lapsticker); + V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, kp_lapsticker); } else //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); if (K_BigLapSticker()) - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr), colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr), colormap); else - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, kp_lapstickerclr, colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, kp_lapstickerclr, colormap); } if (stplyr->exiting) - V_DrawKartString(LAPS_X+33, LAPS_Y+3, V_HUDTRANS|splitflags, "FIN"); + V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, "FIN"); else - V_DrawKartString(LAPS_X+33, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); + V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); } } @@ -8840,31 +8890,22 @@ static void K_drawKartSpeedometer(void) static void K_drawKartBumpersOrKarma(void) { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); - INT32 fx = 0, fy = 0, fflags = 0; - boolean flipstring = false; // same as laps, used for splitscreen + INT32 fx, fy, fflags; + boolean flipstring = splitscreen > 1 && stplyrnum & 1; // same as laps, used for splitscreen INT32 stringw = 0; // used with the above + drawinfo_t info; + K_getLapsDrawinfo(&info); + fx = info.x; + fy = info.y; + fflags = info.flags; + if (splitscreen > 1) { - // we will reuse lap coords here since it's essentially the same shit. - - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = LAPS2_X; - fy = LAPS2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom - flipstring = true; - } - if (stplyr->kartstuff[k_bumper] <= 0) { + if (flipstring) + fx -= 37; V_DrawMappedPatch(fx, fy-1, V_HUDTRANS|fflags, kp_splitkarmabomb, colormap); V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); } @@ -8874,8 +8915,8 @@ static void K_drawKartBumpersOrKarma(void) { stringw = V_StringWidth(va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value), 0); - V_DrawMappedPatch(BASEVIDWIDTH-stringw-16, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); - V_DrawRightAlignedString(BASEVIDWIDTH-3, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); + V_DrawMappedPatch(fx-stringw-13, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); } else // draw bumpers normally. { @@ -8888,21 +8929,543 @@ static void K_drawKartBumpersOrKarma(void) { if (stplyr->kartstuff[k_bumper] <= 0) { - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker), colormap); - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker), colormap); + V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); } else { if (stplyr->kartstuff[k_bumper] > 9 && cv_kartbumpers.value > 9) - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide), colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide), colormap); else - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker), colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker), colormap); - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); + V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); } } } +// converts mobj coordinates into screen coordinates +// NOTE: use with V_NOSCALESTART! +// Code updated in Lua by GenericHeroGuy for libSG +// Badly ported to C by NepDisk and acutally made to work and fixed by Indev!(Thanks so much!) +// original code by Lat' +static void K_GetScreenCoords(vector2_t *vec, player_t *player, camera_t *came, mobj_t *target, fixed_t hofs, boolean dontclip) +{ + fixed_t camx, camy, camz; + angle_t camangle, camaiming; + fixed_t distfact; + fixed_t dist; + fixed_t xres; + fixed_t yres; + fixed_t fov; + fixed_t fovratio; + fixed_t offset; + boolean srcflip; + boolean targflip; + fixed_t y; + fixed_t x; + + // In case of early return we can check if those are negative + vec->x = -1; + vec->y = -1; + + // this should never happen but its also kart so ¯\_(ツ)_/¯ + if (!player || !target || !came) + return; + + if (player->awayviewtics) { + camx = player->awayviewmobj->x; + camy = player->awayviewmobj->y; + camz = player->awayviewmobj->z; + camangle = player->awayviewmobj->angle; + camaiming = player->awayviewaiming; + } + else if (came->chase) { + camx = came->x; + camy = came->y; + camz = came->z + (player->mo->eflags & MFE_VERTICALFLIP && came->height); + camangle = came->angle; + camaiming = came->aiming; + } + else { + camx = player->mo->x; + camy = player->mo->y; + camz = player->viewz; + camangle = player->mo->angle; + camaiming = player->aiming; + } + + xres = vid.width<<(FRACBITS-1); + yres = vid.height<<(FRACBITS-1); + fov = FixedDiv(xres, FINETANGENT(((FixedAngle(cv_fov.value/2)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095)); + + // X coordinate + // get difference between camangle and angle towards target + x = (INT32)camangle - (INT32)R_PointToAngle2(camx, camy, target->x, target->y); + + distfact = FINECOSINE((x>>ANGLETOFINESHIFT) & FINEMASK); + if (!distfact) distfact = 1; + + if (encoremode) + x = -x; + if (x < (fixed_t)ANGLE_270 || x > (fixed_t)ANGLE_90) + return; + + // flipping + targflip = target->eflags & MFE_VERTICALFLIP; + srcflip = player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP; + + // Y coordinate + // getting the angle difference here is a bit more involved... + // start by getting the height difference between the camera and target + y = camz - target->z - (targflip ? target->height/1.5 : 0); // for some reason needs to be divided by 1.5 idk + if (hofs) + y = y - (targflip ? -hofs : hofs); + + // then get the distance between camera and target + dist = R_PointToDist2(camx, camy, target->x, target->y); + +#ifdef HWRENDER + // NOW we can get the angle differnce + if (rendermode == render_opengl && cv_grshearing.value == 0) + { + angle_t yang = R_PointToAngle2(0, 0, dist, y); // not perspective + x = FixedMul(x, FINECOSINE((yang>>ANGLETOFINESHIFT) & FINEMASK)); // perspective + y = -camaiming - FixedDiv(yang, distfact); + + if (y < (fixed_t)ANGLE_270 || y > (fixed_t)ANGLE_90) // clip points behind the camera + return; + if (splitscreen == 1) // multiply by 1.25 for 2P splitscreen + y = y + (y/4) ; + if (srcflip) // flipcam + y = -y; + + y = FixedMul(FINETANGENT((((angle_t)(-y)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), fov) + yres; // project the angle to get our final Y coordinate + } + else +#endif + { + fovratio = FixedDiv(90*FRACUNIT, 180*FRACUNIT - FixedMul(cv_fov.value, 4*FRACUNIT/3)-FRACUNIT*-30); + + y = FixedDiv(y, FixedMul(dist, distfact)); + if (srcflip) + y = -y; // flipcam + if (y != INT32_MIN) // I_Error(): FixedDiv: divide by zero + y = FixedMul(FixedDiv(y, fovratio), xres) + yres; + //else print("NOPE!") + + offset = FixedMul(FINETANGENT(((camaiming+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), xres); + // this isn't fovtan... what am i even doing anymore + if (splitscreen == 1) + offset = 17*offset/10; + // OpenGL with software perspective is miscentered on non-16:10 resolutions +#ifdef HWRENDER + if (rendermode == render_opengl) + offset = FixedMul(offset, FixedDiv(104857, FixedDiv(xres, yres))); +#endif + // thanks fickle + offset = FixedDiv(offset, fovratio); + if (srcflip) + offset = -offset; // flipcam + y = y + offset; + } + + // project the angle to get our final X coordinate + x = FixedMul(FINETANGENT(((x+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), fov); + if (splitscreen == 1) // divide by 320/200 (1.6) on 2P splitscreen + x = (x/2) + (x/8); + x = x + xres; + + // now clip in screen-space + if (!dontclip && (x < 0 || x > xres*2 || y < 0 || y > yres*2)) + return; + + // get splitscreen index + int splitindex = stplyrnum; + + // adjust coords for splitscreen + if (splitscreen == 1){ // 2P + y = y>>1; + if (splitindex) + y = y + yres; + } + if (splitscreen >= 2) { // 3P or 4P + x = x>>1; + y = y>>1; + if (splitindex & 1) + x = x + xres; + if (splitindex >= 2) + y = y + yres; + } + + vec->y = y; + vec->x = x; +} + +//Slighty fixed by Alug and further rewritten by NepDisk +//Decided to port and highly modify sunflower version for the main nametag drawing with additions by NepDisk. My previous one was broken anyway due to the changed screencoords and noscalestart +static void K_drawNameTags(void) +{ + UINT8 i,j; + INT32 trans = 0; + vector2_t pos = {0}; + fixed_t tagwidth; + fixed_t tagwidthsmall; + fixed_t namex,namey; + int dup = 0; + int tagcolor = 0; + int vflags = 0; + int flipped = 0; + int tagsdisplayed = 0; + char *tag; + patch_t *icon; + INT32 hudtransflag = V_LocalTransFlag(); + boolean flipcam; + + if (!stplyr->mo || (stplyr->spectator && !cv_shownametagspectator.value) || splitscreen || (stplyr->exiting && !cv_shownametagfinish.value)) + return; + + // True if currently viewed player is flipped and has flipcam on + flipcam = (stplyr->pflags & PF_FLIPCAM) && (stplyr->mo->eflags & MFE_VERTICALFLIP); + + for (i = 0; i < MAXPLAYERS; i++) + { + UINT8 *cm; + fixed_t distance = 0; + fixed_t maxdistance = (10*cv_nametagdist.value)* mapobjectscale; + flipped = 0; + fixed_t z; + + if (i > PLAYERSMASK) + continue; + if (!players[i].mo || P_MobjWasRemoved(players[i].mo) || players[i].spectator || !playeringame[i]) + continue; + if (i == displayplayers[0] && !cv_showownnametag.value && !(leveltime < 130)) + continue; + if (!(i == displayplayers[0]) && leveltime < starttime) + continue; + if (players[i].kartstuff[k_hyudorotimer]) // player is invisible + continue; + distance = R_PointToDist(players[i].mo->x, players[i].mo->y); + if (distance > maxdistance) + continue; + if (!P_CheckSight(stplyr->mo, players[i].mo)) + continue; + + switch (cv_nametagtrans.value) + { + case 0: + trans = 0; + break; + case 1: + if (distance > (maxdistance*3/4)) + trans = V_60TRANS; + else + trans = 0; + break; + case 2: + if (distance > (maxdistance*3/1)) + trans = V_90TRANS; + else if (distance > (maxdistance*3/2)) + trans = V_80TRANS; + else if (distance > (maxdistance*3/3)) + trans = V_60TRANS; + else if (distance > (maxdistance*3/4)) + trans = V_40TRANS; + else if (distance > (maxdistance*3/5)) + trans = V_20TRANS; + else + trans = 0; + break; + case 3: + trans = V_40TRANS; + break; + case 4: + trans = hudtransflag; + break; + default: + break; + } + + dup = vid.dupx; + + // If flipcam is on, other player is flipped relative to us when we have different + // verticalflip flag value. Otherwise, they are simply flipped when verticalflip flag says + // so + if (flipcam) + flipped = (players[i].mo->eflags & MFE_VERTICALFLIP) != (stplyr->mo->eflags & MFE_VERTICALFLIP); + else + flipped = players[i].mo->eflags & MFE_VERTICALFLIP; + + z = players[i].mo->height; + + //Saltyhop hehe + if (cv_saltyhop.value && cv_nametaghop.value) + z += players[i].mo->spriteyoffset; + + K_GetScreenCoords(&pos, stplyr, camera, players[i].mo, z, false); + + //Check for negative screencoords + if (pos.x == -1 || pos.y == -1) + continue; + + tagsdisplayed += 1; + + if (tagsdisplayed > cv_nametagmaxplayers.value) + break; + + namex = pos.x>>FRACBITS; + namey = pos.y>>FRACBITS; + + tag = va("%s%s ", HU_SkinColorToConsoleColor(players[i].mo->color),player_names[i]); + icon = R_GetSkinFaceMini(players[i].mo->player); + + cm = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE); + tagcolor = colortranslations[players[i].mo->color][7]; + vflags = trans | V_NOSCALESTART; + tagwidth = cv_smallnametags.value ? dup*V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : dup*V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE); + tagwidthsmall = cv_smallnametags.value ? V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE); + + if (cv_smallnametags.value == 2 || cv_smallnametags.value == 1 || !nametaggfx) + { + if (flipped) + namey += dup*5; + else // small offset + namey -= dup*3; + + if (nametaggfx && cv_smallnametags.value == 1) + { + if (cv_nametagfacerank.value) + tagwidthsmall += icon->width - dup; + + // Have to draw the nametag using patches here since drawfill can't draw at this scale... + if (!flipped) + V_DrawFixedPatch(namex<height/2)<width/2); // add offset to other stuff + } + + //Name + V_DrawSmallString(namex, namey, V_ALLOWLOWERCASE | vflags, tag); + + if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + { + V_DrawSmallString(namex, namey - dup*5, vflags, va("\x84S%d ", players[i].kartspeed)); + V_DrawSmallString(namex + dup*10, namey - dup*5, vflags, va("\x87W%d ", players[i].kartweight)); + } + + if (cv_nametagscore.value) + { + if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + V_DrawSmallString(namex, namey - dup*10, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + else + V_DrawSmallString(namex, namey - dup*5, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + } + } + else + { + if (cv_nametagfacerank.value) + tagwidth += dup*(icon->width+1); + + if (flipped) + { + for (j = 0; j < 4; j++) + { + V_DrawFill(namex, namey, dup*3, dup*4, 31 | vflags); + V_DrawFill(namex+dup, namey, dup, dup*4, tagcolor | vflags); + namey += dup*4; + namex += dup; + } + namey -= dup*3; + V_DrawFill(namex, namey+dup*2, dup, dup, 31 | vflags); // a single black pixel + V_DrawFill(namex+dup, namey, tagwidth, dup*3, 31 | vflags); + V_DrawFill(namex+dup, namey+dup, tagwidth - dup, dup, tagcolor | vflags); + namex += dup*2; + } + else + { + for (j = 0; j < 4; j++) + { + namey -= dup*4; + V_DrawFill(namex, namey, dup*3, dup*4, 31 | vflags); + V_DrawFill(namex+dup, namey, dup, dup*4, tagcolor | vflags); + namex += dup; + } + V_DrawFill(namex, namey, dup, dup, 31 | vflags); + V_DrawFill(namex+dup, namey, tagwidth - dup*2, dup*3, 31 | vflags); + V_DrawFill(namex+dup, namey+dup, tagwidth - dup*3, dup, tagcolor | vflags); + } + + if (cv_nametagfacerank.value) + { + V_DrawMappedPatch(namex, namey - dup*(icon->height+1), vflags, icon, cm); + namex += dup*(icon->height+1); // add offset to other stuff + } + + V_DrawThinString(namex, namey - dup*10, V_ALLOWLOWERCASE | vflags, tag); + + if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + { + V_DrawScaledPatch(namex, namey - dup*20, vflags, nametagspeed); + V_DrawScaledPatch(namex + dup*18, namey - dup*20, vflags, nametagweight); + V_DrawString(namex + dup*9, namey - dup*19, V_ALLOWLOWERCASE | vflags, va("\x84%d ", players[i].kartspeed)); + V_DrawString(namex + dup*27, namey - dup*19, V_ALLOWLOWERCASE | vflags, va("\x87%d ", players[i].kartweight)); + } + + if (cv_nametagscore.value) + { + if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + V_DrawSmallString(namex, namey - dup*25, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + else + V_DrawSmallString(namex, namey - dup*15, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + } + } + } +} + +// Based on Driftgauge refactor by GenericHeroGuy ported from lua and expanded by NepDisk +static void K_drawDriftGauge(void) +{ + INT32 driftval = K_GetKartDriftSparkValue(stplyr); + INT32 driftcharge = min(driftval*4, stplyr->kartstuff[k_driftcharge]); + vector2_t pos = {0}; + fixed_t basex,basey; + INT32 drifttrans = 0; + INT32 hudtransflag = V_LocalTransFlag(); + int dup = vid.dupx; + int i,j; + + UINT8 driftcolors[3][4] = { + {0, 0, 10, 16}, // no drift + {215, 215, 204, 253}, // blue + {125, 125, 151, 159} // red + }; + + UINT8 driftskins[3] = { + SKINCOLOR_NONE, + SKINCOLOR_TEAL, + SKINCOLOR_SALMON, + }; + + UINT8 driftrainbow[18] = { + 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 + }; + + if (!stplyr->mo || !stplyr->kartstuff[k_drift] || (!splitscreen && !camera->chase)) + return; + + if (!splitscreen) + K_GetScreenCoords(&pos, stplyr, camera, stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale), false); + else + { + //Loop through each player camera for splitscreen. + for (j = 0; j <= stplyrnum; j++) + K_GetScreenCoords(&pos, stplyr, &camera[j], stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale), false); + } + + //Check for negative screencoords + if (pos.x == -1 || pos.y == -1) + return; + + basex = pos.x>>FRACBITS; + basey = pos.y>>FRACBITS; + + fixed_t barx; + fixed_t bary; + INT32 BAR_WIDTH; + + if (cv_driftgaugetrans.value) + drifttrans = hudtransflag; + else + drifttrans = 0; + + switch (cv_driftgaugestyle.value) + { + case 1: + case 2: + case 3: + if (driftgaugegfx) + { + if (cv_driftgaugestyle.value == 1 || cv_driftgaugestyle.value == 3) + { + barx = basex - dup*23; + BAR_WIDTH = dup*47; + } + else + { + barx = basex - dup*12; + BAR_WIDTH = dup*23; + } + + bary = basey - dup*2; + + INT32 limit = driftval * (driftcharge >= driftval*2 ? 2 : 1); + INT32 width = ((driftcharge - (driftcharge >= driftval ? limit : 0)) * BAR_WIDTH) / limit; + INT32 level = min(driftcharge / driftval, 2); + UINT8 *cmap; + + if (!K_UseColorHud()) + V_DrawMappedPatch(cv_driftgaugestyle.value == 2 ? basex + dup*11 : basex, basey, V_NOSCALESTART|V_OFFSET|drifttrans, cv_driftgaugestyle.value == 2 ? driftgaugesmall : driftgauge, NULL); + else //Colourized hud + { + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + V_DrawMappedPatch(cv_driftgaugestyle.value == 2 ? basex + dup*11 : basex, basey, V_NOSCALESTART|V_OFFSET|drifttrans, cv_driftgaugestyle.value == 2 ? driftgaugesmallcolor : driftgaugecolor, colormap); + } + + if (driftcharge >= driftval*4) // rainbow sparks + { + cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); + for (i = 0; i < 4; i++) + { + V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[(leveltime % 18) + 1] + i*2) | V_NOSCALESTART|drifttrans); + } + } + else // none/blue/red + { + cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[level],GTC_CACHE); + for (i = 0; i < 4; i++) + { + if (driftcharge >= driftval) + V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, driftcolors[level-1][i] | V_NOSCALESTART|drifttrans); + + V_DrawFill(barx, bary+dup*1+dup*i, width, dup, driftcolors[level][i] | V_NOSCALESTART|drifttrans); + } + } + + // right, also draw a cool number + //SG_DrawPaddedNum(v, basex + (dup*32), basey, driftcharge*100 / driftval, 3, "PINGN", V_NOSCALESTART|V_OFFSET|drifttrans, cmap) + if (cv_driftgaugestyle.value == 3) + V_DrawPaddedTallColorNum(basex + (dup*32), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, 3, cmap); + else + V_DrawPingNum(cv_driftgaugestyle.value == 2 ? basex + (dup*22) : basex + (dup*32), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, cmap); + } + break; + case 4: + { + UINT8 *cmap; + INT32 level = min(driftcharge / driftval, 2); + if (driftcharge >= driftval*4) + cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); + else + cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[level],GTC_CACHE); + + V_DrawPaddedTallColorNum(basex + (dup*16), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, 3, cmap); + } + break; + default: + break; + } +} + static fixed_t K_FindCheckX(fixed_t px, fixed_t py, angle_t ang, fixed_t mx, fixed_t my) { fixed_t dist, x; @@ -9161,7 +9724,7 @@ static void K_drawKartMinimap(void) patch_t *AutomapPic; INT32 i = 0; INT32 x, y; - INT32 minimaptrans, splitflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) + INT32 minimaptrans, splitflags; SINT8 localplayers[4]; SINT8 numlocalplayers = 0; @@ -9180,8 +9743,12 @@ static void K_drawKartMinimap(void) else return; // no pic, just get outta here - x = MINI_X - (AutomapPic->width/2); - y = MINI_Y - (AutomapPic->height/2); + drawinfo_t info; + K_getMinimapDrawinfo(&info); + x = info.x - (AutomapPic->width/2); + y = info.y - (AutomapPic->height/2); + splitflags = info.flags; + if (timeinmap > 105) { @@ -9345,10 +9912,9 @@ static void K_drawBattleFullscreen(void) INT32 splitflags = V_SNAPTOTOP; // I don't feel like properly supporting non-green resolutions, so you can have a misuse of SNAPTO instead fixed_t scale = FRACUNIT; boolean drawcomebacktimer = true; // lazy hack because it's cleaner in the long run. -#ifdef HAVE_BLUA + if (!LUA_HudEnabled(hud_battlecomebacktimer)) drawcomebacktimer = false; -#endif if (splitscreen) { @@ -9460,9 +10026,7 @@ static void K_drawBattleFullscreen(void) return; } -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_freeplay)) -#endif K_drawKartFreePlay(leveltime); } } @@ -9949,60 +10513,61 @@ void K_drawKartHUD(void) if (!demo.title && (!battlefullscreen || splitscreen)) { // Draw the CHECK indicator before the other items, so it's overlapped by everything else -#ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_check)) // delete lua when? -#endif + { if (cv_kartcheck.value && !splitscreen && !players[displayplayers[0]].exiting && !freecam) K_drawKartPlayerCheck(); + } // Draw WANTED status if (G_BattleGametype()) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_wanted)) -#endif K_drawKartWanted(); } if (cv_kartminimap.value) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_minimap)) -#endif K_drawKartMinimap(); } } if (battlefullscreen && !freecam) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_battlefullscreen)) -#endif K_drawBattleFullscreen(); return; } // Draw the item window -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_item) && !freecam) -#endif - K_drawKartItem(); + K_drawKartItem(); + + if (cv_driftgauge.value && !modeattacking) + { + if (LUA_HudEnabled(hud_driftgauge)) + K_drawDriftGauge(); + } + + if (cv_nametag.value) + { + if (LUA_HudEnabled(hud_nametags)) + K_drawNameTags(); + } // If not splitscreen, draw... if (!splitscreen && !demo.title) { // Draw the timestamp -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_time)) -#endif K_drawKartTimestamp(stplyr->realtime, TIME_X, TIME_Y, gamemap, 0); if (!modeattacking) { // The top-four faces on the left - /*#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_minirankings)) - #endif*/ + //if (LUA_HudEnabled(hud_minirankings)) isfreeplay = K_drawKartPositionFaces(); } } @@ -10010,16 +10575,16 @@ void K_drawKartHUD(void) if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode { if (!(splitscreen || demo.title)) -#ifdef HAVE_BLUA + { if (LUA_HudEnabled(hud_position)) -#endif K_drawInput(); + } if (!demo.title && cv_showstats.value) -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_statdisplay)) -#endif - K_drawKartStats(); + { + if (LUA_HudEnabled(hud_statdisplay)) + K_drawKartStats(); + } if (demo.title) // Draw title logo instead in demo.titles { @@ -10046,19 +10611,15 @@ void K_drawKartHUD(void) else if (G_RaceGametype()) // Race-only elements { // Draw the lap counter -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_gametypeinfo)) -#endif K_drawKartLaps(); if (!splitscreen) { // Draw the speedometer - // TODO: Make a better speedometer. -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_speedometer)) -#endif - K_drawKartSpeedometer(); + // TODO: Make a better speedometer. << done :p + if (LUA_HudEnabled(hud_speedometer)) + K_drawKartSpeedometer(); } if (isfreeplay) @@ -10066,26 +10627,20 @@ void K_drawKartHUD(void) else if (!modeattacking) { // Draw the numerical position -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_position)) -#endif K_DrawKartPositionNum(stplyr->kartstuff[k_position]); } else //if (!(demo.playback && hu_showscores)) { // Draw the input UI -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_position)) -#endif K_drawInput(); } } else if (G_BattleGametype()) // Battle-only { // Draw the hits left! -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_gametypeinfo)) -#endif K_drawKartBumpersOrKarma(); } } @@ -10103,11 +10658,11 @@ void K_drawKartHUD(void) int xoff = cv_dnft_xoffset.value; if (splitscreen > 1) - V_DrawCenteredString(BASEVIDWIDTH/4+xoff, LAPS_Y+1+yoff, K_calcSplitFlags(0), countstr); + V_DrawCenteredString(BASEVIDWIDTH/4+xoff, LAPS_Y+1+yoff, K_calcSplitFlags(V_SNAPTOBOTTOM), countstr); else { INT32 karlen = strlen(countstr)*6; // half of 12 - V_DrawKartString((BASEVIDWIDTH/2)-karlen+xoff, LAPS_Y+3+yoff, K_calcSplitFlags(0), countstr); + V_DrawKartString((BASEVIDWIDTH/2)-karlen+xoff, LAPS_Y+3+yoff, K_calcSplitFlags(V_SNAPTOBOTTOM), countstr); } } @@ -10129,9 +10684,7 @@ void K_drawKartHUD(void) // Draw FREE PLAY. if (isfreeplay && !stplyr->spectator && timeinmap > 113) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_freeplay)) -#endif K_drawKartFreePlay(leveltime); } diff --git a/src/k_kart.h b/src/k_kart.h index 803594790..a486f8cf2 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -18,6 +18,7 @@ void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor); void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, boolean local); UINT8 K_GetKartColorByName(const char *name); UINT8 K_GetHudColor(void); +boolean K_UseColorHud(void); void K_RegisterKartStuff(void); @@ -81,6 +82,7 @@ void K_CalculateBattleWanted(void); void K_CheckBumpers(void); void K_CheckSpectateStatus(void); void K_UpdateSpectateGrief(void); +void K_AutoAdjustNameTagPos(void); // sound stuff for lua void K_PlayAttackTaunt(mobj_t *source); @@ -96,5 +98,18 @@ void K_drawKartHUD(void); void K_drawKartFreePlay(UINT32 flashtime); void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UINT8 mode); +typedef struct +{ + INT32 x; + INT32 y; + INT32 flags; +} drawinfo_t; + +patch_t *K_getItemBoxPatch(boolean small, boolean dark); +patch_t *K_getItemMulPatch(boolean small); +void K_getItemBoxDrawinfo(drawinfo_t *out); +void K_getLapsDrawinfo(drawinfo_t *out); +void K_getMinimapDrawinfo(drawinfo_t *out); + // ========================================================================= #endif // __K_KART__ diff --git a/src/keys.h b/src/keys.h index cf3a0d060..d78ff574d 100644 --- a/src/keys.h +++ b/src/keys.h @@ -13,6 +13,10 @@ #ifndef __KEYS_H__ #define __KEYS_H__ +#include "console.h" + +extern consvar_t cv_nativekeyboard; + // These are the key codes as posted by the keyboard handler, // ascii codes are 0->127, // scancodes are 0x80 + 0->127 diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9e42e7e9f..be561e7ba 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -11,7 +11,6 @@ /// \brief basic functions for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "p_local.h" #include "p_setup.h" // So we can have P_SetupLevelSky #include "p_slopes.h" // P_GetZAt @@ -3267,6 +3266,4 @@ int LUA_BaseLib(lua_State *L) lua_pushvalue(L, LUA_GLOBALSINDEX); luaL_register(L, NULL, lib); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 0e705e2ea..0b93766b8 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -11,7 +11,6 @@ /// \brief blockmap library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "p_local.h" #include "r_main.h" // validcount #include "lua_script.h" @@ -257,6 +256,4 @@ int LUA_BlockmapLib(lua_State *L) { lua_register(L, "searchBlockmap", lib_searchBlockmap); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index f0fe3ac49..7d9cd67ec 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -11,13 +11,17 @@ /// \brief console modifying/etc library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "p_local.h" #include "g_game.h" #include "byteptr.h" #include "z_zone.h" +#include "d_netfil.h" + +#include "m_menu.h" +#include "w_wad.h" + #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors @@ -187,8 +191,8 @@ static int lib_comAddCommand(lua_State *L) const char *luaname = luaL_checkstring(L, 1); // must store in all lowercase - char *name = Z_StrDup(luaname); - strlwr(name); + char *comname = Z_StrDup(luaname); + strlwr(comname); luaL_checktype(L, 2, LUA_TFUNCTION); NOHUD @@ -221,25 +225,26 @@ static int lib_comAddCommand(lua_State *L) lua_pushvalue(L, 3); lua_rawseti(L, -2, 2); - lua_setfield(L, -2, name); + lua_setfield(L, -2, comname); // Try to add the Lua command - com_return = COM_AddLuaCommand(name); + com_return = COM_AddLuaCommand(comname); if (com_return < 0) { // failed to add -- free the lowercased name and return error - Z_Free(name); + Z_Free(comname); return luaL_error(L, "Couldn't add a new console command \"%s\"", luaname); } else if (com_return == 1) { // command existed already -- free our name as the old string will continue to be used - CONS_Printf("Replaced command \"%s\"\n", name); - Z_Free(name); + CONS_Printf("Replaced command \"%s\"\n", comname); + Z_Free(comname); } else { // new command was added -- do NOT free the string as it will forever be used by the console - CONS_Printf("Added command \"%s\"\n", name); + CONS_Printf("Added command \"%s\"\n", comname); } + return 0; } @@ -315,6 +320,10 @@ static int lib_cvRegisterVar(lua_State *L) const char *k; lua_Integer i; consvar_t *cvar; + + const char* category = NULL; + const char* menu_name = NULL; + luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); // Clear out all other possible arguments, leaving only the first one. NOHUD @@ -406,6 +415,18 @@ static int lib_cvRegisterVar(lua_State *L) lua_pop(L, 1); cvar->func = Lua_OnChange; } + else if (((i == 5 && !(cvar->flags & CV_CALL)) + || (cvar->flags & CV_CALL && i == 6)) + || (k && fasticmp(k, "category"))) + { + category = lua_isnoneornil(L, 4) ? NULL : lua_tostring(L, 4); + } + else if (((i == 6 && !(cvar->flags & CV_CALL)) + || (cvar->flags & CV_CALL && i == 7)) + || (k && fasticmp(k, "menuname"))) + { + menu_name = lua_isnoneornil(L, 4) ? NULL : lua_tostring(L, 4); + } lua_pop(L, 1); } #undef FIELDERROR @@ -430,6 +451,22 @@ static int lib_cvRegisterVar(lua_State *L) if (cvar->flags & CV_MODIFIED) return luaL_error(L, "failed to register cvar (probable conflict with internal variable/command names)"); + if (!(((cvar->flags & CV_HIDEN)) || (cvar->flags & CV_NOSHOWHELP)) && (cvar->PossibleValue || !(cvar->value == 0 && stricmp(cvar->string, "0")))) + { + if (!category) + { + char *temp = strdup(wadfiles[numwadfiles - 1]->filename); + nameonly(temp); + + category = temp; + } + + if (menu_name && menu_name[0] != '\0') + M_SlotCvarIntoModMenu(cvar, category, menu_name); + else + M_SlotCvarIntoModMenu(cvar, category, cvar->name); + } + // return cvar userdata return 1; } @@ -601,5 +638,3 @@ int LUA_ConsoleLib(lua_State *L) luaL_register(L, NULL, lib); return 0; } - -#endif diff --git a/src/lua_hook.h b/src/lua_hook.h index a17a7ac78..14270dea5 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -10,8 +10,6 @@ /// \file lua_hook.h /// \brief hooks for Lua scripting -#ifdef HAVE_BLUA - #include "r_defs.h" #include "d_player.h" @@ -112,6 +110,4 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Allows to write to p void LUAh_IntermissionThinker(void); // Hook for Y_Ticker void LUAh_VoteThinker(void); // Hook for Y_VoteTicker -#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink - -#endif +#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink \ No newline at end of file diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 1e6a5cb29..a1ea4fdaf 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -11,7 +11,6 @@ /// \brief hooks for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "doomstat.h" #include "p_mobj.h" #include "g_game.h" @@ -476,12 +475,14 @@ void LUAh_ThinkFrame(void) // variables used by perf stats int hook_index = 0; precise_t time_taken = 0; + if (!gL || !(hooksAvailable[hook_ThinkFrame/8] & (1<<(hook_ThinkFrame%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_ThinkFrame) { if (cv_perfstats.value == 3) @@ -506,8 +507,9 @@ void LUAh_ThinkFrame(void) hook_index++; } } - - lua_pop(gL, 1); // Pop error handler + } + + lua_pop(gL, 1); // Pop error handler } // Hook for frame (at end of tick, ie after overlays, precipitation, specials) @@ -519,13 +521,13 @@ void LUAh_PostThinkFrame(void) precise_t time_taken = 0; if (!gL || !(hooksAvailable[hook_PostThinkFrame/8] & (1<<(hook_PostThinkFrame%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type == hook_PostThinkFrame) - { + { if (cv_perfstats.value == 5) time_taken = I_GetPreciseTime(); lua_pushfstring(gL, FMT_HOOKID, hookp->id); @@ -549,6 +551,7 @@ void LUAh_PostThinkFrame(void) } } } + lua_pop(gL, 1); // Pop error handler } @@ -556,12 +559,14 @@ void LUAh_PostThinkFrame(void) void LUAh_IntermissionThinker(void) { hook_p hookp; + if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_IntermissionThinker) { lua_pushfstring(gL, FMT_HOOKID, hookp->id); @@ -573,20 +578,23 @@ void LUAh_IntermissionThinker(void) hookp->error = true; } } - - lua_pop(gL, 1); // Pop error handler + } + + lua_pop(gL, 1); // Pop error handler } // Hook for Y_VoteTicker void LUAh_VoteThinker(void) { hook_p hookp; + if (!gL || !(hooksAvailable[hook_VoteThinker/8] & (1<<(hook_VoteThinker%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_VoteThinker) { lua_pushfstring(gL, FMT_HOOKID, hookp->id); @@ -598,8 +606,9 @@ void LUAh_VoteThinker(void) hookp->error = true; } } - - lua_pop(gL, 1); // Pop error handler + } + + lua_pop(gL, 1); // Pop error handler } @@ -1740,6 +1749,4 @@ boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source) } lua_settop(gL, 0); return hooked; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_hud.h b/src/lua_hud.h index db759bbfa..d0fec7f1e 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -32,6 +32,8 @@ enum hud { hud_wanted, hud_speedometer, hud_statdisplay, + hud_nametags, + hud_driftgauge, hud_freeplay, hud_rankings, // Tab rankings diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index c7b1ec38e..2f81d98bf 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -12,7 +12,6 @@ #include "doomdef.h" #include "fastcmp.h" -#ifdef HAVE_BLUA #include "r_defs.h" #include "r_local.h" #include "st_stuff.h" // hudinfo[] @@ -24,6 +23,7 @@ #include "v_video.h" #include "w_wad.h" #include "z_zone.h" +#include "k_kart.h" #include "lua_script.h" #include "lua_libs.h" @@ -56,6 +56,8 @@ static const char *const hud_disable_options[] = { "wanted", "speedometer", "statdisplay", + "nametags", + "driftgauge", "freeplay", "rankings", NULL}; @@ -169,6 +171,58 @@ static const char *const camera_opt[] = { "pnum", NULL}; +enum hudpatch { + hudpatch_item = 0, + hudpatch_itemmul +}; + +static const char *const hud_patch_options[] = { + "item", + "itemmul", + NULL}; + +enum hudoffsets { + hudoffsets_item = 0, + hudoffsets_time, + hudoffsets_gametypeinfo, + hudoffsets_countdown, + hudoffsets_speedometer, + hudoffsets_position, + hudoffsets_minirankings, + hudoffsets_startcountdown, + hudoffsets_check, + hudoffsets_minimap, + hudoffsets_wanted, + hudoffsets_statdisplay +}; + +static const char *const hud_offsets_options[] = { + "item", + "time", + "gametypeinfo", + "countdown", + "speedometer", + "position", + "minirankings", + "startcountdown", + "check", + "minimap", + "wanted", + "statdisplay", + NULL}; + +enum huddrawinfo { + huddrawinfo_item = 0, + huddrawinfo_gametypeinfo, + huddrawinfo_minimap +}; + +static const char *const hud_drawinfo_options[] = { + "item", + "gametypeinfo", + "minimap", + NULL}; + static int lib_getHudInfo(lua_State *L) { UINT32 i; @@ -744,7 +798,6 @@ static int libd_drawStretched(lua_State *L) return 0; } - static int libd_drawNum(lua_State *L) { INT32 x, y, flags, num; @@ -1007,6 +1060,54 @@ static int libd_getColormap(lua_State *L) return 1; } +static int libd_getColorHudPatch(lua_State *L) +{ + HUDONLY + enum hudpatch option = luaL_checkoption(L, 1, NULL, hud_patch_options); + patch_t *patch; + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + boolean small, dark; + + switch (option) { + case hudpatch_item: + small = lua_optboolean(L, 2); + dark = lua_optboolean(L, 3); + patch = K_getItemBoxPatch(small, dark); + if (!cv_colorizeditembox.value) + colormap = NULL; + break; + case hudpatch_itemmul: + small = lua_optboolean(L, 2); + patch = K_getItemMulPatch(small); + break; + default: + return 0; // you shouldn't be here + } + + LUA_PushUserdata(L, patch, META_PATCH); + if (colormap && K_UseColorHud()) + LUA_PushUserdata(L, colormap, META_COLORMAP); + else + lua_pushnil(L); + + return 2; +} + +static int libd_getHudColor(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, K_GetHudColor()); + return 1; +} + +static int libd_useColorHud(lua_State *L) +{ + HUDONLY + lua_pushboolean(L, K_UseColorHud()); + return 1; +} + + static int libd_width(lua_State *L) { HUDONLY @@ -1057,6 +1158,26 @@ static int libd_getlocaltransflag(lua_State *L) return 1; } +static int libd_getDrawInfo(lua_State *L) +{ + HUDONLY + enum huddrawinfo option = luaL_checkoption(L, 1, NULL, hud_drawinfo_options); + drawinfo_t info; + + switch(option) { + case huddrawinfo_item: K_getItemBoxDrawinfo(&info); break; + case huddrawinfo_gametypeinfo: K_getLapsDrawinfo(&info); break; + case huddrawinfo_minimap: K_getMinimapDrawinfo(&info); break; + default: + return 0; // unreachable + } + + lua_pushinteger(L, info.x); + lua_pushinteger(L, info.y); + lua_pushinteger(L, info.flags); + return 3; +} + static luaL_Reg lib_draw[] = { {"patchExists", libd_patchExists}, {"cachePatch", libd_cachePatch}, @@ -1080,6 +1201,10 @@ static luaL_Reg lib_draw[] = { {"renderer", libd_renderer}, {"localTransFlag", libd_getlocaltransflag}, {"drawOnMinimap", libd_drawOnMinimap}, + {"getColorHudPatch", libd_getColorHudPatch}, + {"getDrawInfo", libd_getDrawInfo}, + {"getHudColor", libd_getHudColor}, + {"useColorHud", libd_useColorHud}, {NULL, NULL} }; @@ -1170,12 +1295,44 @@ static int lib_hudsetvotebackground(lua_State *L) return 0; } +static int lib_hudgetoffsets(lua_State *L) +{ + enum hudoffsets option = luaL_checkoption(L, 1, NULL, hud_offsets_options); + INT32 ofx, ofy; + +#define OFS(it) ofx = cv_##it##_xoffset.value; ofy = cv_##it##_yoffset.value; break; +#define OFY(it) ofx = 0; ofy = cv_##it##_yoffset.value; break; + switch(option) { + case hudoffsets_item: OFS(item) + case hudoffsets_time: OFS(time) + case hudoffsets_gametypeinfo: OFS(laps) + case hudoffsets_countdown: OFS(dnft) + case hudoffsets_speedometer: OFS(speed) + case hudoffsets_position: OFS(posi) + case hudoffsets_minirankings: OFS(face) + case hudoffsets_startcountdown: OFS(stcd) + case hudoffsets_check: OFY(chek) + case hudoffsets_minimap: OFS(mini) + case hudoffsets_wanted: OFS(want) + case hudoffsets_statdisplay: OFS(stat) + default: + return 0; // unreachable + } +#undef OFS +#undef OFY + + lua_pushinteger(L, ofx); + lua_pushinteger(L, ofy); + return 2; +} + static luaL_Reg lib_hud[] = { {"enable", lib_hudenable}, {"disable", lib_huddisable}, {"enabled", lib_hudenabled}, {"add", lib_hudadd}, {"setVoteBackground", lib_hudsetvotebackground}, + {"getOffsets", lib_hudgetoffsets}, {NULL, NULL} }; @@ -1411,6 +1568,4 @@ void LUAh_VoteHUD(huddrawlist_h list) lua_pushlightuserdata(gL, NULL); lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); -} - -#endif +} \ No newline at end of file diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 64a8b63d7..c94b42b5b 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -11,7 +11,6 @@ /// \brief infotable editing library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "info.h" #include "dehacked.h" @@ -984,6 +983,4 @@ int LUA_InfoLib(lua_State *L) lua_setglobal(L, "S_sfx"); lua_setglobal(L, "sfxinfo"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_libs.h b/src/lua_libs.h index 00dd9c858..c226c4714 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -10,8 +10,6 @@ /// \file lua_libs.h /// \brief libraries for Lua scripting -#ifdef HAVE_BLUA - extern lua_State *gL; #define LREG_VALID "VALID_USERDATA" @@ -70,6 +68,4 @@ int LUA_SkinLib(lua_State *L); int LUA_ThinkerLib(lua_State *L); int LUA_MapLib(lua_State *L); int LUA_BlockmapLib(lua_State *L); -int LUA_HudLib(lua_State *L); - -#endif +int LUA_HudLib(lua_State *L); \ No newline at end of file diff --git a/src/lua_maplib.c b/src/lua_maplib.c index ba2ad97a1..96222ba0a 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -11,7 +11,6 @@ /// \brief game map library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "r_state.h" #include "p_local.h" #include "p_setup.h" @@ -268,6 +267,8 @@ static int lib_iterateSectorThinglist(lua_State *L) if (!lua_isnil(L, 1)) { thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + if (P_MobjWasRemoved(thing)) + return luaL_error(L, "current entry in thinglist was removed; avoid calling P_RemoveMobj on entries!"); thing = thing->snext; } else @@ -1689,6 +1690,4 @@ int LUA_MapLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "mapheaderinfo"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 8c9d10062..c392ac6eb 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -11,7 +11,6 @@ /// \brief basic math library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA //#include "fastcmp.h" #include "tables.h" #include "p_local.h" @@ -228,6 +227,4 @@ int LUA_MathLib(lua_State *L) lua_pushvalue(L, LUA_GLOBALSINDEX); luaL_register(L, NULL, lib); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 9a7ea9828..7b1db5327 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -13,7 +13,6 @@ #include #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "r_things.h" #include "r_main.h" @@ -926,6 +925,4 @@ int LUA_MobjLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "mapthings"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index eb537d51f..70324fa02 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -11,7 +11,6 @@ /// \brief player object library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "r_main.h" #include "r_things.h" @@ -820,6 +819,4 @@ int LUA_PlayerLib(lua_State *L) lua_setglobal(L, "displayplayers"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_script.c b/src/lua_script.c index 29901bc3d..3af655efe 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -11,7 +11,6 @@ /// \brief Lua scripting basics #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "dehacked.h" #include "z_zone.h" @@ -1688,6 +1687,4 @@ int Lua_optoption(lua_State *L, int narg, if (fastcmp(lst[i], name)) return i; return -1; -} - -#endif // HAVE_BLUA +} \ No newline at end of file diff --git a/src/lua_script.h b/src/lua_script.h index 8ea5f3a89..a22e47c12 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -10,8 +10,6 @@ /// \file lua_script.h /// \brief Lua scripting basics -#ifdef HAVE_BLUA - #include "m_fixed.h" #include "doomtype.h" #include "d_player.h" @@ -95,5 +93,3 @@ void COM_Lua_f(void); CONS_Alert(CONS_WARNING,"%s\n", warningmsg);\ }\ } - -#endif diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index e86cd55af..286e983c1 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -11,7 +11,6 @@ /// \brief player skin structure library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "r_things.h" #include "sounds.h" @@ -273,6 +272,4 @@ int LUA_SkinLib(lua_State *L) lua_setglobal(L, "skins"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_thinkerlib.c b/src/lua_thinkerlib.c index ae859d46e..8315e7c3d 100644 --- a/src/lua_thinkerlib.c +++ b/src/lua_thinkerlib.c @@ -11,7 +11,6 @@ /// \brief thinker library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "p_local.h" #include "lua_script.h" #include "lua_libs.h" @@ -131,6 +130,4 @@ int LUA_ThinkerLib(lua_State *L) lua_setfield(L, -2, "iterate"); lua_setglobal(L, "thinkers"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_udatalib.h b/src/lua_udatalib.h index 36d1ef5ff..acff4cf3b 100644 --- a/src/lua_udatalib.h +++ b/src/lua_udatalib.h @@ -1,8 +1,6 @@ #ifndef __LUA_UDATALIB_H__ #define __LUA_UDATALIB_H__ -#ifdef HAVE_BLUA - #include "doomdef.h" #include "lua_script.h" #include "lua_libs.h" @@ -102,6 +100,4 @@ void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[]); return 0; \ } -#endif - -#endif +#endif \ No newline at end of file diff --git a/src/m_cheat.c b/src/m_cheat.c index a4aae676e..91ca536c8 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -647,7 +647,7 @@ void Command_CauseCfail_f(void) } #endif -#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) +#if defined(LUA_ALLOW_BYTECODE) void Command_Dumplua_f(void) { if (modifiedgame) @@ -891,9 +891,7 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mapthing_t *mt = mapthings; sector_t *sec = player->mo->subsector->sector; -#ifdef HAVE_BLUA LUA_InvalidateMapthings(); -#endif mapthings = Z_Realloc(mapthings, ++nummapthings * sizeof (*mapthings), PU_LEVEL, NULL); diff --git a/src/m_cheat.h b/src/m_cheat.h index 95c0060dd..f2944c27c 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -67,7 +67,7 @@ void Command_Weather_f(void); #ifdef _DEBUG void Command_CauseCfail_f(void); #endif -#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) +#if defined(LUA_ALLOW_BYTECODE) void Command_Dumplua_f(void); #endif diff --git a/src/m_menu.c b/src/m_menu.c index fd7900f4a..d12c95867 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -50,6 +50,12 @@ #include "p_setup.h" #include "f_finale.h" +#include "lua_libs.h" + +#include "fastcmp.h" + +#include "qs22j.h" + #ifdef HWRENDER #include "hardware/hw_main.h" #endif @@ -147,6 +153,8 @@ boolean browselocalskins = false; boolean menuactive = false; boolean fromlevelselect = false; +boolean menu_text_input = false; + static INT32 coolalphatimer = 9; typedef enum @@ -302,6 +310,7 @@ static void M_SetupMultiHandler(INT32 choice); menu_t OP_ControlsDef, OP_AllControlsDef; menu_t OP_MouseOptionsDef, OP_Mouse2OptionsDef; menu_t OP_Joystick1Def, OP_Joystick2Def, OP_Joystick3Def, OP_Joystick4Def; +menu_t OP_CustomCvarMenuDef; static void M_VideoModeMenu(INT32 choice); static void M_Setup1PControlsMenu(INT32 choice); static void M_Setup2PControlsMenu(INT32 choice); @@ -346,6 +355,8 @@ static void M_AddonsInternal(); static void M_Addons(INT32 choice); static void M_LocalSkins(INT32 choice); static void M_AddonsOptions(INT32 choice); + +static void M_CustomCvarMenu(INT32 choice); static patch_t *addonsp[NUM_EXT+5]; static void M_DeleteProtocol(void); @@ -358,12 +369,19 @@ menu_t OP_SaturnCreditsDef; // Bird menu_t OP_BirdDef; + // Stuff, yknow. menu_t OP_ForkedBirdDef; menu_t OP_LocalSkinDef; menu_t OP_TiltDef; menu_t OP_AdvancedBirdDef; +// Chaotic +menu_t OP_NametagDef; + +//Driftgauge +menu_t OP_DriftGaugeDef; + #define numaddonsshown 4 // Replay hut @@ -457,6 +475,7 @@ static CV_PossibleValue_t map_cons_t[] = { {0, NULL} }; consvar_t cv_nextmap = {"nextmap", "1", CV_HIDEN|CV_CALL, map_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nextmapaddon = {"nextmapaddon", "1", CV_HIDEN|CV_CALL, NULL, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t skins_cons_t[MAXSKINS+1] = {{1, DEFAULTSKIN}}; consvar_t cv_chooseskin = {"chooseskin", DEFAULTSKIN, CV_HIDEN|CV_CALL, skins_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -1077,7 +1096,7 @@ enum // Prefix: OP_ static menuitem_t OP_MainMenu[] = { - {IT_SUBMENU|IT_STRING, NULL, "Control Setup...", &OP_ControlsDef, 0}, + {IT_SUBMENU|IT_STRING, NULL, "Control Setup...", &OP_ControlsDef, 0}, {IT_SUBMENU|IT_STRING, NULL, "Video Options...", &OP_VideoOptionsDef, 20}, {IT_SUBMENU|IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 30}, @@ -1086,15 +1105,17 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 60}, {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 70}, - {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 90}, + {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 90}, + + {IT_CALL|IT_STRING, NULL, "Custom Options...", M_CustomCvarMenu, 100}, {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 110}, {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 120}, {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 150}, - {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 160}, + {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 150}, + {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 160}, }; static menuitem_t OP_ControlsMenu[] = @@ -1406,31 +1427,39 @@ static menuitem_t OP_ColorOptionsMenu[] = static menuitem_t OP_ExpOptionsMenu[] = { {IT_HEADER, NULL, "Experimental Options", NULL, 10}, - {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 25}, - {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 35}, + {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 25}, + {IT_STRING|IT_CVAR, NULL, "Mobj Subsector Interpolation", &cv_mobjssector, 35}, + {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 45}, + {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 55}, - {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 55}, + {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 75}, - {IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 75}, - {IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 85}, + {IT_STRING | IT_CVAR, NULL, "Clipping R_PointToAngle Version", &cv_pointoangleexor64, 85}, + + {IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 95}, + {IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 105}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 75}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 95}, - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 85}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 105}, + + {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 125}, + {IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 135}, + {IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 145}, + {IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 155}, - {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 105}, - {IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 115}, - {IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 125}, - {IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 135}, #endif }; static const char* OP_ExpTooltips[] = { NULL, + "How far Mobj interpolation should take effect.", + "Toggles Mobj Subsector Interpolation.", "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", "When weather is on this will cut the object amount used in half.", "Show a VHS-like effect when the game is paused\n or youre rewinding replays.", + "Which version of R_PointToAngle should\nbe used for Sector Clipping?\n64 may fix rendering issues on larger maps\nat the cost of performance.", "Hides 3DFloors which are not visible\npotentially resulting in a performance boost.", "Hides Sprites which are not visible\npotentially resulting in a performance boost.", #ifdef HWRENDER @@ -1446,9 +1475,12 @@ static const char* OP_ExpTooltips[] = enum { op_exp_header, + op_exp_interpdist, + op_exp_mobjssector, op_exp_precipinter, op_exp_lessprecip, op_exp_vhs, + op_exp_angleshit, op_exp_ffclip, op_exp_sprclip, #ifdef HWRENDER @@ -1505,43 +1537,62 @@ static const char* OP_OpenGLTooltips[] = static menuitem_t OP_SoundOptionsMenu[] = { - {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "SFX", &cv_gamesounds, 10}, + {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "SFX", &cv_gamesounds, 10}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, - NULL, "SFX Volume", &cv_soundvolume, 18}, + NULL, "SFX Volume", &cv_soundvolume, 18}, - {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music", &cv_gamedigimusic, 30}, + {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music", &cv_gamedigimusic, 30}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, - NULL, "Music Volume", &cv_digmusicvolume, 38}, + NULL, "Music Volume", &cv_digmusicvolume, 38}, -/* -- :nonnathisshit: +#ifndef NO_MIDI {IT_STRING|IT_CVAR, NULL, "MIDI", &cv_gamemidimusic, 50}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "MIDI Volume", &cv_midimusicvolume, 58}, -*/ +#endif //{IT_STRING|IT_CALL, NULL, "Restart Audio System", M_RestartAudio, 50}, +#ifdef NO_MIDI + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50}, + {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 60}, - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50}, - {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 60}, - - {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, - {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, - {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, + {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, + {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, + {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, - {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, - {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, + {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, + {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} +#else + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, + {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 70}, + + {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 85}, + {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 95}, + {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 105}, + + {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 115}, + {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 125}, + + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 135}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 145}, + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 165} +#endif }; static const char* OP_SoundTooltips[] = { "Turn Sound effects on or off.", - "Volume of sound effects.", - "Turn Sound effects on or off.", - "Volume of music.", + "Volume of Sound effects.", + "Turn Music on or off.", + "Volume of Music.", +#ifndef NO_MIDI + "Turn Midi Music on or off.", + "Volume of Midi Music.", +#endif "Reverse left and right channels of audio.", "Surround Sound.", "Chat notification sound.", @@ -1560,17 +1611,17 @@ static menuitem_t OP_SoundAdvancedMenu[] = #ifdef HAVE_OPENMPT {IT_HEADER, NULL, "Tracker Module Options", NULL, 10}, - {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 22}, - {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42}, + {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 22}, + {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42}, #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 - {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 62}, + {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 62}, #endif - {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 82}, + {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 82}, #endif - {IT_HEADER, NULL, "Misc", NULL, 105}, + {IT_HEADER, NULL, "Misc", NULL, 105}, - {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 117}, - {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 137}, + {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 117}, + {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 137}, }; static const char* OP_SoundAdvancedTooltips[] = @@ -1593,11 +1644,10 @@ static const char* OP_SoundAdvancedTooltips[] = static menuitem_t OP_DataOptionsMenu[] = { - {IT_STRING | IT_CALL, NULL, "Screenshot Options...", M_ScreenshotOptions, 10}, {IT_STRING | IT_CALL, NULL, "Addon Options...", M_AddonsOptions, 20}, {IT_STRING | IT_SUBMENU, NULL, "Replay Options...", &MISC_ReplayOptionsDef, 30}, - {IT_STRING | IT_SUBMENU, NULL, "Protocol options...", &OP_ProtocolDef, 40}, + {IT_STRING | IT_SUBMENU, NULL, "Protocol options...", &OP_ProtocolDef, 40}, #ifdef HAVE_DISCORDRPC {IT_STRING | IT_SUBMENU, NULL, "Discord Options...", &OP_DiscordOptionsDef, 50}, @@ -1613,21 +1663,21 @@ static menuitem_t OP_ScreenshotOptionsMenu[] = {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 20}, {IT_HEADER, NULL, "Screenshots (F8)", NULL, 50}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 60}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 70}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 80}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 90}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 60}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 70}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 80}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 90}, {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 105}, - {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 115}, + {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 115}, - {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 125}, - {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 135}, + {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 125}, + {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 135}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 125}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 135}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 145}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 155}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 125}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 135}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 145}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 155}, }; enum @@ -1859,8 +1909,7 @@ static menuitem_t OP_AdvServerOptionsMenu[] = #ifndef NONET static const char* OP_AdvServerOptionsTooltips[] = -{ - +{ "Server used for master server.", "Attempts to resynchronise player to server.", "Maximum allowed delay.", @@ -1958,15 +2007,18 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 60}, {IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 65}, {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 70}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 80}, {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 85}, - - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 95}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 90}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 95}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 105}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 110}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 115}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 120}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 125}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 130}, + + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 140}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -1986,6 +2038,8 @@ static const char* OP_SaturnTooltips[] = "Minimize the player icons on the minimap.", "Show the big Cecho Messages.", "Show Localskin Menus.", + "Nametag Options.", + "Driftgauge Options.", "Disables the flicker effect on Midnight Channel.", "Options for sprite distortion effects.", "Move position of HUD elements.", @@ -2007,6 +2061,10 @@ enum sm_lapemblem, sm_mapnames, sm_smallmap, + sm_cechotogle, + sm_showlocalskin, + sm_nametagmen, + sm_driftgaugemen, sm_pisschannel, sm_distortionmenu, sm_hudoffsets, @@ -2203,6 +2261,88 @@ static menuitem_t OP_ForkedBirdMenu[] = {IT_STRING | IT_CVAR, NULL, "Lua Immersion", &cv_luaimmersion, 170}, }; +static menuitem_t OP_NametagMenu[] = +{ + {IT_HEADER, NULL, "Nametag", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Nametag", &cv_nametag, 20}, + {IT_STRING | IT_CVAR, NULL, "Show Char image in Nametag", &cv_nametagfacerank, 30}, + {IT_STRING | IT_CVAR, NULL, "Show Own Nametag", &cv_showownnametag, 40}, + {IT_STRING | IT_CVAR, NULL, "Nametag Max distance", &cv_nametagdist, 50}, + {IT_STRING | IT_CVAR, NULL, "Nametag Max Display Players", &cv_nametagmaxplayers, 60}, + {IT_STRING | IT_CVAR, NULL, "Nametag Transparency", &cv_nametagtrans, 70}, + {IT_STRING | IT_CVAR, NULL, "Nametag Score", &cv_nametagscore, 80}, + {IT_STRING | IT_CVAR, NULL, "Nametag Restat", &cv_nametagrestat, 90}, + {IT_STRING | IT_CVAR, NULL, "Nametag Hop", &cv_nametaghop, 100}, + {IT_STRING | IT_CVAR, NULL, "Small Nametags", &cv_smallnametags, 110}, + {IT_STRING | IT_CVAR, NULL, "Show Nametags after Race finish", &cv_shownametagfinish, 120}, + {IT_STRING | IT_CVAR, NULL, "Show Nametags in Spectator Mode", &cv_shownametagspectator, 130}, + //{IT_STRING | IT_CVAR, NULL, "Nametag Scaling", &cv_nametagscaling, 70} +}; + + +static const char* OP_NametagTooltips[] = +{ + NULL, + "Enable nametags in game.", + "Show character icon in nametag.", + "Show your own nametag in game.", + "Distance nametags are visible.", + "Maximum amount of nametags on screen.", + "Transparency of nametags.", + "Show player score in nametag.", + "Show stats in nametags.", + "Enable Saltyhop support for nametags.", + "Alternative smaller nametags.", + "Show Nametags after Race finish.", + "Show Nametags when you are spectating.", +}; + +enum +{ + nt_header, + nt_nametag, + nt_ntchar, + nt_owntag, + nt_maxdist, + nt_maxplayer, + nt_nttrans, + nt_ntpscore, + nt_ntrestat, + nt_nthop, + nt_smol, + nt_finish, + nt_spec, +}; + + +static menuitem_t OP_DriftGaugeMenu[] = +{ + {IT_HEADER, NULL, "Driftgauge", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Driftgauge", &cv_driftgauge, 20}, + {IT_STRING | IT_CVAR, NULL, "Driftgauge Transparency", &cv_driftgaugetrans, 30}, + {IT_STRING | IT_CVAR, NULL, "Driftgauge Offset", &cv_driftgaugeofs, 40}, + {IT_STRING | IT_CVAR, NULL, "Driftgauge Style", &cv_driftgaugestyle, 50}, +}; + +static const char* OP_DriftGaugeTooltips[] = +{ + NULL, + "Enable driftgauge in game.", + "Have driftgauge use hud transparency.", + "Vertical driftgauge offset.", + "Driftgauge style.", +}; + +enum +{ + dg_header, + dg_dg, + dg_dgtrans, + dg_dgoffset, + dg_dgstyle, +}; + + static menuitem_t OP_TiltMenu[] = { {IT_STRING | IT_CVAR, NULL, "Camera Tilting", &cv_tilting, 0}, @@ -2263,6 +2403,8 @@ enum syncspecialonly, }; +menuitem_t OP_CustomCvarMenu[MAXMENUCCVARS]; + // ========================================================================== // ALL MENU DEFINITIONS GO HERE // ========================================================================== @@ -2280,7 +2422,7 @@ menu_t MISC_AddonsDef = 50, 28, 0, NULL, - NULL + {NULL} }; menu_t MISC_ReplayHutDef = @@ -2293,7 +2435,7 @@ menu_t MISC_ReplayHutDef = 30, 80, 0, M_QuitReplayHut, - NULL + {NULL} }; menu_t MISC_ReplayOptionsDef = @@ -2306,7 +2448,7 @@ menu_t MISC_ReplayOptionsDef = 27, 40, 0, NULL, - NULL + {NULL} }; menu_t MISC_ReplayStartDef = @@ -2319,7 +2461,7 @@ menu_t MISC_ReplayStartDef = 30, 90, 0, NULL, - NULL + {NULL} }; menu_t PlaybackMenuDef = { @@ -2332,7 +2474,7 @@ menu_t PlaybackMenuDef = { BASEVIDWIDTH/2 - 88, 2, 0, NULL, - NULL + {NULL} }; menu_t MAPauseDef = PAUSEMENUSTYLE(MAPauseMenu, 40, 72); @@ -2348,7 +2490,8 @@ menu_t MISC_DiscordRequestsDef = { M_DrawDiscordRequests, 0, 0, 0, - NULL + NULL, + {NULL} }; #endif @@ -2444,7 +2587,7 @@ menu_t SR_PandoraDef = 60, 40, 0, M_ExitPandorasBox, - NULL + {NULL} }; menu_t SR_MainDef = CENTERMENUSTYLE(NULL, SR_MainMenu, &MainDef, 72); @@ -2460,7 +2603,7 @@ menu_t SR_UnlockChecklistDef = 280, 185, 0, NULL, - NULL + {NULL} }; menu_t SR_MusicTestDef = @@ -2473,7 +2616,7 @@ menu_t SR_MusicTestDef = 60, 150, 0, NULL, - NULL + {NULL} }; menu_t SR_EmblemHintDef = @@ -2486,7 +2629,7 @@ menu_t SR_EmblemHintDef = 60, 150, 0, NULL, - NULL + {NULL} }; // Single Player @@ -2502,7 +2645,7 @@ menu_t SP_LevelStatsDef = 280, 185, 0, NULL, - NULL + {NULL} }; static menu_t SP_TimeAttackDef = @@ -2515,8 +2658,7 @@ static menu_t SP_TimeAttackDef = 34, 40, 0, M_QuitTimeAttackMenu, - NULL, - NULL + {NULL} }; static menu_t SP_ReplayDef = { @@ -2528,8 +2670,7 @@ static menu_t SP_ReplayDef = 34, 40, 0, NULL, - NULL, - NULL + {NULL} }; static menu_t SP_GuestReplayDef = { @@ -2541,8 +2682,7 @@ static menu_t SP_GuestReplayDef = 34, 40, 0, NULL, - NULL, - NULL + {NULL} }; static menu_t SP_GhostDef = { @@ -2554,7 +2694,7 @@ static menu_t SP_GhostDef = 34, 40, 0, NULL, - NULL + {NULL} }; // Multiplayer @@ -2572,7 +2712,7 @@ menu_t MP_MainDef = #else NULL, #endif - NULL + {NULL} }; menu_t MP_OfflineServerDef = MAPICONMENUSTYLE("M_MULTI", MP_OfflineServerMenu, &MP_MainDef); @@ -2590,7 +2730,7 @@ menu_t MP_ConnectDef = 27,24, 0, M_CancelConnect, - NULL + {NULL} }; #endif menu_t MP_PlayerSetupDef = @@ -2603,7 +2743,7 @@ menu_t MP_PlayerSetupDef = 36, 14, 0, M_QuitMultiPlayerMenu, - NULL + {NULL} }; // Options @@ -2617,7 +2757,7 @@ menu_t OP_MainDef = 60, 30, 0, NULL, - NULL + {NULL} }; menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30); @@ -2638,7 +2778,7 @@ menu_t OP_JoystickSetDef = 50, 40, 0, NULL, - NULL + {NULL} }; menu_t OP_VideoOptionsDef = @@ -2651,7 +2791,7 @@ menu_t OP_VideoOptionsDef = 30, 20, 0, NULL, - NULL + {NULL} }; menu_t OP_VideoModeDef = @@ -2664,7 +2804,7 @@ menu_t OP_VideoModeDef = 48, 26, 0, NULL, - NULL + {NULL} }; menu_t OP_ColorOptionsDef = @@ -2690,7 +2830,7 @@ menu_t OP_SoundOptionsDef = 30, 20, 0, NULL, - NULL + {NULL} }; @@ -2704,7 +2844,7 @@ menu_t OP_HUDOptionsDef = 30, 20, 0, NULL, - NULL + {NULL} }; @@ -2731,7 +2871,7 @@ menu_t OP_MonitorToggleDef = 47, 30, 0, NULL, - NULL + {NULL} }; #ifdef HWRENDER @@ -2755,9 +2895,30 @@ menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnDe menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 10); menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); +menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnDef, 30, 40); + +menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnDef, 30, 60); + menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60); menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60); +INT16 ccvarposition = 0; + +static void M_CustomCvarMenu(INT32 choice) +{ + (void)choice; + + if (ccvarposition) + M_SetupNextMenu(&OP_CustomCvarMenuDef); + else + M_StartMessage(M_GetText("No custom options were found\n"), NULL, MM_NOTHING); +} + +/*menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLMENUSTYLE( + MTREE3(MN_OP_MAIN, MN_OP_DATA, MN_OP_ADDONS), + "M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 30, 30);*/ +menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLSTYLE("M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 10, 30); + menu_t OP_ForkedBirdDef = { NULL, sizeof(OP_ForkedBirdMenu)/sizeof(menuitem_t), @@ -2767,7 +2928,7 @@ menu_t OP_ForkedBirdDef = { 30, 6, 0, NULL, - NULL + {NULL} }; menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60); @@ -3503,6 +3664,7 @@ boolean M_Responder(event_t *ev) // Handle menuitems which need a specific key handling if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER) { + menu_text_input = true; if (shiftdown && ch >= 32 && ch <= 127) ch = shiftxform[ch]; routine(ch); @@ -3543,7 +3705,7 @@ boolean M_Responder(event_t *ev) { if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING) { - + menu_text_input = true; if (shiftdown && ch >= 32 && ch <= 127) ch = shiftxform[ch]; if (M_ChangeStringCvar(ch)) @@ -3738,6 +3900,7 @@ boolean M_Responder(event_t *ev) case KEY_BACKSPACE: if ((currentMenu->menuitems[itemOn].status) == IT_CONTROL) { + menu_text_input = false; //never use native layout for control setup // detach any keys associated with the game control G_ClearControlKeys(setupcontrols, currentMenu->menuitems[itemOn].alphaKey); S_StartSound(NULL, sfx_shldls); @@ -4042,7 +4205,7 @@ void M_StartControlPanel(void) Dummymenuplayer_OnChange(); - if ((server || IsPlayerAdmin(consoleplayer))) + if (server || IsPlayerAdmin(consoleplayer)) { MPauseMenu[mpause_switchmap].status = IT_STRING | IT_CALL; MPauseMenu[mpause_addons].status = IT_STRING | IT_CALL; @@ -4328,7 +4491,8 @@ void M_Init(void) OP_ExpOptionsMenu[op_exp_fofcut].status = IT_DISABLED; } - if (rendermode == render_opengl){ + if (rendermode == render_opengl) + { OP_ExpOptionsMenu[op_exp_ffclip].status = IT_DISABLED; OP_ExpOptionsMenu[op_exp_sprclip].status = IT_DISABLED; } @@ -4349,6 +4513,9 @@ void M_Init(void) OP_SaturnMenu[sm_coloritem].status = IT_GRAYEDOUT; OP_SaturnMenu[sm_colorhud_customcolor].status = IT_GRAYEDOUT; } + + if (!nametaggfx) + OP_NametagMenu[nt_ntchar].status = IT_GRAYEDOUT; #ifndef NONET CV_RegisterVar(&cv_serversort); @@ -4609,27 +4776,27 @@ static void M_DrawMenuTitle(void) } // TODO: This is fucking terrible. -static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT32 box_x, INT32 alpha) +static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT32 alpha) { - const char* icopy = strdup(str); - const char** clines = NULL; + char* icopy = strdup(str); + char** clines = NULL; INT16 num_lines = 0; if (icopy == NULL) return; - char* token = strtok(icopy, "\n"); + char* tok = strtok(icopy, "\n"); - while (token != NULL) + while (tok != NULL) { - const char* line = strdup(token); + char* line = strdup(tok); if (line == NULL) return; - clines = (const char**)realloc(clines, (num_lines + 1) * sizeof(const char*)); + clines = realloc(clines, (num_lines + 1) * sizeof(char*)); clines[num_lines] = line; num_lines++; - token = strtok(NULL, "\n"); + tok = strtok(NULL, "\n"); } free(icopy); @@ -4653,7 +4820,7 @@ static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT V_DrawCenteredThinString(x, y + yoffset, option|V_YELLOWMAP|((9 - alpha) << V_ALPHASHIFT), clines[i]); yoffset += 10; // Remember to free the memory for each line when you're done with it. - free((void*)clines[i]); + free(clines[i]); } free(clines); @@ -4802,172 +4969,178 @@ static void M_DrawGenericMenu(void) W_CachePatchName("M_CURSOR", PU_CACHE)); V_DrawString(currentMenu->x, cursory, lowercase|highlightflags, currentMenu->menuitems[itemOn].text); } - - + // dumb hack // tooltips - if (currentMenu == &OP_ControlsDef) { - if (!(OP_ControlsTooltips[itemOn] == NULL)) + if (!(OP_ControlsTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ControlsTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ControlsTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - + if (currentMenu == &OP_MouseOptionsDef) { - if (!(OP_MouseTooltips[itemOn] == NULL)) + if (!(OP_MouseTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_MouseTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_MouseTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - + if (currentMenu == &OP_VideoOptionsDef) { - if (!(OP_VideoTooltips[itemOn] == NULL)) + if (!(OP_VideoTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_VideoTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_VideoTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - + if (currentMenu == &OP_SoundOptionsDef) { - if (!(OP_SoundTooltips[itemOn] == NULL)) + if (!(OP_SoundTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - + if (currentMenu == &OP_SoundAdvancedDef) { - if (!(OP_SoundAdvancedTooltips[itemOn] == NULL)) + if (!(OP_SoundAdvancedTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundAdvancedTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundAdvancedTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - + if (currentMenu == &OP_ExpOptionsDef) { - if (!(OP_ExpTooltips[itemOn] == NULL)) + if (!(OP_ExpTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ExpTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ExpTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - + if (currentMenu == &OP_ChatOptionsDef) { - if (!(OP_ChatOptionsTooltips[itemOn] == NULL)) + if (!(OP_ChatOptionsTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ChatOptionsTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ChatOptionsTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - - if (currentMenu == &OP_GameOptionsDef) { - if (!(OP_GameTooltips[itemOn] == NULL)) + if (!(OP_GameTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_GameTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_GameTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - - + if (currentMenu == &OP_ServerOptionsDef) { - if (!(OP_ServerOptionsTooltips[itemOn] == NULL)) + if (!(OP_ServerOptionsTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ServerOptionsTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ServerOptionsTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - - + if (currentMenu == &OP_AdvServerOptionsDef) { - if (!(OP_AdvServerOptionsTooltips[itemOn] == NULL)) + if (!(OP_AdvServerOptionsTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvServerOptionsTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvServerOptionsTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - - - if (currentMenu == &OP_PlayerDistortDef) { - if (!(OP_PlayerDistortTooltips[itemOn] == NULL)) + if (!(OP_PlayerDistortTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_PlayerDistortTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_PlayerDistortTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - - - - + if (currentMenu == &OP_SaturnCreditsDef) // C: { - if (!(OP_CreditTooltips[itemOn] == NULL)) + if (!(OP_CreditTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_CreditTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_CreditTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - + if (currentMenu == &OP_BirdDef) { - if (!(OP_BirdTooltips[itemOn] == NULL)) + if (!(OP_BirdTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_BirdTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_BirdTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - + if (currentMenu == &OP_TiltDef) { - if (!(OP_TiltTooltips[itemOn] == NULL)) + if (!(OP_TiltTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_TiltTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_TiltTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } - + if (currentMenu == &OP_AdvancedBirdDef) { - if (!(OP_AdvancedBirdTooltips[itemOn] == NULL)) + if (!(OP_AdvancedBirdTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvancedBirdTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvancedBirdTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } + if (currentMenu == &OP_NametagDef) + { + if (!(OP_NametagTooltips[itemOn] == NULL)) + { + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_NametagTooltips[itemOn], coolalphatimer); + if (coolalphatimer > 0 && interpTimerHackAllow) + coolalphatimer--; + } + } + if (currentMenu == &OP_DriftGaugeDef) + { + if (!(OP_DriftGaugeTooltips[itemOn] == NULL)) + { + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_DriftGaugeTooltips[itemOn], coolalphatimer); + if (coolalphatimer > 0 && interpTimerHackAllow) + coolalphatimer--; + } + } } static void M_DrawGenericBackgroundMenu(void) @@ -4978,8 +5151,6 @@ static void M_DrawGenericBackgroundMenu(void) #define scrollareaheight 72 - - // note that alphakey is multiplied by 2 for scrolling menus to allow greater usage in UINT8 range. static void M_DrawGenericScrollMenu(void) { @@ -5118,20 +5289,18 @@ static void M_DrawGenericScrollMenu(void) { if (!(OP_OpenGLTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_OpenGLTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_OpenGLTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } } #endif - - if (currentMenu == &OP_SaturnDef) { if (!(OP_SaturnTooltips[itemOn] == NULL)) { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SaturnTooltips[itemOn], 30, coolalphatimer); + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SaturnTooltips[itemOn], coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) coolalphatimer--; } @@ -5602,7 +5771,8 @@ menu_t MessageDef = M_DrawMessageMenu, // drawing routine -> 0, 0, // x, y (TO HACK) 0, // lastOn, flags (TO HACK) - NULL + NULL, + {0}, }; @@ -5867,7 +6037,7 @@ static void M_AddonsOptions(INT32 choice) #define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make addons!" #define LOCATIONSTRING2 "Visit \x88SRB2.ORG/MODS\x80 to get & make addons!" -static void M_AddonsInternal() +static void M_AddonsInternal(void) { const char *pathname = "."; @@ -6447,13 +6617,8 @@ static void M_HandleAddons(INT32 choice) case EXT_CFG: M_AddonExec(KEY_ENTER); break; - case EXT_LUA: -#ifndef HAVE_BLUA - S_StartSound(NULL, sfx_s26d); - M_StartMessage(va("%c%s\x80\nThis version of SRB2Kart does not\nhave 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 // else intentional fallthrough + case EXT_LUA: case EXT_SOC: case EXT_WAD: #ifdef USE_KART @@ -6583,7 +6748,9 @@ static void PrepReplayList(void) else { demolist[i].type = MD_NOTLOADED; - snprintf(demolist[i].filepath, 255, "%s%s", menupath, dirmenu[i] + DIR_STRING); + // FIXME - do something with buffer sizes. menupath is 1024 chars but filepath is only + // 256. I'm not really sure what to do here but don't want to leave warnings... + snprintf(demolist[i].filepath, 255, "%.254s%s", menupath, dirmenu[i] + DIR_STRING); sprintf(demolist[i].title, "....."); } } @@ -7562,9 +7729,9 @@ static void M_Options(INT32 choice) // if the player is not admin or server, disable gameplay & server options OP_MainMenu[4].status = OP_MainMenu[5].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); - OP_MainMenu[8].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // Play credits + OP_MainMenu[9].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // Play credits - OP_MainMenu[11].status = (!cv_showlocalskinmenus.value) ? (IT_DISABLED) : (IT_CALL|IT_STRING); + OP_MainMenu[12].status = (!cv_showlocalskinmenus.value) ? (IT_DISABLED) : (IT_CALL|IT_STRING); #ifdef HAVE_DISCORDRPC OP_DataOptionsMenu[4].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); // Erase data @@ -7644,6 +7811,54 @@ void M_PopupMasterServerRules(void) #endif } +#define CCVHEIGHT 5 +#define CCVHEIGHTHEADER 1 +#define CCVHEIGHTHEADERAFTER 6 + +UINT16 ccvaralphakey = 4; +INT16 ccvarlaststheader = 0; + +INT32 CVARSETUP; + +void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* name) +{ + if (ccvarposition == INT16_MAX) + return; + + if (ccvarposition >= MAXMENUCCVARS - 2) + { + CONS_Printf("failed to register cvar into custom settings menu as menu reached limit\n"); + ccvarposition = INT16_MAX; + return; + } + + if (!CVARSETUP) + { + CONS_Printf("custom settings menu initiation\n"); + for (CVARSETUP = 0; CVARSETUP < MAXMENUCCVARS; ++CVARSETUP) + OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", 0, INT16_MAX}; + } + + if (category && ((ccvarposition == 0 && category[0] != '\0') || !fasticmp(category, OP_CustomCvarMenu[ccvarlaststheader].text))) + { + ccvarlaststheader = ccvarposition; + ccvaralphakey += CCVHEIGHTHEADER; + + OP_CustomCvarMenu[ccvarposition] = (menuitem_t){IT_HEADER, NULL, Z_StrDup(category), NULL, ccvaralphakey}; + ccvaralphakey += CCVHEIGHTHEADERAFTER; + + ++ccvarposition; + } + + if (cvar->flags & CV_NETVAR) + OP_CustomCvarMenu[ccvarposition] = (menuitem_t){ IT_STRING | IT_CVAR , NULL, Z_StrDup(va("\x85 %s", name)), cvar, ccvaralphakey }; + else + OP_CustomCvarMenu[ccvarposition] = (menuitem_t){ IT_STRING | IT_CVAR, NULL, Z_StrDup(name), cvar, ccvaralphakey }; + + ccvaralphakey += CCVHEIGHT; + ++ccvarposition; +} + // ====== // CHEATS // ====== @@ -7911,17 +8126,21 @@ static void M_DrawSkyRoom(void) (digital_disabled ? warningflags : highlightflags), (digital_disabled ? "OFF" : "ON")); - /*V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, +#ifndef NO_MIDI + V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y+currentMenu->menuitems[5].alphaKey, (midi_disabled ? warningflags : highlightflags), - (midi_disabled ? "OFF" : "ON"));*/ + (midi_disabled ? "OFF" : "ON")); +#endif if (itemOn == 0) lengthstring = 8*(sound_disabled ? 3 : 2); else if (itemOn == 2) lengthstring = 8*(digital_disabled ? 3 : 2); - /*else if (itemOn == 5) - lengthstring = 8*(midi_disabled ? 3 : 2);*/ +#ifndef NO_MIDI + else if (itemOn == 5) + lengthstring = 8*(midi_disabled ? 3 : 2); +#endif } for (i = 0; i < currentMenu->numitems; ++i) @@ -8006,9 +8225,11 @@ static size_t st_namescrollstate = 0; static void M_MusicTest(INT32 choice) { - INT32 ul = skyRoomMenuTranslations[choice-1]; - UINT8 i; - char buf[8]; + //INT32 ul = skyRoomMenuTranslations[choice-1]; + //UINT8 i; + //char buf[8]; + + (void)choice; if (!S_PrepareSoundTest()) { @@ -8045,7 +8266,7 @@ static void M_MusicTest(INT32 choice) static void M_DrawMusicTest(void) { INT32 x, y, i; - char* title; + //char* title; //fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0; //UINT8 frame[4] = {0, 0, -1, SKINCOLOR_RUBY}; @@ -8281,9 +8502,9 @@ static void M_DrawMusicTest(void) } if (soundtestdefs[t]->title[0]) - strncpy(buf, soundtestdefs[t]->title + nameoffset, MAXLENGTH); + memcpy(buf, soundtestdefs[t]->title + nameoffset, MAXLENGTH); else - strncpy(buf, soundtestdefs[t]->source + nameoffset, MAXLENGTH); + memcpy(buf, soundtestdefs[t]->source + nameoffset, MAXLENGTH); buf[MAXLENGTH] = 0; V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); @@ -9255,8 +9476,6 @@ void M_ModeAttackRetry(INT32 choice) G_CheckDemoStatus(); // Cancel recording if (modeattacking == ATTACKING_RECORD) M_ChooseTimeAttack(0); - /*else if (modeattacking == ATTACKING_NIGHTS) - M_ChooseNightsAttack(0);*/ } static void M_ModeAttackEndGame(INT32 choice) @@ -9715,22 +9934,22 @@ void M_SortServerList(void) switch(cv_serversort.value) { case 0: // Ping. - qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_time); + qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_time); break; case 1: // Modified state. - qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_modified); + qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_modified); break; case 2: // Most players. - qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_numberofplayer_reverse); + qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_numberofplayer_reverse); break; case 3: // Least players. - qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_numberofplayer); + qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_numberofplayer); break; case 4: // Max players. - qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_maxplayer_reverse); + qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_maxplayer_reverse); break; case 5: // Gametype. - qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_gametype); + qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_gametype); break; } #endif @@ -10037,7 +10256,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if (cv_nextmap.value && cv_showtrackaddon.value) { char *addonname = wadfiles[mapwads[cv_nextmap.value-1]]->filename; - INT32 len, sw = 0; + INT32 len; INT32 charlimit = 21 + (dupadjust/5); nameonly(addonname); len = strlen(addonname); @@ -10537,7 +10756,7 @@ static boolean setupm_skinlockedselect; #define SKINGRIDNEWWIDTH 8 #define SKINGRIDNEWHEIGHT 9 -static char *sortNames[] = { +static const char *sortNames[] = { "Name", "Internal name", "Speed", @@ -10734,7 +10953,6 @@ static void M_DrawSetupMultiPlayerMenu(void) if (statdp == true) { - int i; //Background V_DrawScaledPatch(statx - 50, staty + 4, 0, W_CachePatchName("K_STATNB", PU_CACHE)); @@ -11035,22 +11253,22 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 j = -colwidth; INT16 col = setupm_fakecolor - colwidth; INT32 x = mx; - INT32 w = indexwidth; - UINT8 h; + INT32 cw = indexwidth; + UINT8 ch; while (col < 1) col += MAXSKINCOLORS-1; while (j <= colwidth) { if (!(j++)) - w = charw; + cw = charw; else - w = indexwidth; - for (h = 0; h < 16; h++) - V_DrawFill(x, my+(cv_skinselectmenu.value?176:162)+h, w, 1, colortranslations[col][h]); + cw = indexwidth; + for (ch = 0; ch < 16; ch++) + V_DrawFill(x, my+(cv_skinselectmenu.value?176:162)+ch, cw, 1, colortranslations[col][ch]); if (++col >= MAXSKINCOLORS) col -= MAXSKINCOLORS-1; - x += w; + x += cw; } } #undef indexwidth @@ -11617,6 +11835,8 @@ static void M_SetupMultiPlayer(INT32 choice) //change the y offsets of the menu depending on cvar settings SKINSELECTMENUEDIT + sortSkinGrid(); + MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); } @@ -11654,6 +11874,8 @@ static void M_SetupMultiPlayer2(INT32 choice) //change the y offsets of the menu depending on cvar settings SKINSELECTMENUEDIT + sortSkinGrid(); + MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); } @@ -11691,6 +11913,8 @@ static void M_SetupMultiPlayer3(INT32 choice) //change the y offsets of the menu depending on cvar settings SKINSELECTMENUEDIT + sortSkinGrid(); + MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); } @@ -11727,6 +11951,8 @@ static void M_SetupMultiPlayer4(INT32 choice) //change the y offsets of the menu depending on cvar settings SKINSELECTMENUEDIT + + sortSkinGrid(); MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); @@ -11752,6 +11978,7 @@ static boolean M_QuitMultiPlayerMenu(void) return true; } + // ================= // DATA OPTIONS MENU // ================= diff --git a/src/m_menu.h b/src/m_menu.h index 8d1ebb723..bb504642d 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -91,6 +91,8 @@ void M_QuitResponse(INT32 ch); // Determines whether to show a level in the list boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt); +extern boolean menu_text_input; + // flags for items in the menu // menu handle (what we do when key is pressed #define IT_TYPE 14 // (2+4+8) @@ -147,6 +149,8 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt); #define MAXSTRINGLENGTH 32 +#define MAXMENUCCVARS 999 + #define MAXTOOLTIPS 255 typedef union @@ -171,7 +175,7 @@ typedef struct menuitem_s void *itemaction; // hotkey in menu or y of the item - UINT8 alphaKey; + UINT16 alphaKey; } menuitem_t; extern menuitem_t PlayerMenu[MAXSKINS]; @@ -289,6 +293,8 @@ void M_PopupMasterServerRules(void); void M_PopupMasterServerConnectError(void); #endif +void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* name); + // These defines make it a little easier to make menus #define DEFAULTMENUSTYLE(header, source, prev, x, y)\ {\ @@ -300,7 +306,7 @@ void M_PopupMasterServerConnectError(void); x, y,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define DEFAULTSCROLLSTYLE(header, source, prev, x, y)\ @@ -313,9 +319,10 @@ void M_PopupMasterServerConnectError(void); x, y,\ 0,\ NULL,\ - NULL\ + {NULL}\ } + #define PAUSEMENUSTYLE(source, x, y)\ {\ NULL,\ @@ -326,7 +333,7 @@ void M_PopupMasterServerConnectError(void); x, y,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define CENTERMENUSTYLE(header, source, prev, y)\ @@ -339,7 +346,7 @@ void M_PopupMasterServerConnectError(void); BASEVIDWIDTH/2, y,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define MAPICONMENUSTYLE(header, source, prev)\ @@ -352,7 +359,7 @@ void M_PopupMasterServerConnectError(void); 24,40,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define CONTROLMENUSTYLE(source, prev)\ @@ -365,7 +372,7 @@ void M_PopupMasterServerConnectError(void); 26, 40,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #define IMAGEDEF(source)\ @@ -378,7 +385,7 @@ void M_PopupMasterServerConnectError(void); 0, 0,\ 0,\ NULL,\ - NULL\ + {NULL}\ } #endif //__X_MENU__ diff --git a/src/m_misc.c b/src/m_misc.c index a8cc28f0b..97dcbed84 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -19,7 +19,6 @@ // (if libpng is compiled with setjmp error handling) #pragma GCC diagnostic ignored "-Wclobbered" #endif - #include #endif @@ -65,6 +64,8 @@ typedef off_t off64_t; #define PRIdS "u" #elif defined(_WIN32) && !defined(__MINGW64__) #define PRIdS "Iu" +#elif defined(_WIN32) && defined(__MINGW64__) +#define PRIdS PRIuPTR #else #define PRIdS "zu" #endif @@ -1937,430 +1938,11 @@ char *sizeu5(size_t num) return sizeu5_buf; } -#if defined (__GNUC__) && defined (__i386__) // from libkwave, under GPL -// Alam: note libkwave memcpy code comes from mplayer's libvo/aclib_template.c, r699 - -/* for small memory blocks (<256 bytes) this version is faster */ -#define small_memcpy(dest,src,n)\ -{\ -register unsigned long int dummy;\ -__asm__ __volatile__(\ - "cld\n\t"\ - "rep; movsb"\ - :"=&D"(dest), "=&S"(src), "=&c"(dummy)\ - :"0" (dest), "1" (src),"2" (n)\ - : "memory", "cc");\ -} -/* linux kernel __memcpy (from: /include/asm/string.h) */ -ATTRINLINE static FUNCINLINE void *__memcpy (void *dest, const void * src, size_t n) +void *M_Memcpy(void *dest, const void *src, size_t n) { - int d0, d1, d2; - - if ( n < 4 ) - { - small_memcpy(dest, src, n); - } - else - { - __asm__ __volatile__ ( - "rep ; movsl;" - "testb $2,%b4;" - "je 1f;" - "movsw;" - "1:\ttestb $1,%b4;" - "je 2f;" - "movsb;" - "2:" - : "=&c" (d0), "=&D" (d1), "=&S" (d2) - :"0" (n/4), "q" (n),"1" ((long) dest),"2" ((long) src) - : "memory"); - } - - return dest; -} - -#define SSE_MMREG_SIZE 16 -#define MMX_MMREG_SIZE 8 - -#define MMX1_MIN_LEN 0x800 /* 2K blocks */ -#define MIN_LEN 0x40 /* 64-byte blocks */ - -/* SSE note: i tried to move 128 bytes a time instead of 64 but it -didn't make any measureable difference. i'm using 64 for the sake of -simplicity. [MF] */ -static /*FUNCTARGET("sse2")*/ void *sse_cpy(void * dest, const void * src, size_t n) -{ - void *retval = dest; - size_t i; - - /* PREFETCH has effect even for MOVSB instruction ;) */ - __asm__ __volatile__ ( - "prefetchnta (%0);" - "prefetchnta 32(%0);" - "prefetchnta 64(%0);" - "prefetchnta 96(%0);" - "prefetchnta 128(%0);" - "prefetchnta 160(%0);" - "prefetchnta 192(%0);" - "prefetchnta 224(%0);" - "prefetchnta 256(%0);" - "prefetchnta 288(%0);" - : : "r" (src) ); - - if (n >= MIN_LEN) - { - register unsigned long int delta; - /* Align destinition to MMREG_SIZE -boundary */ - delta = ((unsigned long int)dest)&(SSE_MMREG_SIZE-1); - if (delta) - { - delta=SSE_MMREG_SIZE-delta; - n -= delta; - small_memcpy(dest, src, delta); - } - i = n >> 6; /* n/64 */ - n&=63; - if (((unsigned long)src) & 15) - /* if SRC is misaligned */ - for (; i>0; i--) - { - __asm__ __volatile__ ( - "prefetchnta 320(%0);" - "prefetchnta 352(%0);" - "movups (%0), %%xmm0;" - "movups 16(%0), %%xmm1;" - "movups 32(%0), %%xmm2;" - "movups 48(%0), %%xmm3;" - "movntps %%xmm0, (%1);" - "movntps %%xmm1, 16(%1);" - "movntps %%xmm2, 32(%1);" - "movntps %%xmm3, 48(%1);" - :: "r" (src), "r" (dest) : "memory"); - src = (const unsigned char *)src + 64; - dest = (unsigned char *)dest + 64; - } - else - /* - Only if SRC is aligned on 16-byte boundary. - It allows to use movaps instead of movups, which required data - to be aligned or a general-protection exception (#GP) is generated. - */ - for (; i>0; i--) - { - __asm__ __volatile__ ( - "prefetchnta 320(%0);" - "prefetchnta 352(%0);" - "movaps (%0), %%xmm0;" - "movaps 16(%0), %%xmm1;" - "movaps 32(%0), %%xmm2;" - "movaps 48(%0), %%xmm3;" - "movntps %%xmm0, (%1);" - "movntps %%xmm1, 16(%1);" - "movntps %%xmm2, 32(%1);" - "movntps %%xmm3, 48(%1);" - :: "r" (src), "r" (dest) : "memory"); - src = ((const unsigned char *)src) + 64; - dest = ((unsigned char *)dest) + 64; - } - /* since movntq is weakly-ordered, a "sfence" - * is needed to become ordered again. */ - __asm__ __volatile__ ("sfence":::"memory"); - /* enables to use FPU */ - __asm__ __volatile__ ("emms":::"memory"); - } - /* - * Now do the tail of the block - */ - if (n) __memcpy(dest, src, n); - return retval; -} - -static FUNCTARGET("mmx") void *mmx2_cpy(void *dest, const void *src, size_t n) -{ - void *retval = dest; - size_t i; - - /* PREFETCH has effect even for MOVSB instruction ;) */ - __asm__ __volatile__ ( - "prefetchnta (%0);" - "prefetchnta 32(%0);" - "prefetchnta 64(%0);" - "prefetchnta 96(%0);" - "prefetchnta 128(%0);" - "prefetchnta 160(%0);" - "prefetchnta 192(%0);" - "prefetchnta 224(%0);" - "prefetchnta 256(%0);" - "prefetchnta 288(%0);" - : : "r" (src)); - - if (n >= MIN_LEN) - { - register unsigned long int delta; - /* Align destinition to MMREG_SIZE -boundary */ - delta = ((unsigned long int)dest)&(MMX_MMREG_SIZE-1); - if (delta) - { - delta=MMX_MMREG_SIZE-delta; - n -= delta; - small_memcpy(dest, src, delta); - } - i = n >> 6; /* n/64 */ - n&=63; - for (; i>0; i--) - { - __asm__ __volatile__ ( - "prefetchnta 320(%0);" - "prefetchnta 352(%0);" - "movq (%0), %%mm0;" - "movq 8(%0), %%mm1;" - "movq 16(%0), %%mm2;" - "movq 24(%0), %%mm3;" - "movq 32(%0), %%mm4;" - "movq 40(%0), %%mm5;" - "movq 48(%0), %%mm6;" - "movq 56(%0), %%mm7;" - "movntq %%mm0, (%1);" - "movntq %%mm1, 8(%1);" - "movntq %%mm2, 16(%1);" - "movntq %%mm3, 24(%1);" - "movntq %%mm4, 32(%1);" - "movntq %%mm5, 40(%1);" - "movntq %%mm6, 48(%1);" - "movntq %%mm7, 56(%1);" - :: "r" (src), "r" (dest) : "memory"); - src = ((const unsigned char *)src) + 64; - dest = ((unsigned char *)dest) + 64; - } - /* since movntq is weakly-ordered, a "sfence" - * is needed to become ordered again. */ - __asm__ __volatile__ ("sfence":::"memory"); - __asm__ __volatile__ ("emms":::"memory"); - } - /* - * Now do the tail of the block - */ - if (n) __memcpy(dest, src, n); - return retval; -} - -static FUNCTARGET("mmx") void *mmx1_cpy(void *dest, const void *src, size_t n) //3DNOW -{ - void *retval = dest; - size_t i; - - /* PREFETCH has effect even for MOVSB instruction ;) */ - __asm__ __volatile__ ( - "prefetch (%0);" - "prefetch 32(%0);" - "prefetch 64(%0);" - "prefetch 96(%0);" - "prefetch 128(%0);" - "prefetch 160(%0);" - "prefetch 192(%0);" - "prefetch 224(%0);" - "prefetch 256(%0);" - "prefetch 288(%0);" - : : "r" (src)); - - if (n >= MMX1_MIN_LEN) - { - register unsigned long int delta; - /* Align destinition to MMREG_SIZE -boundary */ - delta = ((unsigned long int)dest)&(MMX_MMREG_SIZE-1); - if (delta) - { - delta=MMX_MMREG_SIZE-delta; - n -= delta; - small_memcpy(dest, src, delta); - } - i = n >> 6; /* n/64 */ - n&=63; - for (; i>0; i--) - { - __asm__ __volatile__ ( - "prefetch 320(%0);" - "prefetch 352(%0);" - "movq (%0), %%mm0;" - "movq 8(%0), %%mm1;" - "movq 16(%0), %%mm2;" - "movq 24(%0), %%mm3;" - "movq 32(%0), %%mm4;" - "movq 40(%0), %%mm5;" - "movq 48(%0), %%mm6;" - "movq 56(%0), %%mm7;" - "movq %%mm0, (%1);" - "movq %%mm1, 8(%1);" - "movq %%mm2, 16(%1);" - "movq %%mm3, 24(%1);" - "movq %%mm4, 32(%1);" - "movq %%mm5, 40(%1);" - "movq %%mm6, 48(%1);" - "movq %%mm7, 56(%1);" - :: "r" (src), "r" (dest) : "memory"); - src = ((const unsigned char *)src) + 64; - dest = ((unsigned char *)dest) + 64; - } - __asm__ __volatile__ ("femms":::"memory"); // same as mmx_cpy() but with a femms - } - /* - * Now do the tail of the block - */ - if (n) __memcpy(dest, src, n); - return retval; -} -#endif - -// Alam: why? memcpy may be __cdecl/_System and our code may be not the same type -static void *cpu_cpy(void *dest, const void *src, size_t n) -{ - if (src == NULL) - { - CONS_Debug(DBG_MEMORY, "Memcpy from 0x0?!: %p %p %s\n", dest, src, sizeu1(n)); - return dest; - } - - if(dest == NULL) - { - CONS_Debug(DBG_MEMORY, "Memcpy to 0x0?!: %p %p %s\n", dest, src, sizeu1(n)); - return dest; - } - return memcpy(dest, src, n); } -static /*FUNCTARGET("mmx")*/ void *mmx_cpy(void *dest, const void *src, size_t n) -{ -#if defined (_MSC_VER) && defined (_X86_) - _asm - { - mov ecx, [n] - mov esi, [src] - mov edi, [dest] - shr ecx, 6 // mit mmx: 64bytes per iteration - jz lower_64 // if lower than 64 bytes - loop_64: // MMX transfers multiples of 64bytes - movq mm0, 0[ESI] // read sources - movq mm1, 8[ESI] - movq mm2, 16[ESI] - movq mm3, 24[ESI] - movq mm4, 32[ESI] - movq mm5, 40[ESI] - movq mm6, 48[ESI] - movq mm7, 56[ESI] - - movq 0[EDI], mm0 // write destination - movq 8[EDI], mm1 - movq 16[EDI], mm2 - movq 24[EDI], mm3 - movq 32[EDI], mm4 - movq 40[EDI], mm5 - movq 48[EDI], mm6 - movq 56[EDI], mm7 - - add esi, 64 - add edi, 64 - dec ecx - jnz loop_64 - emms // close mmx operation - lower_64:// transfer rest of buffer - mov ebx,esi - sub ebx,src - mov ecx,[n] - sub ecx,ebx - shr ecx, 3 // multiples of 8 bytes - jz lower_8 - loop_8: - movq mm0, [esi] // read source - movq [edi], mm0 // write destination - add esi, 8 - add edi, 8 - dec ecx - jnz loop_8 - emms // close mmx operation - lower_8: - mov ebx,esi - sub ebx,src - mov ecx,[n] - sub ecx,ebx - rep movsb - mov eax, [dest] // return dest - } -#elif defined (__GNUC__) && defined (__i386__) - void *retval = dest; - size_t i; - - if (n >= MMX1_MIN_LEN) - { - register unsigned long int delta; - /* Align destinition to MMREG_SIZE -boundary */ - delta = ((unsigned long int)dest)&(MMX_MMREG_SIZE-1); - if (delta) - { - delta=MMX_MMREG_SIZE-delta; - n -= delta; - small_memcpy(dest, src, delta); - } - i = n >> 6; /* n/64 */ - n&=63; - for (; i>0; i--) - { - __asm__ __volatile__ ( - "movq (%0), %%mm0;" - "movq 8(%0), %%mm1;" - "movq 16(%0), %%mm2;" - "movq 24(%0), %%mm3;" - "movq 32(%0), %%mm4;" - "movq 40(%0), %%mm5;" - "movq 48(%0), %%mm6;" - "movq 56(%0), %%mm7;" - "movq %%mm0, (%1);" - "movq %%mm1, 8(%1);" - "movq %%mm2, 16(%1);" - "movq %%mm3, 24(%1);" - "movq %%mm4, 32(%1);" - "movq %%mm5, 40(%1);" - "movq %%mm6, 48(%1);" - "movq %%mm7, 56(%1);" - :: "r" (src), "r" (dest) : "memory"); - src = ((const unsigned char *)src) + 64; - dest = ((unsigned char *)dest) + 64; - } - __asm__ __volatile__ ("emms":::"memory"); - } - /* - * Now do the tail of the block - */ - if (n) __memcpy(dest, src, n); - return retval; -#else - return cpu_cpy(dest, src, n); -#endif -} - -void *(*M_Memcpy)(void* dest, const void* src, size_t n) = cpu_cpy; - -/** Memcpy that uses MMX, 3DNow, MMXExt or even SSE - * Do not use on overlapped memory, use memmove for that - */ -void M_SetupMemcpy(void) -{ -#if defined (__GNUC__) && defined (__i386__) - if (R_SSE2) - M_Memcpy = sse_cpy; - else if (R_MMXExt) - M_Memcpy = mmx2_cpy; - else if (R_3DNow) - M_Memcpy = mmx1_cpy; - else -#endif - if (R_MMX) - M_Memcpy = mmx_cpy; -#if 0 - M_Memcpy = cpu_cpy; -#endif -} - /** Return the appropriate message for a file error or end of file. */ const char *M_FileError(FILE *fp) diff --git a/src/m_misc.h b/src/m_misc.h index b79965b62..103b1d88a 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -94,8 +94,6 @@ TMatrix *RotateZMatrix(angle_t rad); // s1 = s2+s3+s1 (1024 lenghtmax) void strcatbf(char *s1, const char *s2, const char *s3); -void M_SetupMemcpy(void); - const char *M_FileError(FILE *handle); // counting bits, for weapon ammo code, usually diff --git a/src/p_enemy.c b/src/p_enemy.c index e617cfbce..42fc2bcf7 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -29,11 +29,8 @@ #include "hardware/hw3sound.h" #endif -#ifdef HAVE_BLUA boolean LUA_CallAction(const char *action, mobj_t *actor); -#endif -player_t *stplyr; INT32 var1; INT32 var2; @@ -766,78 +763,6 @@ static boolean P_LookForShield(mobj_t *actor) //return false; } -#ifdef WEIGHTEDRECYCLER -// Compares players to see who currently has the "best" items, etc. -static int P_RecycleCompare(const void *p1, const void *p2) -{ - player_t *player1 = &players[*(const UINT8 *)p1]; - player_t *player2 = &players[*(const UINT8 *)p2]; - - // Non-shooting gametypes - if (!G_RaceGametype()) - { - // Invincibility. - if (player1->powers[pw_invulnerability] > player2->powers[pw_invulnerability]) return -1; - else if (player2->powers[pw_invulnerability] > player1->powers[pw_invulnerability]) return 1; - - // One has a shield, the other doesn't. - if (player1->powers[pw_shield] && !player2->powers[pw_shield]) return -1; - else if (player2->powers[pw_shield] && !player1->powers[pw_shield]) return 1; - - // Sneakers. - if (player1->powers[pw_sneakers] > player2->powers[pw_sneakers]) return -1; - else if (player2->powers[pw_sneakers] > player1->powers[pw_sneakers]) return 1; - } - else // Match, Team Match, CTF, Tag, Etc. - { - UINT8 player1_em = M_CountBits((UINT32)player1->powers[pw_emeralds], 7); - UINT8 player2_em = M_CountBits((UINT32)player2->powers[pw_emeralds], 7); - - UINT8 player1_rw = M_CountBits((UINT32)player1->ringweapons, NUM_WEAPONS-1); - UINT8 player2_rw = M_CountBits((UINT32)player2->ringweapons, NUM_WEAPONS-1); - - UINT16 player1_am = player1->powers[pw_infinityring] // max 800 - + player1->powers[pw_automaticring] // max 300 - + (player1->powers[pw_bouncering] * 3) // max 100 - + (player1->powers[pw_explosionring] * 6) // max 50 - + (player1->powers[pw_scatterring] * 3) // max 100 - + (player1->powers[pw_grenadering] * 6) // max 50 - + (player1->powers[pw_railring] * 6); // max 50 - UINT16 player2_am = player2->powers[pw_infinityring] // max 800 - + player2->powers[pw_automaticring] // max 300 - + (player2->powers[pw_bouncering] * 3) // max 100 - + (player2->powers[pw_explosionring] * 6) // max 50 - + (player2->powers[pw_scatterring] * 3) // max 100 - + (player2->powers[pw_grenadering] * 6) // max 50 - + (player2->powers[pw_railring] * 6); // max 50 - - // Super trumps everything. - if (player1->powers[pw_super] && !player2->powers[pw_super]) return -1; - else if (player2->powers[pw_super] && !player1->powers[pw_super]) return 1; - - // Emerald count if neither player is Super. - if (player1_em > player2_em) return -1; - else if (player1_em < player2_em) return 1; - - // One has a shield, the other doesn't. - // (the likelihood of a shielded player being worse off than one without one is low.) - if (player1->powers[pw_shield] && !player2->powers[pw_shield]) return -1; - else if (player2->powers[pw_shield] && !player1->powers[pw_shield]) return 1; - - // Ring weapons count - if (player1_rw > player2_rw) return -1; - else if (player1_rw < player2_rw) return 1; - - // Ring ammo if they have the same number of weapons - if (player1_am > player2_am) return -1; - else if (player1_am < player2_am) return 1; - } - - // Identical for our purposes - return 0; -} -#endif - // // ACTION ROUTINES // @@ -856,10 +781,8 @@ void A_Look(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Look", actor)) return; -#endif if (!P_LookForPlayers(actor, locvar1 & 65535, false , FixedMul((locvar1 >> 16)*FRACUNIT, actor->scale))) return; @@ -894,10 +817,8 @@ void A_Chase(mobj_t *actor) INT32 delta; INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Chase", actor)) return; -#endif I_Assert(actor != NULL); I_Assert(!P_MobjWasRemoved(actor)); @@ -987,10 +908,8 @@ void A_FaceStabChase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA if (LUA_CallAction("A_FaceStabChase", actor)) return; -#endif if (actor->reactiontime) actor->reactiontime--; @@ -1075,10 +994,9 @@ nomissile: // void A_JetJawRoam(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_JetJawRoam", actor)) return; -#endif + if (actor->reactiontime) { actor->reactiontime--; @@ -1104,10 +1022,9 @@ void A_JetJawRoam(mobj_t *actor) void A_JetJawChomp(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetJawChomp", actor)) return; -#endif // turn towards movement direction if not there yet if (actor->movedir < NUMDIRS) @@ -1153,10 +1070,9 @@ void A_PointyThink(mobj_t *actor) boolean firsttime = true; INT32 sign; -#ifdef HAVE_BLUA if (LUA_CallAction("A_PointyThink", actor)) return; -#endif + actor->momx = actor->momy = actor->momz = 0; // Find nearest player @@ -1252,10 +1168,9 @@ void A_CheckBuddy(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_CheckBuddy", actor)) return; -#endif + if (locvar1 && (!actor->tracer || actor->tracer->health <= 0)) P_RemoveMobj(actor); else if (!locvar1 && (!actor->target || actor->target->health <= 0)) @@ -1271,10 +1186,9 @@ void A_CheckBuddy(mobj_t *actor) // void A_HoodThink(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_HoodThink", actor)) return; -#endif + // Currently in the air... if (!(actor->eflags & MFE_VERTICALFLIP) && actor->z > actor->floorz) { @@ -1333,10 +1247,8 @@ void A_ArrowCheck(mobj_t *actor) angle_t angle; fixed_t dist; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ArrowCheck", actor)) return; -#endif // Movement vector x = actor->momx; @@ -1373,10 +1285,8 @@ void A_ArrowCheck(mobj_t *actor) // void A_SnailerThink(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SnailerThink", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -1448,10 +1358,8 @@ void A_SnailerThink(mobj_t *actor) // void A_SharpChase(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SharpChase", actor)) return; -#endif if (!actor->health) { @@ -1508,10 +1416,8 @@ void A_SharpChase(mobj_t *actor) // void A_SharpSpin(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SharpSpin", actor)) return; -#endif if (!actor->health) { @@ -1546,10 +1452,8 @@ void A_SharpSpin(mobj_t *actor) // void A_VultureVtol(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_VultureVtol", actor)) return; -#endif if (!actor->target) return; @@ -1583,10 +1487,8 @@ void A_VultureVtol(mobj_t *actor) // void A_VultureCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_VultureCheck", actor)) return; -#endif if (actor->momx || actor->momy) return; @@ -1611,10 +1513,9 @@ void A_SkimChase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SkimChase", actor)) return; -#endif + if (actor->reactiontime) actor->reactiontime--; @@ -1698,10 +1599,9 @@ nomissile: // void A_FaceTarget(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_FaceTarget", actor)) return; -#endif + if (!actor->target) return; @@ -1717,10 +1617,9 @@ void A_FaceTarget(mobj_t *actor) // void A_FaceTracer(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_FaceTracer", actor)) return; -#endif + if (!actor->tracer) return; @@ -1747,10 +1646,9 @@ void A_LobShot(mobj_t *actor) fixed_t vertical, horizontal; fixed_t airtime = var2 & 65535; -#ifdef HAVE_BLUA if (LUA_CallAction("A_LobShot", actor)) return; -#endif + if (!actor->target) return; @@ -1848,10 +1746,9 @@ void A_FireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_FireShot", actor)) return; -#endif + if (!actor->target) return; @@ -1887,10 +1784,9 @@ void A_SuperFireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SuperFireShot", actor)) return; -#endif + if (!actor->target) return; @@ -1934,10 +1830,9 @@ void A_BossFireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BossFireShot", actor)) return; -#endif + if (!actor->target) return; @@ -2016,10 +1911,8 @@ void A_Boss7FireMissiles(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss7FireMissiles", actor)) return; -#endif if (!actor->target) { @@ -2075,10 +1968,9 @@ void A_Boss1Laser(mobj_t *actor) angle_t angle; mobj_t *point; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss1Laser", actor)) return; -#endif + if (!actor->target) return; @@ -2176,10 +2068,9 @@ void A_Boss1Laser(mobj_t *actor) void A_FocusTarget(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FocusTarget", actor)) return; -#endif if (actor->target) { @@ -2227,10 +2118,10 @@ void A_FocusTarget(mobj_t *actor) void A_Boss4Reverse(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss4Reverse", actor)) return; -#endif + S_StartSound(NULL, locvar1); actor->reactiontime = 0; if (actor->movedir == 1) @@ -2249,10 +2140,10 @@ void A_Boss4Reverse(mobj_t *actor) void A_Boss4SpeedUp(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss4SpeedUp", actor)) return; -#endif + S_StartSound(NULL, locvar1); actor->reactiontime = 2; } @@ -2267,10 +2158,10 @@ void A_Boss4SpeedUp(mobj_t *actor) void A_Boss4Raise(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss4Raise", actor)) return; -#endif + S_StartSound(NULL, locvar1); actor->reactiontime = 1; } @@ -2298,10 +2189,9 @@ void A_SkullAttack(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SkullAttack", actor)) return; -#endif + if (!actor->target) return; @@ -2349,10 +2239,9 @@ void A_BossZoom(mobj_t *actor) angle_t an; INT32 dist; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BossZoom", actor)) return; -#endif + if (!actor->target) return; @@ -2390,10 +2279,9 @@ void A_BossScream(mobj_t *actor) INT32 locvar2 = var2; mobjtype_t explodetype; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BossScream", actor)) return; -#endif + switch (locvar1) { default: @@ -2438,10 +2326,9 @@ void A_BossScream(mobj_t *actor) // void A_Scream(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Scream", actor)) return; -#endif + if (actor->tracer && (actor->tracer->type == MT_SHELL || actor->tracer->type == MT_FIREBALL)) S_StartScreamSound(actor, sfx_mario2); else if (actor->info->deathsound) @@ -2457,10 +2344,9 @@ void A_Scream(mobj_t *actor) // void A_Pain(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Pain", actor)) return; -#endif + if (actor->info->painsound) S_StartSound(actor, actor->info->painsound); @@ -2477,10 +2363,9 @@ void A_Pain(mobj_t *actor) // void A_Fall(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Fall", actor)) return; -#endif + // actor is on ground, it can be walked over actor->flags &= ~MF_SOLID; @@ -2507,10 +2392,9 @@ void A_1upThinker(mobj_t *actor) fixed_t temp; INT32 closestplayer = -1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_1upThinker", actor)) return; -#endif + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].bot || players[i].spectator) @@ -2566,10 +2450,8 @@ void A_MonitorPop(mobj_t *actor) mobjtype_t item = 0; //mobjtype_t newbox; -#ifdef HAVE_BLUA if (LUA_CallAction("A_MonitorPop", actor)) return; -#endif // de-solidify actor->health = 0; @@ -2706,10 +2588,9 @@ for (i = cvar.value; i; --i) spawnchance[numchoices++] = type // void A_Explode(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Explode", actor)) return; -#endif + P_RadiusAttack(actor, actor->target, actor->info->damage); } @@ -2726,10 +2607,9 @@ void A_BossDeath(mobj_t *mo) mobj_t *mo2; line_t junk; INT32 i; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BossDeath", mo)) return; -#endif P_LinedefExecute(LE_BOSSDEAD, mo, NULL); mo->health = 0; @@ -2778,12 +2658,11 @@ void A_BossDeath(mobj_t *mo) } bossjustdie: -#ifdef HAVE_BLUA if (LUAh_BossDeath(mo)) return; else if (P_MobjWasRemoved(mo)) return; -#endif + if (mo->type == MT_BLACKEGGMAN || mo->type == MT_CYBRAKDEMON) { mo->flags |= MF_NOCLIP; @@ -2898,10 +2777,9 @@ void A_CustomPower(mobj_t *actor) INT32 locvar2 = var2; boolean spawnshield = false; -#ifdef HAVE_BLUA if (LUA_CallAction("A_CustomPower", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -2939,10 +2817,9 @@ void A_GiveWeapon(mobj_t *actor) player_t *player; INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_GiveWeapon", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -2973,10 +2850,9 @@ void A_JumpShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_JumpShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3005,10 +2881,9 @@ void A_RingShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RingShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3038,10 +2913,9 @@ void A_RingBox(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RingBox", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3066,10 +2940,9 @@ void A_Invincibility(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Invincibility", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3099,10 +2972,9 @@ void A_SuperSneakers(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SuperSneakers", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3136,10 +3008,9 @@ void A_AwardScore(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_AwardScore", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3164,10 +3035,9 @@ void A_ExtraLife(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ExtraLife", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3204,10 +3074,9 @@ void A_BombShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BombShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3236,10 +3105,9 @@ void A_WaterShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_WaterShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3254,11 +3122,6 @@ void A_WaterShield(mobj_t *actor) P_SpawnShieldOrb(player); } - /* // SRB2kart - Can't drown. - if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) - P_RestoreMusic(player); - */ - player->powers[pw_underwater] = 0; if (player->powers[pw_spacetime] > 1) @@ -3280,10 +3143,9 @@ void A_ForceShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ForceShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3318,10 +3180,9 @@ void A_PityShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_PityShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3351,10 +3212,9 @@ void A_GravityBox(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_GravityBox", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3376,10 +3236,9 @@ void A_GravityBox(mobj_t *actor) // void A_ScoreRise(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_ScoreRise", actor)) return; -#endif + // make logo rise! P_SetObjectMomZ(actor, actor->info->speed, false); } @@ -3398,10 +3257,9 @@ void A_ParticleSpawn(mobj_t *actor) mobjtype_t type; mobj_t *spawn; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ParticleSpawn", actor)) return; -#endif + if (!actor->spawnpoint) { P_RemoveMobj(actor); @@ -3435,10 +3293,9 @@ void A_BunnyHop(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BunnyHop", actor)) return; -#endif + if (((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz) || (!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz)) { @@ -3459,10 +3316,10 @@ void A_BubbleSpawn(mobj_t *actor) INT32 i, locvar1 = var1; UINT8 prandom; mobj_t *bubble = NULL; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BubbleSpawn", actor)) return; -#endif + if (!(actor->eflags & MFE_UNDERWATER)) { // Don't draw or spawn bubbles above water @@ -3512,10 +3369,10 @@ void A_FanBubbleSpawn(mobj_t *actor) UINT8 prandom; mobj_t *bubble = NULL; fixed_t hz = actor->z + (4*actor->height)/5; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FanBubbleSpawn", actor)) return; -#endif + if (!(actor->eflags & MFE_UNDERWATER)) return; @@ -3559,10 +3416,9 @@ void A_BubbleRise(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BubbleRise", actor)) return; -#endif + if (actor->type == MT_EXTRALARGEBUBBLE) P_SetObjectMomZ(actor, FixedDiv(6*FRACUNIT,5*FRACUNIT), false); // make bubbles rise! else @@ -3596,10 +3452,9 @@ void A_BubbleRise(mobj_t *actor) // void A_BubbleCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_BubbleCheck", actor)) return; -#endif + if (actor->eflags & MFE_UNDERWATER) actor->flags2 &= ~MF2_DONTDRAW; // underwater so draw else @@ -3615,10 +3470,9 @@ void A_BubbleCheck(mobj_t *actor) // void A_AttractChase(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_AttractChase", actor)) return; -#endif + if (actor->flags2 & MF2_NIGHTSPULL || !actor->health) return; @@ -3687,10 +3541,9 @@ void A_DropMine(mobj_t *actor) INT32 locvar2 = var2; fixed_t z; mobj_t *mine; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_DropMine", actor)) return; -#endif if (locvar2 & 65535) { @@ -3735,10 +3588,9 @@ void A_DropMine(mobj_t *actor) void A_FishJump(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FishJump", actor)) return; -#endif if ((actor->z <= actor->floorz) || (actor->z <= actor->watertop - FixedMul((64 << FRACBITS), actor->scale))) { @@ -3772,10 +3624,9 @@ void A_ThrownRing(mobj_t *actor) INT32 stop; player_t *player; fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ThrownRing", actor)) return; -#endif if (leveltime % (TICRATE/7) == 0) { @@ -3979,10 +3830,9 @@ void A_GrenadeRing(mobj_t *actor) { INT32 bx, by, xl, xh, yl, yh; explodedist = FixedMul(actor->info->painchance, mapobjectscale); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_GrenadeRing", actor)) return; -#endif if (actor->flags2 & MF2_DEBRIS) return; @@ -4051,10 +3901,9 @@ void A_MineExplode(mobj_t *actor) INT32 locvar1 = var1; mobjtype_t type; explodedist = FixedMul((3*actor->info->painchance)/2, mapobjectscale); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MineExplode", actor)) return; -#endif if (actor->flags2 & MF2_DEBRIS) return; @@ -4098,10 +3947,9 @@ void A_MineExplode(mobj_t *actor) // void A_SetSolidSteam(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SetSolidSteam", actor)) return; -#endif + actor->flags &= ~MF_NOCLIP; actor->flags |= MF_SOLID; @@ -4131,10 +3979,10 @@ void A_SetSolidSteam(mobj_t *actor) // void A_UnsetSolidSteam(mobj_t *actor) { -#ifdef HAVE_BLUA + if (LUA_CallAction("A_UnsetSolidSteam", actor)) return; -#endif + actor->flags &= ~MF_SOLID; actor->flags |= MF_NOCLIP; } @@ -4149,10 +3997,10 @@ void A_UnsetSolidSteam(mobj_t *actor) void A_SignPlayer(mobj_t *actor) { mobj_t *ov; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SignPlayer", actor)) return; -#endif + if (!actor->target) return; @@ -4193,10 +4041,10 @@ void A_SignPlayer(mobj_t *actor) void A_OverlayThink(mobj_t *actor) { fixed_t destx, desty; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_OverlayThink", actor)) return; -#endif + if (!actor->target) return; @@ -4245,10 +4093,9 @@ void A_OverlayThink(mobj_t *actor) void A_JetChase(mobj_t *actor) { fixed_t thefloor; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetChase", actor)) return; -#endif if (actor->flags2 & MF2_AMBUSH) return; @@ -4342,10 +4189,9 @@ void A_JetbThink(mobj_t *actor) { sector_t *nextsector; fixed_t thefloor; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetbThink", actor)) return; -#endif if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz && actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale)) @@ -4407,10 +4253,9 @@ void A_JetbThink(mobj_t *actor) void A_JetgShoot(mobj_t *actor) { fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetgShoot", actor)) return; -#endif if (!actor->target) return; @@ -4448,10 +4293,9 @@ void A_JetgShoot(mobj_t *actor) void A_ShootBullet(mobj_t *actor) { fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ShootBullet", actor)) return; -#endif if (!actor->target) return; @@ -4477,10 +4321,9 @@ void A_ShootBullet(mobj_t *actor) // void A_MinusDigging(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_MinusDigging", actor)) return; -#endif + actor->flags &= ~MF_SPECIAL; actor->flags &= ~MF_SHOOTABLE; @@ -4529,10 +4372,10 @@ void A_MinusDigging(mobj_t *actor) // void A_MinusPopup(mobj_t *actor) { -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MinusPopup", actor)) return; -#endif + P_SetObjectMomZ(actor, 10*FRACUNIT, false); actor->flags |= MF_SPECIAL; @@ -4551,10 +4394,9 @@ void A_MinusPopup(mobj_t *actor) // void A_MinusCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_MinusCheck", actor)) return; -#endif + if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) || ((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz)) { @@ -4579,10 +4421,9 @@ void A_MinusCheck(mobj_t *actor) // void A_ChickenCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_ChickenCheck", actor)) return; -#endif + if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) || (actor->eflags & MFE_VERTICALFLIP && actor->z + actor->height >= actor->ceilingz)) { @@ -4610,10 +4451,9 @@ void A_JetgThink(mobj_t *actor) sector_t *nextsector; fixed_t thefloor; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetgThink", actor)) return; -#endif if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz && actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale)) @@ -4662,10 +4502,8 @@ void A_JetgThink(mobj_t *actor) // void A_MouseThink(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_MouseThink", actor)) return; -#endif if (actor->reactiontime) actor->reactiontime--; @@ -4700,10 +4538,9 @@ void A_DetonChase(mobj_t *actor) { angle_t exact; fixed_t xydist, dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_DetonChase", actor)) return; -#endif // modify tracer threshold if (!actor->tracer || actor->tracer->health <= 0) @@ -4847,10 +4684,9 @@ void A_CapeChase(mobj_t *actor) fixed_t foffsetx, foffsety, boffsetx, boffsety; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CapeChase", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_CapeChase called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -4906,10 +4742,9 @@ void A_RotateSpikeBall(mobj_t *actor) { INT32 locvar1 = var1; const fixed_t radius = FixedMul(12*actor->info->speed, actor->scale); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RotateSpikeBall", actor)) return; -#endif if (actor->type == MT_SPECIALSPIKEBALL) // don't remove this, these spikeballs share the same states as the rotating spikeballs return; @@ -4962,10 +4797,8 @@ void A_UnidusBall(mobj_t *actor) INT32 locvar1 = var1; boolean canthrow = false; -#ifdef HAVE_BLUA if (LUA_CallAction("A_UnidusBall", actor)) return; -#endif actor->angle += ANGLE_11hh; @@ -5060,10 +4893,9 @@ void A_RockSpawn(mobj_t *actor) line_t *line; fixed_t dist; fixed_t randomoomph; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RockSpawn", actor)) return; -#endif if (i == -1) { @@ -5115,10 +4947,9 @@ void A_SlingAppear(mobj_t *actor) boolean firsttime = true; UINT8 mlength = 4; mobj_t *spawnee; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SlingAppear", actor)) return; -#endif P_UnsetThingPosition(actor); actor->flags &= ~(MF_NOBLOCKMAP|MF_NOCLIP|MF_NOGRAVITY|MF_NOCLIPHEIGHT); @@ -5176,10 +5007,9 @@ void A_MaceRotate(mobj_t *actor) TVector v; TVector *res; fixed_t radius; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MaceRotate", actor)) return; -#endif // Target was removed. if (!actor->target) @@ -5289,10 +5119,9 @@ void A_SetFuse(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetFuse", actor)) return; -#endif if ((!actor->fuse || (locvar2 >> 16)) && (locvar2 >> 16) != 2) // set the actor's fuse value actor->fuse = locvar1; @@ -5318,10 +5147,9 @@ void A_CrawlaCommanderThink(mobj_t *actor) fixed_t thefloor; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CrawlaCommanderThink", actor)) return; -#endif if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz && actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale)) @@ -5457,10 +5285,9 @@ void A_RingExplode(mobj_t *actor) mobj_t *mo2; thinker_t *th; angle_t d; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RingExplode", actor)) return; -#endif for (d = 0; d < 16; d++) P_SpawnParaloop(actor->x, actor->y, actor->z + actor->height, FixedMul(actor->info->painchance, actor->scale), 16, MT_NIGHTSPARKLE, S_NULL, d*(ANGLE_22h), true); @@ -5504,10 +5331,9 @@ void A_OldRingExplode(mobj_t *actor) { INT32 locvar1 = var1; //INT32 locvar2 = var2; boolean changecolor = (actor->target && actor->target->player); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_OldRingExplode", actor)) return; -#endif for (i = 0; i < 32; i++) { @@ -5581,12 +5407,9 @@ void A_MixUp(mobj_t *actor) { boolean teleported[MAXPLAYERS]; INT32 i, numplayers = 0, prandom = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MixUp", actor)) return; -#else - (void)actor; -#endif if (!multiplayer) return; @@ -5834,9 +5657,6 @@ void A_RecyclePowers(mobj_t *actor) { INT32 i, j, k, numplayers = 0; -#ifdef WEIGHTEDRECYCLER - UINT8 beneficiary = 255; -#endif UINT8 playerslist[MAXPLAYERS]; UINT8 postscramble[MAXPLAYERS]; @@ -5844,15 +5664,8 @@ void A_RecyclePowers(mobj_t *actor) INT32 weapons[MAXPLAYERS]; INT32 weaponheld[MAXPLAYERS]; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RecyclePowers", actor)) return; -#endif - -#if !defined(WEIGHTEDRECYCLER) && !defined(HAVE_BLUA) - // actor is used in all scenarios but this one, funny enough - (void)actor; -#endif if (!multiplayer) return; @@ -5865,20 +5678,12 @@ void A_RecyclePowers(mobj_t *actor) if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE && !players[i].exiting && !((netgame || multiplayer) && players[i].spectator)) { -#ifndef WEIGHTEDRECYCLER if (players[i].powers[pw_super]) continue; // Ignore super players -#endif numplayers++; postscramble[j] = playerslist[j] = (UINT8)i; -#ifdef WEIGHTEDRECYCLER - // The guy who started the recycle gets the best result - if (actor && actor->target && actor->target->player && &players[i] == actor->target->player) - beneficiary = (UINT8)i; -#endif - // Save powers for (k = 0; k < NUMPOWERS; k++) powers[i][k] = players[i].powers[k]; @@ -5911,25 +5716,6 @@ void A_RecyclePowers(mobj_t *actor) postscramble[i] = tempint; } -#ifdef WEIGHTEDRECYCLER - //the joys of qsort... - if (beneficiary != 255) { - qsort(playerslist, numplayers, sizeof(UINT8), P_RecycleCompare); - - // now, make sure the benificiary is in the best slot - // swap out whatever poor sap was going to get the best items - for (i = 0; i < numplayers; i++) - { - if (postscramble[i] == beneficiary) - { - postscramble[i] = postscramble[0]; - postscramble[0] = beneficiary; - break; - } - } - } -#endif - // now assign! for (i = 0; i < numplayers; i++) { @@ -5970,10 +5756,9 @@ void A_RecyclePowers(mobj_t *actor) void A_Boss1Chase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss1Chase", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -6091,10 +5876,9 @@ void A_Boss2Chase(mobj_t *actor) fixed_t radius; boolean reverse = false; INT32 speedvar; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss2Chase", actor)) return; -#endif if (actor->health <= 0) return; @@ -6219,10 +6003,9 @@ void A_Boss2Chase(mobj_t *actor) // void A_Boss2Pogo(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss2Pogo", actor)) return; -#endif + if (actor->z <= actor->floorz + FixedMul(8*FRACUNIT, actor->scale) && actor->momz <= 0) { if (actor->state != &states[actor->info->raisestate]) @@ -6267,10 +6050,10 @@ void A_Boss2Pogo(mobj_t *actor) void A_Boss2TakeDamage(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss2TakeDamage", actor)) return; -#endif + A_Pain(actor); actor->reactiontime = 1; // turn around if (locvar1 == 0) // old A_Invincibilerize behavior @@ -6290,10 +6073,9 @@ void A_Boss7Chase(mobj_t *actor) { INT32 delta; INT32 i; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss7Chase", actor)) return; -#endif if (actor->z != actor->floorz) return; @@ -6422,10 +6204,9 @@ void A_Boss7Chase(mobj_t *actor) // void A_GoopSplat(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_GoopSplat", actor)) return; -#endif + P_UnsetThingPosition(actor); if (sector_list) { @@ -6447,10 +6228,9 @@ void A_Boss2PogoSFX(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss2PogoSFX", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -6491,10 +6271,8 @@ void A_Boss2PogoTarget(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss2PogoTarget", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE) || (actor->target->player && actor->target->player->powers[pw_flashing]) || P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) >= FixedMul(512*FRACUNIT, actor->scale)) @@ -6578,10 +6356,9 @@ void A_Boss2PogoTarget(mobj_t *actor) // void A_EggmanBox(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_EggmanBox", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -6604,10 +6381,9 @@ void A_TurretFire(mobj_t *actor) fixed_t dist; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_TurretFire", actor)) return; -#endif if (locvar2) dist = FixedMul(locvar2*FRACUNIT, actor->scale); @@ -6643,10 +6419,9 @@ void A_SuperTurretFire(mobj_t *actor) fixed_t dist; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SuperTurretFire", actor)) return; -#endif if (locvar2) dist = FixedMul(locvar2*FRACUNIT, actor->scale); @@ -6680,10 +6455,9 @@ void A_SuperTurretFire(mobj_t *actor) void A_TurretStop(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_TurretStop", actor)) return; -#endif actor->flags2 &= ~MF2_FIRING; actor->flags2 &= ~MF2_SUPERFIRE; @@ -6701,10 +6475,8 @@ void A_TurretStop(mobj_t *actor) // void A_SparkFollow(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SparkFollow", actor)) return; -#endif if ((!actor->target || (actor->target->health <= 0)) || (actor->target->player && !actor->target->player->powers[pw_super])) @@ -6738,10 +6510,10 @@ void A_BuzzFly(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BuzzFly", actor)) return; -#endif + if (actor->flags2 & MF2_AMBUSH) return; @@ -6837,10 +6609,9 @@ void A_BuzzFly(mobj_t *actor) void A_GuardChase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_GuardChase", actor)) return; -#endif if (actor->reactiontime) actor->reactiontime--; @@ -6913,10 +6684,9 @@ void A_EggShield(mobj_t *actor) fixed_t newx, newy; fixed_t movex, movey; angle_t angle; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_EggShield", actor)) return; -#endif if (!actor->target || !actor->target->health) { @@ -6997,10 +6767,9 @@ void A_EggShield(mobj_t *actor) // void A_SetReactionTime(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SetReactionTime", actor)) return; -#endif + if (var1) actor->reactiontime = var2; else @@ -7020,10 +6789,8 @@ void A_Boss1Spikeballs(mobj_t *actor) INT32 locvar2 = var2; mobj_t *ball; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss1Spikeballs", actor)) return; -#endif ball = P_SpawnMobj(actor->x, actor->y, actor->z, MT_EGGMOBILE_BALL); P_SetTarget(&ball->target, actor); @@ -7044,10 +6811,9 @@ void A_Boss1Spikeballs(mobj_t *actor) // void A_Boss3TakeDamage(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss3TakeDamage", actor)) return; -#endif + actor->movecount = var1; if (actor->target && actor->target->spawnpoint) @@ -7063,10 +6829,8 @@ void A_Boss3TakeDamage(mobj_t *actor) // void A_Boss3Path(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss3Path", actor)) return; -#endif if (actor->tracer && actor->tracer->health && actor->tracer->movecount) actor->movecount |= 1; @@ -7190,10 +6954,9 @@ void A_LinedefExecute(mobj_t *actor) INT32 tagnum; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_LinedefExecute", actor)) return; -#endif tagnum = locvar1; // state numbers option is no more, custom states cannot be guaranteed to stay the same number anymore, now that they can be defined by names instead @@ -7216,10 +6979,9 @@ void A_LinedefExecute(mobj_t *actor) // void A_PlaySeeSound(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_PlaySeeSound", actor)) return; -#endif + if (actor->info->seesound) S_StartScreamSound(actor, actor->info->seesound); } @@ -7233,10 +6995,9 @@ void A_PlaySeeSound(mobj_t *actor) // void A_PlayAttackSound(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_PlayAttackSound", actor)) return; -#endif + if (actor->info->attacksound) S_StartAttackSound(actor, actor->info->attacksound); } @@ -7250,10 +7011,9 @@ void A_PlayAttackSound(mobj_t *actor) // void A_PlayActiveSound(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_PlayActiveSound", actor)) return; -#endif + if (actor->info->activesound) S_StartSound(actor, actor->info->activesound); } @@ -7269,10 +7029,9 @@ void A_SmokeTrailer(mobj_t *actor) { mobj_t *th; INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SmokeTrailer", actor)) return; -#endif if (leveltime % 4) return; @@ -7311,10 +7070,9 @@ void A_SpawnObjectAbsolute(mobj_t *actor) mobj_t *mo; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SpawnObjectAbsolute", actor)) return; -#endif x = (INT16)(locvar1>>16); y = (INT16)(locvar1&65535); @@ -7348,10 +7106,9 @@ void A_SpawnObjectRelative(mobj_t *actor) mobj_t *mo; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SpawnObjectRelative", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_SpawnObjectRelative called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7387,25 +7144,16 @@ void A_ChangeAngleRelative(mobj_t *actor) // rather than the ranges, so <0 and >360 work as possible values. -Red INT32 locvar1 = var1; INT32 locvar2 = var2; - //angle_t angle = (P_RandomByte()+1)<<24; const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - //const angle_t amin = FixedAngle(locvar1*FRACUNIT); - //const angle_t amax = FixedAngle(locvar2*FRACUNIT); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeAngleRelative", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) I_Error("A_ChangeAngleRelative: var1 is greater then var2"); #endif -/* - if (angle < amin) - angle = amin; - if (angle > amax) - angle = amax;*/ actor->angle += FixedAngle(P_RandomRange(amin, amax)); } @@ -7421,25 +7169,16 @@ void A_ChangeAngleAbsolute(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; - //angle_t angle = (P_RandomByte()+1)<<24; const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - //const angle_t amin = FixedAngle(locvar1*FRACUNIT); - //const angle_t amax = FixedAngle(locvar2*FRACUNIT); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeAngleAbsolute", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) I_Error("A_ChangeAngleAbsolute: var1 is greater then var2"); #endif -/* - if (angle < amin) - angle = amin; - if (angle > amax) - angle = amax;*/ actor->angle = FixedAngle(P_RandomRange(amin, amax)); } @@ -7457,10 +7196,8 @@ void A_RollAngle(mobj_t *actor) INT32 locvar2 = var2; const angle_t angle = FixedAngle(locvar1*FRACUNIT); -#ifdef HAVE_BLUA if (LUA_CallAction("A_RollAngle", actor)) return; -#endif // relative (default) if (!locvar2) @@ -7483,10 +7220,9 @@ void A_ChangeRollAngleRelative(mobj_t *actor) INT32 locvar2 = var2; const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeRollAngleRelative", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) @@ -7509,10 +7245,9 @@ void A_ChangeRollAngleAbsolute(mobj_t *actor) INT32 locvar2 = var2; const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeRollAngleAbsolute", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) @@ -7535,10 +7270,9 @@ void A_PlaySound(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_PlaySound", actor)) return; -#endif S_StartSound(locvar2 ? actor : NULL, locvar1); } @@ -7558,10 +7292,9 @@ void A_FindTarget(mobj_t *actor) thinker_t *th; mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FindTarget", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_FindTarget called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7623,10 +7356,9 @@ void A_FindTracer(mobj_t *actor) thinker_t *th; mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FindTracer", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_FindTracer called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7684,10 +7416,9 @@ void A_SetTics(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetTics", actor)) return; -#endif if (locvar1) actor->tics = locvar1; @@ -7706,10 +7437,9 @@ void A_SetRandomTics(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetRandomTics", actor)) return; -#endif actor->tics = P_RandomRange(locvar1, locvar2); } @@ -7725,10 +7455,9 @@ void A_ChangeColorRelative(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeColorRelative", actor)) return; -#endif if (locvar1) { @@ -7751,10 +7480,9 @@ void A_ChangeColorAbsolute(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeColorAbsolute", actor)) return; -#endif if (locvar1) { @@ -7776,10 +7504,9 @@ void A_MoveRelative(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MoveRelative", actor)) return; -#endif P_Thrust(actor, actor->angle+FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); } @@ -7795,10 +7522,9 @@ void A_MoveAbsolute(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MoveAbsolute", actor)) return; -#endif P_InstaThrust(actor, FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); } @@ -7814,10 +7540,9 @@ void A_Thrust(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Thrust", actor)) return; -#endif if (!locvar1) CONS_Debug(DBG_GAMELOGIC, "A_Thrust: Var1 not specified!\n"); @@ -7841,10 +7566,9 @@ void A_ZThrust(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ZThrust", actor)) return; -#endif if (!locvar1) CONS_Debug(DBG_GAMELOGIC, "A_ZThrust: Var1 not specified!\n"); @@ -7876,10 +7600,9 @@ void A_SetTargetsTarget(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *oldtarg = NULL, *newtarg = NULL; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetTargetsTarget", actor)) return; -#endif // actor's target if (locvar1) // or tracer @@ -7921,10 +7644,9 @@ void A_SetObjectFlags(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; boolean unlinkthings = false; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetObjectFlags", actor)) return; -#endif if (locvar2 == 2) locvar1 = actor->flags | locvar1; @@ -7963,10 +7685,9 @@ void A_SetObjectFlags2(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetObjectFlags2", actor)) return; -#endif if (locvar2 == 2) actor->flags2 |= locvar1; @@ -7991,10 +7712,9 @@ void A_BossJetFume(mobj_t *actor) { mobj_t *filler; INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BossJetFume", actor)) return; -#endif if (locvar1 == 0) // Boss1 jet fumes { @@ -8102,10 +7822,9 @@ void A_RandomState(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RandomState", actor)) return; -#endif P_SetMobjState(actor, P_RandomChance(FRACUNIT/2) ? locvar1 : locvar2); } @@ -8122,10 +7841,8 @@ void A_RandomStateRange(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RandomStateRange", actor)) return; -#endif P_SetMobjState(actor, P_RandomRange(locvar1, locvar2)); } @@ -8141,27 +7858,22 @@ void A_DualAction(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_DualAction", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_DualAction called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); var1 = states[locvar1].var1; var2 = states[locvar1].var2; -#ifdef HAVE_BLUA astate = &states[locvar1]; -#endif CONS_Debug(DBG_GAMELOGIC, "A_DualAction: Calling First Action (state %d)...\n", locvar1); states[locvar1].action.acp1(actor); var1 = states[locvar2].var1; var2 = states[locvar2].var2; -#ifdef HAVE_BLUA astate = &states[locvar2]; -#endif CONS_Debug(DBG_GAMELOGIC, "A_DualAction: Calling Second Action (state %d)...\n", locvar2); states[locvar2].action.acp1(actor); @@ -8179,10 +7891,9 @@ void A_RemoteAction(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *originaltarget = actor->target; // Hold on to the target for later. -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RemoteAction", actor)) return; -#endif // If >=0, find the closest target. if (locvar1 >= 0) @@ -8244,9 +7955,7 @@ void A_RemoteAction(mobj_t *actor) // Steal the var1 and var2 from "locvar2" var1 = states[locvar2].var1; var2 = states[locvar2].var2; -#ifdef HAVE_BLUA astate = &states[locvar2]; -#endif CONS_Debug(DBG_GAMELOGIC, "A_RemoteAction: Calling action on %p\n" "var1 is %d\nvar2 is %d\n", actor->target, var1, var2); @@ -8265,10 +7974,9 @@ void A_RemoteAction(mobj_t *actor) // void A_ToggleFlameJet(mobj_t* actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_ToggleFlameJet", actor)) return; -#endif + // threshold - off delay // movecount - on timer @@ -8293,10 +8001,9 @@ void A_ItemPop(mobj_t *actor) { mobj_t *remains; mobjtype_t explode; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ItemPop", actor)) return; -#endif if (!(actor->target && actor->target->player)) { @@ -8360,10 +8067,9 @@ void A_ItemPop(mobj_t *actor) void A_JawzChase(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JawzChase", actor)) return; -#endif if (actor->tracer) { @@ -8407,10 +8113,8 @@ void A_JawzExplode(mobj_t *actor) INT32 shrapnel = 2; mobj_t *truc; -#ifdef HAVE_BLUA if (LUA_CallAction("A_JawzExplode", actor)) return; -#endif truc = P_SpawnMobj(actor->x, actor->y, actor->z, MT_BOOMEXPLODE); truc->scale = actor->scale*2; @@ -8448,10 +8152,9 @@ void A_SPBChase(mobj_t *actor) fixed_t dist; angle_t hang, vang; fixed_t wspeed, xyspeed, zspeed; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SPBChase", actor)) return; -#endif // Default speed wspeed = actor->movefactor; @@ -8728,10 +8431,9 @@ void A_SPBChase(mobj_t *actor) void A_BallhogExplode(mobj_t *actor) { mobj_t *mo2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BallhogExplode", actor)) return; -#endif mo2 = P_SpawnMobj(actor->x, actor->y, actor->z, MT_BALLHOGBOOM); P_SetScale(mo2, actor->scale*2); @@ -8745,10 +8447,10 @@ void A_BallhogExplode(mobj_t *actor) void A_LightningFollowPlayer(mobj_t *actor) { fixed_t sx, sy; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_LightningFollowPlayer", actor)) return; -#endif + if (!actor->target) return; @@ -8774,10 +8476,10 @@ void A_LightningFollowPlayer(mobj_t *actor) void A_FZBoomFlash(mobj_t *actor) { UINT8 i; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FZBoomFlash", actor)) return; -#endif + for (i = 0; i < MAXPLAYERS; i++) { fixed_t dist; @@ -8797,10 +8499,10 @@ void A_FZBoomSmoke(mobj_t *actor) { INT32 i; INT32 rad = 47+(23*var1); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FZBoomSmoke", actor)) return; -#endif + for (i = 0; i < 8+(4*var1); i++) { mobj_t *smoke = P_SpawnMobj(actor->x + (P_RandomRange(-rad, rad)*actor->scale), actor->y + (P_RandomRange(-rad, rad)*actor->scale), @@ -8819,10 +8521,9 @@ void A_RandomShadowFrame(mobj_t *actor) { mobj_t *fire; mobj_t *fake; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RandomShadowFrame", (actor))) return; -#endif if (!actor->extravalue1) // Hack that spawns thoks that look like random shadows. Otherwise the state would overwrite our frame and that's a pain. { @@ -8868,10 +8569,9 @@ void A_RoamingShadowThinker(mobj_t *actor) { mobj_t *wind; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RoamingShadowThinker", (actor))) return; -#endif + // extravalue1 replaces "movetimer" // extravalue2 replaces "stoptimer" @@ -8926,10 +8626,9 @@ void A_MayonakaArrow(mobj_t *actor) { INT32 flip = 0; INT32 iswarning; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MayonakaArrow", (actor))) return; -#endif iswarning = actor->spawnpoint->options & MTF_OBJECTSPECIAL; // is our object a warning sign? // "animtimer" is replaced by "extravalue1" here. @@ -8968,10 +8667,8 @@ void A_MementosTPParticles(mobj_t *actor) int i = 0; thinker_t *th; -#ifdef HAVE_BLUA if (LUA_CallAction("A_MementosTPParticles", (actor))) return; -#endif for (; i<4; i++) { @@ -9019,11 +8716,8 @@ void A_ReaperThinker(mobj_t *actor) player_t *player; // used as a shortcut in a loop. mobj_t *targetplayermo = NULL; // the player mo we can eventually target, or whatever. - -#ifdef HAVE_BLUA if (LUA_CallAction("A_ReaperThinker", (actor))) return; -#endif // We don't have custom variables or whatever so we'll do with whatever the fuck we have left. @@ -9192,10 +8886,9 @@ void A_FlameParticle(mobj_t *actor) { fixed_t rad = actor->radius>>FRACBITS, hei = actor->radius>>FRACBITS; mobj_t *par; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FlameParticle", actor)) return; -#endif par = P_SpawnMobj( actor->x + (P_RandomRange(-rad, rad)<target || !actor->target->player || !actor->target->tracer || !actor->target->player->nightstime @@ -9263,10 +8955,9 @@ void A_OrbitNights(mobj_t* actor) // void A_GhostMe(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_GhostMe", actor)) return; -#endif + P_SpawnGhostMobj(actor); } @@ -9284,10 +8975,9 @@ void A_SetObjectState(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *target; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetObjectState", actor)) return; -#endif if ((!locvar2 && !actor->target) || (locvar2 && !actor->tracer)) { @@ -9330,10 +9020,8 @@ void A_SetObjectTypeState(mobj_t *actor) mobj_t *mo2; fixed_t dist = 0; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SetObjectTypeState", actor)) return; -#endif for (th = thinkercap.next; th != &thinkercap; th = th->next) { @@ -9373,10 +9061,9 @@ void A_KnockBack(mobj_t *actor) { INT32 locvar1 = var1; mobj_t *target; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_KnockBack", actor)) return; -#endif if (!locvar1) target = actor->target; @@ -9409,10 +9096,9 @@ void A_PushAway(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; // target angle_t an; // actor to target angle -#ifdef HAVE_BLUA + if (LUA_CallAction("A_PushAway", actor)) return; -#endif if ((!(locvar2 >> 16) && !actor->target) || ((locvar2 >> 16) && !actor->tracer)) return; @@ -9444,10 +9130,9 @@ void A_RingDrain(mobj_t *actor) { INT32 locvar1 = var1; player_t *player; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RingDrain", actor)) return; -#endif if (!actor->target || !actor->target->player) { @@ -9477,10 +9162,9 @@ void A_SplitShot(mobj_t *actor) const UINT16 loc2up = (UINT16)(locvar2 >> 16); const fixed_t offs = (fixed_t)(locvar1*FRACUNIT); const fixed_t hoffs = (fixed_t)(loc2up*FRACUNIT); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SplitShot", actor)) return; -#endif A_FaceTarget(actor); { @@ -9512,10 +9196,10 @@ void A_MissileSplit(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MissileSplit", actor)) return; -#endif + if (actor->eflags & MFE_VERTICALFLIP) P_SpawnAlteredDirectionMissile(actor, locvar1, actor->x, actor->y, actor->z+actor->height, locvar2); else @@ -9540,10 +9224,9 @@ void A_MultiShot(mobj_t *actor) const UINT16 loc1up = (UINT16)(locvar1 >> 16); INT32 count = 0; fixed_t ad; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MultiShot", actor)) return; -#endif if (actor->target) A_FaceTarget(actor); @@ -9602,10 +9285,9 @@ void A_InstaLoop(mobj_t *actor) const angle_t fa = FixedAngleC(loc1lw*FRACUNIT*360, loc1up*FRACUNIT)>>ANGLETOFINESHIFT; const fixed_t ac = FINECOSINE(fa); const fixed_t as = FINESINE(fa); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_InstaLoop", actor)) return; -#endif P_InstaThrust(actor, actor->angle, FixedMul(ac, FixedMul(force, actor->scale))); P_SetObjectMomZ(actor, FixedMul(as, force), false); @@ -9636,10 +9318,9 @@ void A_Custom3DRotate(mobj_t *actor) const fixed_t hOff = FixedMul(loc1up*FRACUNIT, actor->scale); const fixed_t hspeed = FixedMul(loc2up*FRACUNIT/10, actor->scale); const fixed_t vspeed = FixedMul(loc2lw*FRACUNIT/10, actor->scale); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Custom3DRotate", actor)) return; -#endif if (!actor->target) // Ensure we actually have a target first. { @@ -9697,10 +9378,9 @@ void A_SearchForPlayers(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SearchForPlayers", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -9731,10 +9411,9 @@ void A_CheckRandom(mobj_t *actor) INT32 locvar2 = var2; fixed_t chance = FRACUNIT; -#ifdef HAVE_BLUA if (LUA_CallAction("A_CheckRandom", actor)) return; -#endif + if ((locvar1 & 0xFFFF) == 0) return; @@ -9758,10 +9437,9 @@ void A_CheckTargetRings(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckTargetRings", actor)) return; -#endif if (!(actor->target) || !(actor->target->player)) return; @@ -9782,10 +9460,9 @@ void A_CheckRings(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; INT32 i, cntr = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckRings", actor)) return; -#endif for (i = 0; i < MAXPLAYERS; i++) cntr += players[i].health-1; @@ -9807,10 +9484,9 @@ void A_CheckTotalRings(mobj_t *actor) INT32 locvar2 = var2; INT32 i, cntr = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckTotalRings", actor)) return; -#endif for (i = 0; i < MAXPLAYERS; i++) cntr += players[i].totalring; @@ -9830,10 +9506,9 @@ void A_CheckHealth(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckHealth", actor)) return; -#endif if (actor->health <= locvar1) P_SetMobjState(actor, locvar2); @@ -9853,10 +9528,9 @@ void A_CheckRange(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckRange", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -9884,10 +9558,9 @@ void A_CheckHeight(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; fixed_t height; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckHeight", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -9917,10 +9590,9 @@ void A_CheckTrueRange(mobj_t *actor) fixed_t height; // vertical range fixed_t dist; // horizontal range fixed_t l; // true range -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckTrueRange", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -9969,10 +9641,9 @@ void A_CheckThingCount(mobj_t *actor) thinker_t *th; mobj_t *mo2; fixed_t dist = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckThingCount", actor)) return; -#endif for (th = thinkercap.next; th != &thinkercap; th = th->next) { @@ -10016,10 +9687,8 @@ void A_CheckAmbush(mobj_t *actor) angle_t atp; // actor to target angle angle_t an; // angle between at and atp -#ifdef HAVE_BLUA if (LUA_CallAction("A_CheckAmbush", actor)) return; -#endif if ((!locvar1 && !actor->target) || (locvar1 && !actor->tracer)) return; @@ -10055,10 +9724,9 @@ void A_CheckCustomValue(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckCustomValue", actor)) return; -#endif if (actor->cusval >= locvar1) P_SetMobjState(actor, locvar2); @@ -10075,10 +9743,9 @@ void A_CheckCusValMemo(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckCusValMemo", actor)) return; -#endif if (actor->cvmem >= locvar1) P_SetMobjState(actor, locvar2); @@ -10101,10 +9768,9 @@ void A_SetCustomValue(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetCustomValue", actor)) return; -#endif if (cv_debug) CONS_Printf("Init custom value is %d\n", actor->cusval); @@ -10152,10 +9818,9 @@ void A_UseCusValMemo(mobj_t *actor) INT32 temp = actor->cusval; // value being manipulated INT32 tempM = actor->cvmem; // value used to manipulate temp with -#ifdef HAVE_BLUA + if (LUA_CallAction("A_UseCusValMemo", actor)) return; -#endif if (locvar1 == 1) // cvmem being changed using cusval { @@ -10216,10 +9881,9 @@ void A_RelayCustomValue(mobj_t *actor) INT32 temp; // reference value - var1 lower 16 bits changes this INT32 tempT; // target's value - changed to tracer if var1 upper 16 bits set, then modified to become final value -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RelayCustomValue", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -10276,10 +9940,9 @@ void A_CusValAction(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CusValAction", actor)) return; -#endif if (locvar2 == 5) { @@ -10312,9 +9975,7 @@ void A_CusValAction(mobj_t *actor) var2 = states[locvar1].var2; } -#ifdef HAVE_BLUA astate = &states[locvar1]; -#endif states[locvar1].action.acp1(actor); } @@ -10330,10 +9991,9 @@ void A_CusValAction(mobj_t *actor) void A_ForceStop(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ForceStop", actor)) return; -#endif actor->momx = actor->momy = 0; if (locvar1 == 0) @@ -10351,12 +10011,8 @@ void A_ForceWin(mobj_t *actor) { INT32 i; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ForceWin", actor)) return; -#else - (void)actor; -#endif for (i = 0; i < MAXPLAYERS; i++) { @@ -10384,10 +10040,9 @@ void A_ForceWin(mobj_t *actor) void A_SpikeRetract(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SpikeRetract", actor)) return; -#endif if (actor->flags & MF_NOBLOCKMAP) return; @@ -10469,10 +10124,9 @@ void A_Repeat(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Repeat", actor)) return; -#endif if ((!(actor->extravalue2)) || actor->extravalue2 > locvar1) actor->extravalue2 = locvar1; @@ -10495,10 +10149,9 @@ void A_SetScale(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *target; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetScale", actor)) return; -#endif if (locvar1 <= 0) { @@ -10541,10 +10194,10 @@ void A_RemoteDamage(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; // we MUST have a target mobj_t *source = NULL; // on the other hand we don't necessarily need a source -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RemoteDamage", actor)) return; -#endif + if (locvar1 == 1) target = actor->target; else if (locvar1 == 2) @@ -10594,10 +10247,9 @@ void A_HomingChase(mobj_t *actor) mobj_t *dest; fixed_t dist; fixed_t speedmul; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_HomingChase", actor)) return; -#endif if (locvar2 == 1) dest = actor->tracer; @@ -10643,10 +10295,9 @@ void A_TrapShot(mobj_t *actor) INT16 vertoff = (INT16)(locvar2 >> 16); fixed_t x, y, z; fixed_t speed; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_TrapShot", actor)) return; -#endif x = actor->x + P_ReturnThrustX(actor, actor->angle, FixedMul(frontoff*FRACUNIT, actor->scale)); y = actor->y + P_ReturnThrustY(actor, actor->angle, FixedMul(frontoff*FRACUNIT, actor->scale)); @@ -10698,10 +10349,8 @@ void A_VileTarget(mobj_t *actor) mobjtype_t fogtype; INT32 i; -#ifdef HAVE_BLUA if (LUA_CallAction("A_VileTarget", actor)) return; -#endif if (!actor->target) return; @@ -10787,10 +10436,8 @@ void A_VileAttack(mobj_t *actor) mobj_t *fire; INT32 i; -#ifdef HAVE_BLUA if (LUA_CallAction("A_VileAttack", actor)) return; -#endif if (!actor->target) return; @@ -10901,10 +10548,8 @@ void A_VileFire(mobj_t *actor) INT32 locvar2 = var2; mobj_t *dest; -#ifdef HAVE_BLUA if (LUA_CallAction("A_VileFire", actor)) return; -#endif dest = actor->tracer; if (!dest) @@ -10989,10 +10634,8 @@ void A_BrakChase(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BrakChase", actor)) return; -#endif // Set new tics NOW, in case the state changes while we're doing this and we try applying this to the painstate or something silly if (actor->tics > 1 && locvar1 < actor->tics) // Not much point, otherwise @@ -11111,10 +10754,9 @@ void A_BrakFireShot(mobj_t *actor) fixed_t x, y, z; INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BrakFireShot", actor)) return; -#endif + if (!actor->target) return; @@ -11175,10 +10817,8 @@ void A_BrakLobShot(mobj_t *actor) INT32 locvar2 = var2 & 0x0000FFFF; INT32 aimDirect = var2 & 0xFFFF0000; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BrakLobShot", actor)) return; -#endif if (!actor->target) return; // Don't even bother if we've got nothing to aim at. @@ -11283,10 +10923,8 @@ void A_NapalmScatter(mobj_t *actor) INT32 i; // for-loop cursor mobj_t *mo; // each and every spawned napalm burst -#ifdef HAVE_BLUA if (LUA_CallAction("A_NapalmScatter", actor)) return; -#endif // Some quick sanity-checking if (typeOfShot >= NUMMOBJTYPES) // I'd add a <0 check, too, but 0x0000FFFF isn't negative in this case @@ -11337,10 +10975,8 @@ void A_SpawnFreshCopy(mobj_t *actor) { mobj_t *newObject; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SpawnFreshCopy", actor)) return; -#endif newObject = P_SpawnMobj(actor->x, actor->y, actor->z, actor->type); newObject->angle = actor->angle; diff --git a/src/p_inter.c b/src/p_inter.c index 9e333ebe2..365c8e7b6 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -288,43 +288,12 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (special->flags & MF_BOSS && special->flags2 & MF2_FRET) return; -#ifdef HAVE_BLUA if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special)) return; -#endif if (special->flags & MF_BOSS) { - /*if (special->type == MT_BLACKEGGMAN) - { - P_DamageMobj(toucher, special, special, 1); // ouch - return; - } - - if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) - || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) - || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? - { - if (P_MobjFlip(toucher)*toucher->momz < 0) - toucher->momz = -toucher->momz; - toucher->momx = -toucher->momx; - toucher->momy = -toucher->momy; - P_DamageMobj(special, toucher, toucher, 1); - } - else if (((toucher->z < special->z && !(toucher->eflags & MFE_VERTICALFLIP)) - || (toucher->z + toucher->height > special->z + special->height && (toucher->eflags & MFE_VERTICALFLIP))) - && player->charability == CA_FLY - && (player->powers[pw_tailsfly] - || (toucher->state >= &states[S_PLAY_SPC1] && toucher->state <= &states[S_PLAY_SPC4]))) // Tails can shred stuff with his propeller. - { - toucher->momz = -toucher->momz/2; - - P_DamageMobj(special, toucher, toucher, 1); - } - // SRB2kart - Removed: No more fly states - else*/ - P_DamageMobj(toucher, special, special, 1); - + P_DamageMobj(toucher, special, special, 1); return; } else if ((special->flags & MF_ENEMY) && !(special->flags & MF_MISSILE) @@ -2163,10 +2132,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); target->health = 0; // This makes it easy to check if something's dead elsewhere. -#ifdef HAVE_BLUA if (LUAh_MobjDeath(target, inflictor, source) || P_MobjWasRemoved(target)) return; -#endif // SRB2kart // I wish I knew a better way to do this @@ -3129,11 +3096,7 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) { player_t *player; -#ifdef HAVE_BLUA boolean force = false; -#else - static const boolean force = false; -#endif if (objectplacing) return false; @@ -3153,19 +3116,19 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; } -#ifdef HAVE_BLUA // Everything above here can't be forced. if (!metalrecording) { UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage); if (P_MobjWasRemoved(target)) return (shouldForce == 1); // mobj was removed + if (P_MobjWasRemoved(source)) + source = NULL; if (shouldForce == 1) force = true; else if (shouldForce == 2) return false; } -#endif if (!force) { @@ -3199,10 +3162,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (!force && target->fuse) // Invincible return false; -#ifdef HAVE_BLUA if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target)) return true; -#endif if (target->health > 1) { @@ -3227,21 +3188,17 @@ 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 return false; -#ifdef HAVE_BLUA if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target)) return true; -#endif if (target->health > 1) target->flags2 |= MF2_FRET; } -#ifdef HAVE_BLUA else if (target->flags & MF_ENEMY) { if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target)) return true; } -#endif player = target->player; @@ -3267,18 +3224,16 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da || (G_GametypeHasTeams() && target->player->ctfteam == source->player->ctfteam))) 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)) return true; -#endif + P_NiGHTSDamage(target, source); // -5s :( return true; } -#ifdef HAVE_BLUA // Add this back here for ACTUAL NORMAL DAMAGE. The funny shit is that the player is barely ever "actually" damaged. if (LUAh_MobjDamage(target, inflictor, source, damage)) return true; -#endif if (!force && inflictor && (inflictor->flags & MF_FIRE)) { @@ -3341,72 +3296,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da } return true; } - /* // SRB2kart - don't need these - else if (metalrecording) - { - if (!inflictor) - inflictor = source; - if (inflictor && inflictor->flags & MF_ENEMY) - { // Metal Sonic destroy enemy !! - P_KillMobj(inflictor, NULL, target); - return false; - } - else if (inflictor && inflictor->flags & MF_MISSILE) - return false; // Metal Sonic walk through flame !! - else - { // Oh no! Metal Sonic is hit !! - P_ShieldDamage(player, inflictor, source, damage); - return true; - } - } - else if (player->powers[pw_invulnerability] || player->powers[pw_flashing] // ignore bouncing & such in invulnerability - || (player->powers[pw_super] && !(ALL7EMERALDS(player->powers[pw_emeralds]) && inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player)))) - { - if (force || (inflictor && (inflictor->flags & MF_MISSILE) - && (inflictor->flags2 & MF2_SUPERFIRE) - && player->powers[pw_super])) - { -#ifdef HAVE_BLUA - if (!LUAh_MobjDamage(target, inflictor, source, damage)) -#endif - P_SuperDamage(player, inflictor, source, damage); - return true; - } - else - return false; - } -#ifdef HAVE_BLUA - else if (LUAh_MobjDamage(target, inflictor, source, damage)) - return true; -#endif - else if (!player->powers[pw_super] && (player->powers[pw_shield] || player->bot)) //If One-Hit Shield - { - P_ShieldDamage(player, inflictor, source, damage); - damage = 0; - } - else if (player->mo->health > 1) // No shield but have rings. - { - damage = player->mo->health - 1; - P_RingDamage(player, inflictor, source, damage); - } - else // No shield, no rings, no invincibility. - { - // To reduce griefing potential, don't allow players to be killed - // by friendly fire. Spilling their rings and other items is enough. - if (force || !(G_GametypeHasTeams() - && source && source->player && (source->player->ctfteam == player->ctfteam) - && cv_friendlyfire.value)) - { - damage = 1; - P_KillPlayer(player, source, damage); - } - else - { - damage = 0; - P_ShieldDamage(player, inflictor, source, damage); - } - } - */ if (inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player) && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) { @@ -3485,6 +3374,9 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da P_SetMobjState(target, target->info->painstate); break; } + + if (P_MobjWasRemoved(target)) + return false; if (!P_MobjWasRemoved(target)) { diff --git a/src/p_local.h b/src/p_local.h index df8df412e..e93d4b411 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -306,9 +306,6 @@ void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration); // P_ENEMY // -// main player in game -extern player_t *stplyr; // for splitscreen correct palette changes and overlay - // Is there a better place for these? extern INT32 var1; extern INT32 var2; diff --git a/src/p_map.c b/src/p_map.c index abca82eb0..6051d5d1c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -248,26 +248,6 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) //pflags = object->player->pflags & (PF_JUMPED|PF_SPINNING|PF_THOKKED); // I still need these. P_ResetPlayer(object->player); - - /* // SRB2kart - Springs don't need to change player state in kart. - if (P_MobjFlip(object)*vertispeed > 0) - P_SetPlayerMobjState(object, S_PLAY_SPRING); - else if (P_MobjFlip(object)*vertispeed < 0) - P_SetPlayerMobjState(object, S_PLAY_FALL1); - else // horizontal spring - { - if (pflags & (PF_JUMPED|PF_SPINNING) && object->player->panim == PA_ROLL) - object->player->pflags = pflags; - else - P_SetPlayerMobjState(object, S_PLAY_RUN1); - } - - if (spring->info->painchance) - { - object->player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(object, S_PLAY_ATK1); - } - */ } return true; } @@ -314,14 +294,6 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) if (flipval*object->momz > FixedMul(speed, spring->scale)) object->momz = flipval*FixedMul(speed, spring->scale); - /* // SRB2kart - don't need state change - if (p && !p->powers[pw_tailsfly]) // doesn't reset anim for Tails' flight - { - P_ResetPlayer(p); - if (p->panim != PA_FALL) - P_SetPlayerMobjState(object, S_PLAY_FALL1); - } - */ break; case MT_STEAM: // Steam if (zdist > FixedMul(16*FRACUNIT, spring->scale)) @@ -341,14 +313,6 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) else object->momz = flipval*FixedMul(speed, FixedSqrt(FixedMul(spring->scale, object->scale))); // scale the speed with both objects' scales, just like with springs! - /* // SRB2kart - don't need state change - if (p) - { - P_ResetPlayer(p); - if (p->panim != PA_FALL) - P_SetPlayerMobjState(object, S_PLAY_FALL1); - } - */ break; default: break; @@ -365,10 +329,6 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails) return; if ((sonic->pflags & PF_CARRIED) && sonic->mo->tracer == tails->mo) return; - - //if (!tails->powers[pw_tailsfly] && !(tails->charability == CA_FLY && (tails->mo->state >= &states[S_PLAY_SPC1] && tails->mo->state <= &states[S_PLAY_SPC4]))) - // return; // SRB2kart - no changey statey - if (tails->bot == 1) return; @@ -407,13 +367,6 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails) { // Why block opposing teams from tailsflying each other? // Sneaking into the hands of a flying tails player in Race might be a viable strategy, who knows. - /* - if (gametype == GT_RACE || gametype == GT_COMPETITION - || (netgame && (tails->spectator || sonic->spectator)) - || (G_TagGametype() && (!(tails->pflags & PF_TAGIT) != !(sonic->pflags & PF_TAGIT))) - || (gametype == GT_MATCH) - || (G_GametypeHasTeams() && tails->ctfteam != sonic->ctfteam)) - sonic->pflags &= ~PF_CARRIED; */ if (tails->spectator || sonic->spectator || G_RaceGametype()) // SRB2kart sonic->pflags &= ~PF_CARRIED; else @@ -487,35 +440,6 @@ static boolean PIT_CheckThing(mobj_t *thing) } #endif - // Metal Sonic destroys tiny baby objects. - /*if (tmthing->type == MT_METALSONIC_RACE - && (thing->flags & (MF_MISSILE|MF_ENEMY|MF_BOSS) || thing->type == MT_SPIKE)) - { - if ((thing->flags & (MF_ENEMY|MF_BOSS)) && (thing->health <= 0 || !(thing->flags & MF_SHOOTABLE))) - return true; - blockdist = thing->radius + tmthing->radius; - if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) - return true; // didn't hit it - // see if it went over / under - if (tmthing->z > thing->z + thing->height) - return true; // overhead - if (tmthing->z + tmthing->height < thing->z) - return true; // underneath - if (thing->type == MT_SPIKE) - { - S_StartSound(tmthing, thing->info->deathsound); - for (thing = thing->subsector->sector->thinglist; thing; thing = thing->snext) - if (thing->type == MT_SPIKE && thing->health > 0 && thing->flags & MF_SOLID && P_AproxDistance(thing->x - tmthing->x, thing->y - tmthing->y) < FixedMul(56*FRACUNIT, thing->scale)) - P_KillMobj(thing, tmthing, tmthing); - } - else - { - thing->health = 0; - P_KillMobj(thing, tmthing, tmthing); - } - return true; - }*/ - if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE)) || (thing->flags & MF_NOCLIPTHING)) return true; @@ -596,7 +520,6 @@ static boolean PIT_CheckThing(mobj_t *thing) 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 if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) @@ -615,7 +538,6 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (shouldCollide == 2) return true; // force no collide } -#endif // When solid spikes move, assume they just popped up and teleport things on top of them to hurt. if (tmthing->type == MT_SPIKE && tmthing->flags & MF_SOLID) @@ -1209,21 +1131,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if ((tmthing->type == MT_THROWNBOUNCE && tmthing->fuse > 8*TICRATE) && thing->flags & MF_SOLID) return true; - // Missiles ignore Brak's helper. - /*if (thing->type == MT_BLACKEGGMAN_HELPER) - return true; - - // Hurting Brak - if (tmthing->type == MT_BLACKEGGMAN_MISSILE - && thing->type == MT_BLACKEGGMAN && tmthing->target != thing) - { - // Not if Brak's already in pain - if (!(thing->state >= &states[S_BLACKEGG_PAIN1] && thing->state <= &states[S_BLACKEGG_PAIN35])) - P_SetMobjState(thing, thing->info->painstate); - return false; - }*/ - - if (!(thing->flags & MF_SHOOTABLE)/* && !(thing->type == MT_EGGSHIELD)*/) + if (!(thing->flags & MF_SHOOTABLE)) { // didn't do any damage return !(thing->flags & MF_SOLID); @@ -1234,80 +1142,11 @@ static boolean PIT_CheckThing(mobj_t *thing) && thing->player->pflags & PF_CARRIED && thing->tracer == tmthing->target) return true; // Don't give rings to your carry player by accident. - /*if (thing->type == MT_EGGSHIELD) - { - fixed_t touchx, touchy; - angle_t angle; - - if (P_AproxDistance(tmthing->x-thing->x, tmthing->y-thing->y) > - P_AproxDistance((tmthing->x-tmthing->momx)-thing->x, (tmthing->y-tmthing->momy)-thing->y)) - { - touchx = tmthing->x + tmthing->momx; - touchy = tmthing->y + tmthing->momy; - } - else - { - touchx = tmthing->x; - touchy = tmthing->y; - } - - angle = R_PointToAngle2(thing->x, thing->y, touchx, touchy) - thing->angle; - - if (!(angle > ANGLE_90 && angle < ANGLE_270)) // hit front of shield, didn't destroy it - return false; - else // hit shield from behind, shield is destroyed! - { - P_KillMobj(thing, tmthing, tmthing); - return false; - } - }*/ - if (tmthing->type == MT_SHELL && tmthing->threshold > TICRATE) return true; // damage / explode if (tmthing->flags & MF_ENEMY) // An actual ENEMY! (Like the deton, for example) P_DamageMobj(thing, tmthing, tmthing, 1); - /*else if (tmthing->type == MT_BLACKEGGMAN_MISSILE && thing->player - && (thing->player->pflags & PF_JUMPED) - && !thing->player->powers[pw_flashing] - && thing->tracer != tmthing - && tmthing->target != thing) - { - // Hop on the missile for a ride! - thing->player->pflags |= PF_ITEMHANG; - thing->player->pflags &= ~PF_JUMPED; - P_SetTarget(&thing->tracer, tmthing); - P_SetTarget(&tmthing->target, thing); // Set owner to the player - P_SetTarget(&tmthing->tracer, NULL); // Disable homing-ness - tmthing->momz = 0; - - thing->angle = tmthing->angle; - - if (!demo.playback || P_AnalogMove(thing->player)) - { - if (thing->player == &players[consoleplayer]) - localangle[0] = thing->angle; - else if (thing->player == &players[displayplayers[1]]) - localangle[1] = thing->angle; - else if (thing->player == &players[displayplayers[2]]) - localangle[2] = thing->angle; - else if (thing->player == &players[displayplayers[3]]) - localangle[3] = thing->angle; - } - - return true; - } - else if (tmthing->type == MT_BLACKEGGMAN_MISSILE && thing->player && ((thing->player->pflags & PF_ITEMHANG) || (thing->player->pflags & PF_JUMPED))) - { - // Ignore - } - else if (tmthing->type == MT_BLACKEGGMAN_GOOPFIRE) - { - P_UnsetThingPosition(tmthing); - tmthing->x = thing->x; - tmthing->y = thing->y; - P_SetThingPosition(tmthing); - }*/ else P_DamageMobj(thing, tmthing, tmthing->target, 1); @@ -1376,29 +1215,6 @@ static boolean PIT_CheckThing(mobj_t *thing) P_SetTarget(&thing->target, tmthing); } - // Respawn rings and items - /*if ((tmthing->type == MT_NIGHTSDRONE || thing->type == MT_NIGHTSDRONE) - && (tmthing->player || thing->player)) - { - mobj_t *droneobj = (tmthing->type == MT_NIGHTSDRONE) ? tmthing : thing; - player_t *pl = (droneobj == thing) ? tmthing->player : thing->player; - - // Must be in bonus time, and must be NiGHTS, must wait about a second - // must be flying in the SAME DIRECTION as the last time you came through. - // not (your direction) xor (stored direction) - // In other words, you can't u-turn and respawn rings near the drone. - if (pl->bonustime && (pl->pflags & PF_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && ( - !(pl->flyangle > 90 && pl->flyangle < 270) - ^ (droneobj->extravalue1 > 90 && droneobj->extravalue1 < 270) - )) - { - // Reload all the fancy ring stuff! - P_ReloadRings(); - } - droneobj->extravalue1 = pl->flyangle; - droneobj->extravalue2 = (INT32)leveltime + TICRATE; - }*/ - // check for special pickup if (thing->flags & MF_SPECIAL && tmthing->player) { @@ -1471,71 +1287,10 @@ static boolean PIT_CheckThing(mobj_t *thing) P_DamageMobj(thing, tmthing, tmthing, 1); else if (thing->player->kartstuff[k_invincibilitytimer] && !tmthing->player->kartstuff[k_invincibilitytimer]) P_DamageMobj(tmthing, thing, thing, 1); - - /*if (G_BattleGametype() && (!G_GametypeHasTeams() || tmthing->player->ctfteam != thing->player->ctfteam)) - { - if ((tmthing->player->powers[pw_invulnerability] || tmthing->player->powers[pw_super]) - && !thing->player->powers[pw_super]) - P_DamageMobj(thing, tmthing, tmthing, 1); - else if ((thing->player->powers[pw_invulnerability] || thing->player->powers[pw_super]) - && !tmthing->player->powers[pw_super]) - P_DamageMobj(tmthing, thing, thing, 1); - } - - // If players are using touch tag, seekers damage hiders. - if (G_TagGametype() && cv_touchtag.value && - ((thing->player->pflags & PF_TAGIT) != (tmthing->player->pflags & PF_TAGIT))) - { - if ((tmthing->player->pflags & PF_TAGIT) && !(thing->player->pflags & PF_TAGIT)) - P_DamageMobj(thing, tmthing, tmthing, 1); - else if ((thing->player->pflags & PF_TAGIT) && !(tmthing->player->pflags & PF_TAGIT)) - P_DamageMobj(tmthing, thing, tmthing, 1); - }*/ } - // Force solid players in hide and seek to avoid corner stacking. - // Kart: No Tailspickup ever, players are always solid - /*if (cv_tailspickup.value && gametype != GT_HIDEANDSEEK) - { - if (tmthing->player && thing->player) - { - P_DoTailsCarry(thing->player, tmthing->player); - return true; - } - } - else if (thing->player) { - if (thing->player-players == consoleplayer && botingame) - //CV_SetValue(&cv_analog2, true); - thing->player->pflags &= ~PF_CARRIED; - }*/ - if (thing->player) { - // Doesn't matter what gravity player's following! Just do your stuff in YOUR direction only - /*if (tmthing->eflags & MFE_VERTICALFLIP - && (tmthing->z + tmthing->height + tmthing->momz < thing->z - || tmthing->z + tmthing->height + tmthing->momz >= thing->z + thing->height)) - ; - else if (!(tmthing->eflags & MFE_VERTICALFLIP) - && (tmthing->z + tmthing->momz > thing->z + thing->height - || tmthing->z + tmthing->momz <= thing->z)) - ; - else if (P_IsObjectOnGround(thing) - && !P_IsObjectOnGround(tmthing) // Don't crush if the monitor is on the ground... - && (tmthing->flags & MF_SOLID)) - { - if (tmthing->flags & (MF_MONITOR|MF_PUSHABLE)) - { - // Objects kill you if it falls from above. - if (thing != tmthing->target) - P_DamageMobj(thing, tmthing, tmthing->target, 10000); - - tmthing->momz = -tmthing->momz/2; // Bounce, just for fun! - // The tmthing->target allows the pusher of the object - // to get the point if he topples it on an opponent. - } - }*/ - if (tmthing->type == MT_FAN || tmthing->type == MT_STEAM) P_DoFanAndGasJet(tmthing, thing); } @@ -1757,9 +1512,7 @@ static boolean PIT_CheckThing(mobj_t *thing) ; // Fix a few nasty spring-jumping bugs that happen sometimes. // Monitors are not treated as solid to players who are jumping, spinning or gliding, // unless it's a CTF team monitor and you're on the wrong team - /*else if (thing->flags & MF_MONITOR && tmthing->player && tmthing->player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING) - && !((thing->type == MT_REDRINGBOX && tmthing->player->ctfteam != 1) || (thing->type == MT_BLUERINGBOX && tmthing->player->ctfteam != 2))) - ;*/ + // z checking at last // Treat noclip things as non-solid! else if ((thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID @@ -3931,13 +3684,6 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) topheight = *rover->topheight; bottomheight = *rover->bottomheight; -/*#ifdef ESLOPE - if (rover->t_slope) - topheight = P_GetZAt(rover->t_slope, thing->x, thing->y); - if (rover->b_slope) - bottomheight = P_GetZAt(rover->b_slope, thing->x, thing->y); -#endif*/ - delta1 = thing->z - (bottomheight + topheight)/2; delta2 = thingtop - (bottomheight + topheight)/2; if (bottomheight <= thing->ceilingz && abs(delta1) >= abs(delta2)) diff --git a/src/p_maputl.c b/src/p_maputl.c index 17df33a91..9eb80f2fc 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -136,33 +136,21 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte // INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line) { - const vertex_t *v1 = line->v1; fixed_t dx, dy, left, right; if (!line->dx) - { - if (x <= v1->x) - return (line->dy > 0); + return x <= line->v1->x ? line->dy > 0 : line->dy < 0; - return (line->dy < 0); - } if (!line->dy) - { - if (y <= v1->y) - return (line->dx < 0); + return y <= line->v1->y ? line->dx < 0 : line->dx > 0; - return (line->dx > 0); - } - - dx = (x - v1->x); - dy = (y - v1->y); + dx = (x - line->v1->x); + dy = (y - line->v1->y); left = FixedMul(line->dy>>FRACBITS, dx); right = FixedMul(dy, line->dx>>FRACBITS); - if (right < left) - return 0; // front side - return 1; // back side + return right < left ? 0 : 1; } // @@ -225,39 +213,25 @@ static INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line) fixed_t dx, dy, left, right; if (!line->dx) - { - if (x <= line->x) - return line->dy > 0; + return x <= line->x ? line->dy > 0 : line->dy < 0; - return line->dy < 0; - } if (!line->dy) - { - if (y <= line->y) - return line->dx < 0; - - return line->dx > 0; - } + return y <= line->y ? line->dx < 0 : line->dx > 0; dx = (x - line->x); dy = (y - line->y); // try to quickly decide by looking at sign bits if ((line->dy ^ line->dx ^ dx ^ dy) & 0x80000000) - { - if ((line->dy ^ dx) & 0x80000000) - return 1; // left is negative - return 0; - } + return ((line->dy ^ dx) & 0x80000000) ? 1 : 0; left = FixedMul(line->dy>>8, dx>>8); right = FixedMul(dy>>8, line->dx>>8); - if (right < left) - return 0; // front side - return 1; // back side + return right < left ? 0 : 1; } + // // P_MakeDivline // @@ -546,22 +520,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) texheight = textures[texnum]->height << FRACBITS; // Set texbottom and textop to the Z coordinates of the texture's boundaries -#if 0 // #ifdef POLYOBJECTS - // don't remove this code unless solid midtextures - // on non-solid polyobjects should NEVER happen in the future - if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = back->floorheight + side->rowoffset; - textop = back->ceilingheight + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = back->floorheight + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = back->ceilingheight + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } - } else -#endif { if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat texbottom = openbottom + side->rowoffset; diff --git a/src/p_mobj.c b/src/p_mobj.c index 5ad802f92..cbc08c02c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -63,9 +63,8 @@ void P_RunCachedActions(void) { var1 = states[ac->statenum].var1; var2 = states[ac->statenum].var2; -#ifdef HAVE_BLUA astate = &states[ac->statenum]; -#endif + if (ac->mobj && !P_MobjWasRemoved(ac->mobj)) // just in case... states[ac->statenum].action.acp1(ac->mobj); next = ac->next; @@ -183,12 +182,6 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) player->panim = PA_WALK; else if (state >= S_KART_RUN1 && state <= S_KART_DRIFT2_R) player->panim = PA_RUN; - //else if (state >= S_PLAY_ATK1 && state <= S_PLAY_ATK4) - // player->panim = PA_ROLL; - //else if (state >= S_PLAY_FALL1 && state <= S_PLAY_FALL2) - // player->panim = PA_FALL; - //else if (state >= S_PLAY_ABL1 && state <= S_PLAY_ABL2) - // player->panim = PA_ABILITY; else player->panim = PA_ETC; @@ -220,9 +213,8 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif + st->action.acp1(mobj); // woah. a player was removed by an action. @@ -263,6 +255,9 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) I_Error("P_SetMobjState used for player mobj. Use P_SetPlayerMobjState instead!\n(State called: %d)", state); #endif + if (mobj->player != NULL) + return P_SetPlayerMobjState(mobj, state); + if (recursion++) // if recursion detected, memset(seenstate = tempstate, 0, sizeof tempstate); // clear state table @@ -288,9 +283,8 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif + st->action.acp1(mobj); if (P_MobjWasRemoved(mobj)) return false; @@ -394,182 +388,6 @@ boolean P_WeaponOrPanel(mobjtype_t type) return false; } -// -// P_EmeraldManager -// -// Power Stone emerald management -// -/*void P_EmeraldManager(void) -{ - thinker_t *think; - mobj_t *mo; - INT32 i,j; - INT32 numtospawn; - INT32 emeraldsspawned = 0; - - boolean hasemerald[MAXHUNTEMERALDS]; - INT32 numwithemerald = 0; - - // record empty spawn points - mobj_t *spawnpoints[MAXHUNTEMERALDS]; - INT32 numspawnpoints = 0; - - for (i = 0; i < MAXHUNTEMERALDS; i++) - { - hasemerald[i] = false; - spawnpoints[i] = NULL; - } - - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (mo->type == MT_EMERALDSPAWN) - { - if (mo->threshold || mo->target) // Either has the emerald spawned or is spawning - { - numwithemerald++; - emeraldsspawned |= mobjinfo[mo->reactiontime].speed; - } - else if (numspawnpoints < MAXHUNTEMERALDS) - spawnpoints[numspawnpoints++] = mo; // empty spawn points - } - else if (mo->type == MT_FLINGEMERALD) - { - numwithemerald++; - emeraldsspawned |= mo->threshold; - } - } - - if (numspawnpoints == 0) - return; - - // But wait! We need to check all the players too, to see if anyone has some of the emeralds. - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - if (!players[i].mo) - continue; - - if (players[i].powers[pw_emeralds] & EMERALD1) - { - numwithemerald++; - emeraldsspawned |= EMERALD1; - } - if (players[i].powers[pw_emeralds] & EMERALD2) - { - numwithemerald++; - emeraldsspawned |= EMERALD2; - } - if (players[i].powers[pw_emeralds] & EMERALD3) - { - numwithemerald++; - emeraldsspawned |= EMERALD3; - } - if (players[i].powers[pw_emeralds] & EMERALD4) - { - numwithemerald++; - emeraldsspawned |= EMERALD4; - } - if (players[i].powers[pw_emeralds] & EMERALD5) - { - numwithemerald++; - emeraldsspawned |= EMERALD5; - } - if (players[i].powers[pw_emeralds] & EMERALD6) - { - numwithemerald++; - emeraldsspawned |= EMERALD6; - } - if (players[i].powers[pw_emeralds] & EMERALD7) - { - numwithemerald++; - emeraldsspawned |= EMERALD7; - } - } - - // All emeralds spawned, no worries - if (numwithemerald >= 7) - return; - - // Set up spawning for the emeralds - numtospawn = 7 - numwithemerald; - -#ifdef PARANOIA - if (numtospawn <= 0) // ??? - I_Error("P_EmeraldManager: numtospawn is %d!\n", numtospawn); -#endif - - for (i = 0, j = 0; i < numtospawn; i++) - { - INT32 tries = 0; - while (true) - { - tries++; - - if (tries > 50) - break; - - j = P_RandomKey(numspawnpoints); - - if (hasemerald[j]) - continue; - - hasemerald[j] = true; - - if (!(emeraldsspawned & EMERALD1)) - { - spawnpoints[j]->reactiontime = MT_EMERALD1; - emeraldsspawned |= EMERALD1; - } - else if (!(emeraldsspawned & EMERALD2)) - { - spawnpoints[j]->reactiontime = MT_EMERALD2; - emeraldsspawned |= EMERALD2; - } - else if (!(emeraldsspawned & EMERALD3)) - { - spawnpoints[j]->reactiontime = MT_EMERALD3; - emeraldsspawned |= EMERALD3; - } - else if (!(emeraldsspawned & EMERALD4)) - { - spawnpoints[j]->reactiontime = MT_EMERALD4; - emeraldsspawned |= EMERALD4; - } - else if (!(emeraldsspawned & EMERALD5)) - { - spawnpoints[j]->reactiontime = MT_EMERALD5; - emeraldsspawned |= EMERALD5; - } - else if (!(emeraldsspawned & EMERALD6)) - { - spawnpoints[j]->reactiontime = MT_EMERALD6; - emeraldsspawned |= EMERALD6; - } - else if (!(emeraldsspawned & EMERALD7)) - { - spawnpoints[j]->reactiontime = MT_EMERALD7; - emeraldsspawned |= EMERALD7; - } - else - break; - - if (leveltime < TICRATE) // Start of map - spawnpoints[j]->threshold = 60*TICRATE + P_RandomByte() * (TICRATE/5); - else - spawnpoints[j]->threshold = P_RandomByte() * (TICRATE/5); - - break; - } - } -}*/ - // // P_ExplodeMissile // @@ -590,29 +408,41 @@ void P_ExplodeMissile(mobj_t *mo) P_RadiusAttack(mo, mo, 96*FRACUNIT); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - P_SetScale(explodemo, mo->scale); - explodemo->destscale = mo->destscale; - explodemo->momx += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale); - explodemo->momy += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale); - S_StartSound(explodemo, sfx_pop); + if (!P_MobjWasRemoved(explodemo)) + { + P_SetScale(explodemo, mo->scale); + explodemo->destscale = mo->destscale; + explodemo->momx += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale); + explodemo->momy += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale); + S_StartSound(explodemo, sfx_pop); + } explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - P_SetScale(explodemo, mo->scale); - explodemo->destscale = mo->destscale; - explodemo->momx += (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale); - explodemo->momy -= (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale); - S_StartSound(explodemo, sfx_dmpain); + if (!P_MobjWasRemoved(explodemo)) + { + P_SetScale(explodemo, mo->scale); + explodemo->destscale = mo->destscale; + explodemo->momx += (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale); + explodemo->momy -= (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale); + S_StartSound(explodemo, sfx_dmpain); + } explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - P_SetScale(explodemo, mo->scale); - explodemo->destscale = mo->destscale; - explodemo->momx -= (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale); - explodemo->momy += (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale); - S_StartSound(explodemo, sfx_pop); + if (!P_MobjWasRemoved(explodemo)) + { + P_SetScale(explodemo, mo->scale); + explodemo->destscale = mo->destscale; + explodemo->momx -= (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale); + explodemo->momy += (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale); + S_StartSound(explodemo, sfx_pop); + } explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - P_SetScale(explodemo, mo->scale); - explodemo->destscale = mo->destscale; - explodemo->momx -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); - explodemo->momy -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); - S_StartSound(explodemo, sfx_cybdth); + if (!P_MobjWasRemoved(explodemo)) + { + P_SetScale(explodemo, mo->scale); + explodemo->destscale = mo->destscale; + explodemo->momx -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); + explodemo->momy -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); + S_StartSound(explodemo, sfx_cybdth); + } // Hack: Release an animal. P_DamageMobj(mo, NULL, NULL, 10000); @@ -642,13 +472,8 @@ boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover) || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) return false; - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y); - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, mobj->x, mobj->y); + topheight = P_GetFFloorTopZAt (rover, mobj->x, mobj->y); + bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); if (mobj->z > topheight) return false; @@ -920,6 +745,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix { I_Assert(mobj != NULL); I_Assert(sector != NULL); + if (sector->f_slope) { fixed_t testx, testy; pslope_t *slope = sector->f_slope; @@ -996,6 +822,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f { I_Assert(mobj != NULL); I_Assert(sector != NULL); + if (sector->c_slope) { fixed_t testx, testy; pslope_t *slope = sector->c_slope; @@ -3107,25 +2934,8 @@ void P_MobjCheckWater(mobj_t *mobj) P_FlashPal(p, PAL_WHITE, 1); } } - - // Drown timer setting - /* // SRB2kart - Can't drown. - if ((p->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL // Has elemental - || (p->exiting) // Or exiting - || (maptol & TOL_NIGHTS) // Or in NiGHTS mode - || (mariomode)) // Or in Mario mode... - */ - { - // Can't drown. - p->powers[pw_underwater] = 0; - } - /* - else if (p->powers[pw_underwater] <= 0) // No underwater timer set - { - // Then we'll set it! - p->powers[pw_underwater] = underwatertics + 1; - } - */ + // Can't drown. + p->powers[pw_underwater] = 0; } // The rest of this code only executes on a water state change. @@ -3351,11 +3161,9 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) if (!(rover->flags & FF_EXISTS)) continue; - if (halfheight >= ( - *rover->t_slope ? P_GetZAt(*rover->t_slope, thiscam->x, thiscam->y) : - *rover->topheight) || halfheight <= ( - *rover->b_slope ? P_GetZAt(*rover->b_slope, thiscam->x, thiscam->y) : - *rover->bottomheight)) + if (halfheight >= P_GetFFloorTopZAt(rover, thiscam->x, thiscam->y)) + continue; + if (halfheight <= P_GetFFloorBottomZAt(rover, thiscam->x, thiscam->y)) continue; if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) @@ -3383,11 +3191,9 @@ static boolean P_CameraCheckWater(camera_t *thiscam) if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKOTHERS) continue; - if (halfheight >= ( - *rover->t_slope ? P_GetZAt(*rover->t_slope, thiscam->x, thiscam->y) : - *rover->topheight) || halfheight <= ( - *rover->b_slope ? P_GetZAt(*rover->b_slope, thiscam->x, thiscam->y) : - *rover->bottomheight)) + if (halfheight >= P_GetFFloorTopZAt(rover, thiscam->x, thiscam->y)) + continue; + if (halfheight <= P_GetFFloorBottomZAt(rover, thiscam->x, thiscam->y)) continue; return true; @@ -3583,6 +3389,9 @@ static void P_PlayerMobjThinker(mobj_t *mobj) I_Assert(mobj != NULL); I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); + + if (P_MobjWasRemoved(mobj)) + return; P_MobjCheckWater(mobj); @@ -3742,9 +3551,7 @@ static void CalculatePrecipFloor(precipmobj_t *mobj) mobjsecsubsec = mobj->subsector->sector; else return; - mobj->floorz = - mobjsecsubsec->f_slope ? P_GetZAt(mobjsecsubsec->f_slope, mobj->x, mobj->y) : - mobjsecsubsec->floorheight; + mobj->floorz = P_GetSectorFloorZAt(mobjsecsubsec, mobj->x, mobj->y); if (mobjsecsubsec->ffloors) { ffloor_t *rover; @@ -3759,10 +3566,7 @@ static void CalculatePrecipFloor(precipmobj_t *mobj) if (!(rover->flags & FF_BLOCKOTHERS) && !(rover->flags & FF_SWIMMABLE)) continue; - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y); - else - topheight = *rover->topheight; + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y);; if (topheight > mobj->floorz) mobj->floorz = topheight; @@ -5850,124 +5654,6 @@ static void P_NightsItemChase(mobj_t *thing) P_Attract(thing, thing->tracer, true); } -/*static boolean P_ShieldLook(mobj_t *thing, shieldtype_t shield) -{ - if (!thing->target || thing->target->health <= 0 || !thing->target->player - || (thing->target->player->powers[pw_shield] & SH_NOSTACK) == SH_NONE || thing->target->player->powers[pw_super] - || thing->target->player->powers[pw_invulnerability] > 1) - { - P_RemoveMobj(thing); - return false; - } - - // TODO: Make an MT_SHIELDORB which changes color/states to always match the appropriate shield, - // instead of having completely seperate mobjtypes. - if (shield != SH_FORCE) - { // Regular shields check for themselves only - if ((shieldtype_t)(thing->target->player->powers[pw_shield] & SH_NOSTACK) != shield) - { - P_RemoveMobj(thing); - return false; - } - } - else if (!(thing->target->player->powers[pw_shield] & SH_FORCE)) - { // Force shields check for any force shield - P_RemoveMobj(thing); - return false; - } - - if (shield == SH_FORCE && thing->movecount != (thing->target->player->powers[pw_shield] & 0xFF)) - { - thing->movecount = (thing->target->player->powers[pw_shield] & 0xFF); - if (thing->movecount < 1) - { - if (thing->info->painstate) - P_SetMobjState(thing,thing->info->painstate); - else - thing->flags2 |= MF2_SHADOW; - } - else - { - if (thing->info->painstate) - P_SetMobjState(thing,thing->info->spawnstate); - else - thing->flags2 &= ~MF2_SHADOW; - } - } - - thing->flags |= MF_NOCLIPHEIGHT; - thing->eflags = (thing->eflags & ~MFE_VERTICALFLIP)|(thing->target->eflags & MFE_VERTICALFLIP); - - P_SetScale(thing, thing->target->scale); - P_UnsetThingPosition(thing); - thing->x = thing->target->x; - thing->y = thing->target->y; - if (thing->eflags & MFE_VERTICALFLIP) - thing->z = thing->target->z + thing->target->height - thing->height + FixedDiv(P_GetPlayerHeight(thing->target->player) - thing->target->height, 3*FRACUNIT) - FixedMul(2*FRACUNIT, thing->target->scale); - else - thing->z = thing->target->z - FixedDiv(P_GetPlayerHeight(thing->target->player) - thing->target->height, 3*FRACUNIT) + FixedMul(2*FRACUNIT, thing->target->scale); - P_SetThingPosition(thing); - P_CheckPosition(thing, thing->x, thing->y); - - if (P_MobjWasRemoved(thing)) - return false; - -// if (thing->z < thing->floorz) -// thing->z = thing->floorz; - - return true; -} - -mobj_t *shields[MAXPLAYERS*2]; -INT32 numshields = 0; - -void P_RunShields(void) -{ - INT32 i; - - // run shields - for (i = 0; i < numshields; i++) - { - P_ShieldLook(shields[i], shields[i]->info->speed); - P_SetTarget(&shields[i], NULL); - } - numshields = 0; -} - -static boolean P_AddShield(mobj_t *thing) -{ - shieldtype_t shield = thing->info->speed; - - if (!thing->target || thing->target->health <= 0 || !thing->target->player - || (thing->target->player->powers[pw_shield] & SH_NOSTACK) == SH_NONE || thing->target->player->powers[pw_super] - || thing->target->player->powers[pw_invulnerability] > 1) - { - P_RemoveMobj(thing); - return false; - } - - if (shield != SH_FORCE) - { // Regular shields check for themselves only - if ((shieldtype_t)(thing->target->player->powers[pw_shield] & SH_NOSTACK) != shield) - { - P_RemoveMobj(thing); - return false; - } - } - else if (!(thing->target->player->powers[pw_shield] & SH_FORCE)) - { // Force shields check for any force shield - P_RemoveMobj(thing); - return false; - } - - // Queue has been hit... why?!? - if (numshields >= MAXPLAYERS*2) - return P_ShieldLook(thing, thing->info->speed); - - P_SetTarget(&shields[numshields++], thing); - return true; -}*/ - void P_RunOverlays(void) { // run overlays @@ -5984,6 +5670,7 @@ void P_RunOverlays(void) if (!mo->target) continue; + if (!splitscreen /*&& rendermode != render_soft*/) { angle_t viewingangle; @@ -6259,6 +5946,9 @@ static void P_KoopaThinker(mobj_t *koopa) void P_RollPitchMobj(mobj_t* mobj) { boolean usedist = false; + + if (P_MobjWasRemoved(mobj)) + return; if (cv_sloperolldist.value > 0) usedist = true; @@ -6414,12 +6104,12 @@ void P_MobjThinker(mobj_t *mobj) // Special thinker for scenery objects if (mobj->flags & MF_SCENERY) { -#ifdef HAVE_BLUA if (LUAh_MobjThinker(mobj)) return; + if (P_MobjWasRemoved(mobj)) return; -#endif + switch (mobj->type) { case MT_HOOP: @@ -6496,15 +6186,6 @@ void P_MobjThinker(mobj_t *mobj) } P_AddShadow(mobj); break; - /*case MT_BLACKORB: - case MT_WHITEORB: - case MT_GREENORB: - case MT_YELLOWORB: - case MT_BLUEORB: - case MT_PITYORB: - if (!P_AddShield(mobj)) - return; - break;*/ //{ SRB2kart mobs case MT_ORBINAUT_SHIELD: // Kart orbit/trail items case MT_JAWZ_SHIELD: @@ -7120,10 +6801,8 @@ void P_MobjThinker(mobj_t *mobj) mobj->fuse--; if (!mobj->fuse) { -#ifdef HAVE_BLUA if (!LUAh_MobjFuse(mobj)) -#endif - P_RemoveMobj(mobj); + P_RemoveMobj(mobj); return; } } @@ -7134,7 +6813,6 @@ void P_MobjThinker(mobj_t *mobj) return; } -#ifdef HAVE_BLUA // Check for a Lua thinker first if (!mobj->player) { @@ -7148,11 +6826,14 @@ void P_MobjThinker(mobj_t *mobj) if (P_MobjWasRemoved(mobj)) return; } -#endif + // if it's pushable, or if it would be pushable other than temporary disablement, use the // separate thinker if (mobj->flags & MF_PUSHABLE || (mobj->info->flags & MF_PUSHABLE && mobj->fuse)) { + if (P_MobjWasRemoved(mobj)) + return; + P_MobjCheckWater(mobj); P_PushableThinker(mobj); @@ -7166,7 +6847,6 @@ void P_MobjThinker(mobj_t *mobj) } else if (mobj->flags & MF_BOSS) { -#ifdef HAVE_BLUA if (LUAh_BossThinker(mobj)) { if (P_MobjWasRemoved(mobj)) @@ -7175,23 +6855,13 @@ void P_MobjThinker(mobj_t *mobj) else if (P_MobjWasRemoved(mobj)) return; else -#endif switch (mobj->type) { case MT_EGGMOBILE: if (mobj->health < mobj->info->damage+1 && leveltime & 1 && mobj->health > 0) P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMOKE); if (mobj->flags2 & MF2_SKULLFLY) -#if 1 P_SpawnGhostMobj(mobj); -#else - { - mobj_t *spawnmobj; - spawnmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->info->painchance); - P_SetTarget(&spawnmobj->target, mobj); - spawnmobj->color = SKINCOLOR_GREY; - } -#endif P_Boss1Thinker(mobj); break; case MT_EGGMOBILE2: @@ -7473,11 +7143,6 @@ void P_MobjThinker(mobj_t *mobj) { if (mobj->lastlook > mobj->movecount) mobj->lastlook--; -/* - if (mobj->threshold > mobj->movefactor) - mobj->threshold -= FRACUNIT; - else if (mobj->threshold < mobj->movefactor) - mobj->threshold += FRACUNIT;*/ } break; case MT_EGGCAPSULE: @@ -9141,9 +8806,7 @@ void P_MobjThinker(mobj_t *mobj) fixed_t x, y, z; mobj_t *flagmo, *newmobj; -#ifdef HAVE_BLUA if (!LUAh_MobjFuse(mobj) && !P_MobjWasRemoved(mobj)) -#endif switch (mobj->type) { // gargoyle and snowman handled in P_PushableThinker, not here @@ -9730,7 +9393,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->colorized = false; -#ifdef HAVE_BLUA // DANGER! This can cause P_SpawnMobj to return NULL! // Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks! if (LUAh_MobjSpawn(mobj)) @@ -9741,7 +9403,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) else if (P_MobjWasRemoved(mobj)) return NULL; else -#endif switch (mobj->type) { case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: @@ -10063,9 +9724,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif + st->action.acp1(mobj); // 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! @@ -10178,9 +9838,8 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif + st->action.acp1(mobj); // DANGER! This is the ONLY way for P_SpawnMobj to return NULL! // Avoid using MF_RUNSPAWNFUNC on mobjs whose spawn state expects target or tracer to already be set! @@ -10222,12 +9881,8 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype // set subsector and/or block links P_SetPrecipitationThingPosition(mobj); - mobj->floorz = starting_floorz = - mobj->subsector->sector->f_slope ? P_GetZAt(mobj->subsector->sector->f_slope, x, y) : - mobj->subsector->sector->floorheight; - mobj->ceilingz = - mobj->subsector->sector->c_slope ? P_GetZAt(mobj->subsector->sector->c_slope, x, y) : - mobj->subsector->sector->ceilingheight; + mobj->floorz = starting_floorz = P_GetSectorFloorZAt (mobj->subsector->sector, x, y); + mobj->ceilingz = P_GetSectorCeilingZAt(mobj->subsector->sector, x, y); mobj->z = z; mobj->momz = mobjinfo[type].speed; @@ -10277,16 +9932,13 @@ size_t iquehead, iquetail; void P_RemoveMobj(mobj_t *mobj) { I_Assert(mobj != NULL); -#ifdef HAVE_BLUA + if (P_MobjWasRemoved(mobj)) return; // something already removing this mobj. mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing. LUAh_MobjRemoved(mobj); 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! if (mobj->spawnpoint && @@ -10365,6 +10017,12 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->hprev, NULL); } } + + // clear the reference from the mapthing + if (mobj->spawnpoint) + mobj->spawnpoint->mobj = NULL; + + R_RemoveMobjInterpolator(mobj); // free block // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. @@ -10397,8 +10055,6 @@ void P_RemoveMobj(mobj_t *mobj) #endif P_RemoveThinker((thinker_t *)mobj); } - - R_RemoveMobjInterpolator(mobj); } // This does not need to be added to Lua. @@ -10480,7 +10136,7 @@ void P_SpawnPrecipitation(void) subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; - if (dedicated || /*!cv_precipdensity*/!cv_drawdist_precip.value || curWeather == PRECIP_NONE) // SRB2Kart + if (dedicated || !cv_drawdist_precip.value || curWeather == PRECIP_NONE) // SRB2Kart return; // Use the blockmap to narrow down our placing patterns @@ -10491,16 +10147,8 @@ void P_SpawnPrecipitation(void) //for (j = 0; j < cv_precipdensity.value; ++j) -- density is 1 for kart always { - if (cv_lessprecip.value) - { - x = basex*1.5 + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); - y = basey*1.5 + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); - } - else - { - x = basex + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); - y = basey + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); - } + x = ((cv_lessprecip.value ? basex*1.5 : basex) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); + y = ((cv_lessprecip.value ? basey*1.5 : basey) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); precipsector = R_IsPointInSubsector(x, y); @@ -10890,6 +10538,7 @@ void P_SpawnPlayer(INT32 playernum) } mobj = P_SpawnMobj(0, 0, 0, MT_PLAYER); + I_Assert(mobj != NULL); (mobj->player = p)->mo = mobj; mobj->angle = 0; @@ -12305,285 +11954,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) return; } else return; // srb2kart - no rings or ring-like objects in R1 - /* - // Wing logo item. - else if (mthing->type == mobjinfo[MT_NIGHTSWING].doomednum) - { - z = - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : - sec->floorheight; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - - mthing->z = (INT16)(z>>FRACBITS); - - mobj = P_SpawnMobj(x, y, z, MT_NIGHTSWING); - mobj->spawnpoint = mthing; - - if (G_IsSpecialStage(gamemap) && useNightsSS) - P_SetMobjState(mobj, mobj->info->meleestate); - else if (maptol & TOL_XMAS) - P_SetMobjState(mobj, mobj->info->seestate); - - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); - mobj->flags2 |= MF2_AMBUSH; - mthing->mobj = mobj; - } - // All manners of rings and coins - else if (mthing->type == mobjinfo[MT_RING].doomednum || mthing->type == mobjinfo[MT_COIN].doomednum || - mthing->type == mobjinfo[MT_REDTEAMRING].doomednum || mthing->type == mobjinfo[MT_BLUETEAMRING].doomednum) - { - mobjtype_t ringthing = MT_RING; - - // No rings in Ultimate! - if (ultimatemode && !(G_IsSpecialStage(gamemap) || maptol & TOL_NIGHTS)) - return; - - // Which ringthing to use - switch (mthing->type) - { - case 1800: - ringthing = MT_COIN; - break; - case 308: // No team rings in non-CTF - ringthing = (gametype == GT_CTF) ? MT_REDTEAMRING : MT_RING; - break; - case 309: // No team rings in non-CTF - ringthing = (gametype == GT_CTF) ? MT_BLUETEAMRING : MT_RING; - break; - default: - // Spawn rings as blue spheres in special stages, ala S3+K. - if (G_IsSpecialStage(gamemap) && useNightsSS) - ringthing = MT_BLUEBALL; - break; - } - - // Set proper height - if (mthing->options & MTF_OBJECTFLIP) - { - z = ( - sec->c_slope ? P_GetZAt(sec->c_slope, x, y) : - sec->ceilingheight) - mobjinfo[ringthing].height; - if (mthing->options >> ZSHIFT) - z -= ((mthing->options >> ZSHIFT) << FRACBITS); - } - else - { - z = - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : - sec->floorheight; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - } - - if (mthing->options & MTF_AMBUSH) // Special flag for rings - { - if (mthing->options & MTF_OBJECTFLIP) - z -= 24*FRACUNIT; - else - z += 24*FRACUNIT; - } - - mthing->z = (INT16)(z>>FRACBITS); - - mobj = P_SpawnMobj(x, y, z, ringthing); - mobj->spawnpoint = mthing; - - if (mthing->options & MTF_OBJECTFLIP) - { - mobj->eflags |= MFE_VERTICALFLIP; - mobj->flags2 |= MF2_OBJECTFLIP; - } - - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); - mobj->flags2 |= MF2_AMBUSH; - mthing->mobj = mobj; - } - // *** - // Special placement patterns - // *** - - // Vertical Rings - Stack of 5 (handles both red and yellow) - else if (mthing->type == 600 || mthing->type == 601) - { - INT32 dist = 64*FRACUNIT; - mobjtype_t ringthing = MT_RING; - if (mthing->type == 601) - dist = 128*FRACUNIT; - - // No rings in Ultimate! - if (ultimatemode && !(G_IsSpecialStage(gamemap) || maptol & TOL_NIGHTS)) - return; - - // Spawn rings as blue spheres in special stages, ala S3+K. - if (G_IsSpecialStage(gamemap) && useNightsSS) - ringthing = MT_BLUEBALL; - - for (r = 1; r <= 5; r++) - { - if (mthing->options & MTF_OBJECTFLIP) - { - z = ( - sec->c_slope ? P_GetZAt(sec->c_slope, x, y) : - sec->ceilingheight) - mobjinfo[ringthing].height - dist*r; - if (mthing->options >> ZSHIFT) - z -= ((mthing->options >> ZSHIFT) << FRACBITS); - } - else - { - z = ( - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : - sec->floorheight) + dist*r; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - } - - mobj = P_SpawnMobj(x, y, z, ringthing); - - if (mthing->options & MTF_OBJECTFLIP) - { - mobj->eflags |= MFE_VERTICALFLIP; - mobj->flags2 |= MF2_OBJECTFLIP; - } - - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); - if (mthing->options & MTF_AMBUSH) - mobj->flags2 |= MF2_AMBUSH; - } - } - // Diagonal rings (handles both types) - else if (mthing->type == 602 || mthing->type == 603) // Diagonal rings (5) - { - angle_t angle = FixedAngle(mthing->angle*FRACUNIT); - mobjtype_t ringthing = MT_RING; - INT32 iterations = 5; - if (mthing->type == 603) - iterations = 10; - - // No rings in Ultimate! - if (ultimatemode && !(G_IsSpecialStage(gamemap) || maptol & TOL_NIGHTS)) - return; - - // Spawn rings as blue spheres in special stages, ala S3+K. - if (G_IsSpecialStage(gamemap) && useNightsSS) - ringthing = MT_BLUEBALL; - - angle >>= ANGLETOFINESHIFT; - - for (r = 1; r <= iterations; r++) - { - x += FixedMul(64*FRACUNIT, FINECOSINE(angle)); - y += FixedMul(64*FRACUNIT, FINESINE(angle)); - - if (mthing->options & MTF_OBJECTFLIP) - { - z = ( - sec->c_slope ? P_GetZAt(sec->c_slope, x, y) : - sec->ceilingheight) - mobjinfo[ringthing].height - 64*FRACUNIT*r; - if (mthing->options >> ZSHIFT) - z -= ((mthing->options >> ZSHIFT) << FRACBITS); - } - else - { - z = ( - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : - sec->floorheight) + 64*FRACUNIT*r; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - } - - mobj = P_SpawnMobj(x, y, z, ringthing); - - if (mthing->options & MTF_OBJECTFLIP) - { - mobj->eflags |= MFE_VERTICALFLIP; - mobj->flags2 |= MF2_OBJECTFLIP; - } - - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); - if (mthing->options & MTF_AMBUSH) - mobj->flags2 |= MF2_AMBUSH; - } - } - // Rings of items (all six of them) - else if (mthing->type >= 604 && mthing->type <= 609) - { - INT32 numitems = 8; - INT32 size = 96*FRACUNIT; - mobjtype_t itemToSpawn = MT_NIGHTSWING; - - if (mthing->type & 1) - { - numitems = 16; - size = 192*FRACUNIT; - } - - z = - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : - sec->floorheight; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - - closestangle = FixedAngle(mthing->angle*FRACUNIT); - - // Create the hoop! - for (i = 0; i < numitems; i++) - { - switch (mthing->type) - { - case 604: - case 605: - itemToSpawn = MT_RING; - break; - case 608: - case 609: - itemToSpawn = (i & 1) ? MT_NIGHTSWING : MT_RING; - break; - case 606: - case 607: - itemToSpawn = MT_NIGHTSWING; - break; - default: - break; - } - - // No rings in Ultimate! - if (itemToSpawn == MT_RING) - { - if (ultimatemode && !(G_IsSpecialStage(gamemap) || (maptol & TOL_NIGHTS))) - continue; - - // Spawn rings as blue spheres in special stages, ala S3+K. - if (G_IsSpecialStage(gamemap) && useNightsSS) - itemToSpawn = MT_BLUEBALL; - } - - fa = i*FINEANGLES/numitems; - v[0] = FixedMul(FINECOSINE(fa),size); - v[1] = 0; - v[2] = FixedMul(FINESINE(fa),size); - v[3] = FRACUNIT; - - res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); - - finalx = x + v[0]; - finaly = y + v[1]; - finalz = z + v[2]; - - mobj = P_SpawnMobj(finalx, finaly, finalz, itemToSpawn); - mobj->z -= mobj->height/2; - - if (itemToSpawn == MT_NIGHTSWING) - { - if (G_IsSpecialStage(gamemap) && useNightsSS) - P_SetMobjState(mobj, mobj->info->meleestate); - else if ((maptol & TOL_XMAS)) - P_SetMobjState(mobj, mobj->info->seestate); - } - } - return; - }*/ } // diff --git a/src/p_saveg.c b/src/p_saveg.c index dcfcbe765..6469574c8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2507,7 +2507,7 @@ static inline void LoadLaserThinker(actionf_p1 thinker) // // Loads a lightlevel_t from a save game // -static inline void LoadLightlevelThinker(actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadLightlevelThinker(actionf_p1 thinker) { lightlevel_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -3337,7 +3337,7 @@ static void P_NetArchiveMisc(void) WRITEUINT8(save_p, 0x2e); } -static inline boolean P_NetUnArchiveMisc(void) +FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(void) { UINT32 pig; INT32 i; @@ -3487,10 +3487,8 @@ void P_SaveNetGame(void) P_NetArchiveThinkers(); P_NetArchiveSpecials(); } -#ifdef HAVE_BLUA - LUA_Archive(); -#endif + LUA_Archive(); WRITEUINT8(save_p, 0x1d); // consistency marker } @@ -3531,9 +3529,8 @@ boolean P_LoadNetGame(void) P_RelinkPointers(); P_FinishMobjs(); } -#ifdef HAVE_BLUA + LUA_UnArchive(); -#endif // This is stupid and hacky, but maybe it'll work! P_SetRandSeed(P_GetInitSeed()); diff --git a/src/p_setup.c b/src/p_setup.c index a81ae3226..cd5e68472 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -553,17 +553,18 @@ levelflat_t *levelflats; size_t P_PrecacheLevelFlats(void) { lumpnum_t lump; - size_t i, flatmemory = 0; + size_t i, flatmem = 0; //SoM: 4/18/2000: New flat code to make use of levelflats. for (i = 0; i < numlevelflats; i++) { lump = levelflats[i].lumpnum; if (devparm) - flatmemory += W_LumpLength(lump); + flatmem += W_LumpLength(lump); R_GetFlat(lump); } - return flatmemory; + + return flatmem; } // help function for P_LoadSectors, find a flat in the active wad files, @@ -752,15 +753,6 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->floorspeed = 0; ss->ceilspeed = 0; - -#ifdef HWRENDER // ----- for special tricks with HW renderer ----- - ss->pseudoSector = false; - ss->virtualFloor = false; - ss->virtualCeiling = false; - ss->sectorLines = NULL; - ss->stackList = NULL; - ss->lineoutLength = -1.0l; -#endif // ----- end special tricks ----- } // set the sky flat num @@ -2246,42 +2238,6 @@ static void P_LoadRawReject(UINT8 *data, size_t count, const char *lumpname) } } -#if 0 -static char *levellumps[] = -{ - "label", // ML_LABEL, A separator, name, MAPxx - "THINGS", // ML_THINGS, Enemies, items.. - "LINEDEFS", // ML_LINEDEFS, Linedefs, from editing - "SIDEDEFS", // ML_SIDEDEFS, Sidedefs, from editing - "VERTEXES", // ML_VERTEXES, Vertices, edited and BSP splits generated - "SEGS", // ML_SEGS, Linesegs, from linedefs split by BSP - "SSECTORS", // ML_SSECTORS, Subsectors, list of linesegs - "NODES", // ML_NODES, BSP nodes - "SECTORS", // ML_SECTORS, Sectors, from editing - "REJECT", // ML_REJECT, LUT, sector-sector visibility -}; - -/** Checks a lump and returns whether it is a valid start-of-level marker. - * - * \param lumpnum Lump number to check. - * \return True if the lump is a valid level marker, false if not. - */ -static inline boolean P_CheckLevel(lumpnum_t lumpnum) -{ - UINT16 file, lump; - size_t i; - - for (i = ML_THINGS; i <= ML_REJECT; i++) - { - file = WADFILENUM(lumpnum); - lump = LUMPNUM(lumpnum+1); - if (file > numwadfiles || lump < LUMPNUM(lumpnum) || lump > wadfiles[file]->numlumps || - memcmp(wadfiles[file]->lumpinfo[lump].name, levellumps[i], 8) != 0) - return false; - } - return true; // all right -} -#endif /** Sets up a sky texture to use for the level. * The sky texture is used instead of F_SKY1. @@ -2365,15 +2321,7 @@ static void P_LevelInitStuff(void) for (i = 0; i < MAXPLAYERS; i++) { -#if 0 - if ((netgame || multiplayer) && (gametype == GT_COMPETITION || players[i].lives <= 0)) - { - // In Co-Op, replenish a user's lives if they are depleted. - players[i].lives = cv_startinglives.value; - } -#else players[i].lives = 1; // SRB2Kart -#endif players[i].realtime = racecountdown = exitcountdown = 0; curlap = bestlap = 0; // SRB2Kart @@ -2697,47 +2645,6 @@ static void P_LoadRecordGhosts(void) free(gpath); } -/*static void P_LoadNightsGhosts(void) -{ - const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; - char *gpath = malloc(glen); - - if (!gpath) - return; - - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); - - // Best Score ghost - if (cv_ghost_bestscore.value && FIL_FileExists(va("%s-score-best.lmp", gpath))) - G_AddGhost(va("%s-score-best.lmp", gpath)); - - // Best Time ghost - if (cv_ghost_besttime.value && FIL_FileExists(va("%s-time-best.lmp", gpath))) - G_AddGhost(va("%s-time-best.lmp", gpath)); - - // Last ghost - if (cv_ghost_last.value && FIL_FileExists(va("%s-last.lmp", gpath))) - G_AddGhost(va("%s-last.lmp", gpath)); - - // Guest ghost - if (cv_ghost_guest.value && FIL_FileExists(va("%s-guest.lmp", gpath))) - G_AddGhost(va("%s-guest.lmp", gpath)); - - // Staff Attack ghosts - if (cv_ghost_staff.value) - { - lumpnum_t l; - UINT8 i = 1; - while (i <= 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(gamemap),i))) != LUMPERROR) - { - G_AddGhost(va("%sS%02u",G_BuildMapName(gamemap),i)); - i++; - } - } - - free(gpath); -}*/ - static void P_SetupCamera(UINT8 pnum, camera_t *cam) { if (players[pnum].mo && (server || addedtogame)) @@ -2983,9 +2890,7 @@ boolean P_SetupLevel(boolean skipprecip) I_UpdateNoVsync(); }*/ -#ifdef HAVE_BLUA LUA_InvalidateLevel(); -#endif for (ss = sectors; sectors+numsectors != ss; ss++) { @@ -3400,9 +3305,7 @@ boolean P_SetupLevel(boolean skipprecip) G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); } P_PreTicker(2); -#ifdef HAVE_BLUA LUAh_MapLoad(); -#endif } G_AddMapToBuffer(gamemap-1); @@ -3414,8 +3317,6 @@ boolean P_SetupLevel(boolean skipprecip) void HWR_LoadLevel(void) { HWR_FreeMipmapCache(); - // Correct missing sidedefs & deep water trick - HWR_CorrectSWTricks(); HWR_CreatePlanePolygons((INT32)numnodes - 1); if (HWR_ShouldUsePaletteRendering()) @@ -3483,7 +3384,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) boolean mapsadded = false; lumpinfo_t *lumpinfo; - if ((numlumps = W_InitFile(wadfilename, 0, &wadnum, local)) == INT16_MAX) + if ((numlumps = W_InitFile(wadfilename, local)) == INT16_MAX) { refreshdirmenu |= REFRESHDIR_NOTLOADED; CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename); @@ -3680,31 +3581,3 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) return false; } } - -#ifdef DELFILE -boolean P_DelWadFile(void) -{ - sfxenum_t i; - const UINT16 wadnum = (UINT16)(numwadfiles - 1); - const lumpnum_t lumpnum = numwadfiles<<16; - //lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo; - R_DelSkins(wadnum); // only used by DELFILE - R_DelSpriteDefs(wadnum); // only used by DELFILE - for (i = 0; i < NUMSFX; i++) - { - if (S_sfx[i].lumpnum != LUMPERROR && S_sfx[i].lumpnum >= lumpnum) - { - S_StopSoundByNum(i); - S_RemoveSoundFx(i); - if (S_sfx[i].lumpnum != LUMPERROR) - { - I_FreeSfx(&S_sfx[i]); - S_sfx[i].lumpnum = LUMPERROR; - } - } - } - W_UnloadWadFile(wadnum); // only used by DELFILE - R_LoadTextures(); - return false; -} -#endif diff --git a/src/p_setup.h b/src/p_setup.h index 42c8cb773..9e66fff81 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -65,9 +65,6 @@ void HWR_LoadLevel(void); #endif boolean P_AddWadFile(const char *wadfilename, boolean local); boolean P_AddWadFileLocal(const char *wadfilename); -#ifdef DELFILE -boolean P_DelWadFile(void); -#endif // WARNING: The following functions should be grouped as follows: // any amount of PartialAdds followed by MultiSetups until returned true, diff --git a/src/p_sight.c b/src/p_sight.c index f6fa5775f..b482403cb 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -169,6 +169,7 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) return true; } + // // P_CrossSubsector // @@ -492,4 +493,4 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2) // the head node is the last node output return P_CrossBSPNode((INT32)numnodes - 1, &los); -} +} \ No newline at end of file diff --git a/src/p_slopes.c b/src/p_slopes.c index 4e8918536..112ba008b 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -636,8 +636,6 @@ pslope_t *P_SlopeById(UINT16 id) // Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes void P_ResetDynamicSlopes(void) { size_t i; -#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning - boolean warned = false; slopelist = NULL; slopecount = 0; @@ -648,13 +646,10 @@ void P_ResetDynamicSlopes(void) { { switch (lines[i].special) { -#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning -#define WARNME if (!warned) {warned = true; CONS_Alert(CONS_WARNING, "This level uses old slope specials.\nA conversion will be needed before 2.2's release.\n");} case 386: case 387: case 388: lines[i].special += 700-386; - WARNME P_SpawnSlope_Line(i); break; @@ -663,13 +658,11 @@ void P_ResetDynamicSlopes(void) { case 391: case 392: lines[i].special += 710-389; - WARNME P_SpawnSlope_Line(i); break; case 393: lines[i].special = 703; - WARNME P_SpawnSlope_Line(i); break; @@ -677,11 +670,8 @@ void P_ResetDynamicSlopes(void) { case 395: case 396: lines[i].special += 720-394; - WARNME break; -#endif - case 700: case 701: case 702: @@ -944,5 +934,4 @@ void P_ButteredSlope(mobj_t *mo) P_Thrust(mo, mo->standingslope->xydirection, thrust); } -// EOF -#endif // #ifdef ESLOPE +// EOF \ No newline at end of file diff --git a/src/p_spec.c b/src/p_spec.c index dc2ea796d..9fb1953ee 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -472,7 +472,8 @@ void P_ParseAnimationDefintion(SINT8 istexture) // Increase the size to make room for the new animation definition maxanims++; animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL); - strncpy(animdefs[i].startname, animdefsToken, 9); + memcpy(animdefs[i].startname, animdefsToken, 9); + animdefs[i].startname[8] = '\0'; } // animdefs[i].startname is now set to animdefsToken either way. @@ -3110,14 +3111,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } case 443: // Calls a named Lua function -#ifdef HAVE_BLUA if (line->text) LUAh_LinedefExecute(line, mo, callsec); 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)); -#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; case 444: // Earthquake camera diff --git a/src/p_tick.c b/src/p_tick.c index 6bad0f856..183c42a4b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -254,9 +254,7 @@ void P_RemoveThinkerDelayed(void *pthinker) // void P_RemoveThinker(thinker_t *thinker) { -#ifdef HAVE_BLUA LUA_InvalidateUserdata(thinker); -#endif thinker->function.acp1 = P_RemoveThinkerDelayed; } @@ -661,13 +659,10 @@ void P_Ticker(boolean run) ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; -#ifdef HAVE_BLUA PS_START_TIMING(ps_lua_prethinkframe_time); LUAh_PreThinkFrame(); PS_STOP_TIMING(ps_lua_prethinkframe_time); -#endif - PS_START_TIMING(ps_playerthink_time); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) @@ -679,12 +674,6 @@ void P_Ticker(boolean run) if (!demo.playback) // Don't increment if a demo is playing. totalplaytime++; - /*if (!useNightsSS && G_IsSpecialStage(gamemap)) - P_DoSpecialStageStuff(); - - if (runemeraldmanager) - P_EmeraldManager(); // Power stone mode*/ - if (run) { PS_START_TIMING(ps_thinkertime); @@ -696,11 +685,9 @@ void P_Ticker(boolean run) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); -#ifdef HAVE_BLUA PS_START_TIMING(ps_lua_thinkframe_time); LUAh_ThinkFrame(); PS_STOP_TIMING(ps_lua_thinkframe_time); -#endif } // Run shield positioning @@ -825,13 +812,9 @@ void P_Ticker(boolean run) && server) // Remember: server uses it for mapchange, but EVERYONE ticks down for the animation D_MapChange(gamemap, gametype, encoremode, true, 0, false, false); -#ifdef HAVE_BLUA - PS_START_TIMING(ps_lua_postthinkframe_time); LUAh_PostThinkFrame(); PS_STOP_TIMING(ps_lua_postthinkframe_time); - -#endif } // Always move the camera. @@ -891,9 +874,7 @@ void P_PreTicker(INT32 frames) R_UpdateMobjInterpolators(); -#ifdef HAVE_BLUA LUAh_PreThinkFrame(); -#endif for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) @@ -918,22 +899,15 @@ void P_PreTicker(INT32 frames) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); -#ifdef HAVE_BLUA LUAh_ThinkFrame(); -#endif - // Run shield positioning - //P_RunShields(); P_RunOverlays(); - P_RunShadows(); P_UpdateSpecials(); P_RespawnSpecials(); -#ifdef HAVE_BLUA LUAh_PostThinkFrame(); -#endif R_UpdateLevelInterpolators(); R_UpdateViewInterpolation(); diff --git a/src/p_user.c b/src/p_user.c index b8b1bfe0d..edf585626 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -59,10 +59,6 @@ #include "hardware/hw_main.h" #endif -#if 0 -static void P_NukeAllPlayers(player_t *player); -#endif - // // Movement. // @@ -86,46 +82,6 @@ void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move) mo->momy += FixedMul(move, FINESINE(angle)); } -#if 0 -static inline void P_ThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move) -{ - angle >>= ANGLETOFINESHIFT; - - mo->momx += FixedMul(move, FINECOSINE(angle)); - mo->momy += FixedMul(move, FINESINE(angle)); -} - -static inline void P_VectorInstaThrust(fixed_t xa, fixed_t xb, fixed_t xc, fixed_t ya, fixed_t yb, fixed_t yc, - fixed_t za, fixed_t zb, fixed_t zc, fixed_t momentum, mobj_t *mo) -{ - fixed_t a1, b1, c1, a2, b2, c2, i, j, k; - - a1 = xb - xa; - b1 = yb - ya; - c1 = zb - za; - a2 = xb - xc; - b2 = yb - yc; - c2 = zb - zc; -/* - // Convert to unit vectors... - a1 = FixedDiv(a1,FixedSqrt(FixedMul(a1,a1) + FixedMul(b1,b1) + FixedMul(c1,c1))); - b1 = FixedDiv(b1,FixedSqrt(FixedMul(a1,a1) + FixedMul(b1,b1) + FixedMul(c1,c1))); - c1 = FixedDiv(c1,FixedSqrt(FixedMul(c1,c1) + FixedMul(c1,c1) + FixedMul(c1,c1))); - - a2 = FixedDiv(a2,FixedSqrt(FixedMul(a2,a2) + FixedMul(c2,c2) + FixedMul(c2,c2))); - b2 = FixedDiv(b2,FixedSqrt(FixedMul(a2,a2) + FixedMul(c2,c2) + FixedMul(c2,c2))); - c2 = FixedDiv(c2,FixedSqrt(FixedMul(a2,a2) + FixedMul(c2,c2) + FixedMul(c2,c2))); -*/ - // Calculate the momx, momy, and momz - i = FixedMul(momentum, FixedMul(b1, c2) - FixedMul(c1, b2)); - j = FixedMul(momentum, FixedMul(c1, a2) - FixedMul(a1, c2)); - k = FixedMul(momentum, FixedMul(a1, b2) - FixedMul(a1, c2)); - - mo->momx = i; - mo->momy = j; - mo->momz = k; -} -#endif // // P_InstaThrust @@ -195,12 +151,6 @@ void P_CalcHeight(player_t *player) // Note: a LUT allows for effects // like a ramp with low health. - /*player->bob = (FixedMul(player->rmomx,player->rmomx) - + FixedMul(player->rmomy,player->rmomy))>>2; - - if (player->bob > FixedMul(MAXBOB, mo->scale)) - player->bob = FixedMul(MAXBOB, mo->scale);*/ - if (!P_IsObjectOnGround(mo)) { if (mo->eflags & MFE_VERTICALFLIP) @@ -218,37 +168,9 @@ void P_CalcHeight(player_t *player) return; } - //angle = (FINEANGLES/20*localgametic)&FINEMASK; - //bob = FixedMul(player->bob/2, FINESINE(angle)); - // move viewheight player->viewheight = FixedMul(32 << FRACBITS, mo->scale); // default eye view height - /*if (player->playerstate == PST_LIVE) - { - player->viewheight += player->deltaviewheight; - - if (player->viewheight > pviewheight) - { - player->viewheight = pviewheight; - player->deltaviewheight = 0; - } - - if (player->viewheight < pviewheight/2) - { - player->viewheight = pviewheight/2; - if (player->deltaviewheight <= 0) - player->deltaviewheight = 1; - } - - if (player->deltaviewheight) - { - player->deltaviewheight += FixedMul(FRACUNIT/4, mo->scale); - if (!player->deltaviewheight) - player->deltaviewheight = 1; - } - }*/ - if (player->mo->eflags & MFE_VERTICALFLIP) player->viewz = mo->z + mo->height - player->viewheight; //- bob else @@ -343,43 +265,6 @@ void P_ResetScore(player_t *player) player->scoreadd = 0; } -// -// P_FindLowestMare -// -// Returns the lowest open mare available -// -/*UINT8 P_FindLowestMare(void) -{ - thinker_t *th; - mobj_t *mo2; - UINT8 mare = UINT8_MAX; - - if (G_RaceGametype()) - return 0; - - // scan the thinkers - // to find the egg capsule with the lowest mare - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_EGGCAPSULE && mo2->health > 0) - { - const UINT8 threshold = (UINT8)mo2->threshold; - if (mare == 255) - mare = threshold; - else if (threshold < mare) - mare = threshold; - } - } - - CONS_Debug(DBG_NIGHTS, "Lowest mare found: %d\n", mare); - - return mare; -}*/ // // P_FindLowestLap @@ -435,393 +320,6 @@ UINT8 P_FindHighestLap(void) return highest; } -// -// P_TransferToNextMare -// -// Transfers the player to the next Mare. -// (Finds the lowest mare # for capsules that have not been destroyed). -// Returns true if successful, false if there is no other mare. -// -/*boolean P_TransferToNextMare(player_t *player) -{ - thinker_t *th; - mobj_t *mo2; - mobj_t *closestaxis = NULL; - INT32 lowestaxisnum = -1; - UINT8 mare = P_FindLowestMare(); - fixed_t dist1, dist2 = 0; - - if (mare == 255) - return false; - - CONS_Debug(DBG_NIGHTS, "Mare is %d\n", mare); - - player->mare = mare; - - // scan the thinkers - // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_AXIS) - { - if (mo2->threshold == mare) - { - if (closestaxis == NULL) - { - closestaxis = mo2; - lowestaxisnum = mo2->health; - dist2 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y)-mo2->radius; - } - else if (mo2->health < lowestaxisnum) - { - dist1 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y)-mo2->radius; - - if (dist1 < dist2) - { - closestaxis = mo2; - lowestaxisnum = mo2->health; - dist2 = dist1; - } - } - } - } - } - - if (closestaxis == NULL) - return false; - - P_SetTarget(&player->mo->target, closestaxis); - return true; -} - -// -// P_FindAxis -// -// Given a mare and axis number, returns -// the mobj for that axis point. -static mobj_t *P_FindAxis(INT32 mare, INT32 axisnum) -{ - thinker_t *th; - mobj_t *mo2; - - // scan the thinkers - // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - // Axis things are only at beginning of list. - if (!(mo2->flags2 & MF2_AXIS)) - return NULL; - - if (mo2->type == MT_AXIS) - { - if (mo2->health == axisnum && mo2->threshold == mare) - return mo2; - } - } - - return NULL; -} - -// -// P_FindAxisTransfer -// -// Given a mare and axis number, returns -// the mobj for that axis transfer point. -static mobj_t *P_FindAxisTransfer(INT32 mare, INT32 axisnum, mobjtype_t type) -{ - thinker_t *th; - mobj_t *mo2; - - // scan the thinkers - // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - // Axis things are only at beginning of list. - if (!(mo2->flags2 & MF2_AXIS)) - return NULL; - - if (mo2->type == type) - { - if (mo2->health == axisnum && mo2->threshold == mare) - return mo2; - } - } - - return NULL; -} - -// -// P_TransferToAxis -// -// Finds the CLOSEST axis with the number specified. -void P_TransferToAxis(player_t *player, INT32 axisnum) -{ - thinker_t *th; - mobj_t *mo2; - mobj_t *closestaxis; - INT32 mare = player->mare; - fixed_t dist1, dist2 = 0; - - CONS_Debug(DBG_NIGHTS, "Transferring to axis %d\nLeveltime: %u...\n", axisnum, leveltime); - - closestaxis = NULL; - - // scan the thinkers - // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_AXIS) - { - if (mo2->health == axisnum && mo2->threshold == mare) - { - if (closestaxis == NULL) - { - closestaxis = mo2; - dist2 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y)-mo2->radius; - } - else - { - dist1 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y)-mo2->radius; - - if (dist1 < dist2) - { - closestaxis = mo2; - dist2 = dist1; - } - } - } - } - } - - if (!closestaxis) - { - CONS_Debug(DBG_NIGHTS, "ERROR: Specified axis point to transfer to not found!\n%d\n", axisnum); - } - else - { - CONS_Debug(DBG_NIGHTS, "Transferred to axis %d, mare %d\n", closestaxis->health, closestaxis->threshold); - } - - P_SetTarget(&player->mo->target, closestaxis); -} - -// -// P_DeNightserizePlayer -// -// Whoops! Ran out of NiGHTS time! -// -static void P_DeNightserizePlayer(player_t *player) -{ - thinker_t *th; - mobj_t *mo2; - - player->pflags &= ~PF_NIGHTSMODE; - - //if (player->mo->tracer) - //P_RemoveMobj(player->mo->tracer); - - player->powers[pw_underwater] = 0; - player->pflags &= ~(PF_USEDOWN|PF_JUMPDOWN|PF_ATTACKDOWN|PF_STARTDASH|PF_GLIDING|PF_JUMPED|PF_THOKKED|PF_SPINNING|PF_DRILLING|PF_TRANSFERTOCLOSEST); - player->secondjump = 0; - player->jumping = 0; - player->homing = 0; - player->climbing = 0; - player->mo->fuse = 0; - player->speed = 0; - P_SetTarget(&player->mo->target, NULL); - P_SetTarget(&player->axis1, P_SetTarget(&player->axis2, NULL)); - - player->mo->flags &= ~MF_NOGRAVITY; - - player->mo->flags2 &= ~MF2_DONTDRAW; - - // Restore aiming angle - if (player == &players[consoleplayer]) - localaiming[0] = 0; - else if (player == &players[displayplayers[1]]) - localaiming[1] = 0; - else if (player == &players[displayplayers[2]]) - localaiming[2] = 0; - else if (player == &players[displayplayers[3]]) - localaiming[3] = 0; - - if (player->mo->tracer) - P_RemoveMobj(player->mo->tracer); - //P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); // SRB2kart - player->pflags |= PF_NIGHTSFALL; - - // If in a special stage, add some preliminary exit time. - if (G_IsSpecialStage(gamemap)) - { - INT32 i; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - players[i].nightstime = 1; // force everyone else to fall too. - player->exiting = raceexittime+2; - stagefailed = true; // NIGHT OVER - } - - // Check to see if the player should be killed. - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - if (!(mo2->type == MT_NIGHTSDRONE)) - continue; - - if (mo2->flags2 & MF2_AMBUSH) - P_DamageMobj(player->mo, NULL, NULL, 10000); - - break; - } - - // Restore from drowning music - P_RestoreMusic(player); -} -// -// P_NightserizePlayer -// -// NiGHTS Time! -void P_NightserizePlayer(player_t *player, INT32 nighttime) -{ - INT32 oldmare; - - // Bots can't be super, silly!1 :P - if (player->bot) - return; - - if (!(player->pflags & PF_NIGHTSMODE)) - { - P_SetTarget(&player->mo->tracer, P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_NIGHTSCHAR)); - player->mo->tracer->destscale = player->mo->scale; - P_SetScale(player->mo->tracer, player->mo->scale); - player->mo->tracer->eflags = (player->mo->tracer->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); - player->mo->height = player->mo->tracer->height; - } - - player->pflags &= ~(PF_USEDOWN|PF_JUMPDOWN|PF_ATTACKDOWN|PF_STARTDASH|PF_GLIDING|PF_JUMPED|PF_THOKKED|PF_SPINNING|PF_DRILLING); - player->homing = 0; - player->mo->fuse = 0; - player->speed = 0; - player->climbing = 0; - player->secondjump = 0; - - player->powers[pw_shield] = SH_NONE; - - player->mo->flags |= MF_NOGRAVITY; - - player->mo->flags2 |= MF2_DONTDRAW; - - player->nightstime = player->startedtime = nighttime*TICRATE; - player->bonustime = false; - - P_RestoreMusic(player); - P_SetMobjState(player->mo->tracer, S_SUPERTRANS1); - - if (G_RaceGametype()) - { - if (player->drillmeter < 48*20) - player->drillmeter = 48*20; - } - else - { - if (player->drillmeter < 40*20) - player->drillmeter = 40*20; - } - - oldmare = player->mare; - - if (P_TransferToNextMare(player) == false) - { - INT32 i; - INT32 total_rings = 0; - - P_SetTarget(&player->mo->target, NULL); - - if (G_IsSpecialStage(gamemap)) - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - total_rings += players[i].health-1; - } - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || !players[i].mo || players[i].spectator) - continue; - - players[i].texttimer = (3 * TICRATE) - 10; - players[i].textvar = 4; // Score and grades - players[i].lastmare = players[i].mare; - if (G_IsSpecialStage(gamemap)) - { - players[i].finishedrings = (INT16)total_rings; - P_AddPlayerScore(player, total_rings * 50); - } - else - { - players[i].finishedrings = (INT16)(players[i].health - 1); - P_AddPlayerScore(&players[i], (players[i].health - 1) * 50); - } - - // transfer scores anyway - - players[i].mo->health = players[i].health = 1; - P_DoPlayerExit(&players[i]); - } - } - else if (oldmare != player->mare) - { - /// \todo Handle multi-mare special stages. - // Ring bonus - P_AddPlayerScore(player, (player->health - 1) * 50); - - player->lastmare = (UINT8)oldmare; - player->texttimer = 4*TICRATE; - player->textvar = 4; // Score and grades - player->finishedrings = (INT16)(player->health - 1); - - // Starting a new mare, transfer scores - player->marebegunat = leveltime; - - player->mo->health = player->health = 1; - } - else - { - player->textvar = 5; // Nothing, just tells it to go to the GET n RINGS/SPHERES text in a bit - player->texttimer = 40; - - // Don't show before title card - // Not consistency safe, but this only affects drawing - if (timeinmap + 40 < 110) - player->texttimer = (UINT8)(110 - timeinmap); - } - - player->pflags |= PF_NIGHTSMODE; -}*/ - // // P_PlayerInPain // @@ -830,6 +328,10 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) // boolean P_PlayerInPain(player_t *player) { + // If the player doesn't have a mobj, it can't be in pain. + if (!player->mo) + return false; + // no silly, sliding isn't pain if (!(player->pflags & PF_SLIDING) && player->mo->state == &states[player->mo->info->painstate] && player->powers[pw_flashing]) return true; @@ -904,16 +406,6 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) if (player->pflags & PF_ROPEHANG) P_SetTarget(&player->mo->tracer, NULL); - // Point penalty for hitting a hazard during tag. - // Discourages players from intentionally hurting themselves to avoid being tagged. - /*if (gametype == GT_TAG && (!(player->pflags & PF_TAGGED) && !(player->pflags & PF_TAGIT))) - { - if (player->score >= 50) - player->score -= 50; - else - player->score = 0; - }*/ - P_ResetPlayer(player); P_SetPlayerMobjState(player->mo, player->mo->info->painstate); player->powers[pw_flashing] = K_GetKartFlashing(player); @@ -962,14 +454,6 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) player->totalring += num_rings; //{ SRB2kart - rings don't really do anything, but we don't want the player spilling them later. - /* - // Can only get up to 9999 rings, sorry! - if (player->mo->health > 10000) - { - player->mo->health = 10000; - player->health = 10000; - } - else if (player->mo->health < 1)*/ { player->mo->health = 1; player->health = 1; @@ -1077,13 +561,6 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) else player->marescore = MAXSCORE; - // check for extra lives every 50000 pts - /*if (!ultimatemode && !modeattacking && player->score > oldscore && player->score % 50000 < amount && (gametype == GT_COMPETITION || gametype == GT_COOP)) - { - P_GivePlayerLives(player, (player->score/50000) - (oldscore/50000)); - P_PlayLivesJingle(player); - }*/ - // In team match, all awarded points are incremented to the team's running score. if (gametype == GT_TEAMMATCH) { @@ -1843,15 +1320,6 @@ void P_DoPlayerExit(player_t *player) else player->exiting = raceexittime+2; // Accidental death safeguard??? - //player->pflags &= ~PF_GLIDING; - /* // SRB2kart - don't need - if (player->climbing) - { - player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - */ player->powers[pw_underwater] = 0; player->powers[pw_spacetime] = 0; player->kartstuff[k_cardanimation] = 0; // srb2kart: reset battle animation @@ -1977,14 +1445,10 @@ static void P_CheckBustableBlocks(player_t *player) // ...or are drilling in NiGHTS (or Metal Sonic) if (!(rover->flags & FF_SHATTER) && !(rover->flags & FF_SPINBUST) && !((player->pflags & PF_SPINNING) && !(player->pflags & PF_JUMPED)) - && (/*player->charability != CA_GLIDEANDCLIMB &&*/ !player->powers[pw_super]) + && (!player->powers[pw_super]) && !(player->pflags & PF_DRILLING) && !metalrecording) continue; - // Only Knuckles can break this rock... - /*if (!(rover->flags & FF_SHATTER) && (rover->flags & FF_ONLYKNUX) && !(player->charability == CA_GLIDEANDCLIMB)) - continue;*/ - topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); @@ -2250,142 +1714,6 @@ static void P_CheckQuicksand(player_t *player) } } -// -// P_CheckSneakerAndLivesTimer -// -// Restores music from sneaker and life fanfares -// -/* // SRB2kart - Can't drown. -static void P_CheckSneakerAndLivesTimer(player_t *player) -{ - if ((player->powers[pw_underwater] <= 11*TICRATE + 1) - && (player->powers[pw_underwater] > 1)) - return; // don't restore music if drowning music is playing - - if (player->powers[pw_extralife] == 1) // Extra Life! - P_RestoreMusic(player); - - //if (player->powers[pw_sneakers] == 1) // SRB2kart - // P_RestoreMusic(player); -} -*/ - -// -// P_CheckUnderwaterAndSpaceTimer -// -// Restores music from underwater and space warnings, and handles number generation -// -/* // SRB2kart - Can't drown. -static void P_CheckUnderwaterAndSpaceTimer(player_t *player) -{ - fixed_t height; - mobj_t *numbermobj = NULL; - - if (player->mo->eflags & MFE_VERTICALFLIP) - height = player->mo->z - FixedMul(8*FRACUNIT - mobjinfo[MT_DROWNNUMBERS].height, player->mo->scale); - else - height = player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, player->mo->scale); - - if (player->powers[pw_underwater] == 11*TICRATE + 1 || player->powers[pw_spacetime] == 11*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+5); - } - else if (player->powers[pw_underwater] == 9*TICRATE + 1 || player->powers[pw_spacetime] == 9*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+4); - } - else if (player->powers[pw_underwater] == 7*TICRATE + 1 || player->powers[pw_spacetime] == 7*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+3); - } - else if (player->powers[pw_underwater] == 5*TICRATE + 1 || player->powers[pw_spacetime] == 5*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+2); - } - else if (player->powers[pw_underwater] == 3*TICRATE + 1 || player->powers[pw_spacetime] == 3*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+1); - } - else if (player->powers[pw_underwater] == 1*TICRATE + 1 || player->powers[pw_spacetime] == 1*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - //P_SetMobjState(numbermobj, numbermobj->info->spawnstate+0); - } - // Underwater timer runs out - else if (player->powers[pw_underwater] == 1) - { - mobj_t *killer; - - if ((netgame || multiplayer) && P_IsLocalPlayer(player)) - S_ChangeMusic(mapmusname, mapmusflags, true); - - killer = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_NULL); - killer->threshold = 42; // Special flag that it was drowning which killed you. - P_DamageMobj(player->mo, killer, killer, 10000); - } - else if (player->powers[pw_spacetime] == 1) - { - if ((netgame || multiplayer) && P_IsLocalPlayer(player)) - S_ChangeMusic(mapmusname, mapmusflags, true); - - P_DamageMobj(player->mo, NULL, NULL, 10000); - } - - if (numbermobj) - { - P_SetTarget(&numbermobj->target, player->mo); - numbermobj->threshold = 40; - S_StartSound(player->mo, sfx_dwnind); - numbermobj->destscale = player->mo->scale; - P_SetScale(numbermobj, player->mo->scale); - } - - if (!(player->mo->eflags & MFE_UNDERWATER) && player->powers[pw_underwater]) - { - if (player->powers[pw_underwater] <= 12*TICRATE + 1) - P_RestoreMusic(player); - - player->powers[pw_underwater] = 0; - } - - if (player->powers[pw_spacetime] > 1 && !P_InSpaceSector(player->mo)) - { - P_RestoreMusic(player); - player->powers[pw_spacetime] = 0; - } - - // Underwater audio cues - if (P_IsLocalPlayer(player) && !player->bot) - { - if (player->powers[pw_underwater] == 11*TICRATE + 1 - && player == &players[consoleplayer]) - { - S_StopMusic(); - S_ChangeMusicInternal("drown", false); - } - - if (player->powers[pw_underwater] == 25*TICRATE + 1) - S_StartSound(NULL, sfx_wtrdng); - else if (player->powers[pw_underwater] == 20*TICRATE + 1) - S_StartSound(NULL, sfx_wtrdng); - else if (player->powers[pw_underwater] == 15*TICRATE + 1) - S_StartSound(NULL, sfx_wtrdng); - } - - if (player->exiting) - { - if (player->powers[pw_underwater] > 1) - player->powers[pw_underwater] = 0; - - player->powers[pw_spacetime] = 0; - } -}*/ - // // P_CheckInvincibilityTimer // @@ -2396,49 +1724,27 @@ static void P_CheckInvincibilityTimer(player_t *player) if (!player->powers[pw_invulnerability] && !player->kartstuff[k_invincibilitytimer]) return; - //if (mariomode && !player->powers[pw_super]) // SRB2kart - { - player->mo->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); - } - /*if (leveltime % (TICRATE/7) == 0) - { - mobj_t *sparkle = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_IVSP); - sparkle->destscale = player->mo->scale; - P_SetScale(sparkle, player->mo->scale); - }*/ + player->mo->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); // Resume normal music stuff. if (player->powers[pw_invulnerability] == 1 || player->kartstuff[k_invincibilitytimer] == 1) { if (!player->powers[pw_super]) { - //if (mariomode) { - //if (player->powers[pw_shield] & SH_FIREFLOWER) - //{ - // player->mo->color = SKINCOLOR_WHITE; - // G_GhostAddColor((INT32) (player - players), GHC_FIREFLOWER); - //} - //else - { - player->mo->color = player->skincolor; - G_GhostAddColor((INT32) (player - players), GHC_NORMAL); - } + player->mo->color = player->skincolor; + G_GhostAddColor((INT32) (player - players), GHC_NORMAL); } // If you had a shield, restore its visual significance P_SpawnShieldOrb(player); } - /*if ((player->powers[pw_underwater] <= 11*TICRATE + 1) - && (player->powers[pw_underwater] > 1)) - return; // don't restore music if drowning music is playing - - if (!player->powers[pw_super] || (mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC))*/ - P_RestoreMusic(player); + P_RestoreMusic(player); } } + // // P_DoBubbleBreath // @@ -2470,35 +1776,6 @@ static void P_DoBubbleBreath(player_t *player) if (player->pflags & PF_NIGHTSMODE) // NiGHTS Super doesn't spawn flight bubbles return; - - // Tails stirs up the water while flying in it - /*if (player->powers[pw_tailsfly] && (leveltime & 1) && player->charability != CA_SWIM) - { - fixed_t radius = (3*player->mo->radius)>>1; - angle_t fa = ((leveltime%45)*FINEANGLES/8) & FINEMASK; - fixed_t stirwaterx = FixedMul(FINECOSINE(fa),radius); - fixed_t stirwatery = FixedMul(FINESINE(fa),radius); - fixed_t stirwaterz; - - if (player->mo->eflags & MFE_VERTICALFLIP) - stirwaterz = player->mo->z + player->mo->height - FixedDiv(player->mo->height,3*FRACUNIT/2); - else - stirwaterz = player->mo->z + FixedDiv(player->mo->height,3*FRACUNIT/2); - - bubble = P_SpawnMobj( - player->mo->x + stirwaterx, - player->mo->y + stirwatery, - stirwaterz, MT_SMALLBUBBLE); - bubble->destscale = player->mo->scale; - P_SetScale(bubble,bubble->destscale); - - bubble = P_SpawnMobj( - player->mo->x - stirwaterx, - player->mo->y - stirwatery, - stirwaterz, MT_SMALLBUBBLE); - bubble->destscale = player->mo->scale; - P_SetScale(bubble,bubble->destscale); - }*/ } // @@ -2553,1160 +1830,6 @@ static void P_DoPlayerHeadSigns(player_t *player) } } -// -// P_DoClimbing -// -// Handles player climbing -// -/* -static void P_DoClimbing(player_t *player) // SRB2kart - unused -{ - return; // SRB2kart - don't need - ticcmd_t *cmd = &player->cmd; - fixed_t platx; - fixed_t platy; - subsector_t *glidesector; - //boolean climb = true; // SRB2kart - unused - - platx = P_ReturnThrustX(player->mo, player->mo->angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); - platy = P_ReturnThrustY(player->mo, player->mo->angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); - - glidesector = R_IsPointInSubsector(player->mo->x + platx, player->mo->y + platy); - - if (!glidesector || glidesector->sector != player->mo->subsector->sector) - { - boolean floorclimb = false; - //boolean thrust = false; // SRB2kart - unused - //boolean boostup = false; // SRB2kart - unused - //boolean skyclimber = false; // SRB2kart - unused - fixed_t floorheight, ceilingheight; // ESLOPE - - if (!glidesector) - floorclimb = true; - else - { - floorheight = glidesector->sector->f_slope ? P_GetZAt(glidesector->sector->f_slope, player->mo->x, player->mo->y) - : glidesector->sector->floorheight; - ceilingheight = glidesector->sector->c_slope ? P_GetZAt(glidesector->sector->c_slope, player->mo->x, player->mo->y) - : glidesector->sector->ceilingheight; - - if (glidesector->sector->ffloors) - { - ffloor_t *rover; - fixed_t topheight, bottomheight; // ESLOPE - - for (rover = glidesector->sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; - - floorclimb = true; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - // Only supports rovers that are moving like an 'elevator', not just the top or bottom. - if (rover->master->frontsector->floorspeed && rover->master->frontsector->ceilspeed == 42) - { - if ((!(player->mo->eflags & MFE_VERTICALFLIP) && (bottomheight < player->mo->z+player->mo->height) - && (topheight >= player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale))) - || ((player->mo->eflags & MFE_VERTICALFLIP) && (topheight > player->mo->z) - && (bottomheight <= player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)))) - { - if (cmd->forwardmove != 0) - player->mo->momz += rover->master->frontsector->floorspeed; - else - { - player->mo->momz = rover->master->frontsector->floorspeed; - climb = false; - } - } - } - - // Gravity is flipped, so the comments are, too. - if (player->mo->eflags & MFE_VERTICALFLIP) - { - // Trying to climb down past the bottom of the FOF - if ((topheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= topheight)) - { - fixed_t bottomheight2; - ffloor_t *roverbelow; - boolean foundfof = false; - floorclimb = true; - boostup = false; - - // Is there a FOF directly below this one that we can move onto? - for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) - { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || (roverbelow->flags & FF_BUSTUP)) - continue; - - if (roverbelow == rover) - continue; - - bottomheight2 = *roverbelow->b_slope ? P_GetZAt(*roverbelow->b_slope, player->mo->x, player->mo->y) : *roverbelow->bottomheight; - - if (bottomheight2 < topheight + FixedMul(16*FRACUNIT, player->mo->scale)) - foundfof = true; - } - - if (!foundfof) - player->mo->momz = 0; - } - - // Below the FOF - if (topheight <= player->mo->z) - { - floorclimb = false; - boostup = false; - thrust = false; - } - - // Above the FOF - if (bottomheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)) - { - floorclimb = false; - thrust = true; - boostup = true; - } - } - else - { - // Trying to climb down past the bottom of a FOF - if ((bottomheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= bottomheight)) - { - fixed_t topheight2; - ffloor_t *roverbelow; - boolean foundfof = false; - floorclimb = true; - boostup = false; - - // Is there a FOF directly below this one that we can move onto? - for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) - { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || (roverbelow->flags & FF_BUSTUP)) - continue; - - if (roverbelow == rover) - continue; - - topheight2 = *roverbelow->t_slope ? P_GetZAt(*roverbelow->t_slope, player->mo->x, player->mo->y) : *roverbelow->topheight; - - if (topheight2 > bottomheight - FixedMul(16*FRACUNIT, player->mo->scale)) - foundfof = true; - } - - if (!foundfof) - player->mo->momz = 0; - } - - // Below the FOF - if (bottomheight >= player->mo->z + player->mo->height) - { - floorclimb = false; - boostup = false; - thrust = false; - } - - // Above the FOF - if (topheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale)) - { - floorclimb = false; - thrust = true; - boostup = true; - } - } - - if (floorclimb) - { - if (rover->flags & FF_CRUMBLE && !(netgame && player->spectator)) - EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), player, rover->alpha, !(rover->flags & FF_NORETURN)); - break; - } - } - } - - // Gravity is flipped, so are comments. - if (player->mo->eflags & MFE_VERTICALFLIP) - { - // Trying to climb down past the upper texture area - if ((floorheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= floorheight)) - { - boolean foundfof = false; - floorclimb = true; - - // Is there a FOF directly below that we can move onto? - if (glidesector->sector->ffloors) - { - fixed_t bottomheight; - ffloor_t *rover; - for (rover = glidesector->sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; - - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - if (bottomheight < floorheight + FixedMul(16*FRACUNIT, player->mo->scale)) - { - foundfof = true; - break; - } - } - } - - if (!foundfof) - player->mo->momz = 0; - } - - // Reached the top of the lower texture area - if (!floorclimb && ceilingheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) - && (glidesector->sector->ceilingpic == skyflatnum || floorheight < (player->mo->z - FixedMul(8*FRACUNIT, player->mo->scale)))) - { - thrust = true; - boostup = true; - // Play climb-up animation here - } - } - else - { - // Trying to climb down past the upper texture area - if ((ceilingheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= ceilingheight)) - { - boolean foundfof = false; - floorclimb = true; - - // Is there a FOF directly below that we can move onto? - if (glidesector->sector->ffloors) - { - fixed_t topheight; - ffloor_t *rover; - for (rover = glidesector->sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - - if (topheight > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) - { - foundfof = true; - break; - } - } - } - - if (!foundfof) - player->mo->momz = 0; - } - - // Allow climbing from a FOF or lower texture onto the upper texture and vice versa. - if (player->mo->z > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) - { - floorclimb = true; - thrust = false; - boostup = false; - } - - // Reached the top of the lower texture area - if (!floorclimb && floorheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) - && (glidesector->sector->ceilingpic == skyflatnum || ceilingheight > (player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, player->mo->scale)))) - { - thrust = true; - boostup = true; - // Play climb-up animation here - } - } - - // Trying to climb on the sky - if ((ceilingheight < player->mo->z) && glidesector->sector->ceilingpic == skyflatnum) - { - skyclimber = true; - } - - // Climbing on the lower texture area? - if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) < floorheight) - || ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height <= floorheight)) - { - floorclimb = true; - - if (glidesector->sector->floorspeed) - { - if (cmd->forwardmove != 0) - player->mo->momz += glidesector->sector->floorspeed; - else - { - player->mo->momz = glidesector->sector->floorspeed; - climb = false; - } - } - } - // Climbing on the upper texture area? - else if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z >= ceilingheight) - || ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) > ceilingheight)) - { - floorclimb = true; - - if (glidesector->sector->ceilspeed) - { - if (cmd->forwardmove != 0) - player->mo->momz += glidesector->sector->ceilspeed; - else - { - player->mo->momz = glidesector->sector->ceilspeed; - climb = false; - } - } - } - } - - if (player->lastsidehit != -1 && player->lastlinehit != -1) - { - thinker_t *think; - scroll_t *scroller; - angle_t sideangle; - fixed_t dx, dy; - - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function.acp1 != (actionf_p1)T_Scroll) - continue; - - scroller = (scroll_t *)think; - - if (scroller->type != sc_side) - continue; - - if (scroller->affectee != player->lastsidehit) - continue; - - if (scroller->accel) - { - dx = scroller->vdx; - dy = scroller->vdy; - } - else - { - dx = scroller->dx; - dy = scroller->dy; - } - - if (cmd->forwardmove != 0) - { - player->mo->momz += dy; - climb = true; - } - else - { - player->mo->momz = dy; - climb = false; - } - - sideangle = R_PointToAngle2(lines[player->lastlinehit].v2->x,lines[player->lastlinehit].v2->y,lines[player->lastlinehit].v1->x,lines[player->lastlinehit].v1->y); - - if (cmd->sidemove != 0) - { - P_Thrust(player->mo, sideangle, dx); - climb = true; - } - else - { - P_InstaThrust(player->mo, sideangle, dx); - climb = false; - } - } - } - - if (cmd->sidemove != 0 || cmd->forwardmove != 0) - climb = true; - else - climb = false; - - if (player->climbing && climb && (player->mo->momx || player->mo->momy || player->mo->momz) - && !(player->mo->state >= &states[S_PLAY_CLIMB2] && player->mo->state <= &states[S_PLAY_CLIMB5])) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB2); - else if ((!(player->mo->momx || player->mo->momy || player->mo->momz) || !climb) && player->mo->state != &states[S_PLAY_CLIMB1]) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB1); - - if (!floorclimb) - { - if (boostup) - P_SetObjectMomZ(player->mo, 2*FRACUNIT, true); - if (thrust) - P_InstaThrust(player->mo, player->mo->angle, FixedMul(4*FRACUNIT, player->mo->scale)); // Lil' boost up. - - player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - - if (skyclimber) - { - player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - } - else - { - player->climbing = 0; - player->pflags |= PF_JUMPED; - //P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - - if (cmd->sidemove != 0 || cmd->forwardmove != 0) - climb = true; - else - climb = false; - - if (player->climbing && climb && (player->mo->momx || player->mo->momy || player->mo->momz) - && !(player->mo->state >= &states[S_PLAY_CLIMB2] && player->mo->state <= &states[S_PLAY_CLIMB5])) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB2); - else if ((!(player->mo->momx || player->mo->momy || player->mo->momz) || !climb) && player->mo->state != &states[S_PLAY_CLIMB1]) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB1); - - if (cmd->buttons & BT_BRAKE && !(player->pflags & PF_JUMPSTASIS)) - { - player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - P_SetObjectMomZ(player->mo, 4*FRACUNIT, false); - P_InstaThrust(player->mo, player->mo->angle, FixedMul(-4*FRACUNIT, player->mo->scale)); - } - - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - - if (player->climbing == 0) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - - - if (player->climbing && P_IsObjectOnGround(player->mo)) - { - P_ResetPlayer(player); - P_SetPlayerMobjState(player->mo, S_KART_STND1); // SRB2kart - } -} - -// -// PIT_CheckSolidsTeeter -// AKA: PIT_HacksToStopPlayersTeeteringOnGargoyles -// - -static mobj_t *teeterer; // the player checking for teetering -static boolean solidteeter; // saves whether the player can teeter on this or not -static fixed_t highesttop; // highest floor found so far -// reserved for standing on multiple objects -static boolean couldteeter; -static fixed_t teeterxl, teeterxh; -static fixed_t teeteryl, teeteryh; - -static boolean PIT_CheckSolidsTeeter(mobj_t *thing) // SRB2kart - unused. -{ - fixed_t blockdist; - fixed_t tiptop = FixedMul(MAXSTEPMOVE, mapobjectscale); - fixed_t thingtop = thing->z + thing->height; - fixed_t teeterertop = teeterer->z + teeterer->height; - - if (!teeterer || !thing) - return true; - - if (!(thing->flags & MF_SOLID)) - return true; - - if (thing->flags & MF_NOCLIP) - return true; - - if (thing == teeterer) - return true; - - if (thing->player && cv_tailspickup.value && gametype != GT_HIDEANDSEEK) - return true; - - blockdist = teeterer->radius + thing->radius; - - if (abs(thing->x - teeterer->x) >= blockdist || abs(thing->y - teeterer->y) >= blockdist) - return true; // didn't hit it - - if (teeterer->eflags & MFE_VERTICALFLIP) - { - if (thingtop < teeterer->z) - return true; - if (thing->z > highesttop) - return true; - highesttop = thing->z; - if (thing->z > teeterertop + tiptop) - { - solidteeter = true; - return true; - } - } - else - { - if (thing->z > teeterertop) - return true; - if (thingtop < highesttop) - return true; - highesttop = thingtop; - if (thingtop < teeterer->z - tiptop) - { - solidteeter = true; - return true; - } - } - - // are you standing on this? - if ((teeterer->eflags & MFE_VERTICALFLIP && thing->z - FixedMul(FRACUNIT, teeterer->scale) == teeterertop) - || (!(teeterer->eflags & MFE_VERTICALFLIP) && thingtop + FixedMul(FRACUNIT, teeterer->scale) == teeterer->z)) - { - fixed_t teeterdist = thing->radius - FixedMul(5*FRACUNIT, teeterer->scale); - // how far are you from the edge? - if (abs(teeterer->x - thing->x) > teeterdist || abs(teeterer->y - thing->y) > teeterdist) - { - if (couldteeter) // player is standing on another object already, see if we can stand on both and not teeter! - { - if (thing->x - teeterdist < teeterxl) - teeterxl = thing->x - teeterdist; - if (thing->x + teeterdist > teeterxh) - teeterxh = thing->x + teeterdist; - if (thing->y - teeterdist < teeteryl) - teeteryl = thing->y - teeterdist; - if (thing->y + teeterdist > teeteryh) - teeteryh = thing->y + teeterdist; - - if (teeterer->x < teeterxl) - return true; - if (teeterer->x > teeterxh) - return true; - if (teeterer->y < teeteryl) - return true; - if (teeterer->y > teeteryh) - return true; - - solidteeter = false; // you can stop teetering now! - couldteeter = false; // just in case... - return false; - } - else - { - // too far! don't change teeter status though - // save teeter x/y limits to bring up later - teeterxl = thing->x - teeterdist; - teeterxh = thing->x + teeterdist; - teeteryl = thing->y - teeterdist; - teeteryh = thing->y + teeterdist; - } - couldteeter = true; - return true; - } - solidteeter = false; - couldteeter = false; - return false; // you're definitely not teetering, that's the end of the matter - } - solidteeter = false; - return true; // you're not teetering but it's not neccessarily over, YET -} -*/ - -// -// P_DoTeeter -// -// Handles player teetering -// -/* -static void P_DoTeeter(player_t *player) // SRB2kart - unused. -{ - return; // SRB2kart - don't need - boolean teeter = false; - boolean roverfloor; // solid 3d floors? - fixed_t floorheight, ceilingheight; - fixed_t topheight, bottomheight; // for 3d floor usage - const fixed_t tiptop = FixedMul(MAXSTEPMOVE, mapobjectscale); // Distance you have to be above the ground in order to teeter. - - if (player->mo->standingslope && player->mo->standingslope->zdelta >= (FRACUNIT/2)) // Always teeter if the slope is too steep. - teeter = true; - else // Let's do some checks... - { - UINT8 i; - sector_t *sec; - fixed_t highestceilingheight = INT32_MIN; - fixed_t lowestfloorheight = INT32_MAX; - - teeter = false; - roverfloor = false; - for (i = 0; i < 4; i++) - { - ffloor_t *rover; - -#define xsign ((i & 1) ? -1 : 1) // 0 -> 1 | 1 -> -1 | 2 -> 1 | 3 -> -1 -#define ysign ((i & 2) ? 1 : -1) // 0 -> 1 | 1 -> 1 | 2 -> -1 | 3 -> -1 - fixed_t checkx = player->mo->x + (xsign*FixedMul(5*FRACUNIT, player->mo->scale)); - fixed_t checky = player->mo->y + (ysign*FixedMul(5*FRACUNIT, player->mo->scale)); -#undef xsign -#undef ysign - - sec = R_PointInSubsector(checkx, checky)->sector; - - ceilingheight = sec->ceilingheight; - floorheight = sec->floorheight; - if (sec->c_slope) - ceilingheight = P_GetZAt(sec->c_slope, checkx, checky); - if (sec->f_slope) - floorheight = P_GetZAt(sec->f_slope, checkx, checky); - highestceilingheight = (ceilingheight > highestceilingheight) ? ceilingheight : highestceilingheight; - lowestfloorheight = (floorheight < lowestfloorheight) ? floorheight : lowestfloorheight; - - if (!(sec->ffloors)) - continue; // move on to the next subsector - - for (rover = sec->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) continue; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - if (P_CheckSolidLava(player->mo, rover)) - ; - else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) - continue; // intangible 3d floor - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (bottomheight > ceilingheight) // Above the ceiling - continue; - - if (bottomheight > player->mo->z + player->mo->height + tiptop - || (topheight < player->mo->z - && player->mo->z + player->mo->height < ceilingheight - tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - else - { - if (topheight < floorheight) // Below the floor - continue; - - if (topheight < player->mo->z - tiptop - || (bottomheight > player->mo->z + player->mo->height - && player->mo->z > floorheight + tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - } - break; // break out of loop now, we're done - } - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (!teeter && !roverfloor && (highestceilingheight > player->mo->ceilingz + tiptop)) - teeter = true; - } - else - { - if (!teeter && !roverfloor && (lowestfloorheight < player->mo->floorz - tiptop)) - teeter = true; - } - } - - { - INT32 bx, by, xl, xh, yl, yh; - - yh = (unsigned)(player->mo->y + player->mo->radius - bmaporgy)>>MAPBLOCKSHIFT; - yl = (unsigned)(player->mo->y - player->mo->radius - bmaporgy)>>MAPBLOCKSHIFT; - xh = (unsigned)(player->mo->x + player->mo->radius - bmaporgx)>>MAPBLOCKSHIFT; - xl = (unsigned)(player->mo->x - player->mo->radius - bmaporgx)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - // Polyobjects - validcount++; - - for (by = yl; by <= yh; by++) - for (bx = xl; bx <= xh; bx++) - { - INT32 offset; - polymaplink_t *plink; // haleyjd 02/22/06 - - if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) - continue; - - offset = by*bmapwidth + bx; - - // haleyjd 02/22/06: consider polyobject lines - plink = polyblocklinks[offset]; - - while (plink) - { - polyobj_t *po = plink->po; - - if (po->validcount != validcount) // if polyobj hasn't been checked - { - sector_t *polysec; - fixed_t polytop, polybottom; - - po->validcount = validcount; - - if (!(po->flags & POF_SOLID)) - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - if (!P_MobjInsidePolyobj(po, player->mo)) - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - // We're inside it! Yess... - polysec = po->lines[0]->backsector; - - if (po->flags & POF_CLIPPLANES) - { - polytop = polysec->ceilingheight; - polybottom = polysec->floorheight; - } - else - { - polytop = INT32_MAX; - polybottom = INT32_MIN; - } - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (polybottom > player->mo->ceilingz) // Above the ceiling - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - if (polybottom > player->mo->z + player->mo->height + tiptop - || (polytop < player->mo->z - && player->mo->z + player->mo->height < player->mo->ceilingz - tiptop)) - teeter = true; - else - { - teeter = false; - break; - } - } - else - { - if (polytop < player->mo->floorz) // Below the floor - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - if (polytop < player->mo->z - tiptop - || (polybottom > player->mo->z + player->mo->height - && player->mo->z > player->mo->floorz + tiptop)) - teeter = true; - else - { - teeter = false; - break; - } - } - } - plink = (polymaplink_t *)(plink->link.next); - } - } - if (teeter) // only bother with objects as a last resort if you were already teetering - { - mobj_t *oldtmthing = tmthing; - tmthing = teeterer = player->mo; - teeterxl = teeterxh = player->mo->x; - teeteryl = teeteryh = player->mo->y; - couldteeter = false; - solidteeter = teeter; - for (by = yl; by <= yh; by++) - for (bx = xl; bx <= xh; bx++) - { - highesttop = INT32_MIN; - if (!P_BlockThingsIterator(bx, by, PIT_CheckSolidsTeeter)) - goto teeterdone; // we've found something that stops us teetering at all, how about we stop already - } -teeterdone: - teeter = solidteeter; - tmthing = oldtmthing; // restore old tmthing, goodness knows what the game does with this before mobj thinkers - } - } - if (teeter) - { - if ((player->mo->state == &states[S_PLAY_STND] || player->mo->state == &states[S_PLAY_TAP1] || player->mo->state == &states[S_PLAY_TAP2] || player->mo->state == &states[S_PLAY_SUPERSTAND])) - P_SetPlayerMobjState(player->mo, S_PLAY_TEETER1); - } - else if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) - P_SetPlayerMobjState(player->mo, S_PLAY_STND); -} -*/ - -// -// P_SetWeaponDelay -// -// Sets weapon delay. Properly accounts for Knux's firing rate bonus. -// -/* -static void P_SetWeaponDelay(player_t *player, INT32 delay) // SRB2kart - unused. -{ - player->weapondelay = delay; - - if (player->skin == 2) // Knuckles - { - // Multiply before dividing. - // Loss of precision can make a surprisingly large difference. - player->weapondelay *= 2; - player->weapondelay /= 3; - } -} - -// -// P_DoFiring() -// -// Handles firing ring weapons and Mario fireballs. -// -static void P_DoFiring(player_t *player, ticcmd_t *cmd) // SRB2kart - unused. -{ - INT32 i; - - I_Assert(player != NULL); - I_Assert(!P_MobjWasRemoved(player->mo)); - - if (cmd->buttons & BT_ATTACK) - { - if (!(player->pflags & PF_ATTACKDOWN) && player->powers[pw_shield] & SH_FIREFLOWER && !player->climbing) - { - player->pflags |= PF_ATTACKDOWN; - P_SpawnPlayerMissile(player->mo, MT_FIREBALL, 0); - S_StartSound(player->mo, sfx_mario7); - } - else if (G_BattleGametype() && (!G_TagGametype() || player->pflags & PF_TAGIT) - && !player->weapondelay && !player->climbing - && !(player->pflags & PF_ATTACKDOWN)) - { - mobj_t *mo = NULL; - player->pflags |= PF_ATTACKDOWN; - - //if (cmd->buttons & BT_FIRENORMAL) // No powers, just a regular ring. - // goto firenormal; //code repetition sucks. - // Bounce ring - if (player->currentweapon == WEP_BOUNCE && player->powers[pw_bouncering]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, TICRATE/4); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNBOUNCE, MF2_BOUNCERING); - - if (mo) - mo->fuse = 3*TICRATE; // Bounce Ring time - - player->powers[pw_bouncering]--; - player->mo->health--; - player->health--; - } - // Rail ring - else if (player->currentweapon == WEP_RAIL && player->powers[pw_railring]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, (3*TICRATE)/2); - - mo = P_SpawnPlayerMissile(player->mo, MT_REDRING, MF2_RAILRING|MF2_DONTDRAW); - - // Rail has no unique thrown object, therefore its sound plays here. - S_StartSound(player->mo, sfx_rail1); - - player->powers[pw_railring]--; - player->mo->health--; - player->health--; - } - // Automatic - else if (player->currentweapon == WEP_AUTO && player->powers[pw_automaticring]) - { - if (player->health <= 1) - return; - player->pflags &= ~PF_ATTACKDOWN; - P_SetWeaponDelay(player, 2); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNAUTOMATIC, MF2_AUTOMATIC); - - player->powers[pw_automaticring]--; - player->mo->health--; - player->health--; - } - // Explosion - else if (player->currentweapon == WEP_EXPLODE && player->powers[pw_explosionring]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, (3*TICRATE)/2); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNEXPLOSION, MF2_EXPLOSION); - - player->powers[pw_explosionring]--; - player->mo->health--; - player->health--; - } - // Grenade - else if (player->currentweapon == WEP_GRENADE && player->powers[pw_grenadering]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, TICRATE/3); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNGRENADE, MF2_EXPLOSION); - - if (mo) - { - //P_InstaThrust(mo, player->mo->angle, FixedMul(mo->info->speed, player->mo->scale)); - mo->fuse = mo->info->mass; - } - - player->powers[pw_grenadering]--; - player->mo->health--; - player->health--; - } - // Scatter - // Note: Ignores MF2_RAILRING - else if (player->currentweapon == WEP_SCATTER && player->powers[pw_scatterring]) - { - fixed_t oldz = player->mo->z; - angle_t shotangle = player->mo->angle; - angle_t oldaiming = player->aiming; - - if (player->health <= 1) - return; - P_SetWeaponDelay(player, (2*TICRATE)/3); - - // Center - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNSCATTER, MF2_SCATTER); - if (mo) - shotangle = R_PointToAngle2(player->mo->x, player->mo->y, mo->x, mo->y); - - // Left - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle-ANG2, true, MF2_SCATTER); - - // Right - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle+ANG2, true, MF2_SCATTER); - - // Down - player->mo->z += FixedMul(12*FRACUNIT, player->mo->scale); - player->aiming += ANG1; - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle, true, MF2_SCATTER); - - // Up - player->mo->z -= FixedMul(24*FRACUNIT, player->mo->scale); - player->aiming -= ANG2; - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle, true, MF2_SCATTER); - - player->mo->z = oldz; - player->aiming = oldaiming; - - player->powers[pw_scatterring]--; - player->mo->health--; - player->health--; - return; - } - // No powers, just a regular ring. - else - { -//firenormal: - // Infinity ring was selected. - // Mystic wants this ONLY to happen specifically if it's selected, - // and to not be able to get around it EITHER WAY with firenormal. - - // Infinity Ring - if (player->currentweapon == 0 - && player->powers[pw_infinityring]) - { - P_SetWeaponDelay(player, TICRATE/4); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNINFINITY, 0); - - player->powers[pw_infinityring]--; - } - // Red Ring - else - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, TICRATE/4); - - mo = P_SpawnPlayerMissile(player->mo, MT_REDRING, 0); - - if (mo) - P_ColorTeamMissile(mo, player); - - player->mo->health--; - player->health--; - } - } - - if (mo) - { - if (mo->flags & MF_MISSILE && mo->flags2 & MF2_RAILRING) - { - const boolean nblockmap = !(mo->flags & MF_NOBLOCKMAP); - for (i = 0; i < 256; i++) - { - if (nblockmap) - { - P_UnsetThingPosition(mo); - mo->flags |= MF_NOBLOCKMAP; - P_SetThingPosition(mo); - } - - if (i&1) - P_SpawnMobj(mo->x, mo->y, mo->z, MT_SPARK); - - if (P_RailThinker(mo)) - break; // mobj was removed (missile hit a wall) or couldn't move - } - - // Other rail sound plays at contact point. - S_StartSound(mo, sfx_rail2); - } - } - } - return; - } - - // Not holding any firing buttons anymore. - // Release the grenade / whatever. - player->pflags &= ~PF_ATTACKDOWN; -} -*/ - -// -// P_DoSpinDash -// -// Player spindash handling -// -/* -static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) // SRB2kart - unused. -{ - return; // SRB2kart - what's a spindash? - if (player->pflags & PF_STASIS) - return; - -#ifdef HAVE_BLUA - if (cmd->buttons & BT_BRAKE) - { - if (LUAh_SpinSpecial(player)) - return; - } -#endif - - // Spinning and Spindashing - if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SLIDING) && !player->exiting - && !P_PlayerInPain(player)) // subsequent revs - { - if ((cmd->buttons & BT_BRAKE) && player->speed < FixedMul(5<mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING) - && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) - ) - { - player->mo->momx = player->cmomx; - player->mo->momy = player->cmomy; - player->pflags |= PF_STARTDASH|PF_SPINNING; - player->dashspeed = FixedMul(FRACUNIT, player->mo->scale); - player->dashtime = 0; - //P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - player->pflags |= PF_USEDOWN; - } - else if ((cmd->buttons & BT_BRAKE) && (player->pflags & PF_STARTDASH)) - { - player->dashspeed += FixedMul(FRACUNIT, player->mo->scale); - - if (!(player->dashtime++ % 5)) - { - if (!player->spectator && player->dashspeed < FixedMul(player->maxdash, player->mo->scale)) - S_StartSound(player->mo, sfx_spndsh); // Make the rev sound! - - // Now spawn the color thok circle. - P_SpawnSpinMobj(player, player->revitem); - if (demo.recording) - G_GhostAddRev((INT32) (player - players)); - } - } - // If not moving up or down, and travelling faster than a speed of four while not holding - // down the spin button and not spinning. - // AKA Just go into a spin on the ground, you idiot. ;) - else if ((cmd->buttons & BT_BRAKE || ((twodlevel || (player->mo->flags2 & MF2_TWOD)) && cmd->forwardmove < -20)) - && !player->climbing && !player->mo->momz && onground && (player->speed > FixedMul(5<mo->scale) - || (player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) - ) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING)) - { - player->pflags |= PF_SPINNING; - //P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - if (!player->spectator) - S_StartSound(player->mo, sfx_spin); - player->pflags |= PF_USEDOWN; - } - } - - // Rolling normally - if (onground && player->pflags & PF_SPINNING && !(player->pflags & PF_STARTDASH) - && player->speed < FixedMul(5*FRACUNIT,player->mo->scale) - && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) - ) - { - if (GETSECSPECIAL(player->mo->subsector->sector->special, 4) == 7 || (player->mo->ceilingz - player->mo->floorz < P_GetPlayerHeight(player))) - P_InstaThrust(player->mo, player->mo->angle, FixedMul(10*FRACUNIT, player->mo->scale)); - else - { - player->skidtime = 0; - player->pflags &= ~PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_KART_STND1); - player->mo->momx = player->cmomx; - player->mo->momy = player->cmomy; - } - } - - // Catapult the player from a spindash rev! - if (onground && !(player->pflags & PF_USEDOWN) && player->dashspeed && (player->pflags & PF_STARTDASH) && (player->pflags & PF_SPINNING)) - { - if (player->powers[pw_ingoop]) - player->dashspeed = 0; - - player->pflags &= ~PF_STARTDASH; - if (!((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE)) - { - P_InstaThrust(player->mo, player->mo->angle, player->dashspeed); // catapult forward ho!! - if (!player->spectator) - S_StartSound(player->mo, sfx_zoom); - } - player->dashspeed = 0; - } - - //if (onground && (player->pflags & PF_SPINNING) && !(player->panim == PA_ROLL)) - // P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); -} -*/ // // P_DoJumpShield @@ -3786,266 +1909,6 @@ boolean P_AnalogMove(player_t *player) return player->pflags & PF_ANALOGMODE; } -// -// P_GetPlayerControlDirection -// -// Determines if the player is pressing in the direction they are moving -// -// 0 = no controls pressed/no movement -// 1 = pressing in the direction of movement -// 2 = pressing in the opposite direction of movement -// -/*INT32 P_GetPlayerControlDirection(player_t *player) -{ - ticcmd_t *cmd = &player->cmd; - angle_t controllerdirection, controlplayerdirection; - camera_t *thiscam; - angle_t dangle; - fixed_t tempx = 0, tempy = 0; - angle_t tempangle, origtempangle; - - if (splitscreen > 2 && player == &players[displayplayers[3]]) - thiscam = &camera[3]; - else if (splitscreen > 1 && player == &players[displayplayers[2]]) - thiscam = &camera[2]; - else if (splitscreen && player == &players[displayplayers[1]]) - thiscam = &camera[1]; - else - thiscam = &camera[0]; - - if (!cmd->forwardmove && !cmd->sidemove) - return 0; - - if (!player->mo->momx && !player->mo->momy) - return 0; - - if (twodlevel || player->mo->flags2 & MF2_TWOD) - { - if (!cmd->sidemove) - return 0; - if (!player->mo->momx) - return 0; - origtempangle = tempangle = 0; // relative to the axis rather than the player! - controlplayerdirection = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - } - else if (P_AnalogMove(player) && thiscam->chase) - { - if (player->awayviewtics) - origtempangle = tempangle = player->awayviewmobj->angle; - else - origtempangle = tempangle = thiscam->angle; - controlplayerdirection = player->mo->angle; - } - else - { - origtempangle = tempangle = player->mo->angle; - controlplayerdirection = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - } - - // Calculate the angle at which the controls are pointing - // to figure out the proper mforward and mbackward. - tempangle >>= ANGLETOFINESHIFT; - if (!(twodlevel || player->mo->flags2 & MF2_TWOD)) // in 2d mode, sidemove is treated as the forwards/backwards direction - { - tempx += FixedMul(cmd->forwardmove*FRACUNIT,FINECOSINE(tempangle)); - tempy += FixedMul(cmd->forwardmove*FRACUNIT,FINESINE(tempangle)); - - tempangle = origtempangle-ANGLE_90; - tempangle >>= ANGLETOFINESHIFT; - } - tempx += FixedMul(cmd->sidemove*FRACUNIT,FINECOSINE(tempangle)); - tempy += FixedMul(cmd->sidemove*FRACUNIT,FINESINE(tempangle)); - - controllerdirection = R_PointToAngle2(0, 0, tempx, tempy); - - dangle = controllerdirection - controlplayerdirection; - - if (dangle > ANGLE_180) //flip to keep to one side - dangle = InvAngle(dangle); - - if (dangle > ANGLE_90) - return 2; // Controls pointing backwards from player - else - return 1; // Controls pointing in player's general direction -} - -// Control scheme for 2d levels. -static void P_2dMovement(player_t *player) -{ - ticcmd_t *cmd; - INT32 topspeed, acceleration, thrustfactor; - fixed_t movepushforward = 0; - angle_t movepushangle = 0; - fixed_t normalspd = FixedMul(player->normalspeed, player->mo->scale); - - cmd = &player->cmd; - - if (player->exiting || player->pflags & PF_STASIS) - { - cmd->forwardmove = cmd->sidemove = 0; - if (player->pflags & PF_GLIDING) - { - if (!player->skidtime) - player->pflags &= ~PF_GLIDING; - else if (player->exiting) - { - player->pflags &= ~PF_GLIDING; - P_SetPlayerMobjState(player->mo, S_KART_WALK1); // SRB2kart - was S_PLAY_RUN1 - player->skidtime = 0; - } - } - if (player->pflags & PF_SPINNING && !player->exiting) - { - player->pflags &= ~PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND - } - } - - // cmomx/cmomy stands for the conveyor belt speed. - if (player->onconveyor == 2) // Wind/Current - { - //if (player->mo->z > player->mo->watertop || player->mo->z + player->mo->height < player->mo->waterbottom) - if (!(player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) - player->cmomx = player->cmomy = 0; - } - else if (player->onconveyor == 4 && !P_IsObjectOnGround(player->mo)) // Actual conveyor belt - player->cmomx = player->cmomy = 0; - else if (player->onconveyor != 2 && player->onconveyor != 4 - && player->onconveyor != 1 - ) - player->cmomx = player->cmomy = 0; - - player->rmomx = player->mo->momx - player->cmomx; - player->rmomy = player->mo->momy - player->cmomy; - - // Calculates player's speed based on absolute-value-of-a-number formula - player->speed = abs(player->rmomx); - - if (player->pflags & PF_GLIDING) - { - // Angle fix. - if (player->mo->angle < ANGLE_180 && player->mo->angle > ANGLE_90) - player->mo->angle = ANGLE_180; - else if (player->mo->angle < ANGLE_90 && player->mo->angle > 0) - player->mo->angle = 0; - - if (cmd->sidemove > 0 && player->mo->angle != 0 && player->mo->angle >= ANGLE_180) - player->mo->angle += 1280<sidemove < 0 && player->mo->angle != ANGLE_180 && (player->mo->angle > ANGLE_180 || player->mo->angle == 0)) - player->mo->angle -= 1280<sidemove == 0) - { - if (player->mo->angle >= ANGLE_270) - player->mo->angle += 1280<mo->angle < ANGLE_270 && player->mo->angle > ANGLE_180) - player->mo->angle -= 1280<sidemove && !(player->climbing) && !P_PlayerInPain(player)) - { - if (cmd->sidemove > 0) - player->mo->angle = 0; - else if (cmd->sidemove < 0) - player->mo->angle = ANGLE_180; - } - - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - - if (player->pflags & PF_GLIDING) - movepushangle = player->mo->angle; - else - { - if (cmd->sidemove > 0) - movepushangle = 0; - else if (cmd->sidemove < 0) - movepushangle = ANGLE_180; - else - movepushangle = player->mo->angle; - } - - // Do not let the player control movement if not onground. - onground = P_IsObjectOnGround(player->mo); - - player->aiming = cmd->aiming<powers[pw_super] || player->powers[pw_sneakers]) - { - thrustfactor = player->thrustfactor*2; - acceleration = player->accelstart/2 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration/2; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER) && !(player->pflags & PF_SLIDING)) - { - topspeed = normalspd; - acceleration = 2*acceleration/3; - } - else - topspeed = normalspd * 2; - } - else - { - thrustfactor = player->thrustfactor; - acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd/2; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER) && !(player->pflags & PF_SLIDING)) - { - topspeed = normalspd/2; - acceleration = 2*acceleration/3; - } - else - topspeed = normalspd; - } - -////////////////////////////////////// - if (player->climbing) - { - if (cmd->forwardmove != 0) - P_SetObjectMomZ(player->mo, FixedDiv(cmd->forwardmove*FRACUNIT,10*FRACUNIT), false); - - if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - player->mo->momz *= 2; - - player->mo->momx = 0; - } - else if (cmd->sidemove != 0 && !(player->pflags & PF_GLIDING || player->exiting - || (P_PlayerInPain(player) && !onground))) - { - movepushforward = abs(cmd->sidemove) * (thrustfactor * acceleration); - - // allow very small movement while in air for gameplay - if (!onground) - movepushforward >>= 1; // Proper air movement - - // Allow a bit of movement while spinning - if (player->pflags & PF_SPINNING) - { - if (!(player->pflags & PF_STARTDASH)) - movepushforward = movepushforward/48; - else - movepushforward = 0; - } - - movepushforward = FixedMul(movepushforward, player->mo->scale); - if (player->rmomx < topspeed && cmd->sidemove > 0) // Sonic's Speed - P_Thrust(player->mo, movepushangle, movepushforward); - else if (player->rmomx > -topspeed && cmd->sidemove < 0) - P_Thrust(player->mo, movepushangle, movepushforward); - } -}*/ //#define OLD_MOVEMENT_CODE 1 static void P_3dMovement(player_t *player) @@ -4302,1291 +2165,6 @@ static void P_SpectatorMovement(player_t *player) }*/ } -// -// P_ShootLine -// -// Fun and fancy -// graphical indicator -// for building/debugging -// NiGHTS levels! -/*static void P_ShootLine(mobj_t *source, mobj_t *dest, fixed_t height) -{ - mobj_t *mo; - INT32 i; - fixed_t temp; - INT32 speed, seesound; - - temp = dest->z; - dest->z = height; - - seesound = mobjinfo[MT_REDRING].seesound; - speed = mobjinfo[MT_REDRING].speed; - mobjinfo[MT_REDRING].seesound = sfx_None; - mobjinfo[MT_REDRING].speed = 20*FRACUNIT; - - mo = P_SpawnXYZMissile(source, dest, MT_REDRING, source->x, source->y, height); - - dest->z = temp; - if (mo) - { - mo->flags2 |= MF2_RAILRING; - mo->flags2 |= MF2_DONTDRAW; - mo->flags |= MF_NOCLIPHEIGHT; - mo->flags |= MF_NOCLIP; - mo->flags &= ~MF_MISSILE; - mo->fuse = 3; - } - - for (i = 0; i < 32; i++) - { - if (mo) - { - if (!(mo->flags & MF_NOBLOCKMAP)) - { - P_UnsetThingPosition(mo); - mo->flags |= MF_NOBLOCKMAP; - P_SetThingPosition(mo); - } - if (i&1) - P_SpawnMobj(mo->x, mo->y, mo->z, MT_SPARK); - - P_UnsetThingPosition(mo); - mo->x += mo->momx; - mo->y += mo->momy; - mo->z += mo->momz; - P_SetThingPosition(mo); - } - else - { - mobjinfo[MT_REDRING].seesound = seesound; - mobjinfo[MT_REDRING].speed = speed; - return; - } - } - mobjinfo[MT_REDRING].seesound = seesound; - mobjinfo[MT_REDRING].speed = speed; -} - -#define MAXDRILLSPEED 14000 -#define MAXNORMALSPEED 6250 //6000 - -static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t radius) -{ - if (player->pflags & PF_TRANSFERTOCLOSEST) - { - const angle_t fa = R_PointToAngle2(player->axis1->x, player->axis1->y, player->axis2->x, player->axis2->y); - P_InstaThrust(player->mo, fa, xspeed/10); - } - else - { - const angle_t fa = player->angle_pos>>ANGLETOFINESHIFT; - const angle_t faold = player->old_angle_pos>>ANGLETOFINESHIFT; - player->mo->momx = FixedMul(FINECOSINE(fa),radius) - FixedMul(FINECOSINE(faold),radius); - player->mo->momy = FixedMul(FINESINE(fa),radius) - FixedMul(FINESINE(faold),radius); - } - - if (player->exiting) - return; - - // You're welcome, Rob. (Now with slightly less horrendous hacking -Red - player->mo->tracer->flags &= ~MF_NOCLIP; - player->mo->tracer->z = player->mo->z; - if (!P_TryMove(player->mo->tracer, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, true)) { - player->mo->tracer->flags |= MF_NOCLIP; - return; - } - player->mo->tracer->flags |= MF_NOCLIP; - { - const INT32 sequence = player->mo->target->threshold; - mobj_t *transfer1 = NULL; - mobj_t *transfer2 = NULL; - mobj_t *axis; - mobj_t *mo2; - thinker_t *th; - line_t transfer1line; - line_t transfer2line; - boolean transfer1last = false; - boolean transfer2last = false; - vertex_t vertices[4]; - fixed_t truexspeed = xspeed*(!(player->pflags & PF_TRANSFERTOCLOSEST) && player->mo->target->flags2 & MF2_AMBUSH ? -1 : 1); - - // Find next waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - // Axis things are only at beginning of list. - if (!(mo2->flags2 & MF2_AXIS)) - break; - - if ((mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE) - && mo2->threshold == sequence) - { - if (player->pflags & PF_TRANSFERTOCLOSEST) - { - if (mo2->health == player->axis1->health) - transfer1 = mo2; - else if (mo2->health == player->axis2->health) - transfer2 = mo2; - } - else - { - if (mo2->health == player->mo->target->health) - transfer1 = mo2; - else if (mo2->health == player->mo->target->health + 1) - transfer2 = mo2; - } - } - } - - // It might be possible that one wasn't found. - // Is it because we're at the end of the track? - // Look for a wrapper point. - if (!transfer1) - { - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - // Axis things are only at beginning of list. - if (!(mo2->flags2 & MF2_AXIS)) - break; - - if (mo2->threshold == sequence && (mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE)) - { - if (!transfer1) - { - transfer1 = mo2; - transfer1last = true; - } - else if (mo2->health > transfer1->health) - { - transfer1 = mo2; - transfer1last = true; - } - } - } - } - if (!transfer2) - { - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - // Axis things are only at beginning of list. - if (!(mo2->flags2 & MF2_AXIS)) - break; - - if (mo2->threshold == sequence && (mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE)) - { - if (!transfer2) - { - transfer2 = mo2; - transfer2last = true; - } - else if (mo2->health > transfer2->health) - { - transfer2 = mo2; - transfer2last = true; - } - } - } - } - - if (!(transfer1 && transfer2)) // We can't continue... - I_Error("Mare does not form a complete circuit!\n"); - - transfer1line.v1 = &vertices[0]; - transfer1line.v2 = &vertices[1]; - transfer2line.v1 = &vertices[2]; - transfer2line.v2 = &vertices[3]; - - if (cv_debug && (leveltime % TICRATE == 0)) - { - CONS_Debug(DBG_NIGHTS, "Transfer1 : %d\n", transfer1->health); - CONS_Debug(DBG_NIGHTS, "Transfer2 : %d\n", transfer2->health); - } - //CONS_Debug(DBG_NIGHTS, "Xspeed : %d", truexspeed); - - //CONS_Debug(DBG_NIGHTS, "T1 is at %d, %d\n", transfer1->x>>FRACBITS, transfer1->y>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "T2 is at %d, %d\n", transfer2->x>>FRACBITS, transfer2->y>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "Distance from T1: %d\n", P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "Distance from T2: %d\n", P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS); - - // Transfer1 is closer to the player than transfer2 - if (P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS - < P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS) - { - //CONS_Debug(DBG_NIGHTS, " must be < 0 to transfer\n"); - - if (transfer1->type == MT_AXISTRANSFERLINE) - { - if (transfer1last) - axis = P_FindAxis(transfer1->threshold, transfer1->health-2); - else if (player->pflags & PF_TRANSFERTOCLOSEST) - axis = P_FindAxis(transfer1->threshold, transfer1->health-1); - else - axis = P_FindAxis(transfer1->threshold, transfer1->health); - - if (!axis) - { - CONS_Debug(DBG_NIGHTS, "Unable to find an axis - error code #1\n"); - return; - } - - //CONS_Debug(DBG_NIGHTS, "Drawing a line from %d to ", axis->health); - - transfer1line.v1->x = axis->x; - transfer1line.v1->y = axis->y; - - transfer1line.v2->x = transfer1->x; - transfer1line.v2->y = transfer1->y; - - if (cv_debug & DBG_NIGHTS) - P_ShootLine(axis, transfer1, player->mo->z); - - //CONS_Debug(DBG_NIGHTS, "closest %d\n", transfer1->health); - - transfer1line.dx = transfer1line.v2->x - transfer1line.v1->x; - transfer1line.dy = transfer1line.v2->y - transfer1line.v1->y; - - if (P_PointOnLineSide(player->mo->x, player->mo->y, &transfer1line) - != P_PointOnLineSide(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, &transfer1line) - && truexspeed < 0) - { - if (cv_debug & DBG_NIGHTS) - { - HU_SetCEchoDuration(1); - HU_DoCEcho("transfer!"); - HU_SetCEchoDuration(5); - S_StartSound(NULL, sfx_strpst); - } - if (player->pflags & PF_TRANSFERTOCLOSEST) - { - player->pflags &= ~PF_TRANSFERTOCLOSEST; - P_TransferToAxis(player, transfer1->health - 1); - } - else - { - player->pflags |= PF_TRANSFERTOCLOSEST; - P_SetTarget(&player->axis2, transfer1); - P_SetTarget(&player->axis1, P_FindAxisTransfer(transfer1->threshold, transfer1->health-1, MT_AXISTRANSFERLINE));//P_FindAxis(transfer1->threshold, axis->health-2); - } - } - } - else - { - // Transfer1 - if (transfer1last) - axis = P_FindAxis(transfer1->threshold, 1); - else - axis = P_FindAxis(transfer1->threshold, transfer1->health); - - if (!axis) - { - CONS_Debug(DBG_NIGHTS, "Unable to find an axis - error code #2\n"); - return; - } - - //CONS_Debug(DBG_NIGHTS, "Drawing a line from %d to ", axis->health); - - transfer1line.v1->x = axis->x; - transfer1line.v1->y = axis->y; - - if (cv_debug & DBG_NIGHTS) - P_ShootLine(transfer1, P_FindAxis(transfer1->threshold, transfer1->health-1), player->mo->z); - - //axis = P_FindAxis(transfer1->threshold, transfer1->health-1); - - //CONS_Debug(DBG_NIGHTS, "%d\n", axis->health); - - transfer1line.v2->x = transfer1->x; - transfer1line.v2->y = transfer1->y; - - transfer1line.dx = transfer1line.v2->x - transfer1line.v1->x; - transfer1line.dy = transfer1line.v2->y - transfer1line.v1->y; - - if (P_PointOnLineSide(player->mo->x, player->mo->y, &transfer1line) - != P_PointOnLineSide(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, &transfer1line) - && truexspeed < 0) - { - if (cv_debug & DBG_NIGHTS) - { - HU_SetCEchoDuration(1); - HU_DoCEcho("transfer!"); - HU_SetCEchoDuration(5); - S_StartSound(NULL, sfx_strpst); - } - if (player->mo->target->health < transfer1->health) - { - // Find the next axis with a ->health - // +1 from the current axis. - if (transfer1last) - P_TransferToAxis(player, transfer1->health - 1); - else - P_TransferToAxis(player, transfer1->health); - } - else if (player->mo->target->health >= transfer1->health) - { - // Find the next axis with a ->health - // -1 from the current axis. - P_TransferToAxis(player, transfer1->health - 1); - } - } - } - } - else - { - //CONS_Debug(DBG_NIGHTS, " must be > 0 to transfer\n"); - if (transfer2->type == MT_AXISTRANSFERLINE) - { - if (transfer2last) - axis = P_FindAxis(transfer2->threshold, 1); - else if (player->pflags & PF_TRANSFERTOCLOSEST) - axis = P_FindAxis(transfer2->threshold, transfer2->health); - else - axis = P_FindAxis(transfer2->threshold, transfer2->health - 1); - - if (!axis) - axis = P_FindAxis(transfer2->threshold, 1); - - if (!axis) - { - CONS_Debug(DBG_NIGHTS, "Unable to find an axis - error code #3\n"); - return; - } - - //CONS_Debug(DBG_NIGHTS, "Drawing a line from %d to ", axis->health); - - transfer2line.v1->x = axis->x; - transfer2line.v1->y = axis->y; - - transfer2line.v2->x = transfer2->x; - transfer2line.v2->y = transfer2->y; - - //CONS_Debug(DBG_NIGHTS, "closest %d\n", transfer2->health); - - if (cv_debug & DBG_NIGHTS) - P_ShootLine(axis, transfer2, player->mo->z); - - transfer2line.dx = transfer2line.v2->x - transfer2line.v1->x; - transfer2line.dy = transfer2line.v2->y - transfer2line.v1->y; - - if (P_PointOnLineSide(player->mo->x, player->mo->y, &transfer2line) - != P_PointOnLineSide(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, &transfer2line) - && truexspeed > 0) - { - if (cv_debug & DBG_NIGHTS) - { - HU_SetCEchoDuration(1); - HU_DoCEcho("transfer!"); - HU_SetCEchoDuration(5); - S_StartSound(NULL, sfx_strpst); - } - if (player->pflags & PF_TRANSFERTOCLOSEST) - { - player->pflags &= ~PF_TRANSFERTOCLOSEST; - - if (!P_FindAxis(transfer2->threshold, transfer2->health)) - transfer2last = true; - - if (transfer2last) - P_TransferToAxis(player, 1); - else - P_TransferToAxis(player, transfer2->health); - } - else - { - player->pflags |= PF_TRANSFERTOCLOSEST; - P_SetTarget(&player->axis1, transfer2); - P_SetTarget(&player->axis2, P_FindAxisTransfer(transfer2->threshold, transfer2->health+1, MT_AXISTRANSFERLINE));//P_FindAxis(transfer2->threshold, axis->health + 2); - } - } - } - else - { - // Transfer2 - if (transfer2last) - axis = P_FindAxis(transfer2->threshold, 1); - else - axis = P_FindAxis(transfer2->threshold, transfer2->health); - - if (!axis) - axis = P_FindAxis(transfer2->threshold, 1); - - if (!axis) - { - CONS_Debug(DBG_NIGHTS, "Unable to find an axis - error code #4\n"); - return; - } - - //CONS_Debug(DBG_NIGHTS, "Drawing a line from %d to ", axis->health); - - transfer2line.v1->x = axis->x; - transfer2line.v1->y = axis->y; - - if (cv_debug & DBG_NIGHTS) - P_ShootLine(transfer2, P_FindAxis(transfer2->threshold, transfer2->health-1), player->mo->z); - - //axis = P_FindAxis(transfer2->threshold, transfer2->health-1); - - //CONS_Debug(DBG_NIGHTS, "%d\n", axis->health); - - transfer2line.v2->x = transfer2->x; - transfer2line.v2->y = transfer2->y; - - transfer2line.dx = transfer2line.v2->x - transfer2line.v1->x; - transfer2line.dy = transfer2line.v2->y - transfer2line.v1->y; - - if (P_PointOnLineSide(player->mo->x, player->mo->y, &transfer2line) - != P_PointOnLineSide(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, &transfer2line) - && truexspeed > 0) - { - if (cv_debug & DBG_NIGHTS) - { - HU_SetCEchoDuration(1); - HU_DoCEcho("transfer!"); - HU_SetCEchoDuration(5); - S_StartSound(NULL, sfx_strpst); - } - if (player->mo->target->health < transfer2->health) - { - if (!P_FindAxis(transfer2->threshold, transfer2->health)) - transfer2last = true; - - if (transfer2last) - P_TransferToAxis(player, 1); - else - P_TransferToAxis(player, transfer2->health); - } - else if (player->mo->target->health >= transfer2->health) - P_TransferToAxis(player, transfer2->health - 1); - } - } - } - } -} - -// -// P_DoNiGHTSCapsule -// -// Handles blowing up the Ideya (emerald) capsule for NiGHTS mode -// -static void P_DoNiGHTSCapsule(player_t *player) -{ - INT32 i; - - if ((player->pflags & PF_NIGHTSMODE) && (player->mo->tracer->state < &states[S_NIGHTSHURT1] - || player->mo->tracer->state > &states[S_NIGHTSHURT32])) - P_SetMobjState(player->mo->tracer, S_NIGHTSHURT1); - - if (abs(player->mo->x-player->capsule->x) <= 2*FRACUNIT) - { - P_UnsetThingPosition(player->mo); - player->mo->x = player->capsule->x; - P_SetThingPosition(player->mo); - player->mo->momx = 0; - } - - if (abs(player->mo->y-player->capsule->y) <= 2*FRACUNIT) - { - P_UnsetThingPosition(player->mo); - player->mo->y = player->capsule->y; - P_SetThingPosition(player->mo); - player->mo->momy = 0; - } - - if (abs(player->mo->z - (player->capsule->z+(player->capsule->height/3))) <= 2*FRACUNIT) - { - player->mo->z = player->capsule->z+(player->capsule->height/3); - player->mo->momz = 0; - } - - if (player->mo->x > player->capsule->x) - player->mo->momx = -2*FRACUNIT; - else if (player->mo->x < player->capsule->x) - player->mo->momx = 2*FRACUNIT; - - if (player->mo->y > player->capsule->y) - player->mo->momy = -2*FRACUNIT; - else if (player->mo->y < player->capsule->y) - player->mo->momy = 2*FRACUNIT; - - if (player->mo->z > player->capsule->z+(player->capsule->height/3)) - player->mo->momz = -2*FRACUNIT; - else if (player->mo->z < player->capsule->z+(player->capsule->height/3)) - player->mo->momz = 2*FRACUNIT; - - if (G_IsSpecialStage(gamemap)) - { // In special stages, share rings. Everyone gives up theirs to the capsule player always, because we can't have any individualism here! - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (&players[i] != player) && players[i].mo->health > 1) - { - player->mo->health += players[i].mo->health-1; - player->health = player->mo->health; - players[i].mo->health = 1; - players[i].health = players[i].mo->health; - } - } - - // Time to blow it up! - if (player->mo->x == player->capsule->x - && player->mo->y == player->capsule->y - && player->mo->z == player->capsule->z+(player->capsule->height/3)) - { - if (player->mo->health > 1) - { - player->mo->health--; - player->health--; - player->capsule->health--; - player->capsule->extravalue1++; - - // Spawn a 'pop' for every 5 rings you deposit - if (!(player->capsule->extravalue1 % 5)) - S_StartSound(P_SpawnMobj(player->capsule->x + ((P_SignedRandom()/2)<capsule->y + ((P_SignedRandom()/2)<capsule->z + (player->capsule->height/2) + ((P_SignedRandom()/2)<capsule->health <= 0) - { - player->capsule->flags &= ~MF_NOGRAVITY; - player->capsule->momz = 5*FRACUNIT; - player->capsule->reactiontime = 0; - player->capsule->extravalue1 = -1; - - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !player->exiting && players[i].mare == player->mare) - { - players[i].bonustime = true; - players[i].texttimer = 4*TICRATE; - players[i].textvar = 1; // Time Bonus - players[i].finishedtime = players[i].nightstime; - if (!G_IsSpecialStage(gamemap)) - P_AddPlayerScore(&players[i], (players[i].finishedtime/TICRATE) * 100); - P_FlashPal(&players[i], PAL_WHITE, 8); - } - - if (G_IsSpecialStage(gamemap)) - { - // The Chaos Emerald begins to orbit us! - mobj_t *emmo; - UINT8 em = P_GetNextEmerald(); - tic_t lowest_time; - - if (player->mo->tracer) - { - // Only give it to ONE person, and THAT player has to get to the goal! - emmo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->info->height, MT_GOTEMERALD); - P_SetTarget(&emmo->target, player->mo); - P_SetMobjState(emmo, mobjinfo[MT_GOTEMERALD].meleestate + em); - P_SetTarget(&player->mo->tracer->target, emmo); - } - - // Okay, we're doing this down here because we're handling time weirdly for co-op special stages - // and because P_AddPlayerScore gives score to everyone in co-op special stages. - // Find the player with the lowest time remaining and award points based on that time instead. - lowest_time = player->finishedtime; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - if (players[i].finishedtime < lowest_time) - lowest_time = players[i].finishedtime; - P_AddPlayerScore(player, (lowest_time/TICRATE) * 100); - } - else - { - fixed_t z; - - z = player->capsule->z + player->capsule->height/2; - for (i = 0; i < 16; i++) - P_SpawnMobj(player->capsule->x, player->capsule->y, z, MT_BIRD); - } - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mare == player->mare) - P_SetTarget(&players[i].capsule, NULL); // Remove capsule from everyone now that it is dead! - S_StartScreamSound(player->mo, sfx_ngdone); - } - } - else - { - S_StartScreamSound(player->mo, sfx_lose); - player->texttimer = 4*TICRATE; - player->textvar = 3; // Get more rings! - player->capsule->reactiontime = 0; - player->capsule->extravalue1 = -1; - } - } - else - player->capsule->extravalue1 = -1; -} - -// -// P_NiGHTSMovement -// -// Movement code for NiGHTS! -// -static void P_NiGHTSMovement(player_t *player) -{ - fixed_t drillamt = 0; - boolean still = false, moved = false, backwardaxis = false, firstdrill; - INT16 newangle = 0; - fixed_t xspeed, yspeed; - thinker_t *th; - mobj_t *mo2; - mobj_t *closestaxis = NULL; - fixed_t newx, newy, radius; - angle_t movingangle; - ticcmd_t *cmd = &player->cmd; - INT32 thrustfactor; - INT32 i; - statenum_t flystate = S_NIGHTSFLY1A; - - player->pflags &= ~PF_DRILLING; - - firstdrill = false; - - if (player->drillmeter > 96*20) - player->drillmeter = 96*20; - - if (player->drilldelay) - player->drilldelay--; - - if (!(cmd->buttons & BT_DRIFT)) - { - // Always have just a TINY bit of drill power. - if (player->drillmeter <= 0) - player->drillmeter = TICRATE/10; - } - - if (!player->mo->tracer) - { - P_DeNightserizePlayer(player); - return; - } - - if (G_IsSpecialStage(gamemap)) - { - boolean capsule = false; - // NiGHTS special stages have a pseudo-shared timer, so check if ANYONE is feeding the capsule. - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] - && (players[i].capsule && players[i].capsule->reactiontime)) - capsule = true; - if (!capsule - && !(player->mo->tracer->state >= &states[S_SUPERTRANS1] - && player->mo->tracer->state <= &states[S_SUPERTRANS9]) - && !player->exiting) - player->nightstime--; - } - else if (!G_RaceGametype() - && !(player->mo->tracer->state >= &states[S_SUPERTRANS1] && player->mo->tracer->state <= &states[S_SUPERTRANS9]) - && !(player->capsule && player->capsule->reactiontime) - && !player->exiting) - player->nightstime--; - - if (!player->nightstime) - { - P_DeNightserizePlayer(player); - S_StartScreamSound(player->mo, sfx_s3k66); -// S_StopSoundByNum(sfx_timeup); // Kill the "out of time" music, if it's playing. Dummied out, as some on the dev team thought it wasn't Sonic-y enough (Mystic, notably). Uncomment to restore. -SH - P_RestoreMusic(player); // I have my doubts that this is the right place for this... - - return; - } - else if (P_IsLocalPlayer(player) && player->nightstime == 10*TICRATE) -// S_StartSound(NULL, sfx_timeup); // that creepy "out of time" music from NiGHTS. Dummied out, as some on the dev team thought it wasn't Sonic-y enough (Mystic, notably). Uncomment to restore. -SH - S_ChangeMusicInternal("drown",false); - - - if (player->mo->z < player->mo->floorz) - player->mo->z = player->mo->floorz; - - if (player->mo->z+player->mo->height > player->mo->ceilingz) - player->mo->z = player->mo->ceilingz - player->mo->height; - - newx = P_ReturnThrustX(player->mo, player->mo->angle, 3*FRACUNIT)+player->mo->x; - newy = P_ReturnThrustY(player->mo, player->mo->angle, 3*FRACUNIT)+player->mo->y; - - if (!player->mo->target) - { - fixed_t dist1, dist2 = 0; - - // scan the thinkers - // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_AXIS) - { - if (mo2->threshold == player->mare) - { - if (closestaxis == NULL) - { - closestaxis = mo2; - dist2 = R_PointToDist2(newx, newy, mo2->x, mo2->y)-mo2->radius; - } - else - { - dist1 = R_PointToDist2(newx, newy, mo2->x, mo2->y)-mo2->radius; - - if (dist1 < dist2) - { - closestaxis = mo2; - dist2 = dist1; - } - } - } - } - } - - P_SetTarget(&player->mo->target, closestaxis); - } - - if (!player->mo->target) // Uh-oh! - { - CONS_Debug(DBG_NIGHTS, "No axis points found!\n"); - return; - } - - // The 'ambush' flag says you should rotate - // the other way around the axis. - if (player->mo->target->flags2 & MF2_AMBUSH) - backwardaxis = true; - - player->angle_pos = R_PointToAngle2(player->mo->target->x, player->mo->target->y, player->mo->x, player->mo->y); - - player->old_angle_pos = player->angle_pos; - - radius = player->mo->target->radius; - - player->mo->flags |= MF_NOGRAVITY; - player->mo->flags2 |= MF2_DONTDRAW; - P_SetScale(player->mo->tracer, player->mo->scale); - - if (player->mo->eflags & MFE_VERTICALFLIP) - cmd->forwardmove = (SINT8)(-cmd->forwardmove); - - if (!(player->pflags & PF_TRANSFERTOCLOSEST)) - { - fixed_t realdist = R_PointToDist2(player->mo->x, player->mo->y, player->mo->target->x, player->mo->target->y); - // teleport player to correct radius if neccessary - if (realdist>>FRACBITS != radius>>FRACBITS) - { - CONS_Debug(DBG_NIGHTS, "Aligning player with axis\n"); - P_UnsetThingPosition(player->mo); - if (realdist == 0) // other method won't work if we're exactly on the target lol - { - const angle_t fa = player->old_angle_pos>>ANGLETOFINESHIFT; - player->mo->x = player->mo->target->x + FixedMul(FINECOSINE(fa), radius); - player->mo->y = player->mo->target->y + FixedMul(FINESINE(fa), radius); - } - else - { - player->mo->x = player->mo->target->x + FixedMul(FixedDiv(player->mo->x - player->mo->target->x, realdist), radius); - player->mo->y = player->mo->target->y + FixedMul(FixedDiv(player->mo->y - player->mo->target->y, realdist), radius); - } - P_SetThingPosition(player->mo); - } - } - - // Currently reeling from being hit. - if (player->powers[pw_flashing] > (2*K_GetKartFlashing(player))/3) - { - { - const angle_t fa = (FixedAngle(player->flyangle*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK; - const fixed_t speed = FixedDiv(player->speed*FRACUNIT,50*FRACUNIT); - - xspeed = FixedMul(FINECOSINE(fa),speed); - yspeed = FixedMul(FINESINE(fa),speed); - } - - if (!(player->pflags & PF_TRANSFERTOCLOSEST)) - { - xspeed = FixedMul(xspeed, FixedDiv(1024*FRACUNIT, player->mo->target->radius)); - - if (backwardaxis) - xspeed *= -1; - - player->angle_pos += FixedAngleC(FixedDiv(xspeed,5*FRACUNIT),40*FRACUNIT); - } - - player->mo->momz = 0; - - P_NightsTransferPoints(player, xspeed, radius); - return; - } - - if (player->mo->tracer->state >= &states[S_SUPERTRANS1] - && player->mo->tracer->state <= &states[S_SUPERTRANS9]) - { - player->mo->momx = player->mo->momy = player->mo->momz = 0; - return; - } - - if (player->exiting > 0 && player->exiting < 2*TICRATE) - { - player->mo->momx = player->mo->momy = 0; - - if (!G_RaceGametype()) - P_SetObjectMomZ(player->mo, 30*FRACUNIT, false); - - player->mo->tracer->angle += ANGLE_11hh; - - if (!(player->mo->tracer->state >= &states[S_NIGHTSDRONE1] - && player->mo->tracer->state <= &states[S_NIGHTSDRONE2])) - P_SetMobjState(player->mo->tracer, S_NIGHTSDRONE1); - - player->mo->tracer->flags |= MF_NOCLIPHEIGHT; - player->mo->flags |= MF_NOCLIPHEIGHT; - return; - } - - // Spawn the little sparkles on each side of the player. - if (leveltime & 1) - { - mobj_t *firstmobj; - mobj_t *secondmobj; - fixed_t spawndist = FixedMul(16*FRACUNIT, player->mo->scale); - fixed_t z = player->mo->z + player->mo->height/2; - - if (player->mo->eflags & MFE_VERTICALFLIP) - z -= FixedMul(mobjinfo[MT_NIGHTSPARKLE].height, player->mo->scale); - - firstmobj = P_SpawnMobj(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle+ANGLE_90, spawndist), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle+ANGLE_90, spawndist), z, MT_NIGHTSPARKLE); - secondmobj = P_SpawnMobj(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle-ANGLE_90, spawndist), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle-ANGLE_90, spawndist), z, MT_NIGHTSPARKLE); - - firstmobj->destscale = secondmobj->destscale = player->mo->scale; - P_SetTarget(&firstmobj->target, player->mo); - P_SetScale(firstmobj, player->mo->scale); - P_SetTarget(&secondmobj->target, player->mo); - P_SetScale(secondmobj, player->mo->scale); - - // Superloop turns sparkles red - if (player->powers[pw_nights_superloop]) - { - P_SetMobjState(firstmobj, mobjinfo[MT_NIGHTSPARKLE].seestate); - P_SetMobjState(secondmobj, mobjinfo[MT_NIGHTSPARKLE].seestate); - } - } - - // Paraloop helper is now separate from sparkles - // It also spawns every tic to avoid failed paraloops - { - mobj_t *helpermobj = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, MT_NIGHTSLOOPHELPER); - helpermobj->fuse = player->mo->fuse = leveltime; - P_SetTarget(&helpermobj->target, player->mo); - P_SetScale(helpermobj, player->mo->scale); - } - - if (player->bumpertime) - { - player->jumping = 1; - player->pflags |= PF_DRILLING; - newangle = (INT16)player->flyangle; - } - else if (cmd->buttons & BT_DRIFT && player->drillmeter && player->drilldelay == 0) - { - if (!player->jumping) - firstdrill = true; - - player->jumping = 1; - player->pflags |= PF_DRILLING; - } - else - { - player->jumping = 0; - - if (cmd->sidemove != 0) - moved = true; - - if (player->drillmeter & 1) - player->drillmeter++; // I'll be nice and give them one. - } - - if (cmd->forwardmove != 0) - moved = true; - - if (!player->bumpertime) - { - if (moved) - { - if (player->pflags & PF_DRILLING) - drillamt += 100*FRACUNIT; - else - { - const fixed_t fforward = abs(cmd->forwardmove)*FRACUNIT; - const fixed_t fside = abs(cmd->sidemove)*FRACUNIT; - const fixed_t dist = FixedHypot(fforward, fside); - - drillamt += dist > 50*FRACUNIT ? 50*FRACUNIT : dist; - - // Accel up from 50 * 2.5 - drillamt = FixedMul(drillamt, 5*FRACUNIT/2); - } - if ((player->pflags & PF_DRILLING && player->speed < MAXDRILLSPEED) || player->speed < MAXNORMALSPEED) - player->speed += FixedInt(drillamt); - } - - if (player->pflags & PF_DRILLING) - { - if (player->speed < MAXDRILLSPEED) - player->speed += 150; - - if (--player->drillmeter == 0) - player->drilldelay = TICRATE*2; - } - - if (player->speed < 0) - player->speed = 0; - - if (!cmd->forwardmove) - { - if (cmd->sidemove > 0) - newangle = 0; - else if (cmd->sidemove < 0) - newangle = 180; - } - else if (!cmd->sidemove) - { - if (cmd->forwardmove > 0) - newangle = 90; - else if (cmd->forwardmove < 0) - newangle = 270; - } - else // AngleFixed(R_PointToAngle2()) results in slight inaccuracy! Don't use it unless movement is on both axises. - newangle = (INT16)FixedInt(AngleFixed(R_PointToAngle2(0,0, cmd->sidemove*FRACUNIT, cmd->forwardmove*FRACUNIT))); - - newangle -= player->viewrollangle / ANG1; - - if (newangle < 0 && moved) - newangle = (INT16)(360+newangle); - } - - if (player->pflags & PF_DRILLING) - thrustfactor = 2; - else - { - thrustfactor = 8; - - // Decelerate while turning normally. - if (moved && player->flyangle != newangle && player->speed > 12000) - player->speed -= 60; - } - - for (i = 0; i < thrustfactor; i++) - { - if (moved && player->flyangle != newangle) - { - INT32 anglediff = (((newangle-player->flyangle)+360)%360); - INT32 angledif2 = (((player->flyangle-newangle)+360)%360); - - // player->flyangle is the one to move - // newangle is the "move to" - if (anglediff == 0 && angledif2 == 0) - break; - - if (anglediff>angledif2) - player->flyangle--; - else // if (anglediffflyangle++; - } - - // Buff out negatives, >360 angles... - player->flyangle = ((player->flyangle + 360) % 360); - } - - if (!(player->speed) - && cmd->forwardmove == 0) - still = true; - - // No more bumper braking - if (!player->bumpertime - && ((cmd->buttons & (BT_FORWARD|BT_BACKWARD)) == (BT_FORWARD|BT_BACKWARD) - || (cmd->buttons & BT_BRAKE))) - { - if (!(player->pflags & PF_SKIDDOWN)) - S_StartSound(player->mo, sfx_ngskid); - - // You can tap the button to only slow down a bit, - // or hold it to slow to a crawl as before, your choice. - if (player->speed > 8000) - player->speed -= 2000; - else if (player->speed > 1000) - player->speed -= (player->speed/4); - else { - player->speed -= 60; - if (player->speed < 0) - { - player->speed = 0; - still = true; - } - } - - player->pflags |= PF_SKIDDOWN; - } - else - player->pflags &= ~PF_SKIDDOWN; - - { - const angle_t fa = (FixedAngle(player->flyangle*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK; - const fixed_t speed = FixedDiv(player->speed*FRACUNIT,50*FRACUNIT); - xspeed = FixedMul(FINECOSINE(fa),speed); - yspeed = FixedMul(FINESINE(fa),speed); - } - - if (!(player->pflags & PF_TRANSFERTOCLOSEST)) - { - xspeed = FixedMul(xspeed, FixedDiv(1024*FRACUNIT, player->mo->target->radius)); - - if (backwardaxis) - xspeed *= -1; - - player->angle_pos += FixedAngleC(FixedDiv(xspeed,5*FRACUNIT),40*FRACUNIT); - } - - P_NightsTransferPoints(player, xspeed, radius); - - if (still) - player->mo->momz = -FRACUNIT; - else - player->mo->momz = yspeed/11; - - if (player->mo->momz > 20*FRACUNIT) - player->mo->momz = 20*FRACUNIT; - else if (player->mo->momz < -20*FRACUNIT) - player->mo->momz = -20*FRACUNIT; - - // You can create splashes as you fly across water. - if (((!(player->mo->eflags & MFE_VERTICALFLIP) - && player->mo->z + P_GetPlayerHeight(player) >= player->mo->watertop && player->mo->z <= player->mo->watertop) - || (player->mo->eflags & MFE_VERTICALFLIP - && player->mo->z + player->mo->height - P_GetPlayerHeight(player) <= player->mo->waterbottom && player->mo->z + player->mo->height >= player->mo->waterbottom)) - && player->speed > 9000 && leveltime % (TICRATE/7) == 0 && !player->spectator) - { - mobj_t *water = P_SpawnMobj(player->mo->x, player->mo->y, - ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_SPLISH].height, player->mo->scale) : player->mo->watertop), MT_SPLISH); - if (player->mo->eflags & MFE_GOOWATER) - S_StartSound(water, sfx_ghit); - else - S_StartSound(water, sfx_wslap); - if (player->mo->eflags & MFE_VERTICALFLIP) - { - water->flags2 |= MF2_OBJECTFLIP; - water->eflags |= MFE_VERTICALFLIP; - } - water->destscale = player->mo->scale; - P_SetScale(water, player->mo->scale); - } - - if (player->mo->momx || player->mo->momy) - player->mo->angle = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - - if (still) - { - player->anotherflyangle = 0; - movingangle = 0; - } - else - { - INT32 neg = 1; - - // Special cases to prevent the angle from being - // calculated incorrectly when wrapped. - if (backwardaxis && (player->old_angle_pos > ANG350 && player->angle_pos < ANG10)) - neg = -1; - else if (backwardaxis ^ (player->old_angle_pos < ANG10 && player->angle_pos > ANG350)) - neg = -1; - else if (player->angle_pos > player->old_angle_pos) - neg = -1; - - movingangle = R_PointToAngle2(0, 0, neg*R_PointToDist2(player->mo->momx, player->mo->momy, 0, 0), player->mo->momz); - player->anotherflyangle = (movingangle >> ANGLETOFINESHIFT) * 360/FINEANGLES; - } - - // NiGHTS flying state - // Yep, I just ripped out almost 1000 lines of code. - if ((player->anotherflyangle >= 12 && player->anotherflyangle <= 33) // +x +y - || (player->anotherflyangle >= 147 && player->anotherflyangle <= 168)) // -x +y - flystate = S_NIGHTSFLY2A; - else if ((player->anotherflyangle >= 34 && player->anotherflyangle <= 56) // +x +y - || (player->anotherflyangle >= 124 && player->anotherflyangle <= 146)) // -x +y - flystate = S_NIGHTSFLY3A; - else if ((player->anotherflyangle >= 57 && player->anotherflyangle <= 79) // +x +y - || (player->anotherflyangle >= 102 && player->anotherflyangle <= 123)) // -x +y - flystate = S_NIGHTSFLY4A; - else if (player->anotherflyangle >= 80 && player->anotherflyangle <= 101) - flystate = S_NIGHTSFLY5A; - else if ((player->anotherflyangle >= 192 && player->anotherflyangle <= 213) // -x -y - || (player->anotherflyangle >= 327 && player->anotherflyangle <= 348)) // +x -y - flystate = S_NIGHTSFLY6A; - else if ((player->anotherflyangle >= 214 && player->anotherflyangle <= 236) // -x -y - || (player->anotherflyangle >= 305 && player->anotherflyangle <= 326)) // +x -y - flystate = S_NIGHTSFLY7A; - else if ((player->anotherflyangle >= 237 && player->anotherflyangle <= 258) // -x -y - || (player->anotherflyangle >= 282 && player->anotherflyangle <= 304)) // +x -y - flystate = S_NIGHTSFLY8A; - else if (player->anotherflyangle >= 259 && player->anotherflyangle <= 281) - flystate = S_NIGHTSFLY9A; - else - flystate = S_NIGHTSFLY1A; - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (flystate >= S_NIGHTSFLY2A && flystate <= S_NIGHTSFLY5A) - flystate += 24; // shift to S_NIGHTSFLY6A - else if (flystate >= S_NIGHTSFLY6A && flystate <= S_NIGHTSFLY9A) - flystate -= 24; // shift to S_NIGHTSFLY2A - } - - if (player->pflags & PF_DRILLING) - { - const statenum_t drillstate = flystate + 2; - - if (!(player->mo->tracer->state >= &states[drillstate] - && player->mo->tracer->state <= &states[drillstate+4])) - { - if (!(player->mo->tracer->state >= &states[S_NIGHTSFLY1A] - && player->mo->tracer->state <= &states[S_NIGHTSFLY9B])) - { - const INT32 framenum = player->mo->tracer->state->frame & 3; - - if (framenum == 3) // Drilld special case - P_SetMobjStateNF(player->mo->tracer, drillstate); - else - P_SetMobjStateNF(player->mo->tracer, drillstate+framenum+1); - } - else - P_SetMobjStateNF(player->mo->tracer, drillstate); - } - } - else - P_SetMobjStateNF(player->mo->tracer, leveltime & 1 ? flystate : flystate+1); - - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - - if (still) - { - P_SetMobjStateNF(player->mo->tracer, S_NIGHTSDRONE1); - player->mo->tracer->angle = player->mo->angle; - } - - // Check for crushing in our new location - if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) - && !(player->mo->flags & MF_NOCLIP)) - { - // Flashing won't run out until you STOP being crushed. - if (player->powers[pw_flashing] == 1) - player->powers[pw_flashing] = 3; - else - P_DamageMobj(player->mo, NULL, NULL, 1); - } - - if (movingangle >= ANGLE_90 && movingangle <= ANGLE_180) - movingangle = movingangle - ANGLE_180; - else if (movingangle >= ANGLE_180 && movingangle <= ANGLE_270) - movingangle = movingangle - ANGLE_180; - else if (movingangle >= ANGLE_270) - movingangle = InvAngle(movingangle); - - if (player == &players[consoleplayer]) - localaiming[0] = movingangle; - else if (player == &players[displayplayers[1]]) - localaiming[1] = movingangle; - else if (player == &players[displayplayers[2]]) - localaiming[2] = movingangle; - else if (player == &players[displayplayers[3]]) - localaiming[3] = movingangle; - - player->mo->tracer->angle = player->mo->angle; - - if ((player->pflags & PF_DRILLING) && !player->bumpertime) - { - if (firstdrill) - { - S_StartSound(player->mo, sfx_drill1); - player->drilltimer = 32; - } - else if (--player->drilltimer <= 0) - { - player->drilltimer = 10; - S_StartSound(player->mo, sfx_drill2); - } - } - - if (objectplacing) - OP_NightsObjectplace(player); -}*/ - -// May be used in future for CTF -#if 0 -static void P_PlayerDropWeapon(player_t *player) -{ - mobj_t *mo = NULL; - - if (player->powers[pw_homingring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_HOMINGRING); - player->powers[pw_homingring] = 0; - } - else if (player->powers[pw_railring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_RAILRING); - player->powers[pw_railring] = 0; - } - else if (player->powers[pw_automaticring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_AUTOMATICRING); - player->powers[pw_automaticring] = 0; - } - else if (player->powers[pw_explosionring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_EXPLOSIONRING); - player->powers[pw_explosionring] = 0; - } - else if (player->powers[pw_scatterring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_SCATTERRING); - player->powers[pw_scatterring] = 0; - } - else if (player->powers[pw_grenadering]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_GRENADERING); - player->powers[pw_grenadering] = 0; - } - - if (mo) - { - player->mo->health--; - P_InstaThrust(mo, player->mo->angle-ANGLE_180, 8*FRACUNIT); - P_SetObjectMomZ(mo, 4*FRACUNIT, false); - mo->flags2 |= MF2_DONTRESPAWN; - mo->flags &= ~MF_NOGRAVITY; - mo->flags &= ~MF_NOCLIPHEIGHT; - mo->fuse = 12*TICRATE; - } -} -#endif - void P_BlackOw(player_t *player) { INT32 i; @@ -5666,14 +2244,6 @@ static void P_MovePlayer(player_t *player) if (countdowntimeup) return; - /* // SRB2kart - junk - if (player->mo->state >= &states[S_PLAY_SUPERTRANS1] && player->mo->state <= &states[S_PLAY_SUPERTRANS9]) - { - player->mo->momx = player->mo->momy = player->mo->momz = 0; - return; - } - */ - cmd = &player->cmd; runspd = 14*player->mo->scale; //srb2kart @@ -5733,69 +2303,10 @@ static void P_MovePlayer(player_t *player) return; } - // Locate the capsule for this mare. - /*else if (maptol & TOL_NIGHTS) - { - if (!player->capsule && !player->bonustime) - { - thinker_t *th; - mobj_t *mo2; - - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_EGGCAPSULE - && mo2->threshold == player->mare) - P_SetTarget(&player->capsule, mo2); - } - } - else if (player->capsule && player->capsule->reactiontime > 0 && player == &players[player->capsule->reactiontime-1]) - { - P_DoNiGHTSCapsule(player); - return; - } - - // Test revamped NiGHTS movement. - if (player->pflags & PF_NIGHTSMODE) - { - P_NiGHTSMovement(player); - // No more goto blockchecking, let's just do all that here =D - if (CheckForBustableBlocks) - P_CheckBustableBlocks(player); - if (CheckForBouncySector) - P_CheckBouncySectors(player); - if (CheckForQuicksand) - P_CheckQuicksand(player); - return; - } - - if (player->pflags & PF_NIGHTSFALL && P_IsObjectOnGround(player->mo)) - { - if (G_IsSpecialStage(gamemap)) - { - if (player == &players[displayplayers[0]]) // only play the sound for yourself landing - S_StartSound(NULL, sfx_s3k6a); - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - players[i].exiting = raceexittime+1; - } - else if (player->health > 1) - P_DamageMobj(player->mo, NULL, NULL, 1); - player->pflags &= ~PF_NIGHTSFALL; - } - }*/ - ////////////////////// // MOVEMENT CODE // ////////////////////// - /*if (twodlevel || player->mo->flags2 & MF2_TWOD) // 2d-level, so special control applies. - P_2dMovement(player); - else*/ { INT16 angle_diff, max_left_turn, max_right_turn; boolean add_delta = true; @@ -5861,32 +2372,6 @@ static void P_MovePlayer(player_t *player) // MOVEMENT ANIMATIONS // ///////////////////////// - /* - if ((cmd->forwardmove != 0 || cmd->sidemove != 0) || (player->powers[pw_super] && player->mo->z > player->mo->floorz)) - { - // If the player is moving fast enough, - // break into a run! - if (player->speed >= runspd && player->panim == PA_WALK && !player->skidtime && (onground || player->powers[pw_super])) - P_SetPlayerMobjState (player->mo, S_KART_RUN1); // SRB2kart - was S_PLAY_SPD1 - - // Otherwise, just walk. - else if ((player->rmomx || player->rmomy) && player->panim == PA_IDLE) - P_SetPlayerMobjState (player->mo, S_KART_WALK1); // SRB2kart - was S_PLAY_RUN1 - } - */ - - // If your running animation is playing, and you're - // going too slow, switch back to the walking frames. - //if (player->panim == PA_RUN && player->speed < runspd && player->kartstuff[k_spinouttimer] == 0) - //P_SetPlayerMobjState(player->mo, S_KART_WALK1); // SRB2kart - was S_PLAY_RUN1 - - // If Springing, but travelling DOWNWARD, change back! - //if (player->mo->state == &states[S_PLAY_SPRING] && P_MobjFlip(player->mo)*player->mo->momz < 0) - // P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); - // If Springing but on the ground, change back! - //else if (onground && (player->mo->state == &states[S_PLAY_SPRING] || player->panim == PA_FALL || player->mo->state == &states[S_PLAY_CARRY]) && !player->mo->momz) - // P_SetPlayerMobjState(player->mo, S_PLAY_STND); - // Kart frames if (player->kartstuff[k_squishedtimer] > 0) { @@ -5969,104 +2454,13 @@ static void P_MovePlayer(player_t *player) P_SetPlayerMobjState(player->mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND } - if (/*!(player->charability == CA_GLIDEANDCLIMB) ||*/ player->gotflag) // If you can't glide, then why the heck would you be gliding? + if (player->gotflag) // If you can't glide, then why the heck would you be gliding? { - /* // SRB2kart - ??? - if (player->pflags & PF_GLIDING || player->climbing) - { - if (onground) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); - else - { - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - } - */ player->pflags &= ~PF_GLIDING; player->glidetime = 0; player->climbing = 0; } - // Glide MOMZ - // AKA my own gravity. =) - /* // SRB2kart - gliding is illegal, go to jail - if (player->pflags & PF_GLIDING) - { - fixed_t leeway; - fixed_t glidespeed = player->actionspd; - - if (player->powers[pw_super]) - glidespeed *= 2; - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (player->mo->momz > FixedMul(2*FRACUNIT, player->mo->scale)) - player->mo->momz -= FixedMul(3*(FRACUNIT/4), player->mo->scale); - } - else - { - if (player->mo->momz < FixedMul(-2*FRACUNIT, player->mo->scale)) - player->mo->momz += FixedMul(3*(FRACUNIT/4), player->mo->scale); - } - - // Strafing while gliding. - leeway = FixedAngle(cmd->sidemove*(FRACUNIT/2)); - - if (player->skidtime) // ground gliding - { - fixed_t speed = FixedMul(glidespeed, FRACUNIT - (FRACUNIT>>2)); - if (player->mo->eflags & MFE_UNDERWATER) - speed >>= 1; - speed = FixedMul(speed - player->glidetime*FRACUNIT, player->mo->scale); - if (speed < 0) - speed = 0; - P_InstaThrust(player->mo, player->mo->angle-leeway, speed); - } - else if (player->mo->eflags & MFE_UNDERWATER) - P_InstaThrust(player->mo, player->mo->angle-leeway, FixedMul((glidespeed>>1) + player->glidetime*750, player->mo->scale)); - else - P_InstaThrust(player->mo, player->mo->angle-leeway, FixedMul(glidespeed + player->glidetime*1500, player->mo->scale)); - - player->glidetime++; - - if (!(player->pflags & PF_JUMPDOWN)) // If not holding the jump button - { - P_ResetPlayer(player); // down, stop gliding. - if (onground) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); - else if ((player->charability2 == CA2_MULTIABILITY) - || (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]) && player->charability == CA_GLIDEANDCLIMB)) - { - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - else - { - player->pflags |= PF_THOKKED; - player->mo->momx >>= 1; - player->mo->momy >>= 1; - P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); - } - } - } - else if (player->climbing) // 'Deceleration' for climbing on walls. - { - if (player->mo->momz > 0) - { - player->mo->momz -= FixedMul(FRACUNIT/2, player->mo->scale); - if (player->mo->momz < 0) - player->mo->momz = 0; - } - else if (player->mo->momz < 0) - { - player->mo->momz += FixedMul(FRACUNIT/2, player->mo->scale); - if (player->mo->momz > 0) - player->mo->momz = 0; - } - } - */ - // If you're running fast enough, you can create splashes as you run in shallow water. if (!player->climbing && ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height >= player->mo->watertop && player->mo->z <= player->mo->watertop) @@ -6096,100 +2490,6 @@ static void P_MovePlayer(player_t *player) S_StartSound(player->mo, sfx_floush); } - //////////////// - //TAILS FLYING// - //////////////// - - /* // SRB2kart - nah - if (!(player->charability == CA_FLY || player->charability == CA_SWIM)) // why are you flying when you cannot fly?! - { - if (player->powers[pw_tailsfly] - || (player->mo->state >= &states[S_PLAY_SPC1] && player->mo->state <= &states[S_PLAY_SPC4])) - { - if (onground) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); - else - { - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - } - player->powers[pw_tailsfly] = 0; - } - - if (player->gotflag && player->powers[pw_tailsfly]) - player->powers[pw_tailsfly] = 1; - - // If not in a fly position, don't think you're flying! - if (player->panim != PA_ABILITY) - player->powers[pw_tailsfly] = 0; - - if (player->charability == CA_FLY || (player->charability == CA_SWIM && player->mo->eflags & MFE_UNDERWATER)) - { - // Fly counter for Tails. - if (player->powers[pw_tailsfly]) - { - const fixed_t actionspd = player->actionspd/100; - - if (player->charability2 == CA2_MULTIABILITY) - { - // Adventure-style flying by just holding the button down - if (cmd->buttons & BT_DRIFT && !(player->pflags & PF_STASIS) && !player->exiting) - P_SetObjectMomZ(player->mo, actionspd/4, true); - } - else - { - // Classic flying - if (player->fly1) - { - if (P_MobjFlip(player->mo)*player->mo->momz < FixedMul(5*actionspd, player->mo->scale)) - P_SetObjectMomZ(player->mo, actionspd/2, true); - - player->fly1--; - } - } - - // Tails Put-Put noise - if (player->charability == CA_FLY && player->bot != 1 && leveltime % 10 == 0 && !player->spectator) - S_StartSound(player->mo, sfx_putput); - - // Descend - if (cmd->buttons & BT_BRAKE && !(player->pflags & PF_STASIS) && !player->exiting) - if (P_MobjFlip(player->mo)*player->mo->momz > -FixedMul(5*actionspd, player->mo->scale)) - P_SetObjectMomZ(player->mo, -actionspd/2, true); - - } - else - { - // Tails-gets-tired Stuff - if (player->panim == PA_ABILITY) - P_SetPlayerMobjState(player->mo, S_PLAY_SPC4); - - if (player->charability == CA_FLY && (leveltime % 10 == 0) - && player->mo->state >= &states[S_PLAY_SPC1] - && player->mo->state <= &states[S_PLAY_SPC4] - && !player->spectator) - S_StartSound(player->mo, sfx_pudpud); - } - } - - // End your chain if you're on the ground or climbing a wall. - // But not if invincible! Allow for some crazy long chains with it. - // Also keep in mind the PF_JUMPED check. - // If we lacked this, stepping up while jumping up would reset score. - // (for instance, when climbing up off a wall.) - if ((onground || player->climbing) && !(player->pflags & PF_JUMPED) && player->powers[pw_invulnerability] <= 1) - P_ResetScore(player); - - // Show the "THOK!" graphic when spinning quickly across the ground. (even applies to non-spinners, in the case of zoom tubes) - if (player->pflags & PF_SPINNING && player->speed > FixedMul(15<mo->scale) && !(player->pflags & PF_JUMPED)) - { - P_SpawnSpinMobj(player, player->spinitem); - if (demo.recording) - G_GhostAddSpin((INT32) (player - players)); - } - */ - //////////////////////////// //SPINNING AND SPINDASHING// //////////////////////////// @@ -6206,253 +2506,18 @@ static void P_MovePlayer(player_t *player) K_DriftDustHandling(player->mo); - /* // SRB2kart - nadah - // If the player isn't on the ground, make sure they aren't in a "starting dash" position. - if (!onground) - { - player->pflags &= ~PF_STARTDASH; - player->dashspeed = 0; - } - - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL - && (player->pflags & PF_SPINNING) && player->speed > FixedMul(4<mo->scale) && onground && (leveltime & 1) - && !(player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) - P_ElementalFireTrail(player); - - P_DoSpinDash(player, cmd); - */ - // jumping - //P_DoJumpStuff(player, cmd); - - /* - // If you're not spinning, you'd better not be spindashing! - if (!(player->pflags & PF_SPINNING)) - player->pflags &= ~PF_STARTDASH; - */ - - ////////////////// - //ANALOG CONTROL// - ////////////////// - -#if 0 - // This really looks like it should be moved to P_3dMovement. -Red - if (P_AnalogMove(player) - && (cmd->forwardmove != 0 || cmd->sidemove != 0) && !player->climbing && !twodlevel && !(player->mo->flags2 & MF2_TWOD)) - { - // If travelling slow enough, face the way the controls - // point and not your direction of movement. - if (player->speed < FixedMul(5*FRACUNIT, player->mo->scale) || player->pflags & PF_GLIDING || !onground) - { - angle_t tempangle; - - tempangle = (cmd->angleturn << 16); - -#ifdef REDSANALOG // Ease to it. Chillax. ~Red - tempangle += R_PointToAngle2(0, 0, cmd->forwardmove*FRACUNIT, -cmd->sidemove*FRACUNIT); - { - fixed_t tweenvalue = max(abs(cmd->forwardmove), abs(cmd->sidemove)); - - if (tweenvalue < 10 && (cmd->buttons & (BT_FORWARD|BT_BACKWARD)) == (BT_FORWARD|BT_BACKWARD)) { - tempangle = (cmd->angleturn << 16); - tweenvalue = 16; - } - - tweenvalue *= tweenvalue*tweenvalue*1536; - - //if (player->pflags & PF_GLIDING) - //tweenvalue >>= 1; - - tempangle -= player->mo->angle; - - if (tempangle < ANGLE_180 && tempangle > tweenvalue) - player->mo->angle += tweenvalue; - else if (tempangle >= ANGLE_180 && InvAngle(tempangle) > tweenvalue) - player->mo->angle -= tweenvalue; - else - player->mo->angle += tempangle; - } -#else - // Less math this way ~Red - player->mo->angle = R_PointToAngle2(0, 0, cmd->forwardmove*FRACUNIT, -cmd->sidemove*FRACUNIT)+tempangle; -#endif - } - // Otherwise, face the direction you're travelling. - else if (player->panim == PA_WALK || player->panim == PA_RUN || player->panim == PA_ROLL - /*|| ((player->mo->state >= &states[S_PLAY_ABL1] && player->mo->state <= &states[S_PLAY_SPC4]) && player->charability == CA_FLY)*/) // SRB2kart - idk - player->mo->angle = R_PointToAngle2(0, 0, player->rmomx, player->rmomy); - - // Update the local angle control. - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - } -#endif - - /////////////////////////// - //BOMB SHIELD ACTIVATION,// - //HOMING, AND OTHER COOL // - //STUFF! // - /////////////////////////// - - /* // SRB2kart - what's a shield? Never heard of it. Never happened. Nope. - if (cmd->buttons & BT_BRAKE) // Spin button effects - { - if (player->pflags & PF_JUMPED) // If the player is jumping - { - if (!(player->pflags & PF_USEDOWN)) // If the player is not holding down BT_BRAKE - { - // Jump shield activation - if (!P_PlayerInPain(player) // If the player is not in pain - && !player->climbing // If the player is not climbing - && !(player->pflags & (PF_GLIDING|PF_SLIDING|PF_THOKKED)) // If the player is not gliding or sliding and hasn't used their ability - && !onground) // If the player isn't on the ground - { - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_JUMP && !player->powers[pw_super]) - P_DoJumpShield(player); - else if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]) && player->charability == CA_FLY) - { - P_DoJumpShield(player); - player->mo->momz *= 2; - } - } - // Bomb shield activation - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_BOMB) - { - // Don't let Super Sonic or invincibility use it - if (!(player->powers[pw_super] || player->powers[pw_invulnerability])) - P_BlackOw(player); - } - } - // Super Sonic move - if (player->skin == 0 && player->powers[pw_super] && player->speed > FixedMul(5<mo->scale) - && P_MobjFlip(player->mo)*player->mo->momz <= 0) - { - if (player->panim == PA_ROLL || player->mo->state == &states[S_PLAY_PAIN]) - P_SetPlayerMobjState(player->mo, S_PLAY_SUPERWALK1); - - player->mo->momz = 0; - player->pflags &= ~PF_SPINNING; - player->jumping = 0; // don't cut jump height after bouncing off something - } - } - } - - // HOMING option. - if (player->charability == CA_HOMINGTHOK) - { - // If you've got a target, chase after it! - if (player->homing && player->mo->tracer) - { - P_SpawnThokMobj(player); - P_HomingAttack(player->mo, player->mo->tracer); - - // But if you don't, then stop homing. - if (player->mo->tracer->health <= 0 || (player->mo->tracer->flags2 & MF2_FRET)) - { - if (player->mo->eflags & MFE_UNDERWATER) - P_SetObjectMomZ(player->mo, FixedDiv(457*FRACUNIT,72*FRACUNIT), false); - else - P_SetObjectMomZ(player->mo, 10*FRACUNIT, false); - - player->mo->momx = player->mo->momy = player->homing = 0; - - if (player->mo->tracer->flags2 & MF2_FRET) - P_InstaThrust(player->mo, player->mo->angle, -(player->speed>>3)); - - if (!(player->mo->tracer->flags & MF_BOSS)) - player->pflags &= ~PF_THOKKED; - } - } - - // If you're not jumping, then you obviously wouldn't be homing. - if (!(player->pflags & PF_JUMPED)) - player->homing = 0; - } - else - player->homing = 0; - - if (player->climbing == 1) - P_DoClimbing(player); - - if (player->climbing > 1) - { - P_InstaThrust(player->mo, player->mo->angle, FixedMul(4*FRACUNIT, player->mo->scale)); // Shove up against the wall - player->climbing--; - } - - if (!player->climbing) - { - player->lastsidehit = -1; - player->lastlinehit = -1; - } - - // Make sure you're not teetering when you shouldn't be. - if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER]) - && (player->mo->momx || player->mo->momy || player->mo->momz)) - P_SetPlayerMobjState(player->mo, S_PLAY_STND); - - // Check for teeter! - if (!(player->mo->momz || player->mo->momx || player->mo->momy) && !(player->mo->eflags & MFE_GOOWATER) - && player->panim == PA_IDLE && !(player->pflags & (PF_CARRIED|PF_ITEMHANG|PF_ROPEHANG))) - P_DoTeeter(player); - - // Toss a flag - if (G_GametypeHasTeams() && (cmd->buttons & BT_SPECTATE) && !(player->powers[pw_super]) && !(player->tossdelay)) - { - if (!(player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - P_PlayerEmeraldBurst(player, true); // Toss emeralds - else - P_PlayerFlagBurst(player, true); - } - - // check for fire - if (!player->exiting) - P_DoFiring(player, cmd); - - { - fixed_t oldheight = player->mo->height; - - // Less height while spinning. Good for spinning under things...? - if ((player->mo->state == &states[player->mo->info->painstate] || player->mo->state == &states[S_PLAY_SUPERHIT]) - || (player->charability2 == CA2_SPINDASH && (player->pflags & (PF_SPINNING|PF_JUMPED))) - || player->powers[pw_tailsfly] || player->pflags & PF_GLIDING - || (player->charability == CA_FLY && (player->mo->state >= &states[S_PLAY_SPC1] && player->mo->state <= &states[S_PLAY_SPC4]))) - player->mo->height = P_GetPlayerSpinHeight(player); - else - player->mo->height = P_GetPlayerHeight(player); - - if (player->mo->eflags & MFE_VERTICALFLIP && player->mo->height != oldheight) // adjust z height for reverse gravity, similar to how it's done for scaling - player->mo->z -= player->mo->height - oldheight; - } - */ // Crush test... if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) && !(player->mo->flags & MF_NOCLIP)) { - /* // SRB2kart - no, we're not making the playerspin - if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SPINNING)) - { - player->pflags |= PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - else */if (player->mo->ceilingz - player->mo->floorz < player->mo->height) + if (player->mo->ceilingz - player->mo->floorz < player->mo->height) { if ((netgame || multiplayer) && player->spectator) P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators else { K_SquishPlayer(player, NULL, NULL); // SRB2kart - we don't kill when squished, we squish when squished. - /* - mobj_t *killer = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_NULL); - killer->threshold = 44; // Special flag that it was crushing which killed you. - P_DamageMobj(player->mo, killer, killer, 10000); - */ } if (player->playerstate == PST_DEAD) @@ -6626,200 +2691,6 @@ static void P_DoZoomTube(player_t *player) #endif } -// -// P_DoRopeHang -// -// Kinda like P_DoZoomTube -// but a little different. -// -/* -static void P_DoRopeHang(player_t *player) // SRB2kart - unused. -{ - INT32 sequence; - fixed_t speed; - thinker_t *th; - mobj_t *mo2; - mobj_t *waypoint = NULL; - fixed_t dist; - fixed_t playerz; - - player->mo->height = P_GetPlayerHeight(player); - - // Play the 'clink' sound only if the player is moving. - if (!(leveltime & 7) && player->speed) - S_StartSound(player->mo, sfx_s3k55); - - playerz = player->mo->z + player->mo->height; - - speed = abs(player->speed); - - sequence = player->mo->tracer->threshold; - - // change slope - dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); - - if (dist < 1) - dist = 1; - - player->mo->momx = FixedMul(FixedDiv(player->mo->tracer->x - player->mo->x, dist), (speed)); - player->mo->momy = FixedMul(FixedDiv(player->mo->tracer->y - player->mo->y, dist), (speed)); - player->mo->momz = FixedMul(FixedDiv(player->mo->tracer->z - playerz, dist), (speed)); - - if (player->cmd.buttons & BT_USE && !(player->pflags & PF_STASIS)) // Drop off of the rope - { - P_SetTarget(&player->mo->tracer, NULL); - - player->pflags |= PF_JUMPED; - player->pflags &= ~PF_ROPEHANG; - - if (!(player->pflags & PF_SLIDING) && (player->pflags & PF_JUMPED) - && !(player->panim == PA_ROLL) && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - return; - } - - // If not allowed to move, we're done here. - if (!speed) - return; - - // Calculate the distance between the player and the waypoint - // 'dist' already equals this. - - // Will the player go past the waypoint? - if (speed > dist) - { - speed -= dist; - // If further away, set XYZ of player to waypoint location - P_UnsetThingPosition(player->mo); - player->mo->x = player->mo->tracer->x; - player->mo->y = player->mo->tracer->y; - player->mo->z = player->mo->tracer->z - player->mo->height; - playerz = player->mo->tracer->z; - P_SetThingPosition(player->mo); - - CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n"); - - // Find next waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == sequence) - { - if (mo2->health == player->mo->tracer->health + 1) - { - waypoint = mo2; - break; - } - } - } - - if (!(player->mo->tracer->flags & MF_SLIDEME) && !waypoint) - { - CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found, wrapping to start...\n"); - - // Wrap around back to first waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == sequence) - { - if (mo2->health == 0) - { - waypoint = mo2; - break; - } - } - } - } - - if (waypoint) - { - CONS_Debug(DBG_GAMELOGIC, "Found waypoint (sequence %d, number %d).\n", waypoint->threshold, waypoint->health); - - P_SetTarget(&player->mo->tracer, waypoint); - - // calculate MOMX/MOMY/MOMZ for next waypoint - // change slope - dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); - - if (dist < 1) - dist = 1; - - player->mo->momx = FixedMul(FixedDiv(player->mo->tracer->x - player->mo->x, dist), (speed)); - player->mo->momy = FixedMul(FixedDiv(player->mo->tracer->y - player->mo->y, dist), (speed)); - player->mo->momz = FixedMul(FixedDiv(player->mo->tracer->z - playerz, dist), (speed)); - } - else - { - if (player->mo->tracer->flags & MF_SLIDEME) - { - player->pflags |= PF_JUMPED; - player->pflags &= ~PF_ROPEHANG; - - if (!(player->pflags & PF_SLIDING) && (player->pflags & PF_JUMPED) - && !(player->panim == PA_ROLL) && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - - P_SetTarget(&player->mo->tracer, NULL); - - CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found!\n"); - } - } -} -*/ - -#if 0 -// -// P_NukeAllPlayers -// -// Hurts all players -// source = guy who gets the credit -// -static void P_NukeAllPlayers(player_t *player) -{ - mobj_t *mo; - thinker_t *think; - - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (!mo->player) - continue; - - if (mo->health <= 0) // dead - continue; - - if (mo == player->mo) - continue; - - P_DamageMobj(mo, player->mo, player->mo, 1); - } - - CONS_Printf(M_GetText("%s caused a world of pain.\n"), player_names[player-players]); - - return; -} -#endif - // // P_NukeEnemies // Looks for something you can hit - Used for bomb shield @@ -7964,13 +3835,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (myceilingz != myfloorz && myceilingz - thiscam->height < z) { -/* // no fit - if (!resetcalled && !cameranoclip) - { - P_ResetCamera(player, thiscam); - return true; - } -*/ z = myceilingz - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); // is the camera fit is there own sector } @@ -8297,25 +4161,6 @@ static void P_CalcPostImg(player_t *player) *type = postimg_mirror; } -/*void P_DoPityCheck(player_t *player) -{ - // No pity outside of match or CTF. - if (player->spectator - || !(gametype == GT_MATCH || gametype == GT_TEAMMATCH || gametype == GT_CTF)) - return; - - // Apply pity shield if available. - if ((player->pity >= 3 || player->pity < 0) && player->powers[pw_shield] == SH_NONE) - { - if (player->pity > 0) - S_StartSound(player->mo, mobjinfo[MT_PITYSHIELDICO].seesound); - - player->pity = 0; - player->powers[pw_shield] = SH_PITY; - P_SpawnShieldOrb(player); - } -}*/ - void P_DoTimeOver(player_t *player) { if (netgame && player->health > 0) @@ -8481,9 +4326,7 @@ void P_PlayerThink(player_t *player) } if (player->playerstate == PST_REBORN) { -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif return; } } @@ -8521,16 +4364,6 @@ void P_PlayerThink(player_t *player) player->awayviewtics = 0; // reset to zero } - /* - if (player->pflags & PF_GLIDING) - { - if (player->panim != PA_ABILITY) - P_SetPlayerMobjState(player->mo, S_PLAY_ABL1); - } - else if ((player->pflags & PF_JUMPED) && !player->powers[pw_super] && player->panim != PA_ROLL && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - */ - if (player->flashcount) player->flashcount--; @@ -8592,16 +4425,6 @@ void P_PlayerThink(player_t *player) if (i == MAXPLAYERS && player->exiting == raceexittime+2) // finished player->exiting = raceexittime+1; - // If 10 seconds are left on the timer, - // begin the drown music for countdown! - - // SRB2Kart: despite how perfect this is, it's disabled FOR A REASON - /*if (racecountdown == 11*TICRATE - 1) - { - if (P_IsLocalPlayer(player)) - S_ChangeMusicInternal("drown", false); - }*/ - // If you've hit the countdown and you haven't made // it to the exit, you're a goner! else if (racecountdown == 1 && !player->exiting && !player->spectator && player->lives > 0) @@ -8610,9 +4433,7 @@ void P_PlayerThink(player_t *player) if (player->playerstate == PST_DEAD) { -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif return; } } @@ -8678,9 +4499,7 @@ void P_PlayerThink(player_t *player) else player->mo->flags2 &= ~MF2_SHADOW; P_DeathThink(player); -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif return; } @@ -8692,28 +4511,11 @@ void P_PlayerThink(player_t *player) player->health = 1; } -#if 0 - if ((netgame || multiplayer) && player->lives <= 0) - { - // In Co-Op, replenish a user's lives if they are depleted. - // of course, this is just a cheap hack, meh... - player->lives = cv_startinglives.value; - } -#else player->lives = 1; // SRB2Kart -#endif // SRB2kart 010217 if (leveltime < starttime) player->powers[pw_nocontrol] = 2; - /* - if ((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE) - { - cmd->buttons &= BT_BRAKE; // Remove all buttons except BT_BRAKE - cmd->forwardmove = 0; - cmd->sidemove = 0; - } - */ // Synchronizes the "real" amount of time spent in the level. if (!player->exiting) @@ -8851,25 +4653,8 @@ void P_PlayerThink(player_t *player) player->mo->reactiontime--; else if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) { - // SRB2kart - don't need no rope hangin' - //if (player->pflags & PF_ROPEHANG) - //{ - // if (!P_AnalogMove(player)) - // player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); - - // ticruned++; - // if ((cmd->angleturn & TICCMD_RECEIVED) == 0) - // ticmiss++; - - // P_DoRopeHang(player); - // P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); - // P_DoJumpStuff(player, &player->cmd); - //} - //else { P_DoZoomTube(player); - //if (!(player->panim == PA_ROLL) && player->charability2 == CA2_SPINDASH) // SRB2kart - // P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); } player->rmomx = player->rmomy = 0; // no actual momentum from your controls P_ResetScore(player); @@ -8879,9 +4664,7 @@ void P_PlayerThink(player_t *player) if (!player->mo) { -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif return; // P_MovePlayer removed player->mo. } @@ -8969,23 +4752,6 @@ void P_PlayerThink(player_t *player) if (player->powers[pw_tailsfly] && player->powers[pw_tailsfly] < UINT16_MAX /*&& player->charability != CA_SWIM*/ && !(player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) // tails fly counter player->powers[pw_tailsfly]--; - /* // SRB2kart - Can't drown. - if (player->powers[pw_underwater] && (player->pflags & PF_GODMODE || (player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL)) - { - if (player->powers[pw_underwater] <= 12*TICRATE+1) - P_RestoreMusic(player); //incase they were about to drown - - player->powers[pw_underwater] = 0; - } - else if (player->powers[pw_underwater] && !(maptol & TOL_NIGHTS) && !((netgame || multiplayer) && player->spectator)) // underwater timer - player->powers[pw_underwater]--; - - if (player->powers[pw_spacetime] && (player->pflags & PF_GODMODE || (player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL)) - player->powers[pw_spacetime] = 0; - else if (player->powers[pw_spacetime] && !(maptol & TOL_NIGHTS) && !((netgame || multiplayer) && player->spectator)) // underwater timer - player->powers[pw_spacetime]--; - */ - if (player->powers[pw_gravityboots] && player->powers[pw_gravityboots] < UINT16_MAX) player->powers[pw_gravityboots]--; @@ -9082,45 +4848,7 @@ void P_PlayerThink(player_t *player) if (rendermode != render_none) DoABarrelRoll(player); -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif - -/* -// Colormap verification - { - INT32 i,j; - sector_t *controlsec; - for (j=0; jtag) - break; - } - - if (i == numlines) - CONS_Debug(DBG_GAMELOGIC, "%d, %d\n", j, sectors[j].tag); - } - } - - I_Error("I'm done!\n"); - }*/ } // @@ -9174,229 +4902,10 @@ void P_PlayerAfterThink(player_t *player) //player->mo->eflags &= ~MFE_VERTICALFLIP; } - /* SRB2kart - don't need no weapon rings - if (!(player->pflags & PF_WPNDOWN)) - { - if (cmd->buttons & BT_WEAPONNEXT) - { - player->currentweapon++; - player->currentweapon %= NUM_WEAPONS; - player->pflags |= PF_WPNDOWN; - } - - if (cmd->buttons & BT_WEAPONPREV) - { - player->currentweapon--; - if (player->currentweapon < 0) - player->currentweapon = NUM_WEAPONS - 1; - player->pflags |= PF_WPNDOWN; - - if (player->currentweapon == WEP_RAIL && (!(player->ringweapons & RW_RAIL) || !player->powers[pw_railring])) - player->currentweapon--; - if (player->currentweapon == WEP_EXPLODE && (!(player->ringweapons & RW_EXPLODE) || !player->powers[pw_explosionring])) - player->currentweapon--; - if (player->currentweapon == WEP_GRENADE && (!(player->ringweapons & RW_GRENADE) || !player->powers[pw_grenadering])) - player->currentweapon--; - if (player->currentweapon == WEP_SCATTER && (!(player->ringweapons & RW_SCATTER) || !player->powers[pw_scatterring])) - player->currentweapon--; - if (player->currentweapon == WEP_BOUNCE && (!(player->ringweapons & RW_BOUNCE) || !player->powers[pw_bouncering])) - player->currentweapon--; - if (player->currentweapon == WEP_AUTO && (!(player->ringweapons & RW_AUTO) || !player->powers[pw_automaticring])) - player->currentweapon = 0; - } - - if (cmd->buttons & BT_WEAPONMASK) - { - //Read the bits to determine individual weapon ring selection. - INT32 weapon = (cmd->buttons & BT_WEAPONMASK); - - switch (weapon) - { - case 1: //normal / infinity - player->currentweapon = 0; - player->pflags |= PF_WPNDOWN; - break; - case 2: //automatic - if ((player->ringweapons & RW_AUTO) && player->powers[pw_automaticring]) - { - player->currentweapon = WEP_AUTO; - player->pflags |= PF_WPNDOWN; - } - break; - case 3: //bounce - if ((player->ringweapons & RW_BOUNCE) && player->powers[pw_bouncering]) - { - player->currentweapon = WEP_BOUNCE; - player->pflags |= PF_WPNDOWN; - } - break; - case 4: //scatter - if ((player->ringweapons & RW_SCATTER) && player->powers[pw_scatterring]) - { - player->currentweapon = WEP_SCATTER; - player->pflags |= PF_WPNDOWN; - } - break; - case 5: //grenade - if ((player->ringweapons & RW_GRENADE) && player->powers[pw_grenadering]) - { - player->currentweapon = WEP_GRENADE; - player->pflags |= PF_WPNDOWN; - } - break; - case 6: //explosion - if ((player->ringweapons & RW_EXPLODE) && player->powers[pw_explosionring]) - { - player->currentweapon = WEP_EXPLODE; - player->pflags |= PF_WPNDOWN; - } - break; - case 7: //rail - if ((player->ringweapons & RW_RAIL) && player->powers[pw_railring]) - { - player->currentweapon = WEP_RAIL; - player->pflags |= PF_WPNDOWN; - } - break; - } - } - } - - if (!(cmd->buttons & (BT_WEAPONNEXT|BT_WEAPONPREV|BT_WEAPONMASK))) - player->pflags &= ~PF_WPNDOWN; - - // Weapon cycling if out of ammo for a certain weapon - if (player->currentweapon == WEP_AUTO && (!(player->ringweapons & RW_AUTO) || !player->powers[pw_automaticring])) - player->currentweapon++; - if (player->currentweapon == WEP_BOUNCE && (!(player->ringweapons & RW_BOUNCE) || !player->powers[pw_bouncering])) - player->currentweapon++; - if (player->currentweapon == WEP_SCATTER && (!(player->ringweapons & RW_SCATTER) || !player->powers[pw_scatterring])) - player->currentweapon++; - if (player->currentweapon == WEP_GRENADE && (!(player->ringweapons & RW_GRENADE) || !player->powers[pw_grenadering])) - player->currentweapon++; - if (player->currentweapon == WEP_EXPLODE && (!(player->ringweapons & RW_EXPLODE) || !player->powers[pw_explosionring])) - player->currentweapon++; - if (player->currentweapon == WEP_RAIL && (!(player->ringweapons & RW_RAIL) || !player->powers[pw_railring])) - player->currentweapon = 0; - - // If you're out of rings, but have Infinity Rings left, switch to that. - if (player->currentweapon != 0 && player->health <= 1 && player->powers[pw_infinityring]) - player->currentweapon = 0; - - if (P_IsLocalPlayer(player) && (player->pflags & PF_WPNDOWN) && player->currentweapon != oldweapon) - S_StartSound(NULL, sfx_wepchg); - */ - - /* // SRB2kart - if (player->pflags & PF_GLIDING) - { - if (player->panim != PA_ABILITY) - P_SetPlayerMobjState(player->mo, S_PLAY_ABL1); - } - else */ if (player->pflags & PF_SLIDING) P_SetPlayerMobjState(player->mo, player->mo->info->painstate); - /*else if (player->pflags & PF_JUMPED - && ((!player->powers[pw_super] && player->panim != PA_ROLL) - || player->mo->state == &states[player->mo->info->painstate]) - && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1);*/ - /* // SRB2kart - fight! fight! fight! - if (player->pflags & PF_CARRIED && player->mo->tracer) - { - player->mo->height = FixedDiv(P_GetPlayerHeight(player), FixedDiv(14*FRACUNIT,10*FRACUNIT)); - - // State check for the carrier - Flame - // You are an IDIOT, those aren't even the right frames! >_> - JTE - if (player->mo->tracer->player - && !(player->mo->tracer->state >= &states[S_PLAY_ABL1] - && player->mo->tracer->state <= &states[S_PLAY_SPC4])) - player->pflags &= ~PF_CARRIED; - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if ((player->mo->tracer->z + player->mo->tracer->height + player->mo->height + FixedMul(FRACUNIT, player->mo->scale)) <= player->mo->tracer->ceilingz - && (player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Reverse gravity check for the carrier - Flame - player->mo->z = player->mo->tracer->z + player->mo->tracer->height + FixedMul(FRACUNIT, player->mo->scale); - else - player->pflags &= ~PF_CARRIED; - } - else - { - if ((player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale)) >= player->mo->tracer->floorz - && !(player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Correct gravity check for the carrier - Flame - player->mo->z = player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale); - else - player->pflags &= ~PF_CARRIED; - } - - if (player->mo->tracer->health <= 0) - player->pflags &= ~PF_CARRIED; - else - { - P_TryMove(player->mo, player->mo->tracer->x, player->mo->tracer->y, true); - player->mo->momx = player->mo->tracer->momx; - player->mo->momy = player->mo->tracer->momy; - player->mo->momz = player->mo->tracer->momz; - } - - if (gametype == GT_COOP) - { - player->mo->angle = player->mo->tracer->angle; - - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - } - - if (P_AproxDistance(player->mo->x - player->mo->tracer->x, player->mo->y - player->mo->tracer->y) > player->mo->radius) - player->pflags &= ~PF_CARRIED; - - P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); - - //if (player-players == consoleplayer && botingame) - //CV_SetValue(&cv_analog2, !(player->pflags & PF_CARRIED)); - } - else if (player->pflags & PF_ITEMHANG && player->mo->tracer) - { - // tracer is what you're hanging onto - P_UnsetThingPosition(player->mo); - player->mo->x = player->mo->tracer->x; - player->mo->y = player->mo->tracer->y; - if (player->mo->eflags & MFE_VERTICALFLIP) - player->mo->z = player->mo->tracer->z + player->mo->tracer->height - FixedDiv(player->mo->height, 3*FRACUNIT); - else - player->mo->z = player->mo->tracer->z - FixedDiv(player->mo->height, 3*FRACUNIT/2); - player->mo->momx = player->mo->momy = player->mo->momz = 0; - P_SetThingPosition(player->mo); - P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); - - // Controllable missile - if (player->mo->tracer->type == MT_BLACKEGGMAN_MISSILE) - { - if (cmd->forwardmove > 0) - player->mo->tracer->momz += FixedMul(FRACUNIT/4, player->mo->tracer->scale); - else if (cmd->forwardmove < 0) - player->mo->tracer->momz -= FixedMul(FRACUNIT/4, player->mo->tracer->scale); - - player->mo->tracer->angle = player->mo->angle; - P_InstaThrust(player->mo->tracer, player->mo->tracer->angle, FixedMul(player->mo->tracer->info->speed, player->mo->tracer->scale)); - - if (player->mo->z <= player->mo->floorz - || player->mo->tracer->health <= 0) - { - player->pflags &= ~PF_ITEMHANG; - P_SetTarget(&player->mo->tracer, NULL); - } - } - } - else */if (player->pflags & PF_MACESPIN && player->mo->tracer && player->mo->tracer->target) + if (player->pflags & PF_MACESPIN && player->mo->tracer && player->mo->tracer->target) { player->mo->height = P_GetPlayerSpinHeight(player); // tracer is what you're hanging onto.... diff --git a/src/qs22j.c b/src/qs22j.c new file mode 100644 index 000000000..53277521e --- /dev/null +++ b/src/qs22j.c @@ -0,0 +1,278 @@ +// License: 0BSD +// +// Copyright 2022 Raymond Gardner +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +#include +#include +#include "qs22j.h" + +#define INSORTTHRESH 5 // if n < this use insertion sort + // MUST be >= 2 +#define MIDTHRESH 20 // < this use middle as pivot +#define MEDOF3THRESH 50 // < this use median-of-3 as pivot + // larger subfiles use med-of-3-medians + +#define min(a,b) (((a) < (b)) ? (a) : (b)) + +typedef int32_t WORD; +typedef int64_t DWORD; +typedef void *pref_typ; + +// if no uintptr_t, use Bentley-McIlroy trick (undefined behavior) +//#define ptr_to_int(p) (p-(char*)0) +#define ptr_to_int(p) ((uintptr_t)(void *)p) + +#define ASWAP(a, b, t) ((void)(t = a, a = b, b = t)) + +#define SWAP(a, b) if (swap_type) swapf(a, b, size);\ + else do {pref_typ t; ASWAP(*(pref_typ*)(a), *(pref_typ*)(b), t);} while (0) + +#define COMP(a, b) ((*compar)((void *)(a), (void *)(b))) + +static void swapbytes(void *a0, void *b0, size_t n) +{ + char *a = a0, *b = b0, t; + do {ASWAP(*a, *b, t); a++; b++;} while (--n); +} + +static void swapdword(void *a0, void *b0, size_t n) +{ + DWORD *a = a0, *b = b0, t; + ASWAP(*a, *b, t); + (void)n; +} + +static void swapdwords(void *a0, void *b0, size_t n) +{ + DWORD *a = a0, *b = b0, t; + do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(DWORD)); +} + +static void swapword(void *a0, void *b0, size_t n) +{ + WORD *a = a0, *b = b0, t; + ASWAP(*a, *b, t); + (void)n; +} + +static void swapwords(void *a0, void *b0, size_t n) +{ + WORD *a = a0, *b = b0, t; + do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(WORD)); +} + +typedef void (*swapf_typ)(void *, void *, size_t); + +static char *med3(char *a, char *b, char *c, int (*compar)(const void *, const void *)) +{ + return COMP(a, b) < 0 ? + (COMP(b, c) < 0 ? b : COMP(a, c) < 0 ? c : a) : + (COMP(b, c) > 0 ? b : COMP(a, c) > 0 ? c : a); +} + +void qs22j(void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) +{ + char *stack[2*8*sizeof(size_t)], **sp = stack; // stack and stack pointer + char *left = base; // set up char * base pointer + char *limit = left + nmemb * size; // pointer past end of array + char *i, *ii, *j, *jj; // scan pointers + int ki = 0, kj = 0; + int swap_type = 1; + swapf_typ swapf, vecswapf; + + vecswapf = swapf = swapbytes; + if ((ptr_to_int(left) | size) % sizeof(WORD)) + { + ; // unaligned or not multple of WORD size; swap bytes + } + else if (size == sizeof(DWORD)) + { + swapf = swapdword; + vecswapf = swapdwords; + if (size == sizeof(pref_typ)) + swap_type = 0; + } + else if (size == sizeof(WORD)) + { + swapf = swapword; + vecswapf = swapwords; + if (size == sizeof(pref_typ)) + swap_type = 0; + } + else if ((size % sizeof(DWORD)) == 0) + { + swapf = vecswapf = swapdwords; + } + else if ((size % sizeof(WORD)) == 0) + { + swapf = vecswapf = swapwords; + } + for (;;) + { + nmemb = (limit - left) / size; + for (i = left + size; i < limit && COMP(i - size, i) <= 0; i += size) + ; + + if (i == limit) // if already in order + goto pop; + + if (nmemb >= INSORTTHRESH) // otherwise use insertion sort + { + char *right = limit - size; + // best so far? fewer compares, a few more swaps + char *p = left + (nmemb / 2) * size; + if (nmemb >= MIDTHRESH) + { + char *pleft = left + size; + char *pright = right - size; + + if (nmemb >= MEDOF3THRESH) + { + size_t k = (nmemb / 8) * size; + pleft = med3(pleft, left + k, left + k * 2, compar); + p = med3(p - k, p, p + k, compar); + pright = med3(right - k * 2, right - k, pright, compar); + } + + p = med3(pleft, p, pright, compar); + } + + i = ii = left; // i scans left to right + j = jj = right; // j scans right to left + for (;;) + { + + while (i <= j) + { + if (i != p && ((ki = COMP(i, p)) >= 0)) + { + if (ki) + break; + + if (ii == p) + { + p = i; + } + else if (i != ii) + { + SWAP(i, ii); + } + + ii += size; + } + i += size; + } + + while (i < j) + { + if (j != p && ((kj = COMP(j, p)) <= 0)) + { + if (kj) + break; + + if (jj == p) + { + p = j; + } + else if (j != jj) + { + SWAP(j, jj); + } + + jj -= size; + } + j -= size; + } + + if (i >= j) + break; + + SWAP(i, j); + i += size; + j -= size; + } + + if (p < i) + i -= size; + + if (p != i) + { + SWAP(p, i); + } + + ptrdiff_t lessthan = i - ii; + size_t k = min(lessthan, ii - left); + + if (k) + vecswapf(left, i - k, k); + + ptrdiff_t morethan = jj - i; + k = min(morethan, right - jj); + + if (k) + vecswapf(i + size, limit - k, k); + + if (lessthan > morethan) + { + if (lessthan > 1) + { + sp[0] = left; + sp[1] = left + lessthan; + sp += 2; // increment stack pointer + } + + if (morethan <= 1) + goto pop; + + left = limit - morethan; + } + else + { + if (morethan > 1) + { + sp[0] = limit - morethan; + sp[1] = limit; + sp += 2; // increment stack pointer + } + + if (lessthan <= 1) + goto pop; + + limit = left + lessthan; + } + + } + else // else subfile is small, use insertion sort + { + for (i = left + size; i < limit; i += size) + { + for (j = i; j != left && COMP(j - size, j) > 0; j -= size) + { + SWAP(j - size, j); + } + } +pop: + if (sp != stack) // if any entries on stack + { + sp -= 2; // pop the left and limit + left = sp[0]; + limit = sp[1]; + } + else // else stack empty, done + break; + } + } +} diff --git a/src/qs22j.h b/src/qs22j.h new file mode 100644 index 000000000..95d1c1292 --- /dev/null +++ b/src/qs22j.h @@ -0,0 +1,7 @@ +#ifndef __QS22J__ +#define __QS22J__ + +void qs22j(void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)); + +#endif diff --git a/src/r_bsp.c b/src/r_bsp.c index 2de30d2ab..83f530f2a 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -21,6 +21,8 @@ #include "p_slopes.h" #include "z_zone.h" // Check R_Prep3DFloors +#include "qs22j.h" + seg_t *curline; side_t *sidedef; line_t *linedef; @@ -410,8 +412,18 @@ static void R_AddLine(seg_t *line) return; // big room fix - angle1 = R_PointToAngle64(line->v1->x, line->v1->y); - angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(line->v1->x, line->v1->y); + angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, line->v1->x, line->v1->y); + angle2 = R_PointToAngleEx(viewx, viewy, line->v2->x, line->v2->y); + } + curline = line; // Clip to view edges. @@ -613,8 +625,16 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) check = checkcoord[boxpos]; // big room fix - angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; - angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; + angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, bspcoord[check[0]], bspcoord[check[1]]) - viewangle; + angle2 = R_PointToAngleEx(viewx, viewy, bspcoord[check[2]], bspcoord[check[3]]) - viewangle; + } if ((signed)angle1 < (signed)angle2) { @@ -707,7 +727,7 @@ void R_SortPolyObjects(subsector_t *sub) // 03/10/06: only bother if there are actually polys to sort if (numpolys >= 2) { - qsort(po_ptrs, numpolys, sizeof(polyobj_t *), + qs22j(po_ptrs, numpolys, sizeof(polyobj_t *), R_PolyobjCompare); } } @@ -810,7 +830,7 @@ static void R_AddPolyObjects(subsector_t *sub) // render polyobjects for (i = 0; i < numpolys; ++i) { - qsort(po_ptrs[i]->segs, po_ptrs[i]->segCount, sizeof(seg_t *), R_PolysegCompare); + qs22j(po_ptrs[i]->segs, po_ptrs[i]->segCount, sizeof(seg_t *), R_PolysegCompare); for (j = 0; j < po_ptrs[i]->segCount; ++j) R_AddLine(po_ptrs[i]->segs[j]); } @@ -1293,9 +1313,9 @@ void R_RenderBSPNode(INT32 bspnum) { node_t *bsp; INT32 side; - + ps_numbspcalls.value.i++; - + while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? { bsp = &nodes[bspnum]; @@ -1306,7 +1326,6 @@ void R_RenderBSPNode(INT32 bspnum) R_RenderBSPNode(bsp->children[side]); // Possibly divide back space. - if (!R_CheckBBox(bsp->bbox[side^1])) return; @@ -1314,7 +1333,8 @@ void R_RenderBSPNode(INT32 bspnum) } // PORTAL CULLING - if (portalcullsector) { + if (portalcullsector) + { sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector; if (sect != portalcullsector) return; diff --git a/src/r_defs.h b/src/r_defs.h index 085d25e0b..f5a4195bc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -25,7 +25,6 @@ #include "screen.h" // MAXVIDWIDTH, MAXVIDHEIGHT -#define POLYOBJECTS // // ClipWallSegment @@ -211,19 +210,6 @@ typedef struct r_lightlist_s INT32 lightnum; } r_lightlist_t; -// ----- for special tricks with HW renderer ----- - -// -// For creating a chain with the lines around a sector -// -typedef struct linechain_s -{ - struct line_s *line; - struct linechain_s *next; -} linechain_t; -// ----- end special tricks ----- - - // Slopes typedef enum { @@ -352,17 +338,6 @@ typedef struct sector_s // per-sector colormaps! extracolormap_t *extra_colormap; -#ifdef HWRENDER // ----- for special tricks with HW renderer ----- - boolean pseudoSector; - boolean virtualFloor; - fixed_t virtualFloorheight; - boolean virtualCeiling; - fixed_t virtualCeilingheight; - linechain_t *sectorLines; - struct sector_s **stackList; - double lineoutLength; -#endif // ----- end special tricks ----- - // This points to the master's floorheight, so it can be changed in realtime! fixed_t *gravity; // per-sector gravity boolean verticalflip; // If gravity < 0, then allow flipped physics diff --git a/src/r_draw.c b/src/r_draw.c index df43ecd01..c19febc8a 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -348,8 +348,8 @@ void R_FlushTranslationColormapCache(void) for (i = 0; i < (INT32)(sizeof(translationtablecache) / sizeof(translationtablecache[0])); i++) if (translationtablecache[i]) memset(translationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**)); - - for (i = 0; i < (INT32)(sizeof(localtranslationtablecache) / sizeof(localtranslationtablecache[0])); i++) + + for (i = 0; i < (INT32)(sizeof(localtranslationtablecache) / sizeof(localtranslationtablecache[0])); i++) if (localtranslationtablecache[i]) memset(localtranslationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**)); } diff --git a/src/r_fps.c b/src/r_fps.c index 07d34992d..14c75e8fd 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -16,12 +16,16 @@ #include "r_main.h" #include "g_game.h" +#include "k_kart.h" // saltyhop stuffs #include "i_video.h" #include "r_plane.h" #include "p_spec.h" #include "r_state.h" #include "z_zone.h" #include "console.h" // con_startup_loadprogress +#ifdef HWRENDER +#include "hardware/hw_main.h" // for cv_grshearing +#endif static CV_PossibleValue_t fpscap_cons_t[] = { #ifdef DEVELOP @@ -39,6 +43,8 @@ consvar_t cv_fpscap = {"fpscap", "Match refresh rate", CV_SAVE, fpscap_cons_t, N consvar_t cv_precipinterp = {"precipinterpolation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mobjssector = {"mobjsubsectorinterp", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + UINT32 R_GetFramerateCap(void) { if (rendermode == render_none) @@ -95,7 +101,7 @@ static angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac) return from + FixedMul(frac, to - from); } -static vector2_t *R_LerpVector2(const vector2_t *from, const vector2_t *to, fixed_t frac, vector2_t *out) +/*static vector2_t *R_LerpVector2(const vector2_t *from, const vector2_t *to, fixed_t frac, vector2_t *out) { FV2_SubEx(to, from, out); FV2_MulEx(out, frac, out); @@ -109,19 +115,20 @@ static vector3_t *R_LerpVector3(const vector3_t *from, const vector3_t *to, fixe FV3_MulEx(out, frac, out); FV3_AddEx(from, out, out); return out; -} +}*/ // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). // 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(void) { - (void)player; - (void)skybox; - // clip it in the case we are looking a hardware 90 degrees full aiming // (lmps, network and use F12...) - if (rendermode == render_soft) + if (rendermode == render_soft +#ifdef HWRENDER + || cv_grshearing.value +#endif + ) { G_SoftwareClipAimingPitch((INT32 *)&aimingangle); } @@ -142,7 +149,6 @@ static void R_SetupFreelook(player_t *player, boolean skybox) void R_InterpolateView(fixed_t frac) { viewvars_t* prevview = oldview; - boolean skybox = 0; UINT8 i; if (FIXED_TO_FLOAT(frac) < 0) @@ -180,7 +186,7 @@ void R_InterpolateView(fixed_t frac) viewplayer = newview->player; viewsector = R_PointInSubsector(viewx, viewy)->sector; - R_SetupFreelook(newview->player, skybox); + R_SetupFreelook(); } void R_UpdateViewInterpolation(void) @@ -252,7 +258,7 @@ void R_SetViewContext(enum viewcontext_e _viewcontext) } } -fixed_t R_InterpolateFixed(fixed_t from, fixed_t to) +/*fixed_t R_InterpolateFixed(fixed_t from, fixed_t to) { if (!R_UsingFrameInterpolation()) { @@ -270,7 +276,7 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to) } return (R_LerpAngle(from, to, rendertimefrac)); -} +}*/ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) { @@ -293,46 +299,87 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) return; } - out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); - out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); - out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); - out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); - out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); - out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); - + if (mobj->x == mobj->old_x) + out->x = mobj->x; + else + out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); + + if (mobj->y == mobj->old_y) + out->y = mobj->y; + else + out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); + + if (mobj->z == mobj->old_z) + out->z = mobj->z; + else + out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); + + if (mobj->spritexscale == mobj->old_spritexscale) + out->spritexscale = mobj->spritexscale; + else + out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); + + if (mobj->spriteyscale == mobj->old_spriteyscale) + out->spriteyscale = mobj->spriteyscale; + else + out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); + + if (mobj->spritexoffset == mobj->old_spritexoffset) + out->spritexoffset = mobj->spritexoffset; + else + out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); + + if (mobj->spriteyoffset == mobj->old_spriteyoffset) + out->spriteyoffset = mobj->spriteyoffset; + else + out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); + if (mobj->scale == mobj->old_scale) // Tiny optimisation - scale is usually unchanging, so let's skip a lerp, two FixedMuls, and two FixedDivs - { out->scale = mobj->scale; - } else - { out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac); - } - // Sprite offsets are not interpolated until we have a way to interpolate them explicitly in Lua. - // It seems existing mods visually break more often than not if it is interpolated. - //out->spritexoffset = mobj->spritexoffset; - //out->spriteyoffset = mobj->spriteyoffset; - - out->subsector = R_PointInSubsector(out->x, out->y); + if (cv_mobjssector.value) + out->subsector = R_PointInSubsector(out->x, out->y); + else + out->subsector = mobj->subsector; if (mobj->player) { - out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac); + if (mobj->angle == mobj->player->old_frameangle) + out->angle = mobj->player->frameangle; + else + out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac); } else { - out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); + if (mobj->angle == mobj->old_angle) + out->angle = mobj->angle; + else + out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); } // pitch roll stuff - out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); - out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); + if (mobj->pitch == mobj->old_pitch) + out->pitch = mobj->pitch; + else + out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); + + if (mobj->roll == mobj->old_roll) + out->roll = mobj->roll; + else + out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); // and the slope stuff - out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); - out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); + if (mobj->slopepitch == mobj->old_slopepitch) + out->slopepitch = mobj->slopepitch; + else + out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); + + if (mobj->sloperoll == mobj->old_sloperoll) + out->sloperoll = mobj->sloperoll; + else + out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); } void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjstate_t *out) @@ -361,9 +408,15 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->spritexoffset = mobj->spritexoffset; out->spriteyoffset = mobj->spriteyoffset; - out->subsector = R_PointInSubsector(out->x, out->y); + if (cv_mobjssector.value) + out->subsector = R_PointInSubsector(out->x, out->y); + else + out->subsector = mobj->subsector; - out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); + if (mobj->angle == mobj->old_angle) + out->angle = mobj->angle; + else + out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); } static void AddInterpolator(levelinterpolator_t* interpolator) @@ -463,7 +516,7 @@ void R_CreateInterpolator_Polyobj(thinker_t *thinker, polyobj_t *polyobj) interp->polyobj.oldcy = interp->polyobj.bakcy = polyobj->centerPt.y; } -void R_CreateInterpolator_DynSlope(thinker_t *thinker, pslope_t *slope) +/*void R_CreateInterpolator_DynSlope(thinker_t *thinker, pslope_t *slope) { levelinterpolator_t *interp = CreateInterpolator(LVLINTERP_DynSlope, thinker); interp->dynslope.slope = slope; @@ -475,7 +528,7 @@ void R_CreateInterpolator_DynSlope(thinker_t *thinker, pslope_t *slope) FV2_Copy(&interp->dynslope.bakd, &slope->d); interp->dynslope.oldzdelta = interp->dynslope.bakzdelta = slope->zdelta; -} +}*/ void R_InitializeLevelInterpolators(void) { @@ -519,7 +572,7 @@ static void UpdateLevelInterpolatorState(levelinterpolator_t *interp) interp->polyobj.bakcx = interp->polyobj.polyobj->centerPt.x; interp->polyobj.bakcy = interp->polyobj.polyobj->centerPt.y; break; - case LVLINTERP_DynSlope: + /*case LVLINTERP_DynSlope: FV3_Copy(&interp->dynslope.oldo, &interp->dynslope.bako); FV2_Copy(&interp->dynslope.oldd, &interp->dynslope.bakd); interp->dynslope.oldzdelta = interp->dynslope.bakzdelta; @@ -527,7 +580,7 @@ static void UpdateLevelInterpolatorState(levelinterpolator_t *interp) FV3_Copy(&interp->dynslope.bako, &interp->dynslope.slope->o); FV2_Copy(&interp->dynslope.bakd, &interp->dynslope.slope->d); interp->dynslope.bakzdelta = interp->dynslope.slope->zdelta; - break; + break;*/ } } @@ -573,44 +626,86 @@ void R_ApplyLevelInterpolators(fixed_t frac) case LVLINTERP_SectorPlane: if (interp->sectorplane.ceiling) { - interp->sectorplane.sector->ceilingheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); + if (interp->sectorplane.sector->ceilingheight == interp->sectorplane.oldheight) + interp->sectorplane.sector->ceilingheight = interp->sectorplane.bakheight; + else + interp->sectorplane.sector->ceilingheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); } else { - interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); + if (interp->sectorplane.sector->floorheight == interp->sectorplane.oldheight) + interp->sectorplane.sector->floorheight = interp->sectorplane.bakheight; + else + interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); } interp->sectorplane.sector->moved = true; break; case LVLINTERP_SectorScroll: if (interp->sectorscroll.ceiling) { - interp->sectorscroll.sector->ceiling_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); - interp->sectorscroll.sector->ceiling_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); + if (interp->sectorscroll.sector->ceiling_xoffs == interp->sectorscroll.oldxoffs) + interp->sectorscroll.sector->ceiling_xoffs = interp->sectorscroll.bakxoffs; + else + interp->sectorscroll.sector->ceiling_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); + + if (interp->sectorscroll.sector->ceiling_yoffs == interp->sectorscroll.oldyoffs) + interp->sectorscroll.sector->ceiling_yoffs = interp->sectorscroll.bakyoffs; + else + interp->sectorscroll.sector->ceiling_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } else { - interp->sectorscroll.sector->floor_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); - interp->sectorscroll.sector->floor_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); + if (interp->sectorscroll.sector->floor_xoffs == interp->sectorscroll.oldxoffs) + interp->sectorscroll.sector->floor_xoffs = interp->sectorscroll.bakxoffs; + else + interp->sectorscroll.sector->floor_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); + + if (interp->sectorscroll.sector->floor_yoffs == interp->sectorscroll.oldyoffs) + interp->sectorscroll.sector->floor_yoffs = interp->sectorscroll.bakyoffs; + else + interp->sectorscroll.sector->floor_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } break; case LVLINTERP_SideScroll: - interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac); - interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac); + if (interp->sidescroll.side->textureoffset == interp->sidescroll.oldtextureoffset) + interp->sidescroll.side->textureoffset = interp->sidescroll.baktextureoffset; + else + interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac); + + if (interp->sidescroll.side->rowoffset == interp->sidescroll.oldrowoffset) + interp->sidescroll.side->rowoffset = interp->sidescroll.bakrowoffset; + else + interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac); break; case LVLINTERP_Polyobj: for (ii = 0; ii < interp->polyobj.vertices_size; ii++) { - interp->polyobj.polyobj->vertices[ii]->x = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 ], interp->polyobj.bakvertices[ii * 2 ], frac); - interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac); + if (interp->polyobj.polyobj->vertices[ii]->x == interp->polyobj.oldvertices[ii * 2 ]) + interp->polyobj.polyobj->vertices[ii]->x = interp->polyobj.bakvertices[ii * 2 ]; + else + interp->polyobj.polyobj->vertices[ii]->x = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 ], interp->polyobj.bakvertices[ii * 2 ], frac); + + if (interp->polyobj.polyobj->vertices[ii]->y == interp->polyobj.oldvertices[ii * 2 + 1]) + interp->polyobj.polyobj->vertices[ii]->y = interp->polyobj.bakvertices[ii * 2 + 1]; + else + interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac); } - interp->polyobj.polyobj->centerPt.x = R_LerpFixed(interp->polyobj.oldcx, interp->polyobj.bakcx, frac); - interp->polyobj.polyobj->centerPt.y = R_LerpFixed(interp->polyobj.oldcy, interp->polyobj.bakcy, frac); + if (interp->polyobj.polyobj->centerPt.x == interp->polyobj.oldcx) + interp->polyobj.polyobj->centerPt.x = interp->polyobj.bakcx; + else + interp->polyobj.polyobj->centerPt.x = R_LerpFixed(interp->polyobj.oldcx, interp->polyobj.bakcx, frac); + + if (interp->polyobj.polyobj->centerPt.y == interp->polyobj.oldcy) + interp->polyobj.polyobj->centerPt.y = interp->polyobj.bakcy; + else + interp->polyobj.polyobj->centerPt.y = R_LerpFixed(interp->polyobj.oldcy, interp->polyobj.bakcy, frac); + break; - case LVLINTERP_DynSlope: + /*case LVLINTERP_DynSlope: R_LerpVector3(&interp->dynslope.oldo, &interp->dynslope.bako, frac, &interp->dynslope.slope->o); R_LerpVector2(&interp->dynslope.oldd, &interp->dynslope.bakd, frac, &interp->dynslope.slope->d); interp->dynslope.slope->zdelta = R_LerpFixed(interp->dynslope.oldzdelta, interp->dynslope.bakzdelta, frac); - break; + break;*/ } } } @@ -661,11 +756,11 @@ void R_RestoreLevelInterpolators(void) interp->polyobj.polyobj->centerPt.x = interp->polyobj.bakcx; interp->polyobj.polyobj->centerPt.y = interp->polyobj.bakcy; break; - case LVLINTERP_DynSlope: + /*case LVLINTERP_DynSlope: FV3_Copy(&interp->dynslope.slope->o, &interp->dynslope.bako); FV2_Copy(&interp->dynslope.slope->d, &interp->dynslope.bakd); interp->dynslope.slope->zdelta = interp->dynslope.bakzdelta; - break; + break;*/ } } } diff --git a/src/r_fps.h b/src/r_fps.h index deb0c8788..1c0f1f884 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -21,6 +21,7 @@ extern consvar_t cv_fpscap; extern consvar_t cv_precipinterp; +extern consvar_t cv_mobjssector; UINT32 R_GetFramerateCap(void); boolean R_UsingFrameInterpolation(void); @@ -77,7 +78,7 @@ typedef enum { LVLINTERP_SectorScroll, LVLINTERP_SideScroll, LVLINTERP_Polyobj, - LVLINTERP_DynSlope, + //LVLINTERP_DynSlope, } levelinterpolator_type_e; // Tagged union of a level interpolator diff --git a/src/r_main.c b/src/r_main.c index 297a06a68..fd2707a2d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -145,17 +145,20 @@ static CV_PossibleValue_t drawdist_cons_t[] = { {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -//static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}}; - static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {0, "None"}, {0, NULL}}; +static CV_PossibleValue_t maxinterpdist_cons_t[] = { + /*{256, "256"},*/ {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, + {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; + static CV_PossibleValue_t fov_cons_t[] = {{5*FRACUNIT, "MIN"}, {178*FRACUNIT, "MAX"}, {0, NULL}}; -//static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}}; static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; static CV_PossibleValue_t maxportals_cons_t[] = {{0, "MIN"}, {12, "MAX"}, {0, NULL}}; // lmao rendering 32 portals, you're a card static CV_PossibleValue_t homremoval_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Flash"}, {0, NULL}}; @@ -196,10 +199,10 @@ consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_c consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -//consvar_t cv_drawdist_nights = {"drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -//consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // cap fov, fov too high tears software apart. consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -209,6 +212,9 @@ consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t pointoangle_cons_t[] = {{0, "Ex"}, {1, "64"}, {0, NULL}}; +consvar_t cv_pointoangleexor64 = {"r_pointtoangle", "64", CV_SAVE, pointoangle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + void SplitScreen_OnChange(void) { UINT8 i; @@ -325,7 +331,7 @@ static void FlipCam4_OnChange(void) // // killough 5/2/98: reformatted // -INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *restrict node) +PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *restrict node) { if (!node->dx) return x <= node->x ? node->dy > 0 : node->dy < 0; @@ -344,7 +350,7 @@ INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *restrict node) } // killough 5/2/98: reformatted -INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line) +PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) { fixed_t lx = line->v1->x; fixed_t ly = line->v1->y; @@ -412,6 +418,29 @@ angle_t R_PointToAngle64(INT64 x, INT64 y) 0; } +angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1) +{ + INT64 dx = x1-x2; + INT64 dy = y1-y2; + if (dx < INT32_MIN || dx > INT32_MAX || dy < INT32_MIN || dy > INT32_MAX) + { + x1 = (int)(dx / 2 + x2); + y1 = (int)(dy / 2 + y2); + } + return (y1 -= y2, (x1 -= x2) || y1) ? + x1 >= 0 ? + y1 >= 0 ? + (x1 > y1) ? tantoangle[SlopeDivEx(y1,x1)] : // octant 0 + ANGLE_90-tantoangle[SlopeDivEx(x1,y1)] : // octant 1 + x1 > (y1 = -y1) ? 0-tantoangle[SlopeDivEx(y1,x1)] : // octant 8 + ANGLE_270+tantoangle[SlopeDivEx(x1,y1)] : // octant 7 + y1 >= 0 ? (x1 = -x1) > y1 ? ANGLE_180-tantoangle[SlopeDivEx(y1,x1)] : // octant 3 + ANGLE_90 + tantoangle[SlopeDivEx(x1,y1)] : // octant 2 + (x1 = -x1) > (y1 = -y1) ? ANGLE_180+tantoangle[SlopeDivEx(y1,x1)] : // octant 4 + ANGLE_270-tantoangle[SlopeDivEx(x1,y1)] : // octant 5 + 0; +} + angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) { return (y -= pviewy, (x -= pviewx) || y) ? @@ -1048,7 +1077,6 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) INT32 side, i; size_t nodenum; subsector_t *ret; - seg_t *seg; // single subsector is a special case if (numnodes == 0) @@ -1078,31 +1106,6 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) static mobj_t *viewmobj; -// recalc necessary stuff for mouseaiming -// slopes are already calculated for the full possible view (which is 4*viewheight). -// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) -static void R_SetupFreelook(void) -{ - INT32 dy = 0; - - // clip it in the case we are looking a hardware 90 degrees full aiming - // (lmps, network and use F12...) - if (rendermode == render_soft -#ifdef HWRENDER - || cv_grshearing.value -#endif - ) - G_SoftwareClipAimingPitch((INT32 *)&aimingangle); - - if (rendermode == render_soft) - { - dy = (AIMINGTODY(aimingangle)>>FRACBITS) * viewwidth/BASEVIDWIDTH; - yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)]; - } - centery = (viewheight/2) + dy; - centeryfrac = centery<dontrenderme && curline->polyseg && (curline->polyseg->flags & POF_RENDERPLANES)) - { - fixed_t my_topscreen; - fixed_t my_bottomscreen; - fixed_t my_yl, my_yh; - - my_topscreen = sprtopscreen + spryscale*col->topdelta; - my_bottomscreen = sprbotscreen == INT32_MAX ? my_topscreen + spryscale*col->length - : sprbotscreen + spryscale*col->length; - - my_yl = (my_topscreen+FRACUNIT-1)>>FRACBITS; - my_yh = (my_bottomscreen-1)>>FRACBITS; - // CONS_Debug(DBG_RENDER, "my_topscreen: %d\nmy_bottomscreen: %d\nmy_yl: %d\nmy_yh: %d\n", my_topscreen, my_bottomscreen, my_yl, my_yh); - - if (numffloors) - { - INT32 top = my_yl; - INT32 bottom = my_yh; - - for (i = 0; i < numffloors; i++) - { - if (!ffloor[i].polyobj || ffloor[i].polyobj != curline->polyseg) - continue; - - if (ffloor[i].height < viewz) - { - INT32 top_w = ffloor[i].plane->top[dc_x]; - - // CONS_Debug(DBG_RENDER, "Leveltime : %d\n", leveltime); - // CONS_Debug(DBG_RENDER, "Top is %d, top_w is %d\n", top, top_w); - if (top_w < top) - { - ffloor[i].plane->top[dc_x] = (INT16)top; - ffloor[i].plane->picnum = 0; - } - // CONS_Debug(DBG_RENDER, "top_w is now %d\n", ffloor[i].plane->top[dc_x]); - } - else if (ffloor[i].height > viewz) - { - INT32 bottom_w = ffloor[i].plane->bottom[dc_x]; - - if (bottom_w > bottom) - { - ffloor[i].plane->bottom[dc_x] = (INT16)bottom; - ffloor[i].plane->picnum = 0; - } - } - } - } - } - else -#endif - colfunc_2s(col); + + colfunc_2s(col); } spryscale += rw_scalestep; } @@ -755,7 +701,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (pfloor->master->flags & ML_TFERLINE) { - size_t linenum = min(curline->linedef-backsector->lines[0], pfloor->master->frontsector->linecount); + size_t linenum = min((size_t)(curline->linedef-backsector->lines[0]), pfloor->master->frontsector->linecount); newline = pfloor->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } @@ -1628,6 +1574,7 @@ static void R_RenderSegLoop (void) { if (curline->polyseg && (ffloor[i].polyobj != curline->polyseg)) continue; + ffloor[i].f_frac += ffloor[i].f_step; } @@ -2634,13 +2581,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) } else { -#ifdef ESLOPE ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); ffloor[i].f_step = ((centeryfrac>>4) - FixedMul(ffloor[i].f_pos_slope, ds_p->scale2) - ffloor[i].f_frac)/(range); -#else - ffloor[i].f_step = FixedMul(-rw_scalestep, ffloor[i].f_pos); - ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); -#endif } } } diff --git a/src/r_state.h b/src/r_state.h index e37bdf52e..670f800d1 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -102,6 +102,8 @@ extern INT32 portalclipstart, portalclipend; extern consvar_t cv_allowmlook; extern consvar_t cv_maxportals; +extern consvar_t cv_pointoangleexor64; + extern angle_t clipangle; extern angle_t doubleclipangle; diff --git a/src/r_things.c b/src/r_things.c index 6cc11b49f..c66ca9f58 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -36,6 +36,8 @@ #include "hardware/hw_md2.h" #endif +#include "qs22j.h" + #ifdef PC_DOS #include // for snprintf int snprintf(char *str, size_t n, const char *fmt, ...); @@ -475,116 +477,6 @@ void R_AddSpriteDefs(UINT16 wadnum) CONS_Printf(M_GetText("%s added %d frames in %s sprites\n"), wadname, end-start, sizeu1(addsprites)); } -#ifdef DELFILE -static void R_RemoveSpriteLump(UINT16 wad, // graphics patch - UINT16 lump, - size_t lumpid, // identifier - UINT8 frame, - UINT8 rotation, - UINT8 flipped) -{ - (void)wad; /// \todo: how do I remove sprites? - (void)lump; - (void)lumpid; - (void)frame; - (void)rotation; - (void)flipped; -} - -static boolean R_DelSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump) -{ - UINT16 l; - UINT8 frame; - UINT8 rotation; - lumpinfo_t *lumpinfo; - - maxframe = (size_t)-1; - - // scan the lumps, - // filling in the frames for whatever is found - lumpinfo = wadfiles[wadnum]->lumpinfo; - if (endlump > wadfiles[wadnum]->numlumps) - endlump = wadfiles[wadnum]->numlumps; - - for (l = startlump; l < endlump; l++) - { - if (memcmp(lumpinfo[l].name,sprname,4)==0) - { - frame = (UINT8)(lumpinfo[l].name[4] - 'A'); - rotation = (UINT8)(lumpinfo[l].name[5] - '0'); - - // skip NULL sprites from very old dmadds pwads - if (W_LumpLengthPwad(wadnum,l)<=8) - continue; - - //---------------------------------------------------- - - R_RemoveSpriteLump(wadnum, l, numspritelumps, frame, rotation, 0); - - if (lumpinfo[l].name[6]) - { - frame = (UINT8)(lumpinfo[l].name[6] - 'A'); - rotation = (UINT8)(lumpinfo[l].name[7] - '0'); - R_RemoveSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1); - } - } - } - - if (maxframe == (size_t)-1) - return false; - - spritedef->numframes = 0; - Z_Free(spritedef->spriteframes); - spritedef->spriteframes = NULL; - return true; -} - -void R_DelSpriteDefs(UINT16 wadnum) -{ - size_t i, delsprites = 0; - UINT16 start, end; - - // find the sprites section in this pwad - // we need at least the S_END - // (not really, but for speedup) - - start = W_CheckNumForNamePwad("S_START", wadnum, 0); - if (start == INT16_MAX) - start = W_CheckNumForNamePwad("SS_START", wadnum, 0); //deutex compatib. - if (start == INT16_MAX) - start = 0; //let say S_START is lump 0 - else - start++; // just after S_START - - end = W_CheckNumForNamePwad("S_END",wadnum,start); - if (end == INT16_MAX) - end = W_CheckNumForNamePwad("SS_END",wadnum,start); //deutex compatib. - if (end == INT16_MAX) - { - CONS_Debug(DBG_SETUP, "no sprites in pwad %d\n", wadnum); - return; - //I_Error("R_DelSpriteDefs: S_END, or SS_END missing for sprites " - // "in pwad %d\n",wadnum); - } - - // - // scan through lumps, for each sprite, find all the sprite frames - // - for (i = 0; i < numsprites; i++) - { - spritename = sprnames[i]; - - if (R_DelSingleSpriteDef(spritename, &sprites[i], wadnum, start, end)) - { - // if a new sprite was removed (not just replaced) - delsprites++; - CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", spritename, wadnum); - } - } - - CONS_Printf(M_GetText("%s sprites removed from file %s\n"), sizeu1(delsprites), wadfiles[wadnum]->filename); -} -#endif // // GAME FUNCTIONS @@ -1225,65 +1117,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) groundslope = NULL; } -#if 0 // Unfortunately, this drops CEZ2 down to sub-17 FPS on my i7. - // NOTE: this section was not updated to reflect reverse gravity support - // Check polyobjects and see if groundz needs to be altered, for rings only because they don't update floorz - if (thing->type == MT_RING) - { - INT32 xl, xh, yl, yh, bx, by; - - xl = (unsigned)(thing->x - thing->radius - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(thing->x + thing->radius - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(thing->y - thing->radius - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(thing->y + thing->radius - bmaporgy)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - validcount++; - - for (by = yl; by <= yh; by++) - for (bx = xl; bx <= xh; bx++) - { - INT32 offset; - polymaplink_t *plink; // haleyjd 02/22/06 - - if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) - continue; - - offset = by*bmapwidth + bx; - - // haleyjd 02/22/06: consider polyobject lines - plink = polyblocklinks[offset]; - - while (plink) - { - polyobj_t *po = plink->po; - - if (po->validcount != validcount) // if polyobj hasn't been checked - { - po->validcount = validcount; - - if (!P_MobjInsidePolyobj(po, thing) || !(po->flags & POF_RENDERPLANES)) - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - // We're inside it! Yess... - z = po->lines[0]->backsector->ceilingheight; - - if (z < thing->z+thing->height/2 && z > groundz) - { - groundz = z; - groundslope = NULL; - } - } - plink = (polymaplink_t *)(plink->link.next); - } - } - } -#endif - if (shadowslope != NULL) *shadowslope = groundslope; @@ -1316,15 +1149,13 @@ static void R_ProjectSprite(mobj_t *thing) size_t rot; UINT8 flip; /*boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(thing));*/ - + boolean mirrored = thing->mirrored; boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); INT32 lindex; vissprite_t *vis; - - spritecut_e cut = SC_NONE; angle_t ang = 0; // gcc 4.6 and lower fix angle_t camang = 0; @@ -1352,12 +1183,17 @@ static void R_ProjectSprite(mobj_t *thing) #endif fixed_t ang_scale = FRACUNIT; + + INT32 dist = -1; + + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); // uncapped/interpolation interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolateMobjState(oldthing, rendertimefrac, &interp); } @@ -1877,11 +1713,16 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) //SoM: 3/17/2000 fixed_t gz ,gzt; + INT32 dist = 1; + + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); + // uncapped/interpolation interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp); } @@ -2495,20 +2336,6 @@ static void R_CreateDrawNodes(void) } else if (r2->seg) { -#if 0 //#ifdef POLYOBJECTS_PLANES - if (r2->seg->curline->polyseg && rover->mobj && P_MobjInsidePolyobj(r2->seg->curline->polyseg, rover->mobj)) { - // Determine if we need to sort in front of the polyobj, based on the planes. This fixes the issue where - // polyobject planes render above the object standing on them. (A bit hacky... but it works.) -Red - mobj_t *mo = rover->mobj; - sector_t *po = r2->seg->curline->backsector; - - if (po->ceilingheight < viewz && mo->z+mo->height > po->ceilingheight) - continue; - - if (po->floorheight > viewz && mo->z < po->floorheight) - continue; - } -#endif if (rover->x1 > r2->seg->x2 || rover->x2 < r2->seg->x1) continue; @@ -3362,93 +3189,92 @@ static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what const UINT8 val_a = *((const UINT8 *)a); const UINT8 val_b = *((const UINT8 *)b); - //return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==); switch (cv_skinselectgridsort.value) { - case SKINMENUSORT_REALNAME: - //CONS_Printf("Sorting by realname\n"); - // check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_REALNAME: + //CONS_Printf("Sorting by realname\n"); + // check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_NAME: - //CONS_Printf("Sorting by name\n"); - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_NAME: + //CONS_Printf("Sorting by name\n"); + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_SPEED: - //CONS_Printf("Sorting by speed\n"); - // check speed - if (in1->kartspeed < in2->kartspeed) - return -1; - else if (in2->kartspeed < in1->kartspeed) - return 1; - // then check weight - if (in1->kartweight < in2->kartweight) - return -1; - else if (in2->kartweight < in1->kartweight) - return 1; - // then check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_SPEED: + //CONS_Printf("Sorting by speed\n"); + // check speed + if (in1->kartspeed < in2->kartspeed) + return -1; + else if (in2->kartspeed < in1->kartspeed) + return 1; + // then check weight + if (in1->kartweight < in2->kartweight) + return -1; + else if (in2->kartweight < in1->kartweight) + return 1; + // then check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_WEIGHT: - //CONS_Printf("Sorting by weight\n"); - // check weight - if (in1->kartweight < in2->kartweight) - return -1; - else if (in2->kartweight < in1->kartweight) - return 1; - // then check speed - if (in1->kartspeed < in2->kartspeed) - return -1; - else if (in2->kartspeed < in1->kartspeed) - return 1; - // then check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_WEIGHT: + //CONS_Printf("Sorting by weight\n"); + // check weight + if (in1->kartweight < in2->kartweight) + return -1; + else if (in2->kartweight < in1->kartweight) + return 1; + // then check speed + if (in1->kartspeed < in2->kartspeed) + return -1; + else if (in2->kartspeed < in1->kartspeed) + return 1; + // then check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_PREFCOLOR: - //CONS_Printf("Sorting by prefcolor\n"); - // check prefcolor - if (in1->prefcolor < in2->prefcolor) - return -1; - else if (in2->prefcolor < in1->prefcolor) - return 1; - // then check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_PREFCOLOR: + //CONS_Printf("Sorting by prefcolor\n"); + // check prefcolor + if (in1->prefcolor < in2->prefcolor) + return -1; + else if (in2->prefcolor < in1->prefcolor) + return 1; + // then check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_ID: - //CONS_Printf("Sorting by id\n"); - //how do i do by ID????? - //wait why dont i just convert the inputs to UINT32s - //please tell me im allowed to define variables in here since its a block + case SKINMENUSORT_ID: + //CONS_Printf("Sorting by id\n"); + //how do i do by ID????? + //wait why dont i just convert the inputs to UINT32s + //please tell me im allowed to define variables in here since its a block - if (val_a == val_b) - return 0; - else if (val_a < val_b) - return -1; - else - return 1; + if (val_a == val_b) + return 0; + else if (val_a < val_b) + return -1; + else + return 1; - default: - return strcmp(in1->name, in2->name); - break; + default: + return strcmp(in1->name, in2->name); + break; } //im scared this somehow will sometimes end up here so im gonna add this here just to be safe return strcmp(in1->name, in2->name); @@ -3456,8 +3282,8 @@ static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what void sortSkinGrid(void) { - CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); - qsort(skinsorted, numskins, sizeof(UINT8), skinSortFunc); + //CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); + qs22j(skinsorted, numskins, sizeof(UINT8), skinSortFunc); } // @@ -3585,22 +3411,25 @@ void R_AddSkins(UINT16 wadnum, boolean local) else if (!stricmp(stoken, "sprite")) { strupr(value); - strncpy(skin->sprite, value, sizeof skin->sprite); + memcpy(skin->sprite, value, sizeof skin->sprite); } else if (!stricmp(stoken, "facerank")) { strupr(value); - strncpy(skin->facerank, value, sizeof skin->facerank); + memcpy(skin->facerank, value, sizeof(skin->facerank)-1); + skin->facerank[sizeof(skin->facerank)-1] = '\0'; } else if (!stricmp(stoken, "facewant")) { strupr(value); - strncpy(skin->facewant, value, sizeof skin->facewant); + memcpy(skin->facewant, value, sizeof(skin->facewant)-1); + skin->facewant[sizeof(skin->facewant)-1] = '\0'; } else if (!stricmp(stoken, "facemmap")) { strupr(value); - strncpy(skin->facemmap, value, sizeof skin->facemmap); + strncpy(skin->facemmap, value, sizeof(skin->facemmap)-1); + skin->facemmap[sizeof(skin->facemmap)-1] = '\0'; } #define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); @@ -3655,7 +3484,6 @@ next_token: free(buf2); lump++; // if no sprite defined use spirte just after this one - INT32 sprnum; if (skin->sprite[0] == '\0') { const char *csprname = W_CheckNameForNumPwad(wadnum, lump); @@ -3666,9 +3494,6 @@ next_token: lastlump++; // allocate (or replace) sprite frames, and set spritedef R_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump); - - // i feel like generally most skin authors just use PLAY here, so just assume PLAY - sprnum = SPR_PLAY; } else { @@ -3716,8 +3541,6 @@ next_token: R_AddSingleSpriteDef(sprname, &skin->spritedef, wadnum, lstart, lend); } - sprnum = numspritelumps - 1; - // I don't particularly care about skipping to the end of the used frames. // We could be using frames from ANYWHERE in the current WAD file, including // right before us, which is a terrible idea. @@ -3772,53 +3595,7 @@ next_token: numallskins++; } - sortSkinGrid(); + //sortSkinGrid(); return; } - -#ifdef DELFILE -void R_DelSkins(UINT16 wadnum) -{ - UINT16 lump, lastlump = 0; - while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) - { - if (skins[numskins].wadnum != wadnum) - break; - numskins--; - ST_UnLoadFaceGraphics(numskins); // only used by DELFILE - if (skins[numskins].sprite[0] != '\0') - { - const char *csprname = W_CheckNameForNumPwad(wadnum, lump); - - // skip to end of this skin's frames - lastlump = lump; - while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),csprname,4)==0) - lastlump++; - // allocate (or replace) sprite frames, and set spritedef - R_DelSingleSpriteDef(csprname, &skins[numskins].spritedef, wadnum, lump, lastlump); - } - else - { - // search in the normal sprite tables - size_t name; - boolean found = false; - const char *sprname = skins[numskins].sprite; - for (name = 0;sprnames[name][0] != '\0';name++) - if (strcmp(sprnames[name], sprname) == 0) - { - found = true; - skins[numskins].spritedef = sprites[name]; - } - - // not found so make a new one - if (!found) - R_DelSingleSpriteDef(sprname, &skins[numskins].spritedef, wadnum, 0, INT16_MAX); - - while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),sprname,4)==0) - lastlump++; - } - CONS_Printf(M_GetText("Removed skin '%s'\n"), skins[numskins].name); - } -} -#endif diff --git a/src/r_things.h b/src/r_things.h index 823bad9a8..7a22b0ef1 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -32,6 +32,12 @@ #define FEETADJUST (4<>FRACBITS) - (viewx>>FRACBITS)), abs(((y)>>FRACBITS) - (viewy>>FRACBITS))) + // Constant arrays used for psprite clipping // and initializing clipping. extern INT16 negonearray[MAXVIDWIDTH]; @@ -55,10 +61,6 @@ void R_SortVisSprites(void); // (only sprites from namelist are added or replaced) void R_AddSpriteDefs(UINT16 wadnum); -#ifdef DELFILE -void R_DelSpriteDefs(UINT16 wadnum); -#endif - //SoM: 6/5/2000: Light sprites correctly! void R_AddSprites(sector_t *sec, INT32 lightlevel); void R_InitSprites(void); @@ -223,10 +225,6 @@ INT32 R_AnySkinAvailable(const char *name); INT32 R_LocalSkinAvailable(const char *name, boolean local); void R_AddSkins(UINT16 wadnum, boolean local); -#ifdef DELFILE -void R_DelSkins(UINT16 wadnum); -#endif - void R_InitDrawNodes(void); char *GetPlayerFacePic(INT32 skinnum); diff --git a/src/s_sound.c b/src/s_sound.c index a2f81f210..06a454bdf 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -30,9 +30,7 @@ #include "m_cond.h" // for conditionsets #include "m_menu.h" // bird music stuff -#ifdef HAVE_BLUA #include "lua_hook.h" // MusicChange hook -#endif #ifdef HW3SOUND // 3D Sound Interface @@ -1435,8 +1433,9 @@ void S_LoadMusicDefs(UINT16 wadnum) //CONS_Printf("S_LoadMusicDefs: Added song '%s'\n", def->name); } } - + strncpy(def->filename, wadfiles[wadnum]->filename, 256); + def->filename[256] = '\0'; skip_lump: stoken = strtok(NULL, "\r\n "); @@ -1987,19 +1986,17 @@ static void S_ChangeMusicToQueue(void) void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms) { - char newmusic[7]; + char newmusic[7] = {0}; if (S_MusicDisabled() || demo.rewinding // Don't mess with music while rewinding! || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; - strncpy(newmusic, mmusic, 7); -#ifdef HAVE_BLUA + strncpy(newmusic, mmusic, 6); + if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) return; -#endif - newmusic[6] = 0; // No Music (empty string) if (newmusic[0] == 0) @@ -2465,8 +2462,12 @@ static void StereoSep_OnChange(void) static void AmigaFilter_OnChange(void) { if (openmpt_mhandle) +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 + openmpt_module_ctl_set_boolean(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value); +#else openmpt_module_ctl_set(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value ? "1" : "0"); - } +#endif +} #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 diff --git a/src/s_sound.h b/src/s_sound.h index 12efb9c44..538e8713e 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -160,7 +160,7 @@ typedef struct musicdef_s char name[7]; char usage[256]; char source[256]; - char filename[256]; + char filename[256+1]; // for the music test stuff // generally if these are present on vanilla the game would throw up a warning // a sacrifice i suppose diff --git a/src/screen.c b/src/screen.c index d7aa1407e..949adc525 100644 --- a/src/screen.c +++ b/src/screen.c @@ -70,10 +70,10 @@ consvar_t cv_shittyscreen = {"televisionsignal", "Okay", CV_NOSHOWHELP, shittysc static void SCR_ChangeFullscreen (void); -static INT32 SCR_FPSflags(void); - consvar_t cv_fullscreen = {"fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_accuratefps = {"accuratefpscounter", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + // ========================================================================= // SCREEN VARIABLES // ========================================================================= @@ -86,15 +86,6 @@ UINT8 *scr_borderpatch; // flat used to fill the reduced view borders set at ST_ // Short and Tall sky drawer, for the current color mode void (*walldrawerfunc)(void); -boolean R_486 = false; -boolean R_586 = false; -boolean R_MMX = false; -boolean R_SSE = false; -boolean R_3DNow = false; -boolean R_MMXExt = false; -boolean R_SSE2 = false; - - void SCR_SetMode(void) { if (dedicated) @@ -150,48 +141,6 @@ void SCR_SetMode(void) // void SCR_Startup(void) { - const CPUInfoFlags *RCpuInfo = I_CPUInfo(); - if (!M_CheckParm("-NOCPUID") && RCpuInfo) - { -#if defined (__i386__) || defined (_M_IX86) || defined (__WATCOMC__) - R_486 = true; -#endif - if (RCpuInfo->RDTSC) - R_586 = true; - if (RCpuInfo->MMX) - R_MMX = true; - if (RCpuInfo->AMD3DNow) - R_3DNow = true; - if (RCpuInfo->MMXExt) - R_MMXExt = true; - if (RCpuInfo->SSE) - R_SSE = true; - if (RCpuInfo->SSE2) - R_SSE2 = true; - CONS_Printf("CPU Info: 486: %i, 586: %i, MMX: %i, 3DNow: %i, MMXExt: %i, SSE2: %i\n", R_486, R_586, R_MMX, R_3DNow, R_MMXExt, R_SSE2); - } - - if (M_CheckParm("-486")) - R_486 = true; - if (M_CheckParm("-586")) - R_586 = true; - if (M_CheckParm("-MMX")) - R_MMX = true; - if (M_CheckParm("-3DNow")) - R_3DNow = true; - if (M_CheckParm("-MMXExt")) - R_MMXExt = true; - - if (M_CheckParm("-SSE")) - R_SSE = true; - if (M_CheckParm("-noSSE")) - R_SSE = false; - - if (M_CheckParm("-SSE2")) - R_SSE2 = true; - - M_SetupMemcpy(); - if (dedicated) { V_Init(); @@ -230,6 +179,7 @@ void SCR_Startup(void) V_Init(); CV_RegisterVar(&cv_ticrate); + CV_RegisterVar(&cv_accuratefps); CV_RegisterVar(&cv_menucaps); CV_RegisterVar(&cv_constextsize); @@ -399,9 +349,13 @@ double averageFPS = 0.0f; #ifdef USE_FPS_SAMPLES #define MAX_FRAME_TIME 0.05 #define NUM_FPS_SAMPLES (16) // Number of samples to store +#define NUM_FPS_SAMPLES2 (32) // Number of samples to store for inaccurate counter static double total_frame_time = 0.0; static int frame_index; + +static double fps_samples[NUM_FPS_SAMPLES2]; +static int fps_index; #endif static boolean fps_init = false; @@ -410,6 +364,7 @@ static precise_t fps_enter = 0; void SCR_CalculateFPS(void) { precise_t fps_finish = 0; + int i; double frameElapsed = 0.0; @@ -424,12 +379,26 @@ void SCR_CalculateFPS(void) fps_enter = fps_finish; #ifdef USE_FPS_SAMPLES - total_frame_time += frameElapsed; - if (frame_index++ >= NUM_FPS_SAMPLES || total_frame_time >= MAX_FRAME_TIME) + + if (cv_accuratefps.value) { - averageFPS = 1.0 / (total_frame_time / frame_index); - total_frame_time = 0.0; - frame_index = 0; + total_frame_time += frameElapsed; + if (frame_index++ >= NUM_FPS_SAMPLES || total_frame_time >= MAX_FRAME_TIME) + { + averageFPS = 1.0 / (total_frame_time / frame_index); + total_frame_time = 0.0; + frame_index = 0; + } + } + else + { + fps_samples[fps_index] = frameElapsed / NUM_FPS_SAMPLES2; + fps_index = (fps_index + 1) % NUM_FPS_SAMPLES2; + + averageFPS = 0.0; + for (i = 0; i < NUM_FPS_SAMPLES2; i++) + averageFPS += fps_samples[i]; + averageFPS = 1.0 / averageFPS; } #else // Direct, unsampled counter. @@ -437,14 +406,6 @@ void SCR_CalculateFPS(void) #endif } -// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol -static INT32 SCR_FPSflags(void) -{ - if (!cv_translucenthud.value) return V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS; // eee kinda works ig - - return (((10-cv_translucenthud.value)*V_10TRANS) & V_ALPHAMASK) | V_SNAPTOBOTTOM|V_SNAPTORIGHT; -} - void SCR_DisplayTicRate(void) { const UINT8 *ticcntcolor = NULL; @@ -452,7 +413,7 @@ void SCR_DisplayTicRate(void) UINT32 benchmark = (cap == 0) ? I_GetRefreshRate() : cap; INT32 x = 318; double fps = round(averageFPS); - INT32 fpsflags = SCR_FPSflags(); + INT32 fpsflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; const char *fps_string; INT32 ticcntcolor2 = 0; @@ -520,12 +481,12 @@ void SCR_DisplayTicRate(void) void SCR_DisplayLocalPing(void) { UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P - INT32 fpsflags = SCR_FPSflags(); + INT32 pingflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain - HU_drawPing(308, dispy, ping, fpsflags); + HU_drawPing(308, dispy, ping, pingflags); } } diff --git a/src/screen.h b/src/screen.h index 2f46eaeb5..1af085b1a 100644 --- a/src/screen.h +++ b/src/screen.h @@ -134,17 +134,6 @@ extern void (*transtransfunc)(void); extern void (*twosmultipatchfunc)(void); extern void (*twosmultipatchtransfunc)(void); -// ----- -// CPUID -// ----- -extern boolean R_ASM; -extern boolean R_486; -extern boolean R_586; -extern boolean R_MMX; -extern boolean R_3DNow; -extern boolean R_MMXExt; -extern boolean R_SSE2; - // ---------------- // screen variables // ---------------- diff --git a/src/sdl/SDL_icon.xpm b/src/sdl/SDL_icon.xpm index 0acac88ec..bc74641d6 100644 --- a/src/sdl/SDL_icon.xpm +++ b/src/sdl/SDL_icon.xpm @@ -1,100 +1,72 @@ -/* XPM */ -static const char *SDL_icon_xpm[] = { -/* columns rows colors chars-per-pixel */ -"64 64 32 1", -" c None", -". c #E7E7E7", -"+ c #DFDFDF", -"@ c #AFAFAF", -"# c #979797", -"$ c #8F8F8F", -"% c #B7B7B7", -"& c #F7F7F7", -"* c #D7D7D7", -"= c #4F4F4F", -"- c #0F0F0F", -"; c #070707", -"> c #575757", -", c #C7C7C7", -"' c #676767", -") c #7F7F7F", -"! c #5F5F5F", -"~ c #777777", -"{ c #474747", -"] c #878787", -"^ c #6F6F6F", -"/ c #BFBFBF", -"( c #373737", -"_ c #1F1F1F", -": c #272727", -"< c #2F2F2F", -"[ c #3F3F3F", -"} c #EFEFEF", -"| c #A7A7A7", -"1 c #9F9F9F", -"2 c #171717", -"3 c #CFCFCF", -" ", -" .................... ", -" ...+@##$$$$###@%&....... ", -" ..*=-;;;-;;;;;;;;@........ ", -" ..+-;;;;--;;;;;;;>.......... ", -" ...,')!!'~>{!)$)>'....*]>^%&.. ", -" ../(__(>:{<)$![[[%&...^!!!!!~*. ", -" ..@;;;;;({=]:;;;;;~..*_;;;;;;;_.. ", -" .}>;;;;;^#=;;;;;;>...<;;;;;;;;;|.. ", -" ..*1)))))%]))))))%&..1])))))))))#}. ", -" ..%[;;;;;[2;;;;;;;:..#;;;2[[-;;;;;=.. ", -" .&:;[{;;;{;;;~={:;^.._;;'}...>;;;;;,. ", -" .}<;;:{;_:2!'-;;;]*.&(_].|{=@.~___[/.. ", -" ..*$))]@%//,111111}..|1*.@1111@.3111|&. ", -" .,:;;;;;'#^;;;;;;;]./;;+);;;;;;$*;;;;.. ", -" .^;;;;;;));;;;;;;;$.~;$*;;;;;;;-+^;;;#. ", -" ..$;;;;;;>;;;;;;;;>}.^-.!;;;;;;;;)*:;;|. ", -" .&@$|#)))|)))1||#]+..$/}]))))))))$.3))#.. ", -" .#;;;[{;->;-^[;;;;].~;@];;;;;;;;;;1#;;-}. ", -" .{;;;;{<[:(~-;;;;;$.(-.<;;;;;;;;;;{};;;3. ", -" ..);;;;;~~[!;;;;;;-/.>=.>;;;;;;;;;;2}^;:3. ", -" .&#)))))$}@)))))))@.}]3.*))))))))))).,)).. ", -" .3;;;;;;;);;;;;;;;2+|;%.';;;;;;;;;;;]1;;1. ", -" .1_(:;;;;{;;;[=[:;;.];}.);;;;;;;;;;;=,;;]. ", -" .%2-(!2;2{;_':;;;;).1;..+:;;;;;;;;;;_.;;1. ", -" .+))))@1$1#@))))))3.,@...1))))))))))].1#3. ", -" .{;;;;;^<>);;;;;;;-.[). .-;;;;;;;;;;;3{;#. ", -" ._;;;;;-~];;;;;;;;;};#. ._;;;;;;;;;;;/^;#. ", -" .$'!!!!!1]!!!!!!!!%}[,. .'[[[[[[[[[[[,|>}. ", -" ..'{::___!{___:(>___:[@...~[[[[[[[[[[[1#{,. ", -" .+;-<=(;;[:;;(=-;;;;;;;;;;;;;;;;;;;;;;;;;). ", -" .*;;;;[=;[_;{(;;;;;;;;;;;;;;;;;;;;;;;;;;-#. ", -" .&)!!!!)$]~)$!!!!!!!!!!!!!!!!!!!!!!!!!!!^+. ", -" .&(_____!$)!____________________________<3. ", -" .%;;;;;;;@|;;;;;;;;;;;;==))))))))))))))]*&. ", -" .*22;;;;;({;;;;;_-;;;;%.&.................. ", -" .&+~#]!!!~]!=[!^>[[[[{}... ", -" ../__:^^:(!_[$>[[[[[[{+. ", -" .<;;;;<^2{;'2;;;;;;;;]. ", -" .;;;;;;:~=>:;;;;;;;;;]. ", -" .@!!!!!!]3|!!!!!!!!!!*. ", -" .#_______#_____:<____~.. ", -" .^_{[_;;;=2;;;<<-;;;;;,.................. ", -" .@<;;{~2;_>;;((;;;;;;;3,-----------|.$-!. ", -" ..@))))|@)|)$|)))))))#}&/))))))))))}./)/. ", -" .&:;;;;;=>>;^;;;;;;;;;_.[;;;;;;;;;;^.{;|. ", -" ..2;;;;;;{#<[;;;;;;;;;;+';;;;;;;;;;~*;;.. ", -" .^;;;;;;;'%;;;;;;;;;;{&}#;;;;;;;;[+|;-.. ", -" .&3$1$))))%))))1]))))]+&}$))))))@&./)@. ", -" ..(;_<'{;;(-;;[2;;;;;;-@3;;;;;;;_}};;~. ", -" .=;;;;:~<-(;-[;;;;;;;;:.=;;;;;;>.!;;,. ", -" ./:;;;;;!!!;=-;;;;;;;;>.+$;;;;[.&_;=.. ", -" ..&|)))))$,|%)))))))))]1&.|]]@&.|]]}. ", -" .&;;;;;;;:@=;;;;;;;;;;;-/....3:;;;}. ", -" ..!;;;;;;;([;;;;_2;;;;;;;>)){;;;;^.. ", -" ..=2_:-;;;(;;;2<;;;;;;;;;;;;;;-).. ", -" ...%$#@%#)#))|))))))))))))))|}&. ", -" ..!;;;2!]{_-[;;;;;;;;;;;;;;;&.. ", -" ..^-;;;;^)(:;;;;;;;;;;;;;;'.. ", -" ..*'-;;;:]-;;;;;;;;;;;;-$.. ", -" ....}./1))))))))))))]/... ", -" ........}3||1#$$$]1... ", -" ................... ", -" "}; +/* XPM */ +static const char *SDL_icon_xpm[] = { +"64 64 5 1", +" c None", +". c #6B6451", +"+ c #9F926D", +"@ c #CFBD8A", +"# c #FFE7A6", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ........................ ", +" ....++++...++++++++++...++++... ", +" ....++++...++++++++++...++++... ", +" ...+++++...++++++++++++++++...++++.... ", +" ..++++++@.####++++++++++++++####.@++++++.. ", +" ..+++++@@@.########################.@@@+++++.. ", +" ..+++++@@@.########################.@@@+++++.. ", +" .++++++@@..##########################..@@++++++. ", +" .+++++@@@.@@@########################@@@.@@@+++++. ", +" ..+++++@@@.@@@@@@@##################@@@@@@@.@@@+++++.. ", +" ..+++++@@@.@@@@@@@##################@@@@@@@.@@@+++++.. ", +" .++++++@@...@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...@@++++++. ", +" .+++++@@@. .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. .@@@+++++. ", +" .++++@@@. .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. .@@@++++. ", +" .++++@@@. .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. .@@@++++. ", +" .++++@@@. .####@@@@@@@@@@@@@@@@@@@@@@@@####. .@@@++++. ", +" .++++@@@. .################################. .@@@++++. ", +" .++++@@@@. .################################. .@@@@++++. ", +" .++++@@@@. .################################. .@@@@++++. ", +" .++++@@@@@...################################...@@@@@++++. ", +" .+++++@@@@@@@...##########################...@@@@@@@+++++. ", +" .+++++++@@@@@@@@....##################....@@@@@@@@+++++++. ", +" .+++++++@@@@@@@@....##################....@@@@@@@@+++++++. ", +" .++++++++@@@@@@@@@@..................@@@@@@@@@@++++++++. ", +" ..++++++++++@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@++++++++++.. ", +" .+++++++++++++@@@@@@@@@@@@@@@@@@@@@@+++++++++++++. ", +" .+++++++++++++@@@@@@@@@@@@@@@@@@@@@@+++++++++++++. ", +" ...++++++++++++++++++++++++++++++++++++++++++... ", +" ..++++++++++++++++++++++++++++++++++++++.. ", +" ....++++++++++++++++++++++++++++++.... ", +" ....++++++++++++++++++++++++++++++.... ", +" .............................. ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/src/sdl/Srb2SDL.dsp b/src/sdl/Srb2SDL.dsp index c6e96a453..92821295d 100644 --- a/src/sdl/Srb2SDL.dsp +++ b/src/sdl/Srb2SDL.dsp @@ -604,10 +604,6 @@ SOURCE=..\hardware\hw_md2.h # End Source File # Begin Source File -SOURCE=..\hardware\hw_trick.c -# End Source File -# Begin Source File - SOURCE=..\hardware\hws_data.h # End Source File # End Group diff --git a/src/sdl/Srb2SDL.ico b/src/sdl/Srb2SDL.ico index 4e3f81336..87bd2766e 100644 Binary files a/src/sdl/Srb2SDL.ico and b/src/sdl/Srb2SDL.ico differ diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 0e921d73b..bea0f645b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -43,12 +43,15 @@ typedef HANDLE (WINAPI *p_OpenFileMappingA) (DWORD, BOOL, LPCSTR); typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #endif - // A little more than the minimum sleep duration on Windows. // May be incorrect for other platforms, but we don't currently have a way to // query the scheduler granularity. SDL will do what's needed to make this as // low as possible though. +#if defined(_WIN32) +#define MIN_SLEEP_DURATION_MS 1.6 +#else #define MIN_SLEEP_DURATION_MS 2.1 +#endif #include #include @@ -343,6 +346,9 @@ static void write_backtrace(bt_crash_reason_t reason) if (compdate && comptime && comprevision && compbranch) fprintf(out, "Compiled: %s %s, commit %s, branch %s\n", compdate, comptime, comprevision, compbranch); + if (gamestate == GS_LEVEL) + fprintf(out, "Game map: %s\n", G_BuildMapName(gamemap)); + fprintf(out, "Time of crash: %s\n", asctime(timeinfo)); fprintf(out, "Caused by: "); @@ -2638,7 +2644,7 @@ INT32 I_NumJoys(void) return numjoy; } -static char joyname[255]; // MAX_PATH; joystick name is straight from the driver +static char joyname[256]; // MAX_PATH; joystick name is straight from the driver const char *I_GetJoyName(INT32 joyindex) { @@ -2649,7 +2655,10 @@ const char *I_GetJoyName(INT32 joyindex) { tempname = SDL_JoystickNameForIndex(joyindex); if (tempname) - strncpy(joyname, tempname, 255); + { + memcpy(joyname, tempname, 255); + joyname[255] = '\0'; + } } return joyname; } @@ -3184,12 +3193,24 @@ static Uint64 timer_frequency; precise_t I_GetPreciseTime(void) { +#if defined(_WIN32) + LARGE_INTEGER counter; + QueryPerformanceCounter(&counter); + return counter.QuadPart; +#else return SDL_GetPerformanceCounter(); +#endif } UINT64 I_GetPrecisePrecision(void) { +#if defined(_WIN32) + LARGE_INTEGER frequency; + QueryPerformanceFrequency(&frequency); + return frequency.QuadPart; +#else return SDL_GetPerformanceFrequency(); +#endif } static UINT32 frame_rate; @@ -3216,14 +3237,24 @@ static void I_InitFrameTime(const UINT64 now, const UINT32 cap) } double I_GetFrameTime(void) -{ +{ +#if defined(_WIN32) + LARGE_INTEGER now; + QueryPerformanceCounter(&now); + const UINT64 nowValue = now.QuadPart; +#else const UINT64 now = SDL_GetPerformanceCounter(); +#endif const UINT32 cap = R_GetFramerateCap(); if (cap != frame_rate) { // Maybe do this in a OnChange function for cv_fpscap? +#if defined(_WIN32) + I_InitFrameTime(nowValue, cap); +#else I_InitFrameTime(now, cap); +#endif } if (frame_rate == 0) @@ -3233,10 +3264,17 @@ double I_GetFrameTime(void) } else { +#if defined(_WIN32) + elapsed_frames += (nowValue - frame_epoch) / frame_frequency; +#else elapsed_frames += (now - frame_epoch) / frame_frequency; +#endif } - - frame_epoch = now; // moving epoch +#if defined(_WIN32) + frame_epoch = nowValue; // moving epoch +#else + frame_epoch = now; // moving epoch +#endif return elapsed_frames; } @@ -3245,8 +3283,13 @@ double I_GetFrameTime(void) // void I_StartupTimer(void) { +#if defined(_WIN32) + LARGE_INTEGER frequency; + QueryPerformanceFrequency(&frequency); + timer_frequency = frequency.QuadPart; +#else timer_frequency = SDL_GetPerformanceFrequency(); - +#endif I_InitFrameTime(0, R_GetFramerateCap()); elapsed_frames = 0.0; } @@ -3292,7 +3335,12 @@ void I_SleepDuration(precise_t duration) // hard sleep function. if (sleepvalue > 0 && (dest - cur) > delaygranularity) { +#if defined(_WIN32) + DWORD sleepDuration = (DWORD)min((INT64)(dest - cur), sleepvalue); + SleepEx(sleepDuration, TRUE); +#else I_Sleep(sleepvalue); +#endif } // Otherwise, this is a spinloop. @@ -3791,10 +3839,10 @@ const char *I_ClipboardPaste(void) if (!SDL_HasClipboardText()) return NULL; + clipboard_contents = SDL_GetClipboardText(); - memcpy(clipboard_modified, clipboard_contents, 255); + strlcpy(clipboard_modified, clipboard_contents, 256); SDL_free(clipboard_contents); - clipboard_modified[255] = 0; while (*i) { @@ -4183,69 +4231,6 @@ size_t I_GetFreeMem(size_t *total) #endif } -const CPUInfoFlags *I_CPUInfo(void) -{ -#if defined (_WIN32) - static CPUInfoFlags WIN_CPUInfo; - SYSTEM_INFO SI; - p_IsProcessorFeaturePresent pfnCPUID = (p_IsProcessorFeaturePresent)(LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsProcessorFeaturePresent"); - - ZeroMemory(&WIN_CPUInfo,sizeof (WIN_CPUInfo)); - if (pfnCPUID) - { - WIN_CPUInfo.FPPE = pfnCPUID( 0); //PF_FLOATING_POINT_PRECISION_ERRATA - WIN_CPUInfo.FPE = pfnCPUID( 1); //PF_FLOATING_POINT_EMULATED - WIN_CPUInfo.cmpxchg = pfnCPUID( 2); //PF_COMPARE_EXCHANGE_DOUBLE - WIN_CPUInfo.MMX = pfnCPUID( 3); //PF_MMX_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.PPCMM64 = pfnCPUID( 4); //PF_PPC_MOVEMEM_64BIT_OK - WIN_CPUInfo.ALPHAbyte = pfnCPUID( 5); //PF_ALPHA_BYTE_INSTRUCTIONS - WIN_CPUInfo.SSE = pfnCPUID( 6); //PF_XMMI_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.AMD3DNow = pfnCPUID( 7); //PF_3DNOW_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.RDTSC = pfnCPUID( 8); //PF_RDTSC_INSTRUCTION_AVAILABLE - WIN_CPUInfo.PAE = pfnCPUID( 9); //PF_PAE_ENABLED - WIN_CPUInfo.SSE2 = pfnCPUID(10); //PF_XMMI64_INSTRUCTIONS_AVAILABLE - //WIN_CPUInfo.blank = pfnCPUID(11); //PF_SSE_DAZ_MODE_AVAILABLE - WIN_CPUInfo.DEP = pfnCPUID(12); //PF_NX_ENABLED - WIN_CPUInfo.SSE3 = pfnCPUID(13); //PF_SSE3_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.cmpxchg16b = pfnCPUID(14); //PF_COMPARE_EXCHANGE128 - WIN_CPUInfo.cmp8xchg16 = pfnCPUID(15); //PF_COMPARE64_EXCHANGE128 - WIN_CPUInfo.PFC = pfnCPUID(16); //PF_CHANNELS_ENABLED - } -#ifdef HAVE_SDLCPUINFO - else - { - WIN_CPUInfo.RDTSC = SDL_HasRDTSC(); - WIN_CPUInfo.MMX = SDL_HasMMX(); - WIN_CPUInfo.AMD3DNow = SDL_Has3DNow(); - WIN_CPUInfo.SSE = SDL_HasSSE(); - WIN_CPUInfo.SSE2 = SDL_HasSSE2(); - WIN_CPUInfo.AltiVec = SDL_HasAltiVec(); - } - WIN_CPUInfo.MMXExt = SDL_FALSE; //SDL_HasMMXExt(); No longer in SDL2 - WIN_CPUInfo.AMD3DNowExt = SDL_FALSE; //SDL_Has3DNowExt(); No longer in SDL2 -#endif - GetSystemInfo(&SI); - WIN_CPUInfo.CPUs = SI.dwNumberOfProcessors; - WIN_CPUInfo.IA64 = (SI.dwProcessorType == 2200); // PROCESSOR_INTEL_IA64 - WIN_CPUInfo.AMD64 = (SI.dwProcessorType == 8664); // PROCESSOR_AMD_X8664 - return &WIN_CPUInfo; -#elif defined (HAVE_SDLCPUINFO) - static CPUInfoFlags SDL_CPUInfo; - memset(&SDL_CPUInfo,0,sizeof (CPUInfoFlags)); - SDL_CPUInfo.RDTSC = SDL_HasRDTSC(); - SDL_CPUInfo.MMX = SDL_HasMMX(); - SDL_CPUInfo.MMXExt = SDL_FALSE; //SDL_HasMMXExt(); No longer in SDL2 - SDL_CPUInfo.AMD3DNow = SDL_Has3DNow(); - SDL_CPUInfo.AMD3DNowExt = SDL_FALSE; //SDL_Has3DNowExt(); No longer in SDL2 - SDL_CPUInfo.SSE = SDL_HasSSE(); - SDL_CPUInfo.SSE2 = SDL_HasSSE2(); - SDL_CPUInfo.AltiVec = SDL_HasAltiVec(); - return &SDL_CPUInfo; -#else - return NULL; /// \todo CPUID asm -#endif -} - // note CPUAFFINITY code used to reside here void I_RegisterSysCommands(void) {} #endif diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 89c7bf555..dbdfee229 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -75,6 +75,7 @@ #include "../command.h" #include "sdlmain.h" #include "../i_system.h" +#include "../hu_stuff.h" // for chat_on #ifdef HWRENDER #include "../hardware/hw_main.h" #include "../hardware/hw_drv.h" @@ -109,6 +110,7 @@ boolean a2c = false; #endif boolean highcolor = false; +consvar_t cv_nativekeyboard = {"nativekeyboard", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static void Impl_SetVsync(void); @@ -382,6 +384,149 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) return 0; } +// Get the equivalent ASCII (Unicode?) character for a keypress. +static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) +{ + SDL_Event next_event; + + // Special cases, where we always return a fixed value. + switch (sym->sym) + { + case SDLK_BACKSPACE: return KEY_BACKSPACE; + case SDLK_RETURN: return KEY_ENTER; + default: + break; + } + + // The following is a gross hack, but I don't see an easier way + // of doing this within the SDL2 API (in SDL1 it was easier). + // We want to get the fully transformed input character associated + // with this keypress - correct keyboard layout, appropriately + // transformed by any modifier keys, etc. So peek ahead in the SDL + // event queue and see if the key press is immediately followed by + // an SDL_TEXTINPUT event. If it is, it's reasonable to assume the + // key press and the text input are connected. Technically the SDL + // API does not guarantee anything of the sort, but in practice this + // is what happens and I've verified it through manual inspect of + // the SDL source code. + // + // In an ideal world we'd split out ev_keydown into a separate + // ev_textinput event, as SDL2 has done. But this doesn't work + // (I experimented with the idea), because lots of Doom's code is + // based around different responders "eating" events to stop them + // being passed on to another responder. If code is listening for + // a text input, it cannot block the corresponding keydown events + // which can affect other responders. + // + // So we're stuck with this as a rather fragile alternative. + + if (SDL_PeepEvents(&next_event, 1, SDL_PEEKEVENT, + SDL_FIRSTEVENT, SDL_LASTEVENT) == 1 + && next_event.type == SDL_TEXTINPUT) + { + // If an SDL_TEXTINPUT event is found, we always assume it + // matches the key press. The input text must be a single + // ASCII character - if it isn't, it's possible the input + // char is a Unicode value instead; better to send a null + // character than the unshifted key. + if (strlen(next_event.text.text) == 1 && + (next_event.text.text[0] >= ' ' && next_event.text.text[0] <= '~')) { + return next_event.text.text[0]; + } else { + return '\0'; + } + } + + if (code >= SDL_SCANCODE_1 && code <= SDL_SCANCODE_9) + { + return code - SDL_SCANCODE_1 + '1'; + } + else if (code == SDL_SCANCODE_0) + { + return '0'; + } + if (code >= SDL_SCANCODE_F1 && code <= SDL_SCANCODE_F10) + { + return KEY_F1 + (code - SDL_SCANCODE_F1); + } + + switch (code) + { + // F11 and F12 are separated from the rest of the function keys + case SDL_SCANCODE_F11: return KEY_F11; + case SDL_SCANCODE_F12: return KEY_F12; + + case SDL_SCANCODE_KP_0: return KEY_KEYPAD0; + case SDL_SCANCODE_KP_1: return KEY_KEYPAD1; + case SDL_SCANCODE_KP_2: return KEY_KEYPAD2; + case SDL_SCANCODE_KP_3: return KEY_KEYPAD3; + case SDL_SCANCODE_KP_4: return KEY_KEYPAD4; + case SDL_SCANCODE_KP_5: return KEY_KEYPAD5; + case SDL_SCANCODE_KP_6: return KEY_KEYPAD6; + case SDL_SCANCODE_KP_7: return KEY_KEYPAD7; + case SDL_SCANCODE_KP_8: return KEY_KEYPAD8; + case SDL_SCANCODE_KP_9: return KEY_KEYPAD9; + + case SDL_SCANCODE_RETURN: return KEY_ENTER; + case SDL_SCANCODE_ESCAPE: return KEY_ESCAPE; + case SDL_SCANCODE_BACKSPACE: return KEY_BACKSPACE; + case SDL_SCANCODE_TAB: return KEY_TAB; + case SDL_SCANCODE_SPACE: return KEY_SPACE; + case SDL_SCANCODE_MINUS: return KEY_MINUS; + case SDL_SCANCODE_EQUALS: return KEY_EQUALS; + case SDL_SCANCODE_LEFTBRACKET: return '['; + case SDL_SCANCODE_RIGHTBRACKET: return ']'; + case SDL_SCANCODE_BACKSLASH: return '\\'; + case SDL_SCANCODE_NONUSHASH: return '#'; + case SDL_SCANCODE_SEMICOLON: return ';'; + case SDL_SCANCODE_APOSTROPHE: return '\''; + case SDL_SCANCODE_GRAVE: return '`'; + case SDL_SCANCODE_COMMA: return ','; + case SDL_SCANCODE_PERIOD: return '.'; + case SDL_SCANCODE_SLASH: return '/'; + case SDL_SCANCODE_CAPSLOCK: return KEY_CAPSLOCK; + case SDL_SCANCODE_PRINTSCREEN: return 0; // undefined? + case SDL_SCANCODE_SCROLLLOCK: return KEY_SCROLLLOCK; + case SDL_SCANCODE_PAUSE: return KEY_PAUSE; + case SDL_SCANCODE_INSERT: return KEY_INS; + case SDL_SCANCODE_HOME: return KEY_HOME; + case SDL_SCANCODE_PAGEUP: return KEY_PGUP; + case SDL_SCANCODE_DELETE: return KEY_DEL; + case SDL_SCANCODE_END: return KEY_END; + case SDL_SCANCODE_PAGEDOWN: return KEY_PGDN; + case SDL_SCANCODE_RIGHT: return KEY_RIGHTARROW; + case SDL_SCANCODE_LEFT: return KEY_LEFTARROW; + case SDL_SCANCODE_DOWN: return KEY_DOWNARROW; + case SDL_SCANCODE_UP: return KEY_UPARROW; + case SDL_SCANCODE_NUMLOCKCLEAR: return KEY_NUMLOCK; + case SDL_SCANCODE_KP_DIVIDE: return KEY_KPADSLASH; + case SDL_SCANCODE_KP_MULTIPLY: return '*'; // undefined? + case SDL_SCANCODE_KP_MINUS: return KEY_MINUSPAD; + case SDL_SCANCODE_KP_PLUS: return KEY_PLUSPAD; + case SDL_SCANCODE_KP_ENTER: return KEY_ENTER; + case SDL_SCANCODE_KP_PERIOD: return KEY_KPADDEL; + case SDL_SCANCODE_NONUSBACKSLASH: return '\\'; + + case SDL_SCANCODE_LSHIFT: return KEY_LSHIFT; + case SDL_SCANCODE_RSHIFT: return KEY_RSHIFT; + case SDL_SCANCODE_LCTRL: return KEY_LCTRL; + case SDL_SCANCODE_RCTRL: return KEY_RCTRL; + case SDL_SCANCODE_LALT: return KEY_LALT; + case SDL_SCANCODE_RALT: return KEY_RALT; + case SDL_SCANCODE_LGUI: return KEY_LEFTWIN; + case SDL_SCANCODE_RGUI: return KEY_RIGHTWIN; + default: break; + } + + if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z) + { + // get lowercase ASCII + return code - SDL_SCANCODE_A + 'a'; + } + + return 0; +} + static void SDLdoGrabMouse(void) { SDL_ShowCursor(SDL_DISABLE); @@ -696,7 +841,12 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) { return; } - event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); + + if (cv_nativekeyboard.value && (chat_on || CON_Ready() || (menu_text_input && menuactive))) //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) + event.data1 = GetTypedChar(evt.keysym.scancode, &evt.keysym); + else + event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); + if (event.data1) D_PostEvent(&event); } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index b34ccb18a..c3b117c91 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1242,7 +1242,7 @@ boolean I_PlaySong(boolean looping) gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; #if defined (GME_VERSION) && GME_VERSION >= 0x000603 gme_set_autoload_playback_limit(gme, 0); -#endif +#endif gme_set_equalizer(gme, &eq); gme_start_track(gme, 0); current_track = 0; @@ -1255,12 +1255,25 @@ boolean I_PlaySong(boolean looping) if (openmpt_mhandle) { openmpt_module_select_subsong(openmpt_mhandle, 0); + +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 + openmpt_module_ctl_set_text(openmpt_mhandle, "dither", "1"); +#else openmpt_module_ctl_set(openmpt_mhandle, "dither", "1"); +#endif + openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT, cv_stereosep.value); //have a feeling some might like it + +#if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 + openmpt_module_ctl_set_boolean(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value); +#else openmpt_module_ctl_set(openmpt_mhandle, "render.resampler.emulate_amiga", cv_amigafilter.value ? "1" : "0"); +#endif + #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 openmpt_module_ctl_set_text(openmpt_mhandle, "render.resampler.emulate_amiga_type", cv_amigatype.string); #endif + openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value); if (looping) openmpt_module_set_repeat_count(openmpt_mhandle, -1); // Always repeat diff --git a/src/sdl/srb2icon.png b/src/sdl/srb2icon.png index 2aca4b204..39e170ff2 100644 Binary files a/src/sdl/srb2icon.png and b/src/sdl/srb2icon.png differ diff --git a/src/st_stuff.c b/src/st_stuff.c index b4b4a3d49..06ce08c5e 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -40,11 +40,9 @@ #include "hardware/hw_main.h" #endif -#ifdef HAVE_BLUA #include "lua_hud.h" #include "lua_hudlib_drawlist.h" #include "lua_hook.h" -#endif #include "r_fps.h" @@ -150,6 +148,10 @@ static patch_t *hud_tv2; static patch_t *envelope; #endif +// current player for overlay drawing +player_t *stplyr; +UINT8 stplyrnum; + // SRB2kart hudinfo_t hudinfo[NUMHUDITEMS] = @@ -191,9 +193,7 @@ hudinfo_t hudinfo[NUMHUDITEMS] = { 240, 160}, // HUD_LAP }; -#ifdef HAVE_BLUA static huddrawlist_h luahuddrawlist_game; -#endif // variable to stop mayonaka static from flickering consvar_t cv_lessflicker = {"lessflicker", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -471,9 +471,7 @@ void ST_Init(void) ST_LoadGraphics(); -#ifdef HAVE_BLUA luahuddrawlist_game = LUA_HUD_CreateDrawList(); -#endif } // change the status bar too, when pressing F12 while viewing a demo. @@ -490,86 +488,6 @@ void ST_changeDemoView(void) boolean st_overlay; -/* -static INT32 SCZ(INT32 z) -{ - return FixedInt(FixedMul(z<>= 1; - if (stplyr != &players[displayplayers[0]]) - y += vid.height / 2; - } - return y; -} -*/ - -/* -static INT32 STRINGY(INT32 y) -{ - //31/10/99: fixed by Hurdler so it _works_ also in hardware mode - // do not scale to resolution for hardware accelerated - // because these modes always scale by default - if (splitscreen) - { - y >>= 1; - if (stplyr != &players[displayplayers[0]]) - y += BASEVIDHEIGHT / 2; - } - return y; -} -*/ - -/* -static INT32 SPLITFLAGS(INT32 f) -{ - // Pass this V_SNAPTO(TOP|BOTTOM) and it'll trim them to account for splitscreen! -Red - if (splitscreen) - { - if (stplyr != &players[displayplayers[0]]) - f &= ~V_SNAPTOTOP; - else - f &= ~V_SNAPTOBOTTOM; - } - return f; -} -*/ - -/* -static INT32 SCX(INT32 x) -{ - return FixedInt(FixedMul(x<>= 1; - if (stplyr != &players[displayplayers[0]]) - y += vid.height / 2; - } - return FixedInt(FixedDiv(y, vid.fdupy)); -} -#endif - // ========================================================================= // INTERNAL DRAWING // ========================================================================= @@ -584,39 +502,6 @@ static INT32 SCR(INT32 r) #define ST_DrawPadNumFromHudWS(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n, q) #define ST_DrawPatchFromHudWS(h,p) V_DrawScaledPatch(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, p) -/* -// Draw a number, scaled, over the view, maybe with set translucency -// Always draw the number completely since it's overlay -// -// Supports different colors! woo! -static void ST_DrawNightsOverlayNum(INT32 x, INT32 y, INT32 a, - INT32 num, patch_t **numpat, skincolors_t colornum) -{ - INT32 w = SHORT(numpat[0]->width); - const UINT8 *colormap; - - // I want my V_SNAPTOx flags. :< -Red - //a &= V_ALPHAMASK; - - if (colornum == 0) - colormap = colormaps; - else // Uses the player colors. - colormap = R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE); - - I_Assert(num >= 0); // this function does not draw negative numbers - - // draw the number - do - { - x -= w; - V_DrawTranslucentMappedPatch(x, y, a, numpat[num % 10], colormap); - num /= 10; - } while (num); - - // Sorry chum, this function only draws UNSIGNED values! -} -*/ - // Devmode information static void ST_drawDebugInfo(void) { @@ -861,13 +746,13 @@ static void ST_drawLevelTitle(void) { dupcalc = (dupcalc - BASEVIDWIDTH)>>1; - V_DrawFill(sub - dupcalc, bary+9, ttlnumxpos+dupcalc + 1, 2, 31); - V_DrawDiag(sub + ttlnumxpos + 1, bary, 11, 31); - V_DrawFill(sub - dupcalc, bary, ttlnumxpos+dupcalc, 10, gtc); - V_DrawDiag(sub + ttlnumxpos, bary, 10, gtc); + V_DrawFill(sub - dupcalc, bary+9, ttlnumxpos+dupcalc + 1, 2, 31|V_SNAPTOBOTTOM); + V_DrawDiag(sub + ttlnumxpos + 1, bary, 11, 31|V_SNAPTOBOTTOM); + V_DrawFill(sub - dupcalc, bary, ttlnumxpos+dupcalc, 10, gtc|V_SNAPTOBOTTOM); + V_DrawDiag(sub + ttlnumxpos, bary, 10, gtc|V_SNAPTOBOTTOM); if (subttl[0]) - V_DrawRightAlignedString(sub + zonexpos - 8, bary+1, V_ALLOWLOWERCASE, subttl); + V_DrawRightAlignedString(sub + zonexpos - 8, bary+1, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, subttl); //else //V_DrawRightAlignedString(sub + zonexpos - 8, bary+1, V_ALLOWLOWERCASE, va("%s Mode", gametype_cons_t[gametype].strvalue)); } @@ -876,990 +761,17 @@ static void ST_drawLevelTitle(void) lvlttlxpos += sub; zonexpos += sub; - V_DrawLevelTitle(lvlttlxpos, bary-18, 0, lvlttl); + V_DrawLevelTitle(lvlttlxpos, bary-18, V_SNAPTOBOTTOM, lvlttl); if (strlen(zonttl) > 0) - V_DrawLevelTitle(zonexpos, bary+6, 0, zonttl); + V_DrawLevelTitle(zonexpos, bary+6, V_SNAPTOBOTTOM, zonttl); else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) - V_DrawLevelTitle(zonexpos, bary+6, 0, M_GetText("Zone")); + V_DrawLevelTitle(zonexpos, bary+6, V_SNAPTOBOTTOM, M_GetText("Zone")); if (actnum[0]) - V_DrawLevelTitle(ttlnumxpos+12, bary+6, 0, actnum); + V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } -/* -static void ST_drawFirstPersonHUD(void) -{ - player_t *player = stplyr; - patch_t *p = NULL; - UINT16 invulntime = 0; - - if (player->playerstate != PST_LIVE) - return; - - // Graue 06-18-2004: no V_NOSCALESTART, no SCX, no SCY, snap to right - if (player->powers[pw_shield] & SH_FORCE) - { - if ((player->powers[pw_shield] & 0xFF) > 0 || leveltime & 1) - p = forceshield; - } - else switch (player->powers[pw_shield] & SH_NOSTACK) - { - case SH_JUMP: p = jumpshield; break; - case SH_ELEMENTAL: p = watershield; break; - case SH_BOMB: p = bombshield; break; - case SH_ATTRACT: p = ringshield; break; - case SH_PITY: p = pityshield; break; - default: break; - } - - if (p) - { - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24), V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - else - V_DrawScaledPatch(304, 24, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - } - - // pw_flashing just sets the icon to flash no matter what. - invulntime = player->powers[pw_flashing] ? 1 : player->powers[pw_invulnerability]; - if (invulntime > 3*TICRATE || (invulntime && leveltime & 1)) - { - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24) + 14, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, invincibility); - else - V_DrawScaledPatch(304, 24 + 28, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, invincibility); - } - - if (player->powers[pw_sneakers] > 3*TICRATE || (player->powers[pw_sneakers] && leveltime & 1)) - { - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24) + 28, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, sneakers); - else - V_DrawScaledPatch(304, 24 + 56, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, sneakers); - } - - p = NULL; - - // Display the countdown drown numbers! - if ((player->powers[pw_underwater] <= 11*TICRATE + 1 - && player->powers[pw_underwater] >= 10*TICRATE + 1) - || (player->powers[pw_spacetime] <= 11*TICRATE + 1 - && player->powers[pw_spacetime] >= 10*TICRATE + 1)) - { - p = count5; - } - else if ((player->powers[pw_underwater] <= 9*TICRATE + 1 - && player->powers[pw_underwater] >= 8*TICRATE + 1) - || (player->powers[pw_spacetime] <= 9*TICRATE + 1 - && player->powers[pw_spacetime] >= 8*TICRATE + 1)) - { - p = count4; - } - else if ((player->powers[pw_underwater] <= 7*TICRATE + 1 - && player->powers[pw_underwater] >= 6*TICRATE + 1) - || (player->powers[pw_spacetime] <= 7*TICRATE + 1 - && player->powers[pw_spacetime] >= 6*TICRATE + 1)) - { - p = count3; - } - else if ((player->powers[pw_underwater] <= 5*TICRATE + 1 - && player->powers[pw_underwater] >= 4*TICRATE + 1) - || (player->powers[pw_spacetime] <= 5*TICRATE + 1 - && player->powers[pw_spacetime] >= 4*TICRATE + 1)) - { - p = count2; - } - else if ((player->powers[pw_underwater] <= 3*TICRATE + 1 - && player->powers[pw_underwater] >= 2*TICRATE + 1) - || (player->powers[pw_spacetime] <= 3*TICRATE + 1 - && player->powers[pw_spacetime] >= 2*TICRATE + 1)) - { - p = count1; - } - else if ((player->powers[pw_underwater] <= 1*TICRATE + 1 - && player->powers[pw_underwater] > 1) - || (player->powers[pw_spacetime] <= 1*TICRATE + 1 - && player->powers[pw_spacetime] > 1)) - { - p = count0; - } - - if (p) - V_DrawScaledPatch(SCX((BASEVIDWIDTH/2) - (SHORT(p->width)/2) + SHORT(p->leftoffset)), SCY(60 - SHORT(p->topoffset)), - V_NOSCALESTART|V_OFFSET|V_TRANSLUCENT, p); -} -*/ - -/* -// [21:42] <+Rob> Beige - Lavender - Steel Blue - Peach - Orange - Purple - Silver - Yellow - Pink - Red - Blue - Green - Cyan - Gold -static skincolors_t linkColor[14] = -{SKINCOLOR_BEIGE, SKINCOLOR_LAVENDER, SKINCOLOR_STEEL, SKINCOLOR_PEACH, SKINCOLOR_ORANGE, - SKINCOLOR_PURPLE, SKINCOLOR_SILVER, SKINCOLOR_SUPER4, SKINCOLOR_PINK, SKINCOLOR_RED, - SKINCOLOR_BLUE, SKINCOLOR_GREEN, SKINCOLOR_CYAN, SKINCOLOR_GOLD}; - -static void ST_drawNightsRecords(void) -{ - INT32 aflag = 0; - - if (!stplyr->texttimer) - return; - - if (stplyr->texttimer < TICRATE/2) - aflag = (9 - 9*stplyr->texttimer/(TICRATE/2)) << V_ALPHASHIFT; - - // A "Bonus Time Start" by any other name... - if (stplyr->textvar == 1) - { - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(52), V_GREENMAP|aflag, M_GetText("GET TO THE GOAL!")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60), aflag, M_GetText("SCORE MULTIPLIER START!")); - - if (stplyr->finishedtime) - { - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(140), aflag, "TIME:"); - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(148), aflag, "BONUS:"); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(140), V_ORANGEMAP|aflag, va("%d", (stplyr->startedtime - stplyr->finishedtime)/TICRATE)); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(148), V_ORANGEMAP|aflag, va("%d", (stplyr->finishedtime/TICRATE) * 100)); - } - } - - // Get n [more] Spheres - else if (stplyr->textvar <= 3 && stplyr->textvar >= 2) - { - if (!stplyr->capsule) - return; - - // Yes, this string is an abomination. - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60), aflag, - va(M_GetText("\x80GET\x82 %d\x80 %s%s%s!"), stplyr->capsule->health, - (stplyr->textvar == 3) ? M_GetText("MORE ") : "", - (G_IsSpecialStage(gamemap)) ? "SPHERE" : "RING", - (stplyr->capsule->health > 1) ? "S" : "")); - } - - // End Bonus - else if (stplyr->textvar == 4) - { - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(140), aflag, (G_IsSpecialStage(gamemap)) ? "ORBS:" : "RINGS:"); - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(148), aflag, "BONUS:"); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(140), V_ORANGEMAP|aflag, va("%d", stplyr->finishedrings)); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(148), V_ORANGEMAP|aflag, va("%d", stplyr->finishedrings * 50)); - ST_DrawNightsOverlayNum(BASEVIDWIDTH/2 + 48, STRINGY(160), aflag, stplyr->lastmarescore, nightsnum, SKINCOLOR_STEEL); - - // If new record, say so! - if (!(netgame || multiplayer) && G_GetBestNightsScore(gamemap, stplyr->lastmare + 1) <= stplyr->lastmarescore) - { - if (stplyr->texttimer & 16) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), V_YELLOWMAP|aflag, "* NEW RECORD *"); - } - - if (P_HasGrades(gamemap, stplyr->lastmare + 1)) - { - if (aflag) - V_DrawTranslucentPatch(BASEVIDWIDTH/2 + 60, STRINGY(160), aflag, - ngradeletters[P_GetGrade(stplyr->lastmarescore, gamemap, stplyr->lastmare)]); - else - V_DrawScaledPatch(BASEVIDWIDTH/2 + 60, STRINGY(160), 0, - ngradeletters[P_GetGrade(stplyr->lastmarescore, gamemap, stplyr->lastmare)]); - } - } -} -*/ - -/* -static void ST_drawNiGHTSHUD(void) // SRB2kart - unused. -{ - INT32 origamount; - INT32 minlink = 1; - INT32 total_ringcount; - UINT8 nosshack = 0; - - // When debugging, show "0 Link". - if (cv_debug & DBG_NIGHTSBASIC) - minlink = 0; - - // Cheap hack: don't display when the score is showing (it popping up for a split second when exiting a map is intentional) - if (stplyr->texttimer && stplyr->textvar == 4) - minlink = INT32_MAX; - - if (G_IsSpecialStage(gamemap)) - { // Since special stages share score, time, rings, etc. - // disable splitscreen mode for its HUD. - if (stplyr != &players[displayplayers[0]]) - return; - nosshack = splitscreen; - splitscreen = 0; - } - - // Link drawing - if ( -#ifdef HAVE_BLUA - LUA_HudEnabled(hud_nightslink) && -#endif - stplyr->linkcount > minlink) - { - skincolors_t colornum = linkColor[((stplyr->linkcount-1) / 5) % (sizeof(linkColor) / sizeof(skincolors_t))]; - if (stplyr->powers[pw_nights_linkfreeze]) - colornum = SKINCOLOR_WHITE; - - if (stplyr->linktimer < 2*TICRATE/3) - { - INT32 linktrans = (9 - 9*stplyr->linktimer/(2*TICRATE/3)) << V_ALPHASHIFT; - - if (splitscreen) - { - ST_DrawNightsOverlayNum(256, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT|linktrans, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawTranslucentMappedPatch(264, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT|linktrans, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - else - { - ST_DrawNightsOverlayNum(160, 160, V_SNAPTOBOTTOM|linktrans, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawTranslucentMappedPatch(168, 160, V_SNAPTOBOTTOM|linktrans, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - } - else // normal, fullbright - { -#if 0 // Cool but silly number effect where the previous link number fades away - if (stplyr->linkcount > 2 && stplyr->linktimer > (2*TICRATE) - 9) - { - INT32 offs = 10 - (stplyr->linktimer - (2*TICRATE - 9)); - INT32 ghosttrans = offs << V_ALPHASHIFT; - ST_DrawNightsOverlayNum(160, STRINGY(160+offs), SPLITFLAGS(V_SNAPTOBOTTOM)|ghosttrans, (stplyr->linkcount-2), - nightsnum, colornum); - } -#endif - - if (splitscreen) - { - ST_DrawNightsOverlayNum(256, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawMappedPatch(264, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - else - { - ST_DrawNightsOverlayNum(160, 160, V_SNAPTOBOTTOM, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawMappedPatch(168, 160, V_SNAPTOBOTTOM, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - } - - // Show remaining link time left in debug - if (cv_debug & DBG_NIGHTSBASIC) - V_DrawCenteredString(BASEVIDWIDTH/2, 180, V_SNAPTOBOTTOM, va("End in %d.%02d", stplyr->linktimer/TICRATE, G_TicsToCentiseconds(stplyr->linktimer))); - } - - // Drill meter - if ( -#ifdef HAVE_BLUA - LUA_HudEnabled(hud_nightsdrill) && -#endif - stplyr->pflags & PF_NIGHTSMODE) - { - INT32 locx, locy; - INT32 dfill; - UINT8 fillpatch; - - if (splitscreen || nosshack) - { - locx = 110; - locy = 188; - } - else - { - locx = 16; - locy = 180; - } - - // Use which patch? - if (stplyr->pflags & PF_DRILLING) - fillpatch = (stplyr->drillmeter & 1) + 1; - else - fillpatch = 0; - - if (splitscreen) - { // 11-5-14 Replaced the old hack with a slightly better hack. -Red - V_DrawScaledPatch(locx, STRINGY(locy)-3, SPLITFLAGS(V_SNAPTOBOTTOM)|V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), SPLITFLAGS(V_SNAPTOBOTTOM)|V_HUDTRANS, drillfill[fillpatch]); - } - else if (nosshack) - { // Even dirtier hack-of-a-hack to draw seperate drill meters in splitscreen special stages but nothing else. - splitscreen = nosshack; - V_DrawScaledPatch(locx, STRINGY(locy)-3, V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_HUDTRANS, drillfill[fillpatch]); - stplyr = &players[displayplayers[1]]; - if (stplyr->pflags & PF_DRILLING) - fillpatch = (stplyr->drillmeter & 1) + 1; - else - fillpatch = 0; - V_DrawScaledPatch(locx, STRINGY(locy-3), V_SNAPTOBOTTOM|V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_SNAPTOBOTTOM|V_HUDTRANS, drillfill[fillpatch]); - stplyr = &players[displayplayers[0]]; - splitscreen = 0; - } - else - { // Draw normally. <:3 - V_DrawScaledPatch(locx, locy, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, locy + 3, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS, drillfill[fillpatch]); - } - - // Display actual drill amount and bumper time - if (cv_debug & DBG_NIGHTSBASIC) - { - if (stplyr->bumpertime) - V_DrawString(SCX(locx), SCY(locy - 8), V_NOSCALESTART|V_REDMAP|V_MONOSPACE, va("BUMPER: 0.%02d", G_TicsToCentiseconds(stplyr->bumpertime))); - else - V_DrawString(SCX(locx), SCY(locy - 8), V_NOSCALESTART|V_MONOSPACE, va("Drill: %3d%%", (stplyr->drillmeter*100)/(96*20))); - } - } - - if (gametype == GT_RACE || gametype == GT_COMPETITION) - { - ST_drawScore(); - ST_drawTime(); - return; - } - - // Begin drawing brackets/chip display -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_nightsrings)) - { -#endif - ST_DrawOverlayPatch(SCX(16), SCY(8), nbracket); - if (G_IsSpecialStage(gamemap)) - ST_DrawOverlayPatch(SCX(24), SCY(8) + SCZ(8), nsshud); - else - ST_DrawOverlayPatch(SCX(24), SCY(8) + SCZ(8), nhud[(leveltime/2)%12]); - - if (G_IsSpecialStage(gamemap)) - { - INT32 i; - total_ringcount = 0; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE && players[i].health) - total_ringcount += players[i].health - 1; - } - else - total_ringcount = stplyr->health-1; - - if (stplyr->capsule) - { - INT32 amount; - const INT32 length = 88; - - origamount = stplyr->capsule->spawnpoint->angle; - I_Assert(origamount > 0); // should not happen now - - ST_DrawOverlayPatch(SCX(72), SCY(8), nbracket); - ST_DrawOverlayPatch(SCX(74), SCY(8) + SCZ(4), minicaps); - - if (stplyr->capsule->reactiontime != 0) - { - INT32 r; - const INT32 orblength = 20; - - for (r = 0; r < 5; r++) - { - ST_DrawOverlayPatch(SCX(230 - (7*r)), SCY(144), redstat); - ST_DrawOverlayPatch(SCX(188 - (7*r)), SCY(144), orngstat); - ST_DrawOverlayPatch(SCX(146 - (7*r)), SCY(144), yelstat); - ST_DrawOverlayPatch(SCX(104 - (7*r)), SCY(144), byelstat); - } - - amount = (origamount - stplyr->capsule->health); - amount = (amount * orblength)/origamount; - - if (amount > 0) - { - INT32 t; - - // Fill up the bar with blue orbs... in reverse! (yuck) - for (r = amount; r > 0; r--) - { - t = r; - - if (r > 15) ++t; - if (r > 10) ++t; - if (r > 5) ++t; - - ST_DrawOverlayPatch(SCX(69 + (7*t)), SCY(144), bluestat); - } - } - } - else - { - INT32 cfill; - - // Lil' white box! - V_DrawScaledPatch(15, STRINGY(8) + 34, V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulebar); - - amount = (origamount - stplyr->capsule->health); - amount = (amount * length)/origamount; - - for (cfill = 0; cfill < amount && cfill < 88; ++cfill) - V_DrawScaledPatch(15 + cfill + 1, STRINGY(8) + 35, V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulefill); - } - - if (total_ringcount >= stplyr->capsule->health) - ST_DrawOverlayPatch(SCX(40), SCY(8) + SCZ(5), nredar[leveltime%8]); - else - ST_DrawOverlayPatch(SCX(40), SCY(8) + SCZ(5), narrow[(leveltime/2)%8]); - } - else - ST_DrawOverlayPatch(SCX(40), SCY(8) + SCZ(5), narrow[8]); - - if (total_ringcount >= 100) - ST_DrawOverlayNum((total_ringcount >= 1000) ? SCX(76) : SCX(72), SCY(8) + SCZ(11), total_ringcount); - else - ST_DrawOverlayNum(SCX(68), SCY(8) + SCZ(11), total_ringcount); -#ifdef HAVE_BLUA - } -#endif - - // Score - if (!stplyr->exiting -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_nightsscore) -#endif - ) - { - ST_DrawNightsOverlayNum(304, STRINGY(16), SPLITFLAGS(V_SNAPTOTOP)|V_SNAPTORIGHT, stplyr->marescore, nightsnum, SKINCOLOR_STEEL); - } - - if (!stplyr->exiting -#ifdef HAVE_BLUA - // TODO give this its own section for Lua - && LUA_HudEnabled(hud_nightsscore) -#endif - ) - { - if (modeattacking == ATTACKING_NIGHTS) - { - INT32 maretime = max(stplyr->realtime - stplyr->marebegunat, 0); - fixed_t cornerx = vid.width, cornery = vid.height-SCZ(20); - -#define ASSISHHUDFIX(n) (n*vid.dupx) - ST_DrawOverlayPatch(cornerx-ASSISHHUDFIX(22), cornery, W_CachePatchName("NGRTIMER", PU_HUDGFX)); - ST_DrawPaddedOverlayNum(cornerx-ASSISHHUDFIX(22), cornery, G_TicsToCentiseconds(maretime), 2); - ST_DrawOverlayPatch(cornerx-ASSISHHUDFIX(46), cornery, sboperiod); - if (maretime < 60*TICRATE) - ST_DrawOverlayNum(cornerx-ASSISHHUDFIX(46), cornery, G_TicsToSeconds(maretime)); - else - { - ST_DrawPaddedOverlayNum(cornerx-ASSISHHUDFIX(46), cornery, G_TicsToSeconds(maretime), 2); - ST_DrawOverlayPatch(cornerx-ASSISHHUDFIX(70), cornery, sbocolon); - ST_DrawOverlayNum(cornerx-ASSISHHUDFIX(70), cornery, G_TicsToMinutes(maretime, true)); - } - } -#undef ASSISHHUDFIX - } - - // Ideya time remaining - if (!stplyr->exiting && stplyr->nightstime > 0 -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_nightstime) -#endif - ) - { - INT32 realnightstime = stplyr->nightstime/TICRATE; - INT32 numbersize; - - if (G_IsSpecialStage(gamemap)) - { - tic_t lowest_time = stplyr->nightstime; - INT32 i; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE && players[i].nightstime < lowest_time) - lowest_time = players[i].nightstime; - realnightstime = lowest_time/TICRATE; - } - - if (stplyr->powers[pw_flashing] > TICRATE ) // was hit - { - UINT16 flashingLeft = stplyr->powers[pw_flashing]-(TICRATE); - if (flashingLeft < TICRATE/2) // Start fading out - { - UINT32 fadingFlag = (9 - 9*flashingLeft/(TICRATE/2)) << V_ALPHASHIFT; - V_DrawTranslucentPatch(SCX(160 - (minus5sec->width/2)), SCY(28), V_NOSCALESTART|fadingFlag, minus5sec); - } - else - V_DrawScaledPatch(SCX(160 - (minus5sec->width/2)), SCY(28), V_NOSCALESTART, minus5sec); - } - - if (realnightstime < 10) - numbersize = 16/2; - else if (realnightstime < 100) - numbersize = 32/2; - else - numbersize = 48/2; - - if (realnightstime < 10) - ST_DrawNightsOverlayNum(160 + numbersize, STRINGY(12), SPLITFLAGS(V_SNAPTOTOP), realnightstime, - nightsnum, SKINCOLOR_RED); - else - ST_DrawNightsOverlayNum(160 + numbersize, STRINGY(12), SPLITFLAGS(V_SNAPTOTOP), realnightstime, - nightsnum, SKINCOLOR_SUPER4); - - // Show exact time in debug - if (cv_debug & DBG_NIGHTSBASIC) - V_DrawString(160 + numbersize + 8, 24, V_SNAPTOTOP|((realnightstime < 10) ? V_REDMAP : V_YELLOWMAP), va("%02d", G_TicsToCentiseconds(stplyr->nightstime))); - } - - // Show pickup durations - if (cv_debug & DBG_NIGHTSBASIC) - { - UINT16 pwr; - - if (stplyr->powers[pw_nights_superloop]) - { - pwr = stplyr->powers[pw_nights_superloop]; - V_DrawSmallScaledPatch(SCX(110), SCY(44), V_NOSCALESTART, W_CachePatchName("NPRUA0",PU_CACHE)); - V_DrawThinString(SCX(106), SCY(52), V_NOSCALESTART|V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); - } - - if (stplyr->powers[pw_nights_helper]) - { - pwr = stplyr->powers[pw_nights_helper]; - V_DrawSmallScaledPatch(SCX(150), SCY(44), V_NOSCALESTART, W_CachePatchName("NPRUC0",PU_CACHE)); - V_DrawThinString(SCX(146), SCY(52), V_NOSCALESTART|V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); - } - - if (stplyr->powers[pw_nights_linkfreeze]) - { - pwr = stplyr->powers[pw_nights_linkfreeze]; - V_DrawSmallScaledPatch(SCX(190), SCY(44), V_NOSCALESTART, W_CachePatchName("NPRUE0",PU_CACHE)); - V_DrawThinString(SCX(186), SCY(52), V_NOSCALESTART|V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); - } - } - - // Records/extra text -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_nightsrecords)) -#endif - ST_drawNightsRecords(); - - splitscreen = nosshack; -} -*/ - -/* -static void ST_drawWeaponRing(powertype_t weapon, INT32 rwflag, INT32 wepflag, INT32 xoffs, patch_t *pat) -{ - INT32 txtflags = 0, patflags = 0; - - if (stplyr->powers[weapon]) - { - if (stplyr->powers[weapon] >= rw_maximums[wepflag]) - txtflags |= V_YELLOWMAP; - - if (weapon == pw_infinityring - || (stplyr->ringweapons & rwflag && stplyr->health > 1)) - txtflags |= V_20TRANS; - else - { - txtflags |= V_TRANSLUCENT; - patflags = V_80TRANS; - } - - V_DrawScaledPatch(8 + xoffs, STRINGY(162), V_SNAPTOLEFT|patflags, pat); - - if (stplyr->powers[weapon] > 99) - V_DrawThinString(8 + xoffs + 1, STRINGY(162), V_SNAPTOLEFT|txtflags, va("%d", stplyr->powers[weapon])); - else - V_DrawString(8 + xoffs, STRINGY(162), V_SNAPTOLEFT|txtflags, va("%d", stplyr->powers[weapon])); - - if (stplyr->currentweapon == wepflag) - V_DrawScaledPatch(6 + xoffs, STRINGY(162 - (splitscreen ? 4 : 2)), V_SNAPTOLEFT, curweapon); - } - else if (stplyr->ringweapons & rwflag) - V_DrawScaledPatch(8 + xoffs, STRINGY(162), V_SNAPTOLEFT|V_TRANSLUCENT, pat); -} -*/ - -/* -static void ST_drawMatchHUD(void) // SRB2kart - unused. -{ - INT32 offset = (BASEVIDWIDTH / 2) - (NUM_WEAPONS * 10); - - if (!G_BattleGametype()) - return; - - if (G_TagGametype() && !(stplyr->pflags & PF_TAGIT)) - return; - -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_weaponrings)) { -#endif - - if (stplyr->powers[pw_infinityring]) - ST_drawWeaponRing(pw_infinityring, 0, 0, offset, infinityring); - else if (stplyr->health > 1) - V_DrawScaledPatch(8 + offset, STRINGY(162), V_SNAPTOLEFT, normring); - else - V_DrawTranslucentPatch(8 + offset, STRINGY(162), V_SNAPTOLEFT|V_80TRANS, normring); - - if (!stplyr->currentweapon) - V_DrawScaledPatch(6 + offset, STRINGY(162 - (splitscreen ? 4 : 2)), V_SNAPTOLEFT, curweapon); - - offset += 20; - ST_drawWeaponRing(pw_automaticring, RW_AUTO, WEP_AUTO, offset, autoring); - offset += 20; - ST_drawWeaponRing(pw_bouncering, RW_BOUNCE, WEP_BOUNCE, offset, bouncering); - offset += 20; - ST_drawWeaponRing(pw_scatterring, RW_SCATTER, WEP_SCATTER, offset, scatterring); - offset += 20; - ST_drawWeaponRing(pw_grenadering, RW_GRENADE, WEP_GRENADE, offset, grenadering); - offset += 20; - ST_drawWeaponRing(pw_explosionring, RW_EXPLODE, WEP_EXPLODE, offset, explosionring); - offset += 20; - ST_drawWeaponRing(pw_railring, RW_RAIL, WEP_RAIL, offset, railring); - -#ifdef HAVE_BLUA - } - - if (LUA_HudEnabled(hud_powerstones)) { -#endif - - // Power Stones collected - offset = 136; // Used for Y now - - if (stplyr->powers[pw_emeralds] & EMERALD1) - V_DrawScaledPatch(28, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[0]); - - offset += 8; - - if (stplyr->powers[pw_emeralds] & EMERALD2) - V_DrawScaledPatch(40, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[1]); - - if (stplyr->powers[pw_emeralds] & EMERALD6) - V_DrawScaledPatch(16, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[5]); - - offset += 16; - - if (stplyr->powers[pw_emeralds] & EMERALD3) - V_DrawScaledPatch(40, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[2]); - - if (stplyr->powers[pw_emeralds] & EMERALD5) - V_DrawScaledPatch(16, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[4]); - - offset += 8; - - if (stplyr->powers[pw_emeralds] & EMERALD4) - V_DrawScaledPatch(28, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[3]); - - offset -= 16; - - if (stplyr->powers[pw_emeralds] & EMERALD7) - V_DrawScaledPatch(28, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[6]); - -#ifdef HAVE_BLUA - } -#endif -} -*/ - -/* -static inline void ST_drawRaceHUD(void) // SRB2kart - unused. -{ - if (leveltime > starttime-(3*TICRATE) && leveltime <= starttime-(2*TICRATE)) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(race3->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, race3); - else if (leveltime > starttime-(2*TICRATE) && leveltime <= starttime-TICRATE) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(race2->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, race2); - else if (leveltime > starttime-TICRATE && leveltime <= starttime) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(race1->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, race1); - else if (leveltime > starttime && leveltime <= starttime+TICRATE) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(racego->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, racego); - - if (circuitmap) - { - if (stplyr->exiting) - V_DrawString(hudinfo[HUD_LAP].x, STRINGY(hudinfo[HUD_LAP].y), V_YELLOWMAP, "FINISHED!"); - else - V_DrawString(hudinfo[HUD_LAP].x, STRINGY(hudinfo[HUD_LAP].y), 0, va("Lap: %u/%d", stplyr->laps+1, cv_numlaps.value)); - } -} -*/ - -/* -static void ST_drawTagHUD(void) // SRB2kart - unused. -{ - char pstime[33] = ""; - char pstext[33] = ""; - - // Figure out what we're going to print. - if (leveltime < hidetime * TICRATE) //during the hide time, the seeker and hiders have different messages on their HUD. - { - if (hidetime) - sprintf(pstime, "%d", (hidetime - leveltime/TICRATE)); //hide time is in seconds, not tics. - - if (stplyr->pflags & PF_TAGIT && !stplyr->spectator) - sprintf(pstext, "%s", M_GetText("WAITING FOR PLAYERS TO HIDE...")); - else - { - if (!stplyr->spectator) //spectators get a generic HUD message rather than a gametype specific one. - { - if (gametype == GT_HIDEANDSEEK) //hide and seek. - sprintf(pstext, "%s", M_GetText("HIDE BEFORE TIME RUNS OUT!")); - else //default - sprintf(pstext, "%s", M_GetText("FLEE BEFORE YOU ARE HUNTED!")); - } - else - sprintf(pstext, "%s", M_GetText("HIDE TIME REMAINING:")); - } - } - else - { - if (cv_timelimit.value && timelimitintics >= leveltime) - sprintf(pstime, "%d", (timelimitintics-leveltime)/TICRATE); - - if (stplyr->pflags & PF_TAGIT) - sprintf(pstext, "%s", M_GetText("YOU'RE IT!")); - else - { - if (cv_timelimit.value) - sprintf(pstext, "%s", M_GetText("TIME REMAINING:")); - else //Since having no hud message in tag is not characteristic: - sprintf(pstext, "%s", M_GetText("NO TIME LIMIT")); - } - } - - // Print the stuff. - if (pstext[0]) - { - if (splitscreen) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(168), 0, pstext); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), 0, pstext); - } - if (pstime[0]) - { - if (splitscreen) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), 0, pstime); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(192), 0, pstime); - } -} - -static void ST_drawCTFHUD(void) // SRB2kart - unused. -{ - INT32 i; - UINT16 whichflag = 0; - - // Draw the flags - V_DrawSmallScaledPatch(256, (splitscreen) ? STRINGY(160) : STRINGY(176), V_HUDTRANS, rflagico); - V_DrawSmallScaledPatch(288, (splitscreen) ? STRINGY(160) : STRINGY(176), V_HUDTRANS, bflagico); - - for (i = 0; i < MAXPLAYERS; i++) - { - if (players[i].gotflag & GF_REDFLAG) // Red flag isn't at base - V_DrawScaledPatch(256, (splitscreen) ? STRINGY(156) : STRINGY(174), V_HUDTRANS, nonicon); - else if (players[i].gotflag & GF_BLUEFLAG) // Blue flag isn't at base - V_DrawScaledPatch(288, (splitscreen) ? STRINGY(156) : STRINGY(174), V_HUDTRANS, nonicon); - - whichflag |= players[i].gotflag; - if ((whichflag & (GF_REDFLAG|GF_BLUEFLAG)) == (GF_REDFLAG|GF_BLUEFLAG)) - break; // both flags were found, let's stop early - } - - // YOU have a flag. Display a monitor-like icon for it. - if (stplyr->gotflag) - { - patch_t *p = (stplyr->gotflag & GF_REDFLAG) ? gotrflag : gotbflag; - - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24) + 42, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - else - V_DrawScaledPatch(304, 24 + 84, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - } - - // Display a countdown timer showing how much time left until the flag your team dropped returns to base. - { - char timeleft[33]; - if (redflag && redflag->fuse > 1) - { - sprintf(timeleft, "%u", (redflag->fuse / TICRATE)); - V_DrawCenteredString(268, STRINGY(184), V_YELLOWMAP|V_HUDTRANS, timeleft); - } - - if (blueflag && blueflag->fuse > 1) - { - sprintf(timeleft, "%u", (blueflag->fuse / TICRATE)); - V_DrawCenteredString(300, STRINGY(184), V_YELLOWMAP|V_HUDTRANS, timeleft); - } - } -} -*/ - -// Draws "Red Team", "Blue Team", or "Spectator" for team gametypes. -/* -static inline void ST_drawTeamName(void) // SRB2kart - unused. -{ - if (stplyr->ctfteam == 1) - V_DrawString(256, splitscreen ? STRINGY(184) : STRINGY(192), V_HUDTRANSHALF, "RED TEAM"); - else if (stplyr->ctfteam == 2) - V_DrawString(248, splitscreen ? STRINGY(184) : STRINGY(192), V_HUDTRANSHALF, "BLUE TEAM"); - else - V_DrawString(244, splitscreen ? STRINGY(184) : STRINGY(192), V_HUDTRANSHALF, "SPECTATOR"); -} -*/ - -/* -static void ST_drawSpecialStageHUD(void) // SRB2kart - unused. -{ - if (totalrings > 0) - ST_DrawNumFromHudWS(HUD_SS_TOTALRINGS, totalrings); - - if (leveltime < 5*TICRATE && totalrings > 0) - { - ST_DrawPatchFromHud(HUD_GETRINGS, getall); - ST_DrawNumFromHud(HUD_GETRINGSNUM, totalrings); - } - - if (sstimer) - { - V_DrawString(hudinfo[HUD_TIMELEFT].x, STRINGY(hudinfo[HUD_TIMELEFT].y), V_HUDTRANS, M_GetText("TIME LEFT")); - ST_DrawNumFromHud(HUD_TIMELEFTNUM, sstimer/TICRATE); - } - else - ST_DrawPatchFromHud(HUD_TIMEUP, timeup); -} -*/ - -/* -static INT32 ST_drawEmeraldHuntIcon(mobj_t *hunt, patch_t **patches, INT32 offset) -{ - INT32 interval, i; - UINT32 dist = ((UINT32)P_AproxDistance(P_AproxDistance(stplyr->mo->x - hunt->x, stplyr->mo->y - hunt->y), stplyr->mo->z - hunt->z))>>FRACBITS; - - if (dist < 128) - { - i = 5; - interval = 5; - } - else if (dist < 512) - { - i = 4; - interval = 10; - } - else if (dist < 1024) - { - i = 3; - interval = 20; - } - else if (dist < 2048) - { - i = 2; - interval = 30; - } - else if (dist < 3072) - { - i = 1; - interval = 35; - } - else - { - i = 0; - interval = 0; - } - - V_DrawScaledPatch(hudinfo[HUD_HUNTPICS].x+offset, STRINGY(hudinfo[HUD_HUNTPICS].y), V_HUDTRANS, patches[i]); - return interval; -} -*/ - -/* -// Separated a few things to stop the SOUND EFFECTS BLARING UGH SHUT UP AAAA -static void ST_doHuntIconsAndSound(void) // SRB2kart - unused. -{ - INT32 interval = 0, newinterval = 0; - - if (hunt1 && hunt1->health) - interval = ST_drawEmeraldHuntIcon(hunt1, hunthoming, -20); - - if (hunt2 && hunt2->health) - { - newinterval = ST_drawEmeraldHuntIcon(hunt2, hunthoming, 0); - if (newinterval && (!interval || newinterval < interval)) - interval = newinterval; - } - - if (hunt3 && hunt3->health) - { - newinterval = ST_drawEmeraldHuntIcon(hunt3, hunthoming, 20); - if (newinterval && (!interval || newinterval < interval)) - interval = newinterval; - } - - if (!(P_AutoPause() || paused) && interval > 0 && leveltime && leveltime % interval == 0) - S_StartSound(NULL, sfx_emfind); -} - -static void ST_doItemFinderIconsAndSound(void) // SRB2kart - unused. -{ - INT32 emblems[16]; - thinker_t *th; - mobj_t *mo2; - - UINT8 stemblems = 0, stunfound = 0; - INT32 i; - INT32 interval = 0, newinterval = 0; - INT32 soffset; - - for (i = 0; i < numemblems; ++i) - { - if (emblemlocations[i].type > ET_SKIN || emblemlocations[i].level != gamemap) - continue; - - emblems[stemblems++] = i; - - if (!emblemlocations[i].collected) - ++stunfound; - - if (stemblems >= 16) - break; - } - // Found all/none exist? Don't waste our time - if (!stunfound) - return; - - // Scan thinkers to find emblem mobj with these ids - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - mo2 = (mobj_t *)th; - - if (mo2->type == MT_EMBLEM) - { - if (!(mo2->flags & MF_SPECIAL)) - continue; - - for (i = 0; i < stemblems; ++i) - { - if (mo2->health == emblems[i]+1) - { - soffset = (i * 20) - ((stemblems-1) * 10); - - newinterval = ST_drawEmeraldHuntIcon(mo2, itemhoming, soffset); - if (newinterval && (!interval || newinterval < interval)) - interval = newinterval; - - break; - } - } - } - } - - if (!(P_AutoPause() || paused) && interval > 0 && leveltime && leveltime % interval == 0) - S_StartSound(NULL, sfx_emfind); -} -*/ - // Draw the status bar overlay, customisable: the user chooses which // kind of information to overlay // @@ -1869,97 +781,13 @@ static void ST_overlayDrawer(void) if (!(hu_showscores && (netgame || multiplayer))) { K_drawKartHUD(); - - /* SRB2kart doesn't need this stuff - if (maptol & TOL_NIGHTS) - ST_drawNiGHTSHUD(); - else - { -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_score)) -#endif - ST_drawScore(); -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_time)) -#endif - ST_drawTime(); -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_rings)) -#endif - ST_drawRings(); - if (G_GametypeUsesLives() -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_lives) -#endif - ) - ST_drawLives(); - } - */ } - // GAME OVER pic - /*if (G_GametypeUsesLives() && stplyr->lives <= 0 && !(hu_showscores && (netgame || multiplayer))) - { - patch_t *p; - - if (racecountdown == 1) - p = timeover; - else - p = sboover; - - V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, STRINGY(BASEVIDHEIGHT/2 - (SHORT(p->height)/2)), 0, p); - }*/ - if (!hu_showscores) // hide the following if TAB is held { // Countdown timer for Race Mode // ...moved to k_kart.c so we can take advantage of the LAPS_Y value - /* SRB2kart doesn't need this stuff, I think - // If you are in overtime, put a big honkin' flashin' message on the screen. - if (G_BattleGametype() && cv_overtime.value - && (leveltime > (timelimitintics + TICRATE/2)) && cv_timelimit.value && (leveltime/TICRATE % 2 == 0)) - { - if (splitscreen) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(168), 0, M_GetText("OVERTIME!")); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), 0, M_GetText("OVERTIME!")); - } - - // Draw Match-related stuff - //\note Match HUD is drawn no matter what gametype. - // ... just not if you're a spectator. - if (!stplyr->spectator) - ST_drawMatchHUD(); - - // Race HUD Stuff - if (gametype == GT_RACE || gametype == GT_COMPETITION) - ST_drawRaceHUD(); - // Tag HUD Stuff - else if (gametype == GT_TAG || gametype == GT_HIDEANDSEEK) - ST_drawTagHUD(); - // CTF HUD Stuff - else if (gametype == GT_CTF) - ST_drawCTFHUD(); - - // Team names for team gametypes - if (G_GametypeHasTeams()) - ST_drawTeamName(); - - // Special Stage HUD - if (!useNightsSS && G_IsSpecialStage(gamemap) && stplyr == &players[displayplayers[0]]) - ST_drawSpecialStageHUD(); - - // Emerald Hunt Indicators - if (cv_itemfinder.value && M_SecretUnlocked(SECRET_ITEMFINDER)) - ST_doItemFinderIconsAndSound(); - else - ST_doHuntIconsAndSound(); - - if (stplyr->powers[pw_gravityboots] > 3*TICRATE || (stplyr->powers[pw_gravityboots] && leveltime & 1)) - V_DrawScaledPatch(hudinfo[HUD_GRAVBOOTSICO].x, STRINGY(hudinfo[HUD_GRAVBOOTSICO].y), V_SNAPTORIGHT, gravboots); - */ - if (cv_showviewpointtext.value) { if (!(multiplayer && demo.playback)) @@ -1971,16 +799,16 @@ static void ST_overlayDrawer(void) strlcpy(name, player_names[stplyr-players], 13);*/ // Show name of player being displayed - V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, V_HUDTRANS, M_GetText("VIEWPOINT:")); - V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_HUDTRANS|V_ALLOWLOWERCASE, player_names[stplyr-players]); + V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_HUDTRANS, M_GetText("VIEWPOINT:")); + V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_SNAPTOBOTTOM|V_HUDTRANS|V_ALLOWLOWERCASE, player_names[stplyr-players]); } } else if (!demo.title) { if (!splitscreen) { - V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("VIEWPOINT:")); - V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_HUDTRANSHALF|V_ALLOWLOWERCASE, player_names[stplyr-players]); + V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_HUDTRANSHALF, M_GetText("VIEWPOINT:")); + V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_SNAPTOBOTTOM|V_HUDTRANSHALF|V_ALLOWLOWERCASE, player_names[stplyr-players]); } else if (splitscreen == 1) { @@ -2007,7 +835,6 @@ static void ST_overlayDrawer(void) }*/ } -#ifdef HAVE_BLUA if (!(netgame || multiplayer) || !hu_showscores) { if (renderisnewtic) @@ -2015,39 +842,14 @@ static void ST_overlayDrawer(void) LUAh_GameHUD(stplyr, luahuddrawlist_game); } } -#endif // HAVE_BLUA // draw level title Tails - if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_stagetitle) -#endif - ) + if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) && LUA_HudEnabled(hud_stagetitle)) ST_drawLevelTitle(); if (!hu_showscores && netgame && !mapreset) { - /*if (G_GametypeUsesLives() && stplyr->lives <= 0 && racecountdown != 1) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), 0, M_GetText("Press Viewpoint Key to watch a player.")); - else if (gametype == GT_HIDEANDSEEK && - (!stplyr->spectator && !(stplyr->pflags & PF_TAGIT)) && (leveltime > hidetime * TICRATE)) - { - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(116), 0, M_GetText("You cannot move while hiding.")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), 0, M_GetText("Press Viewpoint Key to watch a player.")); - } - else if (!G_RaceGametype() && stplyr->playerstate == PST_DEAD && stplyr->lives) //Death overrides spectator text. - { - INT32 respawntime = cv_respawntime.value - stplyr->deadtimer/TICRATE; - if (respawntime > 0 && !stplyr->spectator) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, va(M_GetText("Respawn in: %d second%s."), respawntime, respawntime == 1 ? "" : "s")); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Jump to respawn.")); - } - else*/ if (stplyr->spectator -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_textspectator) -#endif - ) + if (stplyr->spectator && LUA_HudEnabled(hud_textspectator)) { const char *itemtxt = M_GetText("Item - Join Game"); @@ -2213,22 +1015,20 @@ void ST_Drawer(void) if (st_overlay) { -#ifdef HAVE_BLUA if (renderisnewtic) { LUA_HUD_ClearDrawList(luahuddrawlist_game); } -#endif // HAVE_BLUA + // No deadview! for (i = 0; i <= splitscreen; i++) { stplyr = &players[displayplayers[i]]; + stplyrnum = i; ST_overlayDrawer(); } -#ifdef HAVE_BLUA LUA_HUD_DrawList(luahuddrawlist_game); -#endif // HAVE_BLUA // draw Midnight Channel's overlay ontop if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff. diff --git a/src/st_stuff.h b/src/st_stuff.h index 0dffa46c3..46fcc4d67 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -53,9 +53,6 @@ void ST_LoadGraphics(void); void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum); void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum); void ST_ReloadSkinFaceGraphics(void); -#ifdef DELFILE -void ST_UnLoadFaceGraphics(INT32 skinnum); -#endif void ST_doPaletteStuff(void); @@ -68,6 +65,8 @@ boolean ST_SameTeam(player_t *a, player_t *b); extern boolean st_overlay; // sb overlay on or off when fullscreen extern INT32 st_palette; // 0 is default, any others are special palettes. +extern player_t *stplyr; // for splitscreen correct palette changes and overlay +extern UINT8 stplyrnum; extern lumpnum_t st_borderpatchnum; // patches, also used in intermission diff --git a/src/tables.h b/src/tables.h index beea392ec..353bf591f 100644 --- a/src/tables.h +++ b/src/tables.h @@ -86,7 +86,7 @@ extern angle_t tantoangle[SLOPERANGE+1]; // Utility function, called by R_PointToAngle. FUNCMATH unsigned SlopeDiv(unsigned num, unsigned den); // Only called by R_PointToAngleEx -UINT64 SlopeDivEx(unsigned int num, unsigned int den); +FUNCMATH UINT64 SlopeDivEx(unsigned int num, unsigned int den); // 360 - angle_t(ANGLE_45) = ANGLE_315 FUNCMATH FUNCINLINE static ATTRINLINE angle_t InvAngle(angle_t a) diff --git a/src/v_video.c b/src/v_video.c index 0d0405208..25d7a1dbd 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -388,7 +388,7 @@ const char *R_GetPalname(UINT16 num) if (num > 0 && num <= 10000) snprintf(newpal, 8, "PAL%04u", num-1); - strncpy(palname, newpal, 8); + memcpy(palname, newpal, 9); return palname; } @@ -477,6 +477,12 @@ static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0}; static UINT8 hudminusalpha[11] = { 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5}; UINT8 hudtrans = 0; +// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol +INT32 V_LocalTransFlag(void) +{ + return ((10-cv_translucenthud.value)*V_10TRANS); +} + static const UINT8 *v_colormap = NULL; static const UINT8 *v_translevel = NULL; @@ -2322,6 +2328,109 @@ void V_DrawCenteredSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const V_DrawSmallStringAtFixed(x, y, option, string); } +void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + fixed_t cx = x, cy = y; + INT32 w, c, dupx, dupy, scrwidth, center = 0, left = 0; + const char *ch = string; + INT32 spacewidth = 4, charwidth = 0; + INT32 charflags = 0; + const UINT8 *colormap = NULL; + INT32 lowercase = (option & V_ALLOWLOWERCASE); + option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE... + + if (option & V_NOSCALESTART) + { + dupx = vid.dupx; + dupy = vid.dupy; + scrwidth = vid.width; + } + else + { + dupx = dupy = 1; + scrwidth = vid.width/vid.dupx; + left = (scrwidth - BASEVIDWIDTH)/2; + scrwidth -= left; + } + + switch (option & V_SPACINGMASK) + { + case V_MONOSPACE: + spacewidth = 8; + /* FALLTHRU */ + case V_OLDSPACING: + charwidth = 8; + break; + case V_6WIDTHSPACE: + spacewidth = 6; + default: + break; + } + + charflags = (option & V_CHARCOLORMASK); + colormap = V_GetStringColormap(charflags); + + for (;;ch++) + { + if (!*ch) + break; + if (*ch & 0x80) //color parsing -x 2.16.09 + { + // manually set flags override color codes + if (!(option & V_CHARCOLORMASK)) + { + charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; + colormap = V_GetStringColormap(charflags); + } + continue; + } + if (*ch == '\n') + { + cx = x; + + if (option & V_RETURN8) + cy += (8*dupy)<= HU_FONTSIZE || !tny_font[c]) + { + cx += (spacewidth * dupx)<width)*(dupx/2); + } + else + w = SHORT(tny_font[c]->width) * dupx; + + if ((cx>>FRACBITS) > scrwidth) + break; + if ((cx>>FRACBITS)+left + w < 0) //left boundary check + { + cx += w<width); + + if (flags & V_NOSCALESTART) + w *= vid.dupx; + + if (num < 0) + num = -num; + + // draw the number + do + { + x -= w; + V_DrawFixedPatch(x< // Windows can't open utf-8 path so it must be converted to utf-16 -FILE* fopen_utf8(const char* filename, const char* mode) +static FILE* fopen_utf8(const char* filename, const char* mode) { static const int MY_PATH_MAX = 2048; WCHAR nameW[MY_PATH_MAX]; @@ -222,7 +222,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors) static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) { UINT16 posStart, posEnd; -#ifdef HAVE_BLUA + posStart = W_CheckNumForFolderStartPK3("Lua/", wadnum, 0); if (posStart != INT16_MAX) { @@ -230,7 +230,6 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) for (; posStart < posEnd; posStart++) LUA_LoadLump(wadnum, posStart); } -#endif posStart = W_CheckNumForFolderStartPK3("SOC/", wadnum, 0); if (posStart != INT16_MAX) @@ -255,7 +254,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) { UINT16 lump; -#ifdef HAVE_BLUA // Find Lua scripts before SOCs to allow new A_Actions in SOC editing. { lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; @@ -263,7 +261,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) if (memcmp(lump_p->name,"LUA_",4)==0) LUA_LoadLump(wadnum, lump); } -#endif { lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; @@ -704,7 +701,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) // // Can now load dehacked files (.soc) // -UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, boolean local) +UINT16 W_InitFile(const char *filename, boolean local) { FILE *handle; lumpinfo_t *lumpinfo = NULL; @@ -770,11 +767,9 @@ UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, b case RET_SOC: lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "OBJCTCFG"); break; -#ifdef HAVE_BLUA case RET_LUA: lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "LUA_INIT"); break; -#endif case RET_PK3: lumpinfo = ResGetLumpsZip(handle, &numlumps); break; @@ -842,11 +837,9 @@ UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, b CONS_Printf(M_GetText("Loading SOC from %s\n"), wadfile->filename); DEH_LoadDehackedLumpPwad(numwadfiles - 1, 0); break; -#ifdef HAVE_BLUA case RET_LUA: LUA_LoadLump(numwadfiles - 1, 0); break; -#endif default: break; } @@ -859,37 +852,6 @@ UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, b return wadfile->numlumps; } -#ifdef DELFILE -void W_UnloadWadFile(UINT16 num) -{ - INT32 i; - wadfile_t *delwad = wadfiles[num]; - lumpcache_t *lumpcache; - if (num == 0) - return; - CONS_Printf(M_GetText("Removing WAD %s...\n"), wadfiles[num]->filename); - - DEH_UnloadDehackedWad(num); - wadfiles[num] = NULL; - lumpcache = delwad->lumpcache; - numwadfiles--; -#ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - HWR_FreeTextureCache(); - M_AATreeFree(delwad->hwrcache); -#endif - if (*lumpcache) - { - for (i = 0;i < delwad->numlumps;i++) - Z_ChangeTag(lumpcache[i], PU_PURGELEVEL); - } - Z_Free(lumpcache); - fclose(delwad->handle); - Z_Free(delwad->filename); - Z_Free(delwad); - CONS_Printf(M_GetText("Done unloading WAD.\n")); -} -#endif /** Tries to load a series of files. * All files are wads unless they have an extension of ".soc" or ".lua". @@ -914,7 +876,7 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons) G_SetGameModified(true, false); //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); - rc = W_InitFile(*filenames, 0, 0, false); + rc = W_InitFile(*filenames, false); if (rc == INT16_MAX) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); overallrc &= (rc != INT16_MAX) ? 1 : 0; @@ -1724,7 +1686,7 @@ void *W_CacheLumpName(const char *name, INT32 tag) // Software-only compile cache the data without conversion #ifdef HWRENDER -static inline void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) +FUNCINLINE static ATTRINLINE void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) { GLPatch_t *grPatch; diff --git a/src/w_wad.h b/src/w_wad.h index 4b083ece6..84ce9775e 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -136,10 +136,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors); // // if local is true, it wouldn't check if file adds complex things, therefore // allowing to still join server without the "you have wrong addons loaded" error -UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, boolean local); -#ifdef DELFILE -void W_UnloadWadFile(UINT16 num); -#endif +UINT16 W_InitFile(const char *filename, boolean local); // W_InitMultipleFiles returns 1 if all is okay, 0 otherwise, // so that it stops with a message if a file was not found, but not if all is okay. diff --git a/src/win32/Srb2win.ico b/src/win32/Srb2win.ico index 4e3f81336..87bd2766e 100644 Binary files a/src/win32/Srb2win.ico and b/src/win32/Srb2win.ico differ diff --git a/src/y_inter.c b/src/y_inter.c index ba5f89785..611cd5336 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -125,11 +125,8 @@ static INT32 foundAnimVoteWideFrames = 0; intertype_t intertype = int_none; - -#ifdef HAVE_BLUA static huddrawlist_h luahuddrawlist_intermission = NULL; static huddrawlist_h luahuddrawlist_vote = NULL; -#endif static void Y_FollowIntermission(void); static void Y_UnloadData(void); @@ -337,20 +334,17 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) // Y_AnimatedVoteScreenCheck // // Check if the lumps exist (checking for VEXTR(N|W)xx for race and VEXTRB(N|W)xx for battle) -void Y_AnimatedVoteScreenCheck(void) +static void Y_AnimatedVoteScreenCheck(void) { char tmpPrefix[] = "INTS"; boolean stopSearching = false; if (luaVoteScreen) - { strncpy(tmpPrefix, luaVoteScreen, 4); - } else { - if(G_BattleGametype()) { + if(G_BattleGametype()) strcpy(tmpPrefix, "BTLS"); - } } strncpy(animPrefix, tmpPrefix, 4); @@ -363,20 +357,22 @@ void Y_AnimatedVoteScreenCheck(void) currentAnimFrame = 0; INT32 i = 1; - while(!stopSearching){ + while(!stopSearching) + { boolean normalLumpExists = W_LumpExists(va("%sC%d", tmpPrefix, i)); boolean wideLumpExists = W_LumpExists(va("%sW%d", tmpPrefix, i)); - if(normalLumpExists || wideLumpExists){ - if(normalLumpExists){ + if (normalLumpExists || wideLumpExists) + { + if (normalLumpExists) foundAnimVoteFrames++; - } - if(wideLumpExists){ + + if (wideLumpExists) foundAnimVoteWideFrames++; - } - } else { // If we don't find at least frame 1 (e.g VEXTRN1), let's just stop looking - stopSearching = true; } + else // If we don't find at least frame 1 (e.g VEXTRN1), let's just stop looking + stopSearching = true; + i++; } } @@ -539,22 +535,21 @@ void Y_IntermissionDrawer(void) { UINT8 *colormap = R_GetTranslationColormap(*data.match.character[i], *data.match.color[i], GTC_CACHE); // i fucking hate this i fucking hate this i hate this so much - if (!players[data.match.num[i]].skinlocal) { - if (!players[data.match.num[i]].localskin) - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x+16, y-4, 0, facewantprefix[*data.match.character[i]], colormap); - else - V_DrawMappedPatch(x+16, y-4, 0, facerankprefix[*data.match.character[i]], colormap); - else - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x+16, y-4, 0, facewantprefix[players[data.match.num[i]].localskin - 1], colormap); - else - V_DrawMappedPatch(x+16, y-4, 0, facerankprefix[players[data.match.num[i]].localskin - 1], colormap); - } else { + if (!players[data.match.num[i]].skinlocal) + { + int skinIndex = players[data.match.num[i]].localskin ? players[data.match.num[i]].localskin - 1 : *data.match.character[i]; + if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x+16, y-4, 0, localfacewantprefix[players[data.match.num[i]].localskin - 1], colormap); + V_DrawSmallMappedPatch(x + 16, y - 4, 0, facewantprefix[skinIndex], colormap); else - V_DrawMappedPatch(x+16, y-4, 0, localfacerankprefix[players[data.match.num[i]].localskin - 1], colormap); + V_DrawMappedPatch(x + 16, y - 4, 0, facerankprefix[skinIndex], colormap); + } + else + { + if (cv_highresportrait.value) + V_DrawSmallMappedPatch(x + 16, y - 4, 0, localfacewantprefix[players[data.match.num[i]].localskin - 1], colormap); + else + V_DrawMappedPatch(x + 16, y - 4, 0, localfacerankprefix[players[data.match.num[i]].localskin - 1], colormap); } } @@ -675,14 +670,12 @@ dotimer: if (cv_scrambleonchange.value && cv_teamscramble.value && (intertic/TICRATE % 2 == 0)) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, hilicol, M_GetText("Teams will be scrambled next round!")); -#ifdef HAVE_BLUA if (renderisnewtic) { LUA_HUD_ClearDrawList(luahuddrawlist_intermission); LUAh_IntermissionHUD(luahuddrawlist_intermission); } LUA_HUD_DrawList(luahuddrawlist_intermission); -#endif } // @@ -710,22 +703,10 @@ void Y_Ticker(void) if (paused || P_AutoPause()) return; -#ifdef HAVE_BLUA LUAh_IntermissionThinker(); -#endif intertic++; - // Team scramble code for team match and CTF. - // Don't do this if we're going to automatically scramble teams next round. - /*if (G_GametypeHasTeams() && cv_teamscramble.value && !cv_scrambleonchange.value && server) - { - // If we run out of time in intermission, the beauty is that - // the P_Ticker() team scramble code will pick it up. - if ((intertic % (TICRATE/7)) == 0) - P_DoTeamscrambling(); - }*/ - // multiplayer uses timer (based on cv_inttime) if (timer) { @@ -944,11 +925,6 @@ void Y_StartIntermission(void) mapvisited[gamemap-1] |= MV_BEATEN; if (ALL7EMERALDS(emeralds)) mapvisited[gamemap-1] |= MV_ALLEMERALDS; - /*if (ultimatemode) - mapvisited[gamemap-1] |= MV_ULTIMATE; - if (data.coop.gotperfbonus) - mapvisited[gamemap-1] |= MV_PERFECT;*/ - if (modeattacking == ATTACKING_RECORD) Y_UpdateRecordReplays(); } @@ -970,10 +946,8 @@ void Y_StartIntermission(void) usebuffer = true; } -#ifdef HAVE_BLUA LUA_HUD_DestroyDrawList(luahuddrawlist_intermission); luahuddrawlist_intermission = LUA_HUD_CreateDrawList(); -#endif } // ====== @@ -1019,34 +993,6 @@ static void Y_UnloadData(void) UNLOAD(widebgpatch); UNLOAD(bgtile); UNLOAD(interpic); - - /*switch (intertype) - { - case int_coop: - // unload the coop and single player patches - UNLOAD(data.coop.ttlnum); - UNLOAD(data.coop.bonuspatches[3]); - UNLOAD(data.coop.bonuspatches[2]); - UNLOAD(data.coop.bonuspatches[1]); - UNLOAD(data.coop.bonuspatches[0]); - UNLOAD(data.coop.ptotal); - break; - case int_spec: - // unload the special stage patches - //UNLOAD(data.spec.cemerald); - //UNLOAD(data.spec.nowsuper); - UNLOAD(data.spec.bonuspatch); - UNLOAD(data.spec.pscore); - UNLOAD(data.spec.pcontinues); - break; - case int_match: - case int_race: - default: - //without this default, - //int_none, int_tag, int_chaos, and int_classicrace - //are not handled - break; - }*/ } // SRB2Kart: Voting! @@ -1055,36 +1001,29 @@ static void Y_UnloadData(void) // // Draw animated patch based on frame counter on vote screen // -void Y_DrawAnimatedVoteScreenPatch(boolean widePatch){ +static inline void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) +{ char tempAnimPrefix[7]; (widePatch) ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix); INT32 tempFoundAnimVoteFrames = (widePatch) ? foundAnimVoteWideFrames : foundAnimVoteFrames; - INT32 flags = V_SNAPTOBOTTOM | V_SNAPTOTOP; // Just in case someone provides LESS widescreen frames than normal frames or vice versa, reset the frame counter to 0 - if(widePatch) { - if(currentAnimFrame > foundAnimVoteWideFrames-1){ + if (widePatch) + { + if (currentAnimFrame > foundAnimVoteWideFrames-1) currentAnimFrame = 0; - } - } else { - if(currentAnimFrame > foundAnimVoteFrames-1){ + } + else + { + if (currentAnimFrame > foundAnimVoteFrames-1) currentAnimFrame = 0; - } } - /*patch_t *currPatch = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame+1), PU_CACHE); - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(currPatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) - (vid.height / vid.dupy) - SHORT(currPatch->height), - V_SNAPTOTOP|V_SNAPTOLEFT, currPatch); - if(votetic % 3 == 0 && !paused){*/ - - { - patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE); - V_DrawScaledPatch(160 - (background->width / 2), (200 - (background->height)), flags, background); - } - if (lastvotetic != votetic && lastvotetic % 2 == 0) { - currentAnimFrame = (currentAnimFrame+1 > tempFoundAnimVoteFrames-1) ? 0 : currentAnimFrame + 1; // jeez no fucking idea how to make this shit not go nuts with interpolation - } + patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE); + V_DrawScaledPatch(160 - (background->width / 2), (200 - (background->height)), V_SNAPTOBOTTOM|V_SNAPTOTOP, background); + + if (lastvotetic != votetic && lastvotetic % 2 == 0) + currentAnimFrame = (currentAnimFrame + 1 > tempFoundAnimVoteFrames - 1) ? 0 : currentAnimFrame + 1; // jeez no fucking idea how to make this shit not go nuts with interpolation } // @@ -1107,42 +1046,30 @@ void Y_VoteDrawer(void) if (!voteclient.loaded) return; - { - static angle_t rubyfloattime = 0; - rubyheight = FINESINE(rubyfloattime>>ANGLETOFINESHIFT); - rubyfloattime += FixedMul(ANGLE_MAX/NEWTICRATE, renderdeltatics); - } + static angle_t rubyfloattime = 0; + rubyheight = FINESINE(rubyfloattime>>ANGLETOFINESHIFT); + rubyfloattime += FixedMul(ANGLE_MAX/NEWTICRATE, renderdeltatics); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - if (widebgpatch && vid.width / vid.dupx > 320) { - - if(foundAnimVoteWideFrames == 0){ + if (widebgpatch && vid.width / vid.dupx > 320) + { + if (foundAnimVoteWideFrames == 0) V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2), (vid.height / vid.dupy) - SHORT(widebgpatch->height), V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch); - } else { - // patch_t *currPatch = W_CachePatchName(va("%s%d", animPrefix, currentAnimFrame+1), PU_CACHE); - // V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(currPatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) - // (vid.height / vid.dupy) - SHORT(currPatch->height), - // V_SNAPTOTOP|V_SNAPTOLEFT, currPatch); - // if(votetic % 4 == 0 && !paused){ - // currentAnimFrame = (currentAnimFrame+1 > foundAnimVoteFrames-1) ? 0 : currentAnimFrame + 1; - // } + else Y_DrawAnimatedVoteScreenPatch(true); - } - } else { - if(foundAnimVoteFrames == 0) { + } + else + { + if (foundAnimVoteFrames == 0) V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) (vid.height / vid.dupy) - SHORT(bgpatch->height), V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch); - } else { + else Y_DrawAnimatedVoteScreenPatch(false); - } - - } - for (i = 0; i < 4; i++) // First, we need to figure out the height of this thing... { @@ -1366,14 +1293,12 @@ void Y_VoteDrawer(void) lastvotetic = votetic; -#ifdef HAVE_BLUA if (renderisnewtic) { LUA_HUD_ClearDrawList(luahuddrawlist_vote); LUAh_VoteHUD(luahuddrawlist_vote); } LUA_HUD_DrawList(luahuddrawlist_vote); -#endif } // @@ -1418,9 +1343,7 @@ void Y_VoteTicker(void) if (paused || P_AutoPause() || !voteclient.loaded) return; -#ifdef HAVE_BLUA LUAh_VoteThinker(); -#endif votetic++; @@ -1706,10 +1629,8 @@ void Y_StartVote(void) voteclient.loaded = true; -#ifdef HAVE_BLUA LUA_HUD_DestroyDrawList(luahuddrawlist_vote); luahuddrawlist_vote = LUA_HUD_CreateDrawList(); -#endif } //