Merge branch 'Saturn-Next' into speedostuff
This commit is contained in:
commit
fbc51f00ef
141 files changed
+4201
-12897
No files matched your search
+31
-2
@@ -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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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.
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 257 KiB After Width: | Height: | Size: 5.2 KiB |
@@ -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
|
||||
)
|
||||
|
||||
|
||||
+5
-5
@@ -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"
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -10,8 +10,6 @@ WFLAGS+=-Wno-logical-op
|
||||
endif
|
||||
endif
|
||||
|
||||
OPTS+=-DHAVE_BLUA
|
||||
|
||||
OBJS:=$(OBJS) \
|
||||
$(OBJDIR)/lapi.o \
|
||||
$(OBJDIR)/lbaselib.o \
|
||||
|
||||
+1
-1
@@ -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 */
|
||||
|
||||
+2
-17
@@ -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();
|
||||
|
||||
|
||||
+14
-17
@@ -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;
|
||||
|
||||
+28
-41
@@ -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();
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+16
-10
@@ -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;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
+6
-3
@@ -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;
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+68
-110
@@ -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.
|
||||
*
|
||||
|
||||
+20
-2
@@ -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;
|
||||
|
||||
|
||||
+76
-59
@@ -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 *
|
||||
|
||||
@@ -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);
|
||||
|
||||
+11
-677
@@ -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);
|
||||
}
|
||||
// <Callum> 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; }
|
||||
static fixed_t op_rshift(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<<i);
|
||||
}
|
||||
|
||||
// Not found error
|
||||
const_warning("mobj flag",word);
|
||||
free(word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("MF2_", word, 4)) {
|
||||
char *p = word+4;
|
||||
for (i = 0; MOBJFLAG2_LIST[i]; i++)
|
||||
if (fastcmp(p, MOBJFLAG2_LIST[i])) {
|
||||
free(word);
|
||||
return (1<<i);
|
||||
}
|
||||
|
||||
// Not found error
|
||||
const_warning("mobj flag2",word);
|
||||
free(word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("MFE_", word, 4)) {
|
||||
char *p = word+4;
|
||||
for (i = 0; MOBJEFLAG_LIST[i]; i++)
|
||||
if (fastcmp(p, MOBJEFLAG_LIST[i])) {
|
||||
free(word);
|
||||
return (1<<i);
|
||||
}
|
||||
|
||||
// Not found error
|
||||
const_warning("mobj eflag",word);
|
||||
free(word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("PF_", word, 3)) {
|
||||
char *p = word+3;
|
||||
for (i = 0; PLAYERFLAG_LIST[i]; i++)
|
||||
if (fastcmp(p, PLAYERFLAG_LIST[i])) {
|
||||
free(word);
|
||||
return (1<<i);
|
||||
}
|
||||
if (fastcmp(p, "FULLSTASIS"))
|
||||
return PF_FULLSTASIS;
|
||||
|
||||
// Not found error
|
||||
const_warning("player flag",word);
|
||||
free(word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("S_",word,2)) {
|
||||
r = get_state(word);
|
||||
free(word);
|
||||
return r;
|
||||
}
|
||||
else if (fastncmp("MT_",word,3)) {
|
||||
r = get_mobjtype(word);
|
||||
free(word);
|
||||
return r;
|
||||
}
|
||||
else if (fastncmp("SPR_",word,4)) {
|
||||
r = get_sprite(word);
|
||||
free(word);
|
||||
return r;
|
||||
}
|
||||
else if (fastncmp("SFX_",word,4) || fastncmp("DS",word,2)) {
|
||||
r = get_sfx(word);
|
||||
free(word);
|
||||
return r;
|
||||
}
|
||||
#ifdef MUSICSLOT_COMPATIBILITY
|
||||
else if (fastncmp("MUS_",word,4) || fastncmp("O_",word,2)) {
|
||||
r = get_mus(word, true);
|
||||
free(word);
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
else if (fastncmp("PW_",word,3)) {
|
||||
r = get_power(word);
|
||||
free(word);
|
||||
return r;
|
||||
}
|
||||
else if (fastncmp("HUD_",word,4)) {
|
||||
r = get_huditem(word);
|
||||
free(word);
|
||||
return r;
|
||||
}
|
||||
else if (fastncmp("SKINCOLOR_",word,10)) {
|
||||
char *p = word+10;
|
||||
for (i = 0; i < MAXTRANSLATIONS; i++)
|
||||
if (fastcmp(p, COLOR_ENUMS[i])) {
|
||||
free(word);
|
||||
return i;
|
||||
}
|
||||
const_warning("color",word);
|
||||
free(word);
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; INT_CONST[i].n; i++)
|
||||
if (fastcmp(word,INT_CONST[i].n)) {
|
||||
free(word);
|
||||
return INT_CONST[i].v;
|
||||
}
|
||||
|
||||
// Not found error.
|
||||
const_warning("constant",word);
|
||||
free(word);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Loops through every constant and operation in word and performs its calculations, returning the final value.
|
||||
fixed_t get_number(const char *word)
|
||||
{
|
||||
#ifdef HAVE_BLUA
|
||||
return LUA_EvalMath(word);
|
||||
#else
|
||||
// DESPERATELY NEEDED: Order of operations support! :x
|
||||
fixed_t i = find_const(&word);
|
||||
INT32 o;
|
||||
while(*word) {
|
||||
o = operation_pad(&word);
|
||||
if (o != -1)
|
||||
i = OPERATIONS[o].v(i,find_const(&word));
|
||||
else
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
|
||||
void DEH_Check(void)
|
||||
@@ -9141,10 +8481,6 @@ void DEH_Check(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
#include "lua_script.h"
|
||||
#include "lua_libs.h"
|
||||
|
||||
// freeslot takes a name (string only!)
|
||||
// and allocates it to the appropriate free slot.
|
||||
// Returns the slot number allocated for it or nil if failed.
|
||||
@@ -10082,6 +9418,4 @@ void LUA_SetActionByName(void *state, const char *actiontocompare)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAVE_BLUA
|
||||
}
|
||||
@@ -27,12 +27,7 @@ typedef enum
|
||||
UNDO_DONE = 0,
|
||||
} undotype_f;
|
||||
|
||||
#ifdef DELFILE
|
||||
void DEH_WriteUndoline(const char *value, const char *data, undotype_f flags);
|
||||
void DEH_UnloadDehackedWad(UINT16 wad);
|
||||
#else // null the undo lines
|
||||
#define DEH_WriteUndoline(a,b,c)
|
||||
#endif
|
||||
|
||||
void DEH_LoadDehackedLump(lumpnum_t lumpnum);
|
||||
void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump);
|
||||
@@ -43,11 +38,9 @@ void DEH_Check(void);
|
||||
|
||||
fixed_t get_number(const char *word);
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
boolean LUA_SetLuaAction(void *state, const char *actiontocompare);
|
||||
const char *LUA_GetActionName(void *action);
|
||||
void LUA_SetActionByName(void *state, const char *actiontocompare);
|
||||
#endif
|
||||
|
||||
extern boolean deh_loaded;
|
||||
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ struct discordInfo_s discordInfo;
|
||||
|
||||
discordRequest_t *discordRequestList = NULL;
|
||||
|
||||
static char self_ip[IP_SIZE];
|
||||
static char self_ip[IP_SIZE+1];
|
||||
|
||||
boolean drpc_init = false;
|
||||
|
||||
|
||||
+3
-27
@@ -127,8 +127,8 @@ extern char logfilename[1024];
|
||||
#else
|
||||
#define VERSION 1 // Game version
|
||||
#define SUBVERSION 6 // more precise version number
|
||||
#define VERSIONSTRING "Saturn v5.1 "
|
||||
#define VERSIONSTRINGW L"Saturn v5.1"
|
||||
#define VERSIONSTRING "Saturn v6 "
|
||||
#define VERSIONSTRINGW L"Saturn v6"
|
||||
// Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates!
|
||||
// And change CMakeLists.txt (not src/, but in root), for CMake users!
|
||||
// AND appveyor.yml, for the build bots!
|
||||
@@ -468,7 +468,7 @@ void M_StartupLocale(void);
|
||||
// M_GetText function that just returns the string.
|
||||
#define M_GetText(x) (x)
|
||||
#endif
|
||||
extern void *(*M_Memcpy)(void* dest, const void* src, size_t n) FUNCNONNULL;
|
||||
void *M_Memcpy(void* dest, const void* src, size_t n);
|
||||
char *va(const char *format, ...) FUNCPRINTF;
|
||||
char *M_GetToken(const char *inputString);
|
||||
char *sizeu1(size_t num);
|
||||
@@ -561,17 +561,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||
/// Undefine to use the new method of Gamma correction see colour cube in v_video.c
|
||||
#define BACKWARDSCOMPATCORRECTION
|
||||
|
||||
/// Kalaron/Eternity Engine slope code (SRB2CB ported)
|
||||
#define ESLOPE
|
||||
|
||||
/// Backwards compatibility with SRB2CB's slope linedef types.
|
||||
/// \note A simple shim that prints a warning.
|
||||
#define ESLOPE_TYPESHIM
|
||||
|
||||
/// Delete file while the game is running.
|
||||
/// \note EXTREMELY buggy, tends to crash game.
|
||||
//#define DELFILE
|
||||
|
||||
/// Allows the use of devmode in multiplayer. AKA "fishcake"
|
||||
//#define NETGAME_DEVMODE
|
||||
|
||||
@@ -581,16 +570,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||
/// Dumps the contents of a network save game upon consistency failure for debugging.
|
||||
//#define DUMPCONSISTENCY
|
||||
|
||||
/// Polyobject fake flat code
|
||||
#define POLYOBJECTS_PLANES
|
||||
|
||||
/// See name of player in your crosshair
|
||||
#define SEENAMES
|
||||
|
||||
/// Who put weights on my recycler? ... Inuyasha did.
|
||||
/// \note XMOD port.
|
||||
//#define WEIGHTEDRECYCLER
|
||||
|
||||
/// Allow loading of savegames between different versions of the game.
|
||||
/// \note XMOD port.
|
||||
/// Most modifications should probably enable this.
|
||||
@@ -608,9 +590,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||
#define CLIENT_LOADINGSCREEN
|
||||
#endif
|
||||
|
||||
/// Experimental tweaks to analog mode. (Needs a lot of work before it's ready for primetime.)
|
||||
//#define REDSANALOG
|
||||
|
||||
/// Backwards compatibility with musicslots.
|
||||
/// \note You should leave this enabled unless you're working with a future SRB2 version.
|
||||
#define MUSICSLOT_COMPATIBILITY
|
||||
@@ -630,9 +609,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||
#define ROTANGLES 72 // Needs to be a divisor of 360 (45, 60, 90, 120...)
|
||||
#define ROTANGDIFF (360 / ROTANGLES)
|
||||
|
||||
/// Hardware renderer: OpenGL
|
||||
#define GL_SHADERS
|
||||
|
||||
#if defined (HAVE_CURL) && ! defined (NONET)
|
||||
#define MASTERSERVER
|
||||
#define HOLEPUNCH
|
||||
|
||||
@@ -249,6 +249,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
|
||||
#if (__GNUC__ > 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?) */
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+5
-3
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+11
-33
@@ -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;
|
||||
|
||||
|
||||
+282
-274
@@ -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
|
||||
@@ -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
|
||||
@@ -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++)
|
||||
|
||||
+11
-27
@@ -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;
|
||||
@@ -107,18 +107,14 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
|
||||
count--;
|
||||
|
||||
texel = source[yfrac>>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();
|
||||
}
|
||||
|
||||
|
||||
+13
-17
@@ -68,6 +68,7 @@
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#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];
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
// --------
|
||||
|
||||
+442
-903
File diff suppressed because it is too large.
Load diff
+1
-17
@@ -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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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" \
|
||||
|
||||
@@ -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 <math.h>
|
||||
#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
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -123,6 +123,8 @@ extern GLint maximumAnisotropy;
|
||||
extern INT32 oglflags;
|
||||
extern GLint textureformatGL;
|
||||
|
||||
extern GLfloat projMatrix[16];
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GLF_NOZBUFREAD = 0x01,
|
||||
|
||||
+30
-33
@@ -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<node> \'.", false);
|
||||
free(nodenum);
|
||||
return;
|
||||
}
|
||||
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", 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;
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
+753
-200
File diff suppressed because it is too large.
Load diff
@@ -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__
|
||||
@@ -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
|
||||
|
||||
+1
-4
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
+46
-11
@@ -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
|
||||
+1
-5
@@ -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
|
||||
+22
-15
@@ -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
|
||||
}
|
||||
@@ -32,6 +32,8 @@ enum hud {
|
||||
hud_wanted,
|
||||
hud_speedometer,
|
||||
hud_statdisplay,
|
||||
hud_nametags,
|
||||
hud_driftgauge,
|
||||
hud_freeplay,
|
||||
hud_rankings, // Tab rankings
|
||||
|
||||
|
||||
+160
-5
@@ -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
|
||||
}
|
||||
+1
-4
@@ -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
|
||||
}
|
||||
+1
-5
@@ -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);
|
||||
+3
-4
@@ -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
|
||||
}
|
||||
+1
-4
@@ -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
|
||||
}
|
||||
+1
-4
@@ -13,7 +13,6 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#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
|
||||
}
|
||||
+1
-4
@@ -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
|
||||
}
|
||||
+1
-4
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
+1
-4
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
+1
-5
@@ -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
|
||||
+1
-3
@@ -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);
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
+430
-203
File diff suppressed because it is too large.
Load diff
+15
-8
@@ -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__
|
||||
+3
-421
@@ -19,7 +19,6 @@
|
||||
// (if libpng is compiled with setjmp error handling)
|
||||
#pragma GCC diagnostic ignored "-Wclobbered"
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#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)
|
||||
|
||||
@@ -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
|
||||
|
||||
+186
-550
File diff suppressed because it is too large.
Load diff
+8
-116
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-256
@@ -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))
|
||||
|
||||
+10
-52
@@ -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;
|
||||
|
||||
+81
-711
File diff suppressed because it is too large.
Load diff
Loaded 100 of 141 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user