383 lines
12 KiB
C++
383 lines
12 KiB
C++
#include "StdAfx.h"
|
|
|
|
//_NA_005026_20120527_CHAOS_ZONE_BATTLE_GROUND
|
|
#include ".\BattleGroundInfoParser.h"
|
|
//------------------------------------------------------------------------------
|
|
BattleGroundInfoParser::BattleGroundInfoParser(void)
|
|
{
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
BattleGroundInfoParser::~BattleGroundInfoParser(void)
|
|
{
|
|
}
|
|
VOID BattleGroundInfoParser::Init()
|
|
{
|
|
}
|
|
|
|
VOID BattleGroundInfoParser::Init(char * pszPackFileName)
|
|
{
|
|
SetPackFileName(pszPackFileName);
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
void BattleGroundInfoParser::Release()
|
|
{
|
|
Unload();
|
|
}
|
|
|
|
void BattleGroundInfoParser::Unload()
|
|
{
|
|
_UnloadBattleGroundInfo();
|
|
|
|
#ifdef _NA_008679_20160202_REWORK_BATTLEGROUND
|
|
_UnloadCostumeInfo();
|
|
_UnloadWeaponInfo();
|
|
#endif //_NA_008679_20160202_REWORK_BATTLEGROUND
|
|
}
|
|
|
|
BOOL BattleGroundInfoParser::_Load(BOOL bReload)
|
|
{
|
|
if (bReload == TRUE)
|
|
{
|
|
_UnloadBattleGroundInfo();
|
|
}
|
|
|
|
int nRowSize = GetRowSize();
|
|
for (int nRow = 0; nRow < nRowSize; ++nRow)
|
|
{
|
|
BattleGroundInfo* info = new BattleGroundInfo();
|
|
|
|
info->index = GetDataBYTE("Index", nRow);
|
|
info->map_code = GetDataDWORD("MapCode", nRow);
|
|
info->limit_level = GetDataDWORD("LimitLv", nRow);
|
|
info->equipment_rating = GetDataDWORD("EquipmentRating", nRow);
|
|
info->team_max = GetDataBYTE("TeamMAX", nRow);
|
|
info->max_party = GetDataBYTE("MAXParty", nRow);
|
|
info->start_time = GetDataDWORD("StartTime", nRow);
|
|
info->entry_time = GetDataDWORD("EntryTime", nRow);
|
|
info->prepare_condition_code = GetDataDWORD("PrepareConCode", nRow);
|
|
info->prepare_time = GetDataDWORD("PrepareTime", nRow);
|
|
info->gate_trigger_id = GetDataDWORD("GateTriggerID", nRow);
|
|
info->goal_score = GetDataDWORD("GoalScore", nRow);
|
|
info->sealing_time = GetDataDWORD("SealingTime", nRow);
|
|
info->conquer_wait_time = GetDataDWORD("ConquerWaitTime", nRow);
|
|
info->gather_point = GetDataDWORD("GatherPoint", nRow);
|
|
info->gather_period = GetDataDWORD("GatherPeriod", nRow);
|
|
#ifdef _NA_006599_20130401_BATTLEGROUND_PKPOINT
|
|
info->pk_point = GetDataBYTE("PkPoint", nRow);
|
|
#endif
|
|
info->dead_time = GetDataDWORD("DeadTime", nRow);
|
|
info->resurrection_period = GetDataDWORD("ResPeriod", nRow);
|
|
info->resurrection_condition_code = GetDataDWORD("ResConCode", nRow);
|
|
info->iron_mode = GetDataDWORD("IronMode", nRow);
|
|
info->abusing_point = GetDataDWORD("AbusingPoint", nRow);
|
|
info->win_reward_code = GetDataDWORD("WinItemCode", nRow);
|
|
info->base_reward_code = GetDataDWORD("BaseItemCode", nRow);
|
|
info->penalty_reward_code = GetDataDWORD("PenaltyItemCode", nRow);
|
|
#ifdef _NA_008679_20160202_REWORK_BATTLEGROUND
|
|
info->mismatch_reward_code = GetDataDWORD("MismatchItemCode", nRow);
|
|
info->basic_point = GetDataBYTE("BasicPoint", nRow);
|
|
#endif //_NA_008679_20160202_REWORK_BATTLEGROUND
|
|
|
|
TCHAR* item_limit_text[10] = {"LimitIT01", "LimitIT02", "LimitIT03", "LimitIT04",
|
|
"LimitIT05", "LimitIT06", "LimitIT07", "LimitIT08", "LimitIT09", "LimitIT10"};
|
|
|
|
for (int i = 0; i < BattleGroundInfo::MAX_ITEM_LIMIT_COUNT; ++i)
|
|
{
|
|
info->limit_item[i] = GetDataDWORD(item_limit_text[i], nRow);
|
|
}
|
|
|
|
info->draw_time = GetDataDWORD("DrawTime", nRow);
|
|
info->re_enter_condiion = GetDataDWORD("ReEnterCon", nRow);
|
|
info->re_enter_condition_period = GetDataDWORD("ReEnterConPeriod", nRow);
|
|
info->exit_condition = GetDataDWORD("BGESCCon", nRow);
|
|
info->exit_period = GetDataDWORD("BGESCPeriod", nRow);
|
|
|
|
#ifdef _NA_008679_20160202_REWORK_BATTLEGROUND
|
|
info->team_min = GetDataBYTE("TeamMIN", nRow);
|
|
#else
|
|
info->max_match_time = GetDataDWORD("MaxMatchTime", nRow);
|
|
#endif //_NA_008679_20160202_REWORK_BATTLEGROUND
|
|
|
|
BattleGroundInfo_Hash::_Pairib result = battlegroundinfo_hash().insert(
|
|
BattleGroundInfo_Hash::value_type(static_cast<DWORD>(info->map_code), info));
|
|
ASSERT(result.second == true);
|
|
}
|
|
return TRUE;
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
BOOL BattleGroundInfoParser::LoadScript(eSCRIPT_CODE scriptCode, BOOL bReload)
|
|
{
|
|
switch (scriptCode)
|
|
{
|
|
case SCRIPT_BATTLE_GROUND_INFO:
|
|
return _Load(bReload);
|
|
#ifdef _NA_008679_20160202_REWORK_BATTLEGROUND
|
|
case SCRIPT_BATTLE_GROUND_COSTUME:
|
|
return _LoadCostumeInfo(bReload);
|
|
case SCRIPT_BATTLE_GROUND_WEAPON:
|
|
return _LoadWeaponInfo(bReload);
|
|
#endif //_NA_008679_20160202_REWORK_BATTLEGROUND
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
const BattleGroundInfo* BattleGroundInfoParser::FindData(const MAPCODE map_code) const
|
|
{
|
|
BattleGroundInfo_Hash::const_iterator begin_iterator = battlegroundinfo_hash_.begin(),
|
|
end_iterator = battlegroundinfo_hash_.end();
|
|
|
|
for (; begin_iterator != end_iterator; ++begin_iterator)
|
|
{
|
|
const BattleGroundInfo* find_info = begin_iterator->second;
|
|
if (find_info->map_code == map_code)
|
|
{
|
|
return find_info;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
VOID BattleGroundInfoParser::_UnloadBattleGroundInfo()
|
|
{
|
|
BattleGroundInfo_Hash::const_iterator it, end( battlegroundinfo_hash_.end() );
|
|
for(it = battlegroundinfo_hash_.begin() ; it != end ; ++it)
|
|
{
|
|
BattleGroundInfo* info = (it->second);
|
|
SAFE_DELETE(info);
|
|
}
|
|
|
|
battlegroundinfo_hash_.clear();
|
|
}
|
|
|
|
#ifdef _NA_008679_20160202_REWORK_BATTLEGROUND
|
|
|
|
BOOL BattleGroundInfoParser::_LoadCostumeInfo( BOOL _reload )
|
|
{
|
|
if (_reload == TRUE)
|
|
{
|
|
_UnloadCostumeInfo();
|
|
}
|
|
|
|
int nRowSize = GetRowSize();
|
|
for (int nRow = 0; nRow < nRowSize; ++nRow)
|
|
{
|
|
BattleGroundCostumeInfo info;
|
|
info.index = GetDataBYTE("Index", nRow);
|
|
info.class_code = GetDataBYTE("BClassCode", nRow);
|
|
info.enchant = GetDataBYTE("Enchant", nRow);
|
|
info.costume_code1 = GetDataWORD("NpcCostumeItem1", nRow);
|
|
info.costume_code2 = GetDataWORD("NpcCostumeItem2", nRow);
|
|
info.armor_item_code = GetDataWORD("ArmorImage", nRow);
|
|
info.helm_item_code = GetDataWORD("HelmImage", nRow);
|
|
info.pants_item_code = GetDataWORD("PantsImage", nRow);
|
|
info.boots_item_code = GetDataWORD("BootImage", nRow);
|
|
info.gloves_item_code = GetDataWORD("GloveImage", nRow);
|
|
info.probability = GetDataBYTE("Probability", nRow);
|
|
|
|
BattleCostumeInfoMap::iterator itr = costumeinfo_map_.find(info.index);
|
|
if (itr == costumeinfo_map_.end())
|
|
{
|
|
BattleCostumeList* costume_list = new BattleCostumeList;
|
|
costumeinfo_map_.insert(std::make_pair(info.index, costume_list));
|
|
|
|
costume_list->push_back(info);
|
|
|
|
// randomizer setting
|
|
costume_randomizer_.AddRatio(info.index, info.probability, 100);
|
|
}
|
|
else
|
|
{
|
|
BattleCostumeList* costume_list = itr->second;
|
|
if (costume_list != NULL)
|
|
{
|
|
costume_list->push_back(info);
|
|
}
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL BattleGroundInfoParser::_LoadWeaponInfo( BOOL _reload )
|
|
{
|
|
if (_reload == TRUE)
|
|
{
|
|
_UnloadCostumeInfo();
|
|
}
|
|
|
|
int nRowSize = GetRowSize();
|
|
for (int nRow = 0; nRow < nRowSize; ++nRow)
|
|
{
|
|
BattleGroundWeaponInfo info;
|
|
info.index = GetDataBYTE("Index", nRow);
|
|
info.class_code = GetDataBYTE("BClassCode", nRow);
|
|
info.enchant = GetDataBYTE("Enchant", nRow);
|
|
|
|
info.weapon_type_A = (eWEAPONTYPE)(GetDataBYTE("WeaponTypeA", nRow));
|
|
info.weapon_item_code_A = GetDataWORD("WeaponImageA", nRow);
|
|
|
|
info.weapon_type_B = (eWEAPONTYPE)(GetDataBYTE("WeaponTypeB", nRow));
|
|
info.weapon_item_code_B = GetDataWORD("WeaponImageB", nRow);
|
|
|
|
info.probability = GetDataBYTE("Probability", nRow);
|
|
|
|
BattleWeaponInfoMap::iterator itr = weaponinfo_map_.find(info.index);
|
|
if (itr == weaponinfo_map_.end())
|
|
{
|
|
BattleWeaponList* weapon_list = new BattleWeaponList;
|
|
weaponinfo_map_.insert(std::make_pair(info.index, weapon_list));
|
|
|
|
weapon_list->push_back(info);
|
|
|
|
// randomizer setting
|
|
weapon_randomizer_.AddRatio(info.index, info.probability, 100);
|
|
}
|
|
else
|
|
{
|
|
BattleWeaponList* weapon_list = itr->second;
|
|
if (weapon_list != NULL)
|
|
{
|
|
weapon_list->push_back(info);
|
|
}
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
VOID BattleGroundInfoParser::_UnloadCostumeInfo()
|
|
{
|
|
while (costumeinfo_map_.empty() == false)
|
|
{
|
|
BattleCostumeInfoMap::iterator itr = costumeinfo_map_.begin();
|
|
if (itr == costumeinfo_map_.end()) {
|
|
break;
|
|
}
|
|
|
|
BattleCostumeList* costume_list = itr->second;
|
|
if (costume_list == NULL) {
|
|
continue;
|
|
}
|
|
|
|
costume_list->clear();
|
|
SAFE_DELETE(costume_list);
|
|
costumeinfo_map_.erase(itr);
|
|
}
|
|
costumeinfo_map_.clear();
|
|
costume_randomizer_.Clear();
|
|
}
|
|
|
|
VOID BattleGroundInfoParser::_UnloadWeaponInfo()
|
|
{
|
|
while (weaponinfo_map_.empty() == false)
|
|
{
|
|
BattleWeaponInfoMap::iterator itr = weaponinfo_map_.begin();
|
|
if (itr == weaponinfo_map_.end()) {
|
|
break;
|
|
}
|
|
|
|
BattleWeaponList* weapon_list = itr->second;
|
|
if (weapon_list == NULL) {
|
|
continue;
|
|
}
|
|
|
|
weapon_list->clear();
|
|
SAFE_DELETE(weapon_list);
|
|
weaponinfo_map_.erase(itr);
|
|
}
|
|
weaponinfo_map_.clear();
|
|
weapon_randomizer_.Clear();
|
|
}
|
|
|
|
SLOTCODE BattleGroundInfoParser::GetRandomBattleCostumeCode()
|
|
{
|
|
// Costume
|
|
BYTE costume_index = costume_randomizer_.RandomizedKey();
|
|
BYTE weapon_index = weapon_randomizer_.RandomizedKey();
|
|
|
|
SLOTCODE false_code = MAKEWORD(weapon_index, costume_index);
|
|
//HIBYTE : ÄÚ½ºÆ¬ / LOBYTE : ¹«±â
|
|
|
|
return false_code;
|
|
}
|
|
|
|
#ifdef _SERVER
|
|
#else
|
|
BattleGroundCostumeInfo* BattleGroundInfoParser::GetBattleGroundCostumeInfo(BYTE costume_index, eCHAR_TYPE class_code)
|
|
{
|
|
BattleCostumeInfoMap::iterator itr = costumeinfo_map_.find(costume_index);
|
|
if (itr == costumeinfo_map_.end())
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
BattleCostumeList* costume_list = itr->second;
|
|
|
|
BattleCostumeList::iterator iter = costume_list->begin();
|
|
BattleCostumeList::const_iterator end_iter = costume_list->end();
|
|
for ( ; iter != end_iter; ++iter)
|
|
{
|
|
if (iter->class_code == class_code)
|
|
{
|
|
BattleGroundCostumeInfo* info = &(*iter);
|
|
return info;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
BattleGroundWeaponInfo* BattleGroundInfoParser::GetBattleGroundWeaponInfo(BYTE costume_index, eCHAR_TYPE class_code)
|
|
{
|
|
BattleWeaponInfoMap::iterator itr = weaponinfo_map_.find(costume_index);
|
|
if (itr == weaponinfo_map_.end())
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
BattleWeaponList* weapon_list = itr->second;
|
|
|
|
BattleWeaponList::iterator iter = weapon_list->begin();
|
|
BattleWeaponList::const_iterator end_iter = weapon_list->end();
|
|
for ( ; iter != end_iter; ++iter)
|
|
{
|
|
if (iter->class_code == class_code)
|
|
{
|
|
BattleGroundWeaponInfo* info = &(*iter);
|
|
return info;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
DWORD BattleGroundInfoParser::GetBattleGroundWeaponItemCode(BYTE costume_index, eCHAR_TYPE class_code, DWORD weapon_kind)
|
|
{
|
|
BattleWeaponInfoMap::iterator itr = weaponinfo_map_.find(costume_index);
|
|
if (itr == weaponinfo_map_.end())
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
BattleWeaponList* weapon_list = itr->second;
|
|
|
|
BattleWeaponList::iterator iter = weapon_list->begin();
|
|
BattleWeaponList::const_iterator end_iter = weapon_list->end();
|
|
for ( ; iter != end_iter; ++iter)
|
|
{
|
|
if (iter->class_code == class_code)
|
|
{
|
|
if (iter->weapon_type_A == weapon_kind)
|
|
{
|
|
return iter->weapon_item_code_A;
|
|
}
|
|
else if (iter->weapon_type_B == weapon_kind)
|
|
{
|
|
return iter->weapon_item_code_B;
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
#endif //_SERVER
|
|
#endif //_NA_008679_20160202_REWORK_BATTLEGROUND
|