//@brief [MsgType:0202]移动 void MapSvc::ProcessMapMove(Session& session,Packet& packet) { UInt32 RetCode = 0; DataBuffer serbuffer(1024); int iRet = 0; UInt32 RoleID = packet.RoleID; ArchvRoute art; //序列化类 Serializer s(packet.GetBuffer()); s>>art; if( s.GetErrorCode()!= 0 ) { LOG(LOG_ERROR,__FILE__,__LINE__,"serial error" ); return; } DEBUG_PRINTF1( " ProcessMapMove roleID[%d]\n", RoleID ); //业务处理 iRet = _mainSvc->GetCoreData()->ProcessRoleMove( RoleID, art); if(iRet) { LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessRoleMove error" ); return; } return; }
//客户端错误应答 //@param session 连接对象 //@param packet 请求包 //@param RetCode 返回errorCode 值 void ShopSvc::ClientErrorAck(Session& session, Packet& packet, UInt32 RetCode) { //组应答数据 DataBuffer serbuffer(1024); Packet p(&serbuffer); Serializer s(&serbuffer); serbuffer.Reset(); p.CopyHeader(packet); p.Direction = DIRECT_C_S_RESP; p.PackHeader(); s<<RetCode; p.UpdatePacketLength(); //发送应答数据 if( session.Send(&serbuffer) ) { LOG(LOG_ERROR,__FILE__,__LINE__,"session.Send error "); } DEBUG_PRINTF1( "C_S ack pkg ----- MsgType[%d] \n", packet.MsgType ); DEBUG_SHOWHEX( serbuffer.GetReadPtr(), serbuffer.GetDataSize(), 0, __FILE__, __LINE__ ); }
void MapSvc::OnProcessPacket(Session& session,Packet& packet) { DEBUG_PRINTF1( "C_S req pkg-------MsgType[%d] \n", packet.MsgType ); DEBUG_SHOWHEX( packet.GetBuffer()->GetReadPtr()-PACKET_HEADER_LENGTH, packet.GetBuffer()->GetDataSize()+PACKET_HEADER_LENGTH, 0, __FILE__, __LINE__ ); switch(packet.MsgType) { case 201: ProcessEnterMap(session,packet); break; case 202: ProcessMapMove(session,packet); break; case 203: ProcessTeleportByRune(session,packet); break; default: ClientErrorAck(session,packet,ERR_SYSTEM_PARAM); LOG(LOG_ERROR,__FILE__,__LINE__,"MsgType[%d] not found",packet.MsgType); break; } }
APIRET EXPENTRY FS_FILEIO ( struct sffsi *psffsi, struct sffsd *psffsd, PCHAR pCmdList, /* not actually PCHAR */ USHORT cbCmdList, PUCHAR poError, USHORT IOflag ) { int rc; UtilEnterRamfs(); DEBUG_PRINTF1 ("FS_FILEIO? sfn=%d", psffsi->sfi_selfsfn); rc = ERROR_NOT_SUPPORTED; DEBUG_PRINTF1 (" => %d\r\n", rc); UtilExitRamfs(); return rc; }
void TBackupList::CleanupL() /* * This function restore the saved entries to the entries in the phone * */ { CMobilePhoneSmspList* restoreSmspList = CMobilePhoneSmspList::NewL(); CleanupStack::PushL(restoreSmspList); TExtEtelRequestStatus storeSmspListStatus(iSmsMessaging, EMobileSmsMessagingStoreSmspList); CleanupStack::PushL(storeSmspListStatus); for(int j=0; j<iListCount;j++) { RMobileSmsMessaging::TMobileSmspEntryV1 smspEntry= iEntryArray[j]; restoreSmspList->AddEntryL(smspEntry); } iSmsMessaging.StoreSmspListL(storeSmspListStatus,restoreSmspList); if(iTestStep.WaitForRequestWithTimeOut(storeSmspListStatus, ETimeMedium)==KErrNone) { if (storeSmspListStatus.Int()!= KErrNone) { DEBUG_PRINTF1(_L("Error- During CleanupStack RMobileSmsMessaging::StoreSmspListL returned with an error")); } } else { DEBUG_PRINTF1(_L("Error- During CleanupStack RMobileSmsMessaging::StoreSmspListL timed out")); } // Pop: // restoreSmspList // storeSmspListStatus CleanupStack::PopAndDestroy(2,restoreSmspList); }
APIRET EXPENTRY FS_COMMIT ( USHORT type, USHORT IOflag, struct sffsi *psffsi, struct sffsd *psffsd ) { int rc; UtilEnterRamfs(); DEBUG_PRINTF2 ("FS_COMMIT? sfn=%d, type=%d", psffsi->sfi_selfsfn, type); rc = NO_ERROR; DEBUG_PRINTF1 (" => %d\r\n", rc); UtilExitRamfs(); return rc; }
APIRET EXPENTRY FS_FILEINFO ( USHORT flag, struct sffsi *psffsi, struct sffsd *psffsd, USHORT level, PCHAR pData, USHORT cbData, USHORT IOflag ) /* not used */ { int rc; POPENFILE pOpenfile; DIRENTRY Entry; UtilEnterRamfs(); DEBUG_PRINTF3 ("FS_FILEINFO sfn=%d, flag=%d, level=%d", psffsi->sfi_selfsfn, flag, level); pOpenfile = psffsd->pOpenfile; if (pOpenfile == NULL || pOpenfile->flatEntry == NULL) { /* Volume already detached */ rc = ERROR_FILE_NOT_FOUND; goto end; } VMRead (&Entry, pOpenfile->flatEntry, sizeof(Entry)-CCHMAXPATHCOMP); if (flag == 0) { /* retrieve information */ rc = InfoQuery (pData, cbData, level, &Entry); } else { /* set information */ rc = InfoSet (pData, cbData, level, &Entry, psffsi); if (rc == NO_ERROR) VMWrite (pOpenfile->flatEntry, &Entry, sizeof(Entry)-CCHMAXPATHCOMP); } end: DEBUG_PRINTF1 (" => %d\r\n", rc); UtilExitRamfs(); return rc; }
void PKSvc::OnProcessPacket(Session& session,Packet& packet) { DEBUG_PRINTF1( "C_S req pkg-------MsgType[%d] \n", packet.MsgType ); DEBUG_SHOWHEX( packet.GetBuffer()->GetReadPtr()-PACKET_HEADER_LENGTH, packet.GetBuffer()->GetDataSize()+PACKET_HEADER_LENGTH, 0, __FILE__, __LINE__ ); switch(packet.MsgType) { case 401: //请求PK ProcessPKReq(session,packet); break; default: ClientErrorAck(session,packet,ERR_SYSTEM_PARAM); LOG(LOG_ERROR,__FILE__,__LINE__,"MsgType[%d] not found",packet.MsgType); break; } }
int main(int argc,char* argv[]) { if (argc < 2) { printf ("usage: Avatar config_file\n"); return -1; } char szFileName[256] = {0}; strncpy (szFileName ,argv[1], sizeof (szFileName)-1 ); if(access (szFileName, F_OK) != 0) { DEBUG_PRINTF1("ini file [%s] not found !!!!!!!!!", szFileName ); return -1; } if(Daemon<GWProxy<MainSvc> >::Run(szFileName)) LOG(LOG_ERROR,__FILE__,__LINE__,"daemon run error!!" ); return 0; }
//数据包信息 void OffLineUpdateSvc::OnProcessPacket(Session& session,Packet& packet) { DEBUG_PRINTF1( "C_S req pkg-------MsgType[%d] \n", packet.MsgType ); DEBUG_SHOWHEX( packet.GetBuffer()->GetReadPtr()-PACKET_HEADER_LENGTH, packet.GetBuffer()->GetDataSize()+PACKET_HEADER_LENGTH, 0, __FILE__, __LINE__ ); switch(packet.MsgType) { case 1601: //[MsgType:1601]升级数据查询 ProcessUpdateDataQuery(session, packet); break; case 1602: //[MsgType:1602]开始修炼升级 ProcessBeginUpdate(session, packet); break; case 1603: //[MsgType:1603]金币加速挂机 ProcessSpeedupUpdate(session, packet); break; case 1604: //[MsgType:1604]停止修炼升级 ProcessStopUpdate(session, packet); break; case 1605: //[MsgType:1605] 剩余挂机的时间 ProcessLeftUpdateHour(session, packet); break; case 1699: //[MsgType:1699]前台触发扣费 ProcessLostBilling(session, packet); break; default: ClientErrorAck(session,packet,ERR_SYSTEM_PARAM); LOG(LOG_ERROR,__FILE__,__LINE__,"MsgType[%d] not found",packet.MsgType); break; } }
TVerdict CCTSYIntegrationTestSMSPStore0005::doTestStepL() /** * @SYMTestCaseID BA-CTSY-INT-SMSP-0005 * @SYMFssID BA/CTSY/SMSP-0005 * @SYMTestCaseDesc Cancel writing SMSP list entries. * @SYMTestPriority High * @SYMTestActions * @SYMTestExpectedResults Pass - Request is cancelled. * @SYMTestType CIT * @SYMTestCaseDependencies live/automatic * * Reason for test: Verify request is cancelled. * * @return - TVerdict code */ { // // SET UP // RMobilePhone& phone = iEtelSessionMgr.GetPhoneL(KMainServer, KMainPhone); // Get the RMobileSmsMessaging subsession RMobileSmsMessaging& smsMessaging = iEtelSessionMgr.GetSmsMessagingL(KMainServer,KMainPhone,KMainSmsMessaging); // Ensure RMobileSmsMessaging::GetCaps returns aCaps.iSmsControl caps in set of KCapsSetSmspList | KCapsGetSmspList RMobileSmsMessaging::TMobileSmsCapsV1 smsCaps; RMobileSmsMessaging::TMobileSmsCapsV1Pckg smsCapsPckg(smsCaps); CHECK_EQUALS_L(smsMessaging.GetCaps(smsCapsPckg),KErrNone, _L("RMobileSmsMessaging::GetCaps returned returned with an error")); TUint32 expectedCaps= RMobileSmsMessaging::KCapsSetSmspList | RMobileSmsMessaging::KCapsGetSmspList; CHECK_BITS_SET_L(smsCaps.iSmsControl, expectedCaps, KNoUnwantedBits, _L("RMobileSmsMessaging::GetCaps returned with unexpected caps")); // Take the backup of SMSP list TInt listCountAtStart; TBackupList backup(*this,smsMessaging); CHECK_TRUE_L(backup.BackupL(listCountAtStart), _L("TBackupList::Backup Could not backup")); CleanupStack::PushL (backup); // // SET UP END // StartTest(); // // TEST START // // Create a CMobilePhoneSmspList with CMobilePhoneSmspList::NewL CMobilePhoneSmspList* smspList = CMobilePhoneSmspList::NewL(); CleanupStack::PushL(smspList); // Find out the network RMobilePhone::TMobilePhoneNetworkInfoV1 info; RMobilePhone::TMobilePhoneNetworkInfoV1Pckg infopckg(info); TExtEtelRequestStatus getNetworkStatus (phone,EMobilePhoneGetCurrentNetwork); CleanupStack::PushL(getNetworkStatus); phone.GetCurrentNetwork(getNetworkStatus, infopckg); ASSERT_EQUALS(WaitForRequestWithTimeOut(getNetworkStatus, ETimeMedium), KErrNone, _L("MobilePhone::GetCurrentNetwork timed out")) ASSERT_EQUALS(getNetworkStatus.Int(), KErrNone, _L("MobilePhone::GetCurrentNetwork returned an error")) // Create a RMobileSmsMessaging::TMobileSmspEntryV1 entry with the following parameters: RMobileSmsMessaging::TMobileSmspEntryV1 smspEntry; smspEntry.iText = _L("ABCD"); smspEntry.iValidParams = RMobileSmsMessaging::KDestinationIncluded | RMobileSmsMessaging::KSCAIncluded | RMobileSmsMessaging::KProtocolIdIncluded | RMobileSmsMessaging::KDcsIncluded | RMobileSmsMessaging::KValidityPeriodIncluded; smspEntry.iDestination.iTelNumber = _L("1234567890"); smspEntry.iDestination.iNumberPlan = RMobilePhone::EIsdnNumberPlan; smspEntry.iDestination.iTypeOfNumber = RMobilePhone::EInternationalNumber; smspEntry.iValidityPeriod = 0; smspEntry.iServiceCentre.iTelNumber = _L("1234567890"); smspEntry.iServiceCentre.iNumberPlan = RMobilePhone::EIsdnNumberPlan; smspEntry.iServiceCentre.iTypeOfNumber = RMobilePhone::EInternationalNumber; smspEntry.iProtocolId = 2; smspEntry.iDcs = 4; smspEntry.iIndex = 1; // Create another RMobileSmsMessaging::TMobileSmspEntryV1 entry with the following parameters: RMobileSmsMessaging::TMobileSmspEntryV1 smspEntry2; smspEntry2.iValidParams = RMobileSmsMessaging::KSCAIncluded; smspEntry2.iServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; smspEntry2.iServiceCentre.iNumberPlan=RMobilePhone:: EIsdnNumberPlan; smspEntry2.iServiceCentre.iTelNumber=_L("441632960000"); smspEntry2.iIndex = 2; // Create another RMobileSmsMessaging::TMobileSmspEntryV1 entry with the following parameters: RMobileSmsMessaging::TMobileSmspEntryV1 smspEntry3; smspEntry3.iValidParams = RMobileSmsMessaging::KSCAIncluded; smspEntry3.iServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; smspEntry3.iServiceCentre.iNumberPlan=RMobilePhone:: EIsdnNumberPlan; smspEntry3.iServiceCentre.iTelNumber=_L("441632960000"); smspEntry3.iIndex = 3; if(info.iShortName.Find(_L("O2")) != KErrNotFound) //O2 { DEBUG_PRINTF1(_L("O2 can have three entries in the SMSP list")); // Add the entry to the CMobilePhoneSmspList list with CMobilePhoneSmspList::AddEntryL smspList->AddEntryL(smspEntry); smspList->AddEntryL(smspEntry2); smspList->AddEntryL(smspEntry3); } else { smspList->AddEntryL(smspEntry); } // Store the empty SMSP list with RMobileSmsMessaging::StoreSmspListL TExtEtelRequestStatus storeSmspListStatus(smsMessaging, EMobileSmsMessagingStoreSmspList); CleanupStack::PushL(storeSmspListStatus); smsMessaging.StoreSmspListL(storeSmspListStatus,smspList); // Cancel request immediately with RTelSubSessionBase::CancelAsyncRequest(EMobileSmsMessagingStoreSmspList) smsMessaging.CancelAsyncRequest(EMobileSmsMessagingStoreSmspList); // Check store request completes with KErrCancel or KErrNone ASSERT_EQUALS(WaitForRequestWithTimeOut(storeSmspListStatus, ETimeShort),KErrNone, _L("RMobileSmsMessaging::StoreSmspListL timed out")); ASSERT_TRUE(storeSmspListStatus.Int() == KErrCancel || storeSmspListStatus.Int() == KErrNone, _L("RMobileSmsMessaging:: CancelAsyncRequest could not cancel the request EMobileSmsMessagingStoreSmspList")); // // TEST END // StartCleanup(); // Pop: // backup // storeSmspListStatus // getNetworkStatus // smspList CleanupStack::PopAndDestroy(4,&backup); return TestStepResult(); }
APIRET EXPENTRY FS_CHDIR ( USHORT flag, struct cdfsi *pcdfsi, struct cdfsd *pcdfsd, PSZ pDir, USHORT iCurDirEnd ) { int rc; PVOLUME pVolume; PCURDIR pCurdir; PCURDIR pPrevCurdir; PCURDIR pCurCurdir; DIRENTRY Entry; FLAT flatEntry; FLAT flatBlkDir; struct vpfsi *pvpfsi; struct vpfsd *pvpfsd; PSZ pFullDir; UtilEnterRamfs(); DEBUG_PRINTF2 ("FS_CHDIR flag=%d pDir='%s'", flag, pDir); switch (flag) { case 0: /* allocate new working directory */ FSH_GETVOLPARM (pcdfsi->cdi_hVPB, &pvpfsi, &pvpfsd); pVolume = pvpfsd->pVolume; flatBlkDir = pVolume->flatBlkRootDir; pFullDir = pDir; pDir += 3; if (iCurDirEnd != 0xFFFF) { flatBlkDir = pcdfsd->pCurdir->flatBlkDir; pDir += iCurDirEnd-3; } switch (UtilLocate (&flatBlkDir, &flatEntry, &Entry, pDir)) { case LOC_NOPATH: rc = ERROR_PATH_NOT_FOUND; break; case LOC_FILEENTRY: rc = ERROR_ACCESS_DENIED; break; case LOC_NOENTRY: rc = ERROR_PATH_NOT_FOUND; break; case LOC_DIRENTRY: rc = NearAlloc ((PNEARBLOCK *) &pCurdir, sizeof(CURDIR) + strlen(pFullDir)); if (rc) break; pcdfsd->pCurdir = pCurdir; pCurdir->pNextCurdir = pVolume->pFirstCurdir; pVolume->pFirstCurdir = pCurdir; pCurdir->pVolume = pVolume; pCurdir->flatBlkDir = flatEntry + FIELDOFFSET(DIRENTRY,fblkFile.clusters); strcpy (pCurdir->szDir, pFullDir); rc = NO_ERROR; break; } break; case 1: /* verify working directory - only for removable media? */ rc = ERROR_NOT_SUPPORTED; break; case 2: /* deallocate working directory */ if (pcdfsi != NULL) FSH_GETVOLPARM (pcdfsi->cdi_hVPB, &pvpfsi, &pvpfsd); else pvpfsd = NULL; pCurdir = pcdfsd->pCurdir; pVolume = pCurdir->pVolume; pPrevCurdir = 0; pCurCurdir = pVolume->pFirstCurdir; if (pCurCurdir == 0) { /* All directories already freed, nothing to do */ rc = NO_ERROR; break; } while (pCurCurdir != pCurdir) { #ifdef DEBUG if (pCurCurdir == 0) { debugging = TRUE; DEBUG_PRINTF0 ("\r\n!!! CURDIR not found\r\n"); INT3; } #endif pPrevCurdir = pCurCurdir; pCurCurdir = pCurCurdir->pNextCurdir; } if (pPrevCurdir != 0) pPrevCurdir->pNextCurdir = pCurCurdir->pNextCurdir; else pVolume->pFirstCurdir = pCurCurdir->pNextCurdir; NearFree (pCurCurdir); if (pvpfsd != NULL) pvpfsd->pVolume = scavenge_volume (pVolume); rc = NO_ERROR; break; } DEBUG_PRINTF1 (" => %d\r\n", rc); UtilExitRamfs(); return rc; }
void PKSvc::ProcessPKReq(Session& session,Packet& packet) { UInt32 RetCode = 0; DataBuffer serbuffer(1024); char szSql[1024]; Connection con; DBOperate dbo; int iRet = 0; PKBriefList pkList; UInt32 roleID = packet.RoleID; Byte creatureFlag; UInt32 creatureID; ArchvRolePKInfo pkInfo; List<ArchvRolePKInfo> lrpki; UInt32 pkID = 0; ArchvCreatureStatus cs; List<ArchvCreatureStatus> lcs; list<TeamRole> roleIDitor; list<TeamRole>::iterator itor; list<UInt32> roleID1,roleID2; list<UInt32>::iterator it; Team team; ArchvPosition posMid; ArchvPosition posPKOrigin; int iTmp = 0; list<SenceMonster> monsterrs; list<SenceMonster>::iterator itor1; Byte Status=0; RolePtr srcRole = _mainSvc->GetCoreData()->ProcessGetRolePtr(roleID); RolePtr desRole; Monster desMonster; ArchvPosition pos1; ArchvPosition pos2; int pp=-1; int j=1; //序列化类 Serializer s(packet.GetBuffer()); s>>creatureFlag>>creatureID; if( s.GetErrorCode()!= 0 ) { RetCode = ERR_SYSTEM_SERERROR; LOG(LOG_ERROR,__FILE__,__LINE__,"serial error" ); goto EndOf_Process; } //获取DB连接 /* con = _cp->GetConnection(); dbo.SetHandle(con.GetHandle()); */ LOG(LOG_ERROR,__FILE__,__LINE__,"creatureFlag[%d],creatureID[%d] ", creatureFlag, creatureID ); //生物标志校验 if( creatureFlag <=0 || creatureFlag > 4 ) { RetCode = ERR_APP_DATA; LOG(LOG_ERROR,__FILE__,__LINE__,"creatureFlag error!! creatureFlag[%d] ", creatureFlag ); goto EndOf_Process; } //会发生角色无法PK得状态,可以使用定时放开PK限制 pkID=_mainSvc->GetCoreData()->IfRoleInPK(roleID); if(pkID!=0) { LOG(LOG_DEBUG,__FILE__,__LINE__,"111111111111 pkID=%d roleID=%d", pkID, roleID ); RetCode = 2011;//角色的上场战斗没有结束 LOG(LOG_ERROR,__FILE__,__LINE__,"role status error!! role is in the pk RoleId=%d", roleID ); goto EndOf_Process; } if( 0 == srcRole->ID() ) { RetCode = ERR_APP_ROLENOTEXISTS; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessGetRole error,roleID[%d]", roleID ); goto EndOf_Process; } if(srcRole->TeamFlag()==0) { //单独作战,跳过 } else { if(srcRole->TeamFlag()!=2) { //失败,不是队长 RetCode = ERR_APP_ROLENOTEXISTS; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessGetRole error,roleID[%d]", roleID ); goto EndOf_Process; } team=_mainSvc->GetCoreData()->GetTeams(srcRole->TeamID()); roleIDitor=team.GetMemberRoleID(); if(roleIDitor.size()>1) { //队伍的人数 for(itor=roleIDitor.begin();itor!=roleIDitor.end();itor++) { //队伍成员 if(itor->status==1) { //队员处于归队状态 roleID1.push_back(itor->roleId); } }//end for pkList.player1=roleID1;//队员,不包括自己 }//end if }//end if else pos1 = srcRole->Pos(); //获取被攻击者信息 if( 1 == creatureFlag ) {//被攻击者为角色 //获取被攻击角色的信息 desRole = _mainSvc->GetCoreData()->ProcessGetRolePtr(creatureID); if( 0 == desRole->ID() ) { RetCode = ERR_APP_ROLENOTEXISTS; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessGetRole error,creatureID[%d]", creatureID ); goto EndOf_Process; } //判断是否同一地图 if( srcRole->MapID() != desRole->MapID() ) { RetCode = ERR_APP_DATA; LOG(LOG_ERROR,__FILE__,__LINE__,"error MapID,srcRole->MapID()[%d],desRole->MapID()[%d] ", srcRole->MapID(), desRole->MapID() ); goto EndOf_Process; } if(desRole->TeamFlag()==0||desRole->TeamFlag()==1) { //单独作战,跳过 } else { roleIDitor.clear(); team=_mainSvc->GetCoreData()->GetTeams(desRole->TeamID()); roleIDitor=team.GetMemberRoleID(); if(roleIDitor.size()>1) { //队伍的人数 for(itor=roleIDitor.begin();itor!=roleIDitor.end();itor++) { //队伍成员 if(itor->status==1||itor->status==2) { //队员处于归队状态 if(itor->roleId!=creatureID) { roleID2.push_back(itor->roleId); } } } pkList.player2=roleID2;//队员,不包括自己 } } pos2 = desRole->Pos(); } else if( 2 == creatureFlag ) {//被攻击者为怪 //获取怪信息 pos2=_mainSvc->GetCoreData()->GetSenceMonster(srcRole->MapID(),creatureID,monsterrs); if(monsterrs.size()==0) { RetCode = ERR_APP_ROLENOTEXISTS; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessGetMonster error,creatureID[%d]", creatureID ); goto EndOf_Process; } desMonster = _mainSvc->GetCoreData()->ProcessGetMonster( srcRole->MapID(), creatureID ); if( 0 == desMonster.ID() ) { RetCode = ERR_APP_ROLENOTEXISTS; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessGetMonster error,creatureID[%d]", creatureID ); goto EndOf_Process; } desMonster.ID(creatureID); } //获取pk 双方间直线中点坐标 posMid = GetMidpoint( pos1, pos2 ); //计算相对坐标原点位置 //posPKOrigin = CalcPKOrigin( posMid ); LOG(LOG_DEBUG,__FILE__,__LINE__,"----------->>>>posMid x[%d],y[%d], srcRole->currPos x[%d],y[%d], desRole->currPos x[%d],y[%d], posPKOrigin x[%d],y[%d] ", posMid.X, posMid.Y, pos1.X, pos1.Y, pos2.X, pos2.Y, posPKOrigin.X, posPKOrigin.Y ); //组建 S_S pk 请求包: pk发起者 if(pos1.X-posMid.X>0)//在右边,暂时没有获取对方的位置 { pos1.X=PKSCREEN_XLENGTH/2-10; pos1.Y=PKSCREEN_YLENGTH/2; } else { pos1.X=PKSCREEN_XLENGTH/2+10; pos1.Y=PKSCREEN_YLENGTH/2; } if(roleID1.size()%2==0) { pos1.Y=pos1.Y-1; } iRet = MakeSSPkgForRole( pos1, srcRole, lrpki,1); if(iRet) { RetCode = ERR_APP_OP; LOG(LOG_ERROR,__FILE__,__LINE__,"MakeSSPkgForRole error!! srcRole->ID()[%d] ", srcRole->ID() ); goto EndOf_Process; } //队伍队员 for(it=roleID1.begin();it!=roleID1.end();it++) { pp=-1*pp; srcRole = _mainSvc->GetCoreData()->ProcessGetRolePtr(*it); if( 0 == srcRole->ID() ) { RetCode = ERR_APP_ROLENOTEXISTS; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessGetRole error,creatureID[%d]", creatureID ); goto EndOf_Process; } pos1.Y=pos1.Y+2*j*pp; j++; // posPKOrigin.X= iRet = MakeSSPkgForRole( pos1, srcRole, lrpki,1); if(iRet) { RetCode = ERR_APP_OP; LOG(LOG_ERROR,__FILE__,__LINE__,"MakeSSPkgForRole error!! srcRole->ID()[%d] ", srcRole->ID() ); goto EndOf_Process; } } //组建 S_S pk 请求包: 被攻击者 if( 1 == creatureFlag ) { if(pos2.X-posMid.X>0)//在右边,暂时没有获取对方的位置 { pos2.X=PKSCREEN_XLENGTH/2-10; pos2.Y=PKSCREEN_YLENGTH/2; } else { pos2.X=PKSCREEN_XLENGTH/2+10; pos2.Y=PKSCREEN_YLENGTH/2; } iRet = MakeSSPkgForRole( pos2, desRole, lrpki,2); //被攻击者为角色 pp=-1; j=1; for(it=roleID2.begin();it!=roleID2.end();it++) { pp=-1*pp; desRole = _mainSvc->GetCoreData()->ProcessGetRolePtr(*it); if( 0 == desRole->ID() ) { RetCode = ERR_APP_ROLENOTEXISTS; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessGetRole error,creatureID[%d]", creatureID ); goto EndOf_Process; } // posPKOrigin.X= pos2.Y=pos2.Y+2*j*pp; j++; iRet = MakeSSPkgForRole( pos1, desRole, lrpki,2); if(iRet) { RetCode = ERR_APP_OP; LOG(LOG_ERROR,__FILE__,__LINE__,"MakeSSPkgForRole error!! srcRole->ID()[%d] ", srcRole->ID() ); goto EndOf_Process; } } } else if( 2 == creatureFlag ) { pp=1; if(pos2.X-posMid.X>0)//在右边,暂时没有获取对方的位置 { pos2.X=PKSCREEN_XLENGTH/2-5; pos2.Y=PKSCREEN_YLENGTH/2; pp=-1; } else { pos2.X=PKSCREEN_XLENGTH/2+5; pos2.Y=PKSCREEN_YLENGTH/2; pp=-1; } iRet = MakeSSPkgForMonster( pos2, desMonster, lrpki,1); //怪 UInt32 i=1; j=1; if(monsterrs.size()>1) { itor1=monsterrs.begin(); itor1++;//跳过第一条数据 for(;itor1!=monsterrs.end();itor1++) { pos2.X=pos2.X-j*pp*2; desMonster=_mainSvc->GetCoreData()->ProcessGetMonster( desMonster.MapID(), itor1->MonsterType); desMonster.ID(creatureID+i); iRet = MakeSSPkgForMonster( pos2, desMonster, lrpki,itor1->num); //怪 i=itor1->num+i; } } } if(iRet) { RetCode = ERR_APP_OP; LOG(LOG_ERROR,__FILE__,__LINE__,"MakeSSPkgForRole error!! desRole->ID()[%d] ", desRole->ID() ); goto EndOf_Process; } //pk 拉人功能,根据组队、坐标范围来拉人进入pk pkID=roleID; pkList.player1.push_back(roleID);//队员,不包括自己 pkList.player2.push_back(creatureID);//队员,不包括自己 pkList.pkID=pkID; _mainSvc->GetCoreData()->AddPKBrif(pkID,pkList); //ss 消息处理 Status=_mainSvc->GetCoreData()->ProcessGetRolePtr(roleID)->Status(); if(Status!=1) { RetCode = ERR_APP_ROLENOTEXISTS; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessGetRole error,roleID[%d]", roleID ); goto EndOf_Process; } else { srcRole->Status(2); } iRet = _mainSvc->GetSSClientManager()->ProcessPkReq( srcRole->MapID(), posMid.X, posMid.Y, lrpki, pkID); if(iRet) { RetCode = iRet; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessPkReq error ,RetCode[%d]", RetCode ); goto EndOf_Process; } EndOf_Process: //状态的重置 if(RetCode) { srcRole->Status(1); //重置为非pk状态 _mainSvc->GetCoreData()->EraseRolePKID(roleID); //删除 PKID LOG(LOG_DEBUG,__FILE__,__LINE__,"222222222 _mainSvc->GetCoreData()->IfRoleInPK(roleID) [%d]", _mainSvc->GetCoreData()->IfRoleInPK(roleID) ); } //组应答数据 Packet p(&serbuffer); s.SetDataBuffer(&serbuffer); serbuffer.Reset(); p.CopyHeader(packet); p.Direction = DIRECT_C_S_RESP; p.PackHeader(); s<<RetCode; if( 0 == RetCode ) {//RetCode 为0 才会返回包体剩下内容 // s<<11; } p.UpdatePacketLength(); //发送应答数据 if( session.Send(&serbuffer) ) { LOG(LOG_ERROR,__FILE__,__LINE__,"session.Send error "); } DEBUG_PRINTF1( "C_S ack pkg ----- MsgType[%d] \n", packet.MsgType ); DEBUG_SHOWHEX( serbuffer.GetReadPtr(), serbuffer.GetDataSize(), 0, __FILE__, __LINE__ ); //-------------------------------------------------------------------------- //成功处理,则修改生物状态 if( 0 == RetCode ) { GetCtStatus( lrpki, lcs ); _mainSvc->GetCoreData()->ChangeCreatureStatus( srcRole->MapID(), lcs); } }
//@brief [MsgType:0203] (使用飞行符文)瞬移 void MapSvc::ProcessTeleportByRune(Session& session,Packet& packet) { UInt32 RetCode = 0; DataBuffer serbuffer(1024); Connection con; DBOperate dbo; int iRet = 0; UInt32 roleID = packet.RoleID; UInt32 mapID = 0; UInt16 x; UInt16 y; ArchvRoute art; ArchvPosition pos; int isToCurrMap = 0; //是否本地图内瞬移 0否 1 是 //序列化类 Serializer s(packet.GetBuffer()); s>>mapID>>x>>y; if( s.GetErrorCode()!= 0 ) { LOG(LOG_ERROR,__FILE__,__LINE__,"serial error" ); return; } DEBUG_PRINTF1( " ProcessTeleportByRune roleID[%d]\n", roleID ); //获取角色信息 RolePtr pRole = _mainSvc->GetCoreData()->ProcessGetRolePtr(roleID); if(pRole->ID()==0) { RetCode = ERR_APP_DATA; LOG(LOG_ERROR,__FILE__,__LINE__,"data error!! role not found,roleID[%d]", roleID); goto EndOf_Process; } //组队状态,不能瞬移 if(pRole->TeamFlag()) { RetCode = ERR_APP_DATA; LOG(LOG_ERROR,__FILE__,__LINE__,"status error!! role in team, roleID[%d]", roleID); goto EndOf_Process; } //是否在本地图瞬移 if( pRole->MapID() == mapID ) {//本地图内瞬移 isToCurrMap = 1; //移动 pos.X = x; pos.Y = y; art.listPos.push_back(pos); iRet = _mainSvc->GetCoreData()->ProcessRoleMove( roleID, art); if(iRet) { RetCode = ERR_APP_OP; LOG(LOG_ERROR,__FILE__,__LINE__,"ProcessRoleMove error" ); goto EndOf_Process; } } else {//跨地图瞬移 pRole->MapID(mapID); isToCurrMap = 0; //业务处理 iRet = _mainSvc->GetCoreData()->ProcessRoleEnterMap( roleID, mapID, x, y); if( iRet == -1) { RetCode = ERR_APP_OP; LOG(LOG_ERROR,__FILE__,__LINE__,"GetCoreData()->ProcessRoleEnterMap error"); goto EndOf_Process; } if(iRet == 1) { RetCode = ERR_APP_ALREADYINMAP; LOG(LOG_ERROR,__FILE__,__LINE__,"GetCoreData()->ProcessRoleEnterMap error"); goto EndOf_Process; } } EndOf_Process: //组应答数据 Packet p(&serbuffer); s.SetDataBuffer(&serbuffer); serbuffer.Reset(); p.CopyHeader(packet); p.Direction = DIRECT_C_S_RESP; p.PackHeader(); s<<RetCode; if( 0 == RetCode ) {//RetCode 为0 才会返回包体剩下内容 // s<<Time; } p.UpdatePacketLength(); //发送应答数据 if( session.Send(&serbuffer) ) { LOG(LOG_ERROR, __FILE__, __LINE__, "session->Send() error,errno[%d],strerror[%s]", errno, strerror(errno) ); } DEBUG_PRINTF1( "C_S ack pkg ----- MsgType[%d] \n", packet.MsgType ); DEBUG_SHOWHEX( serbuffer.GetReadPtr(), serbuffer.GetDataSize(), 0, __FILE__, __LINE__ ); if(RetCode==0) { //跨地图瞬移 if(0==isToCurrMap) { //[MsgType:0202](单播)进入场景,场景所有其他角色的列表 _mainSvc->GetCoreData()->NotifyAllRoleInfo(roleID); } } return; }
//计算角色在地图上的当前位置,并整理移动路径 // 剔除移动路径中已走过的关键点 // 并把当前位置作为新移动路径的第一个关键点 //@return 0 成功 非0 失败 int Creature::CalcCurrPos() { UInt32 uiTime = time(NULL); double dSpeed = ROLE_MOVE_SPEED*10/1000.0; //速度, dSpeed 单位: 格/秒, _moveSpeed单位: 微型格/0.1秒 // 其中 1格子=1000微型格 double dDistance = 0; //用户从起始时间到当前时间的理论累计行程 double dDisLeft = 0.0; ArchvPosition tmpPos1; ArchvPosition tmpPos2; double dPosDis; //坐标间距离 int iCalcFlag = 0; //计算标志, 为1说明角色仍在行走,需根据比例计算当前位置 int iCount = 0; //走过关键点的个数 /*DEBUG_PRINTF3( "1111111 ,Route.listPos.size()[%d], uiTime[%ld], _attrGeneral._route.time[%ld] \n", _attrGeneral._route.listPos.size(), uiTime, (long)_attrGeneral._route.time );*/ /*LOG(LOG_DEBUG,__FILE__,__LINE__,"-direct[%d],pos.X[%d],pos.Y[%d] ", _attrGeneral._direct, _attrGeneral._pos.X, _attrGeneral._pos.Y );*/ //关键坐标的数量 if( _attrGeneral._route.listPos.size() <=1 || uiTime <= _attrGeneral._route.time ) return 0; //计算用户累计行程 dDistance = ( time(NULL) - _attrGeneral._route.time ) * dSpeed; DEBUG_PRINTF1( "2222222 ,dDistance[%f] \n", dDistance ); if( dDistance <= 0.0 ) return 0; //计算用户当前坐标 List<ArchvPosition>::iterator it; tmpPos1 = *(_attrGeneral._route.listPos.begin()); tmpPos2 = *(_attrGeneral._route.listPos.begin()); dDisLeft = dDistance; for( it = _attrGeneral._route.listPos.begin(); it != _attrGeneral._route.listPos.end(); it++ ) { iCount++; //第一个略过 if( it == _attrGeneral._route.listPos.begin() ) continue; tmpPos2 = *(it); dPosDis = CalcPosDistance( tmpPos1, tmpPos2, _attrGeneral._direct ); if( (dPosDis - dDisLeft ) >= 0.1 ) { iCalcFlag = 1; break; } dDisLeft -= dPosDis; tmpPos1 = *(it); } //角色是否仍在行走 if( 1 == iCalcFlag ) { //角色仍在行走,根据比例计算当前位置 _attrGeneral._pos.X = tmpPos1.X + (Int16)(( dDisLeft/dPosDis )*( tmpPos2.X - tmpPos1.X )); _attrGeneral._pos.Y = tmpPos1.Y + (Int16)(( dDisLeft/dPosDis )*( tmpPos2.Y - tmpPos1.Y )); //剔除走过的关键点 iCount--; List<ArchvPosition>::iterator it; for( int i = 0; i < iCount; i++ ) { it = _attrGeneral._route.listPos.begin(); _attrGeneral._route.listPos.erase(it); } //当前位置作为新移动路径的第一个关键点 it = _attrGeneral._route.listPos.begin(); _attrGeneral._route.time = time(NULL); //当前时间 _attrGeneral._route.listPos.insert( it, _attrGeneral._pos ); DEBUG_PRINTF6( "333333 , dDisLeft[%f], dPosDis[%f], tmpPos1.X[%d], tmpPos1.Y[%d]; tmpPos2.X[%d], tmpPos2.Y[%d]; \n", dDisLeft, dPosDis, tmpPos1.X, tmpPos1.Y, tmpPos2.X, tmpPos2.Y ); DEBUG_PRINTF3( "4444 ,direct[%d],pos.X[%d],pos.Y[%d] \n", _attrGeneral._direct, _attrGeneral._pos.X, _attrGeneral._pos.Y ); } else { //角色不再移动,停在最后一个关键点 _attrGeneral._pos.X = tmpPos2.X; _attrGeneral._pos.Y = tmpPos2.Y; //整理移动路径 ArchvPosition posTmp = _attrGeneral._route.listPos.back(); _attrGeneral._route.time = time(NULL); //当前时间 _attrGeneral._route.listPos.clear(); _attrGeneral._route.listPos.push_back(posTmp); //仅保留最后一个关键点 DEBUG_PRINTF3( "5555 ,direct[%d],pos.X[%d],pos.Y[%d] \n", _attrGeneral._direct, _attrGeneral._pos.X, _attrGeneral._pos.Y ); } return 0; }