alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
497 stars 201 forks source link

tfc_get_user_goalitem broken on Linux #865

Closed pizzahut2 closed 3 years ago

pizzahut2 commented 4 years ago

PD_HAS_GOALITEM in amxmodx/modules/tfcx/CMisc.h seems to require a different "linuxdiff" for get_pdata_int on the latest HLDS (not beta). Without adjusting linuxdiff, I need to use offset 24 instead of 26 for Linux.

Maybe I'm doing something wrong, would it help to update hamdata and how would I do this?

Detailed information: https://forums.alliedmods.net/showthread.php?t=323687

Example plugin which uses tfc_get_user_goalitem and thus broke on Linux: https://rv.apg-clan.org/dlds/amxx_plugins/bot_flag_drop21.sma (Bot in same team should drop flag if a human is near, or suicide if the map has disabled flag throws.)

Plugin for testing private data access: https://rv.apg-clan.org/dlds/amxx_plugins/flag_goal_item2.sma

Affects: http://www.amxmodx.org/api/tfcx/tfc_get_user_goalitem https://github.com/alliedmodders/amxmodx/blob/master/modules/tfcx/CMisc.h

pizzahut2 commented 4 years ago

[QUOTE=pizzahut;2703132] Looked into this today.

According to

https://github.com/alliedmodders/amxmodx/blob/master/modules/tfcx/CMisc.h

PD_HAS_GOALITEM is 26

This is correct for Windows.

I made this test plugin:

https://rv.apg-clan.org/dlds/amxx_plugins/flag_goal_item2.sma

And it's 24 on Linux. [/QUOTE]

pizzahut2 commented 4 years ago

[QUOTE=pizzahut;2696224] Since I updated the HLDS a few months ago, this plugin stopped working:

https://rv.apg-clan.org/dlds/amxx_plugins/bot_flag_drop21.sma

It looks like tfc_get_user_goalitem is always returning false, so I suspect that hamdata.ini needs updating.

Had this issue originally on v1.9, so upgraded to v1.10 and still happening.

How can I get an updated hamdata for TFC (Linux)?

version Protocol version 48 Exe version 1.1.2.2/Stdio (tfc) Exe build: 15:16:04 Jul 24 2019 (8308)

meta version Metamod v1.21p38 2018/02/11 (5:13) by Will Day [url] http://www.metamod.org/ [/url] Patch: Metamod-P (mm-p) v38 by Jussi Kivilinna [url] http://metamod-p.sourceforge.net/ [/url] compiled: Feb 11 2018, 11:05:06 EET (optimized)

amxx version AMX Mod X 1.10.0.5392 ([url] http://www.amxmodx.org [/url]) Authors:

David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher Borja "faluco" Ferrer, Scott "DS" Ehlert Compiled: Mar 5 2020 05:52:37 Built from: [url] https://github.com/alliedmodders/amxmodx/commit/6ef4077 [/url] Build ID: 5392:6ef4077 Core mode: JIT+ASM32 ``` amxx plugins Currently loaded plugins: name version author file status [ 1] Advanced Bans 0.8.1 Exolent advanced_bans.a running [ 2] Admin Base 1.10.0.539 AMXX Dev Team admin.amxx running [ 3] Admin Commands 1.10.0.539 AMXX Dev Team admincmd.amxx running [ 4] Admin Help 1.10.0.539 AMXX Dev Team adminhelp.amxx running [ 5] Multi-Lingual System 1.10.0.539 AMXX Dev Team multilingual.am running [ 6] Menus Front-End 1.10.0.539 AMXX Dev Team menufront.amxx running [ 7] Commands Menu 1.10.0.539 AMXX Dev Team cmdmenu.amxx running [ 8] Players Menu 1.8.2 AMXX Dev Team plmenu_ab_tfc.a running [ 9] Teleport Menu 1.10.0.539 AMXX Dev Team telemenu.amxx running [ 10] Maps Menu 1.10.0.539 AMXX Dev Team mapsmenu.amxx running [ 11] Plugin Menu 1.10.0.539 AMXX Dev Team pluginmenu.amxx running [ 12] AMXX Gag 1.5.0 xPaw & Exolent amx_gag.amxx running [ 13] Anti Flood 1.10.0.539 AMXX Dev Team antiflood.amxx running [ 14] HLDS<->IRC 2.8 pizzahut irc.amxx running [ 15] Admin Chat 1.10.0.539 AMXX Dev Team adminchat.amxx running [ 16] Admin Votes 1.8.2 AMXX Dev Team adminvote_ab.am running [ 17] Enhanced Map Searching 1.6.2 EJL/JTP10181/piz amx_ejl_searchm running [ 18] Announce vote 2.1 pizzahut announce_vote.a running [ 19] DeagsMapManager 3.23r5m4 Deags/AMXX Commu dmm-m4.amxx running [ 20] TimeLeft 1.10.0.539 AMXX Dev Team timeleft.amxx running [ 21] Pause Plugins 1.10.0.539 AMXX Dev Team pausecfg.amxx running [ 22] Stats Configuration 1.10.0.539 AMXX Dev Team statscfg.amxx running [ 23] TFC Stats Logging 1.10.0.539 AMXX Dev Team stats_logging.a running [ 24] AFK Spectate 2.1 Cheesy Peteza, p afk_spec_2.amxx running [ 25] Block chop 1 pizzahut block_chop.amxx running [ 26] Check class limits 1.2 pizzahut check_class_lim running [ 27] GHW Connect Messages 2 GHW_Chronic,pizz GHW_connect2.am running [ 28] middies 2.0b Seraphim middies.amxx running [ 29] ChangeName 2 pizzahut name2.amxx running [ 30] No Spy Crash 1.3.1 hlstriker,pizzah nospycrash3.amx running [ 31] Remove AR 2 pizzahut remove-ar.amxx running [ 32] Bot flag drop 2.1-debug pizzahut bot_flag_drop21 debug [ 33] User bot control 11 pizzahut user_bot_contro running [ 34] engclient_cmd 1 pizzahut engclient_cmd.a running [ 35] Spray ID 1.12 Cheesy Peteza sprayid.amxx running [ 36] Admin Tag Enforcement/ 2.7.1 pizzahut tagprotect271.a running 36 plugins, 36 running ``` ``` meta list Currently loaded plugins: description stat pend file vers src load unlod [ 1] AMX Mod X RUN - amxmodx_mm_i386. v1.10.0. ini Start ANY [ 2] FoxBot RUN - foxbot_0792.so v0.792-b ini Start Start [ 3] LogMod RUN - logmod_mm_i386.s v0.8.0.0 ini ANY Pause [ 4] sparky utils v2 RUN - sparky_mm_i386.s v2.02.1 ini Start Never [ 5] Engine RUN - engine_amxx_i386 v1.10.0. pl1 ANY ANY [ 6] TfcX RUN - tfcx_amxx_i386.s v1.10.0. pl1 ANY ANY [ 7] FakeMeta RUN - fakemeta_amxx_i3 v1.10.0. pl1 ANY ANY [ 8] MySQL RUN - mysql_amxx_i386. v1.10.0. pl1 ANY ANY [ 9] GeoIP RUN - geoip_amxx_i386. v1.10.0. pl1 ANY ANY 9 plugins, 9 running ``` https://github.com/APGRoboCop/foxbot/releases [/QUOTE]
pizzahut2 commented 4 years ago
#include <amxmodx>
#include <fakemeta>

new player_data[32][32]

public plugin_init()
{
    register_plugin("flag goal item", "2", "pizzahut")
    register_event("StatusIcon", "flag_grab", "b", "1=1", "2&flag_")
    register_event("StatusIcon", "flag_drop", "b", "1=0", "2&flag_")
    set_task(1.0, "update_player_data",_,_,_, "b")
}

public flag_grab(id)
{
    new icon_name[32], player_name[32]
    read_data(2, icon_name, charsmax(icon_name))
    get_user_name(id, player_name, charsmax(player_name))
    client_print(0, print_console, "%s picked up the %s flag.", player_name, icon_name[5])
    //check_offsets(id)
}

public flag_drop(id)
{
    new icon_name[32], player_name[32]
    read_data(2, icon_name, charsmax(icon_name))
    get_user_name(id, player_name, charsmax(player_name))
    client_print(0, print_console, "%s dropped the %s flag.", player_name, icon_name[5])
    //check_offsets(id)
}

public update_player_data()
{
    static offset, players[32], num, i, id
    get_players(players, num)
    for(i=0; i<num; i++)
    {
        id = players[i]
        check_offsets(id)
        for(offset=12; offset<=29; offset++)
            player_data[id][offset] = get_pdata_int(id, offset)
    }
}

public check_offsets(id)
{
    static offset
    for(offset=12; offset<=29; offset++)
    {
        if (player_data[id][offset] != get_pdata_int(id, offset))
            client_print(0, print_console, "offset %d: %d => %d", offset, player_data[id][offset], get_pdata_int(id, offset))
    }
}
Arkshine commented 4 years ago

Are you sure? I believe 30 is correct for linux. Your plugin doesn't log after 29, can you try again to make sure? The HL update should not have changed those offsets.

pizzahut2 commented 4 years ago

No I'm actually not sure. Couldn't get other TFC admins to check and no response on forum so there's zero confirmation. Anyway updated the test plugin:

Testing result with this correction: offset 26 for Windows and Linux.

https://rv.apg-clan.org/dlds/amxx_plugins/flag_goal_item2.sma

#include <amxmodx>
#include <fakemeta>

new player_data[32][32]

#define linux_diff 3

public plugin_init()
{
    register_plugin("flag goal item", "2", "pizzahut")
    register_event("StatusIcon", "flag_grab", "b", "1=1", "2&flag_")
    register_event("StatusIcon", "flag_drop", "b", "1=0", "2&flag_")
    set_task(1.0, "update_player_data",_,_,_, "b")
}

public flag_grab(id)
{
    new icon_name[32], player_name[32]
    read_data(2, icon_name, charsmax(icon_name))
    get_user_name(id, player_name, charsmax(player_name))
    client_print(0, print_console, "%s picked up the %s flag.", player_name, icon_name[5])
    //check_offsets(id)
}

public flag_drop(id)
{
    new icon_name[32], player_name[32]
    read_data(2, icon_name, charsmax(icon_name))
    get_user_name(id, player_name, charsmax(player_name))
    client_print(0, print_console, "%s dropped the %s flag.", player_name, icon_name[5])
    //check_offsets(id)
}

public update_player_data()
{
    static offset, players[32], num, i, id
    get_players(players, num)
    for(i=0; i<num; i++)
    {
        id = players[i]
        check_offsets(id)
        for(offset=12; offset<=30; offset++)
            player_data[id][offset] = get_pdata_int(id, offset, linux_diff)
    }
}

public check_offsets(id)
{
    static offset
    for(offset=12; offset<=30; offset++)
    {
        if (player_data[id][offset] != get_pdata_int(id, offset, linux_diff))
            client_print(0, print_console, "offset %d: %d => %d", offset, player_data[id][offset], get_pdata_int(id, offset, linux_diff))
    }
}
WPMGPRoSToTeMa commented 4 years ago

Offsets in tfcx should be corrected according to gamedata just like in dodfun. Not sure about this member but someone reported a problem with heal/poison timers.

pizzahut2 commented 4 years ago

I see this in amxmodx/data/gamedata/common.games/entities.games/tfc/offsets-cbaseentity.txt :

                    "is_unableto_spy_or_teleport"  // BOOL
                    {
                        "type"      "integer"

                        "windows"   "104"
                        "linux"     "120"
                        "mac"       "120"
                    }
WPMGPRoSToTeMa commented 4 years ago

@pizzahut2 note that it should be divided by 4.

pizzahut2 commented 3 years ago

Related to this, tfc_setbammo is broken, too (on Linux). When trying to set TFC_AMMO_NADE1 and TFC_AMMO_NADE2, it changes TFC_AMMO_NADE2 and the grenade type of the primary grenades (instead of the count).

So for the following plugin, which used to work fine, now when you capture the flag as medic, you throw nail grenades as primary because of this issue. https://forums.alliedmods.net/showthread.php?t=69829 This is not a plugin issue, but an AMXX issue.

This has been happening on Battlezone and I re-produced this bug on Royston Vasey. (Though I'm going to turn the plugin off on the latter.)

Private data from an old Allied Modders thread:

int                        no_grenades_1;        /*    72     4 */
int                        no_grenades_2;        /*    76     4 */
int                        tp_grenades_1;        /*    80     4 */
int                        tp_grenades_2;        /*    84     4 */

Server 1 (Battlezone):

(EDIT: Two days later, this server has switched to ReHLDS, with the issue still present.)

version Protocol version 48 Exe version 1.1.2.2/Stdio (tfc) Exe build: 19:52:19 Aug 3 2020 (8684)

meta version Metamod v1.21p38 2018/02/11 (5:13)

amxx version AMX Mod X 1.10.0.5435 (http://www.amxmodx.org)

Server 2 (Royston Vasey):

version Protocol version 48 Exe version 1.1.2.2/Stdio (tfc) Exe build: 19:52:19 Aug 3 2020 (8684)

meta version Metamod v1.21p-APG 2020/03/30 (5:13) Patch: Metamod-P (mm-p) v39

amxx version AMX Mod X 1.9.0.5281 (http://www.amxmodx.org)

pizzahut2 commented 3 years ago

Turned out both test servers still had an old "tfc_i386.so" file which took precedence over the newer "tfc.so" library, so both servers were misconfigured and that's why the offsets didn't work.