summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2007-12-11 11:24:09 +0000
committerAndrey Nazarov <skuller@skuller.net>2007-12-11 11:24:09 +0000
commite6358d790aa66b2c93584185158e7466f3ec166f (patch)
tree89e9715f0a9435f9b917fb6b5677ded4f9fbaebc /source
parent8ef839c6d9b8204322aa04f4229fdf98a5323a46 (diff)
Fixed crash inside CL_PacketEntities on player ents with negative skinnum.
Register all vwep models even with `cl_noskins 1'. Fixed S_RegisterSexedSound to always use sounds corresponding to visible player model.
Diffstat (limited to 'source')
-rw-r--r--source/cl_ents.c24
-rw-r--r--source/cl_local.h2
-rw-r--r--source/cl_parse.c30
-rw-r--r--source/cl_view.c2
-rw-r--r--source/gl_main.c2
-rw-r--r--source/snd_main.c30
-rw-r--r--source/vid_sdl.c25
7 files changed, 64 insertions, 51 deletions
diff --git a/source/cl_ents.c b/source/cl_ents.c
index 07b1fd6..f0cfcf5 100644
--- a/source/cl_ents.c
+++ b/source/cl_ents.c
@@ -263,30 +263,18 @@ static void CL_AddPacketEntities( void ) {
{
ent.skin = cl.baseclientinfo.skin;
ent.model = cl.baseclientinfo.model;
+ ci = &cl.baseclientinfo;
}
//============
//PGM
-#if 0
if (renderfx & RF_USE_DISGUISE)
{
- if(!strncmp((char *)ent.skin, "players/male", 12))
- {
- ent.skin = ref.RegisterSkin ("players/male/disguise.pcx");
- ent.model = ref.RegisterModel ("players/male/tris.md2");
- }
- else if(!strncmp((char *)ent.skin, "players/female", 14))
- {
- ent.skin = ref.RegisterSkin ("players/female/disguise.pcx");
- ent.model = ref.RegisterModel ("players/female/tris.md2");
- }
- else if(!strncmp((char *)ent.skin, "players/cyborg", 14))
- {
- ent.skin = ref.RegisterSkin ("players/cyborg/disguise.pcx");
- ent.model = ref.RegisterModel ("players/cyborg/tris.md2");
- }
+ char buffer[MAX_QPATH];
+
+ Q_concat( buffer, sizeof( buffer ), "players/", ci->model_name, "/disguise.pcx", NULL );
+ ent.skin = ref.RegisterSkin( buffer );
}
-#endif
//PGM
//============
}
@@ -444,7 +432,7 @@ static void CL_AddPacketEntities( void ) {
{ // custom weapon
ci = &cl.clientinfo[s1->skinnum & 0xff];
i = (s1->skinnum >> 8); // 0 is default weapon model
- if (!cl_vwep->integer || i > MAX_CLIENTWEAPONMODELS - 1)
+ if (i < 0 || i > cl.numWeaponModels - 1)
i = 0;
ent.model = ci->weaponmodel[i];
if (!ent.model) {
diff --git a/source/cl_local.h b/source/cl_local.h
index 3acede2..886065b 100644
--- a/source/cl_local.h
+++ b/source/cl_local.h
@@ -54,7 +54,7 @@ typedef struct clientinfo_s {
char cinfo[MAX_QPATH];
qhandle_t skin;
qhandle_t icon;
- char iconname[MAX_QPATH];
+ char model_name[MAX_QPATH];
qhandle_t model;
qhandle_t weaponmodel[MAX_CLIENTWEAPONMODELS];
} clientinfo_t;
diff --git a/source/cl_parse.c b/source/cl_parse.c
index 33f4b62..98639b5 100644
--- a/source/cl_parse.c
+++ b/source/cl_parse.c
@@ -272,7 +272,7 @@ static inline void CL_ParseDeltaEntity( server_frame_t *frame,
entity_state_t *state;
if( frame->numEntities == MAX_PACKET_ENTITIES ) {
- Com_Error( ERR_DROP, "CL_ParseDeltaEntity: MAX_PACKET_ENTITIES exceeded" );
+ Com_Error( ERR_DROP, "%s: MAX_PACKET_ENTITIES exceeded", __func__ );
}
state = &cl.entityStates[cl.numEntityStates & PARSE_ENTITIES_MASK];
@@ -321,11 +321,11 @@ static void CL_ParsePacketEntities( server_frame_t *oldframe,
while( 1 ) {
newnum = MSG_ParseEntityBits( &bits );
if( newnum < 0 || newnum >= MAX_EDICTS ) {
- Com_Error( ERR_DROP, "ParsePacketEntities: bad number %i", newnum );
+ Com_Error( ERR_DROP, "%s: bad number: %d", __func__, newnum );
}
if( msg_read.readcount > msg_read.cursize ) {
- Com_Error( ERR_DROP, "ParsePacketEntities: end of message" );
+ Com_Error( ERR_DROP, "%s: read past end of message", __func__ );
}
if( !newnum ) {
@@ -947,6 +947,7 @@ void CL_LoadClientinfo( clientinfo_t *ci, char *s ) {
char model_filename[MAX_QPATH];
char skin_filename[MAX_QPATH];
char weapon_filename[MAX_QPATH];
+ char icon_filename[MAX_QPATH];
strcpy( ci->cinfo, s );
@@ -963,12 +964,16 @@ noskin:
strcpy( model_filename, "players/male/tris.md2" );
strcpy( weapon_filename, "players/male/weapon.md2" );
strcpy( skin_filename, "players/male/grunt.pcx" );
- strcpy( ci->iconname, "/players/male/grunt_i.pcx" );
+ strcpy( icon_filename, "/players/male/grunt_i.pcx" );
ci->model = ref.RegisterModel( model_filename );
- memset( ci->weaponmodel, 0, sizeof( ci->weaponmodel ) );
- ci->weaponmodel[0] = ref.RegisterModel( weapon_filename );
+ for( i = 0; i < cl.numWeaponModels; i++ ) {
+ Q_concat( weapon_filename, sizeof( weapon_filename ),
+ "players/male/", cl.weaponModels[i], NULL );
+ ci->weaponmodel[i] = ref.RegisterModel( weapon_filename );
+ }
ci->skin = ref.RegisterSkin( skin_filename );
- ci->icon = ref.RegisterPic( ci->iconname );
+ ci->icon = ref.RegisterPic( icon_filename );
+ strcpy( ci->model_name, "male" );
} else {
strcpy( model_name, s );
@@ -1036,20 +1041,20 @@ noskin:
Q_concat( weapon_filename, sizeof( weapon_filename ),
"players/", model_name, "/", cl.weaponModels[i], NULL );
ci->weaponmodel[i] = ref.RegisterModel( weapon_filename );
- if( !ci->weaponmodel[i] && !Q_stricmp( model_name, "cyborg" ) ) {
+ if( !ci->weaponmodel[i] && Q_stricmp( model_name, "male" ) ) {
// try male
Q_concat( weapon_filename, sizeof( weapon_filename ),
"players/male/", cl.weaponModels[i], NULL );
ci->weaponmodel[i] = ref.RegisterModel( weapon_filename );
}
- if( !cl_vwep->integer )
- break; // only one when vwep is off
}
// icon file
- Q_concat( ci->iconname, sizeof( ci->iconname ),
+ Q_concat( icon_filename, sizeof( icon_filename ),
"/players/", model_name, "/", skin_name, "_i.pcx", NULL );
- ci->icon = ref.RegisterPic( ci->iconname );
+ ci->icon = ref.RegisterPic( icon_filename );
+
+ strcpy( ci->model_name, model_name );
}
// must have loaded all data types to be valid
@@ -1058,6 +1063,7 @@ noskin:
ci->icon = 0;
ci->model = 0;
ci->weaponmodel[0] = 0;
+ ci->model_name[0] = 0;
}
}
diff --git a/source/cl_view.c b/source/cl_view.c
index 9ecf1e6..130347b 100644
--- a/source/cl_view.c
+++ b/source/cl_view.c
@@ -288,7 +288,7 @@ void CL_PrepRefresh (void)
}
if (name[0] == '#') {
// special player weapon model
- if (cl.numWeaponModels < MAX_CLIENTWEAPONMODELS) {
+ if (cl.numWeaponModels < MAX_CLIENTWEAPONMODELS && cl_vwep->integer) {
strcpy( cl.weaponModels[cl.numWeaponModels++], name + 1 );
}
} else {
diff --git a/source/gl_main.c b/source/gl_main.c
index a06d72a..e09ff79 100644
--- a/source/gl_main.c
+++ b/source/gl_main.c
@@ -514,6 +514,8 @@ static void GL_EndFrame( void ) {
GL_ShowErrors( __func__ );
video.EndFrame();
+
+// qglFinish();
}
/*
diff --git a/source/snd_main.c b/source/snd_main.c
index 6fe6f5a..4796074 100644
--- a/source/snd_main.c
+++ b/source/snd_main.c
@@ -692,25 +692,20 @@ void S_IssuePlaysound( playsound_t *ps ) {
S_RegisterSexedSound
====================
*/
-static sfx_t *S_RegisterSexedSound( entity_state_t *ent, const char *base ) {
- int n;
- char *p;
- sfx_t *sfx;
+static sfx_t *S_RegisterSexedSound( int entnum, const char *base ) {
+ sfx_t *sfx;
char model[MAX_QPATH];
char buffer[MAX_QPATH];
+ clientinfo_t *ci;
// determine what model the client is using
- model[0] = 0;
- n = CS_PLAYERSKINS + ent->number - 1;
- if( cl.configstrings[n][0] ) {
- p = strchr( cl.configstrings[n], '\\' );
- if( p ) {
- Q_strncpyz( model, p + 1, sizeof( model ) );
- p = strchr( model, '/' );
- if( p )
- *p = 0;
- }
- }
+ if( entnum > 0 && entnum <= MAX_CLIENTS ) {
+ ci = &cl.clientinfo[ entnum - 1 ];
+ } else {
+ ci = &cl.baseclientinfo;
+ }
+ strcpy( model, ci->model_name );
+
// if we can't figure it out, they're male
if( !model[0] )
strcpy( model, "male" );
@@ -760,10 +755,7 @@ void S_StartSound( const vec3_t origin, int entnum, int entchannel, qhandle_t hS
}
if( sfx->name[0] == '*' ) {
- if( entnum < 1 || entnum >= MAX_EDICTS ) {
- Com_Error( ERR_DROP, "S_StartSound: bad entnum: %d", entnum );
- }
- sfx = S_RegisterSexedSound( &cl_entities[entnum].current, sfx->name );
+ sfx = S_RegisterSexedSound( entnum, sfx->name );
}
// make sure the sound is loaded
diff --git a/source/vid_sdl.c b/source/vid_sdl.c
index c4c7063..c11041b 100644
--- a/source/vid_sdl.c
+++ b/source/vid_sdl.c
@@ -30,6 +30,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "key_public.h"
#include "q2pro.xbm"
#include <SDL.h>
+#ifdef __unix__
+#include <GL/glx.h>
+#include <GL/glxext.h>
+#endif
typedef struct {
SDL_Surface *surface;
@@ -38,6 +42,9 @@ typedef struct {
vidFlags_t flags;
qboolean mouseactive; // false when not focus app
qboolean mouseinitialized;
+#ifdef __unix__
+ //PFNGLXGETVIDEOSYNCSGIPROC glXGetVideoSyncSGI;
+#endif
} sdl_state_t;
static sdl_state_t sdl;
@@ -386,6 +393,7 @@ static qboolean QSDL_InitGL( void ) {
Com_EPrintf( "Couldn't set video mode: %s\n", SDL_GetError() );
goto fail;
}
+// sdl.glXGetVideoSyncSGI = SDL_GL_GetProcAddress( "glXGetVideoSyncSGI" );
CL_AppActivate( qtrue );
return qtrue;
@@ -395,6 +403,23 @@ fail:
return qfalse;
}
+#if 0
+qboolean QSDL_VideoSync( void ) {
+ GLuint count;
+ static GLuint oldcount;
+
+ sdl.glXGetVideoSyncSGI( &count );
+
+ if( count != oldcount ) {
+ oldcount = count;
+ SDL_GL_SwapBuffers();
+ // Com_Printf( "%u ", count );
+ return qtrue;
+ }
+ return qfalse;
+}
+#endif
+
static void QSDL_BeginFrameGL( void ) {
}