Remove the unknown 255 attachment which caused by Endcontroller replacement

This commit is contained in:
Benau 2018-04-18 13:55:29 +08:00
parent b6caf00bfc
commit 6eaa88a3f5
3 changed files with 18 additions and 9 deletions

View File

@ -269,13 +269,7 @@ void Attachment::saveState(BareNetworkString *buffer) const
void Attachment::rewindTo(BareNetworkString *buffer)
{
uint8_t type = buffer->getUInt8();
AttachmentType new_type = AttachmentType(type & 0x7f); // mask out bit 7
// FIXME Sometimes type == 255 is returned, reason unknown
if (new_type > ATTACH_NOTHING)
{
return;
}
// If there is no attachment, clear the attachment if necessary and exit
if(new_type==ATTACH_NOTHING)

View File

@ -25,6 +25,7 @@
#include "karts/kart_properties.hpp"
#include "karts/controller/ai_properties.hpp"
#include "modes/world.hpp"
#include "network/network_string.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
@ -328,3 +329,18 @@ void AIBaseController::determineTurnRadius(const Vec3 &end, Vec3 *center,
}
} // determineTurnRadius
//-----------------------------------------------------------------------------
void AIBaseController::saveState(BareNetworkString *buffer) const
{
// Endcontroller needs this for proper offset in kart rewinder
buffer->addUInt32(0).addUInt32(0).addUInt32(0);
} // copyToBuffer
//-----------------------------------------------------------------------------
void AIBaseController::rewindTo(BareNetworkString *buffer)
{
// Endcontroller needs this for proper offset in kart rewinder
// Skip 3 uint32_t
buffer->skip(3 * 4);
} // rewindTo

View File

@ -104,9 +104,8 @@ public:
};
virtual void skidBonusTriggered() {};
// ------------------------------------------------------------------------
/** Not used for AIs. */
virtual void saveState(BareNetworkString *buffer) const OVERRIDE {}
virtual void rewindTo(BareNetworkString *buffer) OVERRIDE {}
virtual void saveState(BareNetworkString *buffer) const OVERRIDE;
virtual void rewindTo(BareNetworkString *buffer) OVERRIDE;
}; // AIBaseController