📄 azitmanager.cpp
字号:
// AzitManager.cpp: implementation of the AzitManager class.
//
//
//
////////////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "command.h"
#include "Azit.h"
#include "AzitManager.h"
#include "MapDBAccess.h" // DATA BASE
#include "DBSocket.h"
#include "Map.h"
#include "CLog.h"
////////////////////////////////////////////////////////////////////////////////////////
// Global 函荐
////////////////////////////////////////////////////////////////////////////////////////
extern CDBConnection g_AccountDB; // AccountDB
extern Map *g_pMap; // Map
extern _LPDBSOCK g_lpDBSock; // DB Socket
extern _LPCLOGMANAGER g_lpLog ; // Log
#ifdef DEF_AZIT
////////////////////////////////////////////////////////////////////////////////////////
// Construction/Destruction
//
// - AZITCHART Load From CHAR-DB
// - AZITTEXCHART Load From CHARD-DB
////////////////////////////////////////////////////////////////////////////////////////
AzitManager::AzitManager()
{
m_MapAzit.Clear();
//
// Load Azit Tax Chart
//
m_MapAzitTaxChart.Clear();
Table_AzitTaxChart tbAzitTexChart;
if(tbAzitTexChart.Open( &g_AccountDB ))
{
while(tbAzitTexChart.Fetch())
{
_AZITTAX_CHART_ *pAzitTexChart = new _AZITTAX_CHART_;
pAzitTexChart->nMapID = tbAzitTexChart.m_nMapID;
pAzitTexChart->nAzitHandle = tbAzitTexChart.m_nAzitHandle;
m_MapAzitTaxChart.Insert( pAzitTexChart->nMapID, pAzitTexChart );
}
}
}
AzitManager::~AzitManager()
{
//
// Clean AZIT Memory
//
for ( MAP_VOIDPTR::iterator it = m_MapAzit.Begin(); it != m_MapAzit.End(); it++)
{
Azit *pAzit = (Azit *)it->second;
if( !pAzit ) continue;
SAFE_DELETE<Azit> (&pAzit);
}
m_MapAzit.Clear();
//
// Clean AZIT TAX CHART
//
for ( it = m_MapAzitTaxChart.Begin(); it != m_MapAzitTaxChart.End(); it++)
{
_AZITTAX_CHART_ *pAzitTexChart = (_AZITTAX_CHART_ *)it->second;
if( !pAzitTexChart ) continue;
SAFE_DELETE<_AZITTAX_CHART_> (&pAzitTexChart);
}
m_MapAzitTaxChart.Clear();
}
////////////////////////////////////////////////////////////////////////////////////////
// 酒瘤飘甫 固府 积己矫糯
//
////////////////////////////////////////////////////////////////////////////////////////
void AzitManager::CreateAzit(int pAzitHandle)
{
Azit *pAzit = new Azit( true );
m_MapAzit.Insert( pAzitHandle, pAzit );
}
////////////////////////////////////////////////////////////////////////////////////////
// Azit沥焊甫 涝仿矫糯
//
// - N(2byte) + {ZW_STATUSAZITLIST_REP}(n)
// - 秦寸 甘俊 酒瘤飘 家蜡 咯何甫 魄沥
////////////////////////////////////////////////////////////////////////////////////////
void AzitManager::SetAzitList(_LPDBPACKET pWorldPacket)
{
char *lpReadData = pWorldPacket->strPacket;
WORD *lpReadNum = (WORD *) lpReadData ;
WORD nReadNum = (WORD) (*lpReadNum);
lpReadData += sizeof(WORD);
ErrorMsg("(T) AZIT LIST" );
//
// 酒瘤飘 沥焊甫 涝仿 矫糯
//
while ((nReadNum)-- > 0 )
{
_LPZW_AZITSTATUSLIST_REP pAzitData = (_LPZW_AZITSTATUSLIST_REP ) lpReadData ;
//
// 酒瘤飘 沥焊甫 涝仿矫糯
//
// - 秦寸 甘俊 Azit Map阑 器窃窍绊 乐绰 版快 贸府
//
//
// 酒瘤飘啊 粮犁 窍绰 版快 贸府
//
Azit *pAzit = (Azit *)m_MapAzit.Find( pAzitData->dwAzitSeq );
//
// 酒瘤飘啊 积己登绢 乐绰 版快
//
if( pAzit )
{
SetAzitUpdate( pAzitData );
ErrorMsg("(T) AZIT UPDATE=%d", pAzitData->dwAzitSeq );
}
//
// 酒瘤飘 沥焊啊 绝绰 版快
//
else
{
// Azit *pAzit = new Azit( pAzitData );
pAzit = new Azit( pAzitData );
m_MapAzit.Insert( pAzitData->dwAzitSeq, pAzit );
// pAzit->ForTesting(); // For Testing ...
ErrorMsg("(T) AZIT INSERT=%d", pAzitData->dwAzitSeq );
}
/*
* 秦寸 AZIT狼 NPC / MONSTER俊 辨靛 沥焊甫 涝仿矫糯
*
* - 眠饶 包访 风凭阑 Function栏肺 盒府矫糯
*/
void* ListNPC[10000] = {0, };
int nCountNPC;
for(int iLayer= 0 ; iLayer < g_pMap->m_nMaxLayer; ++iLayer )
{
//
// AZIT MAP俊 加茄 MONSTER俊 秦寸 辨靛 沥焊 涝仿
//
if( MAP_AZIT == g_pMap->MapConfig[iLayer].nMapType )
{
nCountNPC = g_pMap->m_MapNPC[iLayer]->CopyTmpList( ListNPC );
for( int i=0; i< nCountNPC; ++i )
{
NPC *pNPC = (NPC *)ListNPC[i];
if( !pNPC ) continue;
if( pNPC->GetChannel() == pAzitData->dwAzitSeq )
{
// 家蜡 辨靛 沥焊甫 涝仿矫糯
pNPC->m_dwGuildHandle = pAzitData->dwGuildHandle;
}
}
}
}
lpReadData += sizeof(_ZW_AZITSTATUSLIST_REP) ;
}
}
////////////////////////////////////////////////////////////////////////////////////////
// 酒瘤飘郴狼 捞悼 沥焊甫 茫酒 馆券矫糯
//
// - 眠饶 Guild包访 备炼眉俊辑 包访 沥焊甫 楷悼矫糯
//
////////////////////////////////////////////////////////////////////////////////////////
bool AzitManager::GetAzitLocationInfo( int pGuildHandle, _MOVEMAP_ *pMoveMap)
{
bool bFound = false;
// 包访 沥焊甫 掘澜
for ( MAP_VOIDPTR::iterator it = m_MapAzit.Begin(); it != m_MapAzit.End(); it++)
{
Azit *pAzit = (Azit *)it->second;
if( !pAzit ) continue;
_LPZW_AZITSTATUSLIST_REP AzitInfo = pAzit->GetAzit();
if( pAzit->GetOwnerHandle() == pGuildHandle )
{
pMoveMap->dwMapID = AzitInfo->dwMapID; // 甘 沥焊 单捞鸥 涝仿
pMoveMap->wX = AzitInfo->dwX;
pMoveMap->wY = AzitInfo->dwY;
bFound = true; // 秦寸 Loop俊辑 狐廉 唱咳
break;
}
//
// 酒瘤飘 傈 惑怕 & 酒瘤飘 档傈磊牢 版快
//
else if( (pAzit->GetAzitStatus() == AZITSTATUS_WARREADY ||
pAzit->GetAzitStatus() == AZITSTATUS_WAR) &&
pAzit->GetWarProposeHandle() == pGuildHandle )
{
pMoveMap->dwMapID = AzitInfo->dwMapID; // 甘 沥焊 单捞鸥 涝仿
pMoveMap->wX = AzitInfo->dwX;
pMoveMap->wY = AzitInfo->dwY;
bFound = true; // 秦寸 Loop俊辑 狐廉 唱咳
break;
}
}
if( !bFound ) return false;
return true;
}
////////////////////////////////////////////////////////////////////////////////////////
// 秦寸 技陛 刘荐 甘辑滚甫 沥焊甫 掘澜
//
// - 魄概陛咀狼 5%究 涝陛矫糯
////////////////////////////////////////////////////////////////////////////////////////
bool AzitManager::SetAzitTex(int pMapID, int pTax )
{
//
// 秦寸 酒瘤飘 甘苞 技陛 沥焊甫 掘澜
//
_AZITTAX_CHART_ *pAzitTexChart = (_AZITTAX_CHART_*)m_MapAzitTaxChart.Find( pMapID );
if( !pAzitTexChart ) return false;
// 秦寸 酒瘤飘甫 茫澜
Azit *pAzit = (Azit*)m_MapAzit.Find( pAzitTexChart->nAzitHandle );
if( !pAzit ) return false;
// 魄概 陛咀阑 涝仿矫糯
pAzit->SetTax( pTax );
return true;
}
////////////////////////////////////////////////////////////////////////////////////////
// 酒瘤飘 沥焊甫 诀单捞飘矫糯
//
//
////////////////////////////////////////////////////////////////////////////////////////
void AzitManager::SetAzitUpdate(_LPZW_AZITSTATUSUPDATE_REP pAzitInfo)
{
// 秦寸 酒瘤飘 沥焊甫 茫澜
Azit *pAzit = (Azit*)m_MapAzit.Find( pAzitInfo->dwAzitSeq );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -