MMatchDBMgr.h
00001 #ifndef MMATCHDBMGR_H 00002 #define MMATCHDBMGR_H 00003 00004 #include "ODBCRecordset.h" 00005 #include "MMatchItem.h" 00006 #include "MMatchGlobal.h" 00007 00008 class MMatchCharInfo; 00009 class MMatchFriendInfo; 00010 struct MMatchAccountInfo; 00011 struct MTD_CharInfo; 00012 struct MTD_AccountCharInfo; 00013 00014 #ifdef _QUEST_ITEM 00015 class MQuestItem; 00016 #endif 00017 00018 struct MAccountItemNode 00019 { 00020 int nAIID; 00021 unsigned long int nItemID; 00022 int nRentMinutePeriodRemainder; 00023 }; 00024 00025 class MMatchDBMgr { 00026 protected: 00027 CDatabase m_DB; 00028 CString m_strDSNConnect; 00029 00030 bool CheckOpen(); 00031 void Log(const char *pFormat,...); 00032 public: 00033 MMatchDBMgr(); 00034 virtual ~MMatchDBMgr(); 00035 00036 CDatabase* GetDatabase() { return &m_DB; } 00037 00038 CString BuildDSNString(const CString strDSN, const CString strUserName, const CString strPassword); 00039 bool Connect(CString strDSNConnect); 00040 void Disconnect(); 00041 private: 00042 bool UpdateCharLevel(const int nCID, const int nLevel); 00043 bool InsertLevelUpLog(const int nCID, const int nLevel, const int nBP, 00044 const int nKillCount, const int nDeathCount, const int nPlayTime); 00045 public: 00046 // 계정, 캐릭터 관리 관련 00047 bool GetLoginInfo(const TCHAR* szUserID, unsigned int* poutnAID, TCHAR* poutPassword); 00048 00049 bool UpdateLastConnDate(const TCHAR* szUserID, const TCHAR* szIP); 00050 00051 bool CreateAccount(const TCHAR* szUserID, // 사용자ID 00052 const TCHAR* szPassword, // 패스워드 00053 const int nCert, // 실명인증 00054 const TCHAR* szName, // 사용자이름 00055 const int nAge, // 나이 00056 const int nSex); // 성별 0 - 여자, 1 - 남자 00057 bool CreateCharacter(int* pnOutResult, // 결과값 00058 const int nAID, // AID 00059 const TCHAR* szNewName, // 캐릭터 이름 00060 const int nCharIndex, // 계정의 캐릭 슬롯 인덱스 00061 const int nSex, // 성별 00062 const int nHair, // 헤어 00063 const int nFace, // 얼굴 00064 const int nCostume); // 초기 코스튬 00065 bool DeleteCharacter(const int nAID, 00066 const nCharIndex, 00067 const TCHAR* szCharName); 00068 // bool GetAccountCharList(const int nAID, 00069 // MTD_CharInfo* poutCharList, 00070 // int* noutCharCount); 00071 bool GetAccountCharList(const int nAID, 00072 MTD_AccountCharInfo* poutCharList, 00073 int* noutCharCount); 00074 bool GetAccountCharInfo(const int nAID, const int nCharIndex, MTD_CharInfo* poutCharInfo); 00075 bool GetAccountInfo(const unsigned long int nAID, 00076 MMatchAccountInfo* poutAccountInfo); 00077 00078 bool GetCharInfoByAID(const int nAID, 00079 const int nCharIndex, 00080 MMatchCharInfo* poutCharInfo); 00081 00082 bool GetCharCID(const TCHAR* pszName, int* poutCID); 00083 00084 bool SimpleUpdateCharInfo(MMatchCharInfo* pCharInfo); 00085 00086 // 게임 플레이 관련 00087 bool UpdateCharBP(const int nCID, const int nBPInc); 00088 00089 bool UpdateCharInfoData(const int nCID, const int nAddedXP, const int nAddedBP, 00090 const int nAddedKillCount, const int nAddedDeathCount); 00091 00092 // 아이템 관련 00093 bool InsertCharItem(const unsigned int nCID, int nItemDescID, unsigned long int* poutCIID); 00094 bool DeleteCharItem(const unsigned int nCID, int nCIID); 00095 bool GetCharItemInfo(MMatchCharInfo* pCharInfo); // 캐릭터의 모든 아이템을 가져온다 00096 bool GetAccountItemInfo(const int nAID, MAccountItemNode* pOut, int* poutNodeCount, int nMaxNodeCount, 00097 MAccountItemNode* pOutExpiredItemList, int* poutExpiredItemCount, int nMaxExpiredItemCount); // 창고 아이템을 가져온다 00098 bool UpdateEquipedItem(const unsigned long nCID, 00099 MMatchCharItemParts parts, 00100 unsigned long int nCIID, 00101 const unsigned long int nItemID, 00102 bool* poutRet); 00103 bool ClearAllEquipedItem(const unsigned long nCID); 00104 bool DeleteExpiredAccountItem(const int nAIID); 00105 00106 00107 #ifdef _QUEST_ITEM 00108 // Quest Item관련. 00109 // 아직 테스트 중. 00110 00111 #define MAX_QUSET_PLAYER_COUNT 4 00112 #define MAX_DB_QUEST_BINARY_SIZE 256 00113 #define MAX_DB_MONSTER_SIZE 32 00114 00115 bool UpdateQuestItem( MMatchCharInfo* pCharInfo ); 00116 bool TestUpdateQuestItem( MQuestItem* pQuestItem, int nCount ); 00117 bool GetCharQuestItemInfo( MMatchCharInfo* pCharInfo ); 00118 bool TestGetQuestItem( MQuestItem** ppQuestItem, int& nNum ); 00119 bool GetUniqueQuestItem( const int nCID, const int nQIID ); 00120 bool QuestLog( const char* pszQuestName, 00121 const int nMasterCID, 00122 const int nPlayerCount, 00123 const char* pszPlayers, 00124 const char* pszQuestItemLog ); 00125 #endif 00126 00127 // 로그 관련 00128 // bool InsertConnLog(const int nAID, const char* szUserID, const char* szIP); 00129 bool InsertConnLog(const int nAID, const char* szIP); 00130 bool InsertGameLog(const char* szGameName, const char* szMap, const char* GameType, 00131 const int nRound, const unsigned int nMasterCID, 00132 const int nPlayerCount, const char* szPlayers); 00133 bool InsertKillLog(const unsigned int nAttackerCID, const unsigned int nVictimCID); 00134 bool InsertChatLog(const unsigned long int nCID, const char* szMsg, unsigned long int nTime); 00135 bool InsertServerLog(const int nServerID, const int nPlayerCount, const int nGameCount); 00136 bool InsertPlayerLog(const unsigned long int nCID, 00137 const int nPlayTime, const int nKillCount, const int nDeathCount, const int nXP, const int nTotalXP); 00138 00139 bool UpdateServerStatus(const int nServerID, const int nPlayerCount); 00140 bool UpdateMaxPlayer(const int nServerID, const int nMaxPlayer); 00141 bool UpdateServerInfo(const int nServerID, const int nMaxPlayer, const char* szServerName); 00142 bool UpdateCharPlayTime(const unsigned long int nCID, const unsigned long int nPlayTime); 00143 00144 enum _ITEMPURCHASE_TYPE 00145 { 00146 IPT_BUY = 0, 00147 IPT_SELL = 1, 00148 }; 00149 00150 bool InsertItemPurchaseLogByBounty(const unsigned long int nItemID, const unsigned long int nCID, 00151 const int nBounty, const int nCharBP, const _ITEMPURCHASE_TYPE nType); 00152 00153 enum _CHARMAKING_TYPE 00154 { 00155 CMT_CREATE = 0, 00156 CMT_DELETE = 1 00157 }; 00158 bool InsertCharMakingLog(const unsigned int nAID, const char* szCharName, 00159 const _CHARMAKING_TYPE nType); 00160 00161 // 중앙은행에서 내 캐쉬 아이템 가져오기 00162 bool BringAccountItem(const int nAID, const int nCID, const int nAIID, 00163 unsigned long int* poutCIID, unsigned long int* poutItemID, 00164 bool* poutIsRentItem, int* poutRentMinutePeriodRemainder); 00165 // 중앙은행으로 내 캐쉬 아이템 넣기 00166 bool BringBackAccountItem(const int nAID, const int nCID, const int nCIID); 00167 00169 bool FriendAdd(const int nCID, const int nFriendCID, const int nFavorite); 00170 bool FriendRemove(const int nCID, const int nFriendCID); 00171 bool FriendGetList(const int nCID, MMatchFriendInfo* pFriendInfo); 00172 00174 bool GetCharClan(const int nCID, int* poutClanID, TCHAR* poutClanName); 00175 bool GetClanIDFromName(const TCHAR* szClanName, int* poutCLID); 00176 bool CreateClan(const TCHAR* szClanName, const int nMasterCID, const int nMember1CID, const int nMember2CID, 00177 const int nMember3CID, const int nMember4CID, bool* boutRet, int* noutNewCLID); 00178 bool ReserveCloseClan(const int nCLID, const TCHAR* szClanName, const int nMasterCID); 00179 bool AddClanMember(const int nCLID, const int nJoinerCID, const int nClanGrade, bool* boutRet); 00180 bool RemoveClanMember(const int nCLID, const int nLeaverCID); 00181 bool UpdateClanGrade(const int nCLID, const int nMemberCID, const int nClanGrade); 00182 bool ExpelClanMember(const int nCLID, const int nAdminGrade, TCHAR* szMember, int* noutRet); 00183 00184 struct MDB_ClanInfo 00185 { 00186 int nCLID; 00187 char szClanName[CLAN_NAME_LENGTH]; 00188 int nLevel; 00189 int nRanking; 00190 int nPoint; 00191 int nTotalPoint; 00192 int nWins; 00193 int nLosses; 00194 char szMasterName[CLAN_NAME_LENGTH]; 00195 int nTotalMemberCount; 00196 char szEmblemUrl[256]; 00197 int nEmblemChecksum; 00198 }; 00199 bool GetClanInfo(const int nCLID, MDB_ClanInfo* poutClanInfo); 00200 bool UpdateCharClanContPoint(const int nCID, const int nCLID, const int nAddedContPoint); 00201 00202 00203 enum _EXPEL_RETURN 00204 { 00205 ER_OK = 1, // 성공 00206 ER_NO_MEMBER = 0, // 해당 클랜원이 없다 00207 ER_WRONG_GRADE = 2 // 권한이 맞지 않다. 00208 }; 00209 00210 00212 bool GetLadderTeamID(const int nTeamTableIndex, const int* pnMemberCIDArray, const int nMemberCount, int* pnoutTID); 00213 bool LadderTeamWinTheGame(const int nTeamTableIndex, const int nWinnerTID, const int nLoserTID, const bool bIsDrawGame, 00214 const int nWinnerPoint, const int nLoserPoint, const int nDrawPoint); 00215 bool GetLadderTeamMemberByCID(const int nCID, int* poutTeamID, char** ppoutCharArray, int nCount); 00216 00217 00219 bool WinTheClanGame(const int nWinnerCLID, const int nLoserCLID, const bool bIsDrawGame, 00220 const int nWinnerPoint, const int nLoserPoint, const char* szWinnerClanName, 00221 const char* szLoserClanName, const int nRoundWins, const int nRoundLosses, 00222 const int nMapID, const int nGameType, 00223 const char* szWinnerMembers, const char* szLoserMembers); 00224 00225 00226 // Util Func 00227 bool UpdateCharLevel(const int nCID, const int nNewLevel, const int nBP, const int nKillCount, 00228 const int nDeathCount, const int nPlayTime, bool bIsLevelUp); 00229 00230 // 이벤트 관련 00231 bool EventJjangUpdate(const int nAID, const bool bJjang); 00232 }; 00233 00234 00235 #endif
MAIET entertainment