Can jump through hexen2 windows now, changing h2 classes no longer kills the server. Provided Sys_EnumerateFiles for win32+unix targets, other targets will now spam warnings, as its kinda needed for fs_cache (which is default).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3578 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2010-08-11 23:55:35 +00:00
parent 1f621ac18c
commit 6d8e3b01a9
14 changed files with 867 additions and 73 deletions

View file

@ -1028,6 +1028,7 @@ void CSQC_WorldLoaded(void);
qboolean CSQC_ParseTempEntity(unsigned char firstbyte);
qboolean CSQC_ConsoleCommand(char *cmd);
qboolean CSQC_KeyPress(int key, int unicode, qboolean down);
qboolean CSQC_MouseMove(float xdelta, float ydelta);
int CSQC_StartSound(int entnum, int channel, char *soundname, vec3_t pos, float vol, float attenuation);
void CSQC_ParseEntities(void);
qboolean CSQC_SettingListener(void);

View file

@ -228,11 +228,6 @@ int mouse_x, mouse_y;
void ResetFrameBuffers(void);
#endif
#ifdef RGLQUAKE
extern int glwidth;
extern int glheight;
#endif
void Sys_SendKeyEvents(void)
{
SDL_Event event;
@ -251,10 +246,10 @@ void Sys_SendKeyEvents(void)
case SDL_VIDEORESIZE:
switch(qrenderer)
{
#ifdef RGLQUAKE
#ifdef GLQUAKE
case QR_OPENGL:
glwidth = event.resize.w;
glheight = event.resize.h;
vid.pixelwidth = event.resize.w;
vid.pixelheight = event.resize.h;
break;
#endif
#ifdef SWQUAKE

View file

@ -63,7 +63,6 @@ cvar_t m_threshold_noforce = SCVAR("m_threshold_noforce", "0");
cvar_t cl_keypad = SCVAR("cl_keypad", "0");
qboolean CSQC_MouseMove(float xdelta, float ydelta);
qboolean Key_MouseShouldBeFree(void);
typedef struct {

View file

@ -40,3 +40,6 @@ void IN_Accumulate (void);
extern cvar_t in_xflip;
#endif
/*semi-common, so lets prototype on all*/
void IN_ActivateMouse(void);
void IN_DeactivateMouse(void);

View file

@ -10,6 +10,8 @@
#ifndef WIN32
#include <fcntl.h>
#else
#include <direct.h>
#endif
#ifndef isDedicated
@ -126,10 +128,154 @@ void Sys_Quit (void)
//enumerate the files in a directory (of both gpath and match - match may not contain ..)
//calls the callback for each one until the callback returns 0
//SDL provides no file enumeration facilities.
#if defined(_WIN32)
#include <windows.h>
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, int, void *), void *parm)
{
return 1;
HANDLE r;
WIN32_FIND_DATA fd;
char apath[MAX_OSPATH];
char apath2[MAX_OSPATH];
char file[MAX_OSPATH];
char *s;
int go;
if (!gpath)
return 0;
// strcpy(apath, match);
Q_snprintfz(apath, sizeof(apath), "%s/%s", gpath, match);
for (s = apath+strlen(apath)-1; s> apath; s--)
{
if (*s == '/')
break;
}
*s = '\0';
//this is what we ask windows for.
Q_snprintfz(file, sizeof(file), "%s/*.*", apath);
//we need to make apath contain the path in match but not gpath
Q_strncpyz(apath2, match, sizeof(apath));
match = s+1;
for (s = apath2+strlen(apath2)-1; s> apath2; s--)
{
if (*s == '/')
break;
}
*s = '\0';
if (s != apath2)
strcat(apath2, "/");
r = FindFirstFile(file, &fd);
if (r==(HANDLE)-1)
return 1;
go = true;
do
{
if (*fd.cFileName == '.'); //don't ever find files with a name starting with '.'
else if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //is a directory
{
if (wildcmp(match, fd.cFileName))
{
Q_snprintfz(file, sizeof(file), "%s%s/", apath2, fd.cFileName);
go = func(file, fd.nFileSizeLow, parm);
}
}
else
{
if (wildcmp(match, fd.cFileName))
{
Q_snprintfz(file, sizeof(file), "%s%s", apath2, fd.cFileName);
go = func(file, fd.nFileSizeLow, parm);
}
}
}
while(FindNextFile(r, &fd) && go);
FindClose(r);
return go;
}
#elif defined(linux) || defined(__unix__)
#include <dirent.h>
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, int, void *), void *parm)
{
DIR *dir;
char apath[MAX_OSPATH];
char file[MAX_OSPATH];
char truepath[MAX_OSPATH];
char *s;
struct dirent *ent;
struct stat st;
//printf("path = %s\n", gpath);
//printf("match = %s\n", match);
if (!gpath)
gpath = "";
*apath = '\0';
Q_strncpyz(apath, match, sizeof(apath));
for (s = apath+strlen(apath)-1; s >= apath; s--)
{
if (*s == '/')
{
s[1] = '\0';
match += s - apath+1;
break;
}
}
if (s < apath) //didn't find a '/'
*apath = '\0';
Q_snprintfz(truepath, sizeof(truepath), "%s/%s", gpath, apath);
//printf("truepath = %s\n", truepath);
//printf("gamepath = %s\n", gpath);
//printf("apppath = %s\n", apath);
//printf("match = %s\n", match);
dir = opendir(truepath);
if (!dir)
{
Con_DPrintf("Failed to open dir %s\n", truepath);
return true;
}
do
{
ent = readdir(dir);
if (!ent)
break;
if (*ent->d_name != '.')
{
if (wildcmp(match, ent->d_name))
{
Q_snprintfz(file, sizeof(file), "%s/%s", truepath, ent->d_name);
if (stat(file, &st) == 0)
{
Q_snprintfz(file, sizeof(file), "%s%s%s", apath, ent->d_name, S_ISDIR(st.st_mode)?"/":"");
if (!func(file, st.st_size, parm))
{
closedir(dir);
return false;
}
}
else
printf("Stat failed for \"%s\"\n", file);
}
}
} while(1);
closedir(dir);
return true;
}
#else
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, int, void *), void *parm)
{
Con_Printf("Warning: Sys_EnumerateFiles not implemented\n");
return false;
}
#endif
//blink window if possible (it's not)
void Sys_ServerActivity(void)
@ -177,7 +323,7 @@ void *Sys_GetGameAPI (void *parms)
void *(*GetGameAPI)(void *);
dllfunction_t funcs[] =
{
{(void**)GetGameAPI, "GetGameAPI"},
{(void**)&GetGameAPI, "GetGameAPI"},
{NULL,NULL}
};
@ -249,7 +395,7 @@ int VARGS Sys_DebugLog(char *file, char *fmt, ...)
static char data[1024];
va_start(argptr, fmt);
_vsnprintf(data, sizeof(data)-1, fmt, argptr);
vsnprintf(data, sizeof(data)-1, fmt, argptr);
va_end(argptr);
#if defined(CRAZYDEBUGGING) && CRAZYDEBUGGING > 1

View file

@ -2196,11 +2196,11 @@ qboolean Sys_FindGameData(const char *poshname, const char *gamename, char *base
SDL_SysWMinfo wmInfo;
SDL_GetWMInfo(&wmInfo);
HWND sys_parentwindow = wmInfo.window;
#endif
if (sys_parentwindow)
bi.hwndOwner = sys_parentwindow; //note that this is usually still null
else
#endif
bi.hwndOwner = mainwindow; //note that this is usually still null
bi.pidlRoot = NULL;
bi.pszDisplayName = resultpath;

File diff suppressed because it is too large Load diff

View file

@ -352,6 +352,7 @@ qboolean VID_SetWindowedMode (rendererstate_t *info)
WindowRect.bottom = info->height;
#ifndef _SDL
if (sys_parentwindow)
{
SetWindowLong(sys_parentwindow, GWL_STYLE, GetWindowLong(sys_parentwindow, GWL_STYLE)|WS_OVERLAPPED);
@ -373,6 +374,7 @@ qboolean VID_SetWindowedMode (rendererstate_t *info)
WindowRect.bottom += WindowRect.top;
}
else
#endif
{
WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX;

View file

@ -9,9 +9,6 @@ extern cvar_t vid_hardwaregamma;
extern cvar_t gl_lateswap;
extern int gammaworks;
int glwidth;
int glheight;
#ifdef _WIN32 //half the rest of the code uses windows apis to focus windows. Should be fixed, but it's not too important.
HWND mainwindow;
#endif
@ -67,10 +64,10 @@ Con_Printf("Getting gamma\n");
flags = SDL_RESIZABLE;
vid_isfullscreen = false;
}
sdlsurf = SDL_SetVideoMode(glwidth=info->width, glheight=info->height, info->bpp, flags | SDL_OPENGL);
sdlsurf = SDL_SetVideoMode(vid.pixelwidth=info->width, vid.pixelheight=info->height, info->bpp, flags | SDL_OPENGL);
if (!sdlsurf)
{
Con_Printf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
Con_Printf("Couldn't set GL mode: %s\n", SDL_GetError());
return false;
}
@ -81,7 +78,7 @@ Con_Printf("Getting gamma\n");
GLVID_SetPalette (palette);
GL_Init(SDL_GL_GetProcAddress);
qglViewport (0, 0, glwidth, glheight);
qglViewport (0, 0, vid.pixelwidth, vid.pixelheight);
mouseactive = false;
if (vid_isfullscreen)
@ -104,9 +101,6 @@ void GLVID_DeInit (void)
void GL_BeginRendering (void)
{
vid.pixelwidth = glwidth;
vid.pixelheight = glheight;
// if (!wglMakeCurrent( maindc, baseRC ))
// Sys_Error ("wglMakeCurrent failed");

View file

@ -6909,6 +6909,11 @@ void PRH2_SetPlayerClass(client_t *cl, int classnum, qboolean fromqc)
return; //reject it (it would crash the (standard hexen2) mod)
if (classnum > 5)
return;
/*ignore it if they already have a class, this fixes some h2mp crashes*/
if (cl->playerclass)
return;
if (cl->playerclass != classnum)
{
cl->edict->xv->playerclass = classnum;

View file

@ -787,8 +787,8 @@ typedef struct
#define MOVETYPE_BOUNCE 10
#define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity
#define MOVETYPE_FOLLOW 12 // track movement of aiment
#define MOVETYPE_PUSHPULL 13 // pushable/pullable object
#define MOVETYPE_SWIM 14 // should keep the object in water
#define MOVETYPE_H2PUSHPULL 13 // pushable/pullable object
#define MOVETYPE_H2SWIM 14 // should keep the object in water
#define MOVETYPE_PHYSICS 32
// edict->solid values

View file

@ -1103,7 +1103,7 @@ static void SV_Physics_Toss (edict_t *ent)
if (ent->v->movetype != MOVETYPE_FLY
&& ent->v->movetype != MOVETYPE_FLYMISSILE
&& ent->v->movetype != MOVETYPE_BOUNCEMISSILE
&& ent->v->movetype != MOVETYPE_SWIM)
&& ent->v->movetype != MOVETYPE_H2SWIM)
SV_AddGravity (ent, 1.0);
// move angles
@ -1852,7 +1852,7 @@ void SV_RunEntity (edict_t *ent)
SV_Physics_Noclip (ent);
break;
case MOVETYPE_STEP:
case MOVETYPE_PUSHPULL:
case MOVETYPE_H2PUSHPULL:
SV_Physics_Step (ent);
break;
case MOVETYPE_FOLLOW:
@ -1863,7 +1863,7 @@ void SV_RunEntity (edict_t *ent)
case MOVETYPE_BOUNCEMISSILE:
case MOVETYPE_FLY:
case MOVETYPE_FLYMISSILE:
case MOVETYPE_SWIM:
case MOVETYPE_H2SWIM:
SV_Physics_Toss (ent);
break;
case MOVETYPE_WALK:

View file

@ -1604,8 +1604,8 @@ void SV_Begin_Core(client_t *split)
}
oh = host_client;
host_client = split;
sv_player = host_client->edict;
host_client = split;
sv_player = host_client->edict;
SV_PreRunCmd();
{
usercmd_t cmd;
@ -1619,7 +1619,7 @@ void SV_Begin_Core(client_t *split)
}
SV_PostRunCmd();
host_client = oh;
sv_player = host_client->edict;
sv_player = host_client->edict;
}
}
}
@ -5295,19 +5295,36 @@ if (sv_player->v->health > 0 && before && !after )
continue;
n = pmove.physents[pmove.touchindex[i]].info;
ent = EDICT_NUM(svprogfuncs, n);
if (!ent->v->touch || (playertouch[n/8]&(1<<(n%8))))
if (playertouch[n/8]&(1<<(n%8)))
continue;
pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, ent);
pr_global_struct->other = EDICT_TO_PROG(svprogfuncs, sv_player);
pr_global_struct->time = sv.time;
if (ent->v->touch)
{
pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, ent);
pr_global_struct->other = EDICT_TO_PROG(svprogfuncs, sv_player);
pr_global_struct->time = sv.time;
#ifdef VM_Q1
if (svs.gametype == GT_Q1QVM)
Q1QVM_Touch();
else
if (svs.gametype == GT_Q1QVM)
Q1QVM_Touch();
else
#endif
PR_ExecuteProgram (svprogfuncs, ent->v->touch);
PR_ExecuteProgram (svprogfuncs, ent->v->touch);
}
playertouch[n/8] |= 1 << (n%8);
if (sv_player->v->touch && !ent->isfree)
{
pr_global_struct->other = EDICT_TO_PROG(svprogfuncs, ent);
pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player);
pr_global_struct->time = sv.time;
#ifdef VM_Q1
if (svs.gametype == GT_Q1QVM)
Q1QVM_Touch();
else
#endif
PR_ExecuteProgram (svprogfuncs, sv_player->v->touch);
}
}
}

View file

@ -1696,7 +1696,7 @@ void SVHL_RunEntity (hledict_t *ent)
SVHL_Physics_Noclip (ent);
break;
case MOVETYPE_STEP:
case MOVETYPE_PUSHPULL:
case MOVETYPE_H2PUSHPULL:
SVHL_Physics_Step (ent);
break;
case MOVETYPE_FOLLOW:
@ -1707,7 +1707,7 @@ void SVHL_RunEntity (hledict_t *ent)
case MOVETYPE_BOUNCEMISSILE:
case MOVETYPE_FLY:
case MOVETYPE_FLYMISSILE:
case MOVETYPE_SWIM:
case MOVETYPE_H2SWIM:
SVHL_Physics_Toss (ent);
break;
case MOVETYPE_WALK: