📄 gameplayer.cpp
字号:
} */ return SpeedCheck; __END_CATCH}void GamePlayer::loadSpecialEventCount(void) throw(){ __BEGIN_TRY Statement* pStmt = NULL; Result* pResult = NULL; BEGIN_DB {// pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pStmt = g_pDatabaseManager->getDistConnection( "PLAYER_DB" )->createStatement(); pResult = pStmt->executeQuery("SELECT SpecialEventCount FROM Player WHERE PlayerID='%s'", m_ID.c_str()); if (pResult->getRowCount() != 0) { pResult->next(); m_SpecialEventCount = pResult->getDWORD(1); } else { SAFE_DELETE(pStmt); throw ("GamePlayer::loadSpecialEventCount() : unable to dispatch data"); return; } SAFE_DELETE(pStmt); } END_DB(pStmt); __END_CATCH}void GamePlayer::saveSpecialEventCount(void) throw(){ __BEGIN_TRY Statement* pStmt = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement();// pStmt = g_pDatabaseManager->getConnection( (int)Thread::self() )->createStatement(); pStmt->executeQuery("UPDATE Player SET SpecialEventCount=%d WHERE PlayerID='%s'", m_SpecialEventCount, m_ID.c_str()); SAFE_DELETE(pStmt); } END_DB(pStmt); __END_CATCH}bool GamePlayer::sendBillingLogin() throw (Error){ __BEGIN_TRY if (!m_ID.empty() && m_ID!="NONE") { Timeval currentTime; getCurrentTime(currentTime); if (currentTime > m_BillingNextLoginRequestTime) { g_pBillingPlayerManager->sendPayLogin( this ); Timeval afterTime; getCurrentTime( afterTime ); // 1檬 捞惑 吧府搁 肺弊 巢变促. if ( afterTime.tv_sec > currentTime.tv_sec + 1 ) { filelog( "billingLoginTime.txt", "PlayerID : %s, CallTime : %d sec, Try : %d", m_ID.c_str(), (int)(afterTime.tv_sec - currentTime.tv_sec), m_BillingLoginRequestCount ); } // PayLogin 夸没茄 雀荐 扁撅 m_BillingLoginRequestCount ++; // 60檬 饶 促矫 眉农茄促. m_BillingNextLoginRequestTime.tv_sec = currentTime.tv_sec + 60; } return true; } return false; __END_CATCH}void GamePlayer::sendCBillingPayInfo() throw ( Error ){ __BEGIN_TRY char m[200]; if ( m_CBPlayerType == CBILLING_PLAYER_TYPE_MONTHLY ) { VSDate currentDate; currentDate = VSDate::currentDate(); sprintf( m, g_pStringPool->c_str( STRID_CB_MONTHLY_PLAYER ), m_CBEndDateTime.date().year(), m_CBEndDateTime.date().month(), m_CBEndDateTime.date().day(), currentDate.year(), currentDate.month(), currentDate.day() ); GCSystemMessage msg; msg.setMessage( m ); sendPacket( &msg ); } else if ( m_CBPlayerType == CBILLING_PLAYER_TYPE_POINT ) { sprintf( m, g_pStringPool->c_str( STRID_CB_POINT_PLAYER ), m_CBLeftTime / 10 ); GCSystemMessage msg; msg.setMessage( m ); sendPacket( &msg ); } __END_CATCH}// 鞠龋拳 内靛甫 汲沥茄促.void GamePlayer::setEncryptCode() throw (Error){ __BEGIN_TRY#ifdef __USE_ENCRYPTER__ Assert(m_pCreature!=NULL); // 老窜篮 ObjectID甫 捞侩茄促. //ObjectID_t objectID = m_pCreature->getObjectID(); // 粮喊肺 包府甫 窍档废 荐沥茄促.// ZoneID_t zoneID = m_pCreature->getZone()->getZoneID();// static int serverID = g_pConfig->getPropertyInt("ServerID");// if (objectID!=0)// { //uchar code = (uchar)(objectID / zoneID + objectID); //uchar code = (uchar)( ( ( zoneID >> 8 ) ^ zoneID ) ^ ( ( serverID + 1 ) << 4 ) ); uchar code = m_pCreature->getZone()->getEncryptCode();#ifdef __ACTIVE_SERVICE_DEADLINE__ // 辑滚 官焊 父甸扁 内靛 VSDate date = VSDate::currentDate(); // 2003斥 1岿 捞惑牢 版快: 2003, 0 if (date.year()>=DEADLINE_YEAR && date.month()>=DEADLINE_MONTH) code += (date.year()+date.month())/11;#endif SocketEncryptOutputStream* pEOS = dynamic_cast<SocketEncryptOutputStream*>(m_pOutputStream); Assert(pEOS!=NULL); SocketEncryptInputStream* pEIS = dynamic_cast<SocketEncryptInputStream*>(m_pInputStream); Assert(pEIS!=NULL); pEOS->setEncryptCode(code); pEIS->setEncryptCode(code);// }#endif __END_CATCH}void GamePlayer::kickPlayer( uint nSeconds, uint KickMessageType ) throw (Error){ __BEGIN_TRY // 捞固 EventKick 捞 乐促搁 公矫茄促. if ( m_EventManager.getEvent( Event::EVENT_CLASS_KICK ) != NULL ) return; EventKick* pEventKick = new EventKick( this ); pEventKick->setDeadline( nSeconds * 10 ); addEvent( pEventKick ); // 割 檬饶俊 漏赴促..绊 焊郴霖促. GCKickMessage gcKickMessage; gcKickMessage.setType( KickMessageType ); gcKickMessage.setSeconds( nSeconds ); sendPacket( &gcKickMessage ); __END_CATCH}//////////////////////////////////////////////////////////////////// PaySystem 包访//////////////////////////////////////////////////////////////////bool GamePlayer::loginPayPlay( PayType payType, const string& PayPlayDate, int PayPlayHours, uint payPlayFlag, const string& ip, const string& playerID ) throw (Error){ __BEGIN_TRY#ifdef __CONNECT_BILLING_SYSTEM__ return BillingPlayerInfo::isBillingPlayAvaiable();#else return PaySystem::loginPayPlay( payType, PayPlayDate, PayPlayHours, payPlayFlag, ip, playerID );#endif __END_CATCH}bool GamePlayer::loginPayPlay( const string& ip, const string& playerID ) throw (Error){ __BEGIN_TRY#ifdef __CONNECT_BILLING_SYSTEM__ return BillingPlayerInfo::isBillingPlayAvaiable();#else bool bRet = PaySystem::loginPayPlay( ip, playerID ); if ( bRet ) setPCRoomLottoStartTime(); return bRet;#endif __END_CATCH}bool GamePlayer::updatePayPlayTime( const string& playerID, const VSDateTime& currentDateTime, const Timeval& currentTime ) throw ( ProtocolException, Error ){ __BEGIN_TRY#ifdef __CONNECT_BILLING_SYSTEM__ return BillingPlayerInfo::isBillingPlayAvaiable();#else checkPCRoomLotto( currentTime ); return PaySystem::updatePayPlayTime( playerID, currentDateTime, currentTime );#endif __END_CATCH}void GamePlayer::logoutPayPlay( const string& playerID, bool bClear, bool bDecreaseTime ) throw (Error){ __BEGIN_TRY#ifdef __CONNECT_BILLING_SYSTEM__ if ( !BillingPlayerInfo::isBillingPlayAvaiable() ) setPremiumPlay( false );#else savePCRoomLottoTime(); PaySystem::logoutPayPlay( playerID, bClear, bDecreaseTime );#endif __END_CATCH}bool GamePlayer::isPayPlaying() const{#ifdef __CONNECT_BILLING_SYSTEM__ return BillingPlayerInfo::isBillingPlayAvaiable();#elif defined(__CONNECT_CBILLING_SYSTEM__) return CBillingPlayerInfo::isPayPlayer();#elif !defined(__PAY_SYSTEM_ZONE__) && !defined(__PAY_SYSTEM_LOGIN__) && !defined(__PAY_SYSTEM_FREE_LIMIT__) // if there is no Pay defines, all users are pay player return true;#else return PaySystem::isPayPlaying();#endif}////////////////////////////////////////////////////////////////////////////////// add LogoutPlayerdata//// 立加磊 烹拌甫 困秦辑 // UserInfo DB狼 LogoutPlayerData俊 Logout茄 荤侩磊甫 眠啊茄促.////////////////////////////////////////////////////////////////////////////////void addLogoutPlayerData(Player* pPlayer){ Statement* pStmt = NULL; pStmt = g_pDatabaseManager->getUserInfoConnection()->createStatement(); // 蜡历 烹拌 包访 沥焊甫 涝仿茄促. BEGIN_DB { string ID = pPlayer->getID(); string ip = pPlayer->getSocket()->getHost(); // 刚历 泅犁 矫埃阑 掘绢辰促. int year, month, day, hour, minute, second; getCurrentTimeEx(year, month, day, hour, minute, second); string currentDT = VSDateTime::currentDateTime().toDateTime(); StringStream sql; sql << "INSERT INTO USERINFO.LogoutPlayerData (PlayerID,IP,Date,Time) VALUES ('" << ID << "','" << ip << "','" << currentDT.substr( 0, 10 ).c_str() << "','" << currentDT.substr( 11 ).c_str() << "')"; pStmt->executeQuery(sql.toString()); SAFE_DELETE(pStmt); } END_DB(pStmt)}void GamePlayer::setPCRoomLottoStartTime(){ if ( !g_pVariableManager->isPCRoomLottoEvent() ) return; if ( !m_bPCRoomPlay ) return; m_PCRoomLottoStartTime.tv_sec = m_PayPlayStartTime.tv_sec - m_PCRoomLottoSumTime;}void GamePlayer::savePCRoomLottoTime(){ if ( !g_pVariableManager->isPCRoomLottoEvent() ) return; if ( !m_bPCRoomPlay ) return; Timeval currentTime; getCurrentTime( currentTime ); m_PCRoomLottoSumTime = currentTime.tv_sec - m_PCRoomLottoStartTime.tv_sec; m_PCRoomLottoStartTime.tv_sec = 0;}void GamePlayer::checkPCRoomLotto( const Timeval& currentTime ){ if ( !g_pVariableManager->isPCRoomLottoEvent() ) return; if ( !m_bPCRoomPlay ) return; if ( m_PCRoomLottoStartTime.tv_sec == 0 ) { m_PCRoomLottoStartTime.tv_sec = currentTime.tv_sec - m_PCRoomLottoSumTime; } int time = currentTime.tv_sec - m_PCRoomLottoStartTime.tv_sec; if ( time >= PCRoomLottoSec ) { giveLotto(); // 促矫 矫埃阑 檬扁拳茄促. m_PCRoomLottoStartTime.tv_sec = currentTime.tv_sec; m_PCRoomLottoSumTime = 0; }}void GamePlayer::giveLotto(){ if ( m_pCreature == NULL ) return; Statement* pStmt = NULL; Result* pResult = NULL; BEGIN_DB { static uint DimensionID = g_pConfig->getPropertyInt( "Dimension" ); static uint WorldID = g_pConfig->getPropertyInt( "WorldID" ); string PlayerID = getID(); string Name = m_pCreature->getName(); Race_t Race = m_pCreature->getRace(); int Amount = 0; pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); pResult = pStmt->executeQuery( "SELECT Amount FROM PCRoomLottoObject WHERE PlayerID = '%s' AND Name = '%s' AND DimensionID = %u AND WorldID = %u", PlayerID.c_str(), Name.c_str(), DimensionID, WorldID ); if ( pResult->next() ) { Amount = pResult->getInt( 1 ); if ( Amount < PCRoomLottoMaxAmount ) { pStmt->executeQuery( "UPDATE PCRoomLottoObject SET Amount = %d WHERE PlayerID = '%s' AND Name = '%s' AND DimensionID = %u AND WorldID = %u", Amount + 1, PlayerID.c_str(), Name.c_str(), DimensionID, WorldID ); } } else { // 汗鼻捞 绝菌促. 货肺 持绢霖促. pStmt->executeQuery( "INSERT INTO PCRoomLottoObject VALUES ( 0, %u, '%s', %u, %u, '%s', %u, 1 )", m_PCRoomID, PlayerID.c_str(), DimensionID, WorldID, Name.c_str(), Race ); } if ( Amount < PCRoomLottoMaxAmount ) { char msg[100]; sprintf( msg, g_pStringPool->c_str( STRID_GIVE_LOTTO ), Amount + 1 ); GCSystemMessage gcMsg; gcMsg.setMessage( msg ); sendPacket( &gcMsg ); if ( Amount >= PCRoomLottoMaxAmount - 1 ) { gcMsg.setMessage( g_pStringPool->getString( STRID_CANNOT_GIVE_LOTTO ) ); sendPacket( &gcMsg ); } } } END_DB( pStmt )}bool GamePlayer::startPacketLog( uint sec ){ if ( m_pCreature == NULL ) return false; m_bPacketLog = true; getCurrentTime( m_PacketLogEndTime ); m_PacketLogEndTime.tv_sec += sec; char filename[100]; sprintf( filename, "log/%s.log", m_pCreature->getName().c_str() ); m_PacketLogFileName = filename; return true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -