From 01b95d873e113bf66a1e43a63a81b052359babd0 Mon Sep 17 00:00:00 2001 From: Benau Date: Sat, 15 Sep 2018 11:18:30 +0800 Subject: [PATCH] Header clean up --- src/graphics/slip_stream.cpp | 1 + src/items/attachment.cpp | 1 + src/items/plunger.cpp | 1 + src/items/powerup.cpp | 1 + src/items/rubber_ball.cpp | 2 + src/items/swatter.cpp | 1 + src/karts/abstract_kart_animation.cpp | 1 + src/karts/controller/kart_control.cpp | 47 +++++++++------------- src/karts/controller/kart_control.hpp | 23 ++--------- src/karts/controller/player_controller.cpp | 1 + src/karts/kart.cpp | 1 + src/karts/kart.hpp | 1 + src/karts/max_speed.cpp | 1 + src/karts/skidding.hpp | 1 + src/modes/soccer_world.cpp | 1 + src/network/protocols/game_protocol.cpp | 1 + 16 files changed, 37 insertions(+), 48 deletions(-) diff --git a/src/graphics/slip_stream.cpp b/src/graphics/slip_stream.cpp index a6bd14966..46c7e1d5e 100644 --- a/src/graphics/slip_stream.cpp +++ b/src/graphics/slip_stream.cpp @@ -32,6 +32,7 @@ #include "karts/kart_properties.hpp" #include "karts/max_speed.hpp" #include "modes/world.hpp" +#include "network/rewind_info.hpp" #include "network/rewind_manager.hpp" #include "tracks/quad.hpp" #include "utils/constants.hpp" diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index 2314a5eb7..e7567c08f 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -36,6 +36,7 @@ #include "karts/explosion_animation.hpp" #include "karts/kart_properties.hpp" #include "modes/world.hpp" +#include "network/network_string.hpp" #include "network/rewind_manager.hpp" #include "physics/triangle_mesh.hpp" #include "tracks/track.hpp" diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index 928ce0b03..f4638ae49 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -29,6 +29,7 @@ #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/kart_properties.hpp" +#include "network/network_string.hpp" #include "physics/physical_object.hpp" #include "physics/physics.hpp" #include "tracks/track.hpp" diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index 48d47e7c6..9064c1d38 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -33,6 +33,7 @@ #include "karts/kart_properties.hpp" #include "modes/world.hpp" #include "network/network_config.hpp" +#include "network/network_string.hpp" #include "network/rewind_manager.hpp" #include "physics/triangle_mesh.hpp" #include "tracks/track.hpp" diff --git a/src/items/rubber_ball.cpp b/src/items/rubber_ball.cpp index 3aaa7e184..006340b0d 100644 --- a/src/items/rubber_ball.cpp +++ b/src/items/rubber_ball.cpp @@ -27,6 +27,8 @@ #include "items/projectile_manager.hpp" #include "karts/abstract_kart.hpp" #include "modes/linear_world.hpp" +#include "network/network_string.hpp" +#include "network/rewind_info.hpp" #include "network/rewind_manager.hpp" #include "physics/btKart.hpp" #include "physics/triangle_mesh.hpp" diff --git a/src/items/swatter.cpp b/src/items/swatter.cpp index 79ff08178..6d5eab858 100644 --- a/src/items/swatter.cpp +++ b/src/items/swatter.cpp @@ -40,6 +40,7 @@ #include "karts/kart_properties.hpp" #include "modes/world.hpp" #include "network/network_config.hpp" +#include "network/rewind_info.hpp" #include "network/rewind_manager.hpp" #define SWAT_POS_OFFSET core::vector3df(0.0, 0.2f, -0.4f) diff --git a/src/karts/abstract_kart_animation.cpp b/src/karts/abstract_kart_animation.cpp index 13d5ab9a3..2f969f02c 100644 --- a/src/karts/abstract_kart_animation.cpp +++ b/src/karts/abstract_kart_animation.cpp @@ -25,6 +25,7 @@ #include "karts/skidding.hpp" #include "modes/world.hpp" #include "network/network_config.hpp" +#include "network/rewind_info.hpp" #include "network/rewind_manager.hpp" #include "physics/physics.hpp" diff --git a/src/karts/controller/kart_control.cpp b/src/karts/controller/kart_control.cpp index 97cf13c8c..91f8b7c01 100644 --- a/src/karts/controller/kart_control.cpp +++ b/src/karts/controller/kart_control.cpp @@ -17,35 +17,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "karts/controller/kart_control.hpp" - -#include "network/protocols/game_protocol.hpp" -#include "network/rewind_manager.hpp" - - -// ------------------------------------------------------------------------ -/** Called when going back in time during a rewind. Nothing to do here - * in this case. - */ -void KartControl::undo(BareNetworkString *buffer) -{ -} // undo - -// ------------------------------------------------------------------------ -/** Replay an event for a KartControl object from the buffer. - * \param buffer BareNetworkString with saved event into. - */ -void KartControl::rewind(BareNetworkString *buffer) -{ - if(buffer->getTotalSize()>1) - { - // Full state including accel and steering was saved - rewindTo(buffer); - } - else // only a button event was stored - { - setButtonsCompressed(buffer->getUInt8()); - } -} // rewind +#include "network/network_string.hpp" // ------------------------------------------------------------------------ /** Sets the current steering value. */ @@ -102,3 +74,20 @@ void KartControl::setLookBack(bool b) { m_look_back = b; } // setLookBack +// ---------------------------------------------------------------------------- +/** Copies the important data from this objects into a memory buffer. */ +void KartControl::saveState(BareNetworkString *buffer) const +{ + buffer->add(m_steer); + buffer->add(m_accel); + buffer->addChar(getButtonsCompressed()); +} // saveState + +// ---------------------------------------------------------------------------- +/** Restores this object from a previously saved memory buffer. */ +void KartControl::rewindTo(BareNetworkString *buffer) +{ + m_steer = buffer->getFloat(); + m_accel = buffer->getFloat(); + setButtonsCompressed(buffer->getUInt8()); +} // setFromMemory diff --git a/src/karts/controller/kart_control.hpp b/src/karts/controller/kart_control.hpp index 88d1cc171..cc060fcae 100644 --- a/src/karts/controller/kart_control.hpp +++ b/src/karts/controller/kart_control.hpp @@ -19,13 +19,12 @@ #ifndef HEADER_KART_CONTROL_HPP #define HEADER_KART_CONTROL_HPP -#include "network/network_string.hpp" -#include "network/rewind_info.hpp" +class BareNetworkString; /** * \ingroup controller */ -class KartControl : public EventRewinder +class KartControl { public: /** The skidding control state: SC_NONE: not pressed; @@ -51,8 +50,6 @@ private: /** True if the kart looks (and shoots) backwards. */ bool m_look_back; public: - virtual void undo(BareNetworkString *buffer); - virtual void rewind(BareNetworkString *buffer); void setSteer(float f); void setAccel(float f); void setBrake(bool b); @@ -100,22 +97,10 @@ public: static int getLength() { return 9; } // ------------------------------------------------------------------------ /** Copies the important data from this objects into a memory buffer. */ - void saveState(BareNetworkString *buffer) const - { - buffer->add(m_steer); - buffer->add(m_accel); - buffer->addChar(getButtonsCompressed()); - } // saveState - + void saveState(BareNetworkString *buffer) const; // ------------------------------------------------------------------------ /** Restores this object from a previously saved memory buffer. */ - void rewindTo(BareNetworkString *buffer) - { - m_steer = buffer->getFloat(); - m_accel = buffer->getFloat(); - setButtonsCompressed(buffer->getUInt8()); - } // setFromMemory - + void rewindTo(BareNetworkString *buffer); // ------------------------------------------------------------------------ /** Compresses all buttons into a single byte. */ char getButtonsCompressed() const diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/player_controller.cpp index 8acf3c2c3..efca5a337 100644 --- a/src/karts/controller/player_controller.cpp +++ b/src/karts/controller/player_controller.cpp @@ -33,6 +33,7 @@ #include "network/rewind_manager.hpp" #include "network/network_config.hpp" #include "network/network_player_profile.hpp" +#include "network/network_string.hpp" #include "network/protocols/lobby_protocol.hpp" #include "race/history.hpp" #include "states_screens/race_gui_base.hpp" diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index def21671f..d32e0c44d 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -68,6 +68,7 @@ #include "modes/soccer_world.hpp" #include "network/network_config.hpp" #include "network/race_event_manager.hpp" +#include "network/rewind_info.hpp" #include "network/rewind_manager.hpp" #include "physics/btKart.hpp" #include "physics/btKartRaycast.hpp" diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index 361bce9cc..dca4721ef 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -30,6 +30,7 @@ #include "items/powerup_manager.hpp" // For PowerupType #include "karts/abstract_kart.hpp" +#include "utils/cpp2011.hpp" #include "utils/no_copy.hpp" #include diff --git a/src/karts/max_speed.cpp b/src/karts/max_speed.cpp index 89200d162..9c74f2823 100644 --- a/src/karts/max_speed.cpp +++ b/src/karts/max_speed.cpp @@ -21,6 +21,7 @@ #include "config/stk_config.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_properties.hpp" +#include "network/network_string.hpp" #include "physics/btKart.hpp" #include diff --git a/src/karts/skidding.hpp b/src/karts/skidding.hpp index b7aaced0d..a497522e8 100644 --- a/src/karts/skidding.hpp +++ b/src/karts/skidding.hpp @@ -22,6 +22,7 @@ #include "karts/controller/kart_control.hpp" #include "utils/leak_check.hpp" #include "utils/no_copy.hpp" +#include "utils/types.hpp" class BareNetworkString; class Kart; diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index 810b9214f..012f136fb 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -33,6 +33,7 @@ #include "network/network_config.hpp" #include "network/network_string.hpp" #include "network/protocols/game_events_protocol.hpp" +#include "network/rewind_info.hpp" #include "network/rewind_manager.hpp" #include "network/stk_host.hpp" #include "physics/physics.hpp" diff --git a/src/network/protocols/game_protocol.cpp b/src/network/protocols/game_protocol.cpp index dd379a06c..e943c17d1 100644 --- a/src/network/protocols/game_protocol.cpp +++ b/src/network/protocols/game_protocol.cpp @@ -28,6 +28,7 @@ #include "network/network_config.hpp" #include "network/network_string.hpp" #include "network/protocol_manager.hpp" +#include "network/rewind_info.hpp" #include "network/rewind_manager.hpp" #include "network/stk_host.hpp" #include "network/stk_peer.hpp"