qboolean SV_ParseBanlistLegacy(char* line, time_t aclock, int linenumber){
    banList_t *this;
    time_t expire = 0;
    time_t create = 0;
    char reason[128];
    char guid[9];
    guid[8] = 0;
    char playername[MAX_NAME_LENGTH];
    int i;
    char *tmp;
    netadr_t adr;

    expire = atoi(Info_ValueForKey(line, "exp"));
    tmp = Info_ValueForKey(line, "create");
    if(tmp && tmp[0])
    {
        create = atoi(tmp);
    }
    tmp = Info_ValueForKey(line, "netadr");
    if(tmp && tmp[0])
    {
        Plugin_NET_StringToAdr(tmp, &adr, NA_UNSPEC);
    }else{
        memset(&adr, 0, NA_BAD);
    }
    Q_strncpyz(reason, Info_ValueForKey(line, "rsn"), sizeof(reason));
    Q_strncpyz(guid, Info_ValueForKey(line, "guid"), sizeof(guid));
    Q_strncpyz(playername, Info_ValueForKey(line, "nick"), sizeof(playername));


    if(expire < aclock && expire != (time_t)-1)
    {
      return qtrue;
    }
    this = banlist;
    if(!this)
        return qfalse;

    if(guid[7]){
        for(i = 0; i < current_banindex; this++, i++){
            if(Q_stricmpn(this->guid, guid, 8) == 0){
                Plugin_Printf("Error: This player with GUID: %s is already banned on this server (line: %d)\n",guid, linenumber);
                return qfalse;
            }
        }
    }else{
        Plugin_Printf("Error: This player has no guid (line: %d)\n",linenumber);
        return qfalse; //Bad entry: No Id
    }

    if(!SV_OversizeBanlistAlign())
        return qfalse;

    this = &banlist[current_banindex];

    Q_strncpyz(this->guid, guid, sizeof(this->guid));
    this->expire = expire;
    this->created = create;
    Q_strncpyz(this->reason, reason, sizeof(this->reason));
    Q_strncpyz(this->playername, playername, sizeof(this->playername));
    this->remote = adr;

    current_banindex++; //Rise the array index
    return qtrue;
}
Ejemplo n.º 2
0
qboolean SV_ParseBanlist(char* line, time_t aclock, int linenumber){
    banList_t *this;
    uint64_t playerid = 0;
    uint64_t adminsteamid = 0;
    time_t expire = 0;
    time_t create = 0;
    char reason[128];
    char playername[MAX_NAME_LENGTH];
    int i;
    char *tmp;
    netadr_t adr;

    playerid = Plugin_StringToSteamID(Info_ValueForKey(line, "playerid"));
    adminsteamid = Plugin_StringToSteamID(Info_ValueForKey(line, "asteamid"));
    expire = atoi(Info_ValueForKey(line, "exp"));
    create = atoi(Info_ValueForKey(line, "create"));

    tmp = Info_ValueForKey(line, "netadr");
    if(tmp && tmp[0])
    {
        Plugin_NET_StringToAdr(tmp, &adr, NA_UNSPEC);
    }else{
        memset(&adr, 0, NA_BAD);
    }

    Q_strncpyz(reason, Info_ValueForKey(line, "rsn"), sizeof(reason));
    Q_strncpyz(playername, Info_ValueForKey(line, "nick"), sizeof(playername));


    if(expire < aclock && expire != (time_t)-1)
    {
            return qtrue;
    }
    this = banlist;
    if(!this)
        return qfalse;

    if(playerid){
        for(i = 0; i < current_banindex; this++, i++){
            if(this->playerid == playerid){
                Plugin_SteamIDToString(playerid, tmp, sizeof(tmp));
                Plugin_Printf("Error: This player with playerid: %s is already banned on this server (line: %d)\n", tmp, linenumber);
                return qfalse;
            }
        }
    }else{
        Plugin_Printf("Error: This player has no id (line: %d)\n",linenumber);
        return qfalse; //Bad entry: No Id
    }

    if(!SV_OversizeBanlistAlign())
        return qfalse;

    this = &banlist[current_banindex];

    this->playerid = playerid;
    this->adminsteamid = adminsteamid;
    this->expire = expire;
    this->created = create;
    Q_strncpyz(this->reason, reason, sizeof(this->reason));
    Q_strncpyz(this->playername, playername, sizeof(this->playername));
    this->remote = adr;

    current_banindex++; //Rise the array index
    return qtrue;
}