home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-02-21 | 1.5 KB | 49 lines |
- // An update message for the multi-user protocol
-
- // Written by Bernie Roehl, December 1996
-
- package multi;
-
- import java.io.*;
-
- class UpdateMessage {
- int seqnum;
- int entid;
- long timestamp = System.currentTimeMillis();
- Vec3 location = new Vec3();
- Rotation orientation = new Rotation();
- int region;
- float size;
- boolean gone;
-
- // accessor methods:
- public int getEntityId() { return entid; }
- public Vec3 getLocation() { return location; }
- public Rotation getOrientation() { return orientation; }
- public long getTimestamp() { return timestamp; }
- public int getRegion() { return region; }
- public float getSize() { return size; }
- boolean isGone() { return gone; }
- int getSequenceNumber() { return seqnum; }
-
- public UpdateMessage(byte[] buffer) throws IOException {
- ByteArrayInputStream bin = new ByteArrayInputStream(buffer);
- DataInputStream in = new DataInputStream(bin);
- in.readByte(); // ignore version, padding, extension, CSRC count
- if (in.readByte() != 79) // payload type; marker is zero
- throw new IOException("bad payload type!");
- int seq = in.readShort();
- seqnum = seq;
- timestamp = in.readInt() << 16;
- entid = in.readInt();
- location.read(in);
- orientation.read(in);
- region = in.readInt();
- size = in.readFloat();
- int flags = in.readInt();
- gone = ((flags & 0x0001) == 0x0001) ? true : false;
- }
-
- }
-
-