📄 accountmanage.cpp
字号:
#include "StdInc.h"
#include "AccountManage.h"
CAccountManage::CAccountManage()
{
}
CAccountManage::~CAccountManage()
{
}
BOOL CAccountManage::Insert(DWORD dwPCID, ACCOUNT_INFO * pAccountInfo)
{
m_pair = m_AccMap.insert(ACCOUNT_MAP::value_type(dwPCID,pAccountInfo));
if (m_pair.second) return TRUE;
return FALSE;
}
BOOL CAccountManage::Remove(DWORD dwPCID)
{
int iErase = 0;
iErase = m_AccMap.erase(dwPCID);
if (iErase)
{
return TRUE;
}
else
{
// Map erase Error!
printf(" Map erase Error!\n");
return FALSE;
}
/*
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator != m_AccMap.end())
{
ACCOUNT_INFO * tmp = (*Iterator).second;
iErase = m_AccMap.erase(dwPCID)
if (iErase)
{
delete tmp;
return TRUE;
}
else
{
printf(" Map erase Error!\n");
// Map erase Error!
}
}
*/
}
ACCOUNT_INFO* CAccountManage::GetAccountInfo(DWORD dwPCID)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return NULL;
else
{
return (ACCOUNT_INFO*)(*Iterator).second;
}
}
char* CAccountManage::GetAccountName(DWORD dwPCID)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return NULL;
else
{
return (*Iterator).second->szAccountName;
}
}
BOOL CAccountManage::IsValidAccount(DWORD dwPCID, char * szPCName)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return FALSE;
else
{
for(int i=0; i < MAX_CHARACTER; i++)
{
if (strcmp((((*Iterator).second)->AccountCharInfo.CharInfo[i].szPCName), szPCName) == 0)
{
return TRUE;
}
}
return FALSE;
}
}
BOOL CAccountManage::SetCurrentPCIndex(DWORD dwPCID, char *szPCName)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return FALSE;
else
{
for(BYTE i=0; i < MAX_CHARACTER; i++)
{
if (strcmp((((*Iterator).second)->AccountCharInfo.CharInfo[i].szPCName), szPCName) == 0)
{
((*Iterator).second)->byCurrentPCIndex = i;
return TRUE;
}
}
return FALSE;
}
}
BOOL CAccountManage::SetCurrentPCIndex(ACCOUNT_INFO * pInfo, char *szPCName)
{
int i = -1;
while (++i < MAX_CHARACTER)
{
if (strcmp((pInfo->AccountCharInfo.CharInfo[i].szPCName), szPCName) == 0)
{
pInfo->byCurrentPCIndex = i;
return TRUE;
}
}
return FALSE;
}
char* CAccountManage::GetCurrentPCName(DWORD dwPCID)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return NULL;
else
{
BYTE index = ((*Iterator).second)->byCurrentPCIndex;
return ((*Iterator).second)->AccountCharInfo.CharInfo[index].szPCName;
}
}
BOOL CAccountManage::IsUpdateAccount(DWORD dwPCID)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return FALSE;
else
{
if ( ((*Iterator).second)->bUpdate ) return TRUE;
return FALSE;
}
}
BOOL CAccountManage::CreateNewCharacter(DWORD dwPCID, BYTE byPCType, char *szPCName)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return FALSE;
else
{
for(BYTE i=0; i < MAX_CHARACTER; i++)
{
if (((*Iterator).second)->AccountCharInfo.CharInfo[i].byType == 0xff) // empty slot 捞搁
{
//货 某腐磐 烙矫 积己
((*Iterator).second)->byCmd = CREATE_CHARACTER;
((*Iterator).second)->byCmdSlot = i;
((*Iterator).second)->AccountCharInfo.CharInfo[i].byType = byPCType;
((*Iterator).second)->AccountCharInfo.CharInfo[i].wLevel = 1;
strncpy(((*Iterator).second)->AccountCharInfo.CharInfo[i].szPCName, szPCName, sizeof(((*Iterator).second)->AccountCharInfo.CharInfo[i].szPCName));
((*Iterator).second)->AccountCharInfo.CharInfo[i].szPCName[sizeof(((*Iterator).second)->AccountCharInfo.CharInfo[i].szPCName) - 1] = NULL;
switch(byPCType)
{
case WARRIOR_TYPE:
//Weapon
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[2].byWearIndex = 2;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[2].ItemID.code = 1024;
//Cap
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[3].byWearIndex = 3;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[3].ItemID.code = 3282;
//Armor
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[4].byWearIndex = 4;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[4].ItemID.code = 3272;
//Pants
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[5].byWearIndex = 5;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[5].ItemID.code = 3277;
//Glove
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[6].byWearIndex = 6;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[6].ItemID.code = 3292;
//Shoes
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[7].byWearIndex = 7;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[7].ItemID.code = 3287;
break;
case PALADIN_TYPE:
//Weapon
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[1].byWearIndex = 0;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[1].ItemID.code = 1048;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[1].byWearIndex = 1;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[1].ItemID.code = 3322;
//Cap
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[3].byWearIndex = 3;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[3].ItemID.code = 3307;
//Armor
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[4].byWearIndex = 4;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[4].ItemID.code = 3297;
//Pants
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[5].byWearIndex = 5;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[5].ItemID.code = 3302;
//Glove
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[6].byWearIndex = 6;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[6].ItemID.code = 3317;
//Shoes
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[7].byWearIndex = 7;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[7].ItemID.code = 3312;
break;
case MAGE_TYPE:
//Weapon
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[2].byWearIndex = 2;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[2].ItemID.code = 2066;
//Cap
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[3].byWearIndex = 3;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[3].ItemID.code = 3337;
//Armor
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[4].byWearIndex = 4;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[4].ItemID.code = 3327;
//Pants
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[5].byWearIndex = 5;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[5].ItemID.code = 3332;
//Glove
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[6].byWearIndex = 6;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[6].ItemID.code = 3347;
//Shoes
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[7].byWearIndex = 7;
((*Iterator).second)->AccountCharInfo.CharInfo[i].WearList[7].ItemID.code = 3342;
break;
} //switch state
return TRUE;
}//if state
}//for state
return FALSE; //empty slot 绝澜???
}//else state
}
BOOL CAccountManage::DeleteCharacter(DWORD dwPCID, char *szPCName)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return FALSE;
else
{
for(BYTE i=0; i < MAX_CHARACTER; i++)
{
if (strcmp((((*Iterator).second)->AccountCharInfo.CharInfo[i].szPCName), szPCName) == 0)
{
//Delete Character 贸府
((*Iterator).second)->byCmd = DELETE_CHARACTER;
((*Iterator).second)->byCmdSlot = i;
return TRUE;
}
}
return FALSE; //弊 拌沥俊 弊 捞抚狼 某腐磐啊 决镜锭...
}
}
BOOL CAccountManage::VerifyCreatePlayer(DWORD dwPCID, char *szPCName)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return FALSE;
else
{
if (((*Iterator).second)->byCmd == CREATE_CHARACTER)
{
if (strcmp((((*Iterator).second)->AccountCharInfo.CharInfo[((*Iterator).second)->byCmdSlot].szPCName), szPCName) == 0)
{
//葛电 炼扒 父练窍搁 沥富肺 积己
Msg_S2C_Ans_Create_Player.MsgHeader.dwPCID = dwPCID;
strncpy(Msg_S2C_Ans_Create_Player.szCharacterName, szPCName, sizeof(Msg_S2C_Ans_Create_Player.szCharacterName));
Msg_S2C_Ans_Create_Player.szCharacterName[sizeof(Msg_S2C_Ans_Create_Player.szCharacterName) - 1] = NULL;
Msg_S2C_Ans_Create_Player.byClassIndex = ((*Iterator).second)->AccountCharInfo.CharInfo[((*Iterator).second)->byCmdSlot].byType;
for(int i=0; i < MAX_WEAR_ITEM; i++)
{
Msg_S2C_Ans_Create_Player.WearList[i] = ((*Iterator).second)->AccountCharInfo.CharInfo[((*Iterator).second)->byCmdSlot].WearList[i];
//memcpy(Msg_S2C_Ans_Create_Player.WearList[i], ((*Iterator).second)->AccountCharInfo.CharInfo[((*Iterator).second)->byCmdSlot].WearList[i], sizeof(ITEM_IN_WEAR));
}
FDB.m_AccountCharInfo = ((*Iterator).second)->AccountCharInfo;
//Init
((*Iterator).second)->byCmd = NORMAL_CHARACTER;
((*Iterator).second)->byCmdSlot = 0xff;
if(FDB.SaveAccCharInfo(((*Iterator).second)->szAccountName))
{
return TRUE;
}
printf("VerifyCreatePlayer() - File Save Error!!!\n");
}
}
}
return FALSE;
}
BOOL CAccountManage::VerifyDeletePlayer(DWORD dwPCID, char *szPCName)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return FALSE;
else
{
if (((*Iterator).second)->byCmd == DELETE_CHARACTER)
{
if (strcmp((((*Iterator).second)->AccountCharInfo.CharInfo[((*Iterator).second)->byCmdSlot].szPCName), szPCName) == 0)
{
//葛电 炼扒 父练窍搁 沥富肺 瘤款促.
((*Iterator).second)->AccountCharInfo.CharInfo[((*Iterator).second)->byCmdSlot].byType = 0xff;
FDB.m_AccountCharInfo = ((*Iterator).second)->AccountCharInfo;
//Init
((*Iterator).second)->byCmd = NORMAL_CHARACTER;
((*Iterator).second)->byCmdSlot = 0xff;
if(FDB.SaveAccCharInfo(((*Iterator).second)->szAccountName))
{
return TRUE;
}
printf("VerifyDeletePlayer() - File Save Error!!!\n");
}
}
}
return FALSE;
}
void CAccountManage::INITforM2S_Error(DWORD dwPCID)
{
ACCOUNT_MAP::iterator Iterator;
Iterator = m_AccMap.find(dwPCID);
if (Iterator == m_AccMap.end()) return;
else
{
if (((*Iterator).second)->byCmd == CREATE_CHARACTER)
{
((*Iterator).second)->AccountCharInfo.CharInfo[((*Iterator).second)->byCmdSlot].byType = 0xff;
((*Iterator).second)->byCmd = NORMAL_CHARACTER;
((*Iterator).second)->byCmdSlot = 0xff;
}
else if (((*Iterator).second)->byCmd == DELETE_CHARACTER)
{
((*Iterator).second)->byCmd = NORMAL_CHARACTER;
((*Iterator).second)->byCmdSlot = 0xff;
}
else //NORMAL_CHARACTER
{
return;
}
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -