paysystem.cpp
来自「天之炼狱1服务器端源文件游戏服务端不完整」· C++ 代码 · 共 1,151 行 · 第 1/3 页
CPP
1,151 行
VSDateTime payPlayDate = m_PayPlayAvailableDateTime; int payPlayHours = m_PayPlayAvailableHours; uint payPlayFlag = m_PayPlayFlag; // 霸烙规 刚历 眉农 if (!loginPayPlayPCRoom(ip, playerID)) { // 俺牢 荤侩磊 沥焊 汲沥 setPayPlayType( PAY_PLAY_TYPE_PERSON ); setPayType( payType ); m_PayPlayAvailableDateTime = payPlayDate; setPayPlayAvailableHours( payPlayHours ); setPayPlayFlag( payPlayFlag ); // 俺牢 荤侩磊 眉农 if (!checkPayPlayAvailable()) { //cout << "No PayPlay" << endl; return false; } } else { // 促澜俊 俺牢夸陛瘤阂眉拌 沥焊甫 佬绢具 窍骨肺.. m_bSetPersonValue = false; } } // 俺牢 沥咀 荤侩磊档 PC 规 焊呈胶甫 利侩矫难林扁 困秦辑 else if ( m_PayType == PAY_TYPE_PERIOD ) { m_bPCRoomPlay = isPlayInPayPCRoom( ip, playerID ); } } __END_CATCH getCurrentTime(m_PayPlayStartTime); // PayType阑 汲沥茄促. checkPayPlayAvailable(); m_bPremiumPlay = true; //cout << "PayPlay Available : " << m_PayPlayAvailableDateTime.toString() << ", " << (int)m_PayPlayAvailableHours << endl; return true;}//---------------------------------------------------------------------------// logout PayPlay//---------------------------------------------------------------------------void PaySystem::logoutPayPlay(const string& playerID, bool bClear, bool bDecreaseTime) throw (Error){ __BEGIN_TRY // 矫埃捞 促 蹬辑 漏府绰 版快狼 贸府啊 瞪 锭 // m_PayPlayStartTime.tv_sec = 0 栏肺 汲沥秦初篮 惑怕捞促. //if (m_PayPlayStartTime.tv_sec == 0) // return; if (m_PayPlayType==PAY_PLAY_TYPE_PCROOM) { logoutPayPlayPCRoom(playerID); Timeval currentTime; getCurrentTime(currentTime); if (bDecreaseTime && m_PayType==PAY_TYPE_TIME) { int usedMin = (currentTime.tv_sec-m_PayPlayStartTime.tv_sec)/60; //usedMin = max(1, usedMin); if (usedMin > 0) { decreasePayPlayTimePCRoom(usedMin); } } else if (bDecreaseTime && m_PayType==PAY_TYPE_POST) { int usedMin = (currentTime.tv_sec-m_PayPlayStartTime.tv_sec)/60; if (usedMin > 0) { increasePayPlayTimePCRoom(usedMin); } } } else if (m_PayPlayType==PAY_PLAY_TYPE_PERSON) { if (bClear) { // 葛电 Pay沥焊甫 力芭窍绊 公丰荤侩磊肺 官槽促. by sigi. 2002.11.18 clearPayPlayDateTime(playerID); } else if (bDecreaseTime && m_PayType==PAY_TYPE_TIME && m_PayPlayStartTime.tv_sec!=0) { Timeval currentTime; getCurrentTime(currentTime); int usedMin = (currentTime.tv_sec-m_PayPlayStartTime.tv_sec)/60; //usedMin = max(1, usedMin); if (usedMin > 0) { decreasePayPlayTime(playerID, usedMin); } } } m_PayPlayStartTime.tv_sec = 0; m_bPremiumPlay = false; __END_CATCH}//---------------------------------------------------------------------------// clear PayPlayTime //---------------------------------------------------------------------------// DB俊辑 荤侩矫埃阑 力芭茄促.void PaySystem::clearPayPlayDateTime(const string& playerID) throw (Error){ __BEGIN_TRY m_PayPlayAvailableHours = 0; Statement* pStmt = NULL; BEGIN_DB { //pStmt = g_pDatabaseManager->getConnection((int)Thread::self())->createStatement(); pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); pStmt->executeQuery( "UPDATE Player SET PayPlayHours=0, PayPlayDate='2002-11-18 00:00:00' WHERE PlayerID='%s'", playerID.c_str()); SAFE_DELETE(pStmt); } END_DB(pStmt) __END_CATCH}//---------------------------------------------------------------------------// decrease PayPlayTime //---------------------------------------------------------------------------// DB俊辑 荤侩矫埃阑 哗霖促. void PaySystem::decreasePayPlayTime(const string& playerID, uint mm) throw (Error){ __BEGIN_TRY m_PayPlayAvailableHours -= mm; Statement* pStmt = NULL; BEGIN_DB { //pStmt = g_pDatabaseManager->getConnection((int)Thread::self())->createStatement(); pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); pStmt->executeQuery( "UPDATE Player SET PayPlayHours=PayPlayHours-%d WHERE PlayerID='%s'", mm, playerID.c_str()); SAFE_DELETE(pStmt); } END_DB(pStmt) __END_CATCH}//---------------------------------------------------------------------------// decrease PayPlayTime PCRoom//---------------------------------------------------------------------------void PaySystem::decreasePayPlayTimePCRoom(uint mm) throw (Error){ __BEGIN_TRY m_PayPlayAvailableHours -= mm; Statement* pStmt = NULL; BEGIN_DB { //pStmt = g_pDatabaseManager->getConnection((int)Thread::self())->createStatement(); pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); pStmt->executeQuery( "UPDATE PCRoomInfo SET PayPlayHours=PayPlayHours-%d WHERE ID=%d", mm, m_PCRoomID); Result* pResult = pStmt->executeQuery( "SELECT PayPlayHours FROM PCRoomInfo WHERE ID=%d", m_PCRoomID); if (pResult->next()) { m_PayPlayAvailableHours = pResult->getInt(1); } SAFE_DELETE(pStmt); } END_DB(pStmt) __END_CATCH}//---------------------------------------------------------------------------// increase PayPlayTime PCRoom//---------------------------------------------------------------------------void PaySystem::increasePayPlayTimePCRoom(uint mm) throw (Error){ __BEGIN_TRY VSDate vsDate = VSDate::currentDate(); Statement* pStmt = NULL; Result* pResult = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); pResult = pStmt->executeQuery( "SELECT PayPlayMinute FROM PCRoomPayList WHERE PCRoomID=%d AND Year=%d AND Month=%d" , m_PCRoomID, vsDate.year(), vsDate.month() ); if ( pResult->next() ) { pStmt->executeQuery( "UPDATE PCRoomPayList SET PayPlayMinute=PayPlayMinute+%d WHERE PCRoomID=%d AND Year=%d AND Month=%d" , mm, m_PCRoomID, vsDate.year(), vsDate.month() ); } else { pStmt->executeQuery( "INSERT INTO PCRoomPayList (PCRoomID, Year, Month, PayPlayMinute) VALUES (%d, %d, %d, %d)", m_PCRoomID, vsDate.year(), vsDate.month(), mm ); } SAFE_DELETE(pStmt); } END_DB(pStmt) __END_CATCH}bool PaySystem::isPayPlayingPeriodPersonal(const string& PlayerID) throw (Error){ __BEGIN_TRY Statement* pStmt = NULL; bool isPayPlay = false; BEGIN_DB { //pStmt = g_pDatabaseManager->getConnection((int)Thread::self())->createStatement(); pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); Result* pResult = pStmt->executeQuery( " SELECT PayType=0 or PayPlayDate > now() FROM Player WHERE PlayerID='%s'", PlayerID.c_str()); if (pResult->next()) { isPayPlay = pResult->getInt(1)==1; } SAFE_DELETE(pStmt); //} END_DB(pStmt) } catch(SQLQueryException& sqe) { SAFE_DELETE(pStmt); filelog("paySystem.txt", "%s", sqe.toString().c_str()); throw; } return isPayPlay; __END_CATCH}//---------------------------------------------------------------------------// ip啊 PCRoomIPInfo俊 乐促搁 弊 ID甫 啊柳 PCRoom阑 PCRoomInfo俊辑 茫酒辑// 弊 沥焊甫 佬绢甸牢促.// 蜡丰 荤侩吝牢 乔揪规俊辑 敲饭捞 窍绊 乐绰瘤 犬牢窍绰 窃荐// 俺牢 沥咀力老 版快 loginPayPlayPCRoom() 阑 龋免窍瘤 臼扁 锭巩俊 蝶肺 犬牢阑 茄促.//---------------------------------------------------------------------------bool PaySystem::isPlayInPayPCRoom(const string& ip, const string& playerID) throw (Error){ __BEGIN_TRY Statement* pStmt = NULL; Result* pResult = NULL; 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 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; ObjectID_t pcRoomID = (ObjectID_t)pResult->getInt(++i); PayType payType = (PayType)pResult->getInt(++i); VSDateTime payStartAvailableDateTime( pResult->getString(++i) ); VSDateTime payPlayAvailableDateTime( pResult->getString(++i) ); int payPlayAvailableHours = pResult->getInt(++i); VSDateTime currentDateTime(VSDate::currentDate(), VSTime::currentTime()); // 捞惑茄 辆樊力 包访 内靛 if ( payType == PAY_TYPE_POST ) { VSDateTime currentDateTime(VSDate::currentDate(), VSTime::currentTime()); // 力茄等 朝楼 捞饶搁 利侩 救登具 窍骨肺 if ( currentDateTime <= payPlayAvailableDateTime ) return true; return false; } // 蜡丰 荤侩 啊瓷茄 PC 规牢瘤 犬牢茄促. bool bAvailable = ( payType == PAY_TYPE_FREE ) || ( ( currentDateTime >= payStartAvailableDateTime ) && ( currentDateTime <= payPlayAvailableDateTime ) ) || ( payPlayAvailableHours > 0 ); // 蜡丰 荤侩 啊瓷茄 PC 规老版快 PC 规 ID 甫 技泼茄促. if ( bAvailable ) m_PCRoomID = pcRoomID; return bAvailable; } SAFE_DELETE(pStmt); } catch(SQLQueryException& sqe) { SAFE_DELETE(pStmt); filelog("paySystem.txt", "%s", sqe.toString().c_str()); throw; } return false; __END_CATCH}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?