Cosmetic changes only.

This commit is contained in:
hiker 2015-12-16 08:22:30 +11:00
parent 6280613e5c
commit c9bf95079c
2 changed files with 35 additions and 22 deletions

View File

@ -17,12 +17,14 @@
GameEventsProtocol::GameEventsProtocol() : Protocol(PROTOCOL_GAME_EVENTS) GameEventsProtocol::GameEventsProtocol() : Protocol(PROTOCOL_GAME_EVENTS)
{ {
} } // GameEventsProtocol
// ----------------------------------------------------------------------------
GameEventsProtocol::~GameEventsProtocol() GameEventsProtocol::~GameEventsProtocol()
{ {
} } // ~GameEventsProtocol
// ----------------------------------------------------------------------------
bool GameEventsProtocol::notifyEvent(Event* event) bool GameEventsProtocol::notifyEvent(Event* event)
{ {
if (event->getType() != EVENT_TYPE_MESSAGE) if (event->getType() != EVENT_TYPE_MESSAGE)
@ -60,28 +62,34 @@ bool GameEventsProtocol::notifyEvent(Event* event)
ItemManager::get()->getItem(item_id), ItemManager::get()->getItem(item_id),
kart, kart,
powerup_type); 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; } break;
default: default:
Log::warn("GameEventsProtocol", "Unkown message type."); Log::warn("GameEventsProtocol", "Unkown message type.");
break; break;
} }
return true; return true;
} } // notifyEvent
// ----------------------------------------------------------------------------
void GameEventsProtocol::setup() void GameEventsProtocol::setup()
{ {
} } // setup
// ----------------------------------------------------------------------------
void GameEventsProtocol::update() void GameEventsProtocol::update()
{ {
} } // update
// ----------------------------------------------------------------------------
void GameEventsProtocol::collectedItem(Item* item, AbstractKart* kart) void GameEventsProtocol::collectedItem(Item* item, AbstractKart* kart)
{ {
GameSetup* setup = STKHost::get()->getGameSetup(); GameSetup* setup = STKHost::get()->getGameSetup();
assert(setup); 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<STKPeer*> &peers = STKHost::get()->getPeers(); const std::vector<STKPeer*> &peers = STKHost::get()->getPeers();
for (unsigned int i = 0; i < peers.size(); i++) 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) if (item->getType() == Item::ITEM_BANANA)
powerup = (int)(kart->getAttachment()->getType()); powerup = (int)(kart->getAttachment()->getType());
else if (item->getType() == Item::ITEM_BONUS_BOX) 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) ns.ai8(0x01).ai32(item->getItemId()).ai8(powerup)
.ai8(player_profile->getPlayerID()); .ai8(player_profile->getPlayerID());
ProtocolManager::getInstance()->sendMessage(this, peers[i], ns, true); // reliable ProtocolManager::getInstance()->sendMessage(this, peers[i], ns,
Log::info("GameEventsProtocol", "Notified a peer that a kart collected item %d.", (int)(kart->getPowerup()->getType())); /*reliable*/true);
Log::info("GameEventsProtocol",
"Notified a peer that a kart collected item %d.",
(int)(kart->getPowerup()->getType()));
} }
} } // collectedItem

View File

@ -8,19 +8,20 @@ class Item;
class GameEventsProtocol : public Protocol class GameEventsProtocol : public Protocol
{ {
public: public:
GameEventsProtocol(); GameEventsProtocol();
virtual ~GameEventsProtocol(); virtual ~GameEventsProtocol();
virtual bool notifyEvent(Event* event); virtual bool notifyEvent(Event* event);
virtual bool notifyEventAsynchronous(Event* event) { return false; } virtual void setup();
virtual void setup(); virtual void update();
virtual void update(); void collectedItem(Item* item, AbstractKart* kart);
virtual void asynchronousUpdate() {} // ------------------------------------------------------------------------
virtual void asynchronousUpdate() {}
// ------------------------------------------------------------------------
virtual bool notifyEventAsynchronous(Event* event) { return false; }
void collectedItem(Item* item, AbstractKart* kart);
protected: }; // class GameEventsProtocol
};
#endif // GAME_EVENTS_PROTOCOL_HPP #endif // GAME_EVENTS_PROTOCOL_HPP