From dbd210d08ca232375b9f896f79d3ae92eb4fee77 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 10 Dec 2015 17:54:29 +1100 Subject: [PATCH] Renamed PlayerController into LocalPlayerController. --- sources.cmake | 2 +- src/input/gamepad_device.cpp | 4 +-- src/input/input_device.cpp | 1 - ...roller.cpp => local_player_controller.cpp} | 36 +++++++++---------- ...roller.hpp => local_player_controller.hpp} | 12 +++---- src/modes/soccer_world.cpp | 4 +-- src/modes/world.cpp | 11 +++--- src/physics/physics.cpp | 5 +-- 8 files changed, 38 insertions(+), 37 deletions(-) rename src/karts/controller/{player_controller.cpp => local_player_controller.cpp} (94%) rename src/karts/controller/{player_controller.hpp => local_player_controller.hpp} (92%) diff --git a/sources.cmake b/sources.cmake index a4e7b53d7..a009c1682 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,5 +1,5 @@ # Modify this file to change the last-modified date when you add/remove a file. -# This will then trigger a new cmake run automatically. +# This will then trigger a new cmake run automatically. file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*") diff --git a/src/input/gamepad_device.cpp b/src/input/gamepad_device.cpp index c554c0c1b..6b8429ecd 100644 --- a/src/input/gamepad_device.cpp +++ b/src/input/gamepad_device.cpp @@ -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; } diff --git a/src/input/input_device.cpp b/src/input/input_device.cpp index a9a9be510..47ef36aed 100644 --- a/src/input/input_device.cpp +++ b/src/input/input_device.cpp @@ -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" diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/local_player_controller.cpp similarity index 94% rename from src/karts/controller/player_controller.cpp rename to src/karts/controller/local_player_controller.cpp index 849d3ca4c..7b421ef62 100644 --- a/src/karts/controller/player_controller.cpp +++ b/src/karts/controller/local_player_controller.cpp @@ -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()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()) diff --git a/src/karts/controller/player_controller.hpp b/src/karts/controller/local_player_controller.hpp similarity index 92% rename from src/karts/controller/player_controller.hpp rename to src/karts/controller/local_player_controller.hpp index 3f043159c..90648658d 100644 --- a/src/karts/controller/player_controller.hpp +++ b/src/karts/controller/local_player_controller.hpp @@ -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 diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index 2b18d14f6..baf06e643 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -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 ++; diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 1c7abb8e8..f6f7d25df 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -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(m_karts[i]->getController()); + LocalPlayerController *pc = + dynamic_cast(m_karts[i]->getController()); if(pc) pc->resetInputState(); } diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 864010442..650b6eec2 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -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(kart->getController()); + LocalPlayerController *c = + dynamic_cast(kart->getController()); // Check that it's not a kart hitting itself (this can // happen at the time a flyable is shot - release too close