S PreserveEnts: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(p2 preserves ents in MP mode)
mNo edit summary
Line 1: Line 1:
{{DISPLAYTITLE:s_PreserveEnts}}
{{lang|S PreserveEnts|title=S_PreserveEnts}}
{{lang|S_PreserveEnts}}
{{stub}}
{{stub}}
In multiplayer Source games, during a round reset, all entities are resetted to their defaults by being deleted then respawned, unless their current classnames matches an entry in the whitelist '''s_PreserveEnts'''. Whitelisted entities either has special code to handle the resetting process, and isn't ideal to be deleted.
In multiplayer {{source|4}} games, during a round reset, all entities are resetted to their defaults by being deleted then respawned, unless their current classnames matches an entry in the whitelist {{ent|s_PreserveEnts}}. Whitelisted entities either has special code to handle the resetting process, and isn't ideal to be deleted.


Some whitelist entities however don't account round resets properly with their new behavior, so when a round reset occurs, their properties are carried over from the last round, like their [[origin]]s.
Some whitelist entities however don't account round resets properly with their new behavior, so when a round reset occurs, their properties are carried over from the last round, like their [[Coordinates|origins]].


{{todo|Attempt to finish this table. Some games might not have any way to reset the round (even through<code>mp_forcewin</code>or<code>mp_restartgame</code>commands).}}
{{todo|Attempt to finish this table. Some games might not have any way to reset the round (even through <code>mp_forcewin</code> or <code>mp_restartgame</code> commands).}}
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 16: Line 15:
!{{hl2}}
!{{hl2}}
!{{hl2dm}}
!{{hl2dm}}
!{{ep1}}
!{{hl2ep1}}
!{{ep2}}
!{{hl2ep2}}
!{{l4d}}
!{{l4d}}
!{{l4d2}}
!{{l4d2}}
Line 40: Line 39:
|}
|}


== Source Code ==
==Source Code==
==={{hl2dm|4}}===
==={{hl2dm|4}}===
{{Expand|title=<code>hl2mp/hl2mp_gamerules.cpp</code>|
{{Expand|title=<code>hl2mp/hl2mp_gamerules.cpp</code>|
Line 225: Line 224:
};</syntaxhighlight>}}
};</syntaxhighlight>}}


{{Expand|title=<code>tf/tf_gamerules.cpp</code>|
{{expand|title=<code>tf/tf_gamerules.cpp</code>|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
// Classnames of entities that are preserved across round restarts
// Classnames of entities that are preserved across round restarts
Line 267: Line 266:


==={{css|4}}===
==={{css|4}}===
{{Expand|title=<code>cstrike/cs_gamerules.cpp</code>|
{{expand|title=<code>cstrike/cs_gamerules.cpp</code>|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
static const char *s_PreserveEnts[] =
static const char *s_PreserveEnts[] =
Line 316: Line 315:


==={{csgo|4}}===
==={{csgo|4}}===
{{Expand|title=<code>cstrike15/cs_gamerules.cpp</code>|
{{expand|title=<code>cstrike15/cs_gamerules.cpp</code>|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
static const char *s_PreserveEnts[] =
static const char *s_PreserveEnts[] =
Line 383: Line 382:


==={{dods|4}}===
==={{dods|4}}===
{{Expand|title=<code>dod/dod_gamerules.cpp</code>|
{{expand|title=<code>dod/dod_gamerules.cpp</code>|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
static const char *s_PreserveEnts[] =
static const char *s_PreserveEnts[] =
Line 430: Line 429:


==={{as|4}}===
==={{as|4}}===
{{Expand|title=<code>swarm/asw_gamerules.cpp</code>|
{{expand|title=<code>swarm/asw_gamerules.cpp</code>|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CAlienSwarm::CAlienSwarm()
CAlienSwarm::CAlienSwarm()
Line 450: Line 449:
}}
}}


== Code Dumps ==
==Code Dumps==
=== {{l4d|4}} ===
==={{l4d|4}}===
22/07/2021 - Steps: [IDA]<br>
22/07/2021 - Steps: [IDA]<br>
1. Search for the<code>ai_network</code>string reference.<br>
1. Search for the<code>ai_network</code>string reference.<br>
2. Bring up the XREFs of the reference.<br>
2. Bring up the XREFs of the reference.<br>
3. Find the list that has both<code>survivor_bot</code>and<code>logic_versus_random</code>in it.
3. Find the list that has both<code>survivor_bot</code>and<code>logic_versus_random</code>in it.
{{Expand|
{{expand|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
; "ai_network",
; "ai_network",
Line 506: Line 505:
}}
}}


=== {{l4d2|4}} ===
==={{l4d2|4}}===
22/07/2021 - Steps: [IDA]<br>
22/07/2021 - Steps: [IDA]<br>
1. Search for the<code>ai_network</code>string reference.<br>
1. Search for the<code>ai_network</code>string reference.<br>
2. Bring up the XREFs of the reference.<br>
2. Bring up the XREFs of the reference.<br>
3. Find the list that has both<code>survivor_bot</code>and<code>logic_versus_random</code>in it.
3. Find the list that has both<code>survivor_bot</code>and<code>logic_versus_random</code>in it.
{{Expand|
{{expand|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
; "ai_network",
; "ai_network",

Revision as of 00:53, 2 December 2022

English (en)中文 (zh)Translate (Translate)

Stub

This article or section is a stub. You can help by expanding it.

In multiplayer Source Source games, during a round reset, all entities are resetted to their defaults by being deleted then respawned, unless their current classnames matches an entry in the whitelist s_PreserveEnts. Whitelisted entities either has special code to handle the resetting process, and isn't ideal to be deleted.

Some whitelist entities however don't account round resets properly with their new behavior, so when a round reset occurs, their properties are carried over from the last round, like their origins.

Todo: Attempt to finish this table. Some games might not have any way to reset the round (even through mp_forcewin or mp_restartgame commands).
Games Alien Swarm Counter-Strike: Global Offensive Counter-Strike: Source Day of Defeat: Source Half-Life 2 Half-Life 2: Deathmatch Half-Life 2: Episode One Half-Life 2: Episode Two Left 4 Dead Left 4 Dead 2 Portal Portal 2 Team Fortress 2
Has Whitelist Yes Yes Yes Yes No Yes No No Dissembler Dissembler Yes Yes Yes

Source Code

Half-Life 2: Deathmatch Half-Life 2: Deathmatch

hl2mp/hl2mp_gamerules.cpp
static const char *s_PreserveEnts[] =
{
	"ai_network",
	"ai_hint",
	"hl2mp_gamerules",
	"team_manager",
	"player_manager",
	"env_soundscape",
	"env_soundscape_proxy",
	"env_soundscape_triggerable",
	"env_sun",
	"env_wind",
	"env_fog_controller",
	"func_brush",
	"func_wall",
	"func_buyzone",
	"func_illusionary",
	"infodecal",
	"info_projecteddecal",
	"info_node",
	"info_target",
	"info_node_hint",
	"info_player_deathmatch",
	"info_player_combine",
	"info_player_rebel",
	"info_map_parameters",
	"keyframe_rope",
	"move_rope",
	"info_ladder",
	"player",
	"point_viewcontrol",
	"scene_manager",
	"shadow_control",
	"sky_camera",
	"soundent",
	"trigger_soundscape",
	"viewmodel",
	"predicted_viewmodel",
	"worldspawn",
	"point_devshot_camera",
	"", // END Marker
};

Portal Portal

portal/portal_mp_gamerules.cpp
static const char *s_PreserveEnts[] =
{
	"ai_network",
	"ai_hint",
	"hl2mp_gamerules",
	"team_manager",
	"player_manager",
	"env_soundscape",
	"env_soundscape_proxy",
	"env_soundscape_triggerable",
	"env_sun",
	"env_wind",
	"env_fog_controller",
	"func_brush",
	"func_wall",
	"func_buyzone",
	"func_illusionary",
	"infodecal",
	"info_projecteddecal",
	"info_node",
	"info_target",
	"info_node_hint",
	"info_player_deathmatch",
	"info_player_combine",
	"info_player_rebel",
	"info_map_parameters",
	"keyframe_rope",
	"move_rope",
	"info_ladder",
	"player",
	"point_viewcontrol",
	"scene_manager",
	"shadow_control",
	"sky_camera",
	"soundent",
	"trigger_soundscape",
	"viewmodel",
	"predicted_viewmodel",
	"worldspawn",
	"point_devshot_camera",
	"", // END Marker
};

Portal 2 Portal 2

portal/portal_mp_gamerules.cpp
static const char *s_PreserveEnts[] =
{
	"ai_network",
		"ai_hint",
		"hl2mp_gamerules",
		"team_manager",
		"player_manager",
		"env_soundscape",
		"env_soundscape_proxy",
		"env_soundscape_triggerable",
		"env_sun",
		"env_wind",
		"env_fog_controller",
		"func_brush",
		"func_wall",
		"func_buyzone",
		"func_illusionary",
		"infodecal",
		"info_projecteddecal",
		"info_node",
		"info_target",
		"info_node_hint",
		"info_player_deathmatch",
		"info_player_combine",
		"info_player_rebel",
		"info_map_parameters",
		"keyframe_rope",
		"move_rope",
		"info_ladder",
		"player",
		"point_viewcontrol",
		"scene_manager",
		"shadow_control",
		"sky_camera",
		"soundent",
		"trigger_soundscape",
		"viewmodel",
		"predicted_viewmodel",
		"worldspawn",
		"point_devshot_camera",
		"", // END Marker
};

Team Fortress 2 Team Fortress 2

teamplayroundbased_gamerules.cpp
// Classnames of entities that are preserved across round restarts
static const char *s_PreserveEnts[] =
{
	"player",
	"viewmodel",
	"worldspawn",
	"soundent",
	"ai_network",
	"ai_hint",
	"env_soundscape",
	"env_soundscape_proxy",
	"env_soundscape_triggerable",
	"env_sprite",
	"env_sun",
	"env_wind",
	"env_fog_controller",
	"func_wall",
	"func_illusionary",
	"info_node",
	"info_target",
	"info_node_hint",
	"point_commentary_node",
	"point_viewcontrol",
	"func_precipitation",
	"func_team_wall",
	"shadow_control",
	"sky_camera",
	"scene_manager",
	"trigger_soundscape",
	"commentary_auto",
	"point_commentary_node",
	"point_commentary_viewpoint",
	"bot_roster",
	"info_populator",
	"", // END Marker
};
tf/tf_gamerules.cpp
// Classnames of entities that are preserved across round restarts
static const char *s_PreserveEnts[] =
{
	"tf_gamerules",
	"tf_team_manager",
	"tf_player_manager",
	"tf_team",
	"tf_objective_resource",
	"keyframe_rope",
	"move_rope",
	"tf_viewmodel",
	"tf_logic_training",
	"tf_logic_training_mode",
#ifdef TF_RAID_MODE
	"tf_logic_raid",
#endif // TF_RAID_MODE
	"tf_powerup_bottle",
	"tf_mann_vs_machine_stats",
	"tf_wearable",
	"tf_wearable_demoshield",
	"tf_wearable_robot_arm",
	"tf_wearable_vm",
	"tf_logic_bonusround",
	"vote_controller",
	"monster_resource",
	"tf_logic_medieval",
	"tf_logic_cp_timer",
	"tf_logic_tower_defense",	// legacy
	"tf_logic_mann_vs_machine",
	"func_upgradestation",
	"entity_rocket",
	"entity_carrier",
	"entity_sign",
	"entity_saucer",
	"tf_halloween_gift_pickup",
	"tf_logic_competitive",
	"", // END Marker
};

Counter-Strike: Source Counter-Strike: Source

cstrike/cs_gamerules.cpp
static const char *s_PreserveEnts[] =
{
	"ai_network",
	"ai_hint",
	"cs_gamerules",
	"cs_team_manager",
	"cs_player_manager",
	"env_soundscape",
	"env_soundscape_proxy",
	"env_soundscape_triggerable",
	"env_sun",
	"env_wind",
	"env_fog_controller",
	"func_brush",
	"func_wall",
	"func_buyzone",
	"func_illusionary",
	"func_hostage_rescue",
	"func_bomb_target",
	"infodecal",
	"info_projecteddecal",
	"info_node",
	"info_target",
	"info_node_hint",
	"info_player_counterterrorist",
	"info_player_terrorist",
	"info_map_parameters",
	"keyframe_rope",
	"move_rope",
	"info_ladder",
	"player",
	"point_viewcontrol",
	"scene_manager",
	"shadow_control",
	"sky_camera",
	"soundent",
	"trigger_soundscape",
	"viewmodel",
	"predicted_viewmodel",
	"worldspawn",
	"point_devshot_camera",
	"", // END Marker
};

Counter-Strike: Global Offensive Counter-Strike: Global Offensive

cstrike15/cs_gamerules.cpp
static const char *s_PreserveEnts[] =
{
	"ai_network",
	"ai_hint",
	"cs_gamerules",
	"cs_team_manager",
	"cs_player_manager",
	"env_soundscape",
	"env_soundscape_proxy",
	"env_soundscape_triggerable",
	"env_sun",
	"env_wind",
	"env_fog_controller",
	"env_tonemap_controller",
	"env_cascade_light",
	"func_brush",
	"func_wall",
	"func_buyzone",
	"func_illusionary",
	"func_hostage_rescue",
	"func_bomb_target",
	"infodecal",
	"info_projecteddecal",
	"info_node",
	"info_target",
	"info_node_hint",
	"info_player_counterterrorist",
	"info_player_terrorist",
	"info_enemy_terrorist_spawn",
	"info_deathmatch_spawn",
	"info_armsrace_counterterrorist",
	"info_armsrace_terrorist",
	"info_map_parameters",
	"keyframe_rope",
	"move_rope",
	"info_ladder",
	"player",
	"point_viewcontrol",
	"point_viewcontrol_multiplayer",
	"scene_manager",
	"shadow_control",
	"sky_camera",
	"soundent",
	"trigger_soundscape",
	"viewmodel",
	"predicted_viewmodel",
	"worldspawn",
	"point_devshot_camera",
	"logic_choreographed_scene",
	"cfe_player_decal",
	"info_bomb_target_hint_A",
	"info_bomb_target_hint_B",
	"info_hostage_rescue_zone_hint",
	"generic_actor",
	"vote_controller",
	"wearable_item",
	"point_hiding_spot",
	"game_coopmission_manager",
	"chicken",
	"", // END Marker
};

Day of Defeat: Source Day of Defeat: Source

dod/dod_gamerules.cpp
static const char *s_PreserveEnts[] =
{
	"player",
	"viewmodel",
	"worldspawn",
	"soundent",
	"ai_network",
	"ai_hint",
	"dod_gamerules",
	"dod_team_manager",
	"dod_player_manager",
	"dod_objective_resource",
	"env_soundscape",
	"env_soundscape_proxy",
	"env_soundscape_triggerable",
	"env_sprite",
	"env_sun",
	"env_wind",
	"env_fog_controller",
	"func_brush",
	"func_wall",
	"func_illusionary",
	"info_node",
	"info_target",
	"info_node_hint",
	"info_player_allies",
	"info_player_axis",
	"point_viewcontrol",
	"shadow_control",
	"sky_camera",
	"scene_manager",
	"trigger_soundscape",
	"info_dod_detect",
	"dod_team_allies",
	"dod_team_axis",
	"point_commentary_node",
	"dod_round_timer",
	"func_precipitation",
	"func_team_wall",
	"", // END Marker
};

Alien Swarm Alien Swarm

swarm/asw_gamerules.cpp
CAlienSwarm::CAlienSwarm()
{
	// set which entities should stay around when we restart the mission
	m_MapResetFilter.AddKeepEntity("worldspawn");
	m_MapResetFilter.AddKeepEntity("soundent");
	m_MapResetFilter.AddKeepEntity("asw_gamerules");
	m_MapResetFilter.AddKeepEntity("player");
	m_MapResetFilter.AddKeepEntity("asw_player");
	m_MapResetFilter.AddKeepEntity("player_manager");	
	m_MapResetFilter.AddKeepEntity("predicted_viewmodel");
	m_MapResetFilter.AddKeepEntity("sdk_team_manager");
	m_MapResetFilter.AddKeepEntity("scene_manager");
	m_MapResetFilter.AddKeepEntity("event_queue_saveload_proxy");
	m_MapResetFilter.AddKeepEntity("ai_network");
}

Code Dumps

Left 4 Dead Left 4 Dead

22/07/2021 - Steps: [IDA]
1. Search for theai_networkstring reference.
2. Bring up the XREFs of the reference.
3. Find the list that has bothsurvivor_botandlogic_versus_randomin it.

; "ai_network",
; "ai_hint",
; "cs_team_manager",
; "terror_gamerules",
; "terror_player_manager",
; "survivor_bot",
; "env_tonemap_controller",
; "env_tonemap_controller_infected",
; "env_tonemap_controller_ghost",
; "vote_controller",
; "env_soundscape",
; "env_soundscape_proxy",
; "env_soundscape_triggerable",
; "env_sun",
; "env_wind",
; "env_fog_controller",
; "func_wall",
; "func_buyzone",
; "func_illusionary",
; "func_hostage_rescue",
; "func_bomb_target",
; "infodecal",
; "info_projecteddecal",
; "info_node",
; "info_target",
; "info_node_hint",
; "info_player_counterterrorist",
; "info_player_terrorist",
; "info_map_parameters",
; "info_map_parameters_versus",
; "info_ladder",
; "func_simpleladder",
; "player",
; "point_viewcontrol",
; "scene_manager",
; "shadow_control",
; "sky_camera",
; "soundent",
; "trigger_soundscape",
; "viewmodel",
; "predicted_viewmodel",
; "worldspawn",
; "point_devshot_camera",
; "info_survivor_position",
; "logic_versus_random",

Left 4 Dead 2 Left 4 Dead 2

22/07/2021 - Steps: [IDA]
1. Search for theai_networkstring reference.
2. Bring up the XREFs of the reference.
3. Find the list that has bothsurvivor_botandlogic_versus_randomin it.

; "ai_network",
; "ai_hint",
; "cs_team_manager",
; "terror_gamerules",
; "terror_player_manager",
; "survivor_bot",
; "env_tonemap_controller",
; "env_tonemap_controller_infected",
; "env_tonemap_controller_ghost",
; "vote_controller",
; "env_soundscape",
; "env_soundscape_proxy",
; "env_soundscape_triggerable",
; "env_sun",
; "env_wind",
; "env_fog_controller",
; "func_wall",
; "infodecal",
; "info_projecteddecal",
; "info_node",
; "info_node_hint",
; "info_map_parameters",
; "info_map_parameters_versus",
; "info_ladder",
; "func_simpleladder",
; "player",
; "point_viewcontrol",
; "scene_manager",
; "shadow_control",
; "sky_camera",
; "soundent",
; "trigger_soundscape",
; "viewmodel",
; "predicted_viewmodel",
; "worldspawn",
; "point_devshot_camera",
; "weapon_scavenge_item_spawn",
; "logic_versus_random",