mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
Allow _extra_ents.map files next to the map files
This commit is contained in:
parent
e1db32fe30
commit
77f8031eb9
4 changed files with 126 additions and 8 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2014-2016 Robert Beckebans
|
||||
Copyright (C) 2014-2021 Robert Beckebans
|
||||
Copyright (C) 2014-2016 Kot in Action Creative Artel
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
@ -1271,12 +1271,10 @@ void idGameLocal::PopulateEnvironmentProbes()
|
|||
|
||||
for( ent = spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() )
|
||||
{
|
||||
if( !ent->IsType( EnvironmentProbe::Type ) )
|
||||
if( ent->IsType( EnvironmentProbe::Type ) )
|
||||
{
|
||||
continue;
|
||||
numEnvprobes++;
|
||||
}
|
||||
|
||||
numEnvprobes++;
|
||||
}
|
||||
|
||||
if( numEnvprobes > 0 )
|
||||
|
@ -1300,6 +1298,7 @@ void idGameLocal::PopulateEnvironmentProbes()
|
|||
idBounds areaBounds = gameRenderWorld->AreaBounds( i );
|
||||
|
||||
idVec3 point = areaBounds.GetCenter();
|
||||
point.SnapInt();
|
||||
|
||||
int areaNum = gameRenderWorld->PointInArea( point );
|
||||
if( areaNum < 0 )
|
||||
|
@ -1313,7 +1312,7 @@ void idGameLocal::PopulateEnvironmentProbes()
|
|||
args.Set( "origin", point.ToString() );
|
||||
|
||||
idStr name; //= gameEdit->GetUniqueEntityName( "env_probe_generated" );
|
||||
name.Format( "env_probe_generated%i", i );
|
||||
name.Format( "env_probe_generated_area_%i_pos_%i_%i_%i", i, int( point.x ), int( point.y ), int( point.z ) );
|
||||
args.Set( "name", name );
|
||||
|
||||
gameLocal.SpawnEntityDef( args, &ent );
|
||||
|
|
|
@ -944,6 +944,14 @@ void Cmd_Spawn_f( const idCmdArgs& args )
|
|||
dict.Set( "angle", va( "%f", yaw + 180 ) );
|
||||
|
||||
org = player->GetPhysics()->GetOrigin() + idAngles( 0, yaw, 0 ).ToForward() * 80 + idVec3( 0, 0, 1 );
|
||||
|
||||
// RB: put env_probes a bit higher
|
||||
if( idStr::Icmp( value, "env_probe" ) == 0 )
|
||||
{
|
||||
//org.z = 64;
|
||||
org.SnapInt();
|
||||
}
|
||||
|
||||
dict.Set( "origin", org.ToString() );
|
||||
|
||||
for( i = 2; i < args.Argc() - 1; i += 2 )
|
||||
|
@ -2180,6 +2188,68 @@ static void Cmd_SaveLights_f( const idCmdArgs& args )
|
|||
}
|
||||
|
||||
|
||||
// RB begin
|
||||
/*
|
||||
==================
|
||||
Cmd_SaveEnvprobes_f
|
||||
==================
|
||||
*/
|
||||
static void Cmd_SaveEnvprobes_f( const idCmdArgs& args )
|
||||
{
|
||||
int e;
|
||||
EnvironmentProbe* envProbe = NULL;
|
||||
idMapEntity* mapEnt = NULL;
|
||||
idMapFile* mapFile = gameLocal.GetLevelMap();
|
||||
idDict dict;
|
||||
idStr mapName;
|
||||
idMapFile mapExportFile;
|
||||
const char* name = NULL;
|
||||
|
||||
if( !gameLocal.CheatsOk() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( args.Argc() > 1 )
|
||||
{
|
||||
mapName = args.Argv( 1 );
|
||||
mapName = "maps/" + mapName;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapName = mapFile->GetName();
|
||||
}
|
||||
|
||||
mapName += "_extra_ents.map";
|
||||
|
||||
for( e = 0; e < MAX_GENTITIES; e++ )
|
||||
{
|
||||
envProbe = static_cast<EnvironmentProbe*>( gameLocal.entities[ e ] );
|
||||
|
||||
if( !envProbe || !envProbe->IsType( EnvironmentProbe::Type ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
dict.Clear();
|
||||
envProbe->SaveState( &dict );
|
||||
|
||||
mapEnt = new( TAG_SYSTEM ) idMapEntity();
|
||||
mapExportFile.AddEntity( mapEnt );
|
||||
|
||||
envProbe->name = name;
|
||||
mapEnt->epairs.Set( "classname", envProbe->GetEntityDefName() );
|
||||
mapEnt->epairs.Set( "name", envProbe->name );
|
||||
|
||||
// save the env probes state
|
||||
mapEnt->epairs.Copy( dict );
|
||||
}
|
||||
|
||||
// write out the map file
|
||||
mapExportFile.Write( mapName, ".map" );
|
||||
}
|
||||
// RB end
|
||||
|
||||
/*
|
||||
==================
|
||||
Cmd_SaveParticles_f
|
||||
|
@ -2740,6 +2810,7 @@ void idGameLocal::InitConsoleCommands()
|
|||
// RB begin
|
||||
cmdSystem->AddCommand( "exportScriptEvents", idClass::ExportScriptEvents_f, CMD_FL_GAME | CMD_FL_TOOL, "update script/doom_events.script" );
|
||||
cmdSystem->AddCommand( "editLights", idClass::EditLights_f, CMD_FL_GAME | CMD_FL_TOOL, "launches the in-game Light Editor" );
|
||||
cmdSystem->AddCommand( "saveEnvprobes", Cmd_SaveEnvprobes_f, CMD_FL_GAME | CMD_FL_CHEAT, "saves all autogenerated env_probes to a .extras_env_probes.map file" );
|
||||
// RB end
|
||||
|
||||
// multiplayer client commands ( replaces old impulses stuff )
|
||||
|
|
|
@ -1383,6 +1383,7 @@ bool idMapFile::Parse( const char* filename, bool ignoreRegion, bool osPath )
|
|||
|
||||
name = filename;
|
||||
name.StripFileExtension();
|
||||
name.StripFileExtension(); // RB: there might be .map.map
|
||||
fullName = name;
|
||||
hasPrimitiveData = false;
|
||||
|
||||
|
@ -1586,6 +1587,46 @@ bool idMapFile::Parse( const char* filename, bool ignoreRegion, bool osPath )
|
|||
}
|
||||
}
|
||||
|
||||
// RB: <name>_extraents.map allows to add and override existing entities
|
||||
idMapFile extrasMap;
|
||||
fullName = name;
|
||||
//fullName.StripFileExtension();
|
||||
fullName += "_extra_ents.map";
|
||||
|
||||
if( extrasMap.Parse( fullName, ignoreRegion, osPath ) )
|
||||
{
|
||||
for( i = 0; i < extrasMap.entities.Num(); i++ )
|
||||
{
|
||||
idMapEntity* extraEnt = extrasMap.entities[i];
|
||||
|
||||
const idKeyValue* kv = extraEnt->epairs.FindKey( "name" );
|
||||
if( kv && kv->GetValue().Length() )
|
||||
{
|
||||
mapEnt = FindEntity( kv->GetValue().c_str() );
|
||||
if( mapEnt )
|
||||
{
|
||||
// TODO override settings
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
mapEnt = new( TAG_SYSTEM ) idMapEntity();
|
||||
entities.Append( mapEnt );
|
||||
|
||||
// don't grab brushes or polys
|
||||
mapEnt->epairs.Copy( extraEnt->epairs );
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
fullName = name;
|
||||
fullName += "_extra_debug.map";
|
||||
|
||||
Write( fullName, ".map" );
|
||||
#endif
|
||||
}
|
||||
|
||||
hasPrimitiveData = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -782,8 +782,15 @@ void R_DeriveEnvprobeData( RenderEnvprobeLocal* probe )
|
|||
// cull the envprobe if it is behind a closed door
|
||||
int areaNum = probe->world->PointInArea( probe->parms.origin );
|
||||
|
||||
// HACK: this should be in the gamecode and set by the entity properties
|
||||
probe->globalProbeBounds = probe->world->AreaBounds( areaNum );
|
||||
if( areaNum != -1 )
|
||||
{
|
||||
// HACK: this should be in the gamecode and set by the entity properties
|
||||
probe->globalProbeBounds = probe->world->AreaBounds( areaNum );
|
||||
}
|
||||
else
|
||||
{
|
||||
probe->globalProbeBounds.Clear();
|
||||
}
|
||||
|
||||
idMat3 axis;
|
||||
axis.Identity();
|
||||
|
|
Loading…
Reference in a new issue