VuCreateEvent


public:
  VuCreateEvent(VuEntity *entity, VuTargetEntity *target, VU_BOOL loopback=FALSE);
  VuCreateEvent(VU_ID senderid, VU_ID target);
  virtual ~VuCreateEvent();

  virtual int Size();
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);
  virtual VU_BOOL DoSend();     // returns TRUE if ent is in database

  VuEntity *EventData() { return expandedData_; }

protected:
  VuCreateEvent(VU_MSG_TYPE type, VuEntity *entity, VuTargetEntity *target,
                        VU_BOOL loopback=FALSE);
  VuCreateEvent(VU_MSG_TYPE type, VU_ID senderid, VU_ID target);

  virtual VU_ERRCODE Activate(VuEntity *ent);
  virtual VU_ERRCODE Process(VU_BOOL autod);

private:
  int LocalSize();

// data
//protected:
public:
  VuEntity *expandedData_;
#ifdef VU_USE_CLASS_INFO
  VU_BYTE classInfo_[CLASS_NUM_BYTES];  // entity class type
#endif
  ushort vutype_;                       // entity type
  ushort size_;
  VU_BYTE *data_;
};

class VuManageEvent : public VuCreateEvent {

public:
  VuManageEvent(VuEntity *entity, VuTargetEntity *target, VU_BOOL loopback=FALSE);
  VuManageEvent(VU_ID senderid, VU_ID target);
  virtual ~VuManageEvent();

// data
protected:
  // none
};

//--------------------------------------------------

class VuDeleteEvent : public VuEvent {

public:
  VuDeleteEvent(VuEntity *entity);
  VuDeleteEvent(VU_ID senderid, VU_ID target);
  virtual ~VuDeleteEvent();

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);
  virtual VU_ERRCODE Activate(VuEntity *ent);

// data
protected:
  // none
};

//--------------------------------------------------

class VuUnmanageEvent : public VuEvent {

public:
  VuUnmanageEvent(VuEntity *entity, VuTargetEntity *target,
                        VU_TIME mark, VU_BOOL loopback = FALSE);
  VuUnmanageEvent(VU_ID senderid, VU_ID target);
  virtual ~VuUnmanageEvent();

  virtual int Size();
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);

private:
  int LocalSize();

// data
public:
  // time of removal
  VU_TIME mark_;
};

//--------------------------------------------------

class VuReleaseEvent : public VuEvent {

public:
  VuReleaseEvent(VuEntity *entity);
  virtual ~VuReleaseEvent();

  virtual int Size();
  // all these are stubbed out here, as this is not a net message
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);
  virtual VU_BOOL DoSend();     // returns FALSE

protected:
  virtual VU_ERRCODE Activate(VuEntity *ent);
  virtual VU_ERRCODE Process(VU_BOOL autod);

// data
protected:
  // none
};

//--------------------------------------------------

class VuTransferEvent : public VuEvent {

public:
  VuTransferEvent(VuEntity *entity, VuTargetEntity *target, VU_BOOL loopback=FALSE);
  VuTransferEvent(VU_ID senderid, VU_ID target);
  virtual ~VuTransferEvent();

  virtual int Size();
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);

protected:
  virtual VU_ERRCODE Activate(VuEntity *ent);
  virtual VU_ERRCODE Process(VU_BOOL autod);

private:
  int LocalSize();

// data
public:
  VU_ID newOwnerId_;
};

//--------------------------------------------------

class VuPositionUpdateEvent : public VuEvent {

public:
  VuPositionUpdateEvent(VuEntity *entity, VuTargetEntity *target,
                        VU_BOOL loopback=FALSE);
  VuPositionUpdateEvent(VU_ID senderid, VU_ID target);
  virtual ~VuPositionUpdateEvent();

  virtual int Size();
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);

  virtual VU_BOOL DoSend();

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);

private:
  int LocalSize();

// data
public:
#ifdef VU_USE_QUATERNION
  VU_QUAT quat_;        // quaternion indicating current facing
  VU_VECT dquat_;       // unit vector expressing quaternion delta
  SM_SCALAR theta_;     // scalar indicating rate of above delta
#else // !VU_USE_QUATERNION
  SM_SCALAR yaw_, pitch_, roll_;
  SM_SCALAR dyaw_, dpitch_, droll_;
#endif
  BIG_SCALAR x_, y_, z_;
  SM_SCALAR dx_, dy_, dz_;

//--------------------------------------------------

class VuBroadcastGlobalEvent : public VuEvent {

public:
  VuBroadcastGlobalEvent(VuEntity *entity, VuTargetEntity *target, VU_BOOL loopback=FALSE);
  VuBroadcastGlobalEvent(VU_ID senderid, VU_ID target);
  virtual ~VuBroadcastGlobalEvent();

  void MarkAsKeepalive() { flags_ |= VU_KEEPALIVE_MSG_FLAG; }

protected:
  virtual int Size();
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);

  virtual VU_ERRCODE Activate(VuEntity *ent);
  virtual VU_ERRCODE Process(VU_BOOL autod);

// data
protected:

#ifdef VU_USE_CLASS_INFO
  VU_BYTE classInfo_[CLASS_NUM_BYTES];  // entity class type
#endif
  ushort vutype_;                       // entity type

};

//--------------------------------------------------

class VuFullUpdateEvent : public VuCreateEvent {

public:
  VuFullUpdateEvent(VuEntity *entity, VuTargetEntity *target, VU_BOOL loopback=FALSE);
  VuFullUpdateEvent(VU_ID senderid, VU_ID target);
  virtual ~VuFullUpdateEvent();

  VU_BOOL WasCreated() { return (VU_BOOL)(Entity() == expandedData_ ? TRUE : FALSE); }
  void MarkAsKeepalive() { flags_ |= VU_KEEPALIVE_MSG_FLAG; }

protected:
  virtual VU_ERRCODE Activate(VuEntity *ent);

// data
protected:
  // none
};

//--------------------------------------------------

class VuEntityCollisionEvent : public VuEvent {

public:
  VuEntityCollisionEvent(VuEntity *entity, VU_ID otherId,
                         VU_DAMAGE hitLocation, int hitEffect,
                         VuTargetEntity *target, VU_BOOL loopback=FALSE);
  VuEntityCollisionEvent(VU_ID senderid, VU_ID target);

  virtual ~VuEntityCollisionEvent();

  virtual int Size();
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);

private:
  int LocalSize();

// data
public:
  VU_ID otherId_;
  VU_DAMAGE hitLocation_;       // affects damage
  int hitEffect_;               // affects hitpoints/health
};

//--------------------------------------------------

class VuGroundCollisionEvent : public VuEvent {

public:
  VuGroundCollisionEvent(VuEntity *entity, VuTargetEntity *target, VU_BOOL loopback=FALSE);
  VuGroundCollisionEvent(VU_ID senderid, VU_ID target);
  virtual ~VuGroundCollisionEvent();

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);

// data
};

//--------------------------------------------------

class VuSessionEvent : public VuEvent {

public:
  VuSessionEvent(VuEntity *entity, ushort subtype, VuTargetEntity *target,
                 VU_BOOL loopback=FALSE);
  VuSessionEvent(VU_ID senderid, VU_ID target);
  virtual ~VuSessionEvent();

  virtual int Size();
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);

private:
  int LocalSize();

// data
public:
  ushort subtype_;
  VU_ID group_;
  char *callsign_;
  VU_BYTE syncState_;
  VU_TIME gameTime_;
};

//--------------------------------------------------

class VuTimerEvent : public VuEvent {

friend class VuMainMessageQueue;
public:
  VuTimerEvent(VuEntity *entity, VU_TIME mark, ushort type, VuMessage *event=0);
  virtual ~VuTimerEvent();

  virtual int Size();
  // all these are stubbed out here, as this is not a net message
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);
  virtual VU_BOOL DoSend();     // returns FALSE

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);

// data
public:
  // time of firing
  VU_TIME mark_;
  ushort timertype_;
  // event to launch on firing
  VuMessage *event_;

private:
  VuTimerEvent *next_;
};

//--------------------------------------------------

class VuShutdownEvent : public VuEvent {

public:
  VuShutdownEvent(VU_BOOL all = FALSE);
  virtual ~VuShutdownEvent();

  virtual int Size();
  // all these are stubbed out here, as this is not a net message
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);
  virtual VU_BOOL DoSend();     // returns FALSE

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);

// data
public:
  VU_BOOL shutdownAll_;
  VU_BOOL done_;
};

//--------------------------------------------------

class VuTimingMessage : public VuMessage {#ifdef VU_SIMPLE_LATENCY

#ifdef VU_SIMPLE_LATENCY


public:
  VuTimingMessage(VU_ID entityId, VuTargetEntity *target, VU_BOOL loopback=FALSE);
  VuTimingMessage(VU_ID senderid, VU_ID target);
  virtual ~VuTimingMessage();

  virtual int Size();
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);

// data
public:
        VU_TIME sessionRealSendTime_;
        VU_TIME sessionGameSendTime_;
        VU_TIME remoteGameTime_;
};
#endif VU_SIMPLE_LATENCY

//--------------------------------------------------

class VuUnknownMessage : public VuMessage {

public:
  VuUnknownMessage();
  virtual ~VuUnknownMessage();

  virtual int Size();
  // all these are stubbed out here, as this is not a net message
  virtual int Decode(VU_BYTE **buf, int length);
  virtual int Encode(VU_BYTE **buf);
  virtual VU_BOOL DoSend();     // returns FALSE

protected:
  virtual VU_ERRCODE Process(VU_BOOL autod);

// data
public:
  // none
};