Fix no plunger replay with local state

This commit is contained in:
Benau 2018-12-23 12:04:31 +08:00
parent 95564c4d74
commit 2bc01f5f98
2 changed files with 9 additions and 4 deletions

View File

@ -168,7 +168,8 @@ bool Plunger::updateAndDelete(int ticks)
*/ */
bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj) bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
{ {
if (isOwnerImmunity(kart) || m_moved_to_infinity) return false; if (isOwnerImmunity(kart) || m_moved_to_infinity || m_undo_creation)
return false;
// pulling back makes no sense in battle mode, since this mode is not a race. // pulling back makes no sense in battle mode, since this mode is not a race.
// so in battle mode, always hide view // so in battle mode, always hide view
@ -257,7 +258,7 @@ BareNetworkString* Plunger::saveState(std::vector<std::string>* ru)
if (!buffer) if (!buffer)
return NULL; return NULL;
buffer->addUInt16(m_keep_alive).addUInt8(m_moved_to_infinity ? 1 : 0); buffer->addUInt16(m_keep_alive);
if (m_rubber_band) if (m_rubber_band)
buffer->addUInt8(m_rubber_band->get8BitState()); buffer->addUInt8(m_rubber_band->get8BitState());
else else
@ -270,7 +271,7 @@ void Plunger::restoreState(BareNetworkString *buffer, int count)
{ {
Flyable::restoreState(buffer, count); Flyable::restoreState(buffer, count);
m_keep_alive = buffer->getUInt16(); m_keep_alive = buffer->getUInt16();
m_moved_to_infinity = buffer->getUInt8() == 1; m_moved_to_infinity = false;
uint8_t bit_state = buffer->getUInt8(); uint8_t bit_state = buffer->getUInt8();
if (bit_state == 255 && m_rubber_band) if (bit_state == 255 && m_rubber_band)
{ {

View File

@ -48,7 +48,11 @@ private:
bool m_reverse_mode, m_has_locally_played_sound, m_moved_to_infinity; bool m_reverse_mode, m_has_locally_played_sound, m_moved_to_infinity;
virtual void additionalPhysicsProperties() OVERRIDE { m_keep_alive = -1; } virtual void additionalPhysicsProperties() OVERRIDE
{
m_keep_alive = -1;
m_moved_to_infinity = false;
}
virtual void hideNodeWhenUndoDestruction() OVERRIDE; virtual void hideNodeWhenUndoDestruction() OVERRIDE;
public: public:
Plunger(AbstractKart *kart); Plunger(AbstractKart *kart);