Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ProtocolGame::sendMoveCreature(const Creature* creature, const Tile* newTile, const Position& newPos,
- uint32_t newStackpos, const Tile* oldTile, const Position& oldPos, uint32_t oldStackpos, bool teleport)
- {
- if(creature == player)
- {
- NetworkMessage_ptr msg = getOutputBuffer();
- if(msg)
- {
- TRACK_MESSAGE(msg);
- if(teleport || oldStackpos >= 10)
- {
- RemoveTileItem(msg, oldPos, oldStackpos);
- AddMapDescription(msg, newPos);
- }
- else
- {
- if(oldPos.z != 7 || newPos.z < 8)
- {
- msg->AddByte(0x6D);
- msg->AddPosition(oldPos);
- msg->AddByte(oldStackpos);
- msg->AddPosition(newPos);
- }
- else
- RemoveTileItem(msg, oldPos, oldStackpos);
- if(newPos.z > oldPos.z)
- MoveDownCreature(msg, creature, newPos, oldPos, oldStackpos);
- else if(newPos.z < oldPos.z)
- MoveUpCreature(msg, creature, newPos, oldPos, oldStackpos);
- if (oldPos.y > newPos.y) { // north, for old x
- msg->AddByte(0x65);
- GetMapDescription(oldPos.x - Protocol::getPortX(), newPos.y - Protocol::getPortY(), newPos.z, (Protocol::getPortX()+1)*2, 1, msg);
- } else if (oldPos.y < newPos.y) { // south, for old x
- msg->AddByte(0x67);
- GetMapDescription(oldPos.x - Protocol::getPortX(), newPos.y + (Protocol::getPortY()+1), newPos.z, (Protocol::getPortX()+1)*2, 1, msg);
- }
- if (oldPos.x < newPos.x) { // east, [with new y]
- msg->AddByte(0x66);
- GetMapDescription(newPos.x + (Protocol::getPortX()+1), newPos.y - Protocol::getPortY(), newPos.z, 1, (Protocol::getPortY()+1)*2, msg);
- } else if (oldPos.x > newPos.x) { // west, [with new y]
- msg->AddByte(0x68);
- GetMapDescription(newPos.x - Protocol::getPortX(), newPos.y - Protocol::getPortY(), newPos.z, 1, (Protocol::getPortY()+1)*2, msg);
- }
- }
- }
- }
- else if(canSee(oldPos) && canSee(newPos))
- {
- if(!player->canSeeCreature(creature))
- return;
- NetworkMessage_ptr msg = getOutputBuffer();
- if(msg)
- {
- TRACK_MESSAGE(msg);
- if(!teleport && (oldPos.z != 7 || newPos.z < 8) && oldStackpos < 10)
- {
- msg->AddByte(0x6D);
- msg->AddPosition(oldPos);
- msg->AddByte(oldStackpos);
- msg->AddPosition(newPos);
- }
- else
- {
- RemoveTileItem(msg, oldPos, oldStackpos);
- AddTileCreature(msg, newPos, newStackpos, creature);
- }
- }
- }
- else if(canSee(oldPos))
- {
- if(!player->canSeeCreature(creature))
- return;
- NetworkMessage_ptr msg = getOutputBuffer();
- if(msg)
- {
- TRACK_MESSAGE(msg);
- RemoveTileItem(msg, oldPos, oldStackpos);
- }
- }
- else if(canSee(newPos) && player->canSeeCreature(creature))
- {
- NetworkMessage_ptr msg = getOutputBuffer();
- if(msg)
- {
- TRACK_MESSAGE(msg);
- AddTileCreature(msg, newPos, newStackpos, creature);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement