Added file forgotten in previous commit

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3737 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-07-12 00:34:40 +00:00
parent a44b531525
commit dd95352fe2

53
src/config/player.cpp Normal file
View File

@ -0,0 +1,53 @@
#include "config/player.hpp"
#include "race/race_manager.hpp"
#include "modes/world.hpp"
ActivePlayer::ActivePlayer(Player* player)
{
m_player = player;
m_device = NULL;
}
ActivePlayer::~ActivePlayer()
{
setDevice(NULL);
}
Player* ActivePlayer::getPlayer()
{
return m_player;
}
void ActivePlayer::setPlayer(Player* player)
{
m_player = player;
}
InputDevice* ActivePlayer::getDevice() const
{
return m_device;
}
void ActivePlayer::setDevice(InputDevice* device)
{
if (m_device != NULL) m_device->setPlayer(NULL);
m_device = device;
if(device != NULL)
device->setPlayer(this);
}
PlayerKart* ActivePlayer::getKart()
{
const int amount = RaceManager::getWorld()->getCurrentNumLocalPlayers();
for (int p=0; p<amount; p++)
{
if (RaceManager::getWorld()->getLocalPlayerKart(p)->getPlayer() == m_player)
{
return RaceManager::getWorld()->getLocalPlayerKart(p);
}
}
std::cout << "ActivePlayer::getKart() failed to find player named " << m_player->getName() << std::endl;
return NULL;
}