paysystem.cpp
来自「天之炼狱1服务器端源文件游戏服务端不完整」· C++ 代码 · 共 1,151 行 · 第 1/3 页
CPP
1,151 行
//---------------------------------------------------------------------------// ip啊 PCRoomIPInfo俊 乐促搁 弊 ID甫 啊柳 PCRoom阑 PCRoomInfo俊辑 茫酒辑// 弊 沥焊甫 佬绢甸牢促.//---------------------------------------------------------------------------bool PaySystem::loginPayPlayPCRoom(const string& ip, const string& playerID) throw (Error){ __BEGIN_TRY Statement* pStmt = NULL; Result* pResult = NULL; //Statement* pStmt = NULL; //cout << "[loginPayPlayPCRoom] from = " << ip.c_str() << ", " << playerID.c_str() << endl; BEGIN_DB { try { pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); } catch (Throwable& t) { filelog("paySystem.txt", "%s", t.toString().c_str()); throw; } try { pResult = pStmt->executeQuery( "SELECT r.ID, r.PayType, r.PayStartDate, r.PayPlayDate, r.PayPlayHours, r.PayPlayFlag, r.UserLimit, r.UserMax FROM PCRoomInfo r, PCRoomIPInfo p WHERE p.IP='%s' AND p.ID=r.ID", ip.c_str()); } catch (Throwable& t) { filelog("paySystem.txt", "%s", t.toString().c_str()); throw; } if (pResult!=NULL && pResult->next()) { uint i = 0; setPCRoomID( pResult->getInt(++i) ); setPayType( (PayType)pResult->getInt(++i) ); setPayStartAvailableDateTime( pResult->getString(++i) ); setPayPlayAvailableDateTime( pResult->getString(++i) ); setPayPlayAvailableHours( pResult->getInt(++i) ); setPayPlayFlag( pResult->getInt(++i) ); m_UserLimit = pResult->getInt(++i); m_UserMax = pResult->getInt(++i); // 捞惑茄 辆樊力 包访 内靛 if ( m_PayType == PAY_TYPE_POST ) { VSDateTime currentDateTime(VSDate::currentDate(), VSTime::currentTime()); // 力茄等 朝楼 捞饶搁 利侩 救登具 窍骨肺 if ( currentDateTime <= m_PayPlayAvailableDateTime ) { setPayPlayType( PAY_PLAY_TYPE_PCROOM ); m_bPCRoomPlay = true; return true; } return false; } //m_UserMax = max((unsigned int)5, m_UserMax); //m_UserMax = min((unsigned int)12, m_UserMax); m_UserMax = 15; // 茄 白规 弥措 15疙 pResult = pStmt->executeQuery( "SELECT count(*) from PCRoomUserInfo WHERE ID=%d", m_PCRoomID ); if (pResult->next()) { uint users = pResult->getInt(1); setPayPlayType( PAY_PLAY_TYPE_PCROOM ); bool bAvailable = checkPayPlayAvailable(); // // [PC规 荤侩磊荐 力茄] // // 沥咀力 : UserLimit 逞绢啊搁 救等促. // 辆樊力 : UserMax 逞绢啊搁 救等促 <-- 荤角 奴 狼固绰 绝促. // if (m_PayType==PAY_TYPE_PERIOD && users >= m_UserLimit || m_PayType==PAY_TYPE_TIME && users >= m_UserMax) { //cout << "[PayPCRoom] User Limit Exceed!" << endl; SAFE_DELETE(pStmt); return false; } // 荤侩啊瓷窍促搁.. if (bAvailable) { // 老窜 荤侩磊甫 眠啊秦焊绰单.. try { pStmt->executeQuery( "INSERT IGNORE INTO PCRoomUserInfo(ID, PlayerID) VALUES(%d, '%s')", m_PCRoomID, playerID.c_str()); } catch (SQLQueryException& se) { filelog("paySystem.txt", "%s", se.toString().c_str()); // 弊成 逞绢哎鳖 } // 眠啊茄 第狼 荤侩磊 箭磊甫 犬牢秦焊绊.. pResult = pStmt->executeQuery( "SELECT count(*) from PCRoomUserInfo WHERE ID=%d", m_PCRoomID ); if (pResult->next()) { users = pResult->getInt(1); // PC规 荤侩磊荐 力茄阑 逞绢啊搁... if (m_PayType==PAY_TYPE_PERIOD && users >= m_UserLimit || m_PayType==PAY_TYPE_TIME && users >= m_UserMax) { // 眠啊沁带吧 促矫 瘤快绊.. pStmt->executeQuery( "DELETE FROM PCRoomUserInfo WHERE PlayerID='%s'", playerID.c_str()); //cout << "[PayPCRoom] User Limit Exceed2!" << endl; // 荤侩 阂啊.. SAFE_DELETE(pStmt); return false; } else { // 沥惑利牢 版快 SAFE_DELETE(pStmt); m_bPCRoomPlay = true; return true; } } } } } SAFE_DELETE(pStmt); } catch(SQLQueryException& sqe) { SAFE_DELETE(pStmt); filelog("paySystem.txt", "%s", sqe.toString().c_str()); throw; } return false; __END_CATCH}//---------------------------------------------------------------------------// logout Pay PlayPCRoomIP//---------------------------------------------------------------------------void PaySystem::logoutPayPlayPCRoom(const string& playerID) throw (Error){ __BEGIN_TRY Statement* pStmt = NULL; if (m_PayPlayType==PAY_PLAY_TYPE_PCROOM) { BEGIN_DB { pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); // 眠啊沁带吧 促矫 瘤快绊.. pStmt->executeQuery( "DELETE FROM PCRoomUserInfo WHERE PlayerID='%s'", playerID.c_str()); SAFE_DELETE(pStmt); //} END_DB(pStmt); } catch(SQLQueryException& sqe) { SAFE_DELETE(pStmt); filelog("paySystem.txt", "%s", sqe.toString().c_str()); throw; } } __END_CATCH}//---------------------------------------------------------------------------// login PayPlay//---------------------------------------------------------------------------bool PaySystem::loginPayPlay(PayType payType, const string& payPlayDate, int payPlayHours, uint payPlayFlag, const string& ip, const string& playerID) throw (Error){ __BEGIN_TRY // 酒流 logout捞 等 惑怕啊 酒聪搁.. if (m_PayPlayStartTime.tv_sec != 0) { return true; } m_PayPlayStartTime.tv_sec = 0; /* cout << "[PaySystem::loginPayPlay] " << "PlayerID = " << playerID.c_str() << ", " << "PayType = " << (int)payType << endl << "payPlayDate = " << payPlayDate.c_str() << endl << "payPlayHours = " << (int)payPlayHours << endl << "payPlayFlag = " << (int)payPlayFlag << endl; */// if ( g_pConfig->getPropertyInt( "IsNetMarble" ) )// {// payType = PAY_TYPE_FREE;// } // 呼傅 by sigi. 2002.5.31 // FREE, PERIOD, TIME, PART setPayType(payType); //-------------------------------------------------- // 俺牢 荤侩磊 夸陛眉拌俊 措茄 眉农 //-------------------------------------------------- if (payType!=PAY_TYPE_FREE) { setPayPlayType( PAY_PLAY_TYPE_PERSON ); setPayPlayAvailableDateTime( payPlayDate ); setPayPlayAvailableHours( payPlayHours ); setPayPlayFlag( payPlayFlag ); if ( !checkPayPlayAvailable() || m_PayType == PAY_TYPE_TIME ) { // 霸烙规 刚历 眉农 if ( !loginPayPlayPCRoom(ip, playerID) ) { // loginPayPlayPCRoom俊辑 蔼捞 官差骨肺.. -_-; // 俺牢 荤侩磊 沥焊 汲沥 setPayPlayType( PAY_PLAY_TYPE_PERSON ); setPayType( payType ); setPayPlayAvailableDateTime( payPlayDate ); setPayPlayAvailableHours( payPlayHours ); setPayPlayFlag( payPlayFlag ); // 俺牢 荤侩磊 眉农 if (!checkPayPlayAvailable()) { return false; } } else { // 促澜俊 俺牢夸陛瘤阂眉拌 沥焊甫 佬绢具 窍骨肺.. m_bSetPersonValue = false; } } // 俺牢 沥咀 荤侩磊档 PC 规 焊呈胶甫 利侩矫难林扁 困秦辑 else if ( m_PayType == PAY_TYPE_PERIOD ) { // PC 规 肺变秦焊绊 登搁 -_-;; if ( loginPayPlayPCRoom(ip, playerID) ) { // PC 规 肺弊 酒眶 窍绊 logoutPayPlayPCRoom( playerID ); // 蔼 促矫 盔贰措肺 倒妨林扁 setPayType(payType); setPayPlayType( PAY_PLAY_TYPE_PERSON ); setPayPlayAvailableDateTime( payPlayDate ); setPayPlayAvailableHours( payPlayHours ); setPayPlayFlag( payPlayFlag ); } } } __END_CATCH getCurrentTime(m_PayPlayStartTime); // PayType阑 汲沥茄促. checkPayPlayAvailable(); m_bPremiumPlay = true; return true;}//---------------------------------------------------------------------------// login PayPlay//---------------------------------------------------------------------------bool PaySystem::loginPayPlay(const string& ip, const string& playerID) throw (Error){ Statement* pStmt = NULL; __BEGIN_TRY // 酒流 logout捞 等 惑怕啊 酒聪搁.. if (m_PayPlayStartTime.tv_sec != 0) { return true; } m_PayPlayStartTime.tv_sec = 0; if (!m_bSetPersonValue) { BEGIN_DB { //pStmt = g_pDatabaseManager->getConnection((int)Thread::self())->createStatement(); pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); Result* pResult = pStmt->executeQuery( "SELECT PayType, PayPlayDate, PayPlayHours, PayPlayFlag, FamilyPayPlayDate FROM Player WHERE PlayerID='%s'", playerID.c_str()); if (pResult->getRowCount() == 0) { SAFE_DELETE(pStmt); //cout << "No PlayerID" << endl; return false; } pResult->next(); setPayType( (PayType)pResult->getInt(1) ); setPayPlayAvailableDateTime( pResult->getString(2) ); setPayPlayAvailableHours( pResult->getInt(3) ); setPayPlayFlag( pResult->getInt(4) ); setFamilyPayPlayAvailableDateTime( pResult->getString(5) ); SAFE_DELETE(pStmt); //} END_DB(pStmt) } catch(SQLQueryException& sqe) { SAFE_DELETE(pStmt); filelog("paySystem.txt", "%s", sqe.toString().c_str()); throw; } } /* cout << "[PaySystem::loginPayPlay] " << "PlayerID = " << playerID.c_str() << ", " << "PayType = " << (int)m_PayType << endl << "payPlayDate = " << m_PayPlayAvailableDateTime.toString() << endl << "payPlayHours = " << (int)m_PayPlayAvailableHours << endl << "payPlayFlag = " << (int)m_PayPlayFlag << endl; */// if ( g_pConfig->getPropertyInt( "IsNetMarble" ) )// {// setPayType( PAY_TYPE_FREE );// } // 呼傅 by sigi. 2002.5.31 // FREE, PERIOD, TIME, PART //-------------------------------------------------- // 俺牢 荤侩磊 夸陛眉拌俊 措茄 眉农 //-------------------------------------------------- if (m_PayType!=PAY_TYPE_FREE) { // 俺牢 沥咀力 荤侩磊牢瘤 刚历 眉农茄促. setPayPlayType( PAY_PLAY_TYPE_PERSON ); if (!checkPayPlayAvailable() || m_PayType != PAY_TYPE_PERIOD) { // loginPayPlayPCRoom俊辑 蔼捞 官差骨肺.. -_-; PayType payType = m_PayType;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?