Skip to content

Commit 201ccda

Browse files
author
kbengine
committed
修正跨cellapp的地图传送不会更新玩家的新坐标到客户端的问题。
acatadog@39ebe12
1 parent f4049fc commit 201ccda

2 files changed

Lines changed: 11 additions & 25 deletions

File tree

‎kbe/src/server/cellapp/entity.cpp‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,25 +2459,7 @@ void Entity::teleportRefEntity(Entity* entity, Position3D& pos, Direction3D& dir
24592459
}
24602460

24612461
currspace->removeEntity(this);
2462-
24632462
this->setPositionAndDirection(pos, dir);
2464-
2465-
if (this->pWitness())
2466-
{
2467-
// 通知位置强制改变
2468-
Network::Bundle* pSendBundle = Network::Bundle::ObjPool().createObject();
2469-
Network::Bundle* pForwardBundle = Network::Bundle::ObjPool().createObject();
2470-
2471-
(*pForwardBundle).newMessage(ClientInterface::onSetEntityPosAndDir);
2472-
(*pForwardBundle) << id();
2473-
(*pForwardBundle) << pos.x << pos.y << pos.z;
2474-
(*pForwardBundle) << direction().roll() << direction().pitch() << direction().yaw();
2475-
2476-
NETWORK_ENTITY_MESSAGE_FORWARD_CLIENT(id(), (*pSendBundle), (*pForwardBundle));
2477-
this->pWitness()->sendToClient(ClientInterface::onSetEntityPosAndDir, pSendBundle);
2478-
Network::Bundle::ObjPool().reclaimObject(pForwardBundle);
2479-
}
2480-
24812463
space->addEntityAndEnterWorld(this);
24822464

24832465
onTeleportSuccess(entity, lastSpaceID);

‎kbe/src/server/cellapp/witness.cpp‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,19 @@ void Witness::resetAOIEntities()
372372
void Witness::onEnterSpace(Space* pSpace)
373373
{
374374
Network::Bundle* pSendBundle = Network::Bundle::ObjPool().createObject();
375-
Network::Bundle* pForwardBundle = Network::Bundle::ObjPool().createObject();
376-
Network::Bundle* pForwardPosDirBundle = Network::Bundle::ObjPool().createObject();
377375

378-
(*pForwardPosDirBundle).newMessage(ClientInterface::onUpdatePropertys);
379-
MemoryStream* s1 = MemoryStream::ObjPool().createObject();
376+
// 通知位置强制改变
377+
Network::Bundle* pForwardPosDirBundle = Network::Bundle::ObjPool().createObject();
378+
Position3D &pos = pEntity_->position();
379+
Direction3D &dir = pEntity_->direction();
380+
(*pForwardPosDirBundle).newMessage(ClientInterface::onSetEntityPosAndDir);
380381
(*pForwardPosDirBundle) << pEntity_->id();
381-
pEntity_->addPositionAndDirectionToStream(*s1, true);
382-
(*pForwardPosDirBundle).append(*s1);
383-
MemoryStream::ObjPool().reclaimObject(s1);
382+
(*pForwardPosDirBundle) << pos.x << pos.y << pos.z;
383+
(*pForwardPosDirBundle) << dir.roll() << dir.pitch() << dir.yaw();
384384
NETWORK_ENTITY_MESSAGE_FORWARD_CLIENT(pEntity_->id(), (*pSendBundle), (*pForwardPosDirBundle));
385385

386+
// 通知进入了新地图
387+
Network::Bundle* pForwardBundle = Network::Bundle::ObjPool().createObject();
386388
(*pForwardBundle).newMessage(ClientInterface::onEntityEnterSpace);
387389

388390
(*pForwardBundle) << pEntity_->id();
@@ -391,6 +393,8 @@ void Witness::onEnterSpace(Space* pSpace)
391393
(*pForwardBundle) << pEntity_->isOnGround();
392394

393395
NETWORK_ENTITY_MESSAGE_FORWARD_CLIENT(pEntity_->id(), (*pSendBundle), (*pForwardBundle));
396+
397+
// 发送消息并清理
394398
pEntity_->clientMailbox()->postMail(pSendBundle);
395399

396400
Network::Bundle::ObjPool().reclaimObject(pForwardBundle);

0 commit comments

Comments
 (0)