Skip to content

Commit

Permalink
Improved performance of the plugin
Browse files Browse the repository at this point in the history
Added StoreToAddressFast() function, which is significantly faster then native StoreToAddress().
  • Loading branch information
GAMMACASE authored Jan 18, 2020
1 parent 1b2bc4e commit e618d28
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 56 deletions.
16 changes: 16 additions & 0 deletions addons/sourcemod/gamedata/momsurffix2.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@
"CTraceFilterSimple::size" "16"
}

"Addresses"
{
"CGameMovement::TryPlayerMove_Start"
{
"windows"
{
"signature" "CGameMovement::TryPlayerMove"
}
"linux"
{
"signature" "CGameMovement::TryPlayerMove"
}
"offset" "0"
}
}

"Offsets"
{
"OSType"
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/momsurffix/gamemovement.sp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ methodmap CGameMovement < AddressBase
property int m_nTraceCount
{
public get() { return LoadFromAddress(this.Address + offsets.cgmoffsets.m_nTraceCount, NumberType_Int32); }
public set(int _tracecount) { StoreToAddress(this.Address + offsets.cgmoffsets.m_nTraceCount, _tracecount, NumberType_Int32); }
public set(int _tracecount) { StoreToAddressCustom(this.Address + offsets.cgmoffsets.m_nTraceCount, _tracecount, NumberType_Int32); }
}
}

Expand Down
8 changes: 4 additions & 4 deletions addons/sourcemod/scripting/momsurffix/gametrace.sp
Original file line number Diff line number Diff line change
Expand Up @@ -279,25 +279,25 @@ methodmap CTraceFilterSimple < AllocatableBase
property Address vptr
{
public get() { return view_as<Address>(LoadFromAddress(this.Address + offsets.ctfsoffsets.vptr, NumberType_Int32)); }
public set(Address _vtbladdr) { StoreToAddress(this.Address + offsets.ctfsoffsets.vptr, view_as<int>(_vtbladdr), NumberType_Int32); }
public set(Address _vtbladdr) { StoreToAddressCustom(this.Address + offsets.ctfsoffsets.vptr, view_as<int>(_vtbladdr), NumberType_Int32); }
}

property CBaseHandle m_pPassEnt
{
public get() { return view_as<CBaseHandle>(LoadFromAddress(this.Address + offsets.ctfsoffsets.m_pPassEnt, NumberType_Int32)); }
public set(CBaseHandle _passent) { StoreToAddress(this.Address + offsets.ctfsoffsets.m_pPassEnt, view_as<int>(_passent), NumberType_Int32); }
public set(CBaseHandle _passent) { StoreToAddressCustom(this.Address + offsets.ctfsoffsets.m_pPassEnt, view_as<int>(_passent), NumberType_Int32); }
}

property int m_collisionGroup
{
public get() { return LoadFromAddress(this.Address + offsets.ctfsoffsets.m_collisionGroup, NumberType_Int32); }
public set(int _collisiongroup) { StoreToAddress(this.Address + offsets.ctfsoffsets.m_collisionGroup, _collisiongroup, NumberType_Int32); }
public set(int _collisiongroup) { StoreToAddressCustom(this.Address + offsets.ctfsoffsets.m_collisionGroup, _collisiongroup, NumberType_Int32); }
}

property Address m_pExtraShouldHitCheckFunction
{
public get() { return view_as<Address>(LoadFromAddress(this.Address + offsets.ctfsoffsets.m_pExtraShouldHitCheckFunction, NumberType_Int32)); }
public set(Address _checkfnc) { StoreToAddress(this.Address + offsets.ctfsoffsets.m_pExtraShouldHitCheckFunction, view_as<int>(_checkfnc), NumberType_Int32); }
public set(Address _checkfnc) { StoreToAddressCustom(this.Address + offsets.ctfsoffsets.m_pExtraShouldHitCheckFunction, view_as<int>(_checkfnc), NumberType_Int32); }
}

public CTraceFilterSimple()
Expand Down
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/momsurffix/utils.sp
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ methodmap Vector < AllocatableBase

property float x
{
public set(float _x) { StoreToAddress(this.Address, view_as<int>(_x), NumberType_Int32); }
public set(float _x) { StoreToAddressCustom(this.Address, view_as<int>(_x), NumberType_Int32); }
public get() { return view_as<float>(LoadFromAddress(this.Address, NumberType_Int32)); }
}

property float y
{
public set(float _y) { StoreToAddress(this.Address + 4, view_as<int>(_y), NumberType_Int32); }
public set(float _y) { StoreToAddressCustom(this.Address + 4, view_as<int>(_y), NumberType_Int32); }
public get() { return view_as<float>(LoadFromAddress(this.Address + 4, NumberType_Int32)); }
}

property float z
{
public set(float _z) { StoreToAddress(this.Address + 8, view_as<int>(_z), NumberType_Int32); }
public set(float _z) { StoreToAddressCustom(this.Address + 8, view_as<int>(_z), NumberType_Int32); }
public get() { return view_as<float>(LoadFromAddress(this.Address + 8, NumberType_Int32)); }
}

Expand Down
Loading

0 comments on commit e618d28

Please sign in to comment.