diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-09-02 12:03:22 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-09-02 12:03:22 +0000 |
commit | 379c0e936e090a19d295d8514cf94b4fb367eae6 (patch) | |
tree | 3297be7e5a53ed55c5db92bc80e0e65db2ee7bb3 /src/state.cpp | |
parent | 1140de4450b3840340df6459eb6d13cc02496e46 (diff) | |
download | manaserv-379c0e936e090a19d295d8514cf94b4fb367eae6.tar.gz manaserv-379c0e936e090a19d295d8514cf94b4fb367eae6.tar.bz2 manaserv-379c0e936e090a19d295d8514cf94b4fb367eae6.tar.xz manaserv-379c0e936e090a19d295d8514cf94b4fb367eae6.zip |
Decorrelated moving object IDs from character database IDs. Switched to short IDs instead.
Diffstat (limited to 'src/state.cpp')
-rw-r--r-- | src/state.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/state.cpp b/src/state.cpp index 71c9fad0..e3f833a8 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -114,7 +114,7 @@ State::update() int type = (*o)->getType(); MessageOut msg2(GPMSG_BEING_ENTER); msg2.writeByte(type); - msg2.writeLong((*o)->getID()); + msg2.writeShort((*o)->getPublicID()); switch (type) { case OBJECT_PLAYER: { @@ -137,8 +137,7 @@ State::update() { // o is no longer visible from p. MessageOut msg2(GPMSG_BEING_LEAVE); - msg2.writeByte((*o)->getType()); - msg2.writeLong((*o)->getID()); + msg2.writeShort((*o)->getPublicID()); gameHandler->sendTo(*p, msg2); continue; } @@ -151,14 +150,14 @@ State::update() /* At this point, either o has entered p's range, either o is moving inside p's range. Report o's movements. */ Point od = (*o)->getDestination(); - msg.writeLong((*o)->getID()); + msg.writeShort((*o)->getPublicID()); msg.writeShort(on.x); msg.writeShort(on.y); msg.writeShort(od.x); msg.writeShort(od.y); } - // Don't send a packet if nothing happed in p's range. + // Don't send a packet if nothing happened in p's range. if (msg.getLength() > 2) gameHandler->sendTo(*p, msg); } @@ -180,7 +179,10 @@ State::addObject(ObjectPtr objectPtr) maps[mapId].objects.push_back(objectPtr); objectPtr->setNew(true); if (objectPtr->getType() != OBJECT_PLAYER) return; - maps[mapId].players.push_back(PlayerPtr(objectPtr)); + PlayerPtr ptr(objectPtr); + // TODO: Unique object numbering + ptr->setPublicID(ptr->getDatabaseID()); + maps[mapId].players.push_back(ptr); } void @@ -200,8 +202,7 @@ State::removeObject(ObjectPtr objectPtr) if (objectPtr->getType() != OBJECT_PLAYER) return; MessageOut msg(GPMSG_BEING_LEAVE); - msg.writeByte(OBJECT_PLAYER); - msg.writeLong(objectPtr->getID()); + msg.writeShort(PlayerPtr(objectPtr)->getPublicID()); Point objectPosition = objectPtr->getXY(); Players &players = maps[mapId].players; |