Exemple #1
0
// Create/Allocate a new Animal Vehicle (initializing it as well).
//this is a BG function too in MP so don't un-bg-compatibilify it -rww
void G_CreateWalkerNPC( Vehicle_t **pVeh, const char *strAnimalType ) {
	// Allocate the Vehicle.
#ifdef PROJECT_GAME
	//these will remain on entities on the client once allocated because the pointer is
	//never stomped. on the server, however, when an ent is freed, the entity struct is
	//memset to 0, so this memory would be lost..
	G_AllocateVehicleObject( pVeh );
#else
	if ( !*pVeh ) { //only allocate a new one if we really have to
		(*pVeh) = (Vehicle_t *)BG_Alloc( sizeof(Vehicle_t) );
	}
#endif
	memset( *pVeh, 0, sizeof(Vehicle_t) );
	(*pVeh)->m_pVehicleInfo = &g_vehicleInfo[BG_VehicleGetIndex( strAnimalType )];
}
void G_CreateAnimalNPC( Vehicle_t **pVeh, const char *strAnimalType )
{
	// Allocate the Vehicle.
	if( mod == moduleType::game ) {
		//these will remain on entities on the client once allocated because the pointer is
		//never stomped. on the server, however, when an ent is freed, the entity struct is
		//memset to 0, so this memory would be lost..
		G_AllocateVehicleObject( pVeh );
	} else {
		if( !*pVeh ) { //only allocate a new one if we really have to
			( *pVeh ) = (Vehicle_t *)BG_Alloc< moduleType::game >( sizeof( Vehicle_t ) );
		}
	}
	memset(*pVeh, 0, sizeof(Vehicle_t));
	(*pVeh)->m_pVehicleInfo = &g_vehicleInfo[BG_VehicleGetIndex< moduleType::game >( strAnimalType )];
}