-
Notifications
You must be signed in to change notification settings - Fork 36
Description
While messing around with props in HL2DM, it appears I stumbled upon an issue related to the internal caching system. The server crashes when you try to get the PhysicsObject of a prop_physics_respawnable entity after it respawns. Here's the code I used:
# ../physics_object_test/physics_object_test.py
# Source.Python
from commands import CommandReturn
from commands.client import ClientCommand
from entities.constants import MoveType
from mathlib import Vector
from players.entity import Player
FORCE = Vector(0, 0, 500)
@ClientCommand('push_up')
def push_up_cmd(command, index):
player = Player(index)
entity = player.view_entity
# Is this a physical object?
if entity.move_type == MoveType.VPHYSICS:
# Push it up.
entity.physics_object.apply_force_center(
FORCE * entity.physics_object.mass)
return CommandReturn.BLOCKBasically, use the push_up command on any breakable prop, destroy it, and when it respawns - use the command again. This will result in a crash (https://www.youtube.com/watch?v=xFOaoMnlcNI - got lucky in the video, usually it crashes after the first respawn).
As for why I believe this to be an issue with the internal caching system - the entity (prop_physics_respawnable) doesn't get removed when it's destroyed, just hidden. Which means the entity itself is always within the cache. Here's the catch though, the PhysicsObject tied to the entity does get removed - as can be seen in CPhysicsPropRespawnable::Event_Killed(). Thus the physics_object property no longer points at the correct instance.