#include "StdAfx.h" #include ".\armordamageparser.h" #include ArmorDamageParser::ArmorDamageParser(void) : armor_damage_table_(NULL) { } ArmorDamageParser::~ArmorDamageParser(void) { } VOID ArmorDamageParser::Init(DWORD pool_size) { __UNUSED(pool_size); //#if !defined(_NA001605_EP2_ATTRIBUTES_RENEWAL_) armor_damage_table_ = new ARMOR_DAMAGEINFO_HASH; armor_damage_table_->Initialize(pool_size); //#endif } VOID ArmorDamageParser::Release() { #if !defined(_NA001605_EP2_ATTRIBUTES_RENEWAL_) unload(); SAFE_DELETE(armor_damage_table_); #endif } VOID ArmorDamageParser::unload() { if (armor_damage_table_ != NULL) { ARMOR_DAMAGE_INFO* armor_damage_info = NULL; ARMOR_DAMAGEINFO_ITER pos = armor_damage_table_->begin(); ARMOR_DAMAGEINFO_ITER end_pos = armor_damage_table_->end(); for (; pos != end_pos; ++pos) { armor_damage_info = *pos; SAFE_DELETE(armor_damage_info); } armor_damage_table_->RemoveAll(); } } BOOL ArmorDamageParser::load(BOOL is_reload) { __UNUSED(is_reload); //#if !defined(_NA001605_EP2_ATTRIBUTES_RENEWAL_) const int row_size = GetRowSize(); for (int row = 0; row < row_size; ++row) { // (CHANGES)(20100309)(hukim) armor_damage_table_俊 虐肺 火涝窍扁 锭巩俊 index绰 荤侩登瘤 臼 // 扁 锭巩俊 林籍贸府, 叼滚彪 捞惑狼 狼固档 绝绊 楷魂 扯厚捞促. //const WORD index = GetDataWORD("Index", row); const BYTE weapon_type = GetDataBYTE("WeaponType", row); const BYTE armor_type = GetDataBYTE("ArmorType", row); const WORD armor_damage_info_key = make_key(armor_type, weapon_type); ARMOR_DAMAGE_INFO* armor_damage_info = armor_damage_table_->GetData(armor_damage_info_key); if (armor_damage_info == NULL) { armor_damage_info = new ARMOR_DAMAGE_INFO; armor_damage_table_->Add(armor_damage_info, armor_damage_info_key); } else { if (is_reload == FALSE) { SUNLOG(eCRITICAL_LOG, _T("脚本文件数据错误, 盔甲类型 = %d, 攻击类型 = %d"), armor_type, weapon_type ); ASSERT(!"数据有错误."); } } armor_damage_info->byWeaponType = weapon_type; armor_damage_info->byArmorType = armor_type; armor_damage_info->Damage = GetDataWORD("DamageRatio", row); if (armor_damage_info->Damage == 0) { SUNLOG(eCRITICAL_LOG, _T(" 装甲类伤害为0 ")); } } //#endif return TRUE; } DAMAGETYPE ArmorDamageParser::FindDamageRatio(BYTE armor_type, BYTE attack_type) const { __UNUSED((attack_type, armor_type)); //#if !defined(_NA001605_EP2_ATTRIBUTES_RENEWAL_) WORD armor_damage_info_key = make_key(armor_type, attack_type); ARMOR_DAMAGEINFO_ITER pos = armor_damage_table_->find(armor_damage_info_key); ARMOR_DAMAGE_INFO* armor_damage_info = *pos; if (armor_damage_info == NULL) { SUNLOG(eCRITICAL_LOG, _T("盔甲类型伤害不存在! armor_type[%d] attack_type[%d]\n"), armor_type, attack_type); } else { return armor_damage_info->Damage; } //#endif return 100; } //---------------------------------------------------------------------------- /** wArmorType | wAttackType | 8bit | 8bit | */ WORD ArmorDamageParser::make_key(BYTE armor_type, BYTE attack_type) const { return WORD((WORD(armor_type) << 8) | WORD(attack_type)); } BOOL ArmorDamageParser::LoadScript(eSCRIPT_CODE script_code, BOOL is_reload) { switch(script_code) { case SCRIPT_ARMORTYPEDAMAGEINFO: return load(is_reload); }; return FALSE; }