From 4ad12f7ef186a7828c83be14401825891863bb9e Mon Sep 17 00:00:00 2001 From: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com> Date: Sun, 12 Jan 2020 04:15:29 +0300 Subject: [PATCH] Bug fixes Fixed bug on start of the plugin when "world" entity isn't initialized, and few other bug fixes. --- .../scripting/momsurffix/baseplayer.sp | 17 ++++++++++- .../scripting/momsurffix/gametrace.sp | 7 +++-- addons/sourcemod/scripting/momsurffix2.sp | 30 +++++++++++++++---- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/addons/sourcemod/scripting/momsurffix/baseplayer.sp b/addons/sourcemod/scripting/momsurffix/baseplayer.sp index f920aec..b90835d 100644 --- a/addons/sourcemod/scripting/momsurffix/baseplayer.sp +++ b/addons/sourcemod/scripting/momsurffix/baseplayer.sp @@ -37,7 +37,7 @@ methodmap CBasePlayer < AddressBase } } -stock void InitBasePlayer(GameData gd) +stock bool InitBasePlayer(GameData gd) { char buff[128]; @@ -47,6 +47,21 @@ stock void InitBasePlayer(GameData gd) offsets.cbpoffsets.m_hGroundEntity = FindSendPropInfo("CBasePlayer", "m_hGroundEntity"); ASSERT_FMT(offsets.cbpoffsets.m_hGroundEntity > 0, "Can't get \"CBasePlayer::m_hGroundEntity\" offset from FindSendPropInfo()."); + + if(IsValidEntity(0)) + { + offsets.cbpoffsets.m_MoveType = FindDataMapInfo(0, "m_MoveType"); + ASSERT_FMT(offsets.cbpoffsets.m_MoveType != -1, "Can't get \"CBasePlayer::m_MoveType\" offset from FindDataMapInfo()."); + } + else + return false; + + return true; +} + +stock void LateInitBasePlayer(GameData gd) +{ + ASSERT(IsValidEntity(0)); offsets.cbpoffsets.m_MoveType = FindDataMapInfo(0, "m_MoveType"); ASSERT_FMT(offsets.cbpoffsets.m_MoveType != -1, "Can't get \"CBasePlayer::m_MoveType\" offset from FindDataMapInfo()."); } \ No newline at end of file diff --git a/addons/sourcemod/scripting/momsurffix/gametrace.sp b/addons/sourcemod/scripting/momsurffix/gametrace.sp index 2bb5630..0c45b17 100644 --- a/addons/sourcemod/scripting/momsurffix/gametrace.sp +++ b/addons/sourcemod/scripting/momsurffix/gametrace.sp @@ -240,7 +240,7 @@ methodmap Ray_t < AllocatableBase public void Init(float start[3], float end[3], float mins[3], float maxs[3]) { - float buff[3]; + float buff[3], buff2[3]; SubtractVectors(end, start, buff); this.m_Delta.FromArray(buff); @@ -255,8 +255,9 @@ methodmap Ray_t < AllocatableBase AddVectors(mins, maxs, buff); ScaleVector(buff, 0.5); - AddVectors(start, buff, buff); - ScaleVector(buff, -1.0); + AddVectors(start, buff, buff2); + this.m_Start.FromArray(buff2); + NegateVector(buff); this.m_StartOffset.FromArray(buff); } } diff --git a/addons/sourcemod/scripting/momsurffix2.sp b/addons/sourcemod/scripting/momsurffix2.sp index 2a38bd3..7e97ae3 100644 --- a/addons/sourcemod/scripting/momsurffix2.sp +++ b/addons/sourcemod/scripting/momsurffix2.sp @@ -4,12 +4,13 @@ #include "dhooks" #define SNAME "[momsurffix2] " +#define GAME_DATA_FILE "momsurffix2.games" public Plugin myinfo = { name = "Momentum surf fix \'2", author = "GAMMA CASE", description = "Ported surf fix from momentum mod.", - version = "1.0.0", + version = "1.0.1", url = "http://steamcommunity.com/id/_GAMMACASE_/" }; @@ -36,6 +37,7 @@ OSType gOSType; ConVar gRampBumpCount, gBounce, gRampInitialRetraceLength; float vec3_origin[3] = {0.0, 0.0, 0.0}; +bool gLoadedTooEarly; public void OnPluginStart() { @@ -49,14 +51,14 @@ public void OnPluginStart() AutoExecConfig(); - GameData gd = new GameData("momsurffix2.games"); + GameData gd = new GameData(GAME_DATA_FILE); ASSERT_FINAL(gd); ValidateGameData(gd); InitUtils(gd); InitGameTrace(gd); - InitBasePlayer(gd); + gLoadedTooEarly = !InitBasePlayer(gd); InitGameMovement(gd); SetupDhooks(gd); @@ -64,6 +66,17 @@ public void OnPluginStart() delete gd; } +public void OnMapStart() +{ + if(gLoadedTooEarly) + { + GameData gd = new GameData(GAME_DATA_FILE); + LateInitBasePlayer(gd); + gLoadedTooEarly = false; + delete gd; + } +} + public void OnPluginEnd() { CleanUpUtils(); @@ -135,6 +148,8 @@ int TryPlayerMove(CGameMovement pThis, Vector pFirstDest, CGameTrace pFirstTrace if(stuck_on_ramp) { + //PrintToServer(SNAME..."[%i] Stuck!!!", GetGameTickCount()); + if(!has_valid_plane) { plane_normal = pm.plane.normal; @@ -268,10 +283,12 @@ int TryPlayerMove(CGameMovement pThis, Vector pFirstDest, CGameTrace pFirstTrace if(stuck_on_ramp && has_valid_plane) { alloced_vector.FromArray(fixed_origin); + //TracePlayerBBoxCustom(pThis, fixed_origin, end, MASK_PLAYERSOLID, COLLISION_GROUP_PLAYER_MOVEMENT, pm); TracePlayerBBox(pThis, alloced_vector, vec1, MASK_PLAYERSOLID, COLLISION_GROUP_PLAYER_MOVEMENT, pm); pm.plane.normal.FromArray(valid_plane); } else + //TracePlayerBBoxCustom(pThis, VectorToArray(pThis.mv.m_vecAbsOrigin), end, MASK_PLAYERSOLID, COLLISION_GROUP_PLAYER_MOVEMENT, pm); TracePlayerBBox(pThis, pThis.mv.m_vecAbsOrigin, vec1, MASK_PLAYERSOLID, COLLISION_GROUP_PLAYER_MOVEMENT, pm); vec1.Free(); @@ -284,19 +301,20 @@ int TryPlayerMove(CGameMovement pThis, Vector pFirstDest, CGameTrace pFirstTrace continue; } - if(pm.allsolid) + /*if(pm.allsolid) { vecVelocity.FromArray(vec3_origin); pm.Free(); return 4; - } + }*/ if(pm.fraction > 0.0) { if((bumpcount == 0 || pThis.player.m_hGroundEntity != view_as
(-1)) && numbumps > 0 && pm.fraction == 1.0) { CGameTrace stuck = CGameTrace(); + //TracePlayerBBoxCustom(pThis, VectorToArray(pm.endpos), VectorToArray(pm.endpos), MASK_PLAYERSOLID, COLLISION_GROUP_PLAYER_MOVEMENT, stuck); TracePlayerBBox(pThis, pm.endpos, pm.endpos, MASK_PLAYERSOLID, COLLISION_GROUP_PLAYER_MOVEMENT, stuck); if((stuck.startsolid || stuck.fraction != 1.0) && bumpcount == 0) @@ -528,7 +546,7 @@ stock bool IsValidMovementTrace(CGameMovement pThis, CGameTrace tr) return true; } -/*stock void TracePlayerBBox(CGameMovement pThis, float start[3], float end[3], int mask, int collisionGroup, CGameTrace trace) +/*stock void TracePlayerBBoxCustom(CGameMovement pThis, float start[3], float end[3], int mask, int collisionGroup, CGameTrace trace) { Ray_t ray = Ray_t();