Ejemplo n.º 1
0
/*
=================
CG_RegisterUpgrade

The server says this item is used on this level
=================
*/
void CG_RegisterUpgrade( int upgradeNum )
{
  upgradeInfo_t   *upgradeInfo;
  char            *icon;

  if( upgradeNum <= UP_NONE || upgradeNum >= UP_NUM_UPGRADES )
  {
    CG_Error( "CG_RegisterUpgrade: out of range: %d", upgradeNum );
    return;
  }

  upgradeInfo = &cg_upgrades[ upgradeNum ];

  if( upgradeInfo->registered )
  {
    CG_Printf( "CG_RegisterUpgrade: already registered: (%d) %s\n", upgradeNum,
      BG_Upgrade( upgradeNum )->name );
    return;
  }

  upgradeInfo->registered = qtrue;

  if( !BG_Upgrade( upgradeNum )->name[ 0 ] )
    CG_Error( "Couldn't find upgrade %i", upgradeNum );

  upgradeInfo->humanName = BG_Upgrade( upgradeNum )->humanName;

  //la la la la la, i'm not listening!
  if( upgradeNum == UP_GRENADE )
    upgradeInfo->upgradeIcon = cg_weapons[ WP_GRENADE ].weaponIcon;
  else if( ( icon = BG_Upgrade( upgradeNum )->icon ) )
    upgradeInfo->upgradeIcon = trap_R_RegisterShader( icon );
}
Ejemplo n.º 2
0
static void CG_SoundLoadSoundFiles( void ) {
	char soundFiles[MAX_SOUND_FILES][MAX_QPATH];
	char buffer[MAX_BUFFER];
	char *text;
	char filename[MAX_QPATH];
	fileHandle_t f;
	int numSounds;
	int i, len;
	char *token;

	// scan for sound files
	Com_sprintf( filename, MAX_QPATH, "sound/scripts/filelist.txt" );
	len = trap_FS_FOpenFile( filename, &f, FS_READ );
	if ( len <= 0 ) {
		CG_Printf( S_COLOR_RED "WARNING: no sound files found (filelist.txt not found in sound/scripts)\n" );
		return;
	}
	if ( len > MAX_BUFFER ) {
		CG_Error( "%s is too big, make it smaller (max = %i bytes)\n", filename, MAX_BUFFER );
	}
	// load the file into memory
	trap_FS_Read( buffer, len, f );
	buffer[len] = 0;
	trap_FS_FCloseFile( f );
	// parse the list
	text = buffer;
	numSounds = 0;
	while ( 1 ) {
		token = COM_ParseExt( &text, qtrue );
		if ( !token[0] ) {
			break;
		}
		Com_sprintf( soundFiles[numSounds++], MAX_QPATH, token );
	}

	if ( !numSounds ) {
		CG_Printf( S_COLOR_RED "WARNING: no sound files found\n" );
		return;
	}

	// load and parse sound files
	for ( i = 0; i < numSounds; i++ )
	{
		Com_sprintf( filename, sizeof( filename ), "sound/scripts/%s", soundFiles[i] );
#ifndef NDEBUG
		CG_Printf( "...loading '%s'\n", filename );
#endif
		len = trap_FS_FOpenFile( filename, &f, FS_READ );
		if ( len <= 0 ) {
			CG_Error( "Couldn't load %s", filename );
		}
		if ( len > MAX_BUFFER ) {
			CG_Error( "%s is too big, make it smaller (max = %i bytes)\n", filename, MAX_BUFFER );
		}
		memset( buffer, 0, sizeof( buffer ) );
		trap_FS_Read( buffer, len, f );
		trap_FS_FCloseFile( f );
		CG_SoundParseSounds( filename, buffer );
	}
}
/*
=================
CG_ParseTeamInfo

=================
*/
static void CG_ParseTeamInfo( void ) {
	int		i;
	int		client;

	numSortedTeamPlayers = atoi( CG_Argv( 1 ) );
	if( numSortedTeamPlayers < 0 || numSortedTeamPlayers > TEAM_MAXOVERLAY )
	{
		CG_Error( "CG_ParseTeamInfo: numSortedTeamPlayers out of range (%d)",
				numSortedTeamPlayers );
		return;
	}

	for ( i = 0 ; i < numSortedTeamPlayers ; i++ ) {
		client = atoi( CG_Argv( i * 6 + 2 ) );
		if( client < 0 || client >= MAX_CLIENTS )
		{
		  CG_Error( "CG_ParseTeamInfo: bad client number: %d", client );
		  return;
		}

		sortedTeamPlayers[i] = client;

		cgs.clientinfo[ client ].location = atoi( CG_Argv( i * 6 + 3 ) );
		cgs.clientinfo[ client ].health = atoi( CG_Argv( i * 6 + 4 ) );
		cgs.clientinfo[ client ].armor = atoi( CG_Argv( i * 6 + 5 ) );
		cgs.clientinfo[ client ].curWeapon = atoi( CG_Argv( i * 6 + 6 ) );
		cgs.clientinfo[ client ].powerups = atoi( CG_Argv( i * 6 + 7 ) );
	}
}
Ejemplo n.º 4
0
Archivo: cg_spawn.c Proyecto: GenaSG/ET
void SP_info_train_spline_main( void ) {
	char* targetname;
	char* target;
	char* control;
	vec3_t origin;
	int i;
	char* end;
	splinePath_t* spline;

	if( !CG_SpawnVector("origin", "0 0 0", origin) ) {
		CG_Error ("info_train_spline_main with no origin\n");
	}

	if ( !CG_SpawnString("targetname", "", &targetname) ) {
		CG_Error ("info_train_spline_main with no targetname at %s\n", vtos(origin));
	}

	CG_SpawnString("target", "", &target);

	spline = BG_AddSplinePath( targetname, target, origin );

	if(CG_SpawnString( "end", "", &end )) {
		spline->isEnd = qtrue;
	} else if(CG_SpawnString( "start", "", &end )) {
		spline->isStart = qtrue;
	}

	for( i = 1;; i++ ) {
		if(!CG_SpawnString( i == 1 ? va( "control" ) : va( "control%i", i ), "", &control )) {
			break;
		}

		BG_AddSplineControl( spline, control );
	}
}
void CG_JS_Sys_Cvar_Init(JSContext *ctx, JSObject *Sys)
{
	JSObject *cvar = JS_DefineObject(ctx, Sys, "Cvar", &cvar_class, NULL, 0);
    if (!cvar)
        CG_Error("Failed to Define javascript Cvar object\n");
    if (!JS_DefineFunctions(ctx, cvar, cvar_static_methods))
        CG_Error("Failed to Define javascript Cvar functions\n");
}
Ejemplo n.º 6
0
/*
===================
CG_TransitionSnapshot

The transition point from snap to nextSnap has passed
===================
*/
static void CG_TransitionSnapshot( void ) {
	centity_t			*cent;
	snapshot_t			*oldFrame;
	int					i;

	if ( !cg.snap ) {
		CG_Error( "CG_TransitionSnapshot: NULL cg.snap" );
	}
	if ( !cg.nextSnap ) {
		CG_Error( "CG_TransitionSnapshot: NULL cg.nextSnap" );
	}

	// execute any server string commands before transitioning entities
	CG_ExecuteNewServerCommands( cg.nextSnap->serverCommandSequence );

	// clear the currentValid flag for all entities in the existing snapshot
	for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
		cent = &cg_entities[ cg.snap->entities[ i ].number ];
		cent->currentValid = qfalse;
	}

	// move nextSnap to snap and do the transitions
	oldFrame = cg.snap;
	cg.snap = cg.nextSnap;

	BG_PlayerStateToEntityState( &cg.snap->ps, &cg_entities[ cg.snap->ps.clientNum ].currentState, qfalse );
	cg_entities[ cg.snap->ps.clientNum ].interpolate = qfalse;

	for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
		cent = &cg_entities[ cg.snap->entities[ i ].number ];
		CG_TransitionEntity( cent );

		// remember time of snapshot this entity was last updated in
		cent->snapShotTime = cg.snap->serverTime;
	}

	cg.nextSnap = NULL;

	// check for playerstate transition events
	if ( oldFrame ) {
		playerState_t	*ops, *ps;

		ops = &oldFrame->ps;
		ps = &cg.snap->ps;
		// teleporting checks are irrespective of prediction
		if ( ( ps->eFlags ^ ops->eFlags ) & EF_TELEPORT_BIT ) {
			cg.thisFrameTeleport = qtrue;	// will be cleared by prediction code
		}

		// if we are not doing client side movement prediction for any
		// reason, then the client events and view changes will be issued now
		if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW)
			|| cg_nopredict.integer || cg_synchronousClients.integer ) {
			CG_TransitionPlayerState( ps, ops );
		}
	}

}
Ejemplo n.º 7
0
void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd)
{
	cparticle_t	*p;
	int anim;

	if (animStr < (char *)10)
		CG_Error( "CG_ParticleExplosion: animStr is probably an index rather than a string" );

	// find the animation string
	for (anim=0; shaderAnimNames[anim]; anim++) {
		if (!Q_stricmp( animStr, shaderAnimNames[anim] ))
			break;
	}
	if (!shaderAnimNames[anim]) {
		CG_Error("CG_ParticleExplosion: unknown animation string: %s", animStr);
		return;
	}

	if (!free_particles)
		return;
	p = free_particles;
	free_particles = p->next;
	p->next = active_particles;
	active_particles = p;
	p->time = cg.time;
#ifdef WOLF_PARTICLES
	p->alpha = 1.0;
#else
	p->alpha = 0.5;
#endif
	p->alphavel = 0;

	if (duration < 0) {
		duration *= -1;
		p->roll = 0;
	} else {
		p->roll = crandom()*179;
	}

	p->shaderAnim = anim;

	p->width = sizeStart;
	p->height = sizeStart*shaderAnimSTRatio[anim];	// for sprites that are stretch in either direction

	p->endheight = sizeEnd;
	p->endwidth = sizeEnd*shaderAnimSTRatio[anim];

	p->endtime = cg.time + duration;

	p->type = P_ANIM;

	VectorCopy( origin, p->org );
	VectorCopy( vel, p->vel );
	VectorClear( p->accel );

}
Ejemplo n.º 8
0
/*
* SCR_GetNextColumnLayout
*/
static const char *SCR_GetNextColumnLayout( const char **ptrlay, const char **ptrtitle, char *type, int *width, struct qfontface_s *font )
{
	static const char *empty = "";
	const char *token;

	assert( ptrlay && *ptrlay );

	// get the token type from the layout
	token = COM_ParseExt( ptrlay, true );
	if( !token[0] )
		return NULL;

	if( token[0] != '%' )
		CG_Error( "SCR_GetNextColumnLayout: Invalid player tab layout (expecting token type. found '%s')\n", token );

	if( type )
		*type = token[1];

	// get the column width from the layout
	token = COM_ParseExt( ptrlay, true );
	if( !token[0] || token[0] == '%' )
		CG_Error( "SCR_GetNextColumnLayout: Invalid player tab layout (expecting token width. found '%s')\n", token );

	if( width )
	{
		float widthScale = cg_scoreboardWidthScale->value;
		bool relative = true;
		if( token[0] == 'l' ) // line heights
		{
			widthScale *= trap_SCR_FontHeight( font );
			relative = false;
			token++;
		}
		*width = (int)( atof( token ) * widthScale );
		if( relative )
			*width = *width * cgs.vidHeight / 600;

		if( *width < 0 )
			*width = 0;
	}

	if( ptrtitle && *ptrtitle )
	{
		// get the column title token from the layout
		token = COM_ParseExt( ptrtitle, true );
		if( !token[0] )
			CG_Error( "SCR_GetNextColumnLayout: Invalid player tab layout (expecting token tittle. found '%s')\n", token );
	}
	else
	{
		token = empty;
	}

	return token;
}
Ejemplo n.º 9
0
/*
* CG_ValidateItemDef
*
* Compares name and tag against the itemlist to make sure cgame and game lists match
*/
void CG_ValidateItemDef( int tag, char *name )
{
	gsitem_t *item;

	item = GS_FindItemByName( name );
	if( !item )
		CG_Error( "Client/Server itemlist missmatch (Game and Cgame version/mod differs). Item '%s' not found\n", name );

	if( item->tag != tag )
		CG_Error( "Client/Server itemlist missmatch (Game and Cgame version/mod differs).\n" );
}
Ejemplo n.º 10
0
/*
====================
CG_ParseSpawnVars

Parses a brace bounded set of key / value pairs out of the
level's entity strings into cg.spawnVars[]

This does not actually spawn an entity.
====================
*/
qboolean CG_ParseSpawnVars(void)
{
    char keyname[MAX_TOKEN_CHARS];
    char com_token[MAX_TOKEN_CHARS];

    cg.numSpawnVars     = 0;
    cg.numSpawnVarChars = 0;

    // parse the opening brace
    if (!trap_GetEntityToken(com_token, sizeof(com_token)))
    {
        // end of spawn string
        return qfalse;
    }
    if (com_token[0] != '{')
    {
        CG_Error("CG_ParseSpawnVars: found %s when expecting {", com_token);
    }

    // go through all the key / value pairs
    while (1)
    {
        // parse key
        if (!trap_GetEntityToken(keyname, sizeof(keyname)))
        {
            CG_Error("CG_ParseSpawnVars: EOF without closing brace");
        }

        if (keyname[0] == '}')
        {
            break;
        }

        // parse value
        if (!trap_GetEntityToken(com_token, sizeof(com_token)))
        {
            CG_Error("CG_ParseSpawnVars: EOF without closing brace");
        }

        if (com_token[0] == '}')
        {
            CG_Error("CG_ParseSpawnVars: closing brace without data");
        }
        if (cg.numSpawnVars == MAX_SPAWN_VARS)
        {
            CG_Error("CG_ParseSpawnVars: MAX_SPAWN_VARS");
        }
        cg.spawnVars[cg.numSpawnVars][0] = CG_AddSpawnVarToken(keyname);
        cg.spawnVars[cg.numSpawnVars][1] = CG_AddSpawnVarToken(com_token);
        cg.numSpawnVars++;
    }

    return qtrue;
}
Ejemplo n.º 11
0
/*
===================
CG_TransitionSnapshot

The transition point from snap to nextSnap has passed
===================
*/
void CG_TransitionSnapshot( void ) {
	centity_t			*cent;
	snapshot_t			*oldFrame;
	int					i;

	if ( !cg.snap ) {
		CG_Error( "CG_TransitionSnapshot: NULL cg.snap" );
	}
	if ( !cg.nextSnap ) {
		CG_Error( "CG_TransitionSnapshot: NULL cg.nextSnap" );
	}

	// execute any server string commands before transitioning entities
	CG_ExecuteNewServerCommands( cg.nextSnap->serverCommandSequence );

	// clear the currentValid flag for all entities in the existing snapshot
	for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
		cent = &cg_entities[ cg.snap->entities[ i ].number ];
		cent->currentValid = qfalse;
	}

	// move nextSnap to snap and do the transitions
	oldFrame = cg.snap;
	cg.snap = cg.nextSnap;

	// sort out solid entities
	//CG_BuildSolidList();

	for ( i = 0 ; i < cg.snap->numEntities ; i++ ) 
	{
		if ( 1 )//cg.snap->entities[ i ].number != 0 ) // I guess the player adds his/her events elsewhere, so doing this also gives us double events for the player!
		{
			cent = &cg_entities[ cg.snap->entities[ i ].number ];
			CG_TransitionEntity( cent );
		}
	}

	cg.nextSnap = NULL;

	// check for playerstate transition events
	if ( oldFrame ) {
		// if we are not doing client side movement prediction for any
		// reason, then the client events and view changes will be issued now
		if ( cg_timescale.value >= 1.0f )
		{
			CG_TransitionPlayerState( &cg.snap->ps, &oldFrame->ps );
		}
	}

}
Ejemplo n.º 12
0
/*
=================
CG_RegisterUpgrade

The server says this item is used on this level
=================
*/
void CG_RegisterUpgrade( int upgradeNum )
{
  upgradeInfo_t   *upgradeInfo;
  char            *icon;

  upgradeInfo = &cg_upgrades[ upgradeNum ];

  if( upgradeNum == 0 )
    return;

  if( upgradeInfo->registered )
    return;

  memset( upgradeInfo, 0, sizeof( *upgradeInfo ) );
  upgradeInfo->registered = qtrue;

  if( !BG_FindNameForUpgrade( upgradeNum ) )
    CG_Error( "Couldn't find upgrade %i", upgradeNum );

  upgradeInfo->humanName = BG_FindHumanNameForUpgrade( upgradeNum );

  //la la la la la, i'm not listening!
  if( upgradeNum == UP_GRENADE )
    upgradeInfo->upgradeIcon = cg_weapons[ WP_GRENADE ].weaponIcon;
  else if( ( icon = BG_FindIconForUpgrade( upgradeNum ) ) )
    upgradeInfo->upgradeIcon = trap_R_RegisterShader( icon );
}
Ejemplo n.º 13
0
void CG_DrawStats( char *stats ) {
	int i, y, v, j;
	#define MAX_STATS_VARS  64
	int vars[MAX_STATS_VARS];
	char *str, *token;
	char *formatStr = NULL; // TTimo: init
	int varIndex;
	char string[MAX_QPATH];

	UI_DrawProportionalString( 320, 120, "MISSION STATS",
							   UI_CENTER | UI_SMALLFONT | UI_DROPSHADOW, colorWhite );

	Q_strncpyz( string, stats, sizeof( string ) );
	str = string;
	// convert commas to spaces
	for ( i = 0; str[i]; i++ ) {
		if ( str[i] == ',' ) {
			str[i] = ' ';
		}
	}

	for ( i = 0, y = 0, v = 0; statsItems[i].label; i++ ) {
		y += statsItems[i].YOfs;

		UI_DrawProportionalString( statsItems[i].labelX, y, statsItems[i].label,
								   statsItems[i].labelFlags, *statsItems[i].labelColor );

		if ( statsItems[i].numVars ) {
			varIndex = v;
			for ( j = 0; j < statsItems[i].numVars; j++ ) {
				token = COM_Parse( &str );
				if ( !token || !token[0] ) {
					CG_Error( "error parsing mission stats\n" );
					return;
				}

				vars[v++] = atoi( token );
			}

			// build the formatStr
			switch ( statsItems[i].numVars ) {
			case 1:
				formatStr = va( statsItems[i].format, vars[varIndex] );
				break;
			case 2:
				formatStr = va( statsItems[i].format, vars[varIndex], vars[varIndex + 1] );
				break;
			case 3:
				formatStr = va( statsItems[i].format, vars[varIndex], vars[varIndex + 1], vars[varIndex + 2] );
				break;
			case 4:
				formatStr = va( statsItems[i].format, vars[varIndex], vars[varIndex + 1], vars[varIndex + 2], vars[varIndex + 3] );
				break;
			}

			UI_DrawProportionalString( statsItems[i].formatX, y, formatStr,
									   statsItems[i].formatFlags, *statsItems[i].formatColor );
		}
	}
}
Ejemplo n.º 14
0
/*
================
vmMain

This is the only way control passes into the module.
This must be the very first function compiled into the .q3vm file
================
*/
Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {

	switch ( command ) {
	case CG_INIT:
		CG_Init( arg0, arg1, arg2 );
		return 0;
	case CG_SHUTDOWN:
		CG_Shutdown();
		return 0;
	case CG_CONSOLE_COMMAND:
		return CG_ConsoleCommand();
	case CG_DRAW_ACTIVE_FRAME:
		CG_DrawActiveFrame( arg0, arg1, arg2 );
		return 0;
	case CG_CROSSHAIR_PLAYER:
		return CG_CrosshairPlayer();
	case CG_LAST_ATTACKER:
		return CG_LastAttacker();
	case CG_KEY_EVENT:
		CG_KeyEvent(arg0, arg1);
		return 0;
	case CG_MOUSE_EVENT:
		CG_MouseEvent(arg0, arg1);
		return 0;
	case CG_EVENT_HANDLING:
		CG_EventHandling(arg0);
		return 0;
	default:
		CG_Error( "vmMain: unknown command %i", command );
		break;
	}
	return -1;
}
Ejemplo n.º 15
0
void CG_JS_Sys_Init(JSContext *ctx, JSObject *global)
{
    JSObject *Sys;
    int len = strlen(GAME_VERSION);
    char *gv = (char *)JS_malloc(ctx, len+1);

    Sys = JS_DefineObject(ctx, global, "Sys", &sys_class, NULL, 0);
    if (!Sys)
        CG_Error("Failed to Define javascript Sys object\n");
    if (!JS_DefineFunctions(ctx, Sys, sys_static_methods))
        CG_Error("Failed to Define javascript Sys functions\n");
    if (!JS_DefineConstDoubles(ctx, Sys, sys_constants))
        CG_Error("Failed to Define javascript Sys constants\n");

    CG_JS_Sys_Cvar_Init(ctx, Sys);
}
Ejemplo n.º 16
0
/*
==============
CG_SoundPickOldestRandomSound
==============
*/
void CG_SoundPickOldestRandomSound( soundScript_t *sound, vec3_t org, int entnum ) {
	int oldestTime = 0; // TTimo: init
	soundScriptSound_t *oldestSound;
	soundScriptSound_t *scriptSound;

	oldestSound = NULL;
	scriptSound = sound->soundList;
	while ( scriptSound ) {
		if ( !oldestSound || ( scriptSound->lastPlayed < oldestTime ) ) {
			oldestTime = scriptSound->lastPlayed;
			oldestSound = scriptSound;
		}
		scriptSound = scriptSound->next;
	}

	if ( oldestSound ) {
		// play this sound
		if ( !sound->streaming ) {
			if ( !oldestSound->sfxHandle ) {
				oldestSound->sfxHandle = trap_S_RegisterSound( oldestSound->filename );
			}
			trap_S_StartSound( org, entnum, sound->channel, oldestSound->sfxHandle );
		} else {
			trap_S_StartStreamingSound( oldestSound->filename, sound->looping ? oldestSound->filename : NULL, entnum, sound->channel, sound->attenuation );
		}
		oldestSound->lastPlayed = cg.time;
	} else {
		CG_Error( "Unable to locate a valid sound for soundScript: %s\n", sound->name );
	}
}
Ejemplo n.º 17
0
static demoChasePoint_t *chasePointAlloc(void) {
	demoChasePoint_t * point = (demoChasePoint_t *)malloc(sizeof (demoChasePoint_t));
	if (!point)
		CG_Error("Out of memory");
	memset( point, 0, sizeof( demoChasePoint_t ));
	return point;
}
Ejemplo n.º 18
0
weapon_t CG_LimboPanel_GetWeaponForNumber(int number, int slot, qboolean ignoreDisabled) {
	bg_playerclass_t *classInfo;

	if (CG_LimboPanel_GetTeam() == TEAM_SPECTATOR) {
		return WP_NONE;
	}

	classInfo = CG_LimboPanel_GetPlayerClass();
	if (!classInfo) {
		return WP_NONE;
	}

	if (slot == 1) {
		if (!ignoreDisabled && CG_LimboPanel_WeaponIsDisabled(number)) {
			if (!number) {
				CG_Error("ERROR: Class weapon 0 disabled\n");
				return WP_NONE;
			}
			return classInfo->classWeapons[0];
		}

		return classInfo->classWeapons[number];
	}
	if (number == 0) {
		if (CG_LimboPanel_GetClass() == PC_COVERTOPS) {
			return CG_LimboPanel_GetTeam() == TEAM_AXIS ? WP_SILENCER : WP_SILENCED_COLT;
		}
		return CG_LimboPanel_GetTeam() == TEAM_AXIS ? WP_LUGER : WP_COLT;
	}

	return 0;
}
Ejemplo n.º 19
0
void CG_RestartLevel( void ) {
	int		snapshotNum;
	int		r;

	snapshotNum = cg.processedSnapshotNum;

/*
Ghoul2 Insert Start
*/

//	memset( cg_entities, 0, sizeof( cg_entities ) );
	CG_Init_CGents();
// this is a No-No now we have stl vector classes in here.
//	memset( &cg, 0, sizeof( cg ) );
	CG_Init_CG();
/*
Ghoul2 Insert End
*/


	CG_LinkCentsToGents();
	CG_InitLocalEntities();
	CG_InitMarkPolys();

	// regrab the first snapshot of the restart

	cg.processedSnapshotNum = snapshotNum;
	r = cgi_GetSnapshot( cg.processedSnapshotNum, &cg.activeSnapshots[0] );
	if ( !r ) {
		CG_Error( "cgi_GetSnapshot failed on restart" );
	}

	CG_SetInitialSnapshot( &cg.activeSnapshots[0] );
	cg.time = cg.snap->serverTime;
}
Ejemplo n.º 20
0
void SP_worldspawn( void ) {
	char    *s;

	CG_SpawnString( "classname", "", &s );
	if ( Q_stricmp( s, "worldspawn" ) ) {
		CG_Error( "SP_worldspawn: The first entity isn't 'worldspawn'" );
	}

	CG_SpawnString( "enableDust", "0", &s );
	trap_Cvar_Set( "cg_enableDust", s );

	CG_SpawnString( "enableBreath", "0", &s );
	trap_Cvar_Set( "cg_enableBreath", s );

	if ( CG_SpawnVector2D( "mapcoordsmins", "-128 128", cg.mapcoordsMins ) &&  // top left
		 CG_SpawnVector2D( "mapcoordsmaxs", "128 -128", cg.mapcoordsMaxs ) ) { // bottom right
		cg.mapcoordsValid = qtrue;
	} else {
		cg.mapcoordsValid = qfalse;
	}

#if 0
	cg.mapcoordsScale[0] = 1 / ( cg.mapcoordsMaxs[0] - cg.mapcoordsMins[0] );
	cg.mapcoordsScale[1] = 1 / ( cg.mapcoordsMaxs[1] - cg.mapcoordsMins[1] );

	BG_InitLocations( cg.mapcoordsMins, cg.mapcoordsMaxs );
#endif

	CG_SpawnString( "atmosphere", "", &s );
	CG_EffectParse( s );

	CG_SpawnFloat( "skyalpha", "1", &cg.skyAlpha );
}
Ejemplo n.º 21
0
/*
* CG_FindWeaponModelSpot
* 
* Stored names format is without extension, like this: "rocketl/rocketl"
*/
static struct weaponinfo_s *CG_FindWeaponModelSpot( char *filename )
{
	int i;
	int freespot = -1;


	for( i = 0; i < WEAP_TOTAL; i++ )
	{
		if( cg_pWeaponModelInfos[i].inuse == true )
		{
			if( !Q_stricmp( cg_pWeaponModelInfos[i].name, filename ) ) //found it
			{
				if( cg_debugWeaponModels->integer )
					CG_Printf( "WEAPModel: found at spot %i: %s\n", i, filename );

				return &cg_pWeaponModelInfos[i];
			}
		}
		else if( freespot < 0 )
			freespot = i;
	}

	if( freespot < 0 )
		CG_Error( "%sCG_FindWeaponModelSpot: Couldn't find a free weaponinfo spot%s", S_COLOR_RED, S_COLOR_WHITE );

	//we have a free spot
	if( cg_debugWeaponModels->integer )
		CG_Printf( "WEAPmodel: assigned free spot %i for weaponinfo %s\n", freespot, filename );

	return &cg_pWeaponModelInfos[freespot];
}
Ejemplo n.º 22
0
/*========================
CG_AddAuraToScene
========================*/
void CG_AddAuraToScene( centity_t *player){
	int				clientNum, tier;
	auraState_t		*state;
	auraConfig_t	*config;

	// Get the aura system corresponding to the player
	clientNum = player->currentState.clientNum;
	if(clientNum < 0 || clientNum >= MAX_CLIENTS){
		CG_Error( "Bad clientNum on player entity");
		return;
	}
	state = &auraStates[ clientNum ];
	tier = cgs.clientinfo[clientNum].tierCurrent;
	config = &(state->configurations[tier]);	
	
	
	// Update origin
	VectorCopy( player->lerpOrigin, state->origin);

	// Calculate modulation for dimming
	CG_Aura_DimLight( player, state, config);

	// Add aura effects
	CG_Aura_AddSounds( player, state, config);
	CG_Aura_AddTrail( player, state, config);
	CG_Aura_AddDebris( player, state, config);
	CG_Aura_AddDLight( player, state, config);

	// Render the aura
	CG_Aura_ConvexHullRender( player, state, config);
}
Ejemplo n.º 23
0
/*
=================
CG_ConfigString
=================
*/
const char* CG_ConfigString( int index )
{
	if ( index < 0 || index >= MAX_CONFIGSTRINGS )
	{
		CG_Error( "CG_ConfigString: bad index: %i", index );
	}
	return cgs.gameState.stringData + cgs.gameState.stringOffsets[ index ];
}
Ejemplo n.º 24
0
void QDECL Com_Error( int level, const char *error, ... ) {
	va_list		argptr;
	char		text[1024];

	va_start (argptr, error);
	Q_vsnprintf (text, sizeof(text), error, argptr);
	va_end (argptr);

	CG_Error( "%s", text);
}
Ejemplo n.º 25
0
demoListPoint_t *listPointAlloc( int size ) {
	demoListPoint_t * point;

	size += sizeof( demoListPoint_t );
	point = (demoListPoint_t *)malloc( size );
	if (!point)
		CG_Error("Out of memory");
	memset( point, 0, size );
	return point;
}
Ejemplo n.º 26
0
void SP_path_corner_2( void ) {
	char* targetname;
	vec3_t origin;

	CG_SpawnString( "targetname", "", &targetname );
	CG_SpawnVector( "origin", "0 0 0", origin );

	if ( !*targetname ) {
		CG_Error( "path_corner_2 with no targetname at %s\n", vtos( origin ) );
		return;
	}

	if ( numPathCorners >= MAX_PATH_CORNERS ) {
		CG_Error( "Maximum path_corners hit\n" );
		return;
	}

	BG_AddPathCorner( targetname, origin );
}
Ejemplo n.º 27
0
void CG_ParticleExplosion(char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd, qboolean dlight) {
	cparticle_t *p;
	int         anim;

	// find the animation string
	for (anim = 0; shaderAnimNames[anim]; anim++) {
		if (!Q_stricmp(animStr, shaderAnimNames[anim])) {
			break;
		}
	}
	if (!shaderAnimNames[anim]) {
		CG_Error("CG_ParticleExplosion: unknown animation string: %s\n", animStr);
		return;
	}

	if (!free_particles) {
		return;
	}
	p                = free_particles;
	free_particles   = p->next;
	p->next          = active_particles;
	active_particles = p;
	p->time          = cg.time;
	p->alpha         = 1.0;
	p->alphavel      = 0;

	if (duration < 0) {
		duration *= -1;
		p->roll   = 0;
	} else {
		p->roll = crandom() * 179;
	}

	p->shaderAnim = anim;

	p->width  = sizeStart;
	p->height = sizeStart * shaderAnimSTRatio[anim];  // for sprites that are stretch in either direction

	p->endheight = sizeEnd;
	p->endwidth  = sizeEnd * shaderAnimSTRatio[anim];

	p->endtime = cg.time + duration;

	// ydnar
	if (dlight) {
		p->type = P_DLIGHT_ANIM;
	} else {
		p->type = P_ANIM;
	}

	VectorCopy(origin, p->org);
	VectorCopy(vel, p->vel);
	VectorClear(p->accel);

}
Ejemplo n.º 28
0
/*
* CG_DemocamInit
*/
void CG_DemocamInit( void )
{
	int name_size;
	bool hassoundstream = false;
	democam_editing_mode = false;
	demo_initial_timestamp = 0;

	if( !cgs.demoPlaying )
		return;

	if( !*cgs.demoName )
		CG_Error( "CG_LoadRecamScriptFile: no demo name string\n" );

	// see if there is any script for this demo, and load it
	name_size = sizeof( char ) * ( strlen( cgs.demoName ) + strlen( ".cam" ) + 1 );
	demoscriptname = ( char * )CG_Malloc( name_size );
	Q_snprintfz( demoscriptname, name_size, "%s", cgs.demoName );
	COM_ReplaceExtension( demoscriptname, ".cam", name_size );

	CG_Printf( "cam: %s\n", demoscriptname );

	// add console commands
	trap_Cmd_AddCommand( "demoEditMode", CG_DemoEditMode_Cmd_f );
	trap_Cmd_AddCommand( "demoFreeFly", CG_DemoFreeFly_Cmd_f );
	trap_Cmd_AddCommand( "camswitch", CG_CamSwitch_Cmd_f );

	if( CG_LoadRecamScriptFile( demoscriptname ) )
	{
		CG_Printf( "Loaded demo cam script\n" );
	}

	// check for a sound stream file
	cgs.demoAudioStream = ( char * )CG_Malloc( name_size );
	Q_snprintfz( cgs.demoAudioStream, name_size, "%s", cgs.demoName );
	COM_ReplaceExtension( cgs.demoAudioStream, ".wav", name_size );
	if( trap_FS_FOpenFile( cgs.demoAudioStream, NULL, FS_READ ) != -1 )
	{
		hassoundstream = true;
	}
	else
	{
		COM_ReplaceExtension( cgs.demoAudioStream, ".ogg", name_size );
		if( trap_FS_FOpenFile( cgs.demoAudioStream, NULL, FS_READ ) != -1 )
		{
			hassoundstream = true;
		}
	}

	if( !hassoundstream )
	{
		CG_Free( cgs.demoAudioStream );
		cgs.demoAudioStream = NULL;
	}
}
Ejemplo n.º 29
0
void SP_worldspawn( void ) {
	char *s;

	CG_SpawnString( "classname", "", &s );
	if( Q_stricmp( s, "worldspawn" ) ) {
		CG_Error( "SP_worldspawn: The first entity isn't 'worldspawn'" );
	}

	CG_SpawnFloat( "fogstart", "0", &cg_linearFogOverride );
	CG_SpawnFloat( "radarrange", "2500", &cg_radarRange );
}
Ejemplo n.º 30
0
/*
====================
CG_MakeExplosion
====================
*/
localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, 
								qhandle_t hModel, qhandle_t shader,
								int msec, qboolean isSprite ) {
	float			ang;
	localEntity_t	*ex;
	int				offset;
	vec3_t			tmpVec, newOrigin;

	if ( msec <= 0 ) {
		CG_Error( "CG_MakeExplosion: msec = %i", msec );
	}

	// skew the time a bit so they aren't all in sync
	offset = rand() & 63;

	ex = CG_AllocLocalEntity();
	if ( isSprite ) {
		ex->leType = LE_SPRITE_EXPLOSION;

		// randomly rotate sprite orientation
		ex->refEntity.rotation = rand() % 360;
		VectorScale( dir, 16, tmpVec );
		VectorAdd( tmpVec, origin, newOrigin );
	} else {
		ex->leType = LE_EXPLOSION;
		VectorCopy( origin, newOrigin );

		// set axis with random rotate
		if ( !dir ) {
			AxisClear( ex->refEntity.axis );
		} else {
			ang = rand() % 360;
			VectorCopy( dir, ex->refEntity.axis[0] );
			RotateAroundDirection( ex->refEntity.axis, ang );
		}
	}

	ex->startTime = cg.time - offset;
	ex->endTime = ex->startTime + msec;

	// bias the time so all shader effects start correctly
	ex->refEntity.shaderTime = ex->startTime / 1000.0f;

	ex->refEntity.hModel = hModel;
	ex->refEntity.customShader = shader;

	// set origin
	VectorCopy( newOrigin, ex->refEntity.origin );
	VectorCopy( newOrigin, ex->refEntity.oldorigin );

	ex->color[0] = ex->color[1] = ex->color[2] = 1.0;

	return ex;
}