cz.cuni.pogamut.MessageObjects
Class MessageObject

java.lang.Object
  extended by cz.cuni.pogamut.MessageObjects.MessageObject
All Implemented Interfaces:
Visible, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
AddItem, AdrenalineGained, AliveMessage, AutoTraceRay, BeginMessage, BotDamaged, BotKilled, Bumped, ConfigChange, DeleteFromBatch, Disconnected, DominationPoint, DummyMessage, EndMessage, FallEdge, FastTrace, FlagInfo, GameInfo, GamePaused, GameResumed, GameStatus, GlobalChat, HearNoise, HearPickup, HelloBotHandshake, HelloControlServerHandshake, HelloMap, ChangedWeapon, IncommingProjectile, Item, ItemList, MapFinished, MapChange, MapListEnd, MapListStart, Mover, NavList, NavPoint, NeighNav, Path, Player, PlayerDamaged, PlayerJoinsGame, PlayerKilled, PlayerLeft, PlayerListEnd, PlayerListStart, Pong, RayList, Reachable, SeePlayer, Self, Spawn, TeamChat, Thrown, Trace, UTMap, WallCollision, ZoneChangedBot, ZoneChangedFoot, ZoneChangedHead

public class MessageObject
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, Visible

MessageObject serves as a parent of all messages passed from GB to agent.
Its children are entities which represent the objects of the game (player, inventory, noise, etc.).

It has two methods essential for delta compression during networking - diff and update

diff - it is called by Parser when it has seen the object before, so it uses diff to create object that is much smaller and therefore less load the network diff also updates old object in the database

update - after receiving diffed object, Client call Update to obtain updated object

NOTE!!! : MessageObject doesn't implement HashCode. Its blank constructor is used in Parser during parsing of messages, so it is not possible to use it as a key in hash maps but there is a unique ID, which is able to serve as a key :)

See Also:
Serialized Form

Field Summary
 int ID
          int ID in Parser.
 MessageType type
          type of message from GameBot
static java.lang.String[] types
          static final structure which serves to make people happy;) just for more readable printout NOTE!!!
 java.lang.String UnrealID
           
 boolean visible
           
 
Constructor Summary
MessageObject()
           
MessageObject(MessageType type)
           
MessageObject(MessageType type, int ID, java.lang.String UnrealID)
          constructor
MessageObject(MessageType type, int ID, java.lang.String UnrealID, boolean visible)
          copy constructor
 
Method Summary
 java.lang.Object clone()
          clone object - for hard copying
 boolean diff(MessageObject old)
          change this object that all properties that are same as old will be set to null or 0 or similar.
 boolean equals(java.lang.Object arg)
           
 int getID()
           
 MessageType getType()
          getters
 java.lang.String getUnrealID()
           
 boolean getVisibility()
           
 boolean hasID()
           
 boolean isVisible()
           
 void setID(int id)
           
 void setType(MessageType type)
           
 void setUnrealID(java.lang.String unrealID)
           
 void setVisible(boolean visible)
           
 java.lang.String toString()
           
 void update(MessageObject newMsgObj)
          Writes non-null information from newMsgObj to current one.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

types

public static final java.lang.String[] types
static final structure which serves to make people happy;) just for more readable printout

NOTE!!! when you add some new message, you must add it to as the constant here and add its description string to this field as well!!!


type

public MessageType type
type of message from GameBot


ID

public int ID
int ID in Parser. Corresponds uniquely to UnrealID


UnrealID

public java.lang.String UnrealID

visible

public boolean visible
Constructor Detail

MessageObject

public MessageObject(MessageType type,
                     int ID,
                     java.lang.String UnrealID)
constructor

Parameters:
type -
ID -
UnrealID -

MessageObject

public MessageObject(MessageType type,
                     int ID,
                     java.lang.String UnrealID,
                     boolean visible)
copy constructor

Parameters:
type -
ID -
UnrealID -
visible -

MessageObject

public MessageObject()

MessageObject

public MessageObject(MessageType type)
Method Detail

clone

public java.lang.Object clone()
clone object - for hard copying

Overrides:
clone in class java.lang.Object

getType

public MessageType getType()
getters


getID

public int getID()

getUnrealID

public java.lang.String getUnrealID()

getVisibility

public boolean getVisibility()
Specified by:
getVisibility in interface Visible
Returns:
true if the object is visible

diff

public boolean diff(MessageObject old)
change this object that all properties that are same as old will be set to null or 0 or similar. in case all properties are same as old, return false, else true.
If old differs from current, update old.

Parameters:
old - Object we use as reference for change.
Returns:
true if the objects are not different

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

update

public void update(MessageObject newMsgObj)
Writes non-null information from newMsgObj to current one. Remember that you have to overide this method if you creates a new descendant, so the Parser and Client can work correctly.

Parameters:
newMsgObj -

equals

public boolean equals(java.lang.Object arg)
Overrides:
equals in class java.lang.Object

isVisible

public boolean isVisible()

setVisible

public void setVisible(boolean visible)

setID

public void setID(int id)

setType

public void setType(MessageType type)

setUnrealID

public void setUnrealID(java.lang.String unrealID)

hasID

public boolean hasID()