removed billing

This commit is contained in:
savis
2025-09-01 19:56:49 +02:00
parent 286439aada
commit 4a943ed998
21 changed files with 5 additions and 925 deletions

View File

@@ -1,15 +0,0 @@
#ifndef __INC_METIN_II_COMMON_BILLING_H__
#define __INC_METIN_II_COMMON_BILLING_H__
enum EBillingTypes
{
BILLING_NONE,
BILLING_IP_FREE,
BILLING_FREE,
BILLING_IP_TIME,
BILLING_IP_DAY,
BILLING_TIME,
BILLING_DAY,
};
#endif

View File

@@ -97,9 +97,7 @@ enum
HEADER_GD_AUTH_LOGIN = 100,
HEADER_GD_LOGIN_BY_KEY = 101,
HEADER_GD_BILLING_EXPIRE = 104,
HEADER_GD_VCARD = 105,
HEADER_GD_BILLING_CHECK = 106,
HEADER_GD_MALL_LOAD = 107,
HEADER_GD_MYSHOP_PRICELIST_UPDATE = 108, ///< 가격정보 갱신 요청
@@ -224,11 +222,7 @@ enum
HEADER_DG_CHANGE_CHARACTER_PRIV = 127,
HEADER_DG_BILLING_REPAIR = 128,
HEADER_DG_BILLING_EXPIRE = 129,
HEADER_DG_BILLING_LOGIN = 130,
HEADER_DG_VCARD = 131,
HEADER_DG_BILLING_CHECK = 132,
HEADER_DG_CREATE_OBJECT = 140,
HEADER_DG_DELETE_OBJECT = 141,
@@ -1052,8 +1046,6 @@ typedef struct SPacketGDAuthLogin
char szLogin[LOGIN_MAX_LEN + 1];
char szSocialID[SOCIAL_ID_MAX_LEN + 1];
uint32_t adwClientKey[4];
uint8_t bBillType;
uint32_t dwBillID;
int32_t iPremiumTimes[PREMIUM_MAX_NUM];
} TPacketGDAuthLogin;
@@ -1166,26 +1158,6 @@ typedef struct SPacketSetEventFlag
int32_t lValue;
} TPacketSetEventFlag;
typedef struct SPacketBillingLogin
{
uint32_t dwLoginKey;
uint8_t bLogin;
} TPacketBillingLogin;
typedef struct SPacketBillingRepair
{
uint32_t dwLoginKey;
char szLogin[LOGIN_MAX_LEN + 1];
char szHost[MAX_HOST_LENGTH + 1];
} TPacketBillingRepair;
typedef struct SPacketBillingExpire
{
char szLogin[LOGIN_MAX_LEN + 1];
uint8_t bBillType;
uint32_t dwRemainSeconds;
} TPacketBillingExpire;
typedef struct SPacketLoginOnSetup
{
uint32_t dwID;

View File

@@ -1,6 +1,5 @@
#include "stdafx.h"
#include "common/billing.h"
#include "common/building.h"
#include "common/VnumHelper.h"
#include "libgame/grid.h"
@@ -1056,7 +1055,6 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
sys_log(0, "AUTH_PEER ptr %p", peer);
m_pkAuthPeer = peer;
SendAllLoginToBilling();
return;
}
@@ -1202,7 +1200,6 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
// 로그인 및 빌링정보 보내기
//
TPacketLoginOnSetup * pck = (TPacketLoginOnSetup *) c_pData;;
std::vector<TPacketBillingRepair> vec_repair;
for (DWORD c = 0; c < p->dwLoginCount; ++c, ++pck)
{
@@ -1225,29 +1222,11 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
{
sys_log(0, "SETUP: login %u %s login_key %u host %s", pck->dwID, pck->szLogin, pck->dwLoginKey, pck->szHost);
pkLD->SetPlay(true);
if (m_pkAuthPeer)
{
TPacketBillingRepair pck_repair;
pck_repair.dwLoginKey = pkLD->GetKey();
strlcpy(pck_repair.szLogin, pck->szLogin, sizeof(pck_repair.szLogin));
strlcpy(pck_repair.szHost, pck->szHost, sizeof(pck_repair.szHost));
vec_repair.push_back(pck_repair);
}
}
else
sys_log(0, "SETUP: login_fail %u %s login_key %u", pck->dwID, pck->szLogin, pck->dwLoginKey);
}
if (m_pkAuthPeer && !vec_repair.empty())
{
sys_log(0, "REPAIR size %d", vec_repair.size());
m_pkAuthPeer->EncodeHeader(HEADER_DG_BILLING_REPAIR, 0, sizeof(DWORD) + sizeof(TPacketBillingRepair) * vec_repair.size());
m_pkAuthPeer->EncodeDWORD(vec_repair.size());
m_pkAuthPeer->Encode(&vec_repair[0], sizeof(TPacketBillingRepair) * vec_repair.size());
}
SendPartyOnSetup(peer);
CGuildManager::instance().OnSetup(peer);
CPrivManager::instance().SendPrivOnSetup(peer);
@@ -1765,8 +1744,6 @@ void CClientManager::QUERY_AUTH_LOGIN(CPeer * pkPeer, DWORD dwHandle, TPacketGDA
pkLD->SetKey(p->dwLoginKey);
pkLD->SetClientKey(p->adwClientKey);
pkLD->SetBillType(p->bBillType);
pkLD->SetBillID(p->dwBillID);
pkLD->SetPremium(p->iPremiumTimes);
TAccountTable & r = pkLD->GetAccountRef();
@@ -1789,109 +1766,6 @@ void CClientManager::QUERY_AUTH_LOGIN(CPeer * pkPeer, DWORD dwHandle, TPacketGDA
}
}
void CClientManager::BillingExpire(TPacketBillingExpire * p)
{
char key[LOGIN_MAX_LEN + 1];
trim_and_lower(p->szLogin, key, sizeof(key));
switch (p->bBillType)
{
case BILLING_IP_TIME:
case BILLING_IP_DAY:
{
DWORD dwIPID = 0;
str_to_number(dwIPID, p->szLogin);
TLogonAccountMap::iterator it = m_map_kLogonAccount.begin();
while (it != m_map_kLogonAccount.end())
{
CLoginData * pkLD = (it++)->second;
if (pkLD->GetBillID() == dwIPID)
{
CPeer * pkPeer = GetPeer(pkLD->GetConnectedPeerHandle());
if (pkPeer)
{
strlcpy(p->szLogin, pkLD->GetAccountRef().login, sizeof(p->szLogin));
pkPeer->EncodeHeader(HEADER_DG_BILLING_EXPIRE, 0, sizeof(TPacketBillingExpire));
pkPeer->Encode(p, sizeof(TPacketBillingExpire));
}
}
}
}
break;
case BILLING_TIME:
case BILLING_DAY:
{
TLogonAccountMap::iterator it = m_map_kLogonAccount.find(key);
if (it != m_map_kLogonAccount.end())
{
CLoginData * pkLD = it->second;
CPeer * pkPeer = GetPeer(pkLD->GetConnectedPeerHandle());
if (pkPeer)
{
pkPeer->EncodeHeader(HEADER_DG_BILLING_EXPIRE, 0, sizeof(TPacketBillingExpire));
pkPeer->Encode(p, sizeof(TPacketBillingExpire));
}
}
}
break;
}
}
void CClientManager::BillingCheck(const char * data)
{
if (!m_pkAuthPeer)
return;
time_t curTime = GetCurrentTime();
DWORD dwCount = *(DWORD *) data;
data += sizeof(DWORD);
std::vector<DWORD> vec;
sys_log(0, "BillingCheck: size %u", dwCount);
for (DWORD i = 0; i < dwCount; ++i)
{
DWORD dwKey = *(DWORD *) data;
data += sizeof(DWORD);
sys_log(0, "BillingCheck: %u", dwKey);
TLoginDataByLoginKey::iterator it = m_map_pkLoginData.find(dwKey);
if (it == m_map_pkLoginData.end())
{
sys_log(0, "BillingCheck: key not exist: %u", dwKey);
vec.push_back(dwKey);
}
else
{
CLoginData * pkLD = it->second;
if (!pkLD->IsPlay() && curTime - pkLD->GetLastPlayTime() > 180)
{
sys_log(0, "BillingCheck: not login: %u", dwKey);
vec.push_back(dwKey);
}
}
}
m_pkAuthPeer->EncodeHeader(HEADER_DG_BILLING_CHECK, 0, sizeof(DWORD) + sizeof(DWORD) * vec.size());
m_pkAuthPeer->EncodeDWORD(vec.size());
if (!vec.empty())
m_pkAuthPeer->Encode(&vec[0], sizeof(DWORD) * vec.size());
}
void CClientManager::GuildDepositMoney(TPacketGDGuildMoney* p)
{
CGuildManager::instance().DepositMoney(p->dwGuild, p->iGold);
@@ -1912,51 +1786,6 @@ void CClientManager::GuildWarBet(TPacketGDGuildWarBet * p)
CGuildManager::instance().Bet(p->dwWarID, p->szLogin, p->dwGold, p->dwGuild);
}
void CClientManager::SendAllLoginToBilling()
{
if (!m_pkAuthPeer)
return;
std::vector<TPacketBillingRepair> vec;
TPacketBillingRepair p;
TLogonAccountMap::iterator it = m_map_kLogonAccount.begin();
while (it != m_map_kLogonAccount.end())
{
CLoginData * pkLD = (it++)->second;
p.dwLoginKey = pkLD->GetKey();
strlcpy(p.szLogin, pkLD->GetAccountRef().login, sizeof(p.szLogin));
strlcpy(p.szHost, pkLD->GetIP(), sizeof(p.szHost));
sys_log(0, "SendAllLoginToBilling %s %s", pkLD->GetAccountRef().login, pkLD->GetIP());
vec.push_back(p);
}
if (!vec.empty())
{
m_pkAuthPeer->EncodeHeader(HEADER_DG_BILLING_REPAIR, 0, sizeof(DWORD) + sizeof(TPacketBillingRepair) * vec.size());
m_pkAuthPeer->EncodeDWORD(vec.size());
m_pkAuthPeer->Encode(&vec[0], sizeof(TPacketBillingRepair) * vec.size());
}
}
void CClientManager::SendLoginToBilling(CLoginData * pkLD, bool bLogin)
{
if (!m_pkAuthPeer)
return;
TPacketBillingLogin p;
p.dwLoginKey = pkLD->GetKey();
p.bLogin = bLogin ? 1 : 0;
DWORD dwCount = 1;
m_pkAuthPeer->EncodeHeader(HEADER_DG_BILLING_LOGIN, 0, sizeof(DWORD) + sizeof(TPacketBillingLogin));
m_pkAuthPeer->EncodeDWORD(dwCount);
m_pkAuthPeer->Encode(&p, sizeof(TPacketBillingLogin));
}
void CClientManager::CreateObject(TPacketGDCreateObject * p)
{
using namespace building;
@@ -2536,14 +2365,6 @@ void CClientManager::ProcessPackets(CPeer * peer)
SetEventFlag((TPacketSetEventFlag*) data);
break;
case HEADER_GD_BILLING_EXPIRE:
BillingExpire((TPacketBillingExpire *) data);
break;
case HEADER_GD_BILLING_CHECK:
BillingCheck(data);
break;
case HEADER_GD_CREATE_OBJECT:
CreateObject((TPacketGDCreateObject *) data);
break;
@@ -2743,7 +2564,6 @@ void CClientManager::RemovePeer(CPeer * pPeer)
if (pkLD->IsPlay())
{
pkLD->SetPlay(false);
SendLoginToBilling(pkLD, false);
}
if (pkLD->IsDeleted())

View File

@@ -337,12 +337,6 @@ class CClientManager : public CNetBase, public singleton<CClientManager>
void SetEventFlag(TPacketSetEventFlag* p);
void SendEventFlagsOnSetup(CPeer* peer);
void BillingExpire(TPacketBillingExpire * p);
void BillingCheck(const char * data);
void SendAllLoginToBilling();
void SendLoginToBilling(CLoginData * pkLD, bool bLogin);
// 결혼
void MarriageAdd(TPacketMarriageAdd * p);
void MarriageUpdate(TPacketMarriageUpdate * p);

View File

@@ -56,7 +56,6 @@ bool CClientManager::DeleteLogonAccount(const char * c_pszLogin, DWORD dwHandle)
if (pkLD->IsPlay())
{
pkLD->SetPlay(false);
SendLoginToBilling(pkLD, false);
}
if (pkLD->IsDeleted())

View File

@@ -244,7 +244,6 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
pTab = c->Get();
pkLD->SetPlay(true);
SendLoginToBilling(pkLD, true);
thecore_memcpy(pTab->aiPremiumTimes, pkLD->GetPremiumPtr(), sizeof(pTab->aiPremiumTimes));
peer->EncodeHeader(HEADER_DG_PLAYER_LOAD_SUCCESS, dwHandle, sizeof(TPlayerTable));
@@ -651,7 +650,6 @@ void CClientManager::RESULT_PLAYER_LOAD(CPeer * peer, MYSQL_RES * pRes, ClientHa
}
pkLD->SetPlay(true);
SendLoginToBilling(pkLD, true);
thecore_memcpy(tab.aiPremiumTimes, pkLD->GetPremiumPtr(), sizeof(tab.aiPremiumTimes));
peer->EncodeHeader(HEADER_DG_PLAYER_LOAD_SUCCESS, pkInfo->dwHandle, sizeof(TPlayerTable));

View File

@@ -11,8 +11,6 @@ CLoginData::CLoginData()
memset(m_szIP, 0, sizeof(m_szIP));
m_bPlay = false;
m_bDeleted = false;
m_bBillType = 0;
m_dwBillID = 0;
m_lastPlayTime = 0;
m_dwLastPlayerID = 0;

View File

@@ -29,12 +29,6 @@ class CLoginData
void SetDeleted(bool bSet);
bool IsDeleted();
void SetBillID(DWORD id) { m_dwBillID = id; }
DWORD GetBillID() { return m_dwBillID; }
void SetBillType(BYTE type) { m_bBillType = type; }
BYTE GetBillType() { return m_bBillType; }
time_t GetLastPlayTime() { return m_lastPlayTime; }
void SetPremium(int * paiPremiumTimes);
@@ -53,8 +47,6 @@ class CLoginData
bool m_bPlay;
bool m_bDeleted;
BYTE m_bBillType;
DWORD m_dwBillID;
time_t m_lastPlayTime;
int m_aiPremiumTimes[PREMIUM_MAX_NUM];

View File

@@ -70,8 +70,6 @@ BYTE g_bAuthServer = false;
bool g_bCheckClientVersion = true;
string g_stClientVersion = "1215955205";
BYTE g_bBilling = false;
string g_stAuthMasterIP;
WORD g_wAuthMasterPort = 0;
@@ -657,11 +655,6 @@ void config_init(const string& st_localeServiceName)
continue;
}
TOKEN("billing")
{
g_bBilling = true;
}
TOKEN("quest_dir")
{
sys_log(0, "QUEST_DIR SETTING : %s", value_string);

View File

@@ -68,7 +68,6 @@ extern void LoadStateUserCount();
extern bool g_bEmpireWhisper;
extern BYTE g_bAuthServer;
extern BYTE g_bBilling;
extern BYTE PK_PROTECT_LEVEL;

View File

@@ -1,6 +1,5 @@
#include "stdafx.h"
#include <sstream>
#include "common/billing.h"
#include "common/length.h"
#include "db.h"
@@ -197,262 +196,10 @@ void DBManager::DeleteLoginData(CLoginData * pkLD)
sys_log(0, "DeleteLoginData %s %p", pkLD->GetLogin(), pkLD);
mapLDBilling.erase(pkLD->GetLogin());
M2_DELETE(it->second);
m_map_pkLoginData.erase(it);
}
void DBManager::SetBilling(DWORD dwKey, bool bOn, bool bSkipPush)
{
std::map<DWORD, CLoginData *>::iterator it = m_map_pkLoginData.find(dwKey);
if (it == m_map_pkLoginData.end())
{
sys_err("cannot find login key %u", dwKey);
return;
}
CLoginData * ld = it->second;
itertype(mapLDBilling) it2 = mapLDBilling.find(ld->GetLogin());
if (it2 != mapLDBilling.end())
if (it2->second != ld)
DeleteLoginData(it2->second);
mapLDBilling.insert(std::make_pair(ld->GetLogin(), ld));
if (ld->IsBilling() && !bOn && !bSkipPush)
PushBilling(ld);
SendLoginPing(ld->GetLogin());
ld->SetBilling(bOn);
}
void DBManager::PushBilling(CLoginData * pkLD)
{
TUseTime t;
t.dwUseSec = (get_dword_time() - pkLD->GetLogonTime()) / 1000;
if (t.dwUseSec <= 0)
return;
pkLD->SetLogonTime();
long lRemainSecs = pkLD->GetRemainSecs() - t.dwUseSec;
pkLD->SetRemainSecs(MAX(0, lRemainSecs));
t.dwLoginKey = pkLD->GetKey();
t.bBillType = pkLD->GetBillType();
sys_log(0, "BILLING: PUSH %s %u type %u", pkLD->GetLogin(), t.dwUseSec, t.bBillType);
if (t.bBillType == BILLING_IP_FREE || t.bBillType == BILLING_IP_TIME || t.bBillType == BILLING_IP_DAY)
snprintf(t.szLogin, sizeof(t.szLogin), "%u", pkLD->GetBillID());
else
strlcpy(t.szLogin, pkLD->GetLogin(), sizeof(t.szLogin));
strlcpy(t.szIP, pkLD->GetIP(), sizeof(t.szIP));
m_vec_kUseTime.push_back(t);
}
void DBManager::FlushBilling(bool bForce)
{
if (bForce)
{
std::map<DWORD, CLoginData *>::iterator it = m_map_pkLoginData.begin();
while (it != m_map_pkLoginData.end())
{
CLoginData * pkLD = (it++)->second;
if (pkLD->IsBilling())
PushBilling(pkLD);
}
}
if (!m_vec_kUseTime.empty())
{
DWORD dwCount = 0;
std::vector<TUseTime>::iterator it = m_vec_kUseTime.begin();
while (it != m_vec_kUseTime.end())
{
TUseTime * p = &(*(it++));
// DISABLE_OLD_BILLING_CODE
if (!g_bBilling)
{
++dwCount;
continue;
}
Query("INSERT GameTimeLog (login, type, logon_time, logout_time, use_time, ip, server) "
"VALUES('%s', %u, DATE_SUB(NOW(), INTERVAL %u SECOND), NOW(), %u, '%s', '%s')",
p->szLogin, p->bBillType, p->dwUseSec, p->dwUseSec, p->szIP, g_stHostname.c_str());
// DISABLE_OLD_BILLING_CODE_END
switch (p->bBillType)
{
case BILLING_FREE:
case BILLING_IP_FREE:
break;
case BILLING_DAY:
{
if (!bForce)
{
TUseTime * pInfo = M2_NEW TUseTime;
memcpy(pInfo, p, sizeof(TUseTime));
ReturnQuery(QID_BILLING_CHECK, 0, pInfo,
"SELECT UNIX_TIMESTAMP(LimitDt)-UNIX_TIMESTAMP(NOW()),LimitTime FROM GameTime WHERE UserID='%s'", p->szLogin);
}
}
break;
case BILLING_TIME:
{
Query("UPDATE GameTime SET LimitTime=LimitTime-%u WHERE UserID='%s'", p->dwUseSec, p->szLogin);
if (!bForce)
{
TUseTime * pInfo = M2_NEW TUseTime;
memcpy(pInfo, p, sizeof(TUseTime));
ReturnQuery(QID_BILLING_CHECK, 0, pInfo,
"SELECT UNIX_TIMESTAMP(LimitDt)-UNIX_TIMESTAMP(NOW()),LimitTime FROM GameTime WHERE UserID='%s'", p->szLogin);
}
}
break;
case BILLING_IP_DAY:
{
if (!bForce)
{
TUseTime * pInfo = M2_NEW TUseTime;
memcpy(pInfo, p, sizeof(TUseTime));
ReturnQuery(QID_BILLING_CHECK, 0, pInfo,
"SELECT UNIX_TIMESTAMP(LimitDt)-UNIX_TIMESTAMP(NOW()),LimitTime FROM GameTimeIP WHERE ipid=%s", p->szLogin);
}
}
break;
case BILLING_IP_TIME:
{
Query("UPDATE GameTimeIP SET LimitTime=LimitTime-%u WHERE ipid=%s", p->dwUseSec, p->szLogin);
if (!bForce)
{
TUseTime * pInfo = M2_NEW TUseTime;
memcpy(pInfo, p, sizeof(TUseTime));
ReturnQuery(QID_BILLING_CHECK, 0, pInfo,
"SELECT UNIX_TIMESTAMP(LimitDt)-UNIX_TIMESTAMP(NOW()),LimitTime FROM GameTimeIP WHERE ipid=%s", p->szLogin);
}
}
break;
}
if (!bForce && ++dwCount >= 1000)
break;
}
if (dwCount < m_vec_kUseTime.size())
{
int nNewSize = m_vec_kUseTime.size() - dwCount;
memcpy(&m_vec_kUseTime[0], &m_vec_kUseTime[dwCount], sizeof(TUseTime) * nNewSize);
m_vec_kUseTime.resize(nNewSize);
}
else
m_vec_kUseTime.clear();
sys_log(0, "FLUSH_USE_TIME: count %u", dwCount);
}
if (m_vec_kUseTime.size() < 10240)
{
DWORD dwCurTime = get_dword_time();
std::map<DWORD, CLoginData *>::iterator it = m_map_pkLoginData.begin();
while (it != m_map_pkLoginData.end())
{
CLoginData * pkLD = (it++)->second;
if (!pkLD->IsBilling())
continue;
switch (pkLD->GetBillType())
{
case BILLING_IP_FREE:
case BILLING_FREE:
break;
case BILLING_IP_DAY:
case BILLING_DAY:
case BILLING_IP_TIME:
case BILLING_TIME:
if (pkLD->GetRemainSecs() < 0)
{
DWORD dwSecsConnected = (dwCurTime - pkLD->GetLogonTime()) / 1000;
if (dwSecsConnected % 10 == 0)
SendBillingExpire(pkLD->GetLogin(), BILLING_DAY, 0, pkLD);
}
else if (pkLD->GetRemainSecs() <= 600) // if remain seconds lower than 10 minutes
{
DWORD dwSecsConnected = (dwCurTime - pkLD->GetLogonTime()) / 1000;
if (dwSecsConnected >= 60) // 60 second cycle
{
sys_log(0, "BILLING 1 %s remain %d connected secs %u",
pkLD->GetLogin(), pkLD->GetRemainSecs(), dwSecsConnected);
PushBilling(pkLD);
}
}
else
{
DWORD dwSecsConnected = (dwCurTime - pkLD->GetLogonTime()) / 1000;
if (dwSecsConnected > (DWORD) (pkLD->GetRemainSecs() - 600) || dwSecsConnected >= 600)
{
sys_log(0, "BILLING 2 %s remain %d connected secs %u",
pkLD->GetLogin(), pkLD->GetRemainSecs(), dwSecsConnected);
PushBilling(pkLD);
}
}
break;
}
}
}
}
void DBManager::CheckBilling()
{
std::vector<DWORD> vec;
vec.push_back(0); // 카운트를 위해 미리 비워둔다.
//sys_log(0, "CheckBilling: map size %d", m_map_pkLoginData.size());
itertype(m_map_pkLoginData) it = m_map_pkLoginData.begin();
while (it != m_map_pkLoginData.end())
{
CLoginData * pkLD = (it++)->second;
if (pkLD->IsBilling())
{
sys_log(0, "BILLING: CHECK %u", pkLD->GetKey());
vec.push_back(pkLD->GetKey());
}
}
vec[0] = vec.size() - 1; // 비워둔 곳에 사이즈를 넣는다, 사이즈 자신은 제외해야 하므로 -1
db_clientdesc->DBPacket(HEADER_GD_BILLING_CHECK, 0, &vec[0], sizeof(DWORD) * vec.size());
}
void DBManager::SendLoginPing(const char * c_pszLogin)
{
TPacketGGLoginPing ptog;
@@ -485,8 +232,6 @@ void DBManager::SendAuthLogin(LPDESC d)
trim_and_lower(r.login, ptod.szLogin, sizeof(ptod.szLogin));
strlcpy(ptod.szSocialID, r.social_id, sizeof(ptod.szSocialID));
ptod.dwLoginKey = d->GetLoginKey();
ptod.bBillType = pkLD->GetBillType();
ptod.dwBillID = pkLD->GetBillID();
thecore_memcpy(ptod.iPremiumTimes, pkLD->GetPremiumPtr(), sizeof(ptod.iPremiumTimes));
thecore_memcpy(&ptod.adwClientKey, pkLD->GetClientKey(), sizeof(DWORD) * 4);
@@ -497,7 +242,7 @@ void DBManager::SendAuthLogin(LPDESC d)
SendLoginPing(r.login);
}
void DBManager::LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, LPDESC d, uint32_t * pdwClientKey, int * paiPremiumTimes)
void DBManager::LoginPrepare(LPDESC d, uint32_t * pdwClientKey, int * paiPremiumTimes)
{
const TAccountTable & r = d->GetAccountTable();
@@ -505,9 +250,6 @@ void DBManager::LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, L
pkLD->SetKey(d->GetLoginKey());
pkLD->SetLogin(r.login);
pkLD->SetBillType(bBillType);
pkLD->SetBillID(dwBillID);
pkLD->SetRemainSecs(lRemainSecs);
pkLD->SetIP(d->GetHostName());
pkLD->SetClientKey(pdwClientKey);
@@ -571,108 +313,6 @@ void DBManager::LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, L
}
}
bool GetGameTimeIP(MYSQL_RES * pRes, BYTE & bBillType, DWORD & dwBillID, int & seconds, const char * c_pszIP)
{
if (!pRes)
return true;
MYSQL_ROW row = mysql_fetch_row(pRes);
int col = 0;
str_to_number(dwBillID, row[col++]);
int ip_start = 0;
str_to_number(ip_start, row[col++]);
int ip_end = 0;
str_to_number(ip_end, row[col++]);
int type = 0;
str_to_number(type, row[col++]);
str_to_number(seconds, row[col++]);
int day_seconds = 0;
str_to_number(day_seconds, row[col++]);
char szIP[MAX_HOST_LENGTH + 1];
strlcpy(szIP, c_pszIP, sizeof(szIP));
char * p = strrchr(szIP, '.');
++p;
int ip_postfix = 0;
str_to_number(ip_postfix, p);
int valid_ip = false;
if (ip_start <= ip_postfix && ip_end >= ip_postfix)
valid_ip = true;
bBillType = BILLING_NONE;
if (valid_ip)
{
if (type == -1)
return false;
if (type == 0)
bBillType = BILLING_IP_FREE;
else if (day_seconds > 0)
{
bBillType = BILLING_IP_DAY;
seconds = day_seconds;
}
else if (seconds > 0)
bBillType = BILLING_IP_TIME;
}
return true;
}
bool GetGameTime(MYSQL_RES * pRes, BYTE & bBillType, int & seconds)
{
if (!pRes)
return true;
MYSQL_ROW row = mysql_fetch_row(pRes);
sys_log(1, "GetGameTime %p %p %p", row[0], row[1], row[2]);
int type = 0;
str_to_number(type, row[0]);
str_to_number(seconds, row[1]);
int day_seconds = 0;
str_to_number(day_seconds, row[2]);
bBillType = BILLING_NONE;
if (type == -1)
return false;
else if (type == 0)
bBillType = BILLING_FREE;
else if (day_seconds > 0)
{
bBillType = BILLING_DAY;
seconds = day_seconds;
}
else if (seconds > 0)
bBillType = BILLING_TIME;
if (!g_bBilling)
bBillType = BILLING_FREE;
return true;
}
void SendBillingExpire(const char * c_pszLogin, BYTE bBillType, int iSecs, CLoginData * pkLD)
{
TPacketBillingExpire ptod;
strlcpy(ptod.szLogin, c_pszLogin, sizeof(ptod.szLogin));
ptod.bBillType = bBillType;
ptod.dwRemainSeconds = MAX(0, iSecs);
db_clientdesc->DBPacket(HEADER_GD_BILLING_EXPIRE, 0, &ptod, sizeof(TPacketBillingExpire));
sys_log(0, "BILLING: EXPIRE %s type %d sec %d ptr %p", c_pszLogin, bBillType, iSecs, pkLD);
}
void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
{
CReturnQueryInfo * qi = (CReturnQueryInfo *) pMsg->pvUserData;
@@ -870,13 +510,8 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
d->SetMatrixCode(szMatrixCode);
if (!g_bBilling)
{
LoginPrepare(BILLING_FREE, 0, 0, d, pinfo->adwClientKey, aiPremiumTimes);
//By SeMinZ
M2_DELETE(pinfo);
break;
}
LoginPrepare(d, pinfo->adwClientKey, aiPremiumTimes);
M2_DELETE(pinfo);
sys_log(0, "QID_AUTH_LOGIN: SUCCESS %s", pinfo->login);
}
@@ -884,108 +519,6 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
}
break;
case QID_BILLING_GET_TIME:
{
TPacketCGLogin3 * pinfo = (TPacketCGLogin3 *) qi->pvData;
LPDESC d = DESC_MANAGER::instance().FindByLoginKey(qi->dwIdent);
sys_log(0, "QID_BILLING_GET_TIME: START ident %u d %p", qi->dwIdent, get_pointer(d));
if (d)
{
if (pMsg->Get()->uiNumRows == 0)
{
if (g_bBilling)
LoginFailure(d, "NOBILL");
else
LoginPrepare(BILLING_FREE, 0, 0, d, pinfo->adwClientKey);
}
else
{
int seconds = 0;
BYTE bBillType = BILLING_NONE;
if (!GetGameTime(pMsg->Get()->pSQLResult, bBillType, seconds))
{
sys_log(0, "QID_BILLING_GET_TIME: BLOCK");
LoginFailure(d, "BLOCK");
}
else if (bBillType == BILLING_NONE)
{
LoginFailure(d, "NOBILL");
sys_log(0, "QID_BILLING_GET_TIME: NO TIME");
}
else
{
LoginPrepare(bBillType, 0, seconds, d, pinfo->adwClientKey);
sys_log(0, "QID_BILLING_GET_TIME: SUCCESS");
}
}
}
M2_DELETE(pinfo);
}
break;
case QID_BILLING_CHECK:
{
TUseTime * pinfo = (TUseTime *) qi->pvData;
int iRemainSecs = 0;
CLoginData * pkLD = NULL;
if (pMsg->Get()->uiNumRows > 0)
{
MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult);
int iLimitDt = 0;
str_to_number(iLimitDt, row[0]);
int iLimitTime = 0;
str_to_number(iLimitTime, row[1]);
pkLD = GetLoginData(pinfo->dwLoginKey);
if (pkLD)
{
switch (pkLD->GetBillType())
{
case BILLING_TIME:
if (iLimitTime <= 600 && iLimitDt > 0)
{
iRemainSecs = iLimitDt;
pkLD->SetBillType(BILLING_DAY);
pinfo->bBillType = BILLING_DAY;
}
else
iRemainSecs = iLimitTime;
break;
case BILLING_IP_TIME:
if (iLimitTime <= 600 && iLimitDt > 0)
{
iRemainSecs = iLimitDt;
pkLD->SetBillType(BILLING_IP_DAY);
pinfo->bBillType = BILLING_IP_DAY;
}
else
iRemainSecs = iLimitTime;
break;
case BILLING_DAY:
case BILLING_IP_DAY:
iRemainSecs = iLimitDt;
break;
}
pkLD->SetRemainSecs(iRemainSecs);
}
}
SendBillingExpire(pinfo->szLogin, pinfo->bBillType, MAX(0, iRemainSecs), pkLD);
M2_DELETE(pinfo);
}
break;
case QID_SAFEBOX_SIZE:
{
LPCHARACTER ch = CHARACTER_MANAGER::instance().FindByPID(qi->dwIdent);
@@ -1180,14 +713,6 @@ void VCardUse(LPCHARACTER CardOwner, LPCHARACTER CardTaker, LPITEM item)
sys_log(0, "VCARD_TAKE: %u %s -> %s", p.dwID, CardOwner->GetName(), CardTaker->GetName());
}
void DBManager::StopAllBilling()
{
for (itertype(m_map_pkLoginData) it = m_map_pkLoginData.begin(); it != m_map_pkLoginData.end(); ++it)
{
SetBilling(it->first, false);
}
}
void DBManager::RequestBlockException(const char *login, int cmd)
{
TPacketBlockException packet;

View File

@@ -19,8 +19,6 @@ enum
QID_LOTTO,
QID_HIGHSCORE_REGISTER,
QID_HIGHSCORE_SHOW,
QID_BILLING_GET_TIME,
QID_BILLING_CHECK,
// BLOCK_CHAT
QID_BLOCK_CHAT_LIST,
@@ -31,7 +29,6 @@ typedef struct SUseTime
{
uint32_t dwLoginKey;
char szLogin[LOGIN_MAX_LEN+1];
uint8_t bBillType;
uint32_t dwUseSec;
char szIP[MAX_HOST_LENGTH+1];
} TUseTime;
@@ -84,19 +81,13 @@ class DBManager : public singleton<DBManager>
void SendMoneyLog(BYTE type, DWORD vnum, int gold);
void LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, LPDESC d, uint32_t * pdwClientKey, int * paiPremiumTimes = NULL);
void LoginPrepare(LPDESC d, uint32_t * pdwClientKey, int * paiPremiumTimes = NULL);
void SendAuthLogin(LPDESC d);
void SendLoginPing(const char * c_pszLogin);
void InsertLoginData(CLoginData * pkLD);
void DeleteLoginData(CLoginData * pkLD);
CLoginData * GetLoginData(DWORD dwKey);
void SetBilling(DWORD dwKey, bool bOn, bool bSkipPush = false);
void PushBilling(CLoginData * pkLD);
void FlushBilling(bool bForce=false);
void CheckBilling();
void StopAllBilling(); // 20050503.ipkn.DB-AUTH 접속 종료시 빌링 테이블 모두 지우기 (재연결시 복구함)
DWORD CountQuery() { return m_sql.CountQuery(); }
DWORD CountQueryResult() { return m_sql.CountResult(); }
@@ -125,7 +116,6 @@ class DBManager : public singleton<DBManager>
std::map<std::string, std::string> m_map_dbstring;
std::vector<std::string> m_vec_GreetMessage;
std::map<DWORD, CLoginData *> m_map_pkLoginData;
std::map<std::string, CLoginData *> mapLDBilling;
std::vector<TUseTime> m_vec_kUseTime;
};
@@ -172,7 +162,6 @@ typedef struct SHighscoreRegisterQueryInfo
bool bOrder;
} THighscoreRegisterQueryInfo;
extern void SendBillingExpire(const char * c_pszLogin, BYTE bBillType, int iSecs, CLoginData * pkLD);
extern void VCardUse(LPCHARACTER CardOwner, LPCHARACTER CardTaker, LPITEM item);

View File

@@ -95,8 +95,6 @@ void DESC::Initialize()
m_dwFileCRC = 0;
m_bHackCRCQuery = 0;
m_dwBillingExpireSecond = 0;
m_outtime = 0;
m_playtime = 0;
m_offtime = 0;
@@ -1077,16 +1075,6 @@ void DESC::AssembleCRCMagicCube(BYTE bProcPiece, BYTE bFilePiece)
}
}
void DESC::SetBillingExpireSecond(DWORD dwSec)
{
m_dwBillingExpireSecond = dwSec;
}
DWORD DESC::GetBillingExpireSecond()
{
return m_dwBillingExpireSecond;
}
BYTE DESC::GetEmpire()
{
return m_accountTable.bEmpire;

View File

@@ -176,9 +176,6 @@ class DESC
void AssembleCRCMagicCube(BYTE bProcPiece, BYTE bFilePiece);
void SetBillingExpireSecond(DWORD dwSec);
DWORD GetBillingExpireSecond();
void SetClientVersion(const char * c_pszTimestamp) { m_stClientVersion = c_pszTimestamp; }
const char * GetClientVersion() { return m_stClientVersion.c_str(); }
@@ -251,7 +248,6 @@ class DESC
DWORD m_dwFileCRC;
bool m_bHackCRCQuery;
DWORD m_dwBillingExpireSecond;
std::string m_stClientVersion;
std::string m_stMatrixCode;

View File

@@ -57,7 +57,6 @@ void CLIENT_DESC::Destroy()
CPartyManager::instance().DeleteAllParty();
CPartyManager::instance().DisablePCParty();
CGuildManager::instance().StopAllGuildWar();
DBManager::instance().StopAllBilling();
}
fdwatch_del_fd(m_lpFdw, m_sock);

View File

@@ -243,10 +243,6 @@ protected:
void SetEventFlag(const char* c_pData);
void BillingRepair(const char * c_pData);
void BillingExpire(const char * c_pData);
void BillingLogin(const char * c_pData);
void BillingCheck(const char * c_pData);
void VCard(const char * c_pData);
void CreateObject(const char * c_pData);

View File

@@ -1837,90 +1837,6 @@ void CInputDB::UpdateLand(const char * c_pData)
CManager::instance().UpdateLand((TLand *) c_pData);
}
////////////////////////////////////////////////////////////////////
// Billing
////////////////////////////////////////////////////////////////////
void CInputDB::BillingRepair(const char * c_pData)
{
DWORD dwCount = *(DWORD *) c_pData;
c_pData += sizeof(DWORD);
TPacketBillingRepair * p = (TPacketBillingRepair *) c_pData;
for (DWORD i = 0; i < dwCount; ++i, ++p)
{
CLoginData * pkLD = M2_NEW CLoginData;
pkLD->SetKey(p->dwLoginKey);
pkLD->SetLogin(p->szLogin);
pkLD->SetIP(p->szHost);
sys_log(0, "BILLING: REPAIR %s host %s", p->szLogin, p->szHost);
}
}
void CInputDB::BillingExpire(const char * c_pData)
{
TPacketBillingExpire * p = (TPacketBillingExpire *) c_pData;
LPDESC d = DESC_MANAGER::instance().FindByLoginName(p->szLogin);
if (!d)
return;
LPCHARACTER ch = d->GetCharacter();
if (p->dwRemainSeconds <= 60)
{
int i = MAX(5, p->dwRemainSeconds);
sys_log(0, "BILLING_EXPIRE: %s %u", p->szLogin, p->dwRemainSeconds);
d->DelayedDisconnect(i);
}
else
{
if ((p->dwRemainSeconds - d->GetBillingExpireSecond()) > 60)
{
d->SetBillingExpireSecond(p->dwRemainSeconds);
if (ch)
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("결재기간이 %d분 후 만료 됩니다."), (p->dwRemainSeconds / 60));
}
}
}
void CInputDB::BillingLogin(const char * c_pData)
{
if (NULL == c_pData)
return;
TPacketBillingLogin * p;
DWORD dwCount = *(DWORD *) c_pData;
c_pData += sizeof(DWORD);
p = (TPacketBillingLogin *) c_pData;
for (DWORD i = 0; i < dwCount; ++i, ++p)
{
DBManager::instance().SetBilling(p->dwLoginKey, p->bLogin);
}
}
void CInputDB::BillingCheck(const char * c_pData)
{
DWORD size = *(DWORD *) c_pData;
c_pData += sizeof(DWORD);
for (DWORD i = 0; i < size; ++i)
{
DWORD dwKey = *(DWORD *) c_pData;
c_pData += sizeof(DWORD);
sys_log(0, "BILLING: NOT_LOGIN %u", dwKey);
DBManager::instance().SetBilling(dwKey, 0, true);
}
}
void CInputDB::Notice(const char * c_pData)
{
extern void SendNotice(const char * c_pszBuf);
@@ -2319,22 +2235,6 @@ int CInputDB::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
SetEventFlag(c_pData);
break;
case HEADER_DG_BILLING_REPAIR:
BillingRepair(c_pData);
break;
case HEADER_DG_BILLING_EXPIRE:
BillingExpire(c_pData);
break;
case HEADER_DG_BILLING_LOGIN:
BillingLogin(c_pData);
break;
case HEADER_DG_BILLING_CHECK:
BillingCheck(c_pData);
break;
case HEADER_DG_VCARD:
VCard(c_pData);
break;

View File

@@ -1,5 +1,4 @@
#include "stdafx.h"
#include "common/billing.h"
#include "config.h"
#include "desc_client.h"
#include "desc_manager.h"
@@ -370,8 +369,6 @@ void CInputP2P::LoginPing(LPDESC d, const char * c_pData)
{
TPacketGGLoginPing * p = (TPacketGGLoginPing *) c_pData;
SendBillingExpire(p->szLogin, BILLING_DAY, 0, NULL);
if (!g_pkAuthMasterDesc) // If I am master, I have to broadcast
P2P_MANAGER::instance().Send(p, sizeof(TPacketGGLoginPing), d);
}

View File

@@ -8,13 +8,10 @@ CLoginData::CLoginData()
{
m_dwKey = 0;
memset(m_adwClientKey, 0, sizeof(m_adwClientKey));
m_bBillType = 0;
m_dwBillID = 0;
m_dwConnectedPeerHandle = 0;
m_dwLogonTime = 0;
m_lRemainSecs = 0;
memset(m_szIP, 0, sizeof(m_szIP));
m_bBilling = false;
m_bDeleted = false;
memset(m_aiPremiumTimes, 0, sizeof(m_aiPremiumTimes));
}
@@ -39,26 +36,6 @@ uint32_t CLoginData::GetKey()
return m_dwKey;
}
void CLoginData::SetBillType(BYTE bType)
{
m_bBillType = bType;
}
uint32_t CLoginData::GetBillID()
{
return m_dwBillID;
}
void CLoginData::SetBillID(uint32_t dwID)
{
m_dwBillID = dwID;
}
BYTE CLoginData::GetBillType()
{
return m_bBillType;
}
void CLoginData::SetConnectedPeerHandle(uint32_t dwHandle)
{
m_dwConnectedPeerHandle = dwHandle;
@@ -92,7 +69,7 @@ const char * CLoginData::GetIP()
void CLoginData::SetRemainSecs(long l)
{
m_lRemainSecs = l;
sys_log(0, "SetRemainSecs %s %d type %u", m_stLogin.c_str(), m_lRemainSecs, m_bBillType);
sys_log(0, "SetRemainSecs %s %d type %u", m_stLogin.c_str(), m_lRemainSecs);
}
long CLoginData::GetRemainSecs()
@@ -100,24 +77,6 @@ long CLoginData::GetRemainSecs()
return m_lRemainSecs;
}
void CLoginData::SetBilling(bool bOn)
{
if (bOn)
{
sys_log(0, "BILLING: ON %s key %u ptr %p", m_stLogin.c_str(), m_dwKey, this);
SetLogonTime();
}
else
sys_log(0, "BILLING: OFF %s key %u ptr %p", m_stLogin.c_str(), m_dwKey, this);
m_bBilling = bOn;
}
bool CLoginData::IsBilling()
{
return m_bBilling;
}
void CLoginData::SetDeleted(bool bSet)
{
m_bDeleted = bSet;

View File

@@ -15,12 +15,6 @@ class CLoginData
void SetLogin(const char * c_pszLogin);
const char * GetLogin();
void SetBillType(BYTE bType);
uint32_t GetBillID();
void SetBillID(uint32_t dwID);
BYTE GetBillType();
void SetConnectedPeerHandle(uint32_t dwHandle);
uint32_t GetConnectedPeerHandle();
@@ -33,9 +27,6 @@ class CLoginData
void SetRemainSecs(long l);
long GetRemainSecs();
void SetBilling(bool bOn);
bool IsBilling();
void SetDeleted(bool bSet);
bool IsDeleted();
@@ -47,13 +38,10 @@ class CLoginData
private:
uint32_t m_dwKey;
uint32_t m_adwClientKey[4];
uint8_t m_bBillType;
uint32_t m_dwBillID;
uint32_t m_dwConnectedPeerHandle;
uint32_t m_dwLogonTime;
long m_lRemainSecs;
char m_szIP[MAX_HOST_LENGTH+1];
bool m_bBilling;
bool m_bDeleted;
std::string m_stLogin;
int m_aiPremiumTimes[PREMIUM_MAX_NUM];

View File

@@ -257,11 +257,6 @@ void heartbeat(LPHEART ht, int pulse)
else
{
DESC_MANAGER::instance().ProcessExpiredLoginKey();
DBManager::instance().FlushBilling();
/*
if (!(pulse % (ht->passes_per_sec * 600)))
DBManager::instance().CheckBilling();
*/
}
{
@@ -555,8 +550,6 @@ int main(int argc, char **argv)
if (g_bAuthServer)
{
DBManager::instance().FlushBilling(true);
int iLimit = DBManager::instance().CountQuery() / 50;
int i = 0;