Example #1
0
bool CArhat::clearNPC()
{
    Cmd::Session::t_ClearGemNPC_SceneSession send;
    send.dwMapID = (this->dwCountryID<<16) + this->dwMapRealID;
    send.dwBossID = this->dwID;
    SceneSession *pScene = SceneSessionManager::getInstance()->getSceneByID(send.dwMapID);

    if (pScene)
    {
        pScene->sendCmd(&send,sizeof(send));
        return true;
    }

    return false;
}
Example #2
0
bool CArhat::refreshNPC()
{
    Cmd::Session::t_SummonGemNPC_SceneSession send;
    send.dwMapID = (this->dwCountryID<<16) + this->dwMapRealID;
    send.x = this->x;
    send.y = this->y;
    send.dwBossID = this->dwID;
    SceneSession *pScene = SceneSessionManager::getInstance()->getSceneByID(send.dwMapID);

    if (pScene)
    {
        pScene->sendCmd(&send,sizeof(send));
        this->dwHoldUserID = 0;
        this->byState = 0;

        if (this->dwID==1000)
        {
            SessionChannel::sendCountryInfo(Cmd::INFO_TYPE_GAME,
                                            this->dwCountryID,"降龙罗汉出现在 %s 地图 %d,%d 地点",
                                            pScene->name,
                                            this->x,this->y);
#ifdef _DEBUG
            Zebra::logger->debug("[护宝任务]: 降龙罗汉刷新地点: country:%d mapid:%d x:%d y:%d",
                                 this->dwCountryID,this->dwMapRealID,this->x,this->y);
#endif

        }
        else
        {
            SessionChannel::sendCountryInfo(Cmd::INFO_TYPE_GAME,
                                            this->dwCountryID,"伏虎罗汉出现在 %s 地图 %d,%d 地点",
                                            pScene->name,
                                            this->x,this->y);
#ifdef _DEBUG
            Zebra::logger->debug("[护宝任务]: 伏虎罗汉刷新地点: country:%d mapid:%d x:%d y:%d",
                                 this->dwCountryID,this->dwMapRealID,this->x,this->y);
#endif
        }

        return true;
    }
    else
    {
        Zebra::logger->error("[护宝]:未找到罗汉出生地图 %d,%d",this->dwCountryID,this->dwMapRealID);
    }

    return false;
}
Example #3
0
	void exec(CCountry * c)
	{
		if (rushID && cityID && c)
		{
			Cmd::Session::t_createRush_SceneSession cr;
			cr.rushID = rushID;
			cr.delay = delay;
			cr.countryID = c->dwID;

			SceneSession * ss = SceneSessionManager::getInstance()->getSceneByID((c->dwID<<16)+cityID);
			if (ss)
			{
				ss->sendCmd(&cr,sizeof(cr));
				Zebra::logger->warn("向 %s 发送怪物攻城消息",c->name);
			}
			else
				Zebra::logger->warn("向 %s 发送怪物攻城消息失败",c->name);
		}
	}
Example #4
0
/**
 * \brief 解析来自管理服务器的指令
 *
 * 这些指令是网关和管理服务器交互的指令<br>
 * 实现了虚函数<code>zSubNetService::msgParse_SuperService</code>
 *
 * \param pNullCmd 待解析的指令
 * \param nCmdLen 待解析的指令长度
 * \return 解析是否成功
 */
bool SessionService::msgParse_SuperService(const Cmd::t_NullCmd *pNullCmd,const DWORD nCmdLen)
{
  switch (pNullCmd->cmd)
  {
    case Cmd::Session::CMD_SCENE:
      {
        using namespace Cmd::Session;
        switch(pNullCmd->para)
        {                       
          case PARA_SCENE_FORBID_TALK:
            {
              t_forbidTalk_SceneSession * rev = (t_forbidTalk_SceneSession *)pNullCmd;
              UserSession *pUser = UserSessionManager::getInstance()->getUserSessionByName(rev->name);
              if (pUser)
                pUser->scene->sendCmd(rev,sizeof(t_forbidTalk_SceneSession));
              else
              {
                Zebra::logger->debug("处罚玩家时没找到玩家");
                break;
              }
            }
            break;
        }
      }
      break;
    case Cmd::Rolechange::CMD_BATTLE:
      {
	  using namespace Cmd::Rolechange;
	  switch(pNullCmd->para)
	  {
	      case PARA_CHECK_ZONE_STATE:
		  {
		      t_checkZoneState* rev = (t_checkZoneState*)pNullCmd;
		      if(rev->isForce == 2)
		      {
			  UserSession *u = UserSessionManager::getInstance()->getUserByID(rev->charid);
			  t_retCheckZoneState send;
			  send.charid = rev->charid;
			  send.accid = rev->accid;
			  if(u)   //玩家在线
			  {
			      send.type = 5;
			  }
			  else
			  {
			      send.type =  6;
			  }
			  SessionChannel::sendCmdToZone(rev->fromGameID, &send, sizeof(send));
		      }
		      return true;
		  }
		  break;
	      case PARA_RET_CHECK_VALID:
		  {
		      t_Ret_Check_Valid* rev = (t_Ret_Check_Valid*)pNullCmd;
		      UserSession *u = UserSessionManager::getInstance()->getUserByID(rev->userid);
		      if(!u)
			  return true;
		      if(rev->state == BATTLE_SUCCESS)
		      {
			  if(u && u->scene)
			  {
			      Cmd::Session::t_notifyEnterZone_SceneSession send;
			      send.toGameZone = rev->fromGameZone;
			      send.userid = rev->userid;
			      send.type = rev->type;
			      u->scene->sendCmd(&send, sizeof(send));
			      Zebra::logger->info("[转区] 验证成功,发送t_notifyEnterZone_SceneSession到场景 send.toGameZone:%u send.userid:%u send.type:%u",
				      send.toGameZone.zone, send.userid, send.type);
			      return true;
			  }
			  else
			  {
			      Zebra::logger->info("[转区] 验证成功,发送t_notifyEnterZone_SceneSession到场景 时 发现玩家不在线了");
			      return true;
			  }
		      }
		      else
		      {//这里需要通知客户端显示
			  if(rev->state == BATTLE_CLOSE)
			  {
			      Zebra::logger->error("[转区] 验证失败, 目标区未开放");
			  }
			  else if(rev->state == BATTLE_INVALID)
			  {
			      Zebra::logger->error("[转区] 验证失败, 不是战区不能进入");
			  }
			  else if(rev->state == BATTLE_USER_REPEAT)
			  {
			      Zebra::logger->error("[转区] 验证失败, 目标区已经存在该账号的角色");
			  }
			  else if(rev->state == BATTLE_LEVEL_INVALID)
			  {
			      Zebra::logger->error("[转区] 验证失败, 角色等级不符,不能进入");
			  }
			  else if(rev->state == BATTLE_VERSION_INVALID)
			  {
			      Zebra::logger->error("[转区] 验证失败, 目标区和源区版本不符,不能进入");
			  }
			  else if(rev->state == ZONE_CLOSE)
			  {
			      Zebra::logger->error("[转区] 验证失败, 该区已关闭");
			  }
			  else if(rev->state == ZONE_SORT_INVALID)
			  {
			      Zebra::logger->error("[转区] 验证失败, 角色等级过高,不允许进入该区");
			  }
			  else
			  {
			      Zebra::logger->error("[转区] 验证失败, 收到的状态是:%u 状态未定义",rev->state);
			  }
		      }
		      return true;
		  }
		  break;
	      case PARA_RTN_ZONE_LIST:
		  {}
		  break;

	    default:
		break;
	  }
      }
      break;
    case Cmd::GmTool::CMD_GMTOOL:
      {
        using namespace Cmd::GmTool;
        switch(pNullCmd->para)
        {
          case PARA_CHAT_GMTOOL:
            {
              t_Chat_GmTool * rev = (t_Chat_GmTool *)pNullCmd;
              UserSession *pUser = UserSessionManager::getInstance()->getUserSessionByName(rev->userName);
              if (!pUser) return true;

              SessionChannel::sendPrivate(pUser,rev->gmName,rev->content);
            }
            break;
          case PARA_MSG_REPLY_GMTOOL:
            {
              t_Msg_Reply_GmTool * rev = (t_Msg_Reply_GmTool *)pNullCmd;
              char buf[255];
              snprintf(buf,sizeof(buf),"GM对您的问题做出了回复:\n\t%s\n原件:\n\t%s",rev->reply,rev->content);
              //MailService::getMe().sendTextMail(rev->gmName,0,rev->userName,rev->userID,buf,(DWORD)-1,Cmd::Session::MAIL_TYPE_SYS);
              UserSession *pUser = UserSessionManager::getInstance()->getUserSessionByName(rev->userName);
              if (pUser)
                pUser->sendSysChat(Cmd::INFO_TYPE_GAME,"GM对您提出的问题做了回复,请及时查收邮件");
              return true;
            }
            break;
          case PARA_BROADCAST_GMTOOL:
            {
              t_Broadcast_GmTool * rev = (t_Broadcast_GmTool *)pNullCmd;
              Zebra::logger->debug("[GM工具]收到公告 %s:%s id=%u time=%u country=%u mapID=%u",rev->GM,rev->content,rev->id,rev->time,rev->country,rev->mapID);
              if (rev->id>5) return false;
              //置空取消公告
              if (0==strcmp(rev->content,""))
              {
                SessionService::wMsg.erase(rev->id);
                return true;
              }
              if (rev->time)
                if (rev->country)
                  if (rev->mapID)
                    {
                      SceneSession *scene = SceneSessionManager::getInstance()
                        ->getSceneByID((rev->country<<16)+rev->mapID);
                      if (scene)
                      {
                        Cmd::Session::t_broadcastScene_SceneSession send;
                        strncpy(send.info,rev->content,MAX_CHATINFO);
                        strncpy(send.GM,rev->GM,MAX_NAMESIZE);
                        send.mapID = scene->id;
                        scene->sendCmd(&send,sizeof(send));
#ifdef _DEBUG
                        Zebra::logger->debug("GM公告:%s mapID=%u mapName=%s",send.info,send.mapID,scene->name);
#endif
                      }
#ifdef _DEBUG
                      else
                        Zebra::logger->debug("GM公告:%s mapID=%u 没找到地图",rev->content,(rev->country<<16)+rev->mapID);
#endif
                    }
                  else
                    SessionChannel::sendCountryInfo(Cmd::INFO_TYPE_SCROLL,rev->country,rev->content);
                else
                  SessionChannel::sendAllInfo(Cmd::INFO_TYPE_SCROLL,rev->content);
              else
              {
                SessionService::wMsg.erase(rev->id);
                return true;
              }

              if (rev->time-1 && rev->id<=5)
              {
                strncpy(SessionService::wMsg[rev->id].msg,rev->content,256);
                strncpy(SessionService::wMsg[rev->id].GM,rev->GM,MAX_NAMESIZE);
                SessionService::wMsg[rev->id].time = rev->time-1;
                SessionService::wMsg[rev->id].interval = rev->interval;
                SessionService::wMsg[rev->id].count = rev->interval;
                SessionService::wMsg[rev->id].country = rev->country;
                SessionService::wMsg[rev->id].mapID = rev->mapID;
              }
              return true;
            }
            break;
        }
      }
      break;
    case Cmd::Super::CMD_COUNTRYONLINE:
      switch(pNullCmd->para)
      {
        case Cmd::Super::PARA_REQUEST_COUNTRYONLINE:
          {
            Cmd::Super::t_Request_CountryOnline *ptCmd = (Cmd::Super::t_Request_CountryOnline *)pNullCmd;
            BYTE pBuffer[zSocket::MAX_DATASIZE];
            Cmd::Super::t_CountryOnline *cmd = (Cmd::Super::t_CountryOnline *)pBuffer;
            constructInPlace(cmd);

            cmd->rTimestamp = ptCmd->rTimestamp;
            cmd->infoTempID = ptCmd->infoTempID;
            std::vector<std::pair<DWORD,DWORD> >  cti;
            UserSession::getCountryUser(cti);
            std::vector<std::pair<DWORD,DWORD> >::const_iterator it;
            for(it = cti.begin(); it != cti.end(); ++it)
            {
              if (cmd->OnlineNum < 50)
              {
                cmd->CountryOnline[cmd->OnlineNum].country = (*it).first;
                cmd->CountryOnline[cmd->OnlineNum].num = (*it).second;
                cmd->OnlineNum++;
              }
              else
                break;
            }

            return sendCmdToSuperServer(cmd,sizeof(Cmd::Super::t_CountryOnline) + cmd->OnlineNum * sizeof(Cmd::Super::t_CountryOnline::Online));
          }
          break;
      }
      break;
    case Cmd::Super::CMD_SESSION:
      {
	  switch(pNullCmd->para)
	  {
	      case Cmd::Super::PARA_USER_ONLINE_BROADCAST:
		  {
		      Cmd::Super::stUserOnlineBroadCast *rev = (Cmd::Super::stUserOnlineBroadCast *)pNullCmd;

		      Zebra::logger->debug("[广播消息]收到来自(%u)区的玩家:%s消息", rev->dwZoneID, rev->name);
		      return true;
		  }
		  break;
	      default:
		  break;
	  }
      }
      break;
  }

  Zebra::logger->error("SessionService::msgParse_SuperService(%u,%u,%u)",pNullCmd->cmd,pNullCmd->para,nCmdLen);
  return false;
}
Example #5
0
void SessionTimeTick::run()
{
	//int rush = 0;
	while(!isFinal())
	{
		zThread::msleep(50);

		//获取当前时间
		currentTime.now();

		recordClient->doCmd();
		SessionTaskManager::getInstance().execEvery();
		if (_five_sec(currentTime))
		{
		    HeroCardManager::getMe().timer();	//��������ƥ��
		}
#if 0
		if (_five_sec(currentTime)) {
			CDareM::getMe().timer();
			CNpcDareM::getMe().timer();
			CCityM::getMe().timer();
			CArmyM::getMe().timer();
		}

		if (_one_sec(currentTime))
		{
			CQuizM::getMe().timer();
			CUnionM::getMe().timer();
			CAllyM::getMe().timer();
			CArenaManager::getInstance().Arena_timer();
		}

		if (_ten_min(currentTime))
		{
			AuctionService::getMe().checkDB();
		}
#endif
		// [ranqd Add] Session每五分钟同步一次服务器在线状态
		if( _five_min(currentTime) )
		{
			UserSessionManager::getInstance()->notifyOnlineToGate();
		}

		if (_one_min(currentTime))
		{
			SessionService::getInstance().checkShutdown();
#if 0
			//SessionService::getInstance().checkGumu();
			CCountryM::getMe().timer();
			//CGemM::getMe().timer();
			CartoonPetService::getMe().writeAllToDB();
			EmperorForbid::getMe().timer();
#endif
			//定时动作
			time_t timValue = time(NULL);
			struct tm tmValue;
			zRTime::getLocalTime(tmValue,timValue);
			SessionService::getInstance().checkCountry(tmValue);

			//GM公告
			for (int i=0; i<=5; i++)
			{
				if (SessionService::wMsg[i].time)
				{
					if (SessionService::wMsg[i].count)
						SessionService::wMsg[i].count--;
					else
					{
						if (SessionService::wMsg[i].country)
							if (SessionService::wMsg[i].mapID)//区域公告
							{
								SceneSession *scene = SceneSessionManager::getInstance()
									->getSceneByID((SessionService::wMsg[i].country<<16)+SessionService::wMsg[i].mapID);
								if (scene)
								{
									Cmd::Session::t_broadcastScene_SceneSession send;
									strncpy(send.info,SessionService::wMsg[i].msg,MAX_CHATINFO);
									strncpy(send.GM,SessionService::wMsg[i].GM,MAX_NAMESIZE);
									send.mapID = (SessionService::wMsg[i].country<<16)+SessionService::wMsg[i].mapID;
									scene->sendCmd(&send,sizeof(send));
#ifdef _DEBUG
									Zebra::logger->debug("GM公告:%s:%s mapID=%u",send.GM,send.info,send.mapID);
#endif
								}
							}
							else//国家公告
								SessionChannel::sendCountryInfo(Cmd::INFO_TYPE_SCROLL,SessionService::wMsg[i].country,SessionService::wMsg[i].msg);
						else//世界公告
							SessionChannel::sendAllInfo(Cmd::INFO_TYPE_SCROLL,SessionService::wMsg[i].msg);

						SessionService::wMsg[i].count = SessionService::wMsg[i].interval;
						SessionService::wMsg[i].time--;
					}
				}
				if (0==SessionService::wMsg[i].time)
					SessionService::wMsg.erase(i);
			}
		}
#if 0
		if (_one_hour(currentTime))
		{
			MailService::getMe().checkDB();
			CVoteM::getMe().timer();
			CCountryM::getMe().timerPerHour();
			CCountryM::getMe().save();
		}
#endif
	}
}