From 079b5abe2ad016bb926580ac957e53f68399f57d Mon Sep 17 00:00:00 2001 From: hiker Date: Sun, 27 May 2018 00:42:21 +1000 Subject: [PATCH] Started to use ItemState instead of Item in the attachment and powerup callbacks on item collection. --- src/items/attachment.cpp | 6 +++--- src/items/attachment.hpp | 4 ++-- src/items/powerup.cpp | 11 ++++++----- src/items/powerup.hpp | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) mode change 100644 => 100755 src/items/powerup.cpp mode change 100644 => 100755 src/items/powerup.hpp diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index d8681f845..7b9cc2e7c 100755 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -317,7 +317,7 @@ void Attachment::rewind(BareNetworkString *buffer) * server, the new item is based on the current world time. * \param item The item that was collected. */ -void Attachment::hitBanana(Item *item) +void Attachment::hitBanana(ItemState *item_state) { // Don't keep on getting achievements due to rewind! if (m_kart->getController()->canGetAchievements() && @@ -369,9 +369,9 @@ void Attachment::hitBanana(Item *item) // same banana again once the explosion animation is finished, giving // the kart the same penalty twice. int ticks = - std::max(item->getTicksTillReturn(), + std::max(item_state->getTicksTillReturn(), stk_config->time2Ticks(kp->getExplosionDuration() + 2.0f)); - item->setTicksTillReturn(ticks); + item_state->setTicksTillReturn(ticks); break; } case ATTACH_ANVIL: diff --git a/src/items/attachment.hpp b/src/items/attachment.hpp index 1485ec7f7..4b77c10ce 100755 --- a/src/items/attachment.hpp +++ b/src/items/attachment.hpp @@ -30,7 +30,7 @@ using namespace irr; class AbstractKart; class BareNetworkString; -class Item; +class ItemState; class SFXBase; /** This objects is permanently available in a kart and stores information @@ -115,7 +115,7 @@ public: Attachment(AbstractKart* kart); ~Attachment(); void clear (); - void hitBanana(Item *item); + void hitBanana(ItemState *item); void update(int ticks); void handleCollisionWithKart(AbstractKart *other); void set (AttachmentType type, int ticks, diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp old mode 100644 new mode 100755 index d67c53114..6a9064b70 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -445,11 +445,11 @@ void Powerup::use() * or on a client, in which case the item and additional info is used * to make sure server and clients are synched correctly. * \param n - * \param item The item (bonux box) that was hit. This is necessary - * for servers so that the clients can be informed which item - * was collected. + * \param item_state The item_state (bonux box) that was hit. This is + * necessary for servers so that the clients can be informed which + * item was collected. */ -void Powerup::hitBonusBox(const Item &item) +void Powerup::hitBonusBox(const ItemState &item_state) { // Position can be -1 in case of a battle mode (which doesn't have // positions), but this case is properly handled in getRandomPowerup. @@ -474,9 +474,10 @@ void Powerup::hitBonusBox(const Item &item) // non-random selection (e.g. by displaying which item is collecte // where), since it's only around 83 ms - but it is bit more // relaxed when client prediction should be a frame or so earlier. - int random_number = item.getItemId() + world->getTimeTicks() / 10; + int random_number = item_state.getItemId() + world->getTimeTicks() / 10; new_powerup = powerup_manager->getRandomPowerup(position, &n, random_number); + new_powerup = PowerupManager::POWERUP_BUBBLEGUM; if (new_powerup != PowerupManager::POWERUP_RUBBERBALL || (world->getTicksSinceStart() - powerup_manager->getBallCollectTicks()) > RubberBall::getTicksBetweenRubberBalls()) diff --git a/src/items/powerup.hpp b/src/items/powerup.hpp old mode 100644 new mode 100755 index f9bb80d76..9077495da --- a/src/items/powerup.hpp +++ b/src/items/powerup.hpp @@ -27,7 +27,7 @@ class AbstractKart; class BareNetworkString; -class Item; +class ItemState; class SFXBase; /** @@ -59,7 +59,7 @@ public: Material* getIcon () const; void adjustSound (); void use (); - void hitBonusBox (const Item &item); + void hitBonusBox (const ItemState &item); void saveState(BareNetworkString *buffer) const; void rewindTo(BareNetworkString *buffer);