#include "WorldUpdate.h"

#include <Text.h>

#include "Registries.h"

WorldUpdateType::WorldUpdateType(int id)
    : ReferenceCounter(),
      id(id)
{
    STATIC_REGISTRY(WorldUpdateType).registerT(this, id);
}

void WorldUpdateType::applyUpdateAndCheck(Framework::StreamReader* zReader)
{
    this->applyUpdate(zReader);
    int id;
    zReader->lese((char*)&id, 4);
    if (id != this->id)
    {
        Framework::Text* t
            = new Framework::Text("asynchony after world update of type ");
        t->append(this->id);
        t->append(". ID received from server was: ");
        t->append(id);
        throw t->getText();
    }
}