IS4Code / PawnPlus

A SA-MP plugin enhancing the capabilities of the Pawn programming language
MIT License
102 stars 17 forks source link

LFN incompatibility #29

Closed AGraber closed 4 years ago

AGraber commented 4 years ago
#include <a_samp>
#include <PawnPlus>

forward AVeryLongPublicFunctonThatExceeds32Characters();
public AVeryLongPublicFunctonThatExceeds32Characters()
{
    printf("test");
}

forward _pp@on_init@Testing();
public _pp@on_init@Testing()
{
    pawn_call_public(amx_encode_public(amx_public_index("AVeryLongPublicFunctonThatExceeds32Characters")), "");
}

main() {}

Fails with:

[PawnPlus] pawn_call_public: public function '' was not found

In fact, it fails every time, even with a short public function name, if LFN is loaded.

IS4Code commented 4 years ago

@AGraber What does amx_public_index itself return?

AGraber commented 4 years ago
#include <a_samp>
#include <PawnPlus>

forward AVeryLongPublicFunctonThatExceeds32Characters();
public AVeryLongPublicFunctonThatExceeds32Characters()
{
    printf("test");
}

forward _pp@on_init@Testing();
public _pp@on_init@Testing()
{
    new const index = amx_public_index("AVeryLongPublicFunctonThatExceeds32Characters");
    printf("index: %d", index);
    new encoded_public[2];
    encoded_public = amx_encode_public(index);

    printf("encoded_public: %08x %08x", encoded_public[0], encoded_public[1]);
    pawn_call_public(amx_encode_public(index), "");
}

main() {}

Produces:

index: 0
encoded_public: 1B010101 01010000
[PawnPlus] pawn_call_public: public function '' was not found

The index is correct, changing the function name to something starting with _z (so it comes alphabetically after _pp@on_init) changes it to 1, but pawn_call_public keeps failing

IS4Code commented 4 years ago

@AGraber This is an issue of LFN more than of PawnPlus, as LFN hooks amx_FindPublic but doesn't call the trampoline. Loading LFN before PawnPlus (and preferably any plugin that uses SAMPGDK) is recommended. For further discussion, let's continue here.