Files
Sun1602/Server/ShopServer/Uitl/UserMap.cpp
T
2022-10-26 12:25:11 +08:00

146 lines
3.5 KiB
C++

#include "StdAfx.h"
#include "UserMap.h"
CUserMap::CUserMap(void)
{
}
CUserMap::~CUserMap(void)
{
}
int CUserMap::GetSize()
{
return m_usermap.size();
}
void CUserMap::Add(BILLUSER user)
{
autolock(m_cs);
m_usermap[user.dwBillingGUID] = user;
}
bool CUserMap::Remove(long nKey)
{
autolock(m_cs);
return m_usermap.erase(nKey);
}
bool CUserMap::Find(long nGuid, BILLUSER& billingbuser)
{
autolock(m_cs);
stdext::hash_map<long, BILLUSER>::iterator itr;
itr = m_usermap.find(nGuid);
if(m_usermap.end() == itr) return false;
else
{
billingbuser = itr->second;
/*billingbuser.RealEndDate = itr->second.RealEndDate;
billingbuser.EndDate = itr->second.EndDate;
billingbuser.dRestPoint = itr->second.dRestPoint;
billingbuser.dRestTime = itr->second.dRestTime;
billingbuser.sDeductType = itr->second.sDeductType;
billingbuser.dwBillingGUID = itr->second.dwBillingGUID;
billingbuser.dwAccountGUID = itr->second.dwAccountGUID;*/
}
return true;
}
void CUserMap::Clear()
{
autolock(m_cs);
m_usermap.clear();
}
void CUserMap::GetCloseUsers(LPVOID pSession, std::vector<BILLINGJOB>& vec)
{
autolock(m_cs);
BILLINGJOB job;
job.jobcode = JOB_LOGOUT;
stdext::hash_map<long, BILLUSER>::iterator itr;
for(itr = m_usermap.begin() ; itr != m_usermap.end() ; itr++)
{
if(itr->second.pSession == pSession)
{
job.nBillingGUID = itr->second.dwBillingGUID;
vec.push_back(job);
}
}
}
void CUserMap::GetAllUsers(std::vector<BILLINGJOB>& vec, DWORD dwCurrentTime)
{
autolock(m_cs);
BILLINGJOB job;
stdext::hash_map<long, BILLUSER>::iterator itr;
for(itr = m_usermap.begin() ; itr != m_usermap.end() ; itr++)
{
if(DEDUCT_TYPE_PERSON_TIME == itr->second.sDeductType || DEDUCT_TYPE_ROON_TIME == itr->second.sDeductType) //정액 사용자.
{
if(itr->second.RealEndDate > dwCurrentTime) continue;// 정액시간이 남았으면 잡에 추가하지 않는다.
}
job.dwAccountGUID = itr->second.dwAccountGUID;
job.dwIPAddress = itr->second.dwIPAddress;
job.dwRoomGUID = itr->second.dwRoomGUID;
job.dwGameCode = itr->second.dwGameCode;
job.dwServerType = itr->second.dwServerType;
job.nDeductTime = itr->second.nDeductTime;
job.sDeductType = itr->second.sDeductType;
job.pSession = itr->second.pSession;
job.nBillingGUID = itr->second.dwBillingGUID;
job.dRestPoint = itr->second.dRestPoint;
job.dRestTime = itr->second.dRestTime;
job.EndDate = itr->second.EndDate;
job.RealEndDate = itr->second.RealEndDate;
job.jobcode = JOB_DEDUCT;
vec.push_back(job);
}
}
void CUserMap::GetLiveCheckUsers(std::vector<BILLINGJOB>& vec)
{
autolock(m_cs);
BILLINGJOB job;
job.jobcode = JOB_EXPIRED;
stdext::hash_map<long, BILLUSER>::iterator itr;
for(itr = m_usermap.begin() ; itr != m_usermap.end() ; itr++)
{
if(DEDUCT_TYPE_PERSON_TIME == itr->second.sDeductType || DEDUCT_TYPE_ROON_TIME == itr->second.sDeductType)
{
job.dwAccountGUID = itr->second.dwAccountGUID;
job.dwIPAddress = itr->second.dwIPAddress;
job.dwRoomGUID = itr->second.dwRoomGUID;
job.dwGameCode = itr->second.dwGameCode;
job.dwServerType = itr->second.dwServerType;
job.nDeductTime = itr->second.nDeductTime;
job.sDeductType = itr->second.sDeductType;
job.pSession = itr->second.pSession;
job.nBillingGUID = itr->second.dwBillingGUID;
job.dRestPoint = itr->second.dRestPoint;
job.dRestTime = itr->second.dRestTime;
job.EndDate = itr->second.EndDate;
job.RealEndDate = itr->second.RealEndDate;
vec.push_back(job);
}
}
}