Just breaking stuff, trying to get axfte stuff working.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3916 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2011-10-29 19:01:33 +00:00
parent 18179bcf48
commit b91b32cd38
11 changed files with 138 additions and 120 deletions

View file

@ -263,7 +263,6 @@ ifeq ($(shell echo $(FTE_TARGET)|grep -v win),)
endif endif
IMAGELDFLAGS=$(MINGW_LIBS_DIR)/libpng.a $(MINGW_LIBS_DIR)/libz.a $(MINGW_LIBS_DIR)/libjpeg.a IMAGELDFLAGS=$(MINGW_LIBS_DIR)/libpng.a $(MINGW_LIBS_DIR)/libz.a $(MINGW_LIBS_DIR)/libjpeg.a
RELEASE_CFLAGS=$(CPUOPTIMIZATIONS)
ifeq ($(shell echo $(FTE_TARGET)|grep -v -i _SDL),) ifeq ($(shell echo $(FTE_TARGET)|grep -v -i _SDL),)
RELEASE_CFLAGS+= -D_SDL RELEASE_CFLAGS+= -D_SDL
@ -293,6 +292,7 @@ CLIENT_ONLY_CFLAGS=-DCLIENTONLY
SERVER_ONLY_CFLAGS=-DSERVERONLY SERVER_ONLY_CFLAGS=-DSERVERONLY
JOINT_CFLAGS= JOINT_CFLAGS=
DEBUG_CFLAGS=-ggdb -g DEBUG_CFLAGS=-ggdb -g
RELEASE_CFLAGS?=-O3 -ffast-math $(CPUOPTIMIZATIONS)
#incase our compiler doesn't support it (mingw) #incase our compiler doesn't support it (mingw)
ifeq ($(shell $(CC) -rdynamic 2>&1 | grep unrecognised),) ifeq ($(shell $(CC) -rdynamic 2>&1 | grep unrecognised),)
@ -444,7 +444,6 @@ SERVER_OBJS = \
sv_nchan.o \ sv_nchan.o \
sv_ents.o \ sv_ents.o \
sv_send.o \ sv_send.o \
sv_phys.o \
sv_user.o \ sv_user.o \
sv_mvd.o \ sv_mvd.o \
sv_ccmds.o \ sv_ccmds.o \
@ -493,6 +492,7 @@ COMMON_OBJS = \
glmod_doom.o \ glmod_doom.o \
q3common.o \ q3common.o \
world.o \ world.o \
sv_phys.o \
sv_move.o \ sv_move.o \
pmove.o \ pmove.o \
pmovetst.o \ pmovetst.o \
@ -667,7 +667,7 @@ ifeq ($(shell echo $(FTE_TARGET)|grep -E -v "win(32|64)$$"),)
NPFTECL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_npfte.o sys_axfte.o sys_plugfte.o $(LTO_END) npplug.o ../../ftequake/npapi.def $(LTO_START) NPFTECL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) fs_win32.o gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_npfte.o sys_axfte.o sys_plugfte.o $(LTO_END) npplug.o ../../ftequake/npapi.def $(LTO_START)
NPFTE_DLL_NAME=../npfte$(BITS).dll NPFTE_DLL_NAME=../npfte$(BITS).dll
NPFTECL_DLL_NAME=../npftecl$(BITS).dll NPFTECL_DLL_NAME=../npftecl$(BITS).dll
NPFTE_LDFLAGS=--enable-stdcall-fixup $(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 -shared NPFTE_LDFLAGS=-Wl,--enable-stdcall-fixup $(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lws2_32 -lwinmm -lgdi32 -lole32 -loleaut32 -luuid -lstdc++ -shared
NPFTE_CFLAGS=$(NPFTECFLAGS) $(GLCFLAGS) $(W32_CFLAGS) $(DX7SDK) -DMULTITHREAD NPFTE_CFLAGS=$(NPFTECFLAGS) $(GLCFLAGS) $(W32_CFLAGS) $(DX7SDK) -DMULTITHREAD
NPFTEB_DIR=npfte_mgw$(BITS) NPFTEB_DIR=npfte_mgw$(BITS)
NPFTECL_DIR=npqtvcl_mgw$(BITS) NPFTECL_DIR=npqtvcl_mgw$(BITS)

View file

@ -442,7 +442,7 @@ const char *presetexec[] =
"r_particlesystem classic;" "r_particlesystem classic;"
#else #else
"r_particlesystem script;" "r_particlesystem script;"
"r_particledesc highfps;" "r_particledesc classic;"
#endif #endif
"r_drawflat 0;" "r_drawflat 0;"
"r_nolerp 0;" "r_nolerp 0;"

View file

@ -183,7 +183,29 @@ typedef struct texid_s texid_tf;
#define TEXASSIGNF(d,s) memcpy(&d,&s,sizeof(d)) #define TEXASSIGNF(d,s) memcpy(&d,&s,sizeof(d))
#define TEXVALID(t) 1 #define TEXVALID(t) 1
#endif #endif
typedef enum uploadfmt uploadfmt_t; typedef enum uploadfmt
{
TF_INVALID,
TF_RGBA32, /*rgba byte order*/
TF_BGRA32, /*bgra byte order*/
TF_RGBX32, /*rgb byte order, with extra wasted byte after blue*/
TF_RGB24, /*bgr byte order, no alpha channel nor pad, and top down*/
TF_BGR24_FLIP, /*bgr byte order, no alpha channel nor pad, and bottom up*/
TF_SOLID8, /*8bit quake-palette image*/
TF_TRANS8, /*8bit quake-palette image, index 255=transparent*/
TF_TRANS8_FULLBRIGHT, /*fullbright 8 - fullbright texels have alpha 255, everything else 0*/
TF_HEIGHT8, /*image data is greyscale, convert to a normalmap and load that, uploaded alpha contains the original heights*/
TF_HEIGHT8PAL, /*source data is palette values rather than actual heights, generate a fallback heightmap*/
TF_H2_T7G1, /*8bit data, odd indexes give greyscale transparence*/
TF_H2_TRANS8_0, /*8bit data, 0 is transparent, not 255*/
TF_H2_T4A4, /*8bit data, weird packing*/
/*anything below requires a palette*/
TF_PALETTES,
TF_8PAL24,
TF_8PAL32
} uploadfmt_t;
//not all modes accept meshes - STENCIL(intentional) and DEPTHONLY(not implemented) //not all modes accept meshes - STENCIL(intentional) and DEPTHONLY(not implemented)
typedef enum backendmode_e typedef enum backendmode_e
{ {

View file

@ -276,29 +276,6 @@ enum imageflags
IF_SUBDIRONLY = 1<<31 IF_SUBDIRONLY = 1<<31
}; };
enum uploadfmt
{
TF_INVALID,
TF_RGBA32, /*rgba byte order*/
TF_BGRA32, /*bgra byte order*/
TF_RGBX32, /*rgb byte order, with extra wasted byte after blue*/
TF_RGB24, /*bgr byte order, no alpha channel nor pad, and top down*/
TF_BGR24_FLIP, /*bgr byte order, no alpha channel nor pad, and bottom up*/
TF_SOLID8, /*8bit quake-palette image*/
TF_TRANS8, /*8bit quake-palette image, index 255=transparent*/
TF_TRANS8_FULLBRIGHT, /*fullbright 8 - fullbright texels have alpha 255, everything else 0*/
TF_HEIGHT8, /*image data is greyscale, convert to a normalmap and load that, uploaded alpha contains the original heights*/
TF_HEIGHT8PAL, /*source data is palette values rather than actual heights, generate a fallback heightmap*/
TF_H2_T7G1, /*8bit data, odd indexes give greyscale transparence*/
TF_H2_TRANS8_0, /*8bit data, 0 is transparent, not 255*/
TF_H2_T4A4, /*8bit data, weird packing*/
/*anything below requires a palette*/
TF_PALETTES,
TF_8PAL24,
TF_8PAL32
};
#define R_LoadTexture8(id,w,h,d,f,t) R_LoadTexture(id,w,h,t?TF_TRANS8:TF_SOLID8,d,f) #define R_LoadTexture8(id,w,h,d,f,t) R_LoadTexture(id,w,h,t?TF_TRANS8:TF_SOLID8,d,f)
#define R_LoadTexture32(id,w,h,d,f) R_LoadTexture(id,w,h,TF_RGBA32,d,f) #define R_LoadTexture32(id,w,h,d,f) R_LoadTexture(id,w,h,TF_RGBA32,d,f)
#define R_LoadTextureFB(id,w,h,d,f) R_LoadTexture(id,w,h,TF_TRANS8_FULLBRIGHT,d,f) #define R_LoadTextureFB(id,w,h,d,f) R_LoadTexture(id,w,h,TF_TRANS8_FULLBRIGHT,d,f)

View file

@ -3,17 +3,39 @@
#ifdef _WIN32 #ifdef _WIN32
#include "sys_plugfte.h" #include "sys_plugfte.h"
#include <windows.h>
#include <objsafe.h> /*IObjectSafety*/ #include <objsafe.h> /*IObjectSafety*/
#include <mshtmdid.h> /*DISPID_SECURITYCTX*/ #include <mshtmdid.h> /*DISPID_SECURITYCTX*/
#include <olectl.h> /*common dispid values*/ #include <olectl.h> /*common dispid values*/
#ifndef DISPID_READYSTATE
/*my oldctl.h is too old*/
#define DISPID_READYSTATE -525
#endif
#ifndef __IOleInPlaceObjectWindowless_INTERFACE_DEFINED__
/*mshtmdid.h didn't declare this, so fall back*/
#define IID_IOleInPlaceObjectWindowless IID_IOleInPlaceObject
#define IOleInPlaceObjectWindowless IOleInPlaceObject
#endif
#ifndef __IOleInPlaceSiteWindowless_INTERFACE_DEFINED__
#define IOleInPlaceSiteWindowless IOleInPlaceSite
#define IID_IOleInPlaceSiteWindowless IID_IOleInPlaceSite
#endif
const GUID axfte_iid = {0x7d676c9f, 0xfb84, 0x40b6, {0xb3, 0xff, 0xe1, 0x08, 0x31, 0x55, 0x7e, 0xeb}}; const GUID axfte_iid = {0x7d676c9f, 0xfb84, 0x40b6, {0xb3, 0xff, 0xe1, 0x08, 0x31, 0x55, 0x7e, 0xeb}};
#define axfte_iid_str "7d676c9f-fb84-40b6-b3ff-e10831557eeb" #define axfte_iid_str "7d676c9f-fb84-40b6-b3ff-e10831557eeb"
extern "C" extern HINSTANCE global_hInstance; extern "C"
{
extern HINSTANCE global_hInstance;
}
#ifdef _MSC_VER
#pragma warning(disable:4584) /*shush now*/ #pragma warning(disable:4584) /*shush now*/
class axfte : public IUnknown, public IDispatch, public IClassFactory, public IObjectSafety, #endif
class axfte : public IDispatch, public IClassFactory, public IObjectSafety,
public IOleObject, public IOleInPlaceObjectWindowless, public IViewObject, public IPersistPropertyBag2 public IOleObject, public IOleInPlaceObjectWindowless, public IViewObject, public IPersistPropertyBag2
{ {
private: private:
@ -42,7 +64,7 @@ public:
} }
static void statuschanged(void *arg) static void statuschanged(void *arg)
{ {
axfte *fte = (axfte*)arg; //axfte *fte = (axfte*)arg;
InvalidateRect(NULL, NULL, FALSE); InvalidateRect(NULL, NULL, FALSE);
} }
@ -52,7 +74,7 @@ public:
*ppvObject = NULL; *ppvObject = NULL;
if (riid == IID_IUnknown) if (riid == IID_IUnknown)
{ {
*ppvObject = (IUnknown*)this; *ppvObject = (IUnknown*)(IDispatch*)this;
((LPUNKNOWN)*ppvObject)->AddRef(); ((LPUNKNOWN)*ppvObject)->AddRef();
return S_OK; return S_OK;
} }
@ -165,7 +187,7 @@ public:
{ {
char tmp[1024]; char tmp[1024];
HRESULT ret = S_OK; HRESULT ret = S_OK;
int i; UINT i;
int prop; int prop;
for (i = 0; i < cNames; i++) for (i = 0; i < cNames; i++)
{ {
@ -236,7 +258,7 @@ public:
else else
{ {
char tmp[1024]; char tmp[1024];
sprintf(tmp, "DISPATCH_PROPERTYGET dispIdMember=%i", dispIdMember); sprintf(tmp, "DISPATCH_PROPERTYGET dispIdMember=%i", (unsigned int)dispIdMember);
OutputDebugStringA(tmp); OutputDebugStringA(tmp);
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
} }
@ -270,7 +292,7 @@ public:
else else
{ {
char tmp[1024]; char tmp[1024];
sprintf(tmp, "DISPATCH_PROPERTYPUT dispIdMember=%i", dispIdMember); sprintf(tmp, "DISPATCH_PROPERTYPUT dispIdMember=%i", (unsigned int)dispIdMember);
OutputDebugStringA(tmp); OutputDebugStringA(tmp);
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
} }
@ -278,7 +300,7 @@ public:
else if (wFlags & DISPATCH_PROPERTYPUTREF) else if (wFlags & DISPATCH_PROPERTYPUTREF)
{ {
char tmp[1024]; char tmp[1024];
sprintf(tmp, "DISPATCH_PROPERTYPUTREF dispIdMember=%i", dispIdMember); sprintf(tmp, "DISPATCH_PROPERTYPUTREF dispIdMember=%i", (unsigned int)dispIdMember);
OutputDebugStringA(tmp); OutputDebugStringA(tmp);
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
} }
@ -478,7 +500,11 @@ public:
phwnd = frameinfo.hwndFrame; phwnd = frameinfo.hwndFrame;
funcs->ChangeWindow(plug, frameinfo.hwndFrame, lprcPosRect->left, lprcPosRect->top, lprcPosRect->right - lprcPosRect->left, lprcPosRect->bottom - lprcPosRect->top); funcs->ChangeWindow(plug, frameinfo.hwndFrame, lprcPosRect->left, lprcPosRect->top, lprcPosRect->right - lprcPosRect->left, lprcPosRect->bottom - lprcPosRect->top);
#ifndef __IOleInPlaceSiteWindowless_INTERFACE_DEFINED__
oipc->OnInPlaceActivate();
#else
oipc->OnInPlaceActivateEx(NULL, 1); oipc->OnInPlaceActivateEx(NULL, 1);
#endif
oipc->Release(); oipc->Release();
} }
break; break;
@ -682,9 +708,9 @@ public:
{ {
PROPBAG2 prop[] = PROPBAG2 prop[] =
{ {
{PROPBAG2_TYPE_DATA, VT_BSTR, 0, 0, L"splash", NULL}, {PROPBAG2_TYPE_DATA, VT_BSTR, 0, 0, (WCHAR *)L"splash", {0}},
{PROPBAG2_TYPE_DATA, VT_BSTR, 0, 0, L"game", NULL}, {PROPBAG2_TYPE_DATA, VT_BSTR, 0, 0, (WCHAR *)L"game", {0}},
{PROPBAG2_TYPE_DATA, VT_BSTR, 0, 0, L"dataDownload", NULL} {PROPBAG2_TYPE_DATA, VT_BSTR, 0, 0, (WCHAR *)L"dataDownload", {0}}
}; };
VARIANT val[sizeof(prop)/sizeof(prop[0])]; VARIANT val[sizeof(prop)/sizeof(prop[0])];
HRESULT res[sizeof(prop)/sizeof(prop[0])]; HRESULT res[sizeof(prop)/sizeof(prop[0])];
@ -742,8 +768,8 @@ HRESULT WINAPI DllCanUnloadNow(void)
struct struct
{ {
char *key; const char *key;
char *value; const char *value;
} regkeys[] = } regkeys[] =
{ {
{"Software\\Classes\\FTE.FTEPlug\\", "FTEPlug Class"}, {"Software\\Classes\\FTE.FTEPlug\\", "FTEPlug Class"},

View file

@ -3141,8 +3141,6 @@ void COM_Version_f (void)
Con_TPrintf (TL_EXEDATETIME, __DATE__, __TIME__); Con_TPrintf (TL_EXEDATETIME, __DATE__, __TIME__);
#ifdef SVNREVISION #ifdef SVNREVISION
#define STRINGIFY2(arg) #arg
#define STRINGIFY(arg) STRINGIFY2(arg)
Con_Printf("SVN Revision: %s\n",STRINGIFY(SVNREVISION)); Con_Printf("SVN Revision: %s\n",STRINGIFY(SVNREVISION));
#endif #endif
@ -4376,11 +4374,7 @@ char *version_string(void)
#ifdef OFFICIAL_RELEASE #ifdef OFFICIAL_RELEASE
Q_snprintfz(s, sizeof(s), "%s v%i.%02i", DISTRIBUTION, FTE_VER_MAJOR, FTE_VER_MINOR); Q_snprintfz(s, sizeof(s), "%s v%i.%02i", DISTRIBUTION, FTE_VER_MAJOR, FTE_VER_MINOR);
#elif defined(SVNREVISION) #elif defined(SVNREVISION)
#define STRINGIFY2(arg) #arg
#define STRINGIFY(arg) STRINGIFY2(arg)
Q_snprintfz(s, sizeof(s), "%s SVN %s", DISTRIBUTION, STRINGIFY(SVNREVISION)); Q_snprintfz(s, sizeof(s), "%s SVN %s", DISTRIBUTION, STRINGIFY(SVNREVISION));
#undef STRINGIFY
#undef STRINGIFY2
#else #else
Q_snprintfz(s, sizeof(s), "%s build %s", DISTRIBUTION, __DATE__); Q_snprintfz(s, sizeof(s), "%s build %s", DISTRIBUTION, __DATE__);
#endif #endif

View file

@ -56,6 +56,8 @@ void PF_Common_RegisterCvars(void)
Cvar_Register (&pr_tempstringcount, cvargroup_progs); Cvar_Register (&pr_tempstringcount, cvargroup_progs);
Cvar_Register (&pr_tempstringsize, cvargroup_progs); Cvar_Register (&pr_tempstringsize, cvargroup_progs);
Cvar_Register (&dpcompat_stats, cvargroup_progs); Cvar_Register (&dpcompat_stats, cvargroup_progs);
WPhys_Init();
} }
char *Translate(char *message); char *Translate(char *message);

View file

@ -136,6 +136,7 @@ struct world_s
int numareanodes; int numareanodes;
double physicstime; double physicstime;
unsigned int framenum;
int lastcheck; // used by PF_checkclient int lastcheck; // used by PF_checkclient
double lastchecktime; // for monster ai double lastchecktime; // for monster ai

View file

@ -76,7 +76,6 @@ cvar_t pr_droptofloorunits = CVAR("pr_droptofloorunits", "");
cvar_t sv_gameplayfix_honest_tracelines = CVAR("sv_gameplayfix_honest_tracelines", "1"); cvar_t sv_gameplayfix_honest_tracelines = CVAR("sv_gameplayfix_honest_tracelines", "1");
cvar_t sv_gameplayfix_blowupfallenzombies = CVAR("sv_gameplayfix_blowupfallenzombies", "0"); cvar_t sv_gameplayfix_blowupfallenzombies = CVAR("sv_gameplayfix_blowupfallenzombies", "0");
extern cvar_t sv_gameplayfix_noairborncorpse;
cvar_t sv_addon[MAXADDONS]; cvar_t sv_addon[MAXADDONS];
char cvargroup_progs[] = "Progs variables"; char cvargroup_progs[] = "Progs variables";
@ -1162,7 +1161,6 @@ void PR_Init(void)
Cvar_Register (&sv_gameplayfix_honest_tracelines, cvargroup_progs); Cvar_Register (&sv_gameplayfix_honest_tracelines, cvargroup_progs);
Cvar_Register (&sv_gameplayfix_blowupfallenzombies, cvargroup_progs); Cvar_Register (&sv_gameplayfix_blowupfallenzombies, cvargroup_progs);
Cvar_Register (&sv_gameplayfix_noairborncorpse, cvargroup_progs);
#ifdef SQL #ifdef SQL
SQL_Init(); SQL_Init();

View file

@ -3814,18 +3814,8 @@ extern void Log_Init (void);
void SV_InitLocal (void) void SV_InitLocal (void)
{ {
int i, p; int i, p;
extern cvar_t sv_maxvelocity;
extern cvar_t sv_gravity;
extern cvar_t sv_aim;
extern cvar_t sv_stopspeed;
extern cvar_t sv_spectatormaxspeed;
extern cvar_t sv_accelerate;
extern cvar_t sv_airaccelerate;
extern cvar_t sv_wateraccelerate;
extern cvar_t sv_friction;
extern cvar_t sv_waterfriction;
extern cvar_t sv_sound_watersplash, sv_sound_land;
extern cvar_t pr_allowbutton1; extern cvar_t pr_allowbutton1;
extern cvar_t sv_aim;
extern cvar_t pm_bunnyspeedcap; extern cvar_t pm_bunnyspeedcap;
extern cvar_t pm_ktjump; extern cvar_t pm_ktjump;
@ -3833,7 +3823,6 @@ void SV_InitLocal (void)
extern cvar_t pm_airstep; extern cvar_t pm_airstep;
extern cvar_t pm_walljump; extern cvar_t pm_walljump;
extern cvar_t pm_slidyslopes; extern cvar_t pm_slidyslopes;
extern cvar_t pm_stepheight;
SV_InitOperatorCommands (); SV_InitOperatorCommands ();
SV_UserInit (); SV_UserInit ();
@ -3884,19 +3873,6 @@ void SV_InitLocal (void)
Cvar_Register (&sv_pupglow, cvargroup_serverinfo); Cvar_Register (&sv_pupglow, cvargroup_serverinfo);
Cvar_Register (&sv_loadentfiles, cvargroup_servercontrol); Cvar_Register (&sv_loadentfiles, cvargroup_servercontrol);
Cvar_Register (&sv_maxvelocity, cvargroup_serverphysics);
Cvar_Register (&sv_gravity, cvargroup_serverphysics);
Cvar_Register (&sv_stopspeed, cvargroup_serverphysics);
Cvar_Register (&sv_maxspeed, cvargroup_serverphysics);
Cvar_Register (&sv_spectatormaxspeed, cvargroup_serverphysics);
Cvar_Register (&sv_accelerate, cvargroup_serverphysics);
Cvar_Register (&sv_airaccelerate, cvargroup_serverphysics);
Cvar_Register (&sv_wateraccelerate, cvargroup_serverphysics);
Cvar_Register (&sv_friction, cvargroup_serverphysics);
Cvar_Register (&sv_waterfriction, cvargroup_serverphysics);
Cvar_Register (&sv_sound_watersplash, cvargroup_serverphysics);
Cvar_Register (&sv_sound_land, cvargroup_serverphysics);
Cvar_Register (&sv_bigcoords, cvargroup_serverphysics); Cvar_Register (&sv_bigcoords, cvargroup_serverphysics);
Cvar_Register (&pm_bunnyspeedcap, cvargroup_serverphysics); Cvar_Register (&pm_bunnyspeedcap, cvargroup_serverphysics);
@ -3905,7 +3881,6 @@ void SV_InitLocal (void)
Cvar_Register (&pm_slidyslopes, cvargroup_serverphysics); Cvar_Register (&pm_slidyslopes, cvargroup_serverphysics);
Cvar_Register (&pm_airstep, cvargroup_serverphysics); Cvar_Register (&pm_airstep, cvargroup_serverphysics);
Cvar_Register (&pm_walljump, cvargroup_serverphysics); Cvar_Register (&pm_walljump, cvargroup_serverphysics);
Cvar_Register (&pm_stepheight, cvargroup_serverphysics);
Cvar_Register (&sv_compatiblehulls, cvargroup_serverphysics); Cvar_Register (&sv_compatiblehulls, cvargroup_serverphysics);

View file

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// sv_phys.c // sv_phys.c
#include "qwsvdef.h" #include "qwsvdef.h"
#ifndef CLIENTONLY #if !defined(CLIENTONLY) || defined(CSQC_DAT)
#include "pr_common.h" #include "pr_common.h"
@ -59,8 +59,11 @@ cvar_t sv_wateraccelerate = SCVAR( "sv_wateraccelerate", "10");
cvar_t sv_friction = SCVAR( "sv_friction", "4"); cvar_t sv_friction = SCVAR( "sv_friction", "4");
cvar_t sv_waterfriction = SCVAR( "sv_waterfriction", "4"); cvar_t sv_waterfriction = SCVAR( "sv_waterfriction", "4");
cvar_t sv_gameplayfix_noairborncorpse = SCVAR( "sv_gameplayfix_noairborncorpse", "0"); cvar_t sv_gameplayfix_noairborncorpse = SCVAR( "sv_gameplayfix_noairborncorpse", "0");
cvar_t sv_gameplayfix_multiplethinks = CVARD( "sv_gameplayfix_multiplethinks", "1", "Enables multiple thinks per entity per frame so small nextthink times are accurate. QuakeWorld mods expect a value of 1.");
cvar_t sv_sound_watersplash = CVAR( "sv_sound_watersplash", "misc/h2ohit1.wav"); cvar_t sv_sound_watersplash = CVAR( "sv_sound_watersplash", "misc/h2ohit1.wav");
cvar_t sv_sound_land = CVAR( "sv_sound_land", "demon/dland2.wav"); cvar_t sv_sound_land = CVAR( "sv_sound_land", "demon/dland2.wav");
cvar_t sv_stepheight = CVARAF("pm_stepheight", "18",
"sv_stepheight", CVAR_SERVERINFO);
cvar_t pm_ktjump = SCVARF("pm_ktjump", "0", CVAR_SERVERINFO); cvar_t pm_ktjump = SCVARF("pm_ktjump", "0", CVAR_SERVERINFO);
cvar_t pm_bunnyspeedcap = SCVARF("pm_bunnyspeedcap", "0", CVAR_SERVERINFO); cvar_t pm_bunnyspeedcap = SCVARF("pm_bunnyspeedcap", "0", CVAR_SERVERINFO);
@ -68,15 +71,31 @@ cvar_t pm_slidefix = SCVARF("pm_slidefix", "0", CVAR_SERVERINFO);
cvar_t pm_slidyslopes = SCVARF("pm_slidyslopes", "0", CVAR_SERVERINFO); cvar_t pm_slidyslopes = SCVARF("pm_slidyslopes", "0", CVAR_SERVERINFO);
cvar_t pm_airstep = SCVARF("pm_airstep", "0", CVAR_SERVERINFO); cvar_t pm_airstep = SCVARF("pm_airstep", "0", CVAR_SERVERINFO);
cvar_t pm_walljump = SCVARF("pm_walljump", "0", CVAR_SERVERINFO); cvar_t pm_walljump = SCVARF("pm_walljump", "0", CVAR_SERVERINFO);
cvar_t pm_stepheight = CVARAF("pm_stepheight", "18",
"sv_stepheight", CVAR_SERVERINFO);
extern cvar_t sv_nomsec; #define cvargroup_serverphysics "server physics variables"
void WPhys_Init(void)
{
Cvar_Register (&sv_maxvelocity, cvargroup_serverphysics);
Cvar_Register (&sv_gravity, cvargroup_serverphysics);
Cvar_Register (&sv_stopspeed, cvargroup_serverphysics);
Cvar_Register (&sv_maxspeed, cvargroup_serverphysics);
Cvar_Register (&sv_spectatormaxspeed, cvargroup_serverphysics);
Cvar_Register (&sv_accelerate, cvargroup_serverphysics);
Cvar_Register (&sv_airaccelerate, cvargroup_serverphysics);
Cvar_Register (&sv_wateraccelerate, cvargroup_serverphysics);
Cvar_Register (&sv_friction, cvargroup_serverphysics);
Cvar_Register (&sv_waterfriction, cvargroup_serverphysics);
Cvar_Register (&sv_sound_watersplash, cvargroup_serverphysics);
Cvar_Register (&sv_sound_land, cvargroup_serverphysics);
Cvar_Register (&sv_stepheight, cvargroup_serverphysics);
Cvar_Register (&sv_gameplayfix_noairborncorpse, cvargroup_serverphysics);
Cvar_Register (&sv_gameplayfix_multiplethinks, cvargroup_serverphysics);
}
#define MOVE_EPSILON 0.01 #define MOVE_EPSILON 0.01
static void SV_Physics_Toss (edict_t *ent); static void WPhys_Physics_Toss (world_t *w, wedict_t *ent);
// warning: SV_CheckAllEnts defined but not used // warning: SV_CheckAllEnts defined but not used
/* /*
@ -155,7 +174,7 @@ qboolean WPhys_RunThink (world_t *w, wedict_t *ent)
{ {
float thinktime; float thinktime;
if (sv_nomsec.ival>=2) //try and imitate nq as closeley as possible if (!sv_gameplayfix_multiplethinks.ival) //try and imitate nq as closeley as possible
{ {
thinktime = ent->v->nextthink; thinktime = ent->v->nextthink;
if (thinktime <= 0 || thinktime > w->physicstime + host_frametime) if (thinktime <= 0 || thinktime > w->physicstime + host_frametime)
@ -166,20 +185,8 @@ qboolean WPhys_RunThink (world_t *w, wedict_t *ent)
// it is possible to start that way // it is possible to start that way
// by a trigger with a local time. // by a trigger with a local time.
ent->v->nextthink = 0; ent->v->nextthink = 0;
#if 1
*w->g.time = thinktime; *w->g.time = thinktime;
w->Event_Think(w, ent); w->Event_Think(w, ent);
#else
pr_global_struct->time = thinktime;
pr_global_struct->self = EDICT_TO_PROG(w->progs, ent);
pr_global_struct->other = EDICT_TO_PROG(w->progs, w->edicts);
#ifdef VM_Q1
if (svs.gametype == GT_Q1QVM)
Q1QVM_Think();
else
#endif
PR_ExecuteProgram (svprogfuncs, ent->v->think);
#endif
return !ent->isfree; return !ent->isfree;
} }
@ -197,20 +204,8 @@ qboolean WPhys_RunThink (world_t *w, wedict_t *ent)
// by a trigger with a local time. // by a trigger with a local time.
ent->v->nextthink = 0; ent->v->nextthink = 0;
#if 1
*w->g.time = thinktime; *w->g.time = thinktime;
w->Event_Think(w, ent); w->Event_Think(w, ent);
#else
pr_global_struct->time = thinktime;
pr_global_struct->self = EDICT_TO_PROG(w->progs, ent);
pr_global_struct->other = EDICT_TO_PROG(w->progs, w->edicts);
#ifdef VM_Q1
if (svs.gametype == GT_Q1QVM)
Q1QVM_Think();
else
#endif
PR_ExecuteProgram (svprogfuncs, ent->v->think);
#endif
if (ent->isfree) if (ent->isfree)
return false; return false;
@ -333,12 +328,12 @@ static int WPhys_FlyMove (world_t *w, wedict_t *ent, float time, trace_t *steptr
break; // moved the entire distance break; // moved the entire distance
if (!trace.ent) if (!trace.ent)
SV_Error ("SV_FlyMove: !trace.ent"); Host_Error ("SV_FlyMove: !trace.ent");
if (trace.plane.normal[2] > 0.7) if (trace.plane.normal[2] > 0.7)
{ {
blocked |= 1; // floor blocked |= 1; // floor
if (((edict_t *)trace.ent)->v->solid == SOLID_BSP) if (((wedict_t *)trace.ent)->v->solid == SOLID_BSP)
{ {
ent->v->flags = (int)ent->v->flags | FL_ONGROUND; ent->v->flags = (int)ent->v->flags | FL_ONGROUND;
ent->v->groundentity = EDICT_TO_PROG(w->progs, trace.ent); ent->v->groundentity = EDICT_TO_PROG(w->progs, trace.ent);
@ -451,7 +446,12 @@ SV_AddGravity
*/ */
static void WPhys_AddGravity (wedict_t *ent, float scale) static void WPhys_AddGravity (wedict_t *ent, float scale)
{ {
if (!scale && progstype != PROG_QW) if (!scale
#ifndef CLIENTONLY
#pragma warningmsg("This doesn't do csqc properly")
&& progstype != PROG_QW
#endif
)
scale = 1; scale = 1;
ent->v->velocity[2] -= scale * sv_gravity.value/*movevars.gravity*/ * host_frametime; ent->v->velocity[2] -= scale * sv_gravity.value/*movevars.gravity*/ * host_frametime;
} }
@ -1075,6 +1075,7 @@ static void WPhys_Physics_Toss (world_t *w, wedict_t *ent)
float backoff; float backoff;
vec3_t temporg; vec3_t temporg;
int fl;
WPhys_CheckVelocity (w, ent); WPhys_CheckVelocity (w, ent);
@ -1116,7 +1117,14 @@ static void WPhys_Physics_Toss (world_t *w, wedict_t *ent)
VectorCopy(ent->v->origin, temporg); VectorCopy(ent->v->origin, temporg);
VectorCopy(temporg, ent->v->origin); VectorCopy(temporg, ent->v->origin);
trace = WPhys_PushEntity (w, ent, move, (sv_antilag.ival==2)?MOVE_LAGGED:0); fl = 0;
#ifndef CLIENTONLY
/*doesn't affect csqc, as it has no lagged ents registered anywhere*/
if (sv_antilag.ival==2)
fl |= MOVE_LAGGED;
#endif
trace = WPhys_PushEntity (w, ent, move, fl);
if (trace.allsolid) if (trace.allsolid)
trace.fraction = 0; trace.fraction = 0;
@ -1224,6 +1232,7 @@ static void WPhys_Physics_Step (world_t *w, wedict_t *ent)
//============================================================================ //============================================================================
#ifndef CLIENTONLY
void SV_ProgStartFrame (void) void SV_ProgStartFrame (void)
{ {
@ -1238,7 +1247,7 @@ void SV_ProgStartFrame (void)
#endif #endif
PR_ExecuteProgram (svprogfuncs, pr_global_struct->StartFrame); PR_ExecuteProgram (svprogfuncs, pr_global_struct->StartFrame);
} }
#endif
@ -1771,10 +1780,10 @@ static void WPhys_MoveChain(world_t *w, wedict_t *ent, wedict_t *movechain, floa
if (movechain->xv->chainmoved && callfunc) if (movechain->xv->chainmoved && callfunc)
{ {
pr_global_struct->self = EDICT_TO_PROG(w->progs, movechain); *w->g.self = EDICT_TO_PROG(w->progs, movechain);
pr_global_struct->other = EDICT_TO_PROG(w->progs, ent); *w->g.other = EDICT_TO_PROG(w->progs, ent);
#ifdef VM_Q1 #ifdef VM_Q1
if (svs.gametype == GT_Q1QVM) if (svs.gametype == GT_Q1QVM && w == &sv.world)
Q1QVM_ChainMoved(); Q1QVM_ChainMoved();
else else
#endif #endif
@ -1794,9 +1803,10 @@ SV_RunEntity
void WPhys_RunEntity (world_t *w, wedict_t *ent) void WPhys_RunEntity (world_t *w, wedict_t *ent)
{ {
wedict_t *movechain; wedict_t *movechain;
edict_t *svent = (edict_t*)ent;
vec3_t initial_origin = {0},initial_angle = {0}; // warning: initial_?[?] may be used uninitialized in this function vec3_t initial_origin = {0},initial_angle = {0}; // warning: initial_?[?] may be used uninitialized in this function
#ifndef CLIENTONLY
edict_t *svent = (edict_t*)ent;
if (ent->entnum > 0 && ent->entnum <= sv.allocated_client_slots && w == &sv.world) if (ent->entnum > 0 && ent->entnum <= sv.allocated_client_slots && w == &sv.world)
{ //a client woo. { //a client woo.
qboolean readyforjump = false; qboolean readyforjump = false;
@ -1837,11 +1847,14 @@ void WPhys_RunEntity (world_t *w, wedict_t *ent)
} }
} }
else else
#endif
{ {
if ((unsigned int)ent->v->lastruntime == svs.framenum) if ((unsigned int)ent->v->lastruntime == w->framenum)
return; return;
ent->v->lastruntime = svs.framenum; ent->v->lastruntime = w->framenum;
#ifndef CLIENTONLY
svent = NULL; svent = NULL;
#endif
} }
@ -1890,8 +1903,10 @@ void WPhys_RunEntity (world_t *w, wedict_t *ent)
WPhys_WalkMove (w, ent); WPhys_WalkMove (w, ent);
if (!(ent->entnum > 0 && ent->entnum <= sv.allocated_client_slots)) #ifndef CLIENTONLY
if (!(ent->entnum > 0 && ent->entnum <= sv.allocated_client_slots) && w == &sv.world)
World_LinkEdict (w, ent, true); World_LinkEdict (w, ent, true);
#endif
break; break;
case MOVETYPE_PHYSICS: case MOVETYPE_PHYSICS:
@ -1908,6 +1923,7 @@ void WPhys_RunEntity (world_t *w, wedict_t *ent)
WPhys_MoveChain(w, ent, movechain, initial_origin, initial_angle); WPhys_MoveChain(w, ent, movechain, initial_origin, initial_angle);
} }
#ifndef CLIENTONLY
if (svent) if (svent)
{ {
World_LinkEdict (w, (wedict_t*)svent, true); World_LinkEdict (w, (wedict_t*)svent, true);
@ -1924,6 +1940,7 @@ void WPhys_RunEntity (world_t *w, wedict_t *ent)
PR_ExecuteProgram (w->progs, pr_global_struct->PlayerPostThink); PR_ExecuteProgram (w->progs, pr_global_struct->PlayerPostThink);
} }
} }
#endif
} }
/* /*
@ -1939,7 +1956,7 @@ void WPhys_RunNewmis (world_t *w)
if (!w->g.newmis) //newmis variable is not exported. if (!w->g.newmis) //newmis variable is not exported.
return; return;
if (sv_nomsec.ival >= 2) if (!sv_gameplayfix_multiplethinks.ival)
return; return;
if (!*w->g.newmis) if (!*w->g.newmis)
@ -2004,6 +2021,8 @@ void World_Physics_Frame(world_t *w)
qboolean retouch; qboolean retouch;
wedict_t *ent; wedict_t *ent;
w->framenum++;
i = *w->g.physics_mode; i = *w->g.physics_mode;
if (i == 0) if (i == 0)
{ {
@ -2040,6 +2059,7 @@ void World_Physics_Frame(world_t *w)
if (retouch) if (retouch)
World_LinkEdict (w, ent, true); // force retouch even for stationary World_LinkEdict (w, ent, true); // force retouch even for stationary
#ifndef CLIENTONLY
if (i > 0 && i <= sv.allocated_client_slots && w == &sv.world) if (i > 0 && i <= sv.allocated_client_slots && w == &sv.world)
{ {
if (!svs.clients[i-1].isindependant) if (!svs.clients[i-1].isindependant)
@ -2051,6 +2071,7 @@ void World_Physics_Frame(world_t *w)
// World_LinkEdict(w, (wedict_t*)ent, true); // World_LinkEdict(w, (wedict_t*)ent, true);
continue; // clients are run directly from packets continue; // clients are run directly from packets
} }
#endif
WPhys_RunEntity (w, ent); WPhys_RunEntity (w, ent);
WPhys_RunNewmis (w); WPhys_RunNewmis (w);
@ -2066,6 +2087,7 @@ void World_Physics_Frame(world_t *w)
*w->g.force_retouch-=1; *w->g.force_retouch-=1;
} }
#ifndef CLIENTONLY
/* /*
================ ================
SV_Physics SV_Physics
@ -2246,6 +2268,7 @@ qboolean SV_Physics (void)
} }
return moved; return moved;
} }
#endif
void SV_SetMoveVars(void) void SV_SetMoveVars(void)
{ {
@ -2259,8 +2282,8 @@ void SV_SetMoveVars(void)
movevars.friction = sv_friction.value; movevars.friction = sv_friction.value;
movevars.waterfriction = sv_waterfriction.value; movevars.waterfriction = sv_waterfriction.value;
movevars.entgravity = 1.0; movevars.entgravity = 1.0;
if (*pm_stepheight.string) if (*sv_stepheight.string)
movevars.stepheight = pm_stepheight.value; movevars.stepheight = sv_stepheight.value;
else else
movevars.stepheight = PM_DEFAULTSTEPHEIGHT; movevars.stepheight = PM_DEFAULTSTEPHEIGHT;
} }