#include "stdafx.h" #include #include "ProtoReader.h" #include #include "CsvReader.h" #include using namespace std; inline string trim_left(const string &str) { string::size_type n = str.find_first_not_of(" \t\v\n\r"); return n == string::npos ? str : str.substr(n, str.length()); } inline string trim_right(const string &str) { string::size_type n = str.find_last_not_of(" \t\v\n\r"); return n == string::npos ? str : str.substr(0, n + 1); } string trim(const string &str) { return trim_left(trim_right(str)); } static string* StringSplit(string strOrigin, const string &strTok) { uint32_t cutAt; int32_t index = 0; auto strResult = new string[30]; while ((cutAt = strOrigin.find_first_of(strTok)) != strOrigin.npos) { if (cutAt > 0) { strResult[index++] = strOrigin.substr(0, cutAt); } strOrigin = strOrigin.substr(cutAt + 1); } if (strOrigin.length() > 0) { strResult[index++] = strOrigin.substr(0, cutAt); } for( int32_t i=0;i(sizeof(arType) / sizeof(arType[0])) ;j++) { string tempString = arType[j]; if (inputString.find(tempString) != string::npos && tempString.find(inputString) != string::npos) { retInt = j; break; } } return retInt; } int32_t get_Item_SubType_Value(int32_t type_value, const string &inputString) { static std::map> subtypes; subtypes[ITEM_WEAPON] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED", "WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", #ifdef ENABLE_WOLFMAN "WEAPON_MOUNT_SPEAR", "WEAPON_CLAW", #endif #ifdef ENABLE_QUIVER_SYSTEM "WEAPON_QUIVER", #endif }; subtypes[ITEM_ARMOR] = { "ARMOR_BODY", "ARMOR_HEAD", "ARMOR_SHIELD", "ARMOR_WRIST", "ARMOR_FOOTS", "ARMOR_NECK", "ARMOR_EAR", #ifdef ENABLE_PENDANT "ARMOR_PENDANT", #endif "ARMOR_NUM_TYPES", }; subtypes[ITEM_USE] = { "USE_POTION", "USE_TALISMAN", "USE_TUNING", "USE_MOVE", "USE_TREASURE_BOX", "USE_MONEYBAG", "USE_BAIT", "USE_ABILITY_UP", "USE_AFFECT", "USE_CREATE_STONE", "USE_SPECIAL", "USE_POTION_NODELAY", "USE_CLEAR", "USE_INVISIBILITY", "USE_DETACHMENT", "USE_BUCKET", "USE_POTION_CONTINUE", "USE_CLEAN_SOCKET", "USE_CHANGE_ATTRIBUTE", "USE_ADD_ATTRIBUTE", "USE_ADD_ACCESSORY_SOCKET", "USE_PUT_INTO_ACCESSORY_SOCKET", "USE_ADD_ATTRIBUTE2", "USE_RECIPE", "USE_CHANGE_ATTRIBUTE2", "USE_BIND", "USE_UNBIND", "USE_TIME_CHARGE_PER", "USE_TIME_CHARGE_FIX", "USE_PUT_INTO_BELT_SOCKET", "USE_PUT_INTO_RING_SOCKET", "USE_CHEST", "USE_CHANGE_ATTRIBUTE_DS", #ifdef ENABLE_CHANGING_COSTUME_BONUS "USE_CHANGE_COSTUME_ATTR", "USE_RESET_COSTUME_ATTR", #endif #ifdef ENABLE_COSTUME_AURA_SYSTEM "USE_PUT_INTO_AURA_SOCKET", #endif }; subtypes[ITEM_AUTOUSE] = { "AUTOUSE_POTION", "AUTOUSE_ABILITY_UP", "AUTOUSE_BOMB", "AUTOUSE_GOLD", "AUTOUSE_MONEYBAG", "AUTOUSE_TREASURE_BOX", }; subtypes[ITEM_MATERIAL] = { "MATERIAL_LEATHER", "MATERIAL_BLOOD", "MATERIAL_ROOT", "MATERIAL_NEEDLE", "MATERIAL_JEWEL", "MATERIAL_DS_REFINE_NORMAL", "MATERIAL_DS_REFINE_BLESSED", "MATERIAL_DS_REFINE_HOLLY", }; subtypes[ITEM_SPECIAL] = { "SPECIAL_MAP", "SPECIAL_KEY", "SPECIAL_DOC", "SPECIAL_SPIRIT", "SPECIAL_ORE", /*** Do not delete ***/ }; subtypes[ITEM_TOOL] = { "TOOL_FISHING_ROD", }; subtypes[ITEM_LOTTERY] = { "LOTTERY_TICKET", "LOTTERY_INSTANT", }; subtypes[ITEM_METIN] = { "METIN_NORMAL", "METIN_GOLD", }; subtypes[ITEM_FISH] = { "FISH_ALIVE", "FISH_DEAD", }; subtypes[ITEM_RESOURCE] = { "RESOURCE_FISHBONE", "RESOURCE_WATERSTONEPIECE", "RESOURCE_WATERSTONE", "RESOURCE_BLOOD_PEARL", "RESOURCE_BLUE_PEARL", "RESOURCE_WHITE_PEARL", "RESOURCE_BUCKET", "RESOURCE_CRYSTAL", "RESOURCE_GEM", "RESOURCE_STONE", "RESOURCE_METIN", "RESOURCE_ORE", #ifdef ENABLE_COSTUME_AURA_SYSTEM "RESOURCE_AURA", #endif }; subtypes[ITEM_UNIQUE] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_3", "UNIQUE_4", "UNIQUE_5", "UNIQUE_6", "UNIQUE_7", "UNIQUE_8", "UNIQUE_9", "USE_SPECIAL", }; /*** Do not delete ***/ subtypes[ITEM_QUEST] = { "QUEST_SKILLBOOK" }; subtypes[ITEM_PICK] = { "BASIC", "RELIC", }; /*** End ***/ subtypes[ITEM_COSTUME] = { "COSTUME_BODY", "COSTUME_HAIR", #ifdef ENABLE_SHOULDER_SASH_SYSTEM "COSTUME_SASH", #endif #ifdef ENABLE_COSTUME_WEAPON_SYSTEM "COSTUME_WEAPON", #endif #ifdef ENABLE_COSTUME_MOUNT_SYSTEM "COSTUME_MOUNT", #endif #ifdef ENABLE_COSTUME_AURA_SYSTEM "COSTUME_AURA", #endif #ifdef ENABLE_EFFECT_SYSTEM "COSTUME_EFFECT_BODY", "COSTUME_EFFECT_WEAPON", #endif }; subtypes[ITEM_DS] = { "DS_SLOT1", "DS_SLOT2", "DS_SLOT3", "DS_SLOT4", "DS_SLOT5", "DS_SLOT6" }; subtypes[ITEM_EXTRACT] = { "EXTRACT_DRAGON_SOUL", "EXTRACT_DRAGON_HEART", }; #ifdef ENABLE_CHANGING_COSTUME_BONUS subtypes[ITEM_MEDIUM] = { "MEDIUM_MOVE_COSTUME_ATTR", }; #endif subtypes[ITEM_PET] = { #ifdef ENABLE_NEW_PET_SYSTEM "PET_EGG", "PET_UPBRINGING", "PET_BAG", "PET_FEEDSTUFF", "PET_SKILL", "PET_SKILL_DEL_BOOK", "PET_NAME_CHANGE", "PET_EXPFOOD", "PET_SKILL_ALL_DEL_BOOK", "PET_EXPFOOD_PER", "PET_ATTR_CHANGE", "PET_ATTR_CHANGE_ITEMVNUM", #endif #ifdef ENABLE_COSTUME_PET_SYSTEM "PET_SLOT", #endif "PET_NONE", }; if (type_value < 0 || type_value >= ITEM_TYPE_MAX) { sys_err("Out of range type! (type_value: %d, max valid type: %d)", type_value, ITEM_TYPE_MAX); return -1; } if (subtypes.count(type_value) == 0) { return 0; } std::string trimmedInput = trim(inputString); if (type_value == ITEM_QUEST && (trimmedInput.compare("NONE") == 0 || trimmedInput.compare("0") == 0)) { return 0; } for (size_t i = 0, size = subtypes[type_value].size(); i < size; ++i) { if (trimmedInput.compare(subtypes[type_value][i]) == 0) { return i; } } sys_err("Subtype %s is not valid for type %d", trimmedInput.c_str(), type_value); return -1; } int32_t get_Item_AntiFlag_Value(const string &inputString) { string arAntiFlag[] = { "ANTI_FEMALE", "ANTI_MALE", "ANTI_MUSA", "ANTI_ASSASSIN", "ANTI_SURA", "ANTI_MUDANG", "ANTI_GET", "ANTI_DROP", "ANTI_SELL", "ANTI_EMPIRE_A", "ANTI_EMPIRE_B", "ANTI_EMPIRE_C", "ANTI_SAVE", "ANTI_GIVE", "ANTI_PKDROP", "ANTI_STACK", "ANTI_MYSHOP", "ANTI_SAFEBOX", #ifdef ENABLE_WOLFMAN "ANTI_WOLFMAN", #endif "ANTI_CHANGE_ATTRIBUTE", "ANTI_DESTROY", }; int32_t retValue = 0; string* arInputString = StringSplit(inputString, "|"); int32_t comp = sizeof(arAntiFlag) / sizeof(arAntiFlag[0]); for(int32_t i = 0; i < comp; ++i) { string tempString = arAntiFlag[i]; for (int32_t j=0; j < 30; ++j) { string tempString2 = arInputString[j]; if (tempString2.compare("") == 0) { break; } if (tempString2.compare(tempString) == 0) { retValue = retValue + (int32_t)pow(2, i); } } } delete []arInputString; return retValue; } int32_t get_Item_Flag_Value(const string &inputString) { string arFlag[] = { "ITEM_TUNABLE", "ITEM_SAVE", "ITEM_STACKABLE", "COUNT_PER_1GOLD", "ITEM_SLOW_QUERY", "ITEM_UNIQUE", "ITEM_MAKECOUNT", "ITEM_IRREMOVABLE", "CONFIRM_WHEN_USE", "QUEST_USE", "QUEST_USE_MULTIPLE", "QUEST_GIVE", "LOG", "ITEM_APPLICABLE", #ifdef ENABLE_SPECULAR_SYSTEM "ITEM_COLOR", #endif }; int32_t retValue = 0; string* arInputString = StringSplit(inputString, "|"); int32_t sizeOf = sizeof(arFlag)/sizeof(arFlag[0]); for(int32_t i =0;i< sizeOf;i++) { string tempString = arFlag[i]; for (int32_t j=0; j<30 ; j++) { string tempString2 = arInputString[j]; if (tempString2.compare("") == 0) { break; } if (tempString2.compare(tempString) == 0) { retValue = retValue + (int32_t)pow(2, i); } } } delete []arInputString; return retValue; } int32_t get_Item_WearFlag_Value(const string &inputString) { string arWearrFlag[] = { "WEAR_BODY", "WEAR_HEAD", "WEAR_FOOTS", "WEAR_WRIST", "WEAR_WEAPON", "WEAR_NECK", "WEAR_EAR", "WEAR_SHIELD", "WEAR_UNIQUE", "WEAR_ARROW", "WEAR_HAIR", "WEAR_COSTUME_BODY", "WEAR_COSTUME_HAIR", #ifdef ENABLE_SHOULDER_SASH_SYSTEM "WEAR_COSTUME_SASH", #endif #ifdef ENABLE_COSTUME_WEAPON_SYSTEM "WEAR_COSTUME_WEAPON", #endif #ifdef ENABLE_COSTUME_MOUNT_SYSTEM "WEAR_COSTUME_MOUNT", #endif #ifdef ENABLE_COSTUME_AURA_SYSTEM "WEAR_COSTUME_AURA", #endif #ifdef ENABLE_EFFECT_SYSTEM "WEAR_COSTUME_EFFECT_ARMOR", "WEAR_COSTUME_EFFECT_WEAPON", #endif #ifdef ENABLE_PENDANT "WEAR_PENDANT", #endif #ifdef ENABLE_COSTUME_PET_SYSTEM "WEAR_PET", #endif }; int32_t retValue = 0; string* arInputString = StringSplit(inputString, "|"); int32_t sizeOf = sizeof(arWearrFlag)/sizeof(arWearrFlag[0]); for(int32_t i =0;idwVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; strlcpy(mobTable->szName, string_from_row(row[col], length[col]).c_str(), sizeof(mobTable->szName)); col++; if (localeNameColumn.length() > 0) { strlcpy(mobTable->szLocaleName, string_from_row(row[col], length[col]).c_str(), sizeof (mobTable->szLocaleName)); col++; } else { strlcpy(mobTable->szLocaleName, mobTable->szName, sizeof (mobTable->szLocaleName)); } int32_t typeValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); mobTable->bType = typeValue; col++; int32_t rankValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); mobTable->bRank = rankValue; col++; int32_t battleTypeValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); mobTable->bBattleType = battleTypeValue; col++; mobTable->bLevel = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; int32_t sizeValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); mobTable->wScale = sizeValue; col++; mobTable->dwGoldMin = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwGoldMax = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwExp = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwMaxHP = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bRegenCycle = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bRegenPercent = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->wDef = (uint16_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; int32_t aiFlagValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); mobTable->dwAIFlag = aiFlagValue; col++; int32_t raceFlagValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); mobTable->dwRaceFlag = raceFlagValue; col++; int32_t immuneFlagValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); mobTable->dwImmuneFlag = immuneFlagValue; col++; mobTable->bStr = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bDex = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bCon = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bInt = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwDamageRange[0] = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwDamageRange[1] = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->sAttackSpeed = (int16_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->sMovingSpeed = (int16_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bAggresiveHPPct = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->wAggressiveSight = (uint16_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->wAttackRange = (uint16_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; for (auto & cEnchant : mobTable->cEnchants) { cEnchant = (char)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; } for (auto & cResist : mobTable->cResists) { cResist = (char)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; } mobTable->dwResurrectionVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwDropItemVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bMountCapacity = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bOnClickType = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bEmpire = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; strlcpy(mobTable->szFolder, string_from_row(row[col], length[col]).c_str(), sizeof(mobTable->szFolder)); col++; mobTable->fDamMultiply = stof(string_from_row(row[col], length[col]).c_str()); col++; mobTable->dwSummonVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwDrainSP = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwMobColor = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwPolymorphItemVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[0].bLevel = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[0].dwVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[1].bLevel = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[1].dwVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[2].bLevel = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[2].dwVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[3].bLevel = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[3].dwVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[4].bLevel = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->Skills[4].dwVnum = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bBerserkPoint = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bStoneSkinPoint = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bGodSpeedPoint = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bDeathBlowPoint = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->bRevivePoint = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; mobTable->dwSkillRange = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; sys_log(0, "MOB #%-5d %-24s level: %-3u rank: %u empire: %d", mobTable->dwVnum, mobTable->szLocaleName, mobTable->bLevel, mobTable->bRank, mobTable->bEmpire); return true; } bool Set_Proto_Item_Table_MySQL(TItemTable *itemTable, MYSQL_ROW row, uint32_t *length, const string &localeNameColumn) { int32_t col = 0; itemTable->dwVnum = strtoul(string_from_row(row[col], length[col]).c_str(), NULL, 10); itemTable->dwVnumRange = 0; col++; strlcpy(itemTable->szName, string_from_row(row[col], length[col]).c_str(), sizeof(itemTable->szName)); col++; if (localeNameColumn.length() > 0) { strlcpy(itemTable->szLocaleName, string_from_row(row[col], length[col]).c_str(), sizeof (itemTable->szLocaleName)); col++; } else { strlcpy(itemTable->szLocaleName, itemTable->szName, sizeof (itemTable->szLocaleName)); } uint8_t typeValue = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); itemTable->bType = typeValue; col++; uint8_t subTypeValue = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); itemTable->bSubType = subTypeValue; col++; itemTable->bWeight = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; itemTable->bSize = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; uint32_t antiFlagValue = strtoul(string_from_row(row[col], length[col]).c_str(), NULL, 10); itemTable->dwAntiFlags = antiFlagValue; col++; uint32_t flagValue = strtoul(string_from_row(row[col], length[col]).c_str(), NULL, 10); itemTable->dwFlags = flagValue; col++; uint32_t wearFlagValue = strtoul(string_from_row(row[col], length[col]).c_str(), NULL, 10); itemTable->dwWearFlags = wearFlagValue; col++; uint32_t immuneFlagValue = strtoul(string_from_row(row[col], length[col]).c_str(), NULL, 10); itemTable->dwImmuneFlag = immuneFlagValue; col++; itemTable->dwGold = strtoull(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; itemTable->dwShopBuyPrice = strtoull(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; for (int32_t i = 0; i < ITEM_LIMIT_MAX_NUM; ++i) { itemTable->aLimits[i].bType = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; itemTable->aLimits[i].lValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; if (LIMIT_REAL_TIME_START_FIRST_USE == itemTable->aLimits[i].bType) itemTable->cLimitRealTimeFirstUseIndex = (char)i; if (LIMIT_TIMER_BASED_ON_WEAR == itemTable->aLimits[i].bType) itemTable->cLimitTimerBasedOnWearIndex = (char)i; } for (auto & aApplie : itemTable->aApplies) { aApplie.bType = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; aApplie.lValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; } for (auto & alValue : itemTable->alValues) { alValue = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; } for (auto & alSocket : itemTable->alSockets) { alSocket = strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; } itemTable->dwRefinedVnum = strtoul(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; itemTable->wRefineSet = (uint16_t)strtoul(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; itemTable->bAlterToMagicItemPct = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; itemTable->bSpecular = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; itemTable->bGainSocketPct = (uint8_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; itemTable->sAddonType = (int16_t)strtol(string_from_row(row[col], length[col]).c_str(), NULL, 10); col++; sys_log(0, "ITEM #%-5d %-24s type: %-3u subtype: %u", itemTable->dwVnum, itemTable->szLocaleName, itemTable->bType, itemTable->bSubType); return true; } #ifndef __DUMP_PROTO__ bool Set_Proto_Mob_Table(TMobTable *mobTable,const cCsvTable &csvTable,std::map &nameMap) { int32_t col = 0; str_to_number(mobTable->dwVnum, csvTable.AsStringByIndex(col++)); strlcpy(mobTable->szName, csvTable.AsStringByIndex(col++), sizeof(mobTable->szName)); auto it = nameMap.find(mobTable->dwVnum); if (it != nameMap.end()) { const char* localeName = it->second; strlcpy(mobTable->szLocaleName, localeName, sizeof(mobTable->szLocaleName)); } else { strlcpy(mobTable->szLocaleName, mobTable->szName, sizeof(mobTable->szLocaleName)); } int32_t rankValue = get_Mob_Rank_Value(csvTable.AsStringByIndex(col++)); mobTable->bRank = rankValue; int32_t typeValue = get_Mob_Type_Value(csvTable.AsStringByIndex(col++)); mobTable->bType = typeValue; int32_t battleTypeValue = get_Mob_BattleType_Value(csvTable.AsStringByIndex(col++)); mobTable->bBattleType = battleTypeValue; str_to_number(mobTable->bLevel, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->wScale, csvTable.AsStringByIndex(col++)); int32_t aiFlagValue = get_Mob_AIFlag_Value(csvTable.AsStringByIndex(col++)); mobTable->dwAIFlag = aiFlagValue; col++; int32_t raceFlagValue = get_Mob_RaceFlag_Value(csvTable.AsStringByIndex(col++)); mobTable->dwRaceFlag = raceFlagValue; int32_t immuneFlagValue = get_Mob_ImmuneFlag_Value(csvTable.AsStringByIndex(col++)); mobTable->dwImmuneFlag = immuneFlagValue; str_to_number(mobTable->bEmpire, csvTable.AsStringByIndex(col++)); strlcpy(mobTable->szFolder, csvTable.AsStringByIndex(col++), sizeof(mobTable->szFolder)); str_to_number(mobTable->bOnClickType, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bStr, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bDex, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bCon, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bInt, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwDamageRange[0], csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwDamageRange[1], csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwMaxHP, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bRegenCycle, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bRegenPercent, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwGoldMin, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwGoldMax, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwExp, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->wDef, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->sAttackSpeed, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->sMovingSpeed, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bAggresiveHPPct, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->wAggressiveSight, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->wAttackRange, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwDropItemVnum, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwResurrectionVnum, csvTable.AsStringByIndex(col++)); for (auto & cEnchant : mobTable->cEnchants) { str_to_number(cEnchant, csvTable.AsStringByIndex(col++)); } for (auto & cResist : mobTable->cResists) { str_to_number(cResist, csvTable.AsStringByIndex(col++)); } mobTable->fDamMultiply = stof(std::string(csvTable.AsStringByIndex(col++))); str_to_number(mobTable->dwSummonVnum, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwDrainSP, csvTable.AsStringByIndex(col++)); ++col; str_to_number(mobTable->dwPolymorphItemVnum, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[0].bLevel, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[0].dwVnum, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[1].bLevel, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[1].dwVnum, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[2].bLevel, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[2].dwVnum, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[3].bLevel, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[3].dwVnum, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[4].bLevel, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->Skills[4].dwVnum, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bBerserkPoint, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bStoneSkinPoint, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bGodSpeedPoint, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bDeathBlowPoint, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->bRevivePoint, csvTable.AsStringByIndex(col++)); str_to_number(mobTable->dwSkillRange, csvTable.AsStringByIndex(col++)); sys_log(0, "MOB #%-5d %-24s level: %-3u rank: %u empire: %d", mobTable->dwVnum, mobTable->szLocaleName, mobTable->bLevel, mobTable->bRank, mobTable->bEmpire); return true; } bool Set_Proto_Item_Table(TItemTable *itemTable,const cCsvTable &csvTable,std::map &nameMap) { int32_t col = 0; int64_t dataArray[39]; int32_t sizeOf = sizeof(dataArray)/sizeof(dataArray[0]); for (int32_t i=0; idwVnum = dataArray[0]; itemTable->dwVnumRange = 0; } else { std::string s_start_vnum(s.substr(0, pos)); std::string s_end_vnum(s.substr(pos + 1)); int32_t start_vnum = atoi(s_start_vnum.c_str()); int32_t end_vnum = atoi(s_end_vnum.c_str()); if (0 == start_vnum || (0 != end_vnum && end_vnum < start_vnum)) { sys_err("INVALID VNUM %s", s.c_str()); return false; } itemTable->dwVnum = start_vnum; itemTable->dwVnumRange = end_vnum - start_vnum; } } strlcpy(itemTable->szName, csvTable.AsStringByIndex(1), ITEM_NAME_MAX_LEN + 1); auto it = nameMap.find(itemTable->dwVnum); strlcpy(itemTable->szLocaleName, (it != nameMap.end()) ? it->second : itemTable->szName, ITEM_NAME_MAX_LEN + 1); itemTable->bType = (uint8_t)dataArray[2]; itemTable->bSubType = (uint8_t)dataArray[3]; itemTable->bSize = (uint8_t)dataArray[4]; itemTable->dwAntiFlags = (uint32_t)dataArray[5]; itemTable->dwFlags = (uint32_t)dataArray[6]; itemTable->dwWearFlags = (uint32_t)dataArray[7]; itemTable->dwImmuneFlag = (uint32_t)dataArray[8]; itemTable->dwGold = (uint64_t)dataArray[9]; itemTable->dwShopBuyPrice = (uint64_t)dataArray[10]; itemTable->dwRefinedVnum = (uint32_t)dataArray[11]; itemTable->wRefineSet = (uint16_t)dataArray[12]; itemTable->bAlterToMagicItemPct = (uint8_t)dataArray[13]; itemTable->cLimitRealTimeFirstUseIndex = -1; itemTable->cLimitTimerBasedOnWearIndex = -1; int32_t i; for (i = 0; i < ITEM_LIMIT_MAX_NUM; ++i) { itemTable->aLimits[i].bType = (uint8_t)dataArray[14 + i * 2]; itemTable->aLimits[i].lValue = (long)dataArray[15 + i * 2]; if (LIMIT_REAL_TIME_START_FIRST_USE == itemTable->aLimits[i].bType) { itemTable->cLimitRealTimeFirstUseIndex = (char) i; } if (LIMIT_TIMER_BASED_ON_WEAR == itemTable->aLimits[i].bType) { itemTable->cLimitTimerBasedOnWearIndex = (char) i; } } for (i = 0; i < ITEM_APPLY_MAX_NUM; ++i) { itemTable->aApplies[i].bType = (uint8_t)dataArray[18 + i * 2]; itemTable->aApplies[i].lValue = (long)dataArray[19 + i * 2]; } for (i = 0; i < ITEM_VALUES_MAX_NUM; ++i) { itemTable->alValues[i] = (long)dataArray[30 + i]; } itemTable->bGainSocketPct = (long)dataArray[37]; itemTable->sAddonType = (int16_t)dataArray[38]; str_to_number(itemTable->bWeight, "0"); return true; } #endif