Renamed PlayerController into LocalPlayerController.

This commit is contained in:
hiker 2015-12-10 17:54:29 +11:00
parent 770d05f0de
commit dbd210d08c
8 changed files with 38 additions and 37 deletions

View File

@ -21,7 +21,7 @@
#include "input/gamepad_config.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/player_controller.hpp"
#include "karts/controller/local_player_controller.hpp"
/** Constructor for GamePadDevice from a connected gamepad for which no
* configuration existed (defaults will be used)
@ -124,7 +124,7 @@ void GamePadDevice::resetAxisDirection(const int axis,
bind.getDirection()== direction &&
pk->getController() != NULL)
{
((PlayerController*)(pk->getController()))
((LocalPlayerController*)(pk->getController()))
->action((PlayerAction)n, 0);
return;
}

View File

@ -22,7 +22,6 @@
#include "input/input.hpp"
#include "input/input_device.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/player_controller.hpp"
#include "modes/world.hpp"
#include "race/race_manager.hpp"
#include "states_screens/state_manager.hpp"

View File

@ -17,7 +17,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "karts/controller/player_controller.hpp"
#include "karts/controller/local_player_controller.hpp"
#include "audio/sfx_base.hpp"
#include "config/stk_config.hpp"
@ -49,7 +49,7 @@
* \param init_pos The start coordinates and heading of the kart.
* \param player_index Index of the player kart.
*/
PlayerController::PlayerController(AbstractKart *kart,
LocalPlayerController::LocalPlayerController(AbstractKart *kart,
StateManager::ActivePlayer *player,
unsigned int player_index)
: Controller(kart)
@ -68,24 +68,24 @@ PlayerController::PlayerController(AbstractKart *kart,
m_full_sound = SFXManager::get()->createSoundSource( "energy_bar_full" );
reset();
} // PlayerController
} // LocalPlayerController
//-----------------------------------------------------------------------------
/** Destructor for a player kart.
*/
PlayerController::~PlayerController()
LocalPlayerController::~LocalPlayerController()
{
m_bzzt_sound->deleteSFX();
m_wee_sound ->deleteSFX();
m_ugh_sound ->deleteSFX();
m_grab_sound->deleteSFX();
m_full_sound->deleteSFX();
} // ~PlayerController
} // ~LocalPlayerController
//-----------------------------------------------------------------------------
/** Resets the player kart for a new or restarted race.
*/
void PlayerController::reset()
void LocalPlayerController::reset()
{
m_steer_val_l = 0;
m_steer_val_r = 0;
@ -102,7 +102,7 @@ void PlayerController::reset()
* avoid that any keys pressed at the time the menu is opened are still
* considered to be pressed.
*/
void PlayerController::resetInputState()
void LocalPlayerController::resetInputState()
{
m_steer_val_l = 0;
m_steer_val_r = 0;
@ -127,7 +127,7 @@ void PlayerController::resetInputState()
* and if it's 0 it indicates that the corresponding button
* was released.
*/
void PlayerController::action(PlayerAction action, int value)
void LocalPlayerController::action(PlayerAction action, int value)
{
switch (action)
{
@ -235,11 +235,11 @@ void PlayerController::action(PlayerAction action, int value)
//-----------------------------------------------------------------------------
/** Handles steering for a player kart.
*/
void PlayerController::steer(float dt, int steer_val)
void LocalPlayerController::steer(float dt, int steer_val)
{
if(UserConfigParams::m_gamepad_debug)
{
Log::debug("PlayerController", "steering: steer_val %d ", steer_val);
Log::debug("LocalPlayerController", "steering: steer_val %d ", steer_val);
RaceGUIBase* gui_base = World::getWorld()->getRaceGUI();
gui_base->clearAllMessages();
gui_base->addMessage(StringUtils::insertValues(L"steer_val %i", steer_val), m_kart, 1.0f,
@ -292,7 +292,7 @@ void PlayerController::steer(float dt, int steer_val)
} // no key is pressed
if(UserConfigParams::m_gamepad_debug)
{
Log::debug("PlayerController", " set to: %f\n", m_controls->m_steer);
Log::debug("LocalPlayerController", " set to: %f\n", m_controls->m_steer);
}
m_controls->m_steer = std::min(1.0f, std::max(-1.0f, m_controls->m_steer));
@ -303,7 +303,7 @@ void PlayerController::steer(float dt, int steer_val)
/** Callback when the skidding bonus is triggered. The player controller
* resets the current steering to 0, which makes the kart easier to control.
*/
void PlayerController::skidBonusTriggered()
void LocalPlayerController::skidBonusTriggered()
{
m_controls->m_steer = 0;
} // skidBonusTriggered
@ -311,13 +311,13 @@ void PlayerController::skidBonusTriggered()
//-----------------------------------------------------------------------------
/** Updates the player kart, called once each timestep.
*/
void PlayerController::update(float dt)
void LocalPlayerController::update(float dt)
{
if (UserConfigParams::m_gamepad_debug)
{
// Print a dividing line so that it's easier to see which events
// get received in which order in the one frame.
Log::debug("PlayerController", "irr_driver", "-------------------------------------");
Log::debug("LocalPlayerController", "irr_driver", "-------------------------------------");
}
// Don't do steering if it's replay. In position only replay it doesn't
@ -410,7 +410,7 @@ void PlayerController::update(float dt)
//-----------------------------------------------------------------------------
/** Checks if the kart was overtaken, and if so plays a sound
*/
void PlayerController::setPosition(int p)
void LocalPlayerController::setPosition(int p)
{
if(m_kart->getPosition()<p)
{
@ -433,7 +433,7 @@ void PlayerController::setPosition(int p)
/** Called when a kart finishes race.
* /param time Finishing time for this kart.
d*/
void PlayerController::finishedRace(float time)
void LocalPlayerController::finishedRace(float time)
{
// This will implicitely trigger setting the first end camera to be active
m_camera->setMode(Camera::CM_FINAL);
@ -443,7 +443,7 @@ void PlayerController::finishedRace(float time)
//-----------------------------------------------------------------------------
/** Called when a kart hits or uses a zipper.
*/
void PlayerController::handleZipper(bool play_sound)
void LocalPlayerController::handleZipper(bool play_sound)
{
// Only play a zipper sound if it's not already playing, and
// if the material has changed (to avoid machine gun effect
@ -471,7 +471,7 @@ void PlayerController::handleZipper(bool play_sound)
* let the server determine the powerup/attachment for
* the clients.
*/
void PlayerController::collectedItem(const Item &item, int add_info, float old_energy)
void LocalPlayerController::collectedItem(const Item &item, int add_info, float old_energy)
{
if (old_energy < m_kart->getKartProperties()->getNitroMax() &&
m_kart->getEnergy() == m_kart->getKartProperties()->getNitroMax())

View File

@ -18,8 +18,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_PLAYERKART_HPP
#define HEADER_PLAYERKART_HPP
#ifndef HEADER_LOCAL_PLAYER_CONTROLLER_HPP
#define HEADER_LOCAL_PLAYER_CONTROLLER_HPP
#include "karts/controller/controller.hpp"
@ -33,7 +33,7 @@ class SFXBase;
*
* \ingroup controller
*/
class PlayerController : public Controller
class LocalPlayerController : public Controller
{
private:
int m_steer_val, m_steer_val_l, m_steer_val_r;
@ -56,10 +56,10 @@ private:
void steer(float, int);
public:
PlayerController (AbstractKart *kart,
LocalPlayerController (AbstractKart *kart,
StateManager::ActivePlayer *_player,
unsigned int player_index);
~PlayerController ();
~LocalPlayerController ();
void update (float);
void action (PlayerAction action, int value);
void handleZipper (bool play_sound);
@ -82,6 +82,6 @@ public:
/** Player will always be able to get a slipstream bonus. */
virtual bool disableSlipstreamBonus() const { return false; }
}; // PlayerController
}; // LocalPlayerController
#endif

View File

@ -26,7 +26,7 @@
#include "karts/kart_model.hpp"
#include "karts/kart_properties.hpp"
#include "karts/rescue_animation.hpp"
#include "karts/controller/player_controller.hpp"
#include "karts/controller/local_player_controller.hpp"
#include "physics/physics.hpp"
#include "states_screens/race_gui_base.hpp"
#include "tracks/track.hpp"
@ -409,7 +409,7 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
switch(kart_type)
{
case RaceManager::KT_PLAYER:
controller = new PlayerController(new_kart,
controller = new LocalPlayerController(new_kart,
StateManager::get()->getActivePlayer(local_player_id),
local_player_id);
m_num_players ++;

View File

@ -31,7 +31,7 @@
#include "input/device_manager.hpp"
#include "input/keyboard_device.hpp"
#include "items/projectile_manager.hpp"
#include "karts/controller/player_controller.hpp"
#include "karts/controller/local_player_controller.hpp"
#include "karts/controller/end_controller.hpp"
#include "karts/controller/skidding_ai.hpp"
#include "karts/controller/network_player_controller.hpp"
@ -311,7 +311,7 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
switch(kart_type)
{
case RaceManager::KT_PLAYER:
controller = new PlayerController(new_kart,
controller = new LocalPlayerController(new_kart,
StateManager::get()->getActivePlayer(local_player_id),
local_player_id);
m_num_players ++;
@ -1090,7 +1090,8 @@ void World::updateHighscores(int* best_highscore_rank, int* best_finish_time,
Highscores* highscores = getHighscores();
PlayerController *controller = (PlayerController*)(k->getController());
LocalPlayerController *controller =
(LocalPlayerController*)(k->getController());
int highscore_rank = 0;
if (controller->getPlayer()->getProfile() != NULL) // if we have the player profile here
@ -1230,8 +1231,8 @@ void World::unpause()
// Note that we can not test for isPlayerController here, since
// an EndController will also return 'isPlayerController' if the
// kart belonged to a player.
PlayerController *pc =
dynamic_cast<PlayerController*>(m_karts[i]->getController());
LocalPlayerController *pc =
dynamic_cast<LocalPlayerController*>(m_karts[i]->getController());
if(pc)
pc->resetInputState();
}

View File

@ -28,7 +28,7 @@
#include "items/flyable.hpp"
#include "karts/kart_properties.hpp"
#include "karts/rescue_animation.hpp"
#include "karts/controller/player_controller.hpp"
#include "karts/controller/local_player_controller.hpp"
#include "modes/soccer_world.hpp"
#include "modes/world.hpp"
#include "karts/explosion_animation.hpp"
@ -307,7 +307,8 @@ void Physics::update(float dt)
// Check for achievements
AbstractKart * kart = World::getWorld()->getKart(f->getOwnerId());
PlayerController *c = dynamic_cast<PlayerController*>(kart->getController());
LocalPlayerController *c =
dynamic_cast<LocalPlayerController*>(kart->getController());
// Check that it's not a kart hitting itself (this can
// happen at the time a flyable is shot - release too close