5aa4056633
added basic player handling method (no login yet)
65 lines
1.5 KiB
C
65 lines
1.5 KiB
C
/*
|
|
* players.c
|
|
*
|
|
* Copyright (C) 2012 - Gergely POLONKAI
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include <glib.h>
|
|
|
|
#include "networking.h"
|
|
#include "players.h"
|
|
|
|
GSList *players = NULL;
|
|
|
|
gboolean
|
|
wmud_player_auth(wmudClient *client)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
static gint
|
|
find_player_by_name(wmudPlayer *player, gchar *player_name)
|
|
{
|
|
return g_ascii_strcasecmp(player->player_name, player_name);
|
|
}
|
|
|
|
wmudPlayer *
|
|
wmud_player_exists(gchar *player_name)
|
|
{
|
|
GSList *player_elem;
|
|
|
|
if ((player_elem = g_slist_find_custom(players, player_name, (GCompareFunc)find_player_by_name)) == NULL)
|
|
return NULL;
|
|
|
|
return player_elem->data;
|
|
|
|
}
|
|
|
|
void
|
|
wmud_player_free(wmudPlayer **player)
|
|
{
|
|
if (!*player)
|
|
return;
|
|
if ((*player)->player_name)
|
|
g_free((*player)->player_name);
|
|
if ((*player)->cpassword)
|
|
g_free((*player)->cpassword);
|
|
if ((*player)->email)
|
|
g_free((*player)->email);
|
|
g_free(*player);
|
|
*player = NULL;
|
|
}
|
|
|