clcreatepchandler.cpp
来自「dk1游戏的原代码文件,完整.编译系统redhat7.3,mysql 3.23 」· C++ 代码 · 共 492 行 · 第 1/2 页
CPP
492 行
//////////////////////////////////////////////////////////////////////////////// Filename : CLCreatePCHandler.cc// Written By :// Description ://////////////////////////////////////////////////////////////////////////////#include "CLCreatePC.h"#ifdef __LOGIN_SERVER__ #include "LoginPlayer.h" #include "PCSlayerInfo.h" #include "Assert.h" #include "GameServerInfoManager.h" #include "DB.h" #include <list> #include "Lpackets/LCCreatePCOK.h" #include "Lpackets/LCCreatePCError.h" #include <string.h> #include "chinabilling/CBillingInfo.h"#endifbool isAvailableID(const char* pID);////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////void CLCreatePCHandler::execute (CLCreatePC* pPacket , Player* pPlayer) throw (ProtocolException , Error){ __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __LOGIN_SERVER__ Assert(pPacket != NULL); Assert(pPlayer != NULL); LoginPlayer* pLoginPlayer = dynamic_cast<LoginPlayer*>(pPlayer); Statement* pStmt = NULL; Result* pResult = NULL; LCCreatePCError lcCreatePCError; WorldID_t WorldID = pLoginPlayer->getWorldID();#ifdef __CONNECT_CBILLING_SYSTEM__ if ( pLoginPlayer->isCBillingVerified() ) { if ( !pLoginPlayer->isPayPlayer() ) { lcCreatePCError.setErrorID( CANNOT_CREATE_PC_BILLING ); pLoginPlayer->sendPacket( &lcCreatePCError ); return; } } else { lcCreatePCError.setErrorID( CANNOT_AUTHORIZE_BILLING ); pLoginPlayer->sendPacket( &lcCreatePCError ); return; }#endif try { pStmt = g_pDatabaseManager->getConnection( WorldID )->createStatement(); // 矫胶袍俊辑 荤侩窍芭唱, 陛瘤等 捞抚篮 酒囱扁 八刘茄促. // NONE, ZONE***, INV***, QUICK... //string text = pPacket->getName(); if (!isAvailableID( pPacket->getName().c_str() )) { lcCreatePCError.setErrorID(ALREADY_REGISTER_ID); throw DuplicatedException("捞固 粮犁窍绰 酒捞叼涝聪促."); } /* list<string>::const_iterator itr = InvalidTokenList.begin(); for (; itr != InvalidTokenList.end(); itr++) { if (text.find(*itr) != string::npos) { lcCreatePCError.setErrorID(ALREADY_REGISTER_ID); throw DuplicatedException("捞固 粮犁窍绰 酒捞叼涝聪促."); } } */ // 捞固 粮犁窍绰 某腐磐 捞抚捞 酒囱瘤 八刘茄促. ///* pResult = pStmt->executeQuery("SELECT Name FROM Slayer WHERE Name = '%s'", pPacket->getName().c_str()); if (pResult->getRowCount() != 0) { lcCreatePCError.setErrorID(ALREADY_REGISTER_ID); throw DuplicatedException("捞固 粮犁窍绰 酒捞叼涝聪促."); } // 秦寸 浇儿俊 某腐磐啊 捞固 乐瘤绰 臼篮瘤 八刘茄促. pResult = pStmt->executeQuery("SELECT Name FROM Slayer WHERE PlayerID ='%s' and Slot ='%s'", pLoginPlayer->getID().c_str(), Slot2String[pPacket->getSlot()].c_str() ); if (pResult->getRowCount() != 0) { lcCreatePCError.setErrorID(ALREADY_REGISTER_ID); throw DuplicatedException("捞固 粮犁窍绰 酒捞叼涝聪促."); } //*/ // 滴 孽府甫 窍唱肺. 2002. 7. 13 by sigi. 捞芭 救亮促. - -; /* pResult = pStmt->executeQuery("SELECT Name FROM Slayer WHERE Name='%s' OR PlayerID='%s' AND Slot='%s'", pPacket->getName().c_str(), pLoginPlayer->getID().c_str(), Slot2String[pPacket->getSlot()].c_str() ); if (pResult->getRowCount() != 0) { lcCreatePCError.setErrorID(ALREADY_REGISTER_ID); throw DuplicatedException("捞固 粮犁窍绰 酒捞叼涝聪促."); } */ // 肋给等 瓷仿摹甫 啊瘤绊 某腐磐甫 积己窍妨 窍绰 巴篮 酒囱瘤 八刘茄促. bool bInvalidAttr = false; int nSTR = pPacket->getSTR(); int nSTRExp = 0; int nSTRGoalExp = 0; int nDEX = pPacket->getDEX(); int nDEXExp = 0; int nDEXGoalExp = 0; int nINT = pPacket->getINT(); int nINTExp = 0; int nINTGoalExp = 0; //int Rank = 1; //int RankExp = 0; // static int RankGoalExpSlayer = -1; static int GoalExpVampire = -1; // by sigi. 2002.12.20 static int RankGoalExpVampire = -1; static int GoalExpOusters = -1; static int RankGoalExpOusters = -1; if (RankGoalExpSlayer==-1) { pResult = pStmt->executeQuery("SELECT GoalExp FROM RankEXPInfo WHERE Level=1 AND RankType=0"); if (pResult->next()) RankGoalExpSlayer = pResult->getInt(1); } if (GoalExpVampire==-1) // by sigi. 2002.12.20 { pResult = pStmt->executeQuery("SELECT GoalExp FROM VampEXPBalanceInfo WHERE Level=1"); if (pResult->next()) GoalExpVampire = pResult->getInt(1); } if (GoalExpOusters==-1) { pResult = pStmt->executeQuery("SELECT GoalExp FROM OustersEXPBalanceInfo WHERE Level=1"); if (pResult->next()) GoalExpOusters = pResult->getInt(1); } if (RankGoalExpVampire==-1) { pResult = pStmt->executeQuery("SELECT GoalExp FROM RankEXPInfo WHERE Level=1 AND RankType=1"); if (pResult->next()) RankGoalExpVampire = pResult->getInt(1); } if (RankGoalExpOusters==-1) { pResult = pStmt->executeQuery("SELECT GoalExp FROM RankEXPInfo WHERE Level=1 AND RankType=2"); if (pResult->next()) RankGoalExpOusters = pResult->getInt(1); } if (pPacket->getRace() == RACE_SLAYER) { if (nSTR < 5 || nSTR > 20) bInvalidAttr = true; if (nDEX < 5 || nDEX > 20) bInvalidAttr = true; if (nINT < 5 || nINT > 20) bInvalidAttr = true; if (nSTR + nDEX + nINT > 30) bInvalidAttr = true; //cout << "Slayer: " << nSTR << ", " << nDEX << ", " << nINT << endl; } else if ( pPacket->getRace() == RACE_VAMPIRE ) // vampire牢 版快. 公炼扒 20. by sigi. 2002.10.31 { if (nSTR != 20 || nDEX != 20 || nINT != 20) { bInvalidAttr = true; } else { // 沥惑利牢 vampire牢 版快 // Slayer狼 瓷仿摹甫 促矫 汲沥秦拎具 茄促. -_-; // by sigi. 2002.11.7 nSTR = 5 + rand()%16; // 5~20 nDEX = 5 + rand()%(21-nSTR); nINT = 30 - nSTR - nDEX; pPacket->setSTR(nSTR); pPacket->setDEX(nDEX); pPacket->setINT(nINT); } // //cout << "Vampire: " << nSTR << ", " << nDEX << ", " << nINT << endl; } else if ( pPacket->getRace() == RACE_OUSTERS ) { if ( nSTR + nDEX + nINT != 45 ) bInvalidAttr = true; } if (bInvalidAttr) { SAFE_DELETE(pStmt); throw InvalidProtocolException("CLCreatePCHandler::too large character attribute"); } // 葛电 八荤甫 父练沁促搁 捞力 某腐磐甫 积己茄促. ServerGroupID_t CurrentServerGroupID = pPlayer->getServerGroupID(); // 快庆庆.. 老窜 孽府甫 临老妨绊 static栏肺 火龙阑 沁促. // 唱吝俊 酒抗 肺弊牢 辑滚 躲锭俊 版氰摹 table甸阑 loading秦 滴档废秦具且 巴捞促. 2002.7.13 by sigi static int STRGoalExp[100] = { 0, }; static int STRAccumExp[100] = { 0, }; static int DEXGoalExp[100] = { 0, }; static int DEXAccumExp[100] = { 0, }; static int INTGoalExp[100] = { 0, }; static int INTAccumExp[100] = { 0, }; nSTRGoalExp = STRGoalExp[nSTR]; if (nSTRGoalExp==0) { pResult = pStmt->executeQuery("SELECT GoalExp FROM STRBalanceInfo WHERE Level = %d", nSTR); if (pResult->next()) nSTRGoalExp = STRGoalExp[nSTR] = pResult->getInt(1); } nSTRExp = STRAccumExp[nSTR-1]; if (nSTRExp==0) { pResult = pStmt->executeQuery("SELECT AccumExp FROM STRBalanceInfo WHERE Level = %d", nSTR - 1); if (pResult->next()) nSTRExp = STRAccumExp[nSTR-1] = pResult->getInt(1); } nDEXGoalExp = DEXGoalExp[nDEX]; if (nDEXGoalExp==0)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?