Skip to content

Commit

Permalink
Fixed an animation error when setting a model to Player. (#435)
Browse files Browse the repository at this point in the history
* Fixed an animation error when setting a model to Entity.

* Wrapped Entity.set_model with wrap_entity_mem_func.
  • Loading branch information
CookStar committed Nov 17, 2021
1 parent d5da6e6 commit 87d32cb
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
6 changes: 6 additions & 0 deletions addons/source-python/data/source-python/entities/bms/CBaseEntity.ini 100644 → 100755
@@ -1,5 +1,11 @@
[virtual_function]

# _ZN11CBaseEntity8SetModelEPKc
[[set_model]]
offset_linux = 27
offset_windows = 26
arguments = STRING

# _ZN11CBaseEntity9SetParentEPS_i
[[set_parent]]
offset_linux = 38
Expand Down
6 changes: 6 additions & 0 deletions addons/source-python/data/source-python/entities/csgo/CBaseEntity.ini 100644 → 100755
Expand Up @@ -3,6 +3,12 @@ srv_check = False

[virtual_function]

# _ZN11CBaseEntity8SetModelEPKc
[[set_model]]
offset_linux = 28
offset_windows = 27
arguments = STRING

# _ZN11CBaseEntity9SetParentEPS_i
[[set_parent]]
offset_linux = 40
Expand Down
6 changes: 6 additions & 0 deletions addons/source-python/data/source-python/entities/gmod/CBaseEntity.ini 100644 → 100755
@@ -1,5 +1,11 @@
[virtual_function]

# _ZN11CBaseEntity8SetModelEPKc
[[set_model]]
offset_linux = 25
offset_windows = 24
arguments = STRING

# _ZN11CBaseEntity9SetParentEPS_i
[[set_parent]]
offset_linux = 35
Expand Down
6 changes: 6 additions & 0 deletions addons/source-python/data/source-python/entities/l4d2/CBaseEntity.ini 100644 → 100755
@@ -1,5 +1,11 @@
[virtual_function]

# _ZN11CBaseEntity8SetModelEPKc
[[set_model]]
offset_linux = 28
offset_windows = 27
arguments = STRING

# _ZN11CBaseEntity9SetParentEPS_i
[[set_parent]]
offset_linux = 38
Expand Down
6 changes: 6 additions & 0 deletions addons/source-python/data/source-python/entities/orangebox/CBaseEntity.ini 100644 → 100755
@@ -1,5 +1,11 @@
[virtual_function]

# _ZN11CBaseEntity8SetModelEPKc
[[set_model]]
offset_linux = 25
offset_windows = 24
arguments = STRING

# _ZN11CBaseEntity9SetParentEPS_i
[[set_parent]]
offset_linux = 35
Expand Down
14 changes: 9 additions & 5 deletions addons/source-python/packages/source-python/entities/_base.py 100644 → 100755
Expand Up @@ -425,17 +425,21 @@ def get_model(self):

return Model(model_name)

@wrap_entity_mem_func
def set_model(self, model):
"""Set the entity's model to the given model.
:param Model model:
The model to set.
:param str/Model model:
The model path or model to set.
"""
self.model_index = model.index
self.model_name = model.path
if isinstance(model, Model):
model = model.path

return [model]

model = property(
get_model, set_model,
get_model,
lambda self, model: self.set_model(model),
doc="""Property to get/set the entity's model.
.. seealso:: :meth:`get_model` and :meth:`set_model`""")
Expand Down

0 comments on commit 87d32cb

Please sign in to comment.