SmileYzn / AccuracyFix

Counter-Strike 1.6 Accuracy Fix Plugin for MetaMod and ReGameDLL_CS
GNU General Public License v3.0
31 stars 12 forks source link

Crash in 1.0.7 #11

Closed jobmail closed 8 months ago

jobmail commented 8 months ago

Program terminated with signal SIGSEGV, Segmentation fault.

0 0xf7f39f91 in ?? () from /lib/ld-linux.so.2

[Current thread is 1 (Thread 0xf7b30700 (LWP 4963))]

0 0xf7f39f91 in ?? () from /lib/ld-linux.so.2

1 0xf7d21000 in ?? () from /lib/i386-linux-gnu/libc.so.6

2 0xf7c7c80c in _dl_catch_exception () from /lib/i386-linux-gnu/libc.so.6

3 0xf7f318fe in ?? () from /lib/ld-linux.so.2

4 0xf7eff2c8 in ?? () from /lib/i386-linux-gnu/libdl.so.2

5 0xf7c7c80c in _dl_catch_exception () from /lib/i386-linux-gnu/libc.so.6

6 0xf7c7c8b0 in _dl_catch_error () from /lib/i386-linux-gnu/libc.so.6

7 0xf7effab1 in ?? () from /lib/i386-linux-gnu/libdl.so.2

8 0xf7eff366 in dlopen () from /lib/i386-linux-gnu/libdl.so.2

9 0xf38bafec in ?? () from /SRV/test_server/./cstrike/addons/metamod/dlls/metamod.so

10 0xf1c02c2b in CAccuracyUtil::CvarRegister(char const, char const) () from /SRV/test_server/cstrike/addons/accuracyfix/dlls/accuracyfix_mm.so

11 0xf1c038c7 in CAccuracyFix::ServerActivate() () from /SRV/test_server/cstrike/addons/accuracyfix/dlls/accuracyfix_mm.so

12 0xf1c03b8a in DLL_POST_ServerActivate(edict_s*, int, int) () from /SRV/test_server/cstrike/addons/accuracyfix/dlls/accuracyfix_mm.so

13 0xf07edd7f in ?? ()

14 0xffd5b030 in ?? ()

15 0xf74b51b3 in Host_Map () from /SRV/test_server/engine_i486.so

16 0xf73d2228 in vtable for CFileSystem_Stdio () from /SRV/test_server/filesystem_stdio.so

17 0x7370616d in ?? ()

18 0x5f65642f in ?? ()

19 0xffd5b0e8 in ?? ()

jobmail commented 8 months ago

I forgot. Bad includes in your source from 1.0.5. I took from 1.0.2 and everything worked, thanks.

You have more and more strange code with each new version..

Try this one better: auto vEndRes = (Vector)vStart + gpGlobals->v_forward * fwdVelocity;

It is unclear why they abandoned the beautiful code?

if (SlotInfo->weaponName)
                {
                    char cvarName[64] = { 0 };

                    Q_snprintf(cvarName, sizeof(cvarName), "af_distance_%s", SlotInfo->weaponName);

                    this->m_af_distance[WeaponID] = gAccuracyUtil.CvarRegister(cvarName, "8192.0");

                    Q_snprintf(cvarName, sizeof(cvarName), "af_accuracy_%s", SlotInfo->weaponName);

                    this->m_af_accuracy[WeaponID] = gAccuracyUtil.CvarRegister(cvarName, "9999.0");
#ifdef ACCURACY_ENABLE_RECOIL_CONTROL
                    Q_snprintf(cvarName, sizeof(cvarName), "af_recoil_%s", SlotInfo->weaponName);

                    this->m_af_recoil[WeaponID] = gAccuracyUtil.CvarRegister(cvarName, "1.0");
#endif
                }
SmileYzn commented 8 months ago

Bad includes?

I always update CSSDK with same version form reapi amxx module, i guess that SlotInfo->weaponName is badly checked to see if is null or empty i will fix it.

Ps. I think that std::string is not working properly.

auto vEndRes = (Vector)vStart + gpGlobals->v_forward * fwdVelocity;

Project it's C++ 11 based, i guess that will work too?

Anyway, finally someone that understands the accuracy fix do 🙏

SmileYzn commented 8 months ago

I have updated plugin, i will make a release.

@jobmail Did you can test it?

jobmail commented 8 months ago

I have updated plugin, i will make a release.

@jobmail Did you can test it?

Now it works great. I fixed mine with similar code. As for includes, everything is fine with the new cssdk. Most likely something with the metamod. I took the cssdk from 1.0.7, and the metamod from <1.0.5 (I don’t remember exactly, maybe from 1.0.2)

jobmail commented 8 months ago

Metamod-r v1.3.0.138, API (5:13) Metamod-r build: 11:50:32 Nov 28 2023 Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/5179c25

ReGameDLL version: 5.26.0.668-dev Build date: 19:02:48 Dec 31 2023 Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/d3c0ec8

Currently loaded plugins: description stat pend file vers src load unload [ 1] Reunion RUN - reunion_mm_i386.so v0.1.92d ini Start Never [ 2] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never [ 3] Rechecker RUN - rechecker_mm_i386.so v2.7 ini Chlvl ANY [ 4] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY [ 5] Revoice RUN - revoice_mm_i386.so v0.1.0.34 ini Start Never [ 6] AMX Mod X RUN - amxmodx_mm_i386.so v1.10.0.5467 ini Start ANY [ 7] HitBox Fix RUN - hitbox_fix_mm_i386.so v1.1.4 ini Start ANY [ 8] YaPB RUN - yapb.so v4.3. ini Chlvl ANY [ 9] Accuracy Fix (ACS) RUN - accuracyfix_mm.so v1.0.7a ini ANY ANY [10] MySQL RUN - mysql_amxx_i386.so v1.10.0.5467 pl6 ANY ANY [11] CSX RUN - csx_amxx_i386.so v1.10.0.5467 pl6 ANY ANY [12] CStrike RUN - cstrike_amxx_i386.so v1.10.0.5467 pl6 ANY ANY

[13] ReAPI RUN - reapi_amxx_i386.so v5.24.0.300-dev pl6 ANY Never [14] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl6 ANY Never [15] Engine RUN - engine_amxx_i386.so v1.10.0.5467 pl6 ANY ANY [16] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.10.0.5467 pl6 ANY ANY [17] Fun RUN - fun_amxx_i386.so v1.10.0.5467 pl6 ANY ANY [18] FakeMeta RUN - fakemeta_amxx_i386.so v1.10.0.5467 pl6 ANY ANY [19] gRIP RUN - grip_amxx_i386.so v0.1.5 Beta pl6 ANY ANY 19 plugins, 19 running

SmileYzn commented 8 months ago

Metamod SDK do not get updates in ages.

I will make a new release 👍

jobmail commented 8 months ago

Wait... You have mixed code with g_engfuncs.pfnIndexOfEdict() and ENTINDEX(). Is it same?

SmileYzn commented 8 months ago

Yes it is, i always try to not use metamod macros

jobmail commented 8 months ago

I used your module in my plugin [ACS] Weapon Control System... Could you please add support for setting the RECOIL value from the var_fuser1 object property? I do it something like this:

#define AUW_IMPULSE_OFFSET 128381

void CAccuracyFix::PostThink(CBasePlayer* Player)
{
    if (Player->IsAlive() && (!Player->IsBot()))
    {
        auto EntityIndex = Player->entindex();

        if (this->m_Data[EntityIndex].WeaponId != WEAPON_NONE)
        {

            CBasePlayerWeapon* Weapon = static_cast<CBasePlayerWeapon*>(Player->m_pActiveItem);

            auto Ped = Player->edict();

            auto Wed = Weapon->edict();

            auto Recoil = (Wed->v.iuser4 - AUW_IMPULSE_OFFSET >= 0) && (Wed->v.impulse == Wed->v.iuser4) ? Wed->v.fuser1 : this->m_af_recoil[this->m_Data[EntityIndex].WeaponId]->value;

            if (Recoil > 0.0f)
            {
                if (this->m_af_recoil_all->value > 0.0f)
                {
                    Recoil = this->m_af_recoil_all->value;
                }

                if (Recoil < 1.0f)
                {
                    Ped->v.punchangle = Ped->v.punchangle * Recoil;
                }

            }

            this->m_Data[EntityIndex].WeaponId = WEAPON_NONE;
        }
    }
}

This one "#define AUW_IMPULSE_OFFSET 128381" can be moved to the cvar...

The module fixes things much more efficiently than can be done with a plugin.

SmileYzn commented 8 months ago

That code never work here

            if (Recoil > 0.0f)
            {
                if (this->m_af_recoil_all->value > 0.0f)
                {
                    Recoil = this->m_af_recoil_all->value;
                }

                if (Recoil < 1.0f)
                {
                    Ped->v.punchangle = Ped->v.punchangle * Recoil;
                }

            }

Recoil < 1.0? And if (Recoil > 0.0f) ??

Also iuser4 is a temporary variable used for anything, that code do no make any sense and to use OFFSET for what?