Skip to content

Commit 0ffc0b4

Browse files
authored
Merge pull request #393 from KZGlobalTeam/dev
GOKZ v3.4.1
2 parents 928b433 + bba9eef commit 0ffc0b4

File tree

13 files changed

+276
-229
lines changed

13 files changed

+276
-229
lines changed

addons/sourcemod/gamedata/gokz-momsurffix.games.txt

+1-17
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,6 @@
4747
"CTraceFilterSimple::size" "16"
4848
}
4949

50-
"Addresses"
51-
{
52-
"CGameMovement::TryPlayerMove_Start"
53-
{
54-
"windows"
55-
{
56-
"signature" "CGameMovement::TryPlayerMove"
57-
}
58-
"linux"
59-
{
60-
"signature" "CGameMovement::TryPlayerMove"
61-
}
62-
"offset" "0"
63-
}
64-
}
65-
6650
"Offsets"
6751
{
6852
"OSType"
@@ -340,7 +324,7 @@
340324
"windows"
341325
{
342326
"signature" "CGameMovement::TryPlayerMove"
343-
"read" "700"
327+
"read" "718"
344328
}
345329
"linux"
346330
{

addons/sourcemod/scripting/gokz-core.sp

+7
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,13 @@ public Action OnNormalSound(int clients[MAXPLAYERS], int &numClients, char sampl
384384

385385
public void OnEntityCreated(int entity, const char[] classname)
386386
{
387+
// Don't react to player related entities
388+
if (StrEqual(classname, "predicted_viewmodel") || StrEqual(classname, "item_assaultsuit")
389+
|| StrEqual(classname, "cs_bot") || StrEqual(classname, "player")
390+
|| StrContains(classname, "weapon") != -1)
391+
{
392+
return;
393+
}
387394
SDKHook(entity, SDKHook_Spawn, OnEntitySpawned);
388395
SDKHook(entity, SDKHook_SpawnPost, OnEntitySpawnedPost);
389396
OnEntityCreated_Triggerfix(entity, classname);

addons/sourcemod/scripting/gokz-global/send_run.sp

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ bool IsReplayReadyToSend(int client, int course, int timeType, float time)
121121

122122
public void SendReplay(int client)
123123
{
124-
DataPack dp;
124+
DataPack dp = new DataPack();
125125
dp.WriteString(deleteRecord[client] ? storedReplayPath[client] : "");
126126
GlobalAPI_CreateReplayForRecordId(SendReplayCallback, dp, lastRecordId[client], storedReplayPath[client]);
127127
lastRecordId[client] = -1;

addons/sourcemod/scripting/gokz-jumpstats/jump_tracking.sp

+13-5
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ enum struct JumpTracker
9494
// We need to do that before we reset the jump cause we need the
9595
// offset and type of the previous jump
9696
this.lastType = this.DetermineType(jumped, ladderJump, jumpbug);
97-
97+
9898
// We need this for weirdjump w-release
9999
int releaseWTemp = this.jump.releaseW;
100100

@@ -151,10 +151,10 @@ enum struct JumpTracker
151151
We check for speed reduction for abuse; while prop abuses increase speed,
152152
wall collision will very likely (if not always) result in a speed reduction.
153153
*/
154-
float actualSpeed = GetVectorHorizontalDistance(this.position, pose(-1).position) * 128;
154+
float actualSpeed = GetVectorHorizontalDistance(this.position, pose(-1).position) / GetTickInterval();
155155
if (FloatAbs(speed - actualSpeed) > JS_SPEED_MODIFICATION_TOLERANCE && this.jump.duration != 0)
156156
{
157-
if (actualSpeed <= pose(-1).speed)
157+
if (actualSpeed <= pose(-1).speed)
158158
{
159159
pose(0).speed = actualSpeed;
160160
}
@@ -164,7 +164,13 @@ enum struct JumpTracker
164164
this.Invalidate();
165165
}
166166
}
167-
167+
// You shouldn't gain any vertical velocity during a jump.
168+
// This would only happen if you get boosted back up somehow, or you edgebugged.
169+
if (!Movement_GetOnGround(this.jumper) && pose(0).velocity[2] > pose(-1).velocity[2])
170+
{
171+
this.Invalidate();
172+
}
173+
168174
this.jump.height = FloatMax(this.jump.height, this.position[2] - this.takeoffOrigin[2]);
169175
this.jump.maxSpeed = FloatMax(this.jump.maxSpeed, speed);
170176
this.jump.crouchTicks += Movement_GetDucking(this.jumper) ? 1 : 0;
@@ -965,7 +971,7 @@ enum struct JumpTracker
965971
endBlock[coordDev] = middle[coordDev];
966972
startBlock[2] = middle[2];
967973
endBlock[2] = middle[2];
968-
974+
969975
// Search for the blocks
970976
if (!TraceHullPosition(middle, startBlock, sweepBoxMin, sweepBoxMax, startBlock)
971977
|| !TraceHullPosition(middle, endBlock, sweepBoxMin, sweepBoxMax, endBlock))
@@ -976,6 +982,8 @@ enum struct JumpTracker
976982
// Make sure the edges of the blocks are parallel.
977983
if (!this.BlockAreEdgesParallel(startBlock, endBlock, this.jump.deviation + 32.0, coordDist, coordDev))
978984
{
985+
this.jump.block = 0;
986+
this.jump.edge = -1.0;
979987
return;
980988
}
981989

addons/sourcemod/scripting/gokz-momsurffix.sp

+38-82
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ enum OSType
3737
OSType gOSType;
3838
EngineVersion gEngineVersion;
3939

40-
#define CUSTOM_ASSERTION_FAILSTATE
41-
#define FAILSTATE_FUNC SetFailStateCustom
40+
#define ASSERTUTILS_FAILSTATE_FUNC SetFailStateCustom
41+
#define MEMUTILS_PLUGINENDCALL
4242
#include "glib/memutils"
43+
#undef MEMUTILS_PLUGINENDCALL
44+
4345
#include "momsurffix/utils.sp"
4446
#include "momsurffix/baseplayer.sp"
4547
#include "momsurffix/gametrace.sp"
@@ -50,22 +52,27 @@ ConVar gBounce;
5052
float vec3_origin[3] = {0.0, 0.0, 0.0};
5153
bool gBasePlayerLoadedTooEarly;
5254

53-
PatchHandler gASMPatch;
54-
Handle gStoreToAddressFast;
55-
Address gTryPlayerMoveStart;
56-
5755
#if defined DEBUG_PROFILE
5856
#include "profiler"
59-
#define PROF_START() if(gProf) gProf.Start()
60-
#define PROF_STOP(%1)%2; if(gProf)\
61-
{\
62-
gProf.Stop();\
63-
Prof_Check(%1);\
64-
}
65-
6657
Profiler gProf;
6758
ArrayList gProfData;
6859
float gProfTime;
60+
61+
void PROF_START()
62+
{
63+
if(gProf)
64+
gProf.Start();
65+
}
66+
67+
void PROF_STOP(int idx)
68+
{
69+
if(gProf)
70+
{
71+
gProf.Stop();
72+
Prof_Check(idx);
73+
}
74+
}
75+
6976
#else
7077
#define PROF_START%1;
7178
#define PROF_STOP%1;
@@ -100,7 +107,6 @@ public void OnPluginStart()
100107
InitGameMovement(gd);
101108

102109
SetupDhooks(gd);
103-
SetupASMOptimizations(gd);
104110

105111
delete gd;
106112
}
@@ -190,48 +196,6 @@ public Action Prof_Check_Timer(Handle timer, int client)
190196
}
191197
#endif
192198

193-
void SetupASMOptimizations(GameData gd)
194-
{
195-
//CGameMovement::TryPlayerMove_Start
196-
gTryPlayerMoveStart = gd.GetAddress("CGameMovement::TryPlayerMove_Start");
197-
ASSERT_MSG(gTryPlayerMoveStart, "Can't find start of the \"CGameMovement::TryPlayerMove\" function.");
198-
199-
gASMPatch = PatchHandler(gTryPlayerMoveStart + ASM_START_OFFSET);
200-
gASMPatch.Save(ASM_PATCH_LEN);
201-
202-
Address start = gASMPatch.Address;
203-
204-
/*StoreToAddressFast asm:
205-
* push ebp
206-
* mov ebp, esp
207-
*
208-
* mov eax, [ebp + 12]
209-
* mov ecx, [ebp + 8]
210-
* mov [ecx], eax
211-
*
212-
* mov esp, ebp
213-
* pop ebp
214-
* ret 8
215-
*/
216-
217-
StoreToAddress(start, 0x8B_EC_8B_55, NumberType_Int32);
218-
StoreToAddress(start + 4, 0x4D_8B_0C_45, NumberType_Int32);
219-
StoreToAddress(start + 8, 0x8B_01_89_08, NumberType_Int32);
220-
StoreToAddress(start + 12, 0x08_C2_5D_E5, NumberType_Int32);
221-
StoreToAddress(start + 16, 0x00, NumberType_Int8);
222-
223-
//StoreToAddressFast
224-
StartPrepSDKCall(SDKCall_Static);
225-
226-
PrepSDKCall_SetAddress(start);
227-
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
228-
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
229-
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
230-
231-
gStoreToAddressFast = EndPrepSDKCall();
232-
ASSERT(gStoreToAddressFast);
233-
}
234-
235199
void ValidateGameAndOS(GameData gd)
236200
{
237201
gOSType = view_as<OSType>(gd.GetOffset("OSType"));
@@ -345,7 +309,13 @@ int TryPlayerMove(CGameMovement pThis, Vector pFirstDest, CGameTrace pFirstTrace
345309
VectorCopy(view_as<float>({0.0, 0.0, 0.0}), valid_plane);
346310

347311
float offset[3], offset_mins[3], offset_maxs[3], buff[3];
348-
Ray_t ray = Ray_t();
312+
static Ray_t ray;
313+
314+
// Keep this variable allocated only once
315+
// since ray.Init should take care of removing any left garbage values
316+
if(ray.Address == Address_Null)
317+
ray = Ray_t();
318+
349319
for(i = 0; i < 3; i++)
350320
{
351321
for(j = 0; j < 3; j++)
@@ -413,7 +383,6 @@ int TryPlayerMove(CGameMovement pThis, Vector pFirstDest, CGameTrace pFirstTrace
413383
}
414384
}
415385
}
416-
ray.Free();
417386

418387
if(valid_planes != 0 && !CloseEnough(valid_plane, view_as<float>({0.0, 0.0, 0.0})))
419388
{
@@ -669,12 +638,20 @@ stock bool CloseEnoughFloat(float a, float b, float eps = FLT_EPSILON)
669638

670639
public void SetFailStateCustom(const char[] fmt, any ...)
671640
{
672-
char buff[ASSERT_FMT_STRING_LEN];
641+
char buff[512];
673642
VFormat(buff, sizeof(buff), fmt, 2);
674643

675644
CleanUpUtils();
676645

677-
SetFailState(buff);
646+
char ostype[32];
647+
switch(gOSType)
648+
{
649+
case OSLinux: ostype = "LIN";
650+
case OSWindows: ostype = "WIN";
651+
default: ostype = "UNK";
652+
}
653+
654+
SetFailState("[%s | %i] %s", ostype, gEngineVersion, buff);
678655
}
679656

680657
// 0-2 are axial planes
@@ -706,7 +683,7 @@ stock bool IsValidMovementTrace(CGameMovement pThis, CGameTrace tr)
706683

707684
CGameTrace stuck = CGameTrace();
708685

709-
TracePlayerBBox(pThis, tr.endpos, tr.endpos, MASK_PLAYERSOLID, COLLISION_GROUP_PLAYER_MOVEMENT, stuck)
686+
TracePlayerBBox(pThis, tr.endpos, tr.endpos, MASK_PLAYERSOLID, COLLISION_GROUP_PLAYER_MOVEMENT, stuck);
710687
if(stuck.startsolid || !CloseEnoughFloat(stuck.fraction, 1.0))
711688
{
712689
stuck.Free();
@@ -742,25 +719,4 @@ stock void UTIL_TraceRay(Ray_t ray, int mask, CGameMovement gm, int collisionGro
742719

743720
filter.Free();
744721
}
745-
}
746-
747-
//Faster then native StoreToAddress by ~45 times.
748-
stock void StoreToAddressFast(Address addr, any data)
749-
{
750-
ASSERT(gStoreToAddressFast);
751-
752-
int ret = SDKCall(gStoreToAddressFast, addr, data);
753-
ASSERT(ret == data);
754-
}
755-
756-
stock void StoreToAddressCustom(Address addr, any data, NumberType type)
757-
{
758-
if (gStoreToAddressFast && type == NumberType_Int32)
759-
{
760-
StoreToAddressFast(addr, data);
761-
}
762-
else
763-
{
764-
StoreToAddress(addr, view_as<int>(data), type);
765-
}
766722
}

0 commit comments

Comments
 (0)