SHARE
TWEET

Untitled

a guest Apr 21st, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2.  
  3. #include <math.h>
  4. #include "ProtoReader.h"
  5.  
  6. #include "CsvReader.h"
  7.  
  8. #include <sstream>
  9.  
  10. using namespace std;
  11.  
  12. inline string trim_left(const string& str)
  13. {
  14.     string::size_type n = str.find_first_not_of(" \t\v\n\r");
  15.     return n == string::npos ? str : str.substr(n, str.length());
  16. }
  17.  
  18. inline string trim_right(const string& str)
  19. {
  20.     string::size_type n = str.find_last_not_of(" \t\v\n\r");
  21.     return n == string::npos ? str : str.substr(0, n + 1);
  22. }
  23.  
  24. string trim(const string& str){return trim_left(trim_right(str));}
  25.  
  26. static string* StringSplit(string strOrigin, string strTok)
  27. {
  28.     int         cutAt;
  29.     int         index = 0;
  30.     string* strResult = new string[30];
  31.  
  32.     while ((cutAt = strOrigin.find_first_of(strTok)) != static_cast<long>(strOrigin.npos))
  33.     {
  34.         if (cutAt > 0)
  35.         {
  36.             strResult[index++] = strOrigin.substr(0, cutAt);
  37.         }
  38.         strOrigin = strOrigin.substr(cutAt+1);
  39.     }
  40.  
  41.     if(strOrigin.length() > 0)
  42.     {
  43.         strResult[index++] = strOrigin.substr(0, cutAt);
  44.     }
  45.  
  46.     for( int i=0;i<index;i++)
  47.     {
  48.         strResult[i] = trim(strResult[i]);
  49.     }
  50.  
  51.     return strResult;
  52. }
  53.  
  54. int get_Item_Type_Value(string inputString)
  55. {
  56.     string arType[] = {"ITEM_NONE", "ITEM_WEAPON",
  57.         "ITEM_ARMOR", "ITEM_USE",
  58.         "ITEM_AUTOUSE", "ITEM_MATERIAL",
  59.         "ITEM_SPECIAL", "ITEM_TOOL",
  60.         "ITEM_LOTTERY", "ITEM_ELK",                 //10
  61.  
  62.         "ITEM_METIN", "ITEM_CONTAINER",
  63.         "ITEM_FISH", "ITEM_ROD",
  64.         "ITEM_RESOURCE", "ITEM_CAMPFIRE",
  65.         "ITEM_UNIQUE", "ITEM_SKILLBOOK",
  66.         "ITEM_QUEST", "ITEM_POLYMORPH",             //20
  67.  
  68.         "ITEM_TREASURE_BOX", "ITEM_TREASURE_KEY",
  69.         "ITEM_SKILLFORGET", "ITEM_GIFTBOX",
  70.         "ITEM_PICK", "ITEM_HAIR",
  71.         "ITEM_TOTEM", "ITEM_BLEND",
  72.         "ITEM_COSTUME", "ITEM_DS",                  //30
  73.    
  74.         "ITEM_SPECIAL_DS",  "ITEM_EXTRACT",
  75.         "ITEM_SECONDARY_COIN",                      //33
  76.  
  77.         "ITEM_RING",
  78.         "ITEM_BELT",                                //35
  79.         "ITEM_PENDANT",                             //36
  80. };
  81.  
  82.     int retInt = -1;
  83.  
  84.     for (unsigned int j=0;j<sizeof(arType)/sizeof(arType[0]);j++)
  85.     {
  86.         string tempString = arType[j];
  87.         if  (inputString.find(tempString)!=string::npos && tempString.find(inputString)!=string::npos)
  88.         {
  89.             retInt =  j;
  90.             break;
  91.         }
  92.     }
  93.  
  94.     return retInt;
  95. }
  96.  
  97. int get_Item_SubType_Value(int type_value, string inputString)
  98. {
  99.     static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
  100.                 "WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR"};
  101.     static string arSub2[] = { "ARMOR_BODY", "ARMOR_HEAD", "ARMOR_SHIELD", "ARMOR_WRIST", "ARMOR_FOOTS",
  102.                 "ARMOR_NECK", "ARMOR_EAR", "ARMOR_NUM_TYPES"};
  103.     static string arSub3[] = { "USE_POTION", "USE_TALISMAN", "USE_TUNING", "USE_MOVE", "USE_TREASURE_BOX", "USE_MONEYBAG", "USE_BAIT",
  104.                 "USE_ABILITY_UP", "USE_AFFECT", "USE_CREATE_STONE", "USE_SPECIAL", "USE_POTION_NODELAY", "USE_CLEAR",
  105.                 "USE_INVISIBILITY", "USE_DETACHMENT", "USE_BUCKET", "USE_POTION_CONTINUE", "USE_CLEAN_SOCKET",
  106.                 "USE_CHANGE_ATTRIBUTE", "USE_ADD_ATTRIBUTE", "USE_ADD_ACCESSORY_SOCKET", "USE_PUT_INTO_ACCESSORY_SOCKET",
  107.                 "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_33"};
  108.     static string arSub4[] = { "AUTOUSE_POTION", "AUTOUSE_ABILITY_UP", "AUTOUSE_BOMB", "AUTOUSE_GOLD", "AUTOUSE_MONEYBAG", "AUTOUSE_TREASURE_BOX"};
  109.     static string arSub5[] = { "MATERIAL_LEATHER", "MATERIAL_BLOOD", "MATERIAL_ROOT", "MATERIAL_NEEDLE", "MATERIAL_JEWEL",
  110.         "MATERIAL_DS_REFINE_NORMAL", "MATERIAL_DS_REFINE_BLESSED", "MATERIAL_DS_REFINE_HOLLY"};
  111.     static string arSub6[] = { "SPECIAL_MAP", "SPECIAL_KEY", "SPECIAL_DOC", "SPECIAL_SPIRIT"};
  112.     static string arSub7[] = { "TOOL_FISHING_ROD" };
  113.     static string arSub8[] = { "LOTTERY_TICKET", "LOTTERY_INSTANT" };
  114.     static string arSub10[] = { "METIN_NORMAL", "METIN_GOLD" };
  115.     static string arSub12[] = { "FISH_ALIVE", "FISH_DEAD"};
  116.     static string arSub14[] = { "RESOURCE_FISHBONE", "RESOURCE_WATERSTONEPIECE", "RESOURCE_WATERSTONE", "RESOURCE_BLOOD_PEARL",
  117.                         "RESOURCE_BLUE_PEARL", "RESOURCE_WHITE_PEARL", "RESOURCE_BUCKET", "RESOURCE_CRYSTAL", "RESOURCE_GEM",
  118.                         "RESOURCE_STONE", "RESOURCE_METIN", "RESOURCE_ORE" };
  119.     static string arSub16[] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_3", "UNIQUE_4", "UNIQUE_5", "UNIQUE_6", "UNIQUE_7", "UNIQUE_8", "UNIQUE_9", "USE_SPECIAL"};
  120.     static string arSub28[] = { "COSTUME_BODY", "COSTUME_HAIR", "COSTUME_SASH", "COSTUME_MOUNT", "NONE", "NONE", "NONE", "NONE", "NONE","COSTUME_WEAPON_SWORD", "COSTUME_WEAPON_DAGGER", "COSTUME_WEAPON_BOW", "COSTUME_WEAPON_TWO_HANDED", "COSTUME_WEAPON_BELL", "COSTUME_WEAPON_FAN" };
  121.     static string arSub29[] = { "DS_SLOT1", "DS_SLOT2", "DS_SLOT3", "DS_SLOT4", "DS_SLOT5", "DS_SLOT6" };
  122.     static string arSub31[] = { "EXTRACT_DRAGON_SOUL", "EXTRACT_DRAGON_HEART" };
  123.     static string* arSubType[] =
  124.     {
  125.         0,  //0
  126.         arSub1,     //1
  127.         arSub2, //2
  128.         arSub3, //3
  129.         arSub4, //4
  130.         arSub5, //5
  131.         arSub6, //6
  132.         arSub7, //7
  133.         arSub8, //8
  134.         0,          //9
  135.         arSub10,    //10
  136.         0,          //11
  137.         arSub12,    //12
  138.         0,          //13
  139.         arSub14,    //14
  140.         0,          //15
  141.         arSub16,    //16
  142.         0,          //17
  143.         0,          //18
  144.         0,          //19
  145.         0,          //20
  146.         0,          //21
  147.         0,          //22
  148.         0,          //23
  149.         0,          //24
  150.         0,          //25
  151.         0,          //26
  152.         0,          //27
  153.         arSub28,    //28
  154.         arSub29,    //29
  155.         arSub29,    //30
  156.         arSub31,    //31
  157.         0,          //32
  158.         0,          //33 ¹ÝÁö
  159.         0,          //34 º§Æ®
  160.         0,          //35
  161.     };
  162.  
  163.     static int arNumberOfSubtype[_countof(arSubType)] =
  164.     {
  165.         0,
  166.         sizeof(arSub1)/sizeof(arSub1[0]),
  167.         sizeof(arSub2)/sizeof(arSub2[0]),
  168.         sizeof(arSub3)/sizeof(arSub3[0]),
  169.         sizeof(arSub4)/sizeof(arSub4[0]),
  170.         sizeof(arSub5)/sizeof(arSub5[0]),
  171.         sizeof(arSub6)/sizeof(arSub6[0]),
  172.         sizeof(arSub7)/sizeof(arSub7[0]),
  173.         sizeof(arSub8)/sizeof(arSub8[0]),
  174.         0,
  175.         sizeof(arSub10)/sizeof(arSub10[0]),
  176.         0,
  177.         sizeof(arSub12)/sizeof(arSub12[0]),
  178.         0,
  179.         sizeof(arSub14)/sizeof(arSub14[0]),
  180.         0,
  181.         sizeof(arSub16)/sizeof(arSub16[0]),
  182.         0,
  183.         0,
  184.         0,
  185.         0,
  186.         0,
  187.         0,
  188.         0,
  189.         0,
  190.         0,
  191.         0,
  192.         0,
  193.         sizeof(arSub28)/sizeof(arSub28[0]),
  194.         sizeof(arSub29)/sizeof(arSub29[0]),
  195.         sizeof(arSub29)/sizeof(arSub29[0]),
  196.         sizeof(arSub31)/sizeof(arSub31[0]),
  197.         0, // 32
  198.         0, // 33
  199.         0, // 34
  200.         0, // 35
  201.     };
  202.  
  203.     assert(static_cast<long>(_countof(arSubType)) > type_value && "Subtype rule: Out of range!!");
  204.  
  205.     if (static_cast<long>(_countof(arSubType)) <= type_value)
  206.     {
  207.         sys_err("SubType : Out of range!! (type_value: %d, count of registered subtype: %d", type_value, _countof(arSubType));
  208.         return -1;
  209.     }
  210.  
  211.     if (arSubType[type_value]==0)
  212.     {
  213.         return 0;
  214.     }
  215.  
  216.     int retInt = -1;
  217.  
  218.     for (int j=0;j<arNumberOfSubtype[type_value];j++)
  219.     {
  220.         string tempString = arSubType[type_value][j];
  221.         string tempInputString = trim(inputString);
  222.  
  223.         if  (tempInputString.compare(tempString)==0)
  224.         {
  225.             retInt =  j;
  226.             break;
  227.         }
  228.     }
  229.  
  230.     return retInt;
  231. }
  232.  
  233. int get_Item_AntiFlag_Value(string inputString)
  234. {
  235.     string arAntiFlag[] = {"ANTI_FEMALE", "ANTI_MALE", "ANTI_MUSA", "ANTI_ASSASSIN", "ANTI_SURA", "ANTI_MUDANG",
  236.                             "ANTI_GET", "ANTI_DROP", "ANTI_SELL", "ANTI_EMPIRE_A", "ANTI_EMPIRE_B", "ANTI_EMPIRE_C",
  237.                             "ANTI_SAVE", "ANTI_GIVE", "ANTI_PKDROP", "ANTI_STACK", "ANTI_MYSHOP", "ANTI_SAFEBOX"};
  238.  
  239.  
  240.     int retValue = 0;
  241.     string* arInputString = StringSplit(inputString, "|");
  242.     for(unsigned int i =0;i<sizeof(arAntiFlag)/sizeof(arAntiFlag[0]);i++)
  243.     {
  244.         string tempString = arAntiFlag[i];
  245.         for (int j=0; j<30 ; j++)
  246.         {
  247.             string tempString2 = arInputString[j];
  248.  
  249.             if (tempString2.compare(tempString)==0)
  250.             {
  251.                 retValue = retValue + pow((float)2,(float)i);
  252.             }
  253.  
  254.             if(tempString2.compare("") == 0)
  255.                 break;
  256.         }
  257.     }
  258.     delete []arInputString;
  259.     return retValue;
  260. }
  261.  
  262. int get_Item_Flag_Value(string inputString)
  263. {
  264.     string arFlag[] = {"ITEM_TUNABLE", "ITEM_SAVE", "ITEM_STACKABLE", "COUNT_PER_1GOLD", "ITEM_SLOW_QUERY", "ITEM_UNIQUE",
  265.             "ITEM_MAKECOUNT", "ITEM_IRREMOVABLE", "CONFIRM_WHEN_USE", "QUEST_USE", "QUEST_USE_MULTIPLE",
  266.             "QUEST_GIVE", "ITEM_QUEST", "LOG", "STACKABLE", "SLOW_QUERY", "REFINEABLE", "IRREMOVABLE", "ITEM_APPLICABLE"};
  267.  
  268.  
  269.     int retValue = 0;
  270.     string* arInputString = StringSplit(inputString, "|");
  271.     for(unsigned int i =0;i<sizeof(arFlag)/sizeof(arFlag[0]);i++)
  272.     {
  273.         string tempString = arFlag[i];
  274.         for (int j=0; j<30 ; j++)
  275.         {
  276.             string tempString2 = arInputString[j];
  277.  
  278.             if (tempString2.compare(tempString)==0)
  279.             {
  280.                 retValue = retValue + pow((float)2,(float)i);
  281.             }
  282.  
  283.             if(tempString2.compare("") == 0)
  284.                 break;
  285.         }
  286.     }
  287.     delete []arInputString;
  288.     return retValue;
  289. }
  290.  
  291. int get_Item_WearFlag_Value(string inputString)
  292. {
  293.     string arWearrFlag[] = {"WEAR_BODY", "WEAR_HEAD", "WEAR_FOOTS", "WEAR_WRIST", "WEAR_WEAPON", "WEAR_NECK", "WEAR_EAR", "WEAR_SHIELD", "WEAR_UNIQUE",
  294.                     "WEAR_ARROW", "WEAR_HAIR", "WEAR_COSTUME_SASH", "WEAR_COSTUME_MOUNT", "WEAR_RING1", "WEAR_RING2", "WEAR_BELT", "WEAR_ABILITY"};
  295.  
  296.     int retValue = 0;
  297.     string* arInputString = StringSplit(inputString, "|");
  298.     for(unsigned int i =0;i<sizeof(arWearrFlag)/sizeof(arWearrFlag[0]);i++)
  299.     {
  300.         string tempString = arWearrFlag[i];
  301.         for (int j=0; j<30 ; j++)
  302.         {
  303.             string tempString2 = arInputString[j];
  304.  
  305.             if (tempString2.compare(tempString)==0)
  306.             {
  307.                 retValue = retValue + pow((float)2,(float)i);
  308.             }
  309.  
  310.             if(tempString2.compare("") == 0)
  311.                 break;
  312.         }
  313.     }
  314.     delete []arInputString;
  315.     return retValue;
  316. }
  317.  
  318. int get_Item_Immune_Value(string inputString)
  319. {
  320.     string arImmune[] = {"PARA","CURSE","STUN","SLEEP","SLOW","POISON","TERROR"};
  321.  
  322.     int retValue = 0;
  323.     string* arInputString = StringSplit(inputString, "|");
  324.     for(unsigned int i =0;i<sizeof(arImmune)/sizeof(arImmune[0]);i++)
  325.     {
  326.         string tempString = arImmune[i];
  327.  
  328.         for (int j=0; j<30 ; j++)
  329.         {
  330.             string tempString2 = arInputString[j];
  331.             if (tempString2.compare(tempString)==0)
  332.             {
  333.                 retValue = retValue + pow((float)2,(float)i);
  334.             }
  335.  
  336.             if(tempString2.compare("") == 0)
  337.                 break;
  338.         }
  339.     }
  340.     delete []arInputString;
  341.     return retValue;
  342. }
  343.  
  344. int get_Item_LimitType_Value(string inputString)
  345. {
  346.     string arLimitType[] = {"LIMIT_NONE", "LEVEL", "STR", "DEX", "INT", "CON", "PC_BANG", "REAL_TIME", "REAL_TIME_FIRST_USE", "TIMER_BASED_ON_WEAR"};
  347.  
  348.     int retInt = -1;
  349.  
  350.     for (unsigned int j=0;j<sizeof(arLimitType)/sizeof(arLimitType[0]);j++)
  351.     {
  352.         string tempString = arLimitType[j];
  353.         string tempInputString = trim(inputString);
  354.         if  (tempInputString.compare(tempString)==0)
  355.         {
  356.             retInt =  j;
  357.             break;
  358.         }
  359.     }
  360.  
  361.     return retInt;
  362. }
  363.  
  364. int get_Item_ApplyType_Value(string inputString)
  365. {
  366.     string arApplyType[] = {"APPLY_NONE", "APPLY_MAX_HP", "APPLY_MAX_SP", "APPLY_CON", "APPLY_INT", "APPLY_STR", "APPLY_DEX", "APPLY_ATT_SPEED",
  367.             "APPLY_MOV_SPEED", "APPLY_CAST_SPEED", "APPLY_HP_REGEN", "APPLY_SP_REGEN", "APPLY_POISON_PCT", "APPLY_STUN_PCT",
  368.             "APPLY_SLOW_PCT", "APPLY_CRITICAL_PCT", "APPLY_PENETRATE_PCT", "APPLY_ATTBONUS_HUMAN", "APPLY_ATTBONUS_ANIMAL",
  369.             "APPLY_ATTBONUS_ORC", "APPLY_ATTBONUS_MILGYO", "APPLY_ATTBONUS_UNDEAD", "APPLY_ATTBONUS_DEVIL", "APPLY_STEAL_HP",
  370.             "APPLY_STEAL_SP", "APPLY_MANA_BURN_PCT", "APPLY_DAMAGE_SP_RECOVER", "APPLY_BLOCK", "APPLY_DODGE", "APPLY_RESIST_SWORD",
  371.             "APPLY_RESIST_TWOHAND", "APPLY_RESIST_DAGGER", "APPLY_RESIST_BELL", "APPLY_RESIST_FAN", "APPLY_RESIST_BOW", "APPLY_RESIST_FIRE",
  372.             "APPLY_RESIST_ELEC", "APPLY_RESIST_MAGIC", "APPLY_RESIST_WIND", "APPLY_REFLECT_MELEE", "APPLY_REFLECT_CURSE", "APPLY_POISON_REDUCE",
  373.             "APPLY_KILL_SP_RECOVER", "APPLY_EXP_DOUBLE_BONUS", "APPLY_GOLD_DOUBLE_BONUS", "APPLY_ITEM_DROP_BONUS", "APPLY_POTION_BONUS",
  374.             "APPLY_KILL_HP_RECOVER", "APPLY_IMMUNE_STUN", "APPLY_IMMUNE_SLOW", "APPLY_IMMUNE_FALL", "APPLY_SKILL", "APPLY_BOW_DISTANCE",
  375.             "APPLY_ATT_GRADE_BONUS", "APPLY_DEF_GRADE_BONUS", "APPLY_MAGIC_ATT_GRADE", "APPLY_MAGIC_DEF_GRADE", "APPLY_CURSE_PCT",
  376.             "APPLY_MAX_STAMINA", "APPLY_ATTBONUS_WARRIOR", "APPLY_ATTBONUS_ASSASSIN", "APPLY_ATTBONUS_SURA", "APPLY_ATTBONUS_SHAMAN",
  377.             "APPLY_ATTBONUS_MONSTER", "APPLY_MALL_ATTBONUS", "APPLY_MALL_DEFBONUS", "APPLY_MALL_EXPBONUS", "APPLY_MALL_ITEMBONUS",
  378.             "APPLY_MALL_GOLDBONUS", "APPLY_MAX_HP_PCT", "APPLY_MAX_SP_PCT", "APPLY_SKILL_DAMAGE_BONUS", "APPLY_NORMAL_HIT_DAMAGE_BONUS",
  379.             "APPLY_SKILL_DEFEND_BONUS", "APPLY_NORMAL_HIT_DEFEND_BONUS", "APPLY_PC_BANG_EXP_BONUS", "APPLY_PC_BANG_DROP_BONUS",
  380.             "APPLY_EXTRACT_HP_PCT", "APPLY_RESIST_WARRIOR", "APPLY_RESIST_ASSASSIN", "APPLY_RESIST_SURA", "APPLY_RESIST_SHAMAN",
  381.             "APPLY_ENERGY", "APPLY_DEF_GRADE", "APPLY_COSTUME_ATTR_BONUS", "APPLY_MAGIC_ATTBONUS_PER", "APPLY_MELEE_MAGIC_ATTBONUS_PER",
  382.             "APPLY_RESIST_ICE", "APPLY_RESIST_EARTH", "APPLY_RESIST_DARK", "APPLY_ANTI_CRITICAL_PCT", "APPLY_ANTI_PENETRATE_PCT",
  383.             "APPLY_ANTI_RESIST_MAGIC", "APPLY_ATTBONUS_ELECT", "APPLY_ATTBONUS_FIRE", "APPLY_ATTBONUS_ICE", "APPLY_ATTBONUS_WIND",
  384.             "APPLY_ATTBONUS_EARTH", "APPLY_ATTBONUS_DARK",
  385.     };
  386.  
  387.     int retInt = -1;
  388.  
  389.     for (unsigned int j=0;j<sizeof(arApplyType)/sizeof(arApplyType[0]);j++)
  390.     {
  391.         string tempString = arApplyType[j];
  392.         string tempInputString = trim(inputString);
  393.         if  (tempInputString.compare(tempString)==0)
  394.         {
  395.             retInt =  j;
  396.             break;
  397.         }
  398.     }
  399.  
  400.     return retInt;
  401. }
  402.  
  403. int get_Mob_Rank_Value(string inputString)
  404. {
  405.     string arRank[] = {"PAWN", "S_PAWN", "KNIGHT", "S_KNIGHT", "BOSS", "KING"};
  406.  
  407.     int retInt = -1;
  408.  
  409.     for (unsigned int j=0;j<sizeof(arRank)/sizeof(arRank[0]);j++)
  410.     {
  411.         string tempString = arRank[j];
  412.         string tempInputString = trim(inputString);
  413.         if (tempInputString.compare(tempString)==0)
  414.         {
  415.             retInt =  j;
  416.             break;
  417.         }
  418.     }
  419.  
  420.     return retInt;
  421. }
  422.  
  423. int get_Mob_Type_Value(string inputString)
  424. {
  425.     string arType[] = { "MONSTER", "NPC", "STONE", "WARP", "DOOR", "BUILDING", "PC", "POLYMORPH_PC", "HORSE", "GOTO"};
  426.  
  427.     int retInt = -1;
  428.  
  429.     for (unsigned int j=0;j<sizeof(arType)/sizeof(arType[0]);j++)
  430.     {
  431.         string tempString = arType[j];
  432.         string tempInputString = trim(inputString);
  433.         if (tempInputString.compare(tempString)==0)
  434.         {
  435.             retInt =  j;
  436.             break;
  437.         }
  438.     }
  439.  
  440.     return retInt;
  441. }
  442.  
  443. int get_Mob_BattleType_Value(string inputString)
  444. {
  445.     string arBattleType[] = { "MELEE", "RANGE", "MAGIC", "SPECIAL", "POWER", "TANKER", "SUPER_POWER", "SUPER_TANKER"};
  446.  
  447.     int retInt = -1;
  448.  
  449.     for (unsigned int j=0;j<sizeof(arBattleType)/sizeof(arBattleType[0]);j++)
  450.     {
  451.         string tempString = arBattleType[j];
  452.         string tempInputString = trim(inputString);
  453.         if (tempInputString.compare(tempString)==0)
  454.         {
  455.             retInt =  j;
  456.             break;
  457.         }
  458.     }
  459.  
  460.     return retInt;
  461. }
  462.  
  463. int get_Mob_Size_Value(string inputString)
  464. {
  465.     string arSize[] = { "SAMLL", "MEDIUM", "BIG"};
  466.  
  467.     int retInt = 0;
  468.  
  469.     for (unsigned int j=0;j<sizeof(arSize)/sizeof(arSize[0]);j++)
  470.     {
  471.         string tempString = arSize[j];
  472.         string tempInputString = trim(inputString);
  473.         if  (tempInputString.compare(tempString)==0)
  474.         {
  475.             retInt =  j + 1;
  476.             break;
  477.         }
  478.     }
  479.  
  480.     return retInt;
  481. }
  482.  
  483. int get_Mob_AIFlag_Value(string inputString)
  484. {
  485.     string arAIFlag[] = {"AGGR","NOMOVE","COWARD","NOATTSHINSU","NOATTCHUNJO","NOATTJINNO","ATTMOB","BERSERK","STONESKIN","GODSPEED","DEATHBLOW","REVIVE"};
  486.  
  487.     int retValue = 0;
  488.     string* arInputString = StringSplit(inputString, ",");
  489.     for(unsigned int i =0;i<sizeof(arAIFlag)/sizeof(arAIFlag[0]);i++)
  490.     {
  491.         string tempString = arAIFlag[i];
  492.         for (int j=0; j<30 ; j++)
  493.         {
  494.             string tempString2 = arInputString[j];
  495.             if (tempString2.compare(tempString)==0)
  496.             {
  497.                 retValue = retValue + pow((float)2,(float)i);
  498.             }
  499.            
  500.             if(tempString2.compare("") == 0)
  501.                 break;
  502.         }
  503.     }
  504.     delete []arInputString;
  505.     return retValue;
  506. }
  507.  
  508. int get_Mob_RaceFlag_Value(string inputString)
  509. {
  510.     string arRaceFlag[] = {"ANIMAL","UNDEAD","DEVIL","HUMAN","ORC","MILGYO","INSECT","FIRE","ICE","DESERT","TREE",
  511.         "ATT_ELEC","ATT_FIRE","ATT_ICE","ATT_WIND","ATT_EARTH","ATT_DARK"};
  512.  
  513.     int retValue = 0;
  514.     string* arInputString = StringSplit(inputString, ",");
  515.     for(unsigned int i =0;i<sizeof(arRaceFlag)/sizeof(arRaceFlag[0]);i++)
  516.     {
  517.         string tempString = arRaceFlag[i];
  518.         for (int j=0; j<30 ; j++)
  519.         {
  520.             string tempString2 = arInputString[j];
  521.  
  522.             if (tempString2.compare(tempString)==0)
  523.             {
  524.                 retValue = retValue + pow((float)2,(float)i);
  525.             }
  526.  
  527.             if(tempString2.compare("") == 0)
  528.                 break;
  529.         }
  530.     }
  531.     delete []arInputString;
  532.     return retValue;
  533. }
  534.  
  535. int get_Mob_ImmuneFlag_Value(string inputString)
  536. {
  537.     string arImmuneFlag[] = {"STUN","SLOW","FALL","CURSE","POISON","TERROR", "REFLECT"};
  538.  
  539.     int retValue = 0;
  540.     string* arInputString = StringSplit(inputString, ",");
  541.     for(unsigned int i =0;i<sizeof(arImmuneFlag)/sizeof(arImmuneFlag[0]);i++)
  542.     {
  543.         string tempString = arImmuneFlag[i];
  544.         for (int j=0; j<30 ; j++)
  545.         {
  546.             string tempString2 = arInputString[j];
  547.             if (tempString2.compare(tempString)==0)
  548.             {
  549.                 retValue = retValue + pow((float)2,(float)i);
  550.             }
  551.  
  552.             if(tempString2.compare("") == 0)
  553.                 break;
  554.         }
  555.     }
  556.     delete []arInputString;
  557.     return retValue;
  558. }
  559.  
  560. #ifndef __DUMP_PROTO__
  561. bool Set_Proto_Mob_Table(TMobTable *mobTable, cCsvTable &csvTable,std::map<int,const char*> &nameMap)
  562. {
  563.     int col = 0;
  564.     str_to_number(mobTable->dwVnum, csvTable.AsStringByIndex(col++));
  565.     strlcpy(mobTable->szName, csvTable.AsStringByIndex(col++), sizeof(mobTable->szName));
  566.  
  567.     map<int,const char*>::iterator it;
  568.     it = nameMap.find(mobTable->dwVnum);
  569.  
  570.     if (it != nameMap.end())
  571.     {
  572.         const char * localeName = it->second;
  573.         strlcpy(mobTable->szLocaleName, localeName, sizeof (mobTable->szLocaleName));
  574.     }
  575.     else
  576.     {
  577.         strlcpy(mobTable->szLocaleName, mobTable->szName, sizeof (mobTable->szLocaleName));
  578.     }
  579.  
  580.     //RANK
  581.     int rankValue = get_Mob_Rank_Value(csvTable.AsStringByIndex(col++));
  582.     mobTable->bRank = rankValue;
  583.     //TYPE
  584.     int typeValue = get_Mob_Type_Value(csvTable.AsStringByIndex(col++));
  585.     mobTable->bType = typeValue;
  586.     //BATTLE_TYPE
  587.     int battleTypeValue = get_Mob_BattleType_Value(csvTable.AsStringByIndex(col++));
  588.     mobTable->bBattleType = battleTypeValue;
  589.  
  590.     str_to_number(mobTable->bLevel, csvTable.AsStringByIndex(col++));
  591.     //SIZE
  592.     int sizeValue = get_Mob_Size_Value(csvTable.AsStringByIndex(col++));
  593.     mobTable->bSize = sizeValue;
  594.     //AI_FLAG
  595.     int aiFlagValue = get_Mob_AIFlag_Value(csvTable.AsStringByIndex(col++));
  596.     mobTable->dwAIFlag = aiFlagValue;
  597.     //mount_capacity;
  598.     col++;
  599.     //RACE_FLAG
  600.     int raceFlagValue = get_Mob_RaceFlag_Value(csvTable.AsStringByIndex(col++));
  601.     mobTable->dwRaceFlag = raceFlagValue;
  602.     //IMMUNE_FLAG
  603.     int immuneFlagValue = get_Mob_ImmuneFlag_Value(csvTable.AsStringByIndex(col++));
  604.     mobTable->dwImmuneFlag = immuneFlagValue;
  605.  
  606.     str_to_number(mobTable->bEmpire, csvTable.AsStringByIndex(col++));  //col = 11
  607.  
  608.     strlcpy(mobTable->szFolder, csvTable.AsStringByIndex(col++), sizeof(mobTable->szFolder));
  609.  
  610.     str_to_number(mobTable->bOnClickType, csvTable.AsStringByIndex(col++));
  611.  
  612.     str_to_number(mobTable->bStr, csvTable.AsStringByIndex(col++));
  613.     str_to_number(mobTable->bDex, csvTable.AsStringByIndex(col++));
  614.     str_to_number(mobTable->bCon, csvTable.AsStringByIndex(col++));
  615.     str_to_number(mobTable->bInt, csvTable.AsStringByIndex(col++));
  616.     str_to_number(mobTable->dwDamageRange[0], csvTable.AsStringByIndex(col++));
  617.     str_to_number(mobTable->dwDamageRange[1], csvTable.AsStringByIndex(col++));
  618.     str_to_number(mobTable->dwMaxHP, csvTable.AsStringByIndex(col++));
  619.     str_to_number(mobTable->bRegenCycle, csvTable.AsStringByIndex(col++));
  620.     str_to_number(mobTable->bRegenPercent,  csvTable.AsStringByIndex(col++));
  621.     str_to_number(mobTable->dwGoldMin, csvTable.AsStringByIndex(col++));
  622.     str_to_number(mobTable->dwGoldMax, csvTable.AsStringByIndex(col++));
  623.     str_to_number(mobTable->dwExp,  csvTable.AsStringByIndex(col++));
  624.     str_to_number(mobTable->wDef, csvTable.AsStringByIndex(col++));
  625.     str_to_number(mobTable->sAttackSpeed, csvTable.AsStringByIndex(col++));
  626.     str_to_number(mobTable->sMovingSpeed, csvTable.AsStringByIndex(col++));
  627.     str_to_number(mobTable->bAggresiveHPPct, csvTable.AsStringByIndex(col++));
  628.     str_to_number(mobTable->wAggressiveSight, csvTable.AsStringByIndex(col++));
  629.     str_to_number(mobTable->wAttackRange, csvTable.AsStringByIndex(col++));
  630.  
  631.     str_to_number(mobTable->dwDropItemVnum, csvTable.AsStringByIndex(col++));   //32
  632.     str_to_number(mobTable->dwResurrectionVnum, csvTable.AsStringByIndex(col++));
  633.     for (int i = 0; i < MOB_ENCHANTS_MAX_NUM; ++i)
  634.         str_to_number(mobTable->cEnchants[i], csvTable.AsStringByIndex(col++));
  635.  
  636.     for (int i = 0; i < MOB_RESISTS_MAX_NUM; ++i)
  637.         str_to_number(mobTable->cResists[i], csvTable.AsStringByIndex(col++));
  638.  
  639.     str_to_number(mobTable->fDamMultiply, csvTable.AsStringByIndex(col++));
  640.     str_to_number(mobTable->dwSummonVnum, csvTable.AsStringByIndex(col++));
  641.     str_to_number(mobTable->dwDrainSP, csvTable.AsStringByIndex(col++));
  642.  
  643.     //Mob_Color
  644.     ++col;
  645.  
  646.     str_to_number(mobTable->dwPolymorphItemVnum, csvTable.AsStringByIndex(col++));
  647.  
  648.     str_to_number(mobTable->Skills[0].bLevel, csvTable.AsStringByIndex(col++));
  649.     str_to_number(mobTable->Skills[0].dwVnum, csvTable.AsStringByIndex(col++));
  650.     str_to_number(mobTable->Skills[1].bLevel, csvTable.AsStringByIndex(col++));
  651.     str_to_number(mobTable->Skills[1].dwVnum, csvTable.AsStringByIndex(col++));
  652.     str_to_number(mobTable->Skills[2].bLevel, csvTable.AsStringByIndex(col++));
  653.     str_to_number(mobTable->Skills[2].dwVnum, csvTable.AsStringByIndex(col++));
  654.     str_to_number(mobTable->Skills[3].bLevel, csvTable.AsStringByIndex(col++));
  655.     str_to_number(mobTable->Skills[3].dwVnum, csvTable.AsStringByIndex(col++));
  656.     str_to_number(mobTable->Skills[4].bLevel, csvTable.AsStringByIndex(col++));
  657.     str_to_number(mobTable->Skills[4].dwVnum, csvTable.AsStringByIndex(col++));
  658.  
  659.     str_to_number(mobTable->bBerserkPoint, csvTable.AsStringByIndex(col++));
  660.     str_to_number(mobTable->bStoneSkinPoint, csvTable.AsStringByIndex(col++));
  661.     str_to_number(mobTable->bGodSpeedPoint, csvTable.AsStringByIndex(col++));
  662.     str_to_number(mobTable->bDeathBlowPoint, csvTable.AsStringByIndex(col++));
  663.     str_to_number(mobTable->bRevivePoint, csvTable.AsStringByIndex(col++));
  664.  
  665.     sys_log(0, "MOB #%-5d %-24s level: %-3u rank: %u empire: %d", mobTable->dwVnum, mobTable->szLocaleName, mobTable->bLevel, mobTable->bRank, mobTable->bEmpire);
  666.  
  667.     return true;
  668. }
  669.  
  670. bool Set_Proto_Item_Table(TItemTable *itemTable, cCsvTable &csvTable,std::map<int,const char*> &nameMap)
  671. {
  672.     int col = 0;
  673.  
  674.     int dataArray[33];
  675.     for (unsigned int i=0; i<sizeof(dataArray)/sizeof(dataArray[0]);i++) {
  676.         int validCheck = 0;
  677.         if (i==2) {
  678.             dataArray[i] = get_Item_Type_Value(csvTable.AsStringByIndex(col));
  679.             validCheck = dataArray[i];
  680.         } else if (i==3) {
  681.             dataArray[i] = get_Item_SubType_Value(dataArray[i-1], csvTable.AsStringByIndex(col));
  682.             validCheck = dataArray[i];
  683.         } else if (i==5) {
  684.             dataArray[i] = get_Item_AntiFlag_Value(csvTable.AsStringByIndex(col));
  685.             validCheck = dataArray[i];
  686.         } else if (i==6) {
  687.             dataArray[i] = get_Item_Flag_Value(csvTable.AsStringByIndex(col));
  688.             validCheck = dataArray[i];
  689.         } else if (i==7) {
  690.             dataArray[i] = get_Item_WearFlag_Value(csvTable.AsStringByIndex(col));
  691.             validCheck = dataArray[i];
  692.         } else if (i==8) {
  693.             dataArray[i] = get_Item_Immune_Value(csvTable.AsStringByIndex(col));
  694.             validCheck = dataArray[i];
  695.         } else if (i==14) {
  696.             dataArray[i] = get_Item_LimitType_Value(csvTable.AsStringByIndex(col));
  697.             validCheck = dataArray[i];
  698.         } else if (i==16) {
  699.             dataArray[i] = get_Item_LimitType_Value(csvTable.AsStringByIndex(col));
  700.             validCheck = dataArray[i];
  701.         } else if (i==18) {
  702.             dataArray[i] = get_Item_ApplyType_Value(csvTable.AsStringByIndex(col));
  703.             validCheck = dataArray[i];
  704.         } else if (i==20) {
  705.             dataArray[i] = get_Item_ApplyType_Value(csvTable.AsStringByIndex(col));
  706.             validCheck = dataArray[i];
  707.         } else if (i==22) {
  708.             dataArray[i] = get_Item_ApplyType_Value(csvTable.AsStringByIndex(col));
  709.             validCheck = dataArray[i];
  710.         } else {
  711.             str_to_number(dataArray[i], csvTable.AsStringByIndex(col));
  712.         }
  713.  
  714.         if (validCheck == -1)
  715.         {
  716.             std::ostringstream dataStream;
  717.  
  718.             for (unsigned int j = 0; j < i; ++j)
  719.                 dataStream << dataArray[j] << ",";
  720.  
  721.             sys_err("ItemProto Reading Failed : Invalid value. (index: %d, col: %d, value: %s)", i, col, csvTable.AsStringByIndex(col));
  722.             sys_err("\t%d ~ %d Values: %s", 0, i, dataStream.str().c_str());
  723.  
  724.             exit(0);
  725.         }
  726.        
  727.         col = col + 1;
  728.     }
  729.  
  730.     {
  731.         std::string s(csvTable.AsStringByIndex(0));
  732.         int pos = s.find("~");
  733.  
  734.         if (static_cast<long>(std::string::npos) == pos)
  735.         {
  736.             itemTable->dwVnum = dataArray[0];
  737.             itemTable->dwVnumRange = 0;
  738.         }
  739.         else
  740.         {
  741.             std::string s_start_vnum (s.substr(0, pos));
  742.             std::string s_end_vnum (s.substr(pos +1 ));
  743.  
  744.             int start_vnum = atoi(s_start_vnum.c_str());
  745.             int end_vnum = atoi(s_end_vnum.c_str());
  746.             if (0 == start_vnum || (0 != end_vnum && end_vnum < start_vnum))
  747.             {
  748.                 sys_err ("INVALID VNUM %s", s.c_str());
  749.                 return false;
  750.             }
  751.             itemTable->dwVnum = start_vnum;
  752.             itemTable->dwVnumRange = end_vnum - start_vnum;
  753.         }
  754.     }
  755.  
  756.     strlcpy(itemTable->szName, csvTable.AsStringByIndex(1), sizeof(itemTable->szName));
  757.     map<int,const char*>::iterator it;
  758.     it = nameMap.find(itemTable->dwVnum);
  759.  
  760.     if (it != nameMap.end())
  761.     {
  762.         const char * localeName = it->second;
  763.         strlcpy(itemTable->szLocaleName, localeName, sizeof (itemTable->szLocaleName));
  764.     }
  765.     else
  766.     {
  767.         strlcpy(itemTable->szLocaleName, itemTable->szName, sizeof (itemTable->szLocaleName));
  768.     }
  769.     itemTable->bType = dataArray[2];
  770.     itemTable->bSubType = dataArray[3];
  771.     itemTable->bSize = dataArray[4];
  772.     itemTable->dwAntiFlags = dataArray[5];
  773.     itemTable->dwFlags = dataArray[6];
  774.     itemTable->dwWearFlags = dataArray[7];
  775.     itemTable->dwImmuneFlag = dataArray[8];
  776.     itemTable->dwGold = dataArray[9];
  777.     itemTable->dwShopBuyPrice = dataArray[10];
  778.     itemTable->dwRefinedVnum = dataArray[11];
  779.     itemTable->wRefineSet = dataArray[12];
  780.     itemTable->bAlterToMagicItemPct = dataArray[13];
  781.     itemTable->cLimitRealTimeFirstUseIndex = -1;
  782.     itemTable->cLimitTimerBasedOnWearIndex = -1;
  783.  
  784.     int i;
  785.  
  786.     for (i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  787.     {
  788.         itemTable->aLimits[i].bType = dataArray[14+i*2];
  789.         itemTable->aLimits[i].lValue = dataArray[15+i*2];
  790.  
  791.         if (LIMIT_REAL_TIME_START_FIRST_USE == itemTable->aLimits[i].bType)
  792.             itemTable->cLimitRealTimeFirstUseIndex = (char)i;
  793.  
  794.         if (LIMIT_TIMER_BASED_ON_WEAR == itemTable->aLimits[i].bType)
  795.             itemTable->cLimitTimerBasedOnWearIndex = (char)i;
  796.     }
  797.  
  798.     for (i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
  799.     {
  800.         itemTable->aApplies[i].bType = dataArray[18+i*2];
  801.         itemTable->aApplies[i].lValue = dataArray[19+i*2];
  802.     }
  803.  
  804.     for (i = 0; i < ITEM_VALUES_MAX_NUM; ++i)
  805.         itemTable->alValues[i] = dataArray[24+i];
  806.  
  807.     //column for 'Specular'
  808.     itemTable->bGainSocketPct = dataArray[31];
  809.     itemTable->sAddonType = dataArray[32];
  810.  
  811.     //test
  812.     str_to_number(itemTable->bWeight, "0");
  813.            
  814.     return true;
  815. }
  816. #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top