玩家移动
玩家移动 //好长时间没看这些,好多都看不懂了 void Map::UpdatePlayerPos(TgtPos pos, PlayerInfo* pl) { // m_pLog->Logs(eLogLevel_Warning, "人物移动"); // 检查位置包 auto& mpos = m_spBase->GetMapPos(pos.tgtPos); if(!CheckMovePos(pos, pl))//纠正包不知干啥的 return; pl->m_CurPos = pl->tgtPos; pl->tgtPos = pos.tgtPos; pl->m_fSpeed = pos.speed; pl->mov_face = pos.mov_face; pl->mov_mode = pos.mov_mode; pl->dir = pos.dir; int curPosX = pl->m_CurPos.x; int curPosY = pl->m_CurPos.y; int tgtPosX = pl->tgtPos.x; int tgtPosY = pl->tgtPos.y; //[+]设置阻挡(压测的时候取消设置) pos2d cur_map_pos = m_spBase->GetMapPos(curPosX, curPosY); pos2d tgt_map_pos = m_spBase->GetMapPos(tgtPosX, tgtPosY); int id = pl->objId.id; //标记移动 m_MoveMgr.AddMask(pl); //没有发生位置移动 if(cur_map_pos == tgt_map_pos) return; m_MapCellMgr.UpdateObjPos(pl, cur_map_pos, tgt_map_pos); //分配到指定的地图块上面(确定是否离开了所在块) int x = pl->m_nBlockX; int y = pl->m_nBlockY; //更新区域 //pl->region = getRegion(tgt_map_pos); UpdateRegionInfo(pl, tgt_map_pos); pos2d new_block_pos = m_spBase->GetBlockPos(tgtPosX, tgtPosY); // 火墙移动处理 FireWall(pl, pos.tgtPos); if((x == new_block_pos.x) && (y == new_block_pos.y)) return ; //没变化 //删除原来的 ObjID plid; plid.id = id; plid.type = ObjID_Player; m_MapCellMgr.m_vecRolesBlock[x][y].Del(plid); //更新玩家附近的对象(其他玩家/怪) pos2d olDBlockPos = {x, y}; NotifyBlock(olDBlockPos, new_block_pos, pl); //加入新的 pl->m_nBlockX = new_block_pos.x; pl->m_nBlockY = new_block_pos.y; m_MapCellMgr.m_vecRolesBlock[new_block_pos.x][new_block_pos.y].Add(pl); //eSkillId_FireWall处理 }