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::~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<STKPeer*> &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

View File

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