From c9bf95079c6879e37fad0350b80e4d7de9474f1d Mon Sep 17 00:00:00 2001 From: hiker Date: Wed, 16 Dec 2015 08:22:30 +1100 Subject: [PATCH] Cosmetic changes only. --- .../protocols/game_events_protocol.cpp | 34 +++++++++++++------ .../protocols/game_events_protocol.hpp | 23 +++++++------ 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/network/protocols/game_events_protocol.cpp b/src/network/protocols/game_events_protocol.cpp index adc351869..6dea97cc5 100644 --- a/src/network/protocols/game_events_protocol.cpp +++ b/src/network/protocols/game_events_protocol.cpp @@ -17,12 +17,14 @@ GameEventsProtocol::GameEventsProtocol() : Protocol(PROTOCOL_GAME_EVENTS) { -} +} // GameEventsProtocol +// ---------------------------------------------------------------------------- GameEventsProtocol::~GameEventsProtocol() { -} +} // ~GameEventsProtocol +// ---------------------------------------------------------------------------- bool GameEventsProtocol::notifyEvent(Event* event) { if (event->getType() != EVENT_TYPE_MESSAGE) @@ -60,28 +62,34 @@ bool GameEventsProtocol::notifyEvent(Event* event) ItemManager::get()->getItem(item_id), kart, powerup_type); - Log::info("GameEventsProtocol", "Item %d picked by a player.", powerup_type); + Log::info("GameEventsProtocol", "Item %d picked by a player.", + powerup_type); } break; default: Log::warn("GameEventsProtocol", "Unkown message type."); break; } return true; -} +} // notifyEvent +// ---------------------------------------------------------------------------- void GameEventsProtocol::setup() { -} +} // setup +// ---------------------------------------------------------------------------- void GameEventsProtocol::update() { -} +} // update +// ---------------------------------------------------------------------------- void GameEventsProtocol::collectedItem(Item* item, AbstractKart* kart) { GameSetup* setup = STKHost::get()->getGameSetup(); assert(setup); - const NetworkPlayerProfile* player_profile = setup->getProfile(kart->getIdent()); // use kart name + // use kart name + const NetworkPlayerProfile* player_profile = + setup->getProfile(kart->getIdent()); const std::vector &peers = STKHost::get()->getPeers(); for (unsigned int i = 0; i < peers.size(); i++) @@ -93,11 +101,15 @@ void GameEventsProtocol::collectedItem(Item* item, AbstractKart* kart) if (item->getType() == Item::ITEM_BANANA) powerup = (int)(kart->getAttachment()->getType()); else if (item->getType() == Item::ITEM_BONUS_BOX) - powerup = (((int)(kart->getPowerup()->getType()) << 4)&0xf0) + (kart->getPowerup()->getNum()&0x0f); + powerup = (((int)(kart->getPowerup()->getType()) << 4) & 0xf0) + + (kart->getPowerup()->getNum() & 0x0f); ns.ai8(0x01).ai32(item->getItemId()).ai8(powerup) .ai8(player_profile->getPlayerID()); - ProtocolManager::getInstance()->sendMessage(this, peers[i], ns, true); // reliable - Log::info("GameEventsProtocol", "Notified a peer that a kart collected item %d.", (int)(kart->getPowerup()->getType())); + ProtocolManager::getInstance()->sendMessage(this, peers[i], ns, + /*reliable*/true); + Log::info("GameEventsProtocol", + "Notified a peer that a kart collected item %d.", + (int)(kart->getPowerup()->getType())); } -} +} // collectedItem diff --git a/src/network/protocols/game_events_protocol.hpp b/src/network/protocols/game_events_protocol.hpp index 9d85b0104..2de571e0c 100644 --- a/src/network/protocols/game_events_protocol.hpp +++ b/src/network/protocols/game_events_protocol.hpp @@ -8,19 +8,20 @@ class Item; class GameEventsProtocol : public Protocol { - public: - GameEventsProtocol(); - virtual ~GameEventsProtocol(); +public: + GameEventsProtocol(); + virtual ~GameEventsProtocol(); - virtual bool notifyEvent(Event* event); - virtual bool notifyEventAsynchronous(Event* event) { return false; } - virtual void setup(); - virtual void update(); - virtual void asynchronousUpdate() {} + virtual bool notifyEvent(Event* event); + virtual void setup(); + virtual void update(); + void collectedItem(Item* item, AbstractKart* kart); + // ------------------------------------------------------------------------ + virtual void asynchronousUpdate() {} + // ------------------------------------------------------------------------ + virtual bool notifyEventAsynchronous(Event* event) { return false; } - void collectedItem(Item* item, AbstractKart* kart); - protected: -}; +}; // class GameEventsProtocol #endif // GAME_EVENTS_PROTOCOL_HPP