Cosmetic changes only.
This commit is contained in:
parent
6280613e5c
commit
c9bf95079c
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user