Skip to content

Commit

Permalink
Fix linux no model override behavior (#12)
Browse files Browse the repository at this point in the history
* Fix linux no model override behavior
  • Loading branch information
Kailo97 authored Mar 25, 2023
1 parent 5fddbaf commit 05ce68b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Binary file modified build/package/addons/sourcemod/extensions/modelch.ext.2.csgo.so
Binary file not shown.
17 changes: 9 additions & 8 deletions extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ __declspec(naked) void playerspawn()
__asm push eax
__asm push ebx
#else
__asm lea ecx, [ebp-0x38]
__asm mov eax, edi
__asm xor al, 1
__asm or al, byte ptr [ecx]
__asm mov byte ptr [ecx], al
__asm lea ecx, [ebp-0x38] //in [ebp-0x38] value equal player_block = "*((_BYTE *)player + 12481)"
__asm mov eax, edi //in di value equal "custom_cond" = ...
__asm xor al, 1
__asm or al, byte ptr [ecx] //calc arg4 equal block_cond = !(custom_cond && !player_block) = !custom_cond || player_block
__asm mov byte ptr [ecx], al
__asm push ecx
__asm push esi
__asm lea eax, [esp-0x04] //push address of argument itself as value of argument =)
Expand All @@ -127,15 +127,16 @@ __declspec(naked) void playerspawn()
__asm jz UseDefaultMdl

#ifndef WIN32
__asm mov edi, [esp-0x0C] //from value used for model_name argument getting actual address for model name
__asm mov edi, [esp-0x0C] //from value used for model_name argument getting actual address for model name
#endif
__asm mov eax, g_addr_model_custom
__asm jmp eax

__asm UseDefaultMdl:
__asm mov eax, g_addr_model_normal
#ifndef WIN32
__asm test byte ptr [ebp-0x38], 0
// jump to jbe <dst> // di <= dyte ptr [ebp-0x38] ; where dst - set default model
__asm mov edi, 1
#endif
__asm jmp eax
}
Expand Down Expand Up @@ -166,7 +167,7 @@ bool MdlChagerExt::SDK_OnLoad(char* error, size_t maxlen, bool late)
g_addr_model_custom = (void*)((uintptr_t)addr + 0x879);
#else
void *addr_hook = (void*)((uintptr_t)addr + 0xBB4);
g_addr_model_normal = (void*)((uintptr_t)addr + 0xBF4);
g_addr_model_normal = (void*)((uintptr_t)addr + 0xBEF);
g_addr_model_custom = (void*)((uintptr_t)addr + 0xCF1);
#endif

Expand Down
2 changes: 1 addition & 1 deletion smsdk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/* Basic information exposed publicly */
#define SMEXT_CONF_NAME "Model Changer Extension"
#define SMEXT_CONF_DESCRIPTION "Change spawn model"
#define SMEXT_CONF_VERSION "1.0.0.2"
#define SMEXT_CONF_VERSION "1.0.0.3"
#define SMEXT_CONF_AUTHOR "Kailo"
#define SMEXT_CONF_URL "https://github.com/Kailo97"
#define SMEXT_CONF_LOGTAG "MDLCH"
Expand Down

0 comments on commit 05ce68b

Please sign in to comment.