/* ============== 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(); }
/* ============== 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 } }
/*QUAKED worldspawn (0 0 0) ? Every map should have exactly one worldspawn. "music" music wav file "soundSet" soundset name to use (do not combine with 'noise', ignores all other flags) "gravity" 800 is default gravity "message" Text to print during connection process "mission" Indicates which mission script file should be used to find the scripts for mission mode */ void SP_worldspawn( void ) { char *text, temp[32]; int i; int lengthRed, lengthBlue, lengthGreen; G_SpawnString( "classname", "", &text ); if ( strcmp( text, "worldspawn" ) ) { Com_Error( ERR_FATAL, "SP_worldspawn: The first entity isn't 'worldspawn'" ); } // make some data visible to connecting client trap_SetConfigstring( CS_GAME_VERSION, GAME_VERSION ); trap_SetConfigstring( CS_LEVEL_START_TIME, va("%i", level.startTime ) ); G_SpawnString( "music", "", &text ); trap_SetConfigstring( CS_MUSIC, text ); if (G_SpawnString( "soundSet", "", &text ) ) { trap_SetConfigstring(CS_AMBIENT_SOUNDSETS, text ); } if ( level.gametypeData->teams ) { G_SpawnString( "redteam", "", &text ); if ( text && *text ) { level.gametypeTeam[TEAM_RED] = trap_VM_LocalStringAlloc ( text ); } G_SpawnString( "blueteam", "", &text ); if ( text && *text ) { level.gametypeTeam[TEAM_BLUE] = trap_VM_LocalStringAlloc ( text ); } if ( !level.gametypeTeam[TEAM_RED] || !level.gametypeTeam[TEAM_BLUE] ) { level.gametypeTeam[TEAM_RED] = "marine"; level.gametypeTeam[TEAM_BLUE] = "thug"; } trap_SetConfigstring( CS_GAMETYPE_REDTEAM, level.gametypeTeam[TEAM_RED] ); trap_SetConfigstring( CS_GAMETYPE_BLUETEAM, level.gametypeTeam[TEAM_BLUE] ); } G_SpawnString( "message", "", &text ); trap_SetConfigstring( CS_MESSAGE, text ); // map specific message trap_SetConfigstring( CS_MOTD, g_motd.string ); // message of the day G_SpawnString( "gravity", "800", &text ); trap_Cvar_Set( "g_gravity", text ); // Handle all the worldspawn stuff common to both main bsp and sub bsp SP_bsp_worldspawn ( ); g_entities[ENTITYNUM_WORLD].s.number = ENTITYNUM_WORLD; g_entities[ENTITYNUM_WORLD].classname = "worldspawn"; // see if we want a warmup time trap_SetConfigstring( CS_WARMUP, "" ); if ( g_restarted.integer ) { trap_Cvar_Set( "g_restarted", "0" ); level.warmupTime = 0; } else if ( g_doWarmup.integer ) { // Turn it on level.warmupTime = -1; trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) ); G_LogPrintf( "Warmup:\n" ); } trap_SetConfigstring(CS_LIGHT_STYLES+(LS_STYLES_START*3)+0, defaultStyles[0][0]); trap_SetConfigstring(CS_LIGHT_STYLES+(LS_STYLES_START*3)+1, defaultStyles[0][1]); trap_SetConfigstring(CS_LIGHT_STYLES+(LS_STYLES_START*3)+2, defaultStyles[0][2]); for(i=1;i<LS_NUM_STYLES;i++) { sprintf_s(temp, sizeof(temp), "ls_%dr", i); G_SpawnString(temp, defaultStyles[i][0], &text); lengthRed = strlen(text); trap_SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+0, text); sprintf_s(temp, sizeof(temp), "ls_%dg", i); G_SpawnString(temp, defaultStyles[i][1], &text); lengthGreen = strlen(text); trap_SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+1, text); sprintf_s(temp, sizeof(temp), "ls_%db", i); G_SpawnString(temp, defaultStyles[i][2], &text); lengthBlue = strlen(text); trap_SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+2, text); if (lengthRed != lengthGreen || lengthGreen != lengthBlue) { Com_Error(ERR_DROP, "Style %d has inconsistent lengths: R %d, G %d, B %d", i, lengthRed, lengthGreen, lengthBlue); } } }