Exemple #1
0
void GameState::destroyViper(Viper * viper)
 {
	TeamManager * team = viper->getTeam();
	team->removeViper(viper);
	this->playerDestroyed(viper); 
	delete viper;							 
 }
Exemple #2
0
bool SceneUser::doArenaCmd(const Cmd::stArenaUserCmd *ptCmd, DWORD cmdLen)
{
	using namespace Cmd;
	switch(ptCmd->byParam)
	{
	case SURPLUS_MOSAIGEM_USERCMD_ADD:
		{
			stArenaQueuingUserCmd * pCmd = (stArenaQueuingUserCmd*)ptCmd;
			switch(pCmd->Type)
			{
			case 0:		//sky 用户单人排队
				{
					if(pCmd->UserID == this->tempid)
					{
						Cmd::Session::t_Sports_AddMeToQueuing Cmd;
						Cmd.AddMeType = pCmd->AddMeType;
						Cmd.UserID = this->id;
						Cmd.Type = pCmd->Type;
						sessionClient->sendCmd(&Cmd, sizeof(Cmd::Session::t_Sports_AddMeToQueuing));
					}
				}
				break;
			case 1:		//sky 队伍排队形式
				{
					TeamManager * teamM = SceneManager::getInstance().GetMapTeam(TeamThisID);
					if(teamM)
					{
						//sky 必须自己是队长才可以队排战场
						if(this->tempid == teamM->getLeader())
						{
							Cmd::Session::t_Sports_AddMeToQueuing Cmd;
							Cmd.AddMeType = pCmd->AddMeType;
							Cmd.Type = pCmd->Type;
							Cmd.UserID = teamM->getTeamtempId();
							sessionClient->sendCmd(&Cmd, sizeof(Cmd::Session::t_Sports_AddMeToQueuing));
						}
					}
				}
				break;
			default:
				break;
			}
		}
		break;
	default:
		break;
	}

	return true;
}
Exemple #3
0
	/**
	* \brief  构造初始化消息实例
	* \param  u 队长角色对象
	* \param n 新增队员角色对象
	*/
	SendMemberDataExec(SceneUser *n, DWORD leaberID)
	{
		LeaberID = leaberID;
		nm = n;
		TeamManager * team = SceneManager::getInstance().GetMapTeam(nm->TeamThisID);
		if(team)
		{
			ret_1.dwTeamID = team->getTeamtempId(); //getLeader();
			ret_1.dwHeadID = team->getLeader();
		}
		else
		{
			ret_1.dwTeamID = 0;
			ret_1.dwHeadID = 0;
		}
	}
Exemple #4
0
/**     
 * \brief  执行脚本定义的动作
 *
 * template method模式,进行参数检查,并对于队伍中的每一个成员执行脚本定义的动作
 *      
 * \param user: 触发动作的用户
 * \param vars: 用户所带的该任务相关变量
 * \return SUCCESS表示成功,FAILED表示失败,DISABLE表示禁用某项功能
 */   
int TeamAction::do_it(SceneUser* user,Vars* vars)
{
	if (!check_args(user,vars) ) return false;

	if (_team) 
	{
		TeamManager * teamMan = SceneManager::getInstance().GetMapTeam(user->TeamThisID);

		bool result = false;

		if (teamMan) 
		{
			Team& team = const_cast<Team&>(teamMan->getTeam());

			team.rwlock.rdlock();
			std::vector<TeamMember>::iterator it = team.member.begin();;
			for(; it!=team.member.end(); ++it) 
			{
				SceneUser* member = SceneUserManager::getMe().getUserByTempID(it->tempid);
				if (member) 
				{
					Vars* v = member->quest_list.vars(vars->quest_id());
					if (v) result |= done(member,v);
				}
			}
			team.rwlock.unlock();
		}
		else
		{
			result = done(user,vars);    
		}

		return result;  
	}  

	return done(user,vars);
}
Exemple #5
0
  /**
   * \brief  回调方法将新成员发送给每个队员,将每个队员发送给新成员
   * \param  member 队员
   * \return false 终止遍历 true 继续遍历
   */
  bool exec(TeamMember &member)
  {
	  if(member.tempid == MEMBER_BEING_OFF)
		  return true;

	  SceneUser *pUser = SceneUserManager::getMe().
		  getUserByTempID(member.tempid);
	  if (pUser)
	  {
		  TeamManager * team = SceneManager::getInstance().GetMapTeam(pUser->TeamThisID);
		  ret_1.dwTeamID = team->getTeamtempId(); //getLeader();
		  ret_1.dwHeadID = team->getLeader();
		  strncpy(ret_1.data.pstrName,pUser->name,MAX_NAMESIZE);
		  if (LeaberID == pUser->tempid)
		  {
			  ret_1.data.byHead = true;
		  }
		  else
		  {
			  ret_1.data.byHead = false;
		  }
		  ret_1.data.dwTempID = pUser->tempid;
		  ret_1.data.dwMaxHealth = pUser->charstate.maxhp;
		  ret_1.data.dwHealth = pUser->charbase.hp;
		  ret_1.data.dwMaxMp = pUser->charstate.maxmp;
		  ret_1.data.dwMp = pUser->charbase.mp;
		  ret_1.data.wdFace = pUser->charbase.face;
		  strncpy(ret_1.data.pstrName,pUser->name,MAX_NAMESIZE);
		  pUser->sendCmdToMe(&ret_2,sizeof(ret_2));
		  Channel::sendSys(pUser,Cmd::INFO_TYPE_GAME,"%s加入队伍",ret_2.data.pstrName);
		  nm->sendCmdToMe(&ret_1,sizeof(ret_1));
		  //Xlogger->debug("队伍(%ld)发出添加队员指令(%s,%ld)",ret_2.dwTeamID,nm->name,nm->id);
		  return true;
	  }
	  return true;
  }
bool duplicateManager::userQuestEnterDup(SceneUser *user,DWORD mapId)
{
		userDupMaps_it it = _userDupMaps.find(user->id);
		if(it == _userDupMaps.end())
		{
			userDupMap *_userDupMap = new userDupMap;
			
			//否则查看所有队伍中是否有人在副本中,有则进入那个副本


			TeamManager * team = SceneManager::getInstance().GetMapTeam(user->TeamThisID);

			if( team == NULL ) return false; // [ranqd] 用户无队伍时返回

			int tSize = team->getSize();

			for( int i = 0; i < tSize; ++i)
			{
				const TeamMember * member = user->getMember(i);
				SceneUser *u = SceneUserManager::getMe().getUserByID(member->id);
				if(NULL == u)
					continue;
				
				dupScenePair _dupScenePair = checkUserDup(u);

				if(_dupScenePair.dupIndex != 0)
				{
					//DWORD mapid = u->scene->getRealMapID();
					(_userDupMap->tempDups)[mapId] = _dupScenePair.dupIndex;
					return user->userEnterDup(_dupScenePair.dupIndex,_dupScenePair.mapid,_userDupMap);
				}

			}			
			//创建新副本
			unsigned short _dupIndex = duplicateManager::getInstance().CreateDup();
			_userDupMaps[user->id] = _userDupMap;
			if(_dupIndex != 0)
				return user->userEnterDup(_dupIndex,mapId,_userDupMap);

		}
		else
		{
			userDupMap *_userDupMap = it->second;
			std::map<DWORD,unsigned short>::iterator it1 = (_userDupMap->tempDups).find(mapId);
			//存在对应地图的副本则进入
			if(it1 != (_userDupMap->tempDups).end())
			{
				return user->userEnterDup(it1->second,mapId,_userDupMap);
			}

			//否则查看所有队伍中是否有人在副本中,有则进入那个副本
			TeamManager * team = SceneManager::getInstance().GetMapTeam(user->TeamThisID);
			
			int tSize = 0;

			if(team)
				tSize = team->getSize();

			for( int i = 0; i < tSize; ++i)
			{
				const TeamMember * member = user->getMember(i);
				SceneUser *u = SceneUserManager::getMe().getUserByID(member->id);
				if(NULL == u)
					continue;
				
				dupScenePair _dupScenePair = checkUserDup(u);

				if(_dupScenePair.dupIndex != 0)
				{
					//DWORD mapid = u->scene->getRealMapID();
					(_userDupMap->tempDups)[mapId] = _dupScenePair.dupIndex;
					return user->userEnterDup(_dupScenePair.dupIndex,_dupScenePair.mapid,_userDupMap);
				}

			}

            //创建新副本
			unsigned short _dupIndex = duplicateManager::getInstance().CreateDup();
			_userDupMaps[user->id] = _userDupMap;
			if(_dupIndex != 0)
				return user->userEnterDup(_dupIndex,mapId,_userDupMap);

		}
	
		
 }
Exemple #7
0
/**
 * \brief 执行一个技能操作(一个操作包含若干个技能状态,操作有不同的目标对象和范围等)[sky]技能操作
 */
void zSkill::doOperation(const SkillStatus *pSkillStatus)
{
  _entry->carrier.status  = pSkillStatus;      // 一个技能操作
  //_entry->carrier.skilltype = base->usetype;  // 技能使用类型
  //_entry->carrier.skillID  = id;        // 技能ID
  _entry->carrier.skillbase = actionbase;        // 技能字典
  _entry->carrier.revCmd  = *curRevCmd;      // 保存本次收到的攻击消息
  _entry->carrier.attacker  = _entry;      // 攻击者的指针


  WORD wdTarget = pSkillStatus->target;
  if (wdTarget& TARGET_SELF)
  {
    if (_entry->skillStatusM.putOperationToMe(_entry->carrier,true))
    {
      //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
    }
    wdTarget&=(0xff & (~(1))); // 清除表示自己的位,如果只对自己施法那么wdTarget将为0
  }

  _entry->pkValue.damagebonus = actionbase->damnum;
  Scene *pScene = NULL;
  pScene = _entry->scene;
  if (wdTarget)
  {
    if (1 == pSkillStatus->range) // 1据说表示单格,所以做为单攻的判断标志
    {
      switch(curRevCmd->byAttackType)
      {
        case Cmd::ATTACKTYPE_N2U:  /// Npc攻击用户
          {
            //if (!_entry->isPkZone()) return;
            /*if (_entry->tempid == curRevCmd->dwDefenceTempID)
            {
              ScenePk::attackUserCmdToNine(curRevCmd,_entry);
              return;
            }*/
            SceneUser *pDef = pScene->getUserByTempID(curRevCmd->dwDefenceTempID);
            if (pDef)
            {
              if (wdTarget&TARGET_FRIEND)
              {
                if (!_entry->isEnemy(pDef,false,true)&&_entry->checkMagicFlyRoute(pDef,pSkillStatus->mode))
                {
                  if (pDef->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              if (wdTarget&TARGET_ENEMY)
              {
                if (pDef->getTopMaster()&&pDef->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player)
                {
                  if (!(pDef->isPkZone(_entry) && _entry->isPkZone(pDef))) // 新加&&this->isPkZone(pDef)
                  {
                    ScenePk::attackFailToMe(curRevCmd,_entry);
                    return;
                  }
                }

                if (_entry->isEnemy(pDef,_entry->getType() == zSceneEntry::SceneEntry_Player)&& // 判断敌人友和检查PK模式是一个方法,所以只要判断一次就OK了
                  _entry->checkMagicFlyRoute(pDef,pSkillStatus->mode))
                {
                  if (pDef->skillStatusM.putOperationToMe(_entry->carrier))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
            }
          }
          break;
        case Cmd::ATTACKTYPE_U2U:  /// 用户攻击用户
          {
            //if (!_entry->isPkZone()) return;
            /*if (_entry->tempid == curRevCmd->dwDefenceTempID)
            {
              ScenePk::attackUserCmdToNine(curRevCmd,_entry);
              return;
            }*/
            SceneUser *pDef = pScene->getUserByTempID(curRevCmd->dwDefenceTempID);
            if (pDef)
            {
              if (wdTarget&TARGET_FRIEND)
              {
                if (!_entry->isEnemy(pDef,false,true)&&_entry->checkMagicFlyRoute(pDef,pSkillStatus->mode))
                {
                  if (pDef->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              if (wdTarget&TARGET_ENEMY)
              {
                if (_entry->isEnemy(pDef,_entry->getType() == zSceneEntry::SceneEntry_Player)&& // 判断敌人友和检查PK模式是一个方法,所以只要判断一次就OK了
                  pDef->isPkZone(_entry)&&_entry->isPkZone(pDef)&&//新加 _entry->isPkZone(pDef)
                  _entry->checkMagicFlyRoute(pDef,pSkillStatus->mode))
                {
                  if (pDef->skillStatusM.putOperationToMe(_entry->carrier))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
                else
                {
                  ScenePk::attackFailToMe(curRevCmd,_entry);
                }
              }
            }
          }
          break;
        case Cmd::ATTACKTYPE_U2N:  /// 用户攻击Npc
          {
            SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(curRevCmd->dwDefenceTempID);
            if (pNpc)
            {
              if (wdTarget&TARGET_PET)
              {
                if (!_entry->isEnemy(pNpc,false,true)&&_entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode)&&pNpc->getPetType()==Cmd::PET_TYPE_PET)
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              else if (wdTarget&TARGET_SUMMON)
              {
                if (!_entry->isEnemy(pNpc,false,true)&&_entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode)&&pNpc->getPetType()==Cmd::PET_TYPE_SUMMON)
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              else if (wdTarget&TARGET_NPC)
              {
                if (pNpc->getTopMaster()&&pNpc->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player)
                {
                  if (!(pNpc->isPkZone(_entry) && _entry->isPkZone(pNpc))) // 新加&&this->isPkZone(pDef)
                  {
                    ScenePk::attackFailToMe(curRevCmd,_entry);
                    return;
                  }
                }

                if (_entry->isEnemy(pNpc)&& // 判断敌人友和检查PK模式是一个方法,所以只要判断一次就OK了
                  _entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode))
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
                else
                {
                  ScenePk::attackFailToMe(curRevCmd,_entry);
                }
              }
            }
          }
          break;
        case Cmd::ATTACKTYPE_N2N:  /// Npc攻击Npc
          {
            SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(curRevCmd->dwDefenceTempID);
            if (pNpc)
            {
              if (wdTarget&TARGET_PET)
              {
                if (!_entry->isEnemy(pNpc,false,true)&&_entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode)&&pNpc->getPetType()==Cmd::PET_TYPE_PET)
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
              else if (wdTarget&TARGET_SUMMON)
              {
                if (!_entry->isEnemy(pNpc,false,true)&&_entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode)&&pNpc->getPetType()==Cmd::PET_TYPE_SUMMON)
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier,true))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                    return;
                  }
                  else
                  {
                    return;
                  }
                }
              }
              else if (wdTarget&TARGET_NPC)
              {
                if (_entry->getTopMaster() &&
                  _entry->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player &&
                  pNpc->getTopMaster() &&
                  pNpc->getTopMaster()->getType() == zSceneEntry::SceneEntry_Player)
                {
                  if (!(pNpc->isPkZone(_entry) && _entry->isPkZone(pNpc))) // 新加&&this->isPkZone(pDef)
                  {
                    ScenePk::attackFailToMe(curRevCmd,_entry);
                    return;
                  }
                }

                if (_entry->isEnemy(pNpc)&& // 判断敌人友和检查PK模式是一个方法,所以只要判断一次就OK了
                  _entry->checkMagicFlyRoute(pNpc,pSkillStatus->mode))
                {
                  if (pNpc->skillStatusM.putOperationToMe(_entry->carrier))
                  {
                    //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
                  }
                  return;
                }
              }
            }
          }
          break;
        case Cmd::ATTACKTYPE_U2P:  /// 用户攻击点
          {
            zPos pd;
            DWORD num =0;
            pd.x = (DWORD)curRevCmd->xDes;
            pd.y = (DWORD)curRevCmd->yDes;
            if (findAttackTarget(pSkillStatus,pd,num))
            {
              //ScenePk::attackUserCmdToNine(curRevCmd,_entry);
            }
            return;
          }
          break;
        case Cmd::ATTACKTYPE_U2B:  /// 用户攻击建筑
        default:
          {
            //if (!ScenePk::attackUserCmdToNine(curRevCmd,_entry))
            //{
            //  return;
            //}
            return;
          }
          break;
      }
//      ScenePk::attackFailToMe(curRevCmd,_entry);
    }
    else
    {
      zPos center,pd;
      BYTE byDir=0;
      if (curRevCmd->dwDefenceTempID!=0)
      {
        switch(curRevCmd->byAttackType)
        {
          case Cmd::ATTACKTYPE_N2U:  /// Npc攻击用户
          case Cmd::ATTACKTYPE_U2U:  /// Npc攻击用户
            {
              SceneUser *pDef = pScene->getUserByTempID(curRevCmd->dwDefenceTempID);
              if (pDef)
              {
                center = pDef->getPos();
              }
              else
              {
                center.x = (DWORD)curRevCmd->xDes;
                center.y = (DWORD)curRevCmd->yDes;
              }
            }
            break;
          case Cmd::ATTACKTYPE_N2N:  /// Npc攻击用户
          case Cmd::ATTACKTYPE_U2N:  /// Npc攻击用户
            {
              SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(curRevCmd->dwDefenceTempID);
              if (pNpc)
              {
                center = pNpc->getPos();
              }
              else
              {
                center.x = (DWORD)curRevCmd->xDes;
                center.y = (DWORD)curRevCmd->yDes;
              }
            }
            break;
          default:
            {
              center.x = (DWORD)curRevCmd->xDes;
              center.y = (DWORD)curRevCmd->yDes;
            }
            break;
        }
      }
      else
      {
        center.x = (DWORD)curRevCmd->xDes;
        center.y = (DWORD)curRevCmd->yDes;
      }

      switch(pSkillStatus->center)
      {
        case SKILL_CENTER_TYPE_MOUSE:
          {
//            center.x = (DWORD)curRevCmd->xDes;
//            center.y = (DWORD)curRevCmd->yDes;
            byDir = curRevCmd->byDirect;
            _entry->setDir(byDir);
#ifdef _DEBUG 
            Channel::sendSys(_entry->tempid,Cmd::INFO_TYPE_GAME,"中心点类型:鼠标(%u,%u) 方向:%u",center.x,center.y,byDir);
#endif
            // debug提示
          }
          break;
        case SKILL_CENTER_TYPE_SELF:
          {
            center.x = _entry->getPos().x;
            center.y = _entry->getPos().y;
            byDir = curRevCmd->byDirect;//_entry->getDir();
            _entry->setDir(byDir);
#ifdef  _DEBUG 
            Channel::sendSys(_entry->tempid,Cmd::INFO_TYPE_GAME,"中心点类型:自身(%u,%u) 方向:%u",center.x,center.y,byDir);
#endif
          }
          break;
        default:
#ifdef _DEBUG 
          Channel::sendSys(_entry->tempid,Cmd::INFO_TYPE_GAME,"中心点类型:填写错误请查证");
#endif
          break;
      }

      switch(pSkillStatus->range)
      {
        case 20:
          {
            DWORD tempLen = sizeof(struct Cmd::stAttackMagicUserCmd);
            DWORD itemNum = 0;
#ifdef _DEBUG
            Zebra::logger->error("!!!---客户端发过来的攻击指令原始长度[%u] 当前长度[%u]",tempLen,curRevCmdLen);
#endif
            if (curRevCmdLen>tempLen)
            {
              itemNum = (curRevCmdLen-tempLen)/sizeof(DWORD);
#ifdef _DEBUG
              Zebra::logger->error("!!!---客户端发过来的攻击列表数目[%u]",itemNum);
#endif
              if (itemNum >5) itemNum=5;
              for (DWORD i=0; i<itemNum; i++)
              {
                SceneNpc *pNpc=NULL;
                SceneUser *pUser=NULL;
#ifdef _DEBUG
                Zebra::logger->error("!!!---客户端发过来的被攻击临时坐标[%u]",curRevCmd->dwTempIDList[i]);
#endif
                if ((pNpc=_entry->scene->getNpcByTempID(curRevCmd->dwTempIDList[i]))!=NULL)
                {
                  pd = pNpc->getPos();
                }
                else if ((pUser=_entry->scene->getUserByTempID(curRevCmd->dwTempIDList[i]))!=NULL)
                {
                  pd = pUser->getPos();
                }
                else continue;
/*
                pd.x= (curRevCmd->dwTempIDList[i]>>16) &0xffff;
                pd.y= (curRevCmd->dwTempIDList[i]&0xff);
*/    
#ifdef _DEBUG
                Zebra::logger->error("!!!---客户端发过来的攻击坐标[%u][x=%u,y=%u]",curRevCmd->dwTempIDList[i],pd.x,pd.y);
#endif

//-技能范围测试
#ifdef _DEBUG
                zObjectB *base = objectbm.get(501);
                if (base)
                {
                  zObject *o=zObject::create(base,1);
                  _entry->scene->addObject(o,pd);
                }
#endif
                DWORD num=0;
                if (!findAttackTarget(pSkillStatus,pd,num)) break;
              }
            }
          }
          break;
        case 21:
          {
            zPosVector range;
            pScene->findEntryPosInNine(_entry->getPos(),_entry->getPosI(),range);
            for(zPosVector::iterator iter = range.begin(); iter != range.end() ; iter ++)
            {
              pd = *iter;
//-技能范围测试
#ifdef _DEBUG
              zObjectB *base = objectbm.get(585);
              if (base)
              {
                zObject *o=zObject::create(base,randBetween(1,10));
                _entry->scene->addObject(o,pd);
              }
#endif
              DWORD num=0;
              if (!findAttackTarget(pSkillStatus,pd,num)) break;
            }
          }
          break;
        case 22:
          {
            if (_entry->getType() == zSceneEntry::SceneEntry_Player)
            {
              SceneUser *pUser = (SceneUser *)_entry;

			  TeamManager * team = SceneManager::getInstance().GetMapTeam(pUser->TeamThisID);

              if (team)
              {
				  SendStatusToTeamExec exec(pUser,pSkillStatus);
				  team->execEveryOne(exec);
              }
            }
          }
          break;
        case 50:
          {
            zPosVector range;
            int count=0;
            pScene->findEntryPosInOne(_entry->getPos(),_entry->getPosI(),range);
            for(zPosVector::iterator iter = range.begin(); iter != range.end() ; iter ++)
            {
              count++;
              if (count>20) break;
              pd = *iter;
//-技能范围测试
#ifdef _DEBUG
              zObjectB *base = objectbm.get(585);
              if (base)
              {
                zObject *o=zObject::create(base,randBetween(1,10));
                _entry->scene->addObject(o,pd);
              }
#endif
              DWORD num=0;
              if (!findAttackTarget(pSkillStatus,pd,num)) break;
            }
          }
          break;
        default:
          {
            SMagicRange range;
            DWORD maxCount =0;
            DWORD count=0;
            MagicRangeInit::getInstance().get(pSkillStatus->range,byDir % 2,range);
            maxCount = range.num;
            if (0==maxCount) maxCount = 65535;
            for(std::vector<RelativePos>::iterator iter = range.lib.begin(); iter != range.lib.end() ; iter ++)
            {
              SWORD rangDamageBonus=0;
              pd = iter->getAbsolutePos(center,byDir);
              rangDamageBonus = (*iter).w;
//-技能范围测试
#ifdef _DEBUG
              zObjectB *base = objectbm.get(585);
              if (base)
              {
                zObject *o=zObject::create(base,randBetween(1,10));
                _entry->scene->addObject(o,pd);
              }
#endif
              DWORD num=0;
              if (!findAttackTarget(pSkillStatus,pd,num,rangDamageBonus)) break;
              if (num>0)
              {
                count++;
                if (count>= maxCount) break;
              }
            }
          }
      }
      return;
    }
  }
}
Exemple #8
0
//sky 宝石镶嵌处理函数
bool SceneUser::doMosaicGenCmd(const Cmd::stMakeObjectUserCmd *ptCmd,DWORD cmdLen)
{
	using namespace Cmd;
	switch(ptCmd->byParam)
	{
	case SURPLUS_MOSAIGEM_USERCMD_ADD:		//sky 镶嵌宝石
		{
			stMosaicGemUserCmd * pCmd = (stMosaicGemUserCmd *)ptCmd;

			zObject * Eobj = GetObjectBydst( &(pCmd->Epos) );
			zObject * Gobj = GetObjectBydst( &(pCmd->Gpos) );

			if( Hole::put_hole(Eobj ,pCmd->index ,Gobj) )
			{
				//从包袱中删除宝石
				packs.removeObject(Gobj);

				//刷新客户端的物品信息
				Cmd::stAddObjectPropertyUserCmd ret;
				ret.byActionType = Cmd::EQUIPACTION_REFRESH;
				bcopy(&Eobj->data,&ret.object,sizeof(t_Object),sizeof(t_Object));
				sendCmdToMe(&ret,sizeof(ret));
			}
		}
		break;
	case RT_NPC_DIRITEM_USERCMD_PARA:		//sky 队长查询NPC尸体中的物品列表
		{
			stNpcDirItemUserCmd * pCmd = (stNpcDirItemUserCmd *)ptCmd;

			npc_dwNpcTempID = pCmd->dwNpcTempID;
			SceneNpc *sceneNpc= SceneNpcManager::getMe().getNpcByTempID( npc_dwNpcTempID );

			if( !sceneNpc )
			{
				Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"目标不存在.");
				return true;
			}

			if( !(sceneNpc->m_TemObj.empty()) )
			{
				TeamManager * teamMan = SceneManager::getInstance().GetMapTeam(TeamThisID);

				if( this->tempid == sceneNpc->Captain_ID && teamMan->isCaptainObj() )
				{
					void * buffer = NULL;
					int nLen = sizeof(stNpcDirItemDataUserCmd) 
						+ (sizeof(stNpcDirItemDataUserCmd::team)*10)
						+ (sizeof(t_Object)*(sceneNpc->m_TemObj.size()));

					buffer = malloc( nLen );

					stNpcDirItemDataUserCmd * Cmd = (stNpcDirItemDataUserCmd *)buffer;
					Cmd->byCmd = MAKEOBJECT_USERCMD;
					Cmd->byParam = RT_NPC_DIRITEM_DATA_USERCMD_PARA;

					memset( &(Cmd->fen_team[0]), 0, sizeof(Cmd->fen_team) );
					int i = 0;

					std::vector<TeamMember>::iterator teamit;

					for( int f=0; f<teamMan->getSize(); f++ )
					{
						if( f < MAX_TEAM_NUM )
						{
							const TeamMember * ztTeam = getMember(f);
							Cmd->fen_team[f].tempid = ztTeam->tempid;
							memccpy( Cmd->fen_team[f].name, ztTeam->name, 33,sizeof(Cmd->fen_team[f].name) );
						}
					}


					Cmd->count = sceneNpc->m_TemObj.size();
					i = 0;
					std::list<zObject *>::iterator it;
					for( it = sceneNpc->m_TemObj.begin(); it != sceneNpc->m_TemObj.end(); it++ )
					{
						if( i < Cmd->count )
						{
							memccpy( &(Cmd->objects[i]), &((*it)->data), sizeof(t_Object),sizeof(Cmd->objects[i]) );
							i++;
						}
					}

					sendCmdToMe(Cmd,nLen);

					free( buffer );
				}
			}
		}
		break;
	case RT_NPC_GIVEITEM_USERCMD:		//sky 把分配过的物品添加到被分配人的包袱中
		{
			stNpcGiveItemUserCmd * pCmd = (stNpcGiveItemUserCmd *)ptCmd;

			SceneNpc *sceneNpc= SceneNpcManager::getMe().getNpcByTempID( npc_dwNpcTempID );
			if( !sceneNpc )
			{
				Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"该NPC已经不存在拉!");
				return true;
			}
			std::list<zObject *>::iterator it;
			for(it = sceneNpc->m_TemObj.begin(); it != sceneNpc->m_TemObj.end(); it++)
			{
				if( (*it)->data.qwThisID == pCmd->qwThisID )
				{
					SceneUser * pUser = SceneUserManager::getMe().getUserByTempID( pCmd->UserTemID );
					if( !pUser )
					{
						Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"被分配的队员现在处于离线状态!");
					}
					else
					{
						if(pUser->packs.uom.space(pUser) >= 1)
						{
							zObject * obj = *it;
							it = sceneNpc->m_TemObj.erase(it);				//sky 先从怪物尸体中的物品列表里删除这个物品
							pUser->packs.addObject(obj, true, AUTO_PACK);	//sky 再添加到被分配人的包袱中

							char msg[MAX_PATH];
							sprintf(msg, "%s 被队长 %s 分配到物品 %s", pUser->charbase.name, this->charbase.name, obj->data.strName );
							Channel::sendTeam(TeamThisID, msg);

							Cmd::stAddObjectPropertyUserCmd send;
							bcopy(&obj->data,&send.object,sizeof(t_Object),sizeof(send.object));
							pUser->sendCmdToMe(&send,sizeof(send));
							return true;
						}
						else
						{
							Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"被分配队员包裹没有空位!");
						}
					}
				}
			}
		}
		break;
	case RT_TEAM_ROLL_ITEM_START:
		{
			stTeamRollItemStartUserCmd * pCmd = (stTeamRollItemStartUserCmd *)ptCmd;

			zPos p;
			zSceneObject *ret = NULL;
			p.x = pCmd->itemX;
			p.y = pCmd->itemY;
			ret = scene->getSceneObjectByPos( p );
			if (ret)
			{
				//int ok = 0;
				zObject *o=ret->getObject();
				if (!o)
				{
					return true;
				}

				//sky 开始ROLL的时候把地面物品的保护时间延迟90秒(以免ROLL还没结束物品就到拉保护时间被人拾取拉)
				ret->setprotectTime( 90 );

				//sky 判断物品的保护ID是否和拾取人的队伍ID一致
				if(!ret->getOwner())
				{
					TeamManager *team = SceneManager::getInstance().GetMapTeam(TeamThisID);

					if(team && ret->getOwner() == team->getTeamtempId())
					{
						if( team->GetTeamMemberNum() > 1 ) //sky 判断队伍中真实在线的人必须超过2个才ROLL
						{
					
							if( team->bRoll )
							{
								//sky 将该物品的唯一ID保存到队伍被ROLL物品中同时开始设置定时器和ROLL标志
								team->SetRollItem( p, scene->tempid );
								team->dwRollTime = ROLL_MAX_TIME;
								team->bRoll = true;

								//sky 通知所以队伍成员开始ROLL
								team->NoticeRoll( o );
							}
							else
								Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"请先等上一次的ROLL结束后在拾取!");
						
						}
						else //sky 否则直接把物品给这个拾取的玩家
						{
							if( packs.uom.space(this) >= 1)
							{
								//sky 通知客户端跟新地面物品被删除
								Cmd::stRemoveMapObjectMapScreenUserCmd re;
								re.dwMapObjectTempID=ret->id;
								scene->sendCmdToNine(ret->getPosI(),&re,sizeof(re),ret->dupIndex);

								//sky 先冲地面上删除这个物品
								scene->removeObject(ret);
								SAFE_DELETE(ret);

								//sky 在把他添加到玩家的包袱中
								packs.addObject( o, true, AUTO_PACK );

								//sky 通知玩家客户端跟新包袱里的物品信息
								Cmd::stAddObjectPropertyUserCmd send;
								bcopy(&o->data,&send.object,sizeof(t_Object),sizeof(send.object));
								sendCmdToMe(&send,sizeof(send));
							}
							else
							{
								Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"包裹里没有空位置拉!");
							}
						}

						return true;
					}
				}
				else
				{
					Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"这件物品不属于你!");
					return true;
				}
			}
		}
		break;
	case RT_TEAM_ROLL_ITEM_USERTYPE:
		{
			stTeamRollItemTypeUserCmd * pCmd = (stTeamRollItemTypeUserCmd *)ptCmd;

			TeamManager * team = SceneManager::getInstance().GetMapTeam(TeamThisID);

			if( team )
			{
				if(!team->bRoll )
				{
					Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"非法ROLL消息!");
					return true;
				}

				char msg[MAX_PATH];
				int num;

				num = team->SetMemberRoll( this->tempid, pCmd->Rolltype );

				if( pCmd->Rolltype == Roll_GiveUp )
				{
					sprintf(msg, "ROLL信息:%s放弃", charbase.name );
				}
				else if( pCmd->Rolltype == Roll_Greed )
				{
					sprintf(msg, "ROLL信息:%s 贪婪 点数为 %d", charbase.name, num );
				}
				else if( pCmd->Rolltype == Roll_Need )
				{
					sprintf(msg, "ROLL信息:%s 需求 点数为 %d", charbase.name, num );
				}

				Channel::sendTeam(team->getTeamtempId(), msg);
			}
			return true;
		}
		break;
	case RT_MAKE_TURRET_USERCMD:	//sky 这个是制造炮台消息和上面的分配消息已经完全没关系拉^_^
		{
			stMakeTurretUserCmd * pCmd = (stMakeTurretUserCmd*)ptCmd;

			zObject *srcobj=packs.uom.getObjectByThisID(pCmd->dwThisID);

			//sky 如果建筑类的物品不存在或者传递过来的物品类型不是建筑类的物品
			if(!srcobj || srcobj->base->kind != ItemType_Building)
			{
				Zebra::logger->debug("建造:物品已经不存在或者物品类型不是建筑类物品,用户:%s 物品ID:%u", name, pCmd->dwThisID);
				return true;
			}

			zNpcB *base = npcbm.get( srcobj->base->maxhp );

			if(base)
			{
				zPos pos;
				pos.x = pCmd->pos.x;
				pos.y = pCmd->pos.y;

				if(!scene->checkBlock( pos ) && !scene->checkBlock(pos, TILE_NOCREATE) )
				{
					ScenePet *npc = summonPet(base->id ,Cmd::PET_TYPE_TURRET,0,0,"",0,pos,4);

					if(npc)
					{
						//sky 把该NPC设置为建造状态
						npc->showCurrentEffect(Cmd::NPCSTATE_MAKE, true);
						npc->MakeTime = srcobj->base->maxsp;

						if(--srcobj->data.dwNum)
						{
							Cmd::stRefCountObjectPropertyUserCmd send;
							send.qwThisID=srcobj->data.qwThisID;
							send.dwNum=srcobj->data.dwNum;
							sendCmdToMe(&send,sizeof(send));
						}
						else
						{
							return packs.removeObject(srcobj);
						}
					}
					else
						Zebra::logger->debug("用户:%s 企图建造一个不存在的NPC!", name);
				}
				else
					Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"这里不允许建造!");
			}
		}
		break;
	case RT_NPC_START_CHANGE_USERCMD:	//sky  这个又变成NPC变身的处理拉,我承认我懒的加父消息拉otz
		{
			stNpcStartChangeUserCmd * pCmd = (stNpcStartChangeUserCmd*)ptCmd;
			SceneNpc *sceneNpc= SceneNpcManager::getMe().getNpcByTempID( pCmd->npcid );

			if(sceneNpc)
			{
				if(!sceneNpc->ChangeNpc())
					Zebra::logger->debug("NPC %s 变身失败!",sceneNpc->define->name);
			}
			else
				Zebra::logger->debug("无法找到唯一ID为 %u 的NPC",pCmd->npcid);
		}
		break;
	case PACK_BUYTAB_NUM_USERCMD:	//sky 购买包袱页的处理,反正都已经做拉怎么多无关的消息拉,再加一个也没关系吧 ^_^
		{
			stPackBuyTanbNumUserCmd * pCmd = (stPackBuyTanbNumUserCmd*)ptCmd;
			if(pCmd->PackType == PACKE_TYPE)
			{
				switch(packs.main.TabNum)
				{
				case 2:
					{
						if (!packs.checkMoney( 5000 ) || !packs.removeMoney(5000,"购买包袱页3"))
						{
							Channel::sendSys(this, Cmd::INFO_TYPE_FAIL, "50个银币!钱都没有!还想要包袱!!先去赚钱吧");
							return true;
						}
						else
							packs.main.TabNum += 1;
					}
					break;
				case 3:
					{
						if(packs.removeGold( 50, "购买包袱页4" ))
							packs.main.TabNum += 1;
						else
						{
							Channel::sendSys(this,Cmd::INFO_TYPE_FAIL, "50点游戏点卷!钱都没有!还想要包袱!!先去赚钱吧");
							return true;
						}
					}
					break;
				case 4:
					{
						if(packs.removeGold( 200, "购买包袱页5" ))
							packs.main.TabNum += 1;
						else
						{
							Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"200点游戏点卷!钱都没有!还想要包袱!!先去赚钱吧");
							return true;
						}
					}
					break;
				default:
					{
						Zebra::logger->error("玩家:%s 购买包袱的时候 发现错误的可用页数量%d", name, packs.main.TabNum);
						return true;
					}
					break;
				}

				stPackBuyTanbNumUserCmd Cmd;
				Cmd.TabNum = packs.main.TabNum;
				Cmd.PackType = PACKE_TYPE;
				sendCmdToMe(&Cmd,sizeof(stPackBuyTanbNumUserCmd));
			}
			else if(pCmd->PackType == SAVEBOX_TYPE)
			{
				switch(packs.store.days)
				{
				case 2:
					{
						/*if (!packs.checkMoney( 5000 ) || !packs.removeMoney(5000,"购买仓库页3"))
						{
							Channel::sendSys(this, Cmd::INFO_TYPE_FAIL, "50个银币!钱都没有!还想要仓库!!先去赚钱吧");
							return true;
						}
						else*/
							packs.store.days += 1;
					}
					break;
				case 3:
					{
						if(packs.removeGold( 50, "购买仓库页4" ))
							packs.store.days += 1;
						else
						{
							Channel::sendSys(this,Cmd::INFO_TYPE_FAIL, "50点游戏点卷!钱都没有!还想要仓库!!先去赚钱吧");
							return true;
						}
					}
					break;
				case 4:
					{
						if(packs.removeGold( 200, "购买仓库页5" ))
							packs.store.days += 1;
						else
						{
							Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"200点游戏点卷!钱都没有!还想要仓库!!先去赚钱吧");
							return true;
						}
					}
					break;
				default:
					{
						Zebra::logger->error("玩家:%s 购买仓库的时候 发现错误的可用页数量%d", name, packs.main.TabNum);
						return true;
					}
					break;
				}

				packs.store.notify(this);
			}		
		}
		break;
	default:
		break;
	}

	return true;
}
Exemple #9
0
/**
 * \brief 使用药品
 *
 *
 * \param obj: 使用物品指针 
 * \return 使用是否成功
 */
bool SceneUser::useLeechdom(zObject *obj)
{
  if (!useRes) return true;

  DWORD old_num=obj->data.dwNum;
  DWORD update = 0;
  switch(obj->base->leechdom.id)
  {
    case Leechdom_dam:
      {
      }
      break;
    case Leechdom_def:
      {
      }
      break;
    case Leechdom_poison:
      {
      }
      break;
    case Leechdom_sppersist:
      {
        leechdom.add(Leechdom_sppersist,0,obj->base->leechdom.time);
      }
      break;
    case Leechdom_spup:
      {
        DWORD temp = (DWORD)(charstate.maxsp * (obj->base->leechdom.effect/100.0f));
        charbase.sp=(charbase.sp+temp) >
          charstate.maxsp?charstate.maxsp:(charbase.sp+temp);
        update |= 0x04;
      }
      break;
    case Leechdom_spcostdown:
      {
      }
      break;
    case Leechdom_sp:
      {
        DWORD temp = obj->base->leechdom.effect;
        charbase.sp=(charbase.sp+temp) >
          charstate.maxsp?charstate.maxsp:(charbase.sp+temp);
        update |= 0x04;
      }
      break;
    case Leechdom_spresumeup:
      {
        leechdom.add(Leechdom_spresumeup,obj->base->leechdom.effect,obj->base->leechdom.time);
      }
      break;
    case Leechdom_hp:
    case Leechdom_hp5:
      {
        charbase.hp=(charbase.hp+obj->base->leechdom.effect) >
          charstate.maxhp?charstate.maxhp:(charbase.hp+obj->base->leechdom.effect);
        update |= 0x01;
      }
      break;
    case Leechdom_hppersist:
    case Leechdom_hppersist5:
      {
        leechdom.add(Leechdom_hppersist,obj->base->leechdom.effect,obj->base->leechdom.time);
      }
      break;
    case Leechdom_mp:
      {
        charbase.mp=(charbase.mp+obj->base->leechdom.effect) >
          charstate.maxmp?charstate.maxmp:(charbase.mp+obj->base->leechdom.effect);
        update |= 0x02;
      }
      break;
    case Leechdom_mppersist:
      {
        leechdom.add(Leechdom_mppersist,obj->base->leechdom.effect,obj->base->leechdom.time);
      }
      break;
    case Leechdom_hpmax:
      {
        DWORD need = 0;
        if (obj->base->id == 881)
        {
          need = (charstate.maxhp-charbase.hp>3000)?3000:charstate.maxhp-charbase.hp;
        }
        else
        {
          need = (charstate.maxhp-charbase.hp>2500)?2500:charstate.maxhp-charbase.hp;
        }
        if (0==need)
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你现在不需要");
          return true;
        }

        charbase.hp += ((DWORD)(obj->data.dur*100)>need)?need:obj->data.dur*100;

        DWORD minus = need>200?need:200;
        if (minus%100>50)
          minus = minus/100+1;
        else
          minus = minus/100;

        if (obj->data.dur>minus)
          obj->data.dur -= minus;
        else
        {
          obj->data.dur = 0;
          obj->data.dwNum = 0;
        }

        Cmd::stDurabilityUserCmd ret;
        ret.dwThisID = obj->data.qwThisID;
        ret.dwDur = obj->data.dur;
        ret.dwMaxDur = obj->data.maxdur;
        sendCmdToMe(&ret,sizeof(ret));

        update |= 0x01;
      }
      break;
    case Leechdom_mpmax:
      {
        DWORD need = charstate.maxmp-charbase.mp;
        if (0==need)
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你现在不需要");
          return true;
        }

        charbase.mp += ((DWORD)(obj->data.dur*50)>need)?need:obj->data.dur*50;

        DWORD minus = need>50?need:50;
        if (minus%50>25)
          minus = minus/25+1;
        else
          minus = minus/25;

        if (obj->data.dur>minus)
          obj->data.dur -= minus;
        else
        {
          obj->data.dur = 0;
          obj->data.dwNum = 0;
        }

        Cmd::stDurabilityUserCmd ret;
        ret.dwThisID = obj->data.qwThisID;
        ret.dwDur = obj->data.dur;
        ret.dwMaxDur = obj->data.maxdur;
        sendCmdToMe(&ret,sizeof(ret));

        update |= 0x01;
      }
      break;
    case Leechdom_chocolate:
      {
        leechdom.add(Leechdom_hppersist,obj->base->leechdom.effect,obj->base->leechdom.time);
        leechdom.add(Leechdom_mppersist,obj->base->leechdom.effect,obj->base->leechdom.time);
      }
      break;
    default:
      {
        Zebra::logger->debug("不能识别的物品类型:%u",obj->base->leechdom.id);
        return false;
      }
      break;
  }

  if (obj->base->leechdom.id!=Leechdom_hpmax && obj->base->leechdom.id!=Leechdom_mpmax && (int)obj->data.dwNum > 0)
    obj->data.dwNum--;

  if (obj->data.dwNum==0)//数量0
  {
    zObject::logger(obj->createid,obj->data.qwThisID,obj->data.strName,obj->data.dwNum,obj->data.dwNum,0,this->id,this->name,0,NULL,"用药",NULL,0,0);
    packs.removeObject(obj); //notify and delete
  }
  else
  {
    //zObject::logger(obj->createid,obj->data.qwThisID,obj->base->name,obj->data.dwNum,this->id,this->name,this->id,this->name,"用药");
    if (old_num != obj->data.dwNum)
    {
      Cmd::stRefCountObjectPropertyUserCmd send;
      send.qwThisID=obj->data.qwThisID;
      send.dwNum=obj->data.dwNum;
      sendCmdToMe(&send,sizeof(send));
    }
  }

  if (update) {
    //notify me
    Cmd::stSetHPAndMPDataUserCmd ret;
    ret.dwHP = charbase.hp;
    ret.dwMP = charbase.mp;
    //ret.dwSP = charbase.sp;
    this->sendCmdToMe(&ret,sizeof(ret));
  }
  if (update & 0x01) {
	  TeamManager * team = SceneManager::getInstance().GetMapTeam(TeamThisID);

	  if(team)
		  team->sendtoTeamCharData(this);
  }

#ifdef _TEST_DATA_LOG
  switch(obj->data.maxhp)
  {
    case Leechdom_sppersist:
    case Leechdom_spup:
    case Leechdom_sp:
    case Leechdom_spresumeup:
      {
        writeCharTest(Cmd::Record::SP_WRITEBACK);
      }
      break;
    case Leechdom_hp:
    case Leechdom_hp5:
    case Leechdom_hppersist:
    case Leechdom_hppersist5:
    case Leechdom_hpmax:
      {
        writeCharTest(Cmd::Record::HP_WRITEBACK);
      }
      break;
    case Leechdom_mp:
    case Leechdom_mppersist:
    case Leechdom_mpmax:
      {
        writeCharTest(Cmd::Record::MP_WRITEBACK);
      }
      break;
    default:
      break;
  }
#endif // _TEST_DATA_LOG测试数据

  return true;
}
Exemple #10
0
/**     
 * \brief  处理stPropertyUserCmd指令
 *
 *
 * 处理stPropertyUserCmd指令
 *      
 * \param rev: 接受到的指令内容
 * \param cmdLen: 接受到的指令长度
 * \return 处理指令成功返回真,否则返回false
 */       
bool SceneUser::doPropertyCmd(const Cmd::stPropertyUserCmd *rev,DWORD cmdLen)
{
  switch(rev->byParam)
  {
  case SWAPUSEROBJECT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stSwapObjectPropertyUserCmd *swap=(Cmd::stSwapObjectPropertyUserCmd *)rev;
        //得到原物品
        zObject *srcobj=packs.uom.getObjectByThisID(swap->qwThisID);
        if (srcobj)
        {
          //交易处理
          if (tradeorder.hasBegin() && tradeorder.in_trade(srcobj))
          {
            return true;
          }
        
          if (mask.is_use(srcobj)) {
            return Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"请先解除该蒙面巾!");
          }
          stObjectLocation org=srcobj->data.pos;
          Xlogger->info("[移动物品]%s移动物品%s(%d,%d,%d,%d)->(%d,%u,%d,%d)",name,srcobj->data.strName,
              org.loc(),org.tab(),org.xpos(),org.ypos(),
              swap->dst.loc(),swap->dst.tab(),swap->dst.xpos(),swap->dst.ypos());
          if (org != swap->dst && packs.moveObject(this,srcobj,swap->dst))
          {
            //向客户端发送指令指明新的两个地方的物品
            if (swap->dst.loc()!=Cmd::OBJECTCELLTYPE_NONE)
              sendCmdToMe(swap,sizeof(Cmd::stSwapObjectPropertyUserCmd));

            if (packs.equip.needRecalc/* || recalcBySword(false)*/)
            {
              notifyEquipChange();
              setupCharBase();
              Cmd::stMainUserDataUserCmd  userinfo;
              full_t_MainUserData(userinfo.data);
              sendCmdToMe(&userinfo,sizeof(userinfo));

              sendMeToNine();
              this->reSendData = false;
#ifdef _DEBUG
              Xlogger->info("[移动物品]完毕......");
#endif
            }
          }
          else
            Xlogger->info("[移动物品]%s移动物品%s(%d,%d,%d,%d)->(%d,%u,%d,%d)失败",name,srcobj->data.strName,
                org.loc(),org.tab(),org.xpos(),org.ypos(),
                swap->dst.loc(),swap->dst.tab(),swap->dst.xpos(),swap->dst.ypos());
        }
        else
          Xlogger->warn("[移动物品]%s未找到移动物品 %ld",name,swap->qwThisID);
        return true;
      }
      break;
    case SPLITUSEROBJECT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stSplitObjectPropertyUserCmd *split=(Cmd::stSplitObjectPropertyUserCmd *)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(split->qwThisID);

        if (!srcobj) return true;


        //fix objects which have num can be equiped via this,it's ugly and should be checked at client too
        //NOTICE: this will lead to theses objects can not be equiped,client shouldn't send this cmd,use 
        //stSwapObjectPropertyUserCmd instead when needed.
        if (split->dst.loc() == Cmd::OBJECTCELLTYPE_EQUIP
            || split->dst.loc() == Cmd::OBJECTCELLTYPE_PET) return true;
        
        //交易处理
        if (tradeorder.hasBegin() && tradeorder.in_trade(srcobj))
        {
          return true;
        }

        if (split->dwNum > srcobj->data.dwNum) {
          return true;
        }

        bool notify = false;

        //其他物品 
        Package *destpack=packs.getPackage(split->dst.loc(),split->dst.tab());
        zObject *destobj=NULL;
        if (destpack && 
          destpack->getObjectByZone(&destobj,split->dst.xpos(),split->dst.ypos()) )
        {          
          if (!destobj) { //split
            destobj = zObject::create(srcobj);
            if (destobj)   {
              destobj->data.dwNum = split->dwNum;
              destobj->data.pos = split->dst;

              if (packs.addObject(destobj,false)) {
                srcobj->data.dwNum -= split->dwNum;

                //通知客户端
                Cmd::stSplitObjectPropertyUserCmd ret;
                bcopy(split,&ret,sizeof(ret),sizeof(ret));
                ret.qwNewThisID=destobj->data.qwThisID;
                sendCmdToMe(&ret,sizeof(ret));
                notify = true;
                zObject::logger(destobj->createid,destobj->data.qwThisID,destobj->data.strName,destobj->data.dwNum,destobj->data.dwNum,1,0,NULL,this->id,this->name,"拆分新增",destobj->base,destobj->data.kind,destobj->data.upgrade);
              }
              else {
                zObject::destroy(destobj);
                return true;
              }
              
            }
          } else if (destobj->data.dwObjectID == srcobj->data.dwObjectID && 
            srcobj->base->maxnum>1 &&
            srcobj->data.dwObjectID==destobj->data.dwObjectID &&
            srcobj->data.upgrade==destobj->data.upgrade ) {

            srcobj->data.dwNum -= split->dwNum;
            destobj->data.dwNum += split->dwNum;

            if (destobj->data.dwNum>destobj->base->maxnum)
            {
              destobj->data.dwNum=destobj->base->maxnum;
            }

            notify = true;
            
            //通知客户端
          
            Cmd::stSplitObjectPropertyUserCmd ret;
            bcopy(split,&ret,sizeof(ret),sizeof(ret));
            ret.qwNewThisID=destobj->data.qwThisID;
            sendCmdToMe(&ret,sizeof(ret));


          }
           else {
          }


          if (srcobj->data.dwNum==0)
          {
            zObject::logger(srcobj->createid,srcobj->data.qwThisID,srcobj->data.strName,srcobj->data.dwNum,destobj->data.dwNum,0,0,NULL,this->id,this->name,"拆分删除",srcobj->base,srcobj->data.kind,srcobj->data.upgrade);
            packs.removeObject(srcobj,false,true);
          }
          else
          {
            zObject::logger(srcobj->createid,srcobj->data.qwThisID,srcobj->data.strName,srcobj->data.dwNum,destobj->data.dwNum,0,0,NULL,this->id,this->name,"被拆分",srcobj->base,srcobj->data.kind,srcobj->data.upgrade);
          }

        }

        return true;
      }
      break;
#if 0
    case UNIONUSEROBJECT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stUnionObjectPropertyUserCmd *uobj=(Cmd::stUnionObjectPropertyUserCmd *)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(uobj->qwSrcThisID);
        zObject *destobj=packs.uom.getObjectByThisID(uobj->qwDstThisID);
        if (srcobj && destobj && srcobj->base->maxnum>1 &&
            srcobj->data.dwObjectID==destobj->data.dwObjectID &&
            srcobj->data.upgrade==destobj->data.upgrade /*&&
            srcobj->data.pos.dwLocation==Cmd::OBJECTCELLTYPE_MOUSE*/)
        {
          if (srcobj->data.dwNum+destobj->data.dwNum>srcobj->base->maxnum)
          {
            srcobj->data.dwNum=srcobj->data.dwNum+destobj->data.dwNum-srcobj->base->maxnum;
            destobj->data.dwNum=srcobj->base->maxnum;
          }
          else
          {
            destobj->data.dwNum+=srcobj->data.dwNum;
            srcobj->data.dwNum=0;
          }
          //交易处理
          if (destobj->data.pos.dwLocation==Cmd::OBJECTCELLTYPE_TRADE && tradeorder.hasBegin())
          {
            tradeorder.rollback();
            SceneUser *an=tradeorder.getAnother();
            if (an)
            {
              an->lock();
              an->tradeorder.rollback();
              Cmd::stRefCountObjectPropertyUserCmd ret;
              ret.qwThisID=destobj->data.qwThisID;
              ret.dwNum=destobj->data.dwNum;
              an->sendCmdToMe(&ret,sizeof(ret));
              an->unlock();
            }
          }

          //通知客户端
          Cmd::stRefCountObjectPropertyUserCmd ret;
          ret.qwThisID=destobj->data.qwThisID;
          ret.dwNum=destobj->data.dwNum;
          sendCmdToMe(&ret,sizeof(ret));
          if (srcobj->data.dwNum==0)
          {
            packs.rmObject(srcobj);
            Cmd::stRemoveObjectPropertyUserCmd rm;
            rm.qwThisID=srcobj->data.qwThisID;
            sendCmdToMe(&rm,sizeof(rm));
            SAFE_DELETE(srcobj);
          }
          else
          {
            ret.qwThisID=srcobj->data.qwThisID;
            ret.dwNum=srcobj->data.dwNum;
            sendCmdToMe(&ret,sizeof(ret));
          }
        }
        return true;
      }
      break;
#endif
    case USEUSEROBJECT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stUseObjectPropertyUserCmd *use=(Cmd::stUseObjectPropertyUserCmd *)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(use->qwThisID);
        if (srcobj && srcobj->data.pos.loc() ==Cmd::OBJECTCELLTYPE_COMMON)
        {
          useObject(srcobj, use->preUseUserID);
        }
        return true;
      }
      break;
	case SET_COWBOX_KEY_PARAMETER:
	{
		//fprintf(stderr,"用户使用钥匙\n");
		Cmd::stSetCowBoxKeyCmd *use = (Cmd::stSetCowBoxKeyCmd*)rev;
		zObject *srcobj=packs.uom.getObjectByThisID(use->qwThisID);


			//if(use->qwThisID)

			Xlogger->error("key id = %u\n",use->qwThisID);
			fprintf(stderr,"key id = %u\n",use->qwThisID);


			if(srcobj == NULL)
			{
				return false;
				Xlogger->error("%s用户在使用钥匙的时候包裹中没有钥匙\n", this->name);
			}

			zObject* ob;
			if(use->Key_id == 964)
			{
				//寻找包裹中是否有金箱
				
				if(!packs.main.getObjectByID(&ob,962))
				{
					ob = packs.uom.getObjectByID(962,0,true);
					if(NULL == ob)
					{
						//fprintf(stderr,"包裹中找不到金箱\n");
						return false;
					}
				}
				//
			}
			else
			{
				if(!packs.main.getObjectByID(&ob,961))
				{
					ob = packs.uom.getObjectByID(961,0,true);
					if(NULL == ob)
					{
						//fprintf(stderr,"包裹中找不到银箱\n");
						return false;
					}
				}
			}

            
			if(NULL == ob)
				return false;
	
			if(--srcobj->data.dwNum)
				{
					Cmd::stRefCountObjectPropertyUserCmd send;
					send.qwThisID=srcobj->data.qwThisID;
					send.dwNum=srcobj->data.dwNum;
					sendCmdToMe(&send,sizeof(send));
				}
				else
				{
					packs.removeObject(srcobj);
				}

				if(--ob->data.dwNum)
				{
					Cmd::stRefCountObjectPropertyUserCmd send;
					send.qwThisID=ob->data.qwThisID;
					send.dwNum=ob->data.dwNum;
					sendCmdToMe(&send,sizeof(send));
					//fprintf(stderr,"钥匙count=%d\n",send.dwNum);
					//return true;
				}
				else
				{
					packs.removeObject(ob);
				}

				//fprintf(stderr,"钥匙,宝盒删除\n");
				return true;
			} 
		break;

    case Cmd::SCROLL_MAP_PROPERTY_USERCMD_PARA:
      {
        Cmd::stScrollMapPropertyUserCmd * smp = (Cmd::stScrollMapPropertyUserCmd*)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(smp->qwThisID);
        if (srcobj && (srcobj->base->id==675 || srcobj->base->id==676) && srcobj->data.pos.loc()==Cmd::OBJECTCELLTYPE_COMMON)
        {
          strncpy(srcobj->data.maker,smp->mapname[0].strMapName,MAX_NAMESIZE);
          useObject(srcobj);
        }
        else if (srcobj && srcobj->data.pos.loc()==Cmd::OBJECTCELLTYPE_EQUIP&&srcobj->base->kind == ItemType_Amulet)
        {
          strncpy(srcobj->data.maker,smp->mapname[0].strMapName,MAX_NAMESIZE);
          useAmulet(srcobj);
        }
        return true;
      }
      break;
      //请求增值地宫列表
    case Cmd::REQUEST_INC_MAP_PROPERTY_USERCMD_PARA:
      {
        zObject *obj = this->packs.equip.getObjectByEquipPos(Cmd::EQUIPCELLTYPE_ADORN);
        if (obj && obj->base->kind == ItemType_Amulet)
        {
          char buf[1024];
          bzero(buf,sizeof(buf));
          Cmd::stScrollMapPropertyUserCmd *smp = (Cmd::stScrollMapPropertyUserCmd*)buf;
          smp->qwThisID = obj->data.qwThisID;
          constructInPlace(smp);
          smp->size = this->scene->getIncCity((const char*)smp->mapname);
          sendCmdToMe(smp,sizeof(Cmd::stScrollMapPropertyUserCmd) + MAX_NAMESIZE * smp->size);        
        }
        return true;
      }
      break;
    case PICKUPITEM_PROPERTY_USERCMD_PARA:
      {
		  Cmd::stPickUpItemPropertyUserCmd *pick=(Cmd::stPickUpItemPropertyUserCmd *)rev;

		  TeamManager * teamMan = SceneManager::getInstance().GetMapTeam(TeamThisID);

		  zPos p;
		  zSceneObject *ret = NULL;
		  p.x=pick->x;
		  p.y=pick->y;
		  ret = scene->getSceneObjectByPos(p);
		  if (ret)
		  {
			  //int ok = 0;
			  zObject *o=ret->getObject();
			  if (!o)
			  {
				  return false;
			  }
			  //无主物品或者在没有组队情况下的物品
			  if ((o->base->id!=673 || o->base->id!=674) && (!ret->getOwner() || ret->getOwner() == this->id || (teamMan && teamMan->IsOurTeam(ret->getOwner()))))
			  {
				  //bool bret = false;
				  if (o->base->id==673)//玄天符
				  {
					  if (guard)
					  {
						  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你正在运镖,保护好你的镖车!");
						  return true;
					  }
					  if (o->data.maker[0]=='\0')
					  {
						  zPos newPos;
						  if (!this->scene->backtoCityMap())
						  {
							  //随机重生区坐标
							  if (!this->scene->randzPosByZoneType(ZoneTypeDef::ZONE_RELIVE,newPos)) return true;
							  if (!this->goTo(newPos)) return true;
						  }
						  else
						  {
							  //在其它地图中寻找城市
							  this->scene->changeMap(this,false);
						  }
					  }
					  else
					  {
						  zPos newPos;
						  newPos.x=o->data.durpoint;
						  newPos.y=o->data.dursecond;


						  SceneManager::CountryMap_iter country_iter = SceneManager::getInstance().country_info.find(scene->getCountryID());
						  if (country_iter == SceneManager::getInstance().country_info.end()) {
							  //unknow country
							  return true;
						  }


						  std::ostringstream os;
						  os << "name=" << o->data.maker;
						  os << " pos=" << o->data.durpoint << "," << o->data.dursecond;
						  Gm::gomap(this,os.str().c_str());
					  }
					  return true;
				  }
				  else if (o->base->id==674)//轩辕符
				  {
					  if (ret->getOwner() == this->id)
					  {
						  if (guard)
						  {
							  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你正在运镖,保护好你的镖车!");
							  return true;
						  }
						  if (o->data.maker[0]=='\0')
						  {
							  zPos newPos;
							  if (!this->scene->backtoCityMap())
							  {
								  //随机重生区坐标
								  if (!this->scene->randzPosByZoneType(ZoneTypeDef::ZONE_RELIVE,newPos)) return true;
								  if (!this->goTo(newPos)) return true;
							  }
							  else
							  {
								  //在其它地图中寻找城市
								  this->scene->changeMap(this,false);
							  }
						  }
						  else
						  {
							  zPos newPos;
							  newPos.x=o->data.durpoint;
							  newPos.y=o->data.dursecond;


							  SceneManager::CountryMap_iter country_iter = SceneManager::getInstance().country_info.find(scene->getCountryID());
							  if (country_iter == SceneManager::getInstance().country_info.end()) {
								  //unknow country
								  return true;
							  }


							  std::ostringstream os;
							  os << "name=" << o->data.maker;
							  os << " pos=" << o->data.durpoint << "," << o->data.dursecond;
							  Gm::gomap(this,os.str().c_str());
						  }
					  }
					  return true;
				  }
			  }

			  if (!ret->getOwner() || ret->getOwner() == this->id ||(teamMan->IsOurTeam(ret->getOwner()) && (teamMan && teamMan->isNormalObj())))
			  {
				  Combination callback(this,o);
				  packs.main.execEvery(callback);
				  if (packs.equip.pack(EquipPack::L_PACK) && packs.equip.pack(EquipPack::L_PACK)->can_input()) packs.equip.pack(EquipPack::L_PACK)->execEvery(callback);
				  if (packs.equip.pack(EquipPack::R_PACK) && packs.equip.pack(EquipPack::R_PACK)->can_input()) packs.equip.pack(EquipPack::R_PACK)->execEvery(callback);

				  bool added = false;
				  if (o->data.dwNum) {

					  if (this->packs.uom.space(this) >= 1 && packs.addObject(o,true,AUTO_PACK)) {
						  //如果是双倍经验道具和荣誉道具需要绑定
						  if (o->base->kind == ItemType_DoubleExp || o->base->kind == ItemType_Honor || o->base->kind == ItemType_ClearProperty)
						  {
							  o->data.bind=1;
						  }
						  added = true;
						  Cmd::stAddObjectPropertyUserCmd status;
						  status.byActionType = Cmd::EQUIPACTION_OBTAIN;
						  bcopy(&o->data,&status.object,sizeof(t_Object),sizeof(status.object));
						  sendCmdToMe(&status,sizeof(status));
					  }
					  else
					  {
						  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你的包裹已满");
						  Cmd::stAddMapObjectMapScreenUserCmd status;
						  status.action = Cmd::OBJECTACTION_DROP;
						  status.data.dwMapObjectTempID = o->data.qwThisID;
						  status.data.dwObjectID = o->data.dwObjectID;
						  strncpy(status.data.pstrName,o->data.strName,MAX_NAMESIZE);
						  status.data.x = p.x;
						  status.data.y = p.y;
						  status.data.wdNumber = o->data.dwNum;
						  status.data.wdLevel = o->base->level;
						  status.data.upgrade = o->data.upgrade;
						  status.data.kind = o->data.kind;
						  scene->sendCmdToNine(ret->getPosI(),&status,sizeof(status),this->dupIndex);  
					  }
				  }

				  if (callback.num() || added) {
					  OnGet event(o->data.dwObjectID);
					  EventTable::instance().execute(*this,event);
					  zObject::logger(o->createid,o->data.qwThisID,o->data.strName,o->data.dwNum,o->data.dwNum,1,this->scene->id,this->scene->name,this->id,this->name,"拣东西",o->base,o->data.kind,o->data.upgrade);
					  if (ScriptQuest::get_instance().has(ScriptQuest::OBJ_GET,o->data.dwObjectID)) { 
						  char func_name[32];
						  sprintf(func_name,"%s_%d","get",o->data.dwObjectID);
						  execute_script_event(this,func_name,o);
					  }                
					  /*
					  Xlogger->debug("%s(%u)捡到%s(%u)在(%u,%u)",
					  name,id,o->name,o->id,ret->getPos().x,ret->getPos().y);
					  // */
				  }

				  if (added) {
					  ret->clear();
				  }
				  if (!o->data.dwNum || added) {
					  scene->removeObject(ret);

					  Cmd::stRemoveMapObjectMapScreenUserCmd re;
					  re.dwMapObjectTempID=ret->id;
					  scene->sendCmdToNine(getPosI(),&re,sizeof(re),this->dupIndex);

					  SAFE_DELETE(ret);
				  }

				  return true;
				  // }
			  }
			  else
			  {
				  zObject *o=ret->getObject();
				  if (o && o->base->id!=673 && o->base->id!=674)//轩辕符
				  {
					  Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"对不起,该物品不属于你");
				  }
			  }
		  }
	  }
	  break;

	  //sky 老的打造消息不在处理拉
    /*case FOUNDITEM_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().make(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::MAKE);
      }
      break;*/
    case UPGRADEITEM_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().upgrade(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::UPGRADE);
      }
      break;
    case COMPOSEITEM_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().compose(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::COMPOSE);
      }
      break;
    case COMPOSE_SOUL_STONE_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().compose_soul_stone(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::COMPOSE);
      }
      break;
    case HOLE_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().hole(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::HOLE);
      }
      break;
    case ENCHASEL_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().enchance(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::ENCHANCE);
      }
      break;
    case DECOMPOSE_PROPERTY_USERCMD_PARA:
      if (!RebuildObject::instance().decompose(*this,rev))
      {
        RebuildObject::instance().response(*this,1,Base::DECOMPOSE);
      }
      break;


    //更新用户快捷键  
    case Cmd::ACCELKEY_PROPERTY_USERCMD_PARA:
      {
        Cmd::stAccekKeyPropertyUserCmd *acc = (Cmd::stAccekKeyPropertyUserCmd *)rev;
        int len = sizeof(Cmd::stAccekKeyPropertyUserCmd) + acc->accelNum * sizeof(Cmd::stGameAccelKey);
        if (acc->accelNum > 0 && len < 1024)
        {
          memcpy(accelData,rev,len,sizeof(accelData),sizeof(accelData));
        }
        else
        {
          bzero(accelData,sizeof(accelData));
        }
        //Xlogger->debug("(%s,%ld)更新用户快捷键成功",this->name,this->tempid);
        return true;
      }
      break;

    //添加用户技能数据
    case ADDUSERSKILL_PROPERTY_USERCMD_PARA:
      {
        if (!addSkillData((Cmd::stAddUserSkillPropertyUserCmd *)rev))
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"不能再次学习已经学习到技能");
        }
        return true;
      }
      break;
    
    //删除用户技能
    case REMOVEUSERSKILL_PROPERTY_USERCMD_PARAMETER:
      {
        if (removeSkill((Cmd::stRemoveUserSkillPropertyUserCmd *)rev))
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"删除技能失败");
        }
        return true;
      }
      break;

    //技能升级  
    case ADDSKILLPOINT_PROPERTY_USERCMD:
      {
        if (!upgradeSkill(((Cmd::stAddSkillPointPropertyUserCmd *)rev)->dwSkillID))
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"不能升级该技能");
        }
        return true;
      }
      break;
    case SYSTEMSETTINGS_PROPERTY_USERCMD_PARA:
      {
		  Cmd::stSystemSettingsUserCmd *st = (Cmd::stSystemSettingsUserCmd *)rev;


		  //允许组队
		  if (isset_state(st->data.bySettings,Cmd::USER_SETTING_TEAM))
		  {
			  set_state(sysSetting,Cmd::USER_SETTING_TEAM);
			  setOpen(true);
		  }
		  else
		  {
			  clear_state(sysSetting,Cmd::USER_SETTING_TEAM);
			  setOpen(false);
		  }

		  bcopy(&st->data.bySettings[1],setting,sizeof(setting),sizeof(setting));
		  bcopy(st->data.dwChatColor,chatColor,sizeof(chatColor),sizeof(chatColor));


#ifdef _DEBUG
		  Xlogger->debug("收到系统设置消息:%x %x %x %x,%u %u %u %u %u %u %u %u",st->data.bySettings[0],st->data.bySettings[1],st->data.bySettings[2],st->data.bySettings[3],st->data.dwChatColor[0],st->data.dwChatColor[1],st->data.dwChatColor[2],st->data.dwChatColor[3],st->data.dwChatColor[4],st->data.dwChatColor[5],st->data.dwChatColor[6],st->data.dwChatColor[7]);
#endif

		  //通知session
		  Cmd::Session::t_sysSetting_SceneSession send;
		  bcopy(sysSetting,send.sysSetting,sizeof(send.sysSetting),sizeof(send.sysSetting));
		  strncpy((char *)send.name,name,MAX_NAMESIZE-1);
		  sessionClient->sendCmd(&send,sizeof(send));

		  //通知网关
		  Cmd::Scene::t_sysSetting_GateScene gate_send;
		  bcopy(sysSetting,gate_send.sysSetting,sizeof(gate_send.sysSetting),sizeof(gate_send.sysSetting));
		  gate_send.id=this->id;
		  this->gatetask->sendCmd(&gate_send,sizeof(gate_send));


		  return true;
	  }
	  break;
/*
    //分配五行点数
    case DISTRIBUTEUFIVEPOINT_PROPERTY_USERCMD_PARA:
      {
        Xlogger->debug("(%s,%ld)分配五行点数指令",this->name,this->tempid);
        Cmd::stDistributeFivePointPropertyUserCmd *dis = (Cmd::stDistributeFivePointPropertyUserCmd *)rev;
        if (IsJoin(dis->fiveType) && charbase.points > 0 || (charbase.five == dis->fiveType && charbase.points > 0))
        {
          charbase.fivevalue[dis->fiveType] ++;
          charstate.fivevalue[dis->fiveType] ++;
          int type = dis->fiveType;
        charstate.fivedefence[(type + 1) % 5] = 
          (WORD)sqrt(sqrt((charbase.fivevalue[type] * charbase.fivevalue[type] * charbase.fivevalue[type])));
          if (charbase.fivevalue[type] % 4 == 0)
          {
            type =(type + 3) % 5;
            if (charbase.fivevalue[type] > 0)
            {
              charbase.fivevalue[type] ++;
              charstate.fivevalue[type] ++;
              charstate.fivedefence[(type + 1) % 5] = 
                (WORD)sqrt(sqrt((charbase.fivevalue[type] * charbase.fivevalue[type] * charbase.fivevalue[type])));
              if (charbase.fivevalue[type] % 4 == 0)
              {
                type =(type + 3) % 5;
                charbase.fivevalue[type] ++;
                charstate.fivevalue[type] ++;
                charstate.fivedefence[(type + 1) % 5] = 
                  (WORD)sqrt(sqrt((charbase.fivevalue[type] * charbase.fivevalue[type] * charbase.fivevalue[type])));
              }
            }
          }
          charbase.points --;

          //装备改变攻击力预处理
          calPreValue();

          //刷新用户数据
          Cmd::stMainUserDataUserCmd  userinfo;
          full_t_MainUserData(userinfo.data);
          sendCmdToMe(&userinfo,sizeof(userinfo));
          break;
*/
    //分配属性点数
    case DISTRIBUTEUPOINT_PROPERTY_USERCMD_PARA:
      {
        if (charbase.points>0)
        {
          Cmd::stDistributePointPropertyUserCmd *dis = (Cmd::stDistributePointPropertyUserCmd *)rev;
          switch(dis->type)
          {
            case Cmd::PROPERTY_CON:  //体质
            case Cmd::PROPERTY_STR:  //体力
            case Cmd::PROPERTY_DEX:  //敏捷
            case Cmd::PROPERTY_INT:  //智力
            case Cmd::PROPERTY_MEN:  //精神
              {
                charbase.wdProperty[dis->type]++;
                charbase.points--;
                this->setupCharBase();
                //刷新用户数据
                Cmd::stMainUserDataUserCmd  userinfo;
                full_t_MainUserData(userinfo.data);
                sendCmdToMe(&userinfo,sizeof(userinfo));
              }
              break;
            default:
              {
              }
              break;
          }
        }
        return true;
      }
      break;
    case CLEARPOINT_PROPERTY_USERCMD_PARA:
      {
        Cmd::stClearPointPropertyUserCmd *cmd = (Cmd::stClearPointPropertyUserCmd*)rev;
        switch (cmd->dwItemID)
        {
          case 752:
            if (this->charbase.level<40)
            {
              if (this->reduceObjectNum(752,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
              return true;
            }
            break;
          case 760:
            if (this->charbase.level>=40)
            {
              if (this->reduceObjectNum(760,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
              return true;
            }
            break;
          case 756:
            if (this->charbase.level>=40)
            {
              if (this->reduceObjectNum(756,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
              return true;
            }
            break;
          default:
            {
              Xlogger->info("角色[%s]使用洗属性点功能失败",this->name);
              return true;
            }
            break;
        }
        charbase.points =charbase.points
            +charbase.wdProperty[0]
            +charbase.wdProperty[1]
            +charbase.wdProperty[2]
            +charbase.wdProperty[3]
            +charbase.wdProperty[4];
        charbase.wdProperty[0]=0;
        charbase.wdProperty[1]=0;
        charbase.wdProperty[2]=0;
        charbase.wdProperty[3]=0;
        charbase.wdProperty[4]=0;
        this->setupCharBase();
        //刷新用户数据
        Cmd::stMainUserDataUserCmd  userinfo;
        full_t_MainUserData(userinfo.data);
        sendCmdToMe(&userinfo,sizeof(userinfo));
        Xlogger->info("角色[%s]使用洗属性点功能成功",this->name);
        return true;
      }
      break;
    case CLEARPOINT_LIMIT_PROPERTY_USERCMD_PARA:
      {
        Cmd::stClearPointLimitPropertyUserCmd *cmd = (Cmd::stClearPointLimitPropertyUserCmd*)rev;
        zObject *srcobj=packs.uom.getObjectByThisID(cmd->qwThisID);
        if (srcobj && srcobj->data.pos.loc() ==Cmd::OBJECTCELLTYPE_COMMON)
        {
          if (srcobj->base->kind == ItemType_ClearProperty && srcobj->base->id == 755)
          {
            BYTE num = cmd->byProperty%5;
            if (charbase.wdProperty[num]>5)
            {
              charbase.points +=5;
              charbase.wdProperty[num]=charbase.wdProperty[num]-5;
            }
            else
            {
              charbase.points += charbase.wdProperty[num];
              charbase.wdProperty[num]=0;
            }
            this->setupCharBase();
            //刷新用户数据
            Cmd::stMainUserDataUserCmd  userinfo;
            full_t_MainUserData(userinfo.data);
            sendCmdToMe(&userinfo,sizeof(userinfo));

            zObject::logger(srcobj->createid,srcobj->data.qwThisID,srcobj->data.strName,srcobj->data.dwNum,srcobj->data.dwNum,0,this->id,this->name,0,NULL,"用洗5点属性宝石",NULL,0,0);
            Xlogger->info("角色[%s]使用洗5点属性功能成功",this->name);
            packs.removeObject(srcobj); //notify and delete
          }
        }
        return true;
      }
      break;
    case CLEARUSERSKILLPOINT_PROPERTY_USERCMD_PARAMETER:
      {
        Cmd::stClearUserSkillPointPropertyUserCmd *cmd = (Cmd::stClearUserSkillPointPropertyUserCmd*)rev;
        switch (cmd->dwItemID)
        {
          case 753:
            if (this->charbase.level<40)
            {
              if (this->reduceObjectNum(753,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
              return true;
            }
            break;
          case 761:
            if (this->charbase.level>=40)
            {
              if (this->reduceObjectNum(761,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
              return true;
            }
            break;
          case 757:
            if (this->charbase.level>=40)
            {
              if (this->reduceObjectNum(757,1)==-1)
              {
                Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
                return true;
              }
            }
            else
            {
              Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
              return true;
            }
            break;
          default:
            {
              Xlogger->info("角色[%s]使用洗技能点功能失败",this->name);
              return true;
            }
            break;
        }
        charbase.skillpoint = charbase.level;
        usm.clear();
        Cmd::stClearSkillUserCmd send;
        sendCmdToMe(&send,sizeof(send));
        skillValue.init();
        this->setupCharBase();
        //刷新用户数据
        Cmd::stMainUserDataUserCmd  userinfo;
        full_t_MainUserData(userinfo.data);
        sendCmdToMe(&userinfo,sizeof(userinfo));
        Xlogger->info("角色[%s]使用洗技能点功能成功",this->name);
        return true;
      }
      break;
    case BODYCOLOR_PROPERTY_USERCMD_PARA:
      {
        using namespace Cmd;
        stBodyColorPropertyUserCmd *bcp = (stBodyColorPropertyUserCmd*)rev;
        if ((bcp->dwBodyColorCustom != charbase.bodyColor) && packs.equip.canChangeColor())
        {
          DWORD cost = 1000;
/*
          zObject *gold=packs.getGold();          
          if (!gold)
          {
            Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
            return true;
          }

          if (cost > gold->data.dwNum)
          {
            Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
            return true;
          }
          gold->data.dwNum -= cost;
          if (gold->data.dwNum==0)
          {
            stRemoveObjectPropertyUserCmd rmgold;
            rmgold.qwThisID=gold->data.qwThisID;
            sendCmdToMe(&rmgold,sizeof(rmgold));
            packs.rmObject(gold);
            SAFE_DELETE(gold);
          }
          else
          {
            stRefCountObjectPropertyUserCmd setgold;
            setgold.qwThisID=gold->data.qwThisID;
            setgold.dwNum=gold->data.dwNum;
            sendCmdToMe(&setgold,sizeof(setgold));
          }
*/
          if (!packs.checkMoney(cost) || !packs.removeMoney(cost,"服装染色")) {
            Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
            return true;
          }
          Channel::sendMoney(this,Cmd::INFO_TYPE_GAME,cost,"服装染色成功,花费银子");
          if (packs.equip.equip(EquipPack::OTHERS3)  && ( packs.equip.equip(EquipPack::OTHERS3)->base->kind == ItemType_FashionBody || packs.equip.equip(EquipPack::OTHERS3)->base->kind == ItemType_HighFashionBody) )
          {
            packs.equip.equip(EquipPack::OTHERS3)->data.color = bcp->dwBodyColorCustom;
          }
          else if (packs.equip.equip(EquipPack::OTHERS2)  && ( packs.equip.equip(EquipPack::OTHERS2)->base->kind == ItemType_FashionBody || packs.equip.equip(EquipPack::OTHERS2)->base->kind == ItemType_HighFashionBody) )
          {
            packs.equip.equip(EquipPack::OTHERS2)->data.color = bcp->dwBodyColorCustom;
          }
          else if (packs.equip.equip(EquipPack::BODY)) 
          {
            packs.equip.equip(EquipPack::BODY)->data.color = bcp->dwBodyColorCustom;
          }
          else
          {
            charbase.bodyColor = bcp->dwBodyColorCustom;
          }
          //Cmd::stAddUserMapScreenUserCmd cmd;
          //full_t_MapUserData(cmd.data);
          //scene->sendCmdToNine(getPosI(),&cmd,sizeof(cmd),false);
          reSendMyMapData();
        }
        else
        {
          Xlogger->warn("用户(%u,%s,%u)更换不可更换颜色的衣服",id,name,tempid);
        }
        return true;
      }
      break;
    case FACE_PROPERTY_USERCMD_PARA:
      {
        using namespace Cmd;
        stFacePropertyUserCmd *fp = (stFacePropertyUserCmd*)rev;
        if (fp->dwFace == charbase.face)
        {
          return true;
        }
        DWORD cost=0;
        zHeadListB *base=headlistbm.get(fp->dwFace);
        if (base)
        {
          cost = base->cost;
        }
        else
        {
          return true;
        }
        if (!packs.checkMoney(cost) || !packs.removeMoney(cost,"更换头像")) {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
          return true;
        }
        
        charbase.face = fp->dwFace;
        Channel::sendMoney(this,Cmd::INFO_TYPE_GAME,cost,"头像更换成功,花费银子");
        //Cmd::stAddUserMapScreenUserCmd cmd;
        //full_t_MapUserData(cmd.data);
        //scene->sendCmdToNine(getPosI(),&cmd,sizeof(cmd),false);
        reSendMyMapData();
        return true;
      }
      break;
    case HAIR_PROPERTY_USERCMD_PARA:
      {
        using namespace Cmd;
        stHairPropertyUserCmd *hp = (stHairPropertyUserCmd*)rev;
        if (hp->dwHairColor == charbase.hair && hp->byHairType == getHairType())
        {
          return true;
        }
        DWORD cost = 0;
        int isChange = 0;
        if (hp->byHairType != getHairType())
        {
          zHairStyleB *base=hairstylebm.get(hp->byHairType);
          if (base)
          {
            cost = base->cost;
            isChange = 1;
          }
          /*
          switch(hp->byHairType)
          {
            case HairStype_1:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_2:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_3:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_4:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_5:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            case HairStype_6:
              {
                isChange = 1;
                cost = 2000;
              }
              break;
            default:
              break;
          }
          // */
        }
        if ((hp->dwHairColor & 0X00FFFFFF) != getHairColor())
        {
          zHairColourB *base=haircolourbm.get(hp->dwHairColor & 0X00FFFFFF);
          if (base)
          {
            /// 如果不是光头换发色才需要银子
            if (hp->byHairType != 1)
            {
              cost += base->cost;
            }
            isChange = 2;
          }
          /*
          switch(hp->dwHairColor)
          {
            case HairColor_black:
              {
                isChange = 2;
                cost += 1000;
              }
              break;
            case HairColor_drink:
              {
                isChange = 2;
                cost += 2000;
              }
              break;
            case HairColor_purple:
              {
                isChange = 2;
                cost += 3000;
              }
              break;
          }
          // */
        }
/*
        zObject *gold=packs.getGold();
        if (!gold)
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
          return true;
        }
        if (cost > gold->data.dwNum)
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
          return true;
        }
        gold->data.dwNum -= cost;
        if (gold->data.dwNum==0)
        {
          stRemoveObjectPropertyUserCmd rmgold;
          rmgold.qwThisID=gold->data.qwThisID;
          sendCmdToMe(&rmgold,sizeof(rmgold));
          packs.rmObject(gold);
          SAFE_DELETE(gold);
        }
        else
        {
          stRefCountObjectPropertyUserCmd setgold;
          setgold.qwThisID=gold->data.qwThisID;
          setgold.dwNum=gold->data.dwNum;
          sendCmdToMe(&setgold,sizeof(setgold));
        }
*/
        if (!packs.checkMoney(cost) || !packs.removeMoney(cost,"美发")) {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"对不起,您银子不够");
          return true;
        }
        
        if (isChange)
        {
          Channel::sendMoney(this,Cmd::INFO_TYPE_GAME,cost,"美发成功,花费银子");
        }
        else
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"所选服务雷同,请选择其他服务");
        }
        setHairType(hp->byHairType);
        setHairColor(hp->dwHairColor);
        //Cmd::stAddUserMapScreenUserCmd cmd;
        //full_t_MapUserData(cmd.data);
        //scene->sendCmdToNine(getPosI(),&cmd,sizeof(cmd),false);
        reSendMyMapData();
        return true;
      }
      break;
	case SELECT_PROPERTY_USERCMD_PARA:
		{
			using namespace Cmd;
			stSelectPropertyUserCmd * spu = (stSelectPropertyUserCmd*)rev;
			//Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"收到选择指令");
			if (spu->dwOldTempID)
			{
				if (spu->byOldType == MAPDATATYPE_USER)
				{
					SceneUser *pDel = SceneUserManager::getMe().getUserByTempID(spu->dwOldTempID);
					if (pDel)
					{
						//pDel->selected_lock.lock();
						pDel->selected.erase(this->tempid);
						//pDel->selected_lock.unlock();
					}
				}
				else
				{
					SceneNpc *pDel = SceneNpcManager::getMe().getNpcByTempID(spu->dwOldTempID);
					if (pDel)
					{
						//pDel->selected_lock.lock();
						pDel->selected.erase(this->tempid);
						//pDel->selected_lock.unlock();
					}
				}
			}
			//如果目标为-1则表示不再选中别的对象
			if (spu->dwTempID == (DWORD)-1)
			{
				break;
			}
			switch(spu->byType)
			{
			case MAPDATATYPE_NPC:
				{
					SceneNpc *pNpc = SceneNpcManager::getMe().getNpcByTempID(spu->dwTempID);
					if (pNpc)
					{
						//pNpc->selected_lock.lock();
						pNpc->selected.insert(SelectedSet_value_type(this->tempid));
						Cmd::stRTSelectedHpMpPropertyUserCmd ret;
						ret.byType = Cmd::MAPDATATYPE_NPC;
						ret.dwTempID = pNpc->tempid;//临时编号
						ret.dwHP = pNpc->hp;//当前血
						ret.dwMaxHp = pNpc->getMaxHP();//最大hp
						ret.dwMP = 0;//this->charbase.mp;//当前mp
						ret.dwMaxMp = 0;//this->charstate.maxmp;//最大mp
						//pNpc->selected_lock.unlock();
						this->sendCmdToMe(&ret,sizeof(ret));
						char Buf[200]; 
						bzero(Buf,sizeof(Buf));
						stSelectReturnStatesPropertyUserCmd *srs=(stSelectReturnStatesPropertyUserCmd*)Buf;
						constructInPlace(srs);
						srs->byType = MAPDATATYPE_NPC;
						srs->dwTempID = spu->dwTempID;
						pNpc->skillStatusM.getSelectStates(srs,sizeof(Buf));
						if (srs->size > 0)
						{
							this->sendCmdToMe(srs,sizeof(stSelectReturnStatesPropertyUserCmd) + 
								sizeof(srs->states[0]) * srs->size);
						}
					}
				}
				break;
			case MAPDATATYPE_USER:
				{
					using namespace Cmd;
					SceneUser *pUser = SceneUserManager::getMe().getUserByTempID(spu->dwTempID);
					if (pUser)
					{
						//Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"%s收到选择%s指令",this->name,pUser->name);
						//pUser->selected_lock.lock();
						pUser->selected.insert(SelectedSet_value_type(this->tempid));
						Cmd::stRTSelectedHpMpPropertyUserCmd ret;
						ret.byType = Cmd::MAPDATATYPE_USER;
						ret.dwTempID = pUser->tempid;//临时编号
						ret.dwHP = pUser->charbase.hp;//当前血
						ret.dwMaxHp = pUser->charstate.maxhp;//最大hp
						ret.dwMP = pUser->charbase.mp;//当前mp
						ret.dwMaxMp = pUser->charstate.maxmp;//最大mp
						//pUser->selected_lock.unlock();
						this->sendCmdToMe(&ret,sizeof(ret));
						char Buf[200]; 
						bzero(Buf,sizeof(Buf));
						stSelectReturnStatesPropertyUserCmd *srs=(stSelectReturnStatesPropertyUserCmd*)Buf;
						constructInPlace(srs);
						srs->byType = MAPDATATYPE_USER;
						srs->dwTempID = spu->dwTempID;
						pUser->skillStatusM.getSelectStates(srs,sizeof(Buf));
						if (srs->size > 0)
						{
							this->sendCmdToMe(srs,sizeof(stSelectReturnStatesPropertyUserCmd) + 
								sizeof(srs->states[0]) * srs->size);
						}
						//临时发送pk附加状态,等待以后策划修改^_^处理
						pUser->sendtoSelectedPkAdditionStateToUser(this);
						pUser->sendtoSelectedReliveWeakStateToUser(this);
						pUser->sendtoSelectedTrainStateToUser(this);
					}
				}
				break;
			default:
				break;
			}
		}
      break;
      //请求观察某个用户
    case SELECT_MAINUSER_PROPERTY_USERCMD_PARA:
      {
        using namespace Cmd;
        stSelectMainUserPropertyUserCmd *smu = (stSelectMainUserPropertyUserCmd*)rev;
        switch(smu->byType)
        {
          case MAPDATATYPE_USER:
            {
              SceneUser *pUser = SceneUserManager::getMe().getUserByTempID(smu->dwTempID);
              if (pUser)
              {
                if (!pUser->mask.is_masking())
                {
                  char Buf[sizeof(stSelectReturnMainUserPropertyUserCmd) + sizeof(EquipedObject) * 16];
                  bzero(Buf,sizeof(Buf));
                  stSelectReturnMainUserPropertyUserCmd *srm = (stSelectReturnMainUserPropertyUserCmd*)Buf;
                  constructInPlace(srm);
                  srm->dwTempID = pUser->tempid;
                  pUser->full_t_MainUserData(srm->mainuser_data);
                  pUser->full_t_MapUserData(srm->mapuser_data);
                
                  srm->dwSize = pUser->packs.equip.fullAllEquiped((char*)srm->object_data);
                  this->sendCmdToMe(srm,sizeof(stSelectReturnMainUserPropertyUserCmd) 
                      + sizeof(EquipedObject) * srm->dwSize);

                  if (pUser->horse.horse())
                  {
                      stSelectReturnHorsePropertyUserCmd send;
                      pUser->horse.full_HorseDataStruct(&send.data);
                      sendCmdToMe(&send,sizeof(send));
                  }
                }
                else
                {
                  Channel::sendSys(this,Cmd::INFO_TYPE_MSG,"他是蒙面人无法观察");
                }
              }
            }
            break;
          case MAPDATATYPE_NPC:
            {
            }
            break;
          default:
            break;
        }
      }
      break;
    case HONOR_TO_PKVALUE_PROPERTY_USERCMD_PARA:
      {
        short good = this->charbase.goodness & 0x0000FFFF;
        short old_good = good;
        DWORD old_honor = this->charbase.honor;
        if (good > 0 && good < (short)Cmd::GOODNESS_7 && this->charbase.honor > 0)
        {
          if (good <= (short)(this->charbase.honor / 5))
          {
            this->charbase.honor -= good * 5;
            good = 0;
          }
          else
          {
            good -= (short)(this->charbase.honor / 5);
            this->charbase.honor = this->charbase.honor % 5;
          }
          this->charbase.goodness = this->charbase.goodness & 0XFFFF0000 + good;
          Cmd::stMainUserDataUserCmd  userinfo;
          full_t_MainUserData(userinfo.data);
          sendCmdToMe(&userinfo,sizeof(userinfo));
          reSendMyMapData();
          zObject::logger(0,0,"荣誉值",this->charbase.honor,old_honor - this->charbase.honor,0,this->id,this->name,0,NULL,"洗PK值扣除荣誉值",NULL,0,0);
          return Channel::sendSys(this,Cmd::INFO_TYPE_GAME,"你用%u荣誉点缩短了%u分钟的罪恶时间",old_honor - this->charbase.honor,old_good - good);
        }
        return true;
      }
      break;
    case GO_TRAIN_PROPERTY_USERCMD_PARA:
      {
        if ((privatestore.step() != PrivateStore::NONE) || tradeorder.hasBegin())//正在交易
          return true;

        Cmd::stGoTrainPropertyUserCmd * cmd = (Cmd::stGoTrainPropertyUserCmd *)rev;

        char mname[MAX_NAMESIZE];
        bzero(mname,MAX_NAMESIZE);
        DWORD mid = 192+cmd->level;
        SceneManager::getInstance().buildMapName(6,mid,mname);
        zPos p;
        switch (cmd->level)
        {
          case 1:
            p = zPos(172,265);
            break;
          case 2:
            p = zPos(257,144);
            break;
          case 3:
            p = zPos(34,188);
            break;
          case 4:
            p = zPos(139,270);
            break;
          case 5:
            p = zPos(69,192);
            break;
          case 6:
            p = zPos(217,208);
            break;
          case 7:
            p = zPos(245,200);
            break;
          case 8:
            p = zPos(78,187);
            break;
          case 9:
            p = zPos(107,204);
            break;
          default:
            Xlogger->error("%s 进入修炼地图层数不对 level=%u",name,cmd->level);
            return true;
            break;
        }

        zObject * o = 0;
        if (!packs.main.getObjectByID(&o,798))
        {
          Channel::sendSys(this,Cmd::INFO_TYPE_FAIL,"你缺少一件必要的道具");
          return true;
        }

        packs.removeObject(o,true,true);
        charbase.trainTime = 86399;
        sendtoSelectedTrainState();

        Scene * s=SceneManager::getInstance().getSceneByName(mname);
        if (s)
        {
          if (changeMap(s,p))
            Xlogger->info("%s 进入练级地图 %s(%u,%u)",name,s->name,getPos().x,getPos().y);
          else
            Xlogger->info("%s 进入练级地图失败 %s(%u,%u)",name,s->name,p.x,p.y);
        }
        else
        {       
          Cmd::Session::t_changeScene_SceneSession cmd;
          cmd.id = id;
          cmd.temp_id = tempid;
          cmd.x = p.x;
          cmd.y = p.y;
          cmd.map_id = 0; 
          cmd.map_file[0] = '\0';
          strncpy((char *)cmd.map_name,mname,MAX_NAMESIZE);
          sessionClient->sendCmd(&cmd,sizeof(cmd));
        }
      }
      break;
    default:
      break;
  }
//  Xlogger->debug("SceneUser::doPropertyCmd\tparam:%d",rev->byParam);
  return false;
}