cssdm_players.cpp
author Ruben Gonzalez <drifter01620@gmail.com>
Wed Oct 01 11:50:24 2014 -0400 (2014-10-01)
changeset 193 277c856152b0
parent 0 67dcd379a2d5
permissions -rw-r--r--
Update linix CS:GO gamedata
[email protected]
     1
/**
[email protected]
     2
 * vim: set ts=4 :
[email protected]
     3
 * ===============================================================
[email protected]
     4
 * CS:S DM, Copyright (C) 2004-2007 AlliedModders LLC. 
[email protected]
     5
 * By David "BAILOPAN" Anderson
[email protected]
     6
 * All rights reserved.
[email protected]
     7
 * ===============================================================
[email protected]
     8
 *
[email protected]
     9
 * This program is free software; you can redistribute it and/or modify
[email protected]
    10
 * it under the terms of the GNU General Public License as published by
[email protected]
    11
 * the Free Software Foundation; either version 2 of the License, or (at
[email protected]
    12
 * your option) any later version.
[email protected]
    13
 * 
[email protected]
    14
 * This program is distributed in the hope that it will be useful, but
[email protected]
    15
 * WITHOUT ANY WARRANTY; without even the implied warranty of
[email protected]
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
[email protected]
    17
 * General Public License for more details.
[email protected]
    18
 * 
[email protected]
    19
 * You should have received a copy of the GNU General Public License
[email protected]
    20
 * along with this program; see the file COPYING; if not, write to the
[email protected]
    21
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
[email protected]
    22
 * MA 02110-1301 USA
[email protected]
    23
 * 
[email protected]
    24
 * Version: $Id$
[email protected]
    25
 */
[email protected]
    26
[email protected]
    27
#include "cssdm_players.h"
[email protected]
    28
#include "cssdm_headers.h"
[email protected]
    29
#include "cssdm_utils.h"
[email protected]
    30
#include "cssdm_config.h"
[email protected]
    31
#include "cssdm_includesdk.h"
[email protected]
    32
[email protected]
    33
ClientListener g_ClientListener;
[email protected]
    34
dm_player_t g_players[65];
[email protected]
    35
[email protected]
    36
void DM_ResetPlayer(int client);
[email protected]
    37
void DM_ActivatePlayer(int client);
[email protected]
    38
[email protected]
    39
void ClientListener::OnClientConnected(int client)
[email protected]
    40
{
[email protected]
    41
	memset(&g_players[client], 0, sizeof(dm_player_t));
[email protected]
    42
}
[email protected]
    43
[email protected]
    44
void ClientListener::OnClientDisconnecting(int client)
[email protected]
    45
{
[email protected]
    46
	dm_player_t *player = DM_GetPlayer(client);
[email protected]
    47
[email protected]
    48
	DM_ResetPlayer(client);
[email protected]
    49
}
[email protected]
    50
[email protected]
    51
void ClientListener::OnClientPutInServer(int client)
[email protected]
    52
{
[email protected]
    53
	DM_ActivatePlayer(client);
[email protected]
    54
}
[email protected]
    55
[email protected]
    56
void DM_ResetPlayer(int client)
[email protected]
    57
{
[email protected]
    58
	dm_player_t *player = DM_GetPlayer(client);
[email protected]
    59
	if (!player)
[email protected]
    60
	{
[email protected]
    61
		return;
[email protected]
    62
	}
[email protected]
    63
[email protected]
    64
	if (player->respawn_timer)
[email protected]
    65
	{
[email protected]
    66
		timersys->KillTimer(player->respawn_timer);
[email protected]
    67
	}
[email protected]
    68
[email protected]
    69
	memset(player, 0, sizeof(dm_player_t));
[email protected]
    70
}
[email protected]
    71
[email protected]
    72
void DM_ActivatePlayer(int client)
[email protected]
    73
{
[email protected]
    74
	dm_player_t *player = DM_GetPlayer(client);
[email protected]
    75
	if (!player)
[email protected]
    76
	{
[email protected]
    77
		return;
[email protected]
    78
	}
[email protected]
    79
[email protected]
    80
	CBaseEntity *pEntity = DM_GetBaseEntity(client);
[email protected]
    81
	if (!pEntity)
[email protected]
    82
	{
[email protected]
    83
		return;
[email protected]
    84
	}
[email protected]
    85
[email protected]
    86
	player->pEdict = gamehelpers->EdictOfIndex(client);
[email protected]
    87
	player->pEntity = pEntity;
[email protected]
    88
	player->pInfo = playerinfomngr->GetPlayerInfo(player->pEdict);
[email protected]
    89
	player->pBot = botmanager->GetBotController(player->pEdict);
[email protected]
    90
	player->userid = engine->GetPlayerUserId(player->pEdict);
[email protected]
    91
}
[email protected]
    92
[email protected]
    93
dm_player_t *DM_GetPlayer(int client)
[email protected]
    94
{
[email protected]
    95
	if (client < 1 || client > gpGlobals->maxClients)
[email protected]
    96
	{
[email protected]
    97
		return NULL;
[email protected]
    98
	}
[email protected]
    99
[email protected]
   100
	return &g_players[client];
[email protected]
   101
}