Anticheat - structuring
#10

Quote:

* Y_Less - very thorough research

, thanks!

Anyway, I would still recommend using y_master - I used to do what you're doing here and developed that to prevent duplication (because I got royally frustrated with writing everything twice):

pawn Код:
#if defined AC_SLAVE
    AC_STOCK AC_GetPlayerMoney(playerid) {
        return CallRemoteFunction(#AC_GetPlayerMoney, "i", playerid);
    }
    #if defined _ALS_GetPlayerMoney
        #undef GetPlayerMoney
    #else
        #define _ALS_GetPlayerMoney
    #endif
    #define GetPlayerMoney AC_GetPlayerMoney
#else
    AC_PUBLIC AC_GetPlayerMoney(playerid) {
        if (IsPlayerConnected(playerid)) {
            new bad_money = U_GetPlayerMoney(playerid);
            return bad_money < AC_players[playerid][AC_pMoney] ? bad_money : AC_players[playerid][AC_pMoney];
        }
        return 0;
    }
    #if defined _ALS_GetPlayerMoney
        #undef GetPlayerMoney
    #else
        #define _ALS_GetPlayerMoney
    #endif
    #define GetPlayerMoney AC_GetPlayerMoney
#endif
Becomes:

pawn Код:
foreign AC_GetPlayerMoney(playerid);
global AC_GetPlayerMoney(playerid) {
    if (IsPlayerConnected(playerid)) {
        new bad_money = U_GetPlayerMoney(playerid);
        return bad_money < AC_players[playerid][AC_pMoney] ? bad_money : AC_players[playerid][AC_pMoney];
    }
    return 0;
}
#if defined _ALS_GetPlayerMoney
    #undef GetPlayerMoney
#else
    #define _ALS_GetPlayerMoney
#endif
#define GetPlayerMoney AC_GetPlayerMoney
Only one declaration of the function, with the compiler adding and removing calls as appropriate.

Other than that, the layout looks good and thoroughly organised!

Also, I don't tend to rely on using the "FILTERSCRIPT" macro as people are rubbish at using it:

pawn Код:
new bool:AC_FILTERSCRIPT = false;

public OnFilterScriptInit()
{
    AC_FILTERSCRIPT = true;
    AC_OnScriptInit();
}

public OnGameModeInit()
{
    if (!AC_FILTERSCRIPT) AC_OnScriptInit();
}
Reply


Messages In This Thread
Anticheat - structuring - by Dan.. - 25.04.2013, 18:32
Re: Anticheat - structuring - by MP2 - 25.04.2013, 19:03
Re: Anticheat - structuring - by KiNG3 - 25.04.2013, 19:24
Re: Anticheat - structuring - by cessil - 25.04.2013, 19:25
Re: Anticheat - structuring - by Dan.. - 26.04.2013, 12:09
Re: Anticheat - structuring - by Dan.. - 26.04.2013, 12:19
Re: Anticheat - structuring - by cessil - 26.04.2013, 12:40
Re: Anticheat - structuring - by Dan.. - 26.04.2013, 12:53
Re: Anticheat - structuring - by Dan.. - 30.04.2013, 19:58
Re: Anticheat - structuring - by Y_Less - 30.04.2013, 20:34
Re: Anticheat - structuring - by Dan.. - 01.05.2013, 14:31
Re: Anticheat - structuring - by Y_Less - 01.05.2013, 15:03
Re: Anticheat - structuring - by Dan.. - 01.05.2013, 19:43
Re: Anticheat - structuring - by Y_Less - 01.05.2013, 20:44
Re: Anticheat - structuring - by Dan.. - 02.05.2013, 05:28
Re: Anticheat - structuring - by Edvin - 10.05.2013, 18:19
Re: Anticheat - structuring - by Lordzy - 10.05.2013, 18:21
Re: Anticheat - structuring - by Edvin - 10.05.2013, 18:24
Re: Anticheat - structuring - by Gigi-The-Beast - 10.05.2013, 18:53
Re: Anticheat - structuring - by Yiin - 10.05.2013, 18:56
Re: Anticheat - structuring - by Gigi-The-Beast - 10.05.2013, 19:26
Re: Anticheat - structuring - by Y_Less - 12.05.2013, 02:13
Re: Anticheat - structuring - by Dan.. - 12.05.2013, 19:04
Re: Anticheat - structuring - by Y_Less - 12.05.2013, 19:09
Re: Anticheat - structuring - by Gigi-The-Beast - 12.05.2013, 19:56
Re: Anticheat - structuring - by Y_Less - 12.05.2013, 20:10

Forum Jump:


Users browsing this thread: 8 Guest(s)