09 Jun 2010

This commit is contained in:
g-cont 2010-06-09 00:00:00 +04:00 committed by Alibek Omarov
parent e31162d22e
commit 2c0feb43c6
15 changed files with 89 additions and 55 deletions

View File

@ -2204,6 +2204,9 @@ IMPLEMENT_SAVERESTORE(CTriggerCamera,CBaseDelay);
void CTriggerCamera::Spawn( void )
{
// force camera to send on client
SetObjectClass( ED_NORMAL );
pev->movetype = MOVETYPE_NOCLIP;
pev->solid = SOLID_NOT; // Remove model & collisions
pev->renderamt = 0; // The engine won't draw this model if this is set to 0 and blending is on

View File

@ -109,6 +109,11 @@ int CHud :: InitMessages( void )
void CHud :: UserCmd_ChangeLevel( void )
{
m_iDrawPlaque = 0; // disable plaque rendering
// reset shake
m_Shake.amplitude = 0;
m_Shake.frequency = 0;
m_Shake.duration = 0;
}
int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )

View File

@ -222,7 +222,7 @@ static void BSP_LoadTextures( dlump_t *l )
out = Mem_Alloc( loadmodel->mempool, sizeof( *out ));
loadmodel->textures[i] = out;
Mem_Copy( out->name, mt->name, sizeof( out->name ));
com.strnlwr( mt->name, out->name, sizeof( out->name ));
// out->contents = CM_ContentsFromShader( out->name ); // FIXME: implement
}
}

View File

@ -2603,6 +2603,8 @@ static cl_enginefuncs_t gEngfuncs =
void CL_UnloadProgs( void )
{
if( !clgame.hInstance ) return;
CL_FreeEdicts();
CL_FreeEdict( &clgame.viewent );
CL_FreeEdict( &clgame.playermodel );

View File

@ -102,14 +102,14 @@ bool Cmd_GetMapList( const char *s, char *completedname, int length )
token_t token;
message[0] = 0;
while( Com_ReadToken( ents, SC_ALLOW_NEWLINES|SC_PARSE_GENERIC, &token ))
while( Com_ReadToken( ents, SC_ALLOW_NEWLINES|SC_ALLOW_PATHNAMES2, &token ))
{
if( !com.strcmp( token.string, "{" )) continue;
else if(!com.strcmp( token.string, "}" )) break;
else if(!com.strcmp( token.string, "message" ))
{
// get the message contents
Com_ReadString( ents, false, message );
Com_ReadString( ents, SC_ALLOW_PATHNAMES2, message );
}
}
Com_CloseScript( ents );
@ -606,7 +606,7 @@ bool Cmd_CheckMapsList( void )
file_t *f;
int i;
if( FS_FileExists( "scripts/maps.lst" ))
if( FS_FileExists( "scripts/maps.lst" ))
return true; // exist
t = FS_Search( "maps/*.bsp", false );
@ -676,18 +676,18 @@ bool Cmd_CheckMapsList( void )
message[0] = 0;
com.strncpy( message, "No Title", MAX_STRING );
while( Com_ReadToken( ents, SC_ALLOW_NEWLINES|SC_PARSE_GENERIC, &token ))
while( Com_ReadToken( ents, SC_ALLOW_NEWLINES|SC_ALLOW_PATHNAMES2, &token ))
{
if( !com.strcmp( token.string, "{" )) continue;
else if( !com.strcmp( token.string, "}" )) break;
else if( !com.strcmp( token.string, "message" ))
{
// get the message contents
Com_ReadString( ents, 0, message );
Com_ReadString( ents, SC_ALLOW_PATHNAMES2, message );
}
else if( !com.strcmp( token.string, "classname" ))
{
Com_ReadToken( ents, 0, &token );
Com_ReadToken( ents, SC_ALLOW_PATHNAMES2, &token );
if( !com.strcmp( token.string, GI->dm_entity ))
num_spawnpoints++;
else if( !com.strcmp( token.string, GI->sp_entity ))

View File

@ -925,7 +925,7 @@ Host_Main
void Host_Main( void )
{
// main window message loop
while( host.type != HOST_OFFLINE )
while( host.state != HOST_OFFLINE )
{
IN_Frame();
Host_Frame();

View File

@ -517,7 +517,7 @@ void SV_EntPatch_f( void )
return;
}
}
else mapname = Cmd_Argv( 2 );
else mapname = Cmd_Argv( 1 );
SV_WriteEntityPatch( mapname );
}

View File

@ -296,12 +296,12 @@ int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *l
flags |= MAP_IS_EXIST; // map is exist
while( Com_ReadToken( ents, SC_ALLOW_NEWLINES|SC_PARSE_GENERIC, &token ))
while( Com_ReadToken( ents, SC_ALLOW_NEWLINES|SC_ALLOW_PATHNAMES2, &token ))
{
if( !com.strcmp( token.string, "classname" ))
{
// check classname for spawn entity
Com_ReadString( ents, false, check_name );
Com_ReadString( ents, SC_ALLOW_PATHNAMES2, check_name );
if( !com.strcmp( spawn_entity, check_name ))
{
flags |= MAP_HAS_SPAWNPOINT;
@ -314,7 +314,7 @@ int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *l
else if( need_landmark && !com.strcmp( token.string, "targetname" ))
{
// check targetname for landmark entity
Com_ReadString( ents, false, check_name );
Com_ReadString( ents, SC_ALLOW_PATHNAMES2, check_name );
if( !com.strcmp( landmark_name, check_name ))
{
@ -3435,7 +3435,7 @@ bool SV_ParseEdict( script_t *script, edict_t *ent )
string keyname;
// parse key
if( !Com_ReadToken( script, SC_ALLOW_NEWLINES, &token ))
if( !Com_ReadToken( script, SC_ALLOW_NEWLINES|SC_ALLOW_PATHNAMES2, &token ))
Host_Error( "ED_ParseEdict: EOF without closing brace\n" );
if( token.string[0] == '}' ) break; // end of desc
@ -3460,7 +3460,7 @@ bool SV_ParseEdict( script_t *script, edict_t *ent )
// ignore attempts to set key ""
if( !keyname[0] ) continue;
// "wad" field is comletely ignored
// "wad" field is completely ignored
if( !com.strcmp( keyname, "wad" ))
continue;
@ -3532,7 +3532,7 @@ void SV_LoadFromFile( script_t *entities )
died = 0;
// parse ents
while( Com_ReadToken( entities, SC_ALLOW_NEWLINES, &token ))
while( Com_ReadToken( entities, SC_ALLOW_NEWLINES|SC_ALLOW_PATHNAMES2, &token ))
{
if( token.string[0] != '{' )
Host_Error( "ED_LoadFromFile: found %s when expecting {\n", token.string );

View File

@ -150,7 +150,7 @@ static void UI_CreateGame_GetMapsList( void )
int numMaps = 0;
// create new maplist if not exist
if( !Cmd_CheckMapsList() || (script = Com_OpenScript( "scripts/maps.lst", NULL, 0 )) == NULL )
if( !Cmd_CheckMapsList() || (script = Com_OpenScript( "scripts/maps.lst", NULL, 0 )) == NULL )
{
uiCreateGame.done.generic.flags |= QMF_GRAYED;
uiCreateGame.mapsList.itemNames = uiCreateGame.mapsDescriptionPtr;

View File

@ -34,7 +34,6 @@ typedef struct
HWND hwndBuffer;
HWND hwndButtonSubmit;
HBRUSH hbrEditBackground;
HBRUSH hbrErrorBackground;
HFONT hfBufferFont;
HFONT hfButtonFont;
HWND hwndInputLine;
@ -392,7 +391,6 @@ void Con_DestroyConsole( void )
if( s_wcd.hWnd )
{
DeleteObject( s_wcd.hbrEditBackground );
DeleteObject( s_wcd.hbrErrorBackground );
DeleteObject( s_wcd.hfBufferFont );
ShowWindow( s_wcd.hWnd, SW_HIDE );

View File

@ -281,7 +281,7 @@ static bool PS_ReadWhiteSpace( script_t *script, scFlags_t flags )
}
// if newlines are not allowed, restore text and line
if( hasNewLines && !(flags & SC_ALLOW_NEWLINES))
if( hasNewLines && !( flags & SC_ALLOW_NEWLINES ))
{
script->text = text;
script->line = line;
@ -482,6 +482,13 @@ static bool PS_ReadString( script_t *script, scFlags_t flags, token_t *token )
if( *script->text == '\n' )
{
if( flags & SC_ALLOW_PATHNAMES2 )
{
// "wad" pathes can contain very unexpected symbols! Arrgh
if( PS_ReadWhiteSpace( script, flags|SC_ALLOW_NEWLINES ))
continue;
}
PS_ScriptError( script, flags, "newline inside string" );
return false;
}
@ -490,7 +497,7 @@ static bool PS_ReadString( script_t *script, scFlags_t flags, token_t *token )
{
script->text++;
if( !(flags & SC_ALLOW_STRINGCONCAT))
if(!( flags & SC_ALLOW_STRINGCONCAT ))
break;
text = script->text;
@ -516,7 +523,7 @@ static bool PS_ReadString( script_t *script, scFlags_t flags, token_t *token )
return false;
}
if(( flags & SC_ALLOW_ESCAPECHARS) && *script->text == '\\' )
if(( flags & SC_ALLOW_ESCAPECHARS ) && *script->text == '\\' )
{
if( !PS_ReadEscapeChar( script, flags, &token->string[token->length] ))
return false;
@ -603,7 +610,7 @@ static bool PS_ReadLiteral( script_t *script, scFlags_t flags, token_t *token )
{
script->text++;
if(!(flags & SC_ALLOW_STRINGCONCAT))
if(!( flags & SC_ALLOW_STRINGCONCAT ))
break;
text = script->text;
@ -629,7 +636,7 @@ static bool PS_ReadLiteral( script_t *script, scFlags_t flags, token_t *token )
return false;
}
if((flags & SC_ALLOW_ESCAPECHARS) && *script->text == '\\' )
if(( flags & SC_ALLOW_ESCAPECHARS ) && *script->text == '\\' )
{
if( !PS_ReadEscapeChar( script, flags, &token->string[token->length] ))
return false;

View File

@ -115,11 +115,10 @@ returns hash key for string
*/
uint Com_HashKey( const char *string, uint hashSize )
{
uint hashKey = 0;
int i;
uint i, hashKey = 0;
for( i = 0; string[i]; i++ )
hashKey = (hashKey + i) * 37 + com_tolower(string[i]);
hashKey = (hashKey + i) * 37 + com.tolower( string[i] );
return (hashKey % hashSize);
}

View File

@ -3070,7 +3070,7 @@ texture_t *R_FindTexture( const char *name, const byte *buf, size_t size, texFla
}
// NOTE: texname may contains some commands over textures
script = Com_OpenScript( name, name, com.strlen( name ));
script = Com_OpenScript( "texturedef", name, com.strlen( name ));
if( !script ) return NULL;
if( !Com_ReadToken( script, SC_ALLOW_PATHNAMES2, &token ))

View File

@ -1140,7 +1140,11 @@ Mod_LoadCachedImage
static ref_shader_t *Mod_LoadCachedImage( cachedimage_t *image )
{
mip_t *mt = image->base;
int i;
int i, shader_type = SHADER_TEXTURE;
// see if already loaded
if( image->shader )
return image->shader;
Com_Assert( mt == NULL );
@ -1151,7 +1155,7 @@ static ref_shader_t *Mod_LoadCachedImage( cachedimage_t *image )
// build the unique shadername because we don't want keep this for other maps
if( mt->offsets[0] > 0 )
com.snprintf( image->name, 32, "%s/%s", cached.modelname, mt->name );
com.snprintf( image->name, sizeof( image->name ), "%s/%s", cached.modelname, mt->name );
// determine shader parms by texturename
if( !com.strncmp( mt->name, "scroll", 6 ))
@ -1159,18 +1163,25 @@ static ref_shader_t *Mod_LoadCachedImage( cachedimage_t *image )
if( image->animated )
{
R_SetAnimFrequency( 5.0f ); // set primary animation
float fps = ( cached.version == HLBSP_VERSION ) ? 10.0f : 5.0f;
R_SetAnimFrequency( fps ); // set primary animation
for( i = 0; i < image->anim_total[0]; i++ )
Mod_LoadTexture( image->anim_frames[0][i] );
R_SetAnimFrequency( 5.0f ); // set alternate animation
R_SetAnimFrequency( fps ); // set alternate animation
for( i = 0; i < image->anim_total[1]; i++ )
Mod_LoadTexture( image->anim_frames[1][i] );
}
else Mod_LoadTexture( mt ); // load the base image
load_shader:
return R_LoadShader( image->name, SHADER_TEXTURE, false, 0, SHADER_INVALID );
if( !com.strncmp( mt->name, "sky", 3 ))
shader_type = SHADER_SKY;
image->shader = R_LoadShader( image->name, SHADER_TEXTURE, false, 0, SHADER_INVALID );
return image->shader;
}
/*
@ -1231,6 +1242,10 @@ static void Mod_LoadTextures( const dlump_t *l )
out->width = LittleLong( mt->width );
out->height = LittleLong( mt->height );
out->base = mt;
// sky must be loading first
if( !com.strncmp( mt->name, "sky", 3 ))
Mod_LoadCachedImage( out );
}
// sequence the animations
@ -1345,7 +1360,7 @@ static void Mod_LoadTextures( const dlump_t *l )
out = cached.textures + i;
// out->contents = Mod_ContentsFromShader( out->name ); // FIXME: implement
loadmodel->shaders[i] = out->shader = Mod_LoadCachedImage( out );
loadmodel->shaders[i] = Mod_LoadCachedImage( out );
Cvar_SetValue( "scr_loading", scr_loading->value + 50.0f / count );
if( ri.UpdateScreen ) ri.UpdateScreen();
@ -1570,7 +1585,7 @@ static void Mod_LoadSurfaces( const dlump_t *l )
out->numstyles++;
}
if( !tr.currentSkyShader && (out->flags & SURF_DRAWSKY || out->shader->flags & SHADER_SKYPARMS ))
if( !tr.currentSkyShader && ( out->flags & SURF_DRAWSKY || out->shader->flags & SHADER_SKYPARMS ))
{
// because sky shader may missing skyParms, but always has surfaceparm 'sky'
tr.currentSkyShader = out->shader;
@ -2691,6 +2706,8 @@ void R_EndRegistration( const char *skyname )
if( mod->touchFrame != tr.registration_sequence )
Mod_FreeModel( mod );
}
// purge all unused shaders
R_ShaderFreeUnused();
}

View File

@ -2565,23 +2565,24 @@ void R_ShaderDump_f( void )
cache = Shader_GetCache( name, shader->type, hashKey );
if( !cache )
{
if( shader->stages[0].num_textures )
{
int i;
for( i = 0; i < shader->stages[0].num_textures; i++ )
{
if( shader->stages[0].textures[i] )
Msg( "tex[%i] %s\n", i, shader->stages[0].textures[i] ->name );
else Msg( "missing texture %i\n" );
}
}
Msg( "could not find shader %s in cache\n", name );
return;
}
Msg( "found in %s:\n\n", cache->source );
Msg( "^2%s%s\n", name, cache->buffer );
Msg( "shader->flags %d\n", shader->flags );
Msg( "shader->features %d\n", shader->features );
Msg( "shader->sort %d\n", shader->sort );
Msg( "shader->stages %d\n", shader->num_stages );
Msg( "pass[0]->flags %d\n", shader->stages[0].flags );
Msg( "pass[0]->glState %d\n", shader->stages[0].glState );
Msg( "pass[0]->rgbgen %d\n", shader->stages[0].rgbGen.type );
Msg( "pass[0]->alphgen %d\n", shader->stages[0].alphaGen.type );
Msg( "pass[0]->tcgen %d\n", shader->stages[0].tcgen );
}
bool R_ShaderCheckCache( const char *name )
@ -2647,7 +2648,16 @@ void Shader_TouchImages( ref_shader_t *shader, e_free free_unused )
texture_t *texture;
Com_Assert( shader == NULL );
if( free_unused == FREE_IGNORE )
// reset parms
r_shaderTwoSided = 0;
r_miptexFeatures = 0;
r_stageAnimOffset = 0;
r_numStageTextures = 0;
r_stageAnimFrequency[0] = 0.0f;
r_stageAnimFrequency[1] = 0.0f;
if( free_unused == FREE_IGNORE )
shader->touchFrame = tr.registration_sequence;
for( i = 0; i < shader->num_stages; i++ )
@ -2662,7 +2672,8 @@ void Shader_TouchImages( ref_shader_t *shader, e_free free_unused )
// prolonge registration for all shader textures
texture = stage->textures[j];
if( !texture || !texture->texnum ) continue;
if( !texture || !texture->texnum )
continue;
if( free_unused == FREE_FORCE && texture->texType != TEX_SYSTEM )
{
@ -3839,14 +3850,6 @@ static ref_shader_t *Shader_CreateDefault( ref_shader_t *shader, int type, int a
break;
}
// reset parms
r_shaderTwoSided = 0;
r_miptexFeatures = 0;
r_stageAnimOffset = 0;
r_numStageTextures = 0;
r_stageAnimFrequency[0] = 0.0f;
r_stageAnimFrequency[1] = 0.0f;
Shader_SetRenderMode( shader );
// refresh registration sequence