Example #1
0
void G_SpawnEntitiesFromString( void )
{
	int             i;

	// the worldspawn is not an actual entity, but it still
	// has a "spawn" function to perform any global setup
	// needed by a level (setting configstrings or cvars, etc)
	if ( !G_ParseSpawnVars() )
	{
		G_Error( "SpawnEntities: no entities" );
	}
	self = world;
	for ( i = 0; i < numSpawnVars; i++ )
	{
		G_ParseField( spawnVars[i][0], spawnVars[i][1], world );
	}

	SP_worldspawn( world );

	// parse ents

	while ( G_ParseSpawnVars() )
	{
		G_SpawnGEntityFromSpawnVars();
		trap_FlushSignon();
	}
}
Example #2
0
/*
==============
G_SpawnEntitiesFromString

Parses textual entity definitions out of an entstring and spawns gentities.
==============
*/
void G_SpawnEntitiesFromString(void)
{
	// allow calls to G_Spawn*()
	G_Printf("Enable spawning!\n");
	level.spawning     = qtrue;
	level.numSpawnVars = 0;

	// the worldspawn is not an actual entity, but it still
	// has a "spawn" function to perform any global setup
	// needed by a level (setting configstrings or cvars, etc)
	if (!G_ParseSpawnVars())
	{
		G_Error("SpawnEntities: no entities\n");
	}
	SP_worldspawn();

	// parse ents
	while (G_ParseSpawnVars())
	{
		G_SpawnGEntityFromSpawnVars();
	}

#ifdef FEATURE_LUA
	G_LuaHook_SpawnEntitiesFromString();
#endif

	G_Printf("Disable spawning!\n");
	level.spawning = qfalse;            // any future calls to G_Spawn*() will be errors
}
Example #3
0
void Svcmd_AddEntity_f( void ) {
	int				len;
	fileHandle_t	f;
	char			entity[MAX_TOKEN_CHARS];

	// resource
	trap_Argv( 1, entity, sizeof( entity ) );
	if ( !entity[0] ) {
		G_Printf( S_COLOR_YELLOW "Usage: Addentity <entity>\n" );
		return;
	}

	G_Printf( S_COLOR_CYAN "Adding entity %s\n", entity );

	len = trap_FS_FOpenFile( entity, &f, FS_READ );
	if (!len) {
		G_Printf( S_COLOR_RED "Error: empty entity\n" );
		trap_FS_FCloseFile(f);
		return;
	} else if (len>=sizeof(entity)) {
		G_Printf( S_COLOR_RED "Error: too big entity\n" );
		trap_FS_FCloseFile(f);
		return;
	}

	trap_FS_Read( entity, len, f );
	entity[len]=0;
	trap_FS_FCloseFile(f);

	if ( !G_ParseSpawnString( entity ) ) {
		G_Printf( S_COLOR_RED "Error: no entity found\n" );
	} else {
		G_SpawnGEntityFromSpawnVars();
	}
}
Example #4
0
/*
==============
G_SpawnEntitiesFromString

Parses textual entity definitions out of an entstring and spawns gentities.
==============
*/
void G_SpawnEntitiesFromString( qboolean inSubBSP ) {
	// allow calls to G_Spawn*()
	level.spawning = qtrue;
	level.numSpawnVars = 0;

	// the worldspawn is not an actual entity, but it still
	// has a "spawn" function to perform any global setup
	// needed by a level (setting configstrings or cvars, etc)
	if ( !G_ParseSpawnVars(qfalse) ) {
		trap->Error( ERR_DROP, "SpawnEntities: no entities" );
	}

	if (!inSubBSP)
	{
		SP_worldspawn();
	}
	else
	{
		// Skip this guy if its worldspawn fails
		if ( !SP_bsp_worldspawn() )
		{
			return;
		}
	}

	// parse ents
	while( G_ParseSpawnVars(inSubBSP) ) {
		G_SpawnGEntityFromSpawnVars(inSubBSP);
	}

	if( g_entities[ENTITYNUM_WORLD].behaviorSet[BSET_SPAWN] && g_entities[ENTITYNUM_WORLD].behaviorSet[BSET_SPAWN][0] )
	{//World has a spawn script, but we don't want the world in ICARUS and running scripts,
		//so make a scriptrunner and start it going.
		gentity_t *script_runner = G_Spawn();
		if ( script_runner )
		{
			script_runner->behaviorSet[BSET_USE] = g_entities[ENTITYNUM_WORLD].behaviorSet[BSET_SPAWN];
			script_runner->count = 1;
			script_runner->think = scriptrunner_run;
			script_runner->nextthink = level.time + 100;

			if ( script_runner->inuse )
			{
				trap->ICARUS_InitEnt( (sharedEntity_t *)script_runner );
			}
		}
	}

	if (!inSubBSP)
	{
		level.spawning = qfalse;			// any future calls to G_Spawn*() will be errors
	}

	G_LinkLocations();

	G_PrecacheSoundsets();
}
Example #5
0
/*
==============
G_SpawnEntitiesFromString

Parses textual entity definitions out of an entstring and spawns gentities.
==============
 */
void G_SpawnEntitiesFromString(void) {
  // allow calls to G_Spawn*()
  level.spawning = qtrue;
  level.numSpawnVars = 0;

  // the worldspawn is not an actual entity, but it still
  // has a "spawn" function to perform any global setup
  // needed by a level (setting configstrings or cvars, etc)
  if (!G_ParseSpawnVars())
    G_Error("SpawnEntities: no entities");

  SP_worldspawn();

  // parse ents
  while (G_ParseSpawnVars())
    G_SpawnGEntityFromSpawnVars();

  level.spawning = qfalse; // any future calls to G_Spawn*() will be errors
}
Example #6
0
/*
==============
G_SpawnEntitiesFromString

Parses textual entity definitions out of an entstring and spawns gentities.
==============
*/
void G_SpawnEntitiesFromString( void )
{
	level.numSpawnVars = 0;

	// the worldspawn is not an actual entity, but it still
	// has a "spawn" function to perform any global setup
	// needed by a level (setting configstrings or cvars, etc)
	if ( !G_ParseSpawnVars() )
	{
		G_Error( "SpawnEntities: no entities" );
	}

	SP_worldspawn();

	// parse ents
	while ( G_ParseSpawnVars() )
	{
		G_SpawnGEntityFromSpawnVars();
	}
}
Example #7
0
/*
==============
G_SpawnEntitiesFromString

Parses textual entity definitions out of an entstring and spawns gentities.
==============
*/
void G_SpawnEntitiesFromString( bool inSubBSP ) 
{
	// allow calls to G_Spawn*()
	level.spawning = true;
	level.numSpawnVars = 0;

	// the worldspawn is not an actual entity, but it still
	// has a "spawn" function to perform any global setup
	// needed by a level (setting configstrings or cvars, etc)
	if ( !G_ParseSpawnVars(inSubBSP) ) 
	{
		Com_Error( ERR_FATAL, "SpawnEntities: no entities" );
	}
	
	if (!inSubBSP)
	{
		SP_worldspawn();
	}
	else
	{
		// Skip this guy if its worldspawn fails
		if ( !SP_bsp_worldspawn() )
		{
			return;
		}
	}

	// parse ents
	while( G_ParseSpawnVars(inSubBSP) ) 
	{
		G_SpawnGEntityFromSpawnVars(inSubBSP);
	}	

	if (!inSubBSP)
	{
		level.spawning = false;			// any future calls to G_Spawn*() will be errors
	}
}