예제 #1
0
/*
============
idAAS::Alloc
============
*/
idAAS *idAAS::Alloc( void ) {
// RAVEN BEGIN
// jnewquist: Tag scope and callees to track allocations using "new".
	MEM_SCOPED_TAG(tag,MA_AAS);
// RAVEN END
	return new idAASLocal;
}
예제 #2
0
/*
================
idDict::TransferKeyValues

  clear existing key/value pairs and transfer key/value pairs from other
================
*/
void idDict::TransferKeyValues( idDict &other ) {
	int i, n;
// RAVEN BEGIN
// jnewquist: Tag scope and callees to track allocations using "new".
	MEM_SCOPED_TAG(tag,MA_STRING);
// RAVEN END

	if ( this == &other ) {
		return;
	}

	if ( other.args.Num() && other.args[0].key->GetPool() != &globalKeys ) {
		common->FatalError( "idDict::TransferKeyValues: can't transfer values across a DLL boundary" );
		return;
	}

	Clear();

	n = other.args.Num();
	args.SetNum( n );
	for ( i = 0; i < n; i++ ) {
		args[i].key = other.args[i].key;
		args[i].value = other.args[i].value;
	}
	argHash = other.argHash;

	other.args.Clear();
	other.argHash.Free();
}
예제 #3
0
파일: Class.cpp 프로젝트: ET-NiK/amxxgroup
/*
================
idClass::Init

Should be called after all idTypeInfos are initialized, so must be called
manually upon game code initialization.  Tells all the idTypeInfos to initialize
their event callback table for the associated class.  This should only be called
once during the execution of the program or DLL.
================
*/
void idClass::Init( void ) {
	idTypeInfo	*c;
	int			num;
// RAVEN BEGIN
// jnewquist: Tag scope and callees to track allocations using "new".
	MEM_SCOPED_TAG(tag,MA_CLASS);
// RAVEN END

	gameLocal.Printf( "Initializing class hierarchy\n" );

	if ( initialized ) {
		gameLocal.Printf( "...already initialized\n" );
		return;
	}

	// init the event callback tables for all the classes
	for( c = typelist; c != NULL; c = c->next ) {
// RAVEN BEGIN
// jnewquist: Make sure the superclass was actually registered!
		if ( c->super == NULL && (c->superclass && idStr::Cmp(c->superclass, "NULL")) ) {
			common->Error("Superclass %s of %s was never registered!", c->superclass, c->classname);
		}		
// RAVEN END
		c->Init();
	}

	// number the types according to the class hierarchy so we can quickly determine if a class
	// is a subclass of another
	num = 0;
	for( c = classHierarchy.GetNext(); c != NULL; c = c->node.GetNext(), num++ ) {
        c->typeNum = num;
		c->lastChild += num;
	}

	// number of bits needed to send types over network
	typeNumBits = idMath::BitsForInteger( num );

	// create a list of the types so we can do quick lookups
	// one list in alphabetical order, one in typenum order
	types.SetGranularity( 1 );
	types.SetNum( num );
	typenums.SetGranularity( 1 );
	typenums.SetNum( num );
	num = 0;
	for( c = typelist; c != NULL; c = c->next, num++ ) {
		types[ num ] = c;
		typenums[ c->typeNum ] = c;
	}

	initialized = true;

	gameLocal.Printf( "...%i classes, %i bytes for event callbacks\n", types.Num(), eventCallbackMemory );
}
예제 #4
0
/*
================
idDict::Set
================
*/
void idDict::Set( const char *key, const char *value ) {
	int i;
	idKeyValue kv;
// RAVEN BEGIN
// jnewquist: Tag scope and callees to track allocations using "new".
	MEM_SCOPED_TAG(tag,MA_STRING);
// RAVEN END

	if ( key == NULL || key[0] == '\0' ) {
		return;
	}

	i = FindKeyIndex( key );
	if ( i != -1 ) {
		// first set the new value and then free the old value to allow proper self copying
		const idPoolStr *oldValue = args[i].value;
		args[i].value = globalValues.AllocString( value );
		globalValues.FreeString( oldValue );
	} else {
		kv.key = globalKeys.AllocString( key );
		kv.value = globalValues.AllocString( value );
		argHash.Add( argHash.GenerateKey( kv.GetKey(), false ), args.Append( kv ) );
	}
}
예제 #5
0
/*
================
idDict::operator=

  clear existing key/value pairs and copy all key/value pairs from other
================
*/
idDict &idDict::operator=( const idDict &other ) {
	int i;
// RAVEN BEGIN
// jnewquist: Tag scope and callees to track allocations using "new".
	MEM_SCOPED_TAG(tag,MA_STRING);
// RAVEN END

	// check for assignment to self
	if ( this == &other ) {
		return *this;
	}

	Clear();

	args = other.args;
	argHash = other.argHash;

	for ( i = 0; i < args.Num(); i++ ) {
		args[i].key = globalKeys.CopyString( args[i].key );
		args[i].value = globalValues.CopyString( args[i].value );
	}

	return *this;
}
예제 #6
0
/*
================
rvClientEffect::Think
================
*/
void rvClientEffect::Think ( void ) {
	// If we are bound to an entity that is now hidden we can just not render if looping, otherwise stop the effect
	if( bindMaster && (bindMaster->GetRenderEntity()->hModel && bindMaster->GetModelDefHandle() == -1) ) {
		if ( renderEffect.loop ) {		
			return;
		}
		Stop ( );
	}

// RAVEN BEGIN
// jnewquist: Tag scope and callees to track allocations using "new".
	MEM_SCOPED_TAG(tag,MA_EFFECT);
// RAVEN END
	// If there is a valid effect handle and we havent started playing
	// and effect yet then see if its time
	if( effectDefHandle < 0 && renderEffect.declEffect ) {
		if( renderEffect.startTime >= 0.0f ) {
			// Make sure our origins are all straight before starting the effect
			UpdateBind();
			renderEffect.attenuation = 1.0f;
			
			// if the rendereffect needs sound give it an emitter.
			if( renderEffect.referenceSoundHandle <= 0 )	{ 
				if( gameRenderWorld->EffectDefHasSound( &renderEffect) )
				{
					renderEffect.referenceSoundHandle = soundSystem->AllocSoundEmitter( SOUNDWORLD_GAME );
				} else {
					renderEffect.referenceSoundHandle = -1;
				}
			}
			// Add the render effect
			effectDefHandle = gameRenderWorld->AddEffectDef( &renderEffect, gameLocal.time );
			if ( effectDefHandle < 0 ) {
				PostEventMS( &EV_Remove, 0 );
			}
		}
		
		return;
	} 

	// If we lost our effect def handle then just remove ourself
	if( effectDefHandle < 0 ) {
		PostEventMS ( &EV_Remove, 0 );
		return;
	}

	// Dont do anything else if its not a new client frame
	if( !gameLocal.isNewFrame ) {
		return;
	}

	// Check to see if the player can possibly see the effect or not
	renderEffect.inConnectedArea = true;
	if( bindMaster ) {
		renderEffect.inConnectedArea = gameLocal.InPlayerConnectedArea( bindMaster );
	}

	// Update the bind	
	UpdateBind();

	// Update the actual render effect now
	if( gameRenderWorld->UpdateEffectDef( effectDefHandle, &renderEffect, gameLocal.time ) ) {
		FreeEffectDef ( );
		PostEventMS( &EV_Remove, 0 );
		return;
	}
}