Hey, hab ein Problem wenn ich meine item_proto entpacken will kommt in der debug.txt:
ERROR: (109) Item ApplyType not found
ERROR: (8192) Item WearFlag not found
ERROR: (3->47) Item SubType not found
ItemCSVReader.cpp:
ItemCSVReader.cpp:
Code
- #include "ItemCSVReader.h"
- #include <math.h>
- #include "../../../Client/UserInterface/Locale_inc.h"
- bool bDebugFlag = false;
- void writeDebug(const char* szMsg, int iInput, int type_value)
- {
- static char __buf[512];
- static FILE * f1 = NULL;
- if (NULL == f1)
- fopen_s(&f1, "debug.log", "a+");
- if (type_value)
- _snprintf(__buf, sizeof(__buf), "ERROR: (%d->%d) %s\n", type_value, iInput, szMsg);
- else
- _snprintf(__buf, sizeof(__buf), "ERROR: (%d) %s\n", iInput, szMsg);
- fwrite(__buf, sizeof(char), strlen(__buf), f1);
- }
- 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, string strTok)
- {
- int cutAt; //ÀÚ¸£´ÂÀ§Ä¡
- int index = 0; //¹®ÀÚ¿À妽º
- string* strResult = new string[30]; //°á°úreturn ÇÒº¯¼ö
- //strTokÀ»Ã£À»¶§±îÁö¹Ýº¹
- while ((cutAt = strOrigin.find_first_of(strTok)) != strOrigin.npos)
- {
- if (cutAt > 0) //ÀÚ¸£´ÂÀ§Ä¡°¡0º¸´ÙÅ©¸é(¼º°ø½Ã)
- {
- strResult[index++] = strOrigin.substr(0, cutAt); //°á°ú¹è¿¿¡Ãß°¡
- }
- strOrigin = strOrigin.substr(cutAt+1); //¿øº»ÀºÀÚ¸¥ºÎºÐÁ¦¿ÜÇѳª¸ÓÁö
- }
- if(strOrigin.length() > 0) //¿øº»À̾ÆÁ÷³²¾ÒÀ¸¸é
- {
- strResult[index++] = strOrigin.substr(0, cutAt); //³ª¸ÓÁö¸¦°á°ú¹è¿¿¡Ãß°¡
- }
- for( int i=0;i<index;i++)
- {
- strResult[i] = trim(strResult[i]);
- }
- return strResult; //°á°úreturn
- }
- string arITVType[] = {"ITEM_NONE", "ITEM_WEAPON",
- "ITEM_ARMOR", "ITEM_USE",
- "ITEM_AUTOUSE", "ITEM_MATERIAL",
- "ITEM_SPECIAL", "ITEM_TOOL",
- "ITEM_LOTTERY", "ITEM_ELK", //10°³
- "ITEM_METIN", "ITEM_CONTAINER",
- "ITEM_FISH", "ITEM_ROD",
- "ITEM_RESOURCE", "ITEM_CAMPFIRE",
- "ITEM_UNIQUE", "ITEM_SKILLBOOK",
- "ITEM_QUEST", "ITEM_POLYMORPH", //20°³
- "ITEM_TREASURE_BOX", "ITEM_TREASURE_KEY",
- "ITEM_SKILLFORGET", "ITEM_GIFTBOX",
- "ITEM_PICK", "ITEM_HAIR",
- "ITEM_TOTEM", "ITEM_BLEND",
- "ITEM_COSTUME", "ITEM_DS", //30°³
- "ITEM_SPECIAL_DS", "ITEM_EXTRACT",
- "ITEM_SECONDARY_COIN", //33°³
- "ITEM_RING",
- "ITEM_BELT", //35°³ (EItemTypes °ªÀ¸·Î Ä¡¸é 34)
- "ITEM_PET", "ITEM_MEDIUM", // 36,37
- "ITEM_GACHA", // 38
- #ifdef ENABLE_ATTR_TRANSFER_SYSTEM
- "ITEM_TRANSFER_SCROLL",
- #endif
- };
- int get_Item_Type_Value(string inputString)
- {
- int retInt = -1;
- //cout << "Type : " << typeStr << " -> ";
- for (int j=0;j<sizeof(arITVType)/sizeof(arITVType[0]);j++) {
- string tempString = arITVType[j];
- if (inputString.find(tempString)!=string::npos && tempString.find(inputString)!=string::npos) {
- //cout << j << " ";
- retInt = j;
- break;
- }
- }
- //cout << endl;
- return retInt;
- }
- string set_Item_Type_Value(int iInput) // enum -1=None
- {
- if (iInput==(BYTE)-1)
- return "NONE";
- // return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arITVType)/sizeof(arITVType[0]);i++)
- {
- tmpFlag = i;
- if (iInput == tmpFlag)
- {
- if (bDebugFlag)
- iInput = -1;
- inputString = arITVType[i];
- break;
- }
- }
- if (bDebugFlag && iInput!=-1)
- writeDebug("Item Type not found", iInput);
- return inputString;
- }
- string arIAFVSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
- "WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR", "WEAPON_CLAW", "WEAPON_QUIVER", "WEAPON_BOUQUET"};
- string arIAFVSub2[] = { "ARMOR_BODY", "ARMOR_HEAD", "ARMOR_SHIELD", "ARMOR_WRIST", "ARMOR_FOOTS",
- "ARMOR_NECK", "ARMOR_EAR", "ARMOR_NUM_TYPES"};
- string arIAFVSub3[] = { "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_CHANGE_COSTUME_ATTR", "USE_RESET_COSTUME_ATTR", "USE_UNK33", "USE_CHANGE_ATTRIBUTE_PLUS",
- #ifdef ATTR_LOCK
- "USE_ADD_ATTRIBUTE_LOCK",
- "USE_CHANGE_ATTRIBUTE_LOCK",
- "USE_DELETE_ATTRIBUTE_LOCK",
- #endif
- #ifdef ENABLE_ATTR_COSTUMES
- "USE_CHANGE_ATTR_COSTUME",
- "USE_ADD_ATTR_COSTUME1",
- "USE_ADD_ATTR_COSTUME2",
- "USE_REMOVE_ATTR_COSTUME",
- #endif
- };
- string arIAFVSub4[] = { "AUTOUSE_POTION", "AUTOUSE_ABILITY_UP", "AUTOUSE_BOMB", "AUTOUSE_GOLD", "AUTOUSE_MONEYBAG", "AUTOUSE_TREASURE_BOX"};
- string arIAFVSub5[] = { "MATERIAL_LEATHER", "MATERIAL_BLOOD", "MATERIAL_ROOT", "MATERIAL_NEEDLE", "MATERIAL_JEWEL",
- "MATERIAL_DS_REFINE_NORMAL", "MATERIAL_DS_REFINE_BLESSED", "MATERIAL_DS_REFINE_HOLLY"};
- string arIAFVSub6[] = { "SPECIAL_MAP", "SPECIAL_KEY", "SPECIAL_DOC", "SPECIAL_SPIRIT"};
- string arIAFVSub7[] = { "TOOL_FISHING_ROD" };
- string arIAFVSub8[] = { "LOTTERY_TICKET", "LOTTERY_INSTANT" };
- string arIAFVSub10[] = { "METIN_NORMAL", "METIN_GOLD" };
- string arIAFVSub12[] = { "FISH_ALIVE", "FISH_DEAD"};
- string arIAFVSub14[] = { "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" };
- string arIAFVSub16[] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_3", "UNIQUE_4", "UNIQUE_5",
- "UNIQUE_6", "UNIQUE_7", "UNIQUE_8", "UNIQUE_9", "USE_SPECIAL"};
- string arIAFVSub28[] = { "COSTUME_BODY", "COSTUME_HAIR", "COSTUME_MOUNT", "COSTUME_ACCE", "COSTUME_WEAPON" };
- string arIAFVSub29[] = { "DS_SLOT1", "DS_SLOT2", "DS_SLOT3", "DS_SLOT4", "DS_SLOT5", "DS_SLOT6" };
- string arIAFVSub31[] = { "EXTRACT_DRAGON_SOUL", "EXTRACT_DRAGON_HEART" };
- string* arIAFVSubType[] = {0, //0
- arIAFVSub1, //1
- arIAFVSub2, //2
- arIAFVSub3, //3
- arIAFVSub4, //4
- arIAFVSub5, //5
- arIAFVSub6, //6
- arIAFVSub7, //7
- arIAFVSub8, //8
- 0, //9
- arIAFVSub10, //10
- 0, //11
- arIAFVSub12, //12
- 0, //13
- arIAFVSub14, //14
- 0, //15
- arIAFVSub16, //16
- 0, //17
- 0, //18
- 0, //19
- 0, //20
- 0, //21
- 0, //22
- 0, //23
- 0, //24
- 0, //25
- 0, //26
- 0, //27
- arIAFVSub28, //28
- arIAFVSub29, //29
- arIAFVSub29, //30
- arIAFVSub31, //31
- 0, // 32
- 0, // 33 ¹ÝÁö
- 0, // 34 º§Æ®
- 0, // 35
- 0, // 36
- 0, // 37
- 0, // 38
- #ifdef ENABLE_ATTR_TRANSFER_SYSTEM
- 0, // 39
- #endif
- };
- int arNumberOfSubtype[] =
- {
- 0,
- sizeof(arIAFVSub1)/sizeof(arIAFVSub1[0]),
- sizeof(arIAFVSub2)/sizeof(arIAFVSub2[0]),
- sizeof(arIAFVSub3)/sizeof(arIAFVSub3[0]),
- sizeof(arIAFVSub4)/sizeof(arIAFVSub4[0]),
- sizeof(arIAFVSub5)/sizeof(arIAFVSub5[0]),
- sizeof(arIAFVSub6)/sizeof(arIAFVSub6[0]),
- sizeof(arIAFVSub7)/sizeof(arIAFVSub7[0]),
- sizeof(arIAFVSub8)/sizeof(arIAFVSub8[0]),
- 0,
- sizeof(arIAFVSub10)/sizeof(arIAFVSub10[0]),
- 0,
- sizeof(arIAFVSub12)/sizeof(arIAFVSub12[0]),
- 0,
- sizeof(arIAFVSub14)/sizeof(arIAFVSub14[0]),
- 0,
- sizeof(arIAFVSub16)/sizeof(arIAFVSub16[0]),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- sizeof(arIAFVSub28)/sizeof(arIAFVSub28[0]),
- sizeof(arIAFVSub29)/sizeof(arIAFVSub29[0]),
- sizeof(arIAFVSub29)/sizeof(arIAFVSub29[0]),
- sizeof(arIAFVSub31)/sizeof(arIAFVSub31[0]),
- 0,
- 0,
- 0, //34
- 0, //35
- 0, //36
- 0, // 37
- 0, // 38
- #ifdef ENABLE_ATTR_TRANSFER_SYSTEM
- 0, // 39
- #endif
- };
- int get_Item_SubType_Value(int type_value, string inputString)
- {
- //¾ÆÀÌÅÛ Å¸ÀÔÀÇ ¼ºêŸÀÔ ¾î·¹ÀÌ°¡ Á¸ÀçÇÏ´ÂÁö ¾Ë¾Æº¸°í, ¾øÀ¸¸é 0 ¸®ÅÏ
- if (arIAFVSubType[type_value]==0) {
- return 0;
- }
- //
- int retInt = -1;
- //cout << "SubType : " << subTypeStr << " -> ";
- for (int j=0;j<arNumberOfSubtype[type_value];j++) {
- string tempString = arIAFVSubType[type_value][j];
- string tempInputString = trim(inputString);
- if (tempInputString.compare(tempString)==0)
- {
- //cout << j << " ";
- retInt = j;
- break;
- }
- }
- //cout << endl;
- return retInt;
- }
- string set_Item_SubType_Value(int type_value, int iInput) // enum -1=None
- {
- // if (type_value==-1 || arIAFVSubType[type_value]==0 || iInput==-1)
- if (type_value==(BYTE)-1 || arIAFVSubType[type_value]==0 || iInput==(BYTE)-1)
- return "0";
- // return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<arNumberOfSubtype[type_value];i++)
- {
- tmpFlag = i;
- if (iInput == tmpFlag)
- {
- if (bDebugFlag)
- iInput = -1;
- inputString = arIAFVSubType[type_value][i];
- break;
- }
- }
- if (bDebugFlag && iInput!=-1)
- writeDebug("Item SubType not found", iInput, type_value);
- return inputString;
- }
- string arIAFVAntiFlag[] = {"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", "ANTI_WOLFMAN",
- "ANTI_PET20", "ANTI_PET21"};
- int get_Item_AntiFlag_Value(string inputString)
- {
- int retValue = 0;
- string* arInputString = StringSplit(inputString, "|"); //ÇÁ·ÎÅä Á¤º¸ ³»¿ëÀ» ´Ü¾îº°·Î ÂÉ°µ ¹è¿.
- for(int i =0;i<sizeof(arIAFVAntiFlag)/sizeof(arIAFVAntiFlag[0]);i++) {
- string tempString = arIAFVAntiFlag[i];
- for (int j=0; j<30 ; j++) //ÃÖ´ë 30°³ ´Ü¾î±îÁö. (ÇϵåÄÚµù)
- {
- string tempString2 = arInputString[j];
- if (tempString2.compare(tempString)==0) { //ÀÏÄ¡ÇÏ´ÂÁö È®ÀÎ.
- retValue = retValue + static_cast<int>(pow(2.0, static_cast<double>(i)));
- }
- if(tempString2.compare("") == 0)
- break;
- }
- }
- delete []arInputString;
- //cout << "AntiFlag : " << antiFlagStr << " -> " << retValue << endl;
- return retValue;
- }
- string set_Item_AntiFlag_Value(int iInput) // set
- {
- if (iInput==0)
- return "NONE";
- // return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arIAFVAntiFlag)/sizeof(arIAFVAntiFlag[0]);i++)
- {
- tmpFlag = static_cast<int>(pow(2.0, static_cast<double>(i)));
- if (iInput & tmpFlag)
- {
- if (bDebugFlag)
- iInput -= tmpFlag;
- if (!!inputString.compare(""))
- inputString += " | ";
- inputString += arIAFVAntiFlag[i];
- }
- }
- if (bDebugFlag && iInput)
- writeDebug("Item AntiFlag not found", iInput);
- return inputString;
- }
- string arIFVFlag[] = {"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", "ITEM_QUEST", "LOG", "STACKABLE", "SLOW_QUERY", "REFINEABLE", "IRREMOVABLE", "ITEM_APPLICABLE"};
- int get_Item_Flag_Value(string inputString)
- {
- int retValue = 0;
- string* arInputString = StringSplit(inputString, "|"); //ÇÁ·ÎÅä Á¤º¸ ³»¿ëÀ» ´Ü¾îº°·Î ÂÉ°µ ¹è¿.
- for(int i =0;i<sizeof(arIFVFlag)/sizeof(arIFVFlag[0]);i++) {
- string tempString = arIFVFlag[i];
- for (int j=0; j<30 ; j++) //ÃÖ´ë 30°³ ´Ü¾î±îÁö. (ÇϵåÄÚµù)
- {
- string tempString2 = arInputString[j];
- if (tempString2.compare(tempString)==0) { //ÀÏÄ¡ÇÏ´ÂÁö È®ÀÎ.
- retValue = retValue + static_cast<int>(pow(2.0, static_cast<double>(i)));
- }
- if(tempString2.compare("") == 0)
- break;
- }
- }
- delete []arInputString;
- //cout << "Flag : " << flagStr << " -> " << retValue << endl;
- return retValue;
- }
- string set_Item_Flag_Value(int iInput) // set
- {
- if (iInput==0)
- return "NONE";
- // return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arIFVFlag)/sizeof(arIFVFlag[0]);i++)
- {
- tmpFlag = static_cast<int>(pow(2.0, static_cast<double>(i)));
- if (iInput & tmpFlag)
- {
- if (bDebugFlag)
- iInput -= tmpFlag;
- if (!!inputString.compare(""))
- inputString += " | ";
- inputString += arIFVFlag[i];
- }
- }
- if (bDebugFlag && iInput)
- writeDebug("Item Flag not found", iInput);
- return inputString;
- }
- string arIWFVWearrFlag[] = {"WEAR_BODY", "WEAR_HEAD", "WEAR_FOOTS", "WEAR_WRIST", "WEAR_WEAPON", "WEAR_NECK", "WEAR_EAR", "WEAR_SHIELD", "WEAR_UNIQUE",
- "WEAR_ARROW", "WEAR_HAIR", "WEAR_ABILITY"};
- int get_Item_WearFlag_Value(string inputString)
- {
- int retValue = 0;
- string* arInputString = StringSplit(inputString, "|"); //ÇÁ·ÎÅä Á¤º¸ ³»¿ëÀ» ´Ü¾îº°·Î ÂÉ°µ ¹è¿.
- for(int i =0;i<sizeof(arIWFVWearrFlag)/sizeof(arIWFVWearrFlag[0]);i++) {
- string tempString = arIWFVWearrFlag[i];
- for (int j=0; j<30 ; j++) //ÃÖ´ë 30°³ ´Ü¾î±îÁö. (ÇϵåÄÚµù)
- {
- string tempString2 = arInputString[j];
- if (tempString2.compare(tempString)==0) { //ÀÏÄ¡ÇÏ´ÂÁö È®ÀÎ.
- retValue = retValue + static_cast<int>(pow(2.0, static_cast<double>(i)));
- }
- if(tempString2.compare("") == 0)
- break;
- }
- }
- delete []arInputString;
- //cout << "WearFlag : " << wearFlagStr << " -> " << retValue << endl;
- return retValue;
- }
- string set_Item_WearFlag_Value(int iInput) // set
- {
- if (iInput==0)
- return "NONE";
- // return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arIWFVWearrFlag)/sizeof(arIWFVWearrFlag[0]);i++)
- {
- tmpFlag = static_cast<int>(pow(2.0, static_cast<double>(i)));
- if (iInput & tmpFlag)
- {
- if (bDebugFlag)
- iInput -= tmpFlag;
- if (!!inputString.compare(""))
- inputString += " | ";
- inputString += arIWFVWearrFlag[i];
- }
- }
- if (bDebugFlag && iInput)
- writeDebug("Item WearFlag not found", iInput);
- return inputString;
- }
- string arIIVImmune[] = {"PARA","CURSE","STUN","SLEEP","SLOW","POISON","TERROR","REFLECT"};
- int get_Item_Immune_Value(string inputString)
- {
- int retValue = 0;
- string* arInputString = StringSplit(inputString, "|"); //ÇÁ·ÎÅä Á¤º¸ ³»¿ëÀ» ´Ü¾îº°·Î ÂÉ°µ ¹è¿.
- for(int i =0;i<sizeof(arIIVImmune)/sizeof(arIIVImmune[0]);i++) {
- string tempString = arIIVImmune[i];
- for (int j=0; j<30 ; j++) //ÃÖ´ë 30°³ ´Ü¾î±îÁö. (ÇϵåÄÚµù)
- {
- string tempString2 = arInputString[j];
- if (tempString2.compare(tempString)==0) { //ÀÏÄ¡ÇÏ´ÂÁö È®ÀÎ.
- retValue = retValue + static_cast<int>(pow(2.0, static_cast<double>(i)));
- }
- if(tempString2.compare("") == 0)
- break;
- }
- }
- delete []arInputString;
- //cout << "Immune : " << immuneStr << " -> " << retValue << endl;
- return retValue;
- }
- string set_Item_Immune_Value(int iInput) // set
- {
- if (iInput==0)
- return "NONE";
- // return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arIIVImmune)/sizeof(arIIVImmune[0]);i++)
- {
- tmpFlag = static_cast<int>(pow(2.0, static_cast<double>(i)));
- if (iInput & tmpFlag)
- {
- if (bDebugFlag)
- iInput -= tmpFlag;
- if (!!inputString.compare(""))
- inputString += " | ";
- inputString += arIIVImmune[i];
- }
- }
- if (bDebugFlag && iInput)
- writeDebug("Item ImmuneFlag not found", iInput);
- return inputString;
- }
- string arILTVLimitType[] = {"LIMIT_NONE", "LEVEL", "STR", "DEX", "INT", "CON", "PC_BANG", "REAL_TIME", "REAL_TIME_FIRST_USE", "TIMER_BASED_ON_WEAR"};
- int get_Item_LimitType_Value(string inputString)
- {
- int retInt = -1;
- //cout << "LimitType : " << limitTypeStr << " -> ";
- for (int j=0;j<sizeof(arILTVLimitType)/sizeof(arILTVLimitType[0]);j++) {
- string tempString = arILTVLimitType[j];
- string tempInputString = trim(inputString);
- if (tempInputString.compare(tempString)==0)
- {
- //cout << j << " ";
- retInt = j;
- break;
- }
- }
- //cout << endl;
- return retInt;
- }
- string set_Item_LimitType_Value(int iInput) // enum -1=None
- {
- if (iInput==(BYTE)-1)
- return "NONE";
- // return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arILTVLimitType)/sizeof(arILTVLimitType[0]);i++)
- {
- tmpFlag = i;
- if (iInput == tmpFlag)
- {
- if (bDebugFlag)
- iInput = -1;
- inputString = arILTVLimitType[i];
- break;
- }
- }
- if (bDebugFlag && iInput!=-1)
- writeDebug("Item LimitType not found", iInput);
- return inputString;
- }
- string arIATVApplyType[] = {"APPLY_NONE", "APPLY_MAX_HP", "APPLY_MAX_SP", "APPLY_CON", "APPLY_INT", "APPLY_STR", "APPLY_DEX", "APPLY_ATT_SPEED",
- "APPLY_MOV_SPEED", "APPLY_CAST_SPEED", "APPLY_HP_REGEN", "APPLY_SP_REGEN", "APPLY_POISON_PCT", "APPLY_STUN_PCT",
- "APPLY_SLOW_PCT", "APPLY_CRITICAL_PCT", "APPLY_PENETRATE_PCT", "APPLY_ATTBONUS_HUMAN", "APPLY_ATTBONUS_ANIMAL",
- "APPLY_ATTBONUS_ORC", "APPLY_ATTBONUS_MILGYO", "APPLY_ATTBONUS_UNDEAD", "APPLY_ATTBONUS_DEVIL", "APPLY_STEAL_HP",
- "APPLY_STEAL_SP", "APPLY_MANA_BURN_PCT", "APPLY_DAMAGE_SP_RECOVER", "APPLY_BLOCK", "APPLY_DODGE", "APPLY_RESIST_SWORD",
- "APPLY_RESIST_TWOHAND", "APPLY_RESIST_DAGGER", "APPLY_RESIST_BELL", "APPLY_RESIST_FAN", "APPLY_RESIST_BOW", "APPLY_RESIST_FIRE",
- "APPLY_RESIST_ELEC", "APPLY_RESIST_MAGIC", "APPLY_RESIST_WIND", "APPLY_REFLECT_MELEE", "APPLY_REFLECT_CURSE", "APPLY_POISON_REDUCE",
- "APPLY_KILL_SP_RECOVER", "APPLY_EXP_DOUBLE_BONUS", "APPLY_GOLD_DOUBLE_BONUS", "APPLY_ITEM_DROP_BONUS", "APPLY_POTION_BONUS",
- "APPLY_KILL_HP_RECOVER", "APPLY_IMMUNE_STUN", "APPLY_IMMUNE_SLOW", "APPLY_IMMUNE_FALL", "APPLY_SKILL", "APPLY_BOW_DISTANCE",
- "APPLY_ATT_GRADE_BONUS", "APPLY_DEF_GRADE_BONUS", "APPLY_MAGIC_ATT_GRADE", "APPLY_MAGIC_DEF_GRADE", "APPLY_CURSE_PCT",
- "APPLY_MAX_STAMINA", "APPLY_ATTBONUS_WARRIOR", "APPLY_ATTBONUS_ASSASSIN", "APPLY_ATTBONUS_SURA", "APPLY_ATTBONUS_SHAMAN",
- "APPLY_ATTBONUS_MONSTER", "APPLY_MALL_ATTBONUS", "APPLY_MALL_DEFBONUS", "APPLY_MALL_EXPBONUS", "APPLY_MALL_ITEMBONUS",
- "APPLY_MALL_GOLDBONUS", "APPLY_MAX_HP_PCT", "APPLY_MAX_SP_PCT", "APPLY_SKILL_DAMAGE_BONUS", "APPLY_NORMAL_HIT_DAMAGE_BONUS",
- "APPLY_SKILL_DEFEND_BONUS", "APPLY_NORMAL_HIT_DEFEND_BONUS", "APPLY_PC_BANG_EXP_BONUS", "APPLY_PC_BANG_DROP_BONUS",
- "APPLY_EXTRACT_HP_PCT", "APPLY_RESIST_WARRIOR", "APPLY_RESIST_ASSASSIN", "APPLY_RESIST_SURA", "APPLY_RESIST_SHAMAN",
- "APPLY_ENERGY", "APPLY_DEF_GRADE", "APPLY_COSTUME_ATTR_BONUS", "APPLY_MAGIC_ATTBONUS_PER", "APPLY_MELEE_MAGIC_ATTBONUS_PER",
- "APPLY_RESIST_ICE", "APPLY_RESIST_EARTH", "APPLY_RESIST_DARK", "APPLY_ANTI_CRITICAL_PCT", "APPLY_ANTI_PENETRATE_PCT",
- "APPLY_BLEEDING_REDUCE", "APPLY_BLEEDING_PCT", "APPLY_ATTBONUS_WOLFMAN", "APPLY_RESIST_WOLFMAN", "APPLY_RESIST_CLAW",
- "APPLY_ACCEDRAIN_RATE", "APPLY_RESIST_MAGIC_REDUCTION" // 97,98
- };
- int get_Item_ApplyType_Value(string inputString)
- {
- int retInt = -1;
- //cout << "ApplyType : " << applyTypeStr << " -> ";
- for (int j=0;j<sizeof(arIATVApplyType)/sizeof(arIATVApplyType[0]);j++) {
- string tempString = arIATVApplyType[j];
- string tempInputString = trim(inputString);
- if (tempInputString.compare(tempString)==0)
- {
- //cout << j << " ";
- retInt = j;
- break;
- }
- }
- //cout << endl;
- return retInt;
- }
- string set_Item_ApplyType_Value(int iInput) // enum -1=None
- {
- // if (iInput==-1)
- if (iInput==(BYTE)-1)
- return "NONE";
- // return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arIATVApplyType)/sizeof(arIATVApplyType[0]);i++)
- {
- tmpFlag = i;
- if (iInput == tmpFlag)
- {
- if (bDebugFlag)
- iInput = -1;
- inputString = arIATVApplyType[i];
- break;
- }
- }
- if (bDebugFlag && iInput!=-1)
- writeDebug("Item ApplyType not found", iInput);
- return inputString;
- }
- //¸ó½ºÅÍ ÇÁ·ÎÅäµµ Àд´Ù.
- string arMRVRank[] = {"PAWN", "S_PAWN", "KNIGHT", "S_KNIGHT", "BOSS", "KING"};
- int get_Mob_Rank_Value(string inputString)
- {
- int retInt = -1;
- //cout << "Rank : " << rankStr << " -> ";
- for (int j=0;j<sizeof(arMRVRank)/sizeof(arMRVRank[0]);j++) {
- string tempString = arMRVRank[j];
- string tempInputString = trim(inputString);
- if (tempInputString.compare(tempString)==0)
- {
- //cout << j << " ";
- retInt = j;
- break;
- }
- }
- //cout << endl;
- return retInt;
- }
- string set_Mob_Rank_Value(int iInput) // enum -1=None
- {
- if (iInput==(BYTE)-1)
- return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arMRVRank)/sizeof(arMRVRank[0]);i++)
- {
- tmpFlag = i;
- if (iInput == tmpFlag)
- {
- if (bDebugFlag)
- iInput = -1;
- inputString = arMRVRank[i];
- break;
- }
- }
- if (bDebugFlag && iInput!=-1)
- writeDebug("Mob Rank not found", iInput);
- return inputString;
- }
- string arMTVType[] = { "MONSTER", "NPC", "STONE", "WARP", "DOOR", "BUILDING", "PC", "POLYMORPH_PC", "HORSE", "GOTO", "PET"};
- int get_Mob_Type_Value(string inputString)
- {
- int retInt = -1;
- //cout << "Type : " << typeStr << " -> ";
- for (int j=0;j<sizeof(arMTVType)/sizeof(arMTVType[0]);j++) {
- string tempString = arMTVType[j];
- string tempInputString = trim(inputString);
- if (tempInputString.compare(tempString)==0)
- {
- //cout << j << " ";
- retInt = j;
- break;
- }
- }
- //cout << endl;
- return retInt;
- }
- string set_Mob_Type_Value(int iInput) // enum -1=None
- {
- if (iInput==(BYTE)-1)
- return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arMTVType)/sizeof(arMTVType[0]);i++)
- {
- tmpFlag = i;
- if (iInput == tmpFlag)
- {
- if (bDebugFlag)
- iInput = -1;
- inputString = arMTVType[i];
- break;
- }
- }
- if (bDebugFlag && iInput!=-1)
- writeDebug("Mob Type not found", iInput);
- return inputString;
- }
- string arMBTVBattleType[] = { "MELEE", "RANGE", "MAGIC", "SPECIAL", "POWER", "TANKER", "SUPER_POWER", "SUPER_TANKER"};
- int get_Mob_BattleType_Value(string inputString)
- {
- int retInt = -1;
- //cout << "Battle Type : " << battleTypeStr << " -> ";
- for (int j=0;j<sizeof(arMBTVBattleType)/sizeof(arMBTVBattleType[0]);j++) {
- string tempString = arMBTVBattleType[j];
- string tempInputString = trim(inputString);
- if (tempInputString.compare(tempString)==0)
- {
- //cout << j << " ";
- retInt = j;
- break;
- }
- }
- //cout << endl;
- return retInt;
- }
- string set_Mob_BattleType_Value(int iInput) // enum -1=None
- {
- if (iInput==(BYTE)-1)
- return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arMBTVBattleType)/sizeof(arMBTVBattleType[0]);i++)
- {
- tmpFlag = i;
- if (iInput == tmpFlag)
- {
- if (bDebugFlag)
- iInput = -1;
- inputString = arMBTVBattleType[i];
- break;
- }
- }
- if (bDebugFlag && iInput!=-1)
- writeDebug("Mob BattleType not found", iInput);
- return inputString;
- }
- string arMSVSize[] = { "SMALL", "MEDIUM", "BIG"};
- int get_Mob_Size_Value(string inputString)
- {
- int retInt = 0;
- //cout << "Size : " << sizeStr << " -> ";
- for (int j=0;j<sizeof(arMSVSize)/sizeof(arMSVSize[0]);j++) {
- string tempString = arMSVSize[j];
- string tempInputString = trim(inputString);
- if (tempInputString.compare(tempString)==0)
- {
- //cout << j << " ";
- retInt = j + 1;
- break;
- }
- }
- //cout << endl;
- return retInt;
- }
- string set_Mob_Size_Value(int iInput) // enum 0=None
- {
- if (iInput==0)
- return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arMSVSize)/sizeof(arMSVSize[0]);i++)
- {
- tmpFlag = i+1;
- if (iInput == tmpFlag)
- {
- if (bDebugFlag)
- iInput = 0;
- inputString = arMSVSize[i];
- break;
- }
- }
- if (bDebugFlag && iInput)
- writeDebug("Mob Size not found", iInput);
- return inputString;
- }
- string arMOBAIFVAIFlag[] = {"AGGR","NOMOVE","COWARD","NOATTSHINSU","NOATTCHUNJO","NOATTJINNO","ATTMOB","BERSERK","STONESKIN","GODSPEED","DEATHBLOW","REVIVE","HEALER",
- "UNK13","UNK14"
- };
- int get_Mob_AIFlag_Value(string inputString)
- {
- int retValue = 0;
- string* arInputString = StringSplit(inputString, ","); //ÇÁ·ÎÅä Á¤º¸ ³»¿ëÀ» ´Ü¾îº°·Î ÂÉ°µ ¹è¿.
- for(int i =0;i<sizeof(arMOBAIFVAIFlag)/sizeof(arMOBAIFVAIFlag[0]);i++) {
- string tempString = arMOBAIFVAIFlag[i];
- for (int j=0; j<30 ; j++) //ÃÖ´ë 30°³ ´Ü¾î±îÁö. (ÇϵåÄÚµù)
- {
- string tempString2 = arInputString[j];
- if (tempString2.compare(tempString)==0) { //ÀÏÄ¡ÇÏ´ÂÁö È®ÀÎ.
- retValue = retValue + static_cast<int>(pow(2.0, static_cast<double>(i)));
- }
- if(tempString2.compare("") == 0)
- break;
- }
- }
- delete []arInputString;
- //cout << "AIFlag : " << aiFlagStr << " -> " << retValue << endl;
- return retValue;
- }
- string set_Mob_AIFlag_Value(int iInput) // set
- {
- if (iInput==0)
- return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arMOBAIFVAIFlag)/sizeof(arMOBAIFVAIFlag[0]);i++)
- {
- tmpFlag = static_cast<int>(pow(2.0, static_cast<double>(i)));
- if (iInput & tmpFlag)
- {
- if (bDebugFlag)
- iInput -= tmpFlag;
- if (!!inputString.compare(""))
- inputString += ",";
- inputString += arMOBAIFVAIFlag[i];
- }
- }
- if (bDebugFlag && iInput)
- writeDebug("Mob AIFlag not found", iInput);
- return inputString;
- }
- string arMRFVRaceFlag[] = {"ANIMAL","UNDEAD","DEVIL","HUMAN","ORC","MILGYO","INSECT","FIRE","ICE","DESERT","TREE",
- "ATT_ELEC","ATT_FIRE","ATT_ICE","ATT_WIND","ATT_EARTH","ATT_DARK"};
- int get_Mob_RaceFlag_Value(string inputString)
- {
- int retValue = 0;
- // string* arInputString = StringSplit(inputString, "|"); //ÇÁ·ÎÅä Á¤º¸ ³»¿ëÀ» ´Ü¾îº°·Î ÂÉ°µ ¹è¿.
- string* arInputString = StringSplit(inputString, ","); // @fixme201
- for(int i =0;i<sizeof(arMRFVRaceFlag)/sizeof(arMRFVRaceFlag[0]);i++) {
- string tempString = arMRFVRaceFlag[i];
- for (int j=0; j<30 ; j++) //ÃÖ´ë 30°³ ´Ü¾î±îÁö. (ÇϵåÄÚµù)
- {
- string tempString2 = arInputString[j];
- if (tempString2.compare(tempString)==0) { //ÀÏÄ¡ÇÏ´ÂÁö È®ÀÎ.
- retValue = retValue + static_cast<int>(pow(2.0, static_cast<double>(i)));
- }
- if(tempString2.compare("") == 0)
- break;
- }
- }
- delete []arInputString;
- //cout << "Race Flag : " << raceFlagStr << " -> " << retValue << endl;
- return retValue;
- }
- string set_Mob_RaceFlag_Value(int iInput) // set
- {
- if (iInput==0)
- return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arMRFVRaceFlag)/sizeof(arMRFVRaceFlag[0]);i++)
- {
- tmpFlag = static_cast<int>(pow(2.0, static_cast<double>(i)));
- if (iInput & tmpFlag)
- {
- if (bDebugFlag)
- iInput -= tmpFlag;
- if (!!inputString.compare(""))
- inputString += ",";
- inputString += arMRFVRaceFlag[i];
- }
- }
- if (bDebugFlag && iInput)
- writeDebug("Mob RaceFlag not found", iInput);
- return inputString;
- }
- string arMIFVImmuneFlag[] = {"STUN","SLOW","FALL","CURSE","POISON","TERROR", "REFLECT"};
- int get_Mob_ImmuneFlag_Value(string inputString)
- {
- int retValue = 0;
- string* arInputString = StringSplit(inputString, ","); //ÇÁ·ÎÅä Á¤º¸ ³»¿ëÀ» ´Ü¾îº°·Î ÂÉ°µ ¹è¿.
- for(int i =0;i<sizeof(arMIFVImmuneFlag)/sizeof(arMIFVImmuneFlag[0]);i++) {
- string tempString = arMIFVImmuneFlag[i];
- for (int j=0; j<30 ; j++) //ÃÖ´ë 30°³ ´Ü¾î±îÁö. (ÇϵåÄÚµù)
- {
- string tempString2 = arInputString[j];
- if (tempString2.compare(tempString)==0) { //ÀÏÄ¡ÇÏ´ÂÁö È®ÀÎ.
- retValue = retValue + static_cast<int>(pow(2.0, static_cast<double>(i)));
- }
- if(tempString2.compare("") == 0)
- break;
- }
- }
- delete []arInputString;
- //cout << "Immune Flag : " << immuneFlagStr << " -> " << retValue << endl;
- return retValue;
- }
- string set_Mob_ImmuneFlag_Value(int iInput) // set
- {
- if (iInput==0)
- return "";
- string inputString("");
- int tmpFlag;
- for(int i =0;i<sizeof(arMIFVImmuneFlag)/sizeof(arMIFVImmuneFlag[0]);i++)
- {
- tmpFlag = static_cast<int>(pow(2.0, static_cast<double>(i)));
- if (iInput & tmpFlag)
- {
- if (bDebugFlag)
- iInput -= tmpFlag;
- if (!!inputString.compare(""))
- inputString += ",";
- inputString += arMIFVImmuneFlag[i];
- }
- }
- if (bDebugFlag && iInput)
- writeDebug("Mob ImmuneFlag not found", iInput);
- return inputString;
- }
dump_proto.cpp:
Code
- #include "dump_proto.h"
- bool LoadNPrint = false;
- CPythonNonPlayer::TMobTable * m_pMobTable = NULL;
- int m_iMobTableSize = 0;
- CItemData::TItemTable * m_pItemTable = NULL;
- int m_iItemTableSize = 0;
- bool Set_Proto_Mob_Table(CPythonNonPlayer::TMobTable *mobTable, cCsvTable &csvTable, std::map<int,const char*> &nameMap)
- {
- int col = 0;
- mobTable->dwVnum = atoi(csvTable.AsStringByIndex(col++));
- strncpy(mobTable->szName, csvTable.AsStringByIndex(col++), CHARACTER_NAME_MAX_LEN);
- std::map<int,const char*>::iterator it;
- it = nameMap.find(mobTable->dwVnum);
- if (it != nameMap.end()) {
- const char * localeName = it->second;
- strncpy(mobTable->szLocaleName, localeName, sizeof (mobTable->szLocaleName));
- } else { //³×ÀÓ ÆÄÀÏÀÌ ¾øÀ¸¸é, ÇѱÛÀ» ±×´ë·Î »ç¿ë.
- strncpy(mobTable->szLocaleName, mobTable->szName, sizeof (mobTable->szLocaleName));
- }
- //4. RANK
- int rankValue = get_Mob_Rank_Value(csvTable.AsStringByIndex(col++));
- mobTable->bRank = rankValue;
- //5. TYPE
- int typeValue = get_Mob_Type_Value(csvTable.AsStringByIndex(col++));
- mobTable->bType = typeValue;
- //6. BATTLE_TYPE
- int battleTypeValue = get_Mob_BattleType_Value(csvTable.AsStringByIndex(col++));
- mobTable->bBattleType = battleTypeValue;
- mobTable->bLevel = atoi(csvTable.AsStringByIndex(col++));
- //8. SIZE
- int sizeValue = get_Mob_Size_Value(csvTable.AsStringByIndex(col++));
- mobTable->bSize = sizeValue;
- //9. AI_FLAG
- int aiFlagValue = get_Mob_AIFlag_Value(csvTable.AsStringByIndex(col++));
- mobTable->dwAIFlag = aiFlagValue;
- mobTable->bMountCapacity = atoi(csvTable.AsStringByIndex(col++));
- //10. RACE_FLAG
- int raceFlagValue = get_Mob_RaceFlag_Value(csvTable.AsStringByIndex(col++));
- mobTable->dwRaceFlag = raceFlagValue;
- //11. IMMUNE_FLAG
- int immuneFlagValue = get_Mob_ImmuneFlag_Value(csvTable.AsStringByIndex(col++));
- mobTable->dwImmuneFlag = immuneFlagValue;
- mobTable->bEmpire = atoi(csvTable.AsStringByIndex(col++));
- //folder
- strncpy(mobTable->szFolder, csvTable.AsStringByIndex(col++), sizeof(mobTable->szFolder));
- mobTable->bOnClickType = atoi(csvTable.AsStringByIndex(col++));
- mobTable->bStr = atoi(csvTable.AsStringByIndex(col++));
- mobTable->bDex = atoi(csvTable.AsStringByIndex(col++));
- mobTable->bCon = atoi(csvTable.AsStringByIndex(col++));
- mobTable->bInt = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwDamageRange[0] = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwDamageRange[1] = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwMaxHP = atoi(csvTable.AsStringByIndex(col++));
- mobTable->bRegenCycle = atoi(csvTable.AsStringByIndex(col++));
- mobTable->bRegenPercent = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwGoldMin = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwGoldMax = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwExp = atoi(csvTable.AsStringByIndex(col++));
- mobTable->wDef = atoi(csvTable.AsStringByIndex(col++));
- mobTable->sAttackSpeed = atoi(csvTable.AsStringByIndex(col++));
- mobTable->sMovingSpeed = atoi(csvTable.AsStringByIndex(col++));
- mobTable->bAggresiveHPPct = atoi(csvTable.AsStringByIndex(col++));
- mobTable->wAggressiveSight = atoi(csvTable.AsStringByIndex(col++));
- mobTable->wAttackRange = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwDropItemVnum = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwResurrectionVnum = atoi(csvTable.AsStringByIndex(col++));
- for (int i = 0; i < CPythonNonPlayer::MOB_ENCHANTS_MAX_NUM; ++i)
- mobTable->cEnchants[i] = atoi(csvTable.AsStringByIndex(col++));
- for (int i = 0; i < CPythonNonPlayer::MOB_RESISTS_MAX_NUM; ++i)
- mobTable->cResists[i] = atoi(csvTable.AsStringByIndex(col++));
- mobTable->fDamMultiply = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwSummonVnum = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwDrainSP = atoi(csvTable.AsStringByIndex(col++));
- mobTable->dwMonsterColor = atoi(csvTable.AsStringByIndex(col++));
- return true;
- }
- bool BuildMobTable()
- {
- //%%% <ÇÔ¼ö ¼³¸í> %%%//
- //1. ¿ä¾à : 'mob_proto.txt', 'mob_proto_test.txt', 'mob_names.txt' ÆÄÀÏÀ» Àаí,
- // m_pMobTable ¸¦ ±¸¼ºÇÑ´Ù.
- //2. ¼ø¼
- // 1)'mob_names.txt' ÆÄÀÏÀ» ÀÐ¾î¼ vnum:name ¸ÊÀ» ¸¸µç´Ù.
- // 2)'mob_proto_test.txt' ÆÄÀÏÀ» Àоî¼,
- // test_mob_table ¸¦ ¸¸µé°í,
- // vnum:TMobTable ¸ÊÀ» ¸¸µç´Ù.
- // 3)'mob_proto.txt' ÆÄÀÏÀ» Àаí, m_pMobTable¸¦ ±¸¼ºÇÑ´Ù.
- // test_mob_table¿¡ ÀÖ´Â vnumÀº Å×½ºÆ® µ¥ÀÌÅ͸¦ ³Ö´Â´Ù.
- // 4)test_mob_table µ¥ÀÌÅÍÁß¿¡, m_pMobTable ¿¡ ¾ø´Â µ¥ÀÌÅ͸¦ Ãß°¡ÇÑ´Ù.
- //3. Å×½ºÆ®
- // 1)'mob_proto.txt' Á¤º¸°¡ m_pMobTable¿¡ Àß µé¾î°¬´ÂÁö. -> ¿Ï·á
- // 2)'mob_names.txt' Á¤º¸°¡ m_pMobTable¿¡ Àß µé¾î°¬´ÂÁö. -> ¿Ï·á
- // 3)'mob_proto_test.txt' ¿¡¼ [°ãÄ¡´Â] Á¤º¸°¡ m_pMobTable ¿¡ Àß µé¾î°¬´ÂÁö. -> ¿Ï·á
- // 4)'mob_proto_test.txt' ¿¡¼ [»õ·Î¿î] Á¤º¸°¡ m_pMobTable ¿¡ Àß µé¾î°¬´ÂÁö. -> ¿Ï·á
- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
- fprintf(stderr, "sizeof(TMobTable): %u\n", sizeof(CPythonNonPlayer::TMobTable));
- //==============================================================//
- //======localº° ¸ó½ºÅÍ À̸§À» ÀúÀåÇÏ°í ÀÖ´Â [¸Ê] vnum:name======//
- //==============================================================//
- bool isNameFile = true;
- std::map<int,const char*> localMap;
- cCsvTable nameData;
- if(!nameData.Load("mob_names.txt",'\t'))
- {
- fprintf(stderr, "mob_names.txt Unable to read file\n");
- isNameFile = false;
- } else {
- nameData.Next();
- while(nameData.Next()) {
- localMap[atoi(nameData.AsStringByIndex(0))] = nameData.AsStringByIndex(1);
- }
- }
- //______________________________________________________________//
- //=========================================//
- //======¸ó½ºÅ͵éÀÇ vnumÀ» ÀúÀåÇÒ [¼Â]======//
- // *Å×½ºÆ®¿ë ÆÄÀÏÀ» »õ·Î Àоî¿Ã¶§, //
- // 1. ±âÁ¸¿¡ ÀÖ´ø µ¥ÀÌÅÍÀÎÁö È®ÀÏÇÒ¶§ »ç¿ë//
- //=========================================//
- std::set<int> vnumSet;
- //_________________________________________//
- //==================================================//
- // 2)'mob_proto_test.txt' ÆÄÀÏÀ» Àоî¼,
- // test_mob_table ¸¦ ¸¸µé°í,
- // vnum:TMobTable ¸ÊÀ» ¸¸µç´Ù.
- //==================================================//
- std::map<DWORD, CPythonNonPlayer::TMobTable *> test_map_mobTableByVnum;
- //ÆÄÀÏ Àоî¿À±â.
- cCsvTable data;
- if(!data.Load("mob_proto.txt",'\t'))
- {
- fprintf(stderr, "mob_proto.txt Unable to read file\n");
- return false;
- }
- data.Next(); //¸Ç ÀÁÙ Á¦¿Ü (¾ÆÀÌÅÛ Ä®·³À» ¼³¸íÇÏ´Â ºÎºÐ)
- //===== ¸÷ Å×ÀÌºí »ý¼º=====//
- if (m_pMobTable)
- {
- delete m_pMobTable;
- m_pMobTable = NULL;
- }
- //»õ·Î Ãß°¡µÇ´Â °¹¼ö¸¦ ÆľÇÇÑ´Ù.
- int addNumber = 0;
- while(data.Next()) {
- int vnum = atoi(data.AsStringByIndex(0));
- std::map<DWORD, CPythonNonPlayer::TMobTable *>::iterator it_map_mobTable;
- it_map_mobTable = test_map_mobTableByVnum.find(vnum);
- if(it_map_mobTable != test_map_mobTableByVnum.end()) {
- addNumber++;
- }
- }
- m_iMobTableSize = data.m_File.GetRowCount()-1 + addNumber;
- m_pMobTable = new CPythonNonPlayer::TMobTable[m_iMobTableSize];
- memset(m_pMobTable, 0, sizeof(CPythonNonPlayer::TMobTable) * m_iMobTableSize);
- CPythonNonPlayer::TMobTable * mob_table = m_pMobTable;
- //data¸¦ ´Ù½Ã ùÁÙ·Î ¿Å±ä´Ù.(´Ù½Ã Àоî¿Â´Ù;;)
- data.Destroy();
- if(!data.Load("mob_proto.txt",'\t'))
- {
- fprintf(stderr, "mob_proto.txt Unable to read file\n");
- return false;
- }
- data.Next(); //¸Ç ÀÁÙ Á¦¿Ü (¾ÆÀÌÅÛ Ä®·³À» ¼³¸íÇÏ´Â ºÎºÐ)
- while (data.Next())
- {
- int col = 0;
- //Å×½ºÆ® ÆÄÀÏ¿¡ °°Àº vnumÀÌ ÀÖ´ÂÁö Á¶»ç.
- std::map<DWORD, CPythonNonPlayer::TMobTable *>::iterator it_map_mobTable;
- it_map_mobTable = test_map_mobTableByVnum.find(atoi(data.AsStringByIndex(col)));
- if(it_map_mobTable == test_map_mobTableByVnum.end()) {
- if (!Set_Proto_Mob_Table(mob_table, data, localMap))
- {
- fprintf(stderr, "Mob prototype table setting failed.\n");
- }
- } else { //$$$$$$$$$$$$$$$$$$$$$$$ Å×½ºÆ® ¸ó½ºÅÍ Á¤º¸°¡ ÀÖ´Ù!
- CPythonNonPlayer::TMobTable *tempTable = it_map_mobTable->second;
- mob_table->dwVnum = tempTable->dwVnum;
- strncpy(mob_table->szName, tempTable->szName, CHARACTER_NAME_MAX_LEN);
- strncpy(mob_table->szLocaleName, tempTable->szLocaleName, CHARACTER_NAME_MAX_LEN);
- mob_table->bRank = tempTable->bRank;
- mob_table->bType = tempTable->bType;
- mob_table->bBattleType = tempTable->bBattleType;
- mob_table->bLevel = tempTable->bLevel;
- mob_table->bSize = tempTable->bSize;
- mob_table->dwAIFlag = tempTable->dwAIFlag;
- mob_table->dwRaceFlag = tempTable->dwRaceFlag;
- mob_table->dwImmuneFlag = tempTable->dwImmuneFlag;
- mob_table->bEmpire = tempTable->bEmpire;
- strncpy(mob_table->szFolder, tempTable->szFolder, CHARACTER_NAME_MAX_LEN);
- mob_table->bOnClickType = tempTable->bOnClickType;
- mob_table->bStr = tempTable->bStr;
- mob_table->bDex = tempTable->bDex;
- mob_table->bCon = tempTable->bCon;
- mob_table->bInt = tempTable->bInt;
- mob_table->dwDamageRange[0] = tempTable->dwDamageRange[0];
- mob_table->dwDamageRange[1] = tempTable->dwDamageRange[1];
- mob_table->dwMaxHP = tempTable->dwMaxHP;
- mob_table->bRegenCycle = tempTable->bRegenCycle;
- mob_table->bRegenPercent = tempTable->bRegenPercent;
- mob_table->dwExp = tempTable->dwExp;
- mob_table->wDef = tempTable->wDef;
- mob_table->sAttackSpeed = tempTable->sAttackSpeed;
- mob_table->sMovingSpeed = tempTable->sMovingSpeed;
- mob_table->bAggresiveHPPct = tempTable->bAggresiveHPPct;
- mob_table->wAggressiveSight = tempTable->wAggressiveSight;
- mob_table->wAttackRange = tempTable->wAttackRange;
- mob_table->dwDropItemVnum = tempTable->dwDropItemVnum;
- for (int i = 0; i < CPythonNonPlayer::MOB_ENCHANTS_MAX_NUM; ++i)
- mob_table->cEnchants[i] = tempTable->cEnchants[i];
- for (int i = 0; i < CPythonNonPlayer::MOB_RESISTS_MAX_NUM; ++i)
- mob_table->cResists[i] = tempTable->cResists[i];
- mob_table->fDamMultiply = tempTable->fDamMultiply;
- mob_table->dwSummonVnum = tempTable->dwSummonVnum;
- mob_table->dwDrainSP = tempTable->dwDrainSP;
- mob_table->dwMonsterColor = tempTable->dwMonsterColor;
- }
- fprintf(stdout, "MOB #%-5d %-16s %-16s sight: %u color %u[%s]\n", mob_table->dwVnum, mob_table->szName, mob_table->szLocaleName, mob_table->wAggressiveSight, mob_table->dwMonsterColor, 0);
- //¼Â¿¡ vnum Ãß°¡
- vnumSet.insert(mob_table->dwVnum);
- ++mob_table;
- }
- return true;
- }
- DWORD g_adwMobProtoKey[4] =
- {
- 4813894,
- 18955,
- 552631,
- 6822045
- };
- void SaveMobProto()
- {
- FILE * fp;
- fopen_s(&fp, "mob_proto", "wb");
- if (!fp)
- {
- printf("cannot open %s for writing\n", "mob_proto");
- return;
- }
- DWORD fourcc = MAKEFOURCC('M', 'M', 'P', 'T');
- fwrite(&fourcc, sizeof(DWORD), 1, fp);
- DWORD dwElements = m_iMobTableSize;
- fwrite(&dwElements, sizeof(DWORD), 1, fp);
- CLZObject zObj;
- printf("sizeof(TMobTable) %d\n", sizeof(CPythonNonPlayer::TMobTable));
- if (!CLZO::instance().CompressEncryptedMemory(zObj, m_pMobTable, sizeof(CPythonNonPlayer::TMobTable) * m_iMobTableSize, g_adwMobProtoKey))
- {
- printf("cannot compress\n");
- fclose(fp);
- return;
- }
- const CLZObject::THeader & r = zObj.GetHeader();
- printf("MobProto count %u\n%u --Compress--> %u --Encrypt--> %u, GetSize %u\n",
- m_iMobTableSize, r.dwRealSize, r.dwCompressedSize, r.dwEncryptSize, zObj.GetSize());
- DWORD dwDataSize = zObj.GetSize();
- fwrite(&dwDataSize, sizeof(DWORD), 1, fp);
- fwrite(zObj.GetBuffer(), dwDataSize, 1, fp);
- fclose(fp);
- }
- // YMIR WON'T SAVE THE FOLLOWING FIELDS, SO YOU WILL GET 0 FROM THEM WHEN YOU UNPACK THE MOB_PROTO:
- // gold min, gold max, polymorph item, mount capacity
- // skill_*
- // sp_*
- // NB: damage multiply is truncated, so you will get 1 instead of 1.4 and so on
- // NB2: due to a bug, all the mob_protos packed with an unfixed/default dump_proto tool will get the race flag set to 0 if it contains more than 1 value (the bug is about the splitting feature)
- void LoadMobProto()
- {
- FILE * fp;
- DWORD fourcc, tableSize, dataSize;
- fopen_s(&fp, "mob_proto", "rb");
- if (fp==NULL)
- {
- printf("mob_proto not found\n");
- return;
- }
- fread(&fourcc, sizeof(DWORD), 1, fp);
- fread(&tableSize, sizeof(DWORD), 1, fp);
- fread(&dataSize, sizeof(DWORD), 1, fp);
- BYTE * data = (BYTE *) malloc(dataSize);
- printf("fourcc %u\n", fourcc);
- printf("tableSize %u\n", tableSize);
- printf("dataSize %u\n", dataSize);
- if (data)
- {
- fread(data, dataSize, 1, fp);
- CLZObject zObj;
- if (CLZO::instance().Decompress(zObj, data, g_adwMobProtoKey))
- {
- printf("real_size %u\n", zObj.GetSize());
- DWORD structSize = zObj.GetSize() / tableSize;
- DWORD structDiff = zObj.GetSize() % tableSize;
- printf("struct_size %u\n", structSize);
- printf("struct_diff %u\n", structDiff);
- #ifdef ENABLE_PROTOSTRUCT_AUTODETECT
- if (structDiff!=0 && !CPythonNonPlayer::TMobTableAll::IsValidStruct(structSize))
- #else
- if ((zObj.GetSize() % sizeof(TMobTable)) != 0)
- #endif
- {
- printf("LoadMobProto: invalid size %u check data format. structSize %u, structDiff %u\n", zObj.GetSize(), structSize, structDiff);
- return;
- }
- if (LoadNPrint)
- {
- for (DWORD i = 0; i < tableSize; ++i)
- {
- #ifdef ENABLE_PROTOSTRUCT_AUTODETECT
- CPythonNonPlayer::TMobTable rTable = {0};
- CPythonNonPlayer::TMobTableAll::Process(zObj.GetBuffer(), structSize, i, rTable);
- #else
- CPythonNonPlayer::TMobTable & rTable = *((CItemData::TItemTable *) zObj.GetBuffer() + i);
- #endif
- printf("%u %s\n", rTable.dwVnum, rTable.szLocaleName);
- }
- }
- else
- {
- FILE * mf1; fopen_s(&mf1, "mob_names.txt", "w");
- FILE * mf2; fopen_s(&mf2, "mob_proto.txt", "w");
- if (mf1==NULL)
- {
- printf("mob_names.txt not writable");
- return;
- }
- if (mf2==NULL)
- {
- printf("mob_proto.txt not writable");
- return;
- }
- fprintf(mf1, "VNUM\tLOCALE_NAME\n");
- fprintf(mf2, "VNUM\tNAME\tRANK\tTYPE\tBATTLE_TYPE\tLEVEL\tSIZE\tAI_FLAG\tMOUNT_CAPACITY\tRACE_FLAG\tIMMUNE_FLAG\tEMPIRE\tFOLDER\tON_CLICK\tST\tDX\tHT\tIQ\tDAMAGE_MIN\tDAMAGE_MAX\tMAX_HP\tREGEN_CYCLE\tREGEN_PERCENT\tGOLD_MIN\tGOLD_MAX\tEXP\tDEF\tATTACK_SPEED\tMOVE_SPEED\tAGGRESSIVE_HP_PCT\tAGGRESSIVE_SIGHT\tATTACK_RANGE\tDROP_ITEM\tRESURRECTION_VNUM\tENCHANT_CURSE\tENCHANT_SLOW\tENCHANT_POISON\tENCHANT_STUN\tENCHANT_CRITICAL\tENCHANT_PENETRATE\tRESIST_SWORD\tRESIST_TWOHAND\tRESIST_DAGGER\tRESIST_BELL\tRESIST_FAN\tRESIST_BOW\tRESIST_FIRE\tRESIST_ELECT\tRESIST_MAGIC\tRESIST_WIND\tRESIST_POISON\tDAM_MULTIPLY\tSUMMON\tDRAIN_SP\tMOB_COLOR\tPOLYMORPH_ITEM\tSKILL_LEVEL0\tSKILL_VNUM0\tSKILL_LEVEL1\tSKILL_VNUM1\tSKILL_LEVEL2\tSKILL_VNUM2\tSKILL_LEVEL3\tSKILL_VNUM3\tSKILL_LEVEL4\tSKILL_VNUM4\tSP_BERSERK\tSP_STONESKIN\tSP_GODSPEED\tSP_DEATHBLOW\tSP_REVIVE\n");
- for (DWORD i = 0; i < tableSize; ++i)
- {
- #ifdef ENABLE_PROTOSTRUCT_AUTODETECT
- CPythonNonPlayer::TMobTable rTable = {0};
- CPythonNonPlayer::TMobTableAll::Process(zObj.GetBuffer(), structSize, i, rTable);
- #else
- CPythonNonPlayer::TMobTable & rTable = *((CItemData::TItemTable *) zObj.GetBuffer() + i);
- #endif
- fprintf(mf1, "%u %s\n", rTable.dwVnum, rTable.szLocaleName);
- fprintf(mf2,
- "%u %s"
- " %s %s %s %u"
- " %s %s %u %s"
- " %s %u %s %u %u %u %u %u"
- " %u %u %u %u %u %u %u %u %u"
- " %d %d %u %u %u %u %u"
- " %d %d %d"
- " %d %d %d"
- " %d %d %d %d"
- " %d %d"
- " %d %d"
- " %d %d %d"
- " %.1f %u %u %u %u"
- " %u %u %u %u %u %u"
- " %u %u %u %u"
- " %u %u %u %u %u"
- "\n",
- rTable.dwVnum, rTable.szName,
- set_Mob_Rank_Value(rTable.bRank).c_str(), set_Mob_Type_Value(rTable.bType).c_str(), set_Mob_BattleType_Value(rTable.bBattleType).c_str(), rTable.bLevel,
- set_Mob_Size_Value(rTable.bSize).c_str(), set_Mob_AIFlag_Value(rTable.dwAIFlag).c_str(), rTable.bMountCapacity, set_Mob_RaceFlag_Value(rTable.dwRaceFlag).c_str(),
- set_Mob_ImmuneFlag_Value(rTable.dwImmuneFlag).c_str(), rTable.bEmpire, rTable.szFolder, rTable.bOnClickType, rTable.bStr, rTable.bDex, rTable.bCon, rTable.bInt,
- rTable.dwDamageRange[0], rTable.dwDamageRange[1], rTable.dwMaxHP, rTable.bRegenCycle, rTable.bRegenPercent, rTable.dwGoldMin, rTable.dwGoldMax, rTable.dwExp, rTable.wDef,
- rTable.sAttackSpeed, rTable.sMovingSpeed, rTable.bAggresiveHPPct, rTable.wAggressiveSight, rTable.wAttackRange, rTable.dwDropItemVnum, rTable.dwResurrectionVnum,
- rTable.cEnchants[CPythonNonPlayer::MOB_ENCHANT_CURSE], rTable.cEnchants[CPythonNonPlayer::MOB_ENCHANT_SLOW], rTable.cEnchants[CPythonNonPlayer::MOB_ENCHANT_POISON],
- rTable.cEnchants[CPythonNonPlayer::MOB_ENCHANT_STUN], rTable.cEnchants[CPythonNonPlayer::MOB_ENCHANT_CRITICAL], rTable.cEnchants[CPythonNonPlayer::MOB_ENCHANT_PENETRATE],
- rTable.cResists[CPythonNonPlayer::MOB_RESIST_SWORD], rTable.cResists[CPythonNonPlayer::MOB_RESIST_TWOHAND], rTable.cResists[CPythonNonPlayer::MOB_RESIST_DAGGER], rTable.cResists[CPythonNonPlayer::MOB_RESIST_BELL],
- rTable.cResists[CPythonNonPlayer::MOB_RESIST_FAN], rTable.cResists[CPythonNonPlayer::MOB_RESIST_BOW],
- rTable.cResists[CPythonNonPlayer::MOB_RESIST_FIRE], rTable.cResists[CPythonNonPlayer::MOB_RESIST_ELECT],
- rTable.cResists[CPythonNonPlayer::MOB_RESIST_MAGIC], rTable.cResists[CPythonNonPlayer::MOB_RESIST_WIND], rTable.cResists[CPythonNonPlayer::MOB_RESIST_POISON],
- rTable.fDamMultiply, rTable.dwSummonVnum, rTable.dwDrainSP, rTable.dwMonsterColor, rTable.dwPolymorphItemVnum,
- rTable.Skills[0].bLevel, rTable.Skills[0].dwVnum, rTable.Skills[1].bLevel, rTable.Skills[1].dwVnum, rTable.Skills[2].bLevel, rTable.Skills[2].dwVnum,
- rTable.Skills[3].bLevel, rTable.Skills[3].dwVnum, rTable.Skills[4].bLevel, rTable.Skills[4].dwVnum,
- rTable.bBerserkPoint, rTable.bStoneSkinPoint, rTable.bGodSpeedPoint, rTable.bDeathBlowPoint, rTable.bRevivePoint
- );
- }
- ;
- }
- }
- free(data);
- }
- fclose(fp);
- }
- //== ==//
- //== ==//
- //== ==//
- //===== ¿©±â¿¡¼ºÎÅÍ ¾ÆÀÌÅÛ =====//
- //== ==//
- //== ==//
- //== ==//
- string retrieveVnumRange(DWORD dwVnum, DWORD dwVnumRange)
- {
- static char buf[10*2+1];
- if (dwVnumRange>0)
- snprintf(buf, sizeof(buf), "%u~%u", dwVnum, dwVnum+dwVnumRange);
- else
- snprintf(buf, sizeof(buf), "%u", dwVnum);
- return buf;
- }
- int retrieveAddonType(DWORD dwVnum)
- {
- int addon_type = 0;
- #ifdef ENABLE_ADDONTYPE_AUTODETECT
- static DWORD vnumlist[] = {180, 190, 290, 1130, 1170, 2150, 2170, 3160, 3210, 5110, 5120, 7160, 6010, 6060, 6070};
- for (DWORD i = 0; i < (sizeof(vnumlist)/sizeof(DWORD)); i++)
- {
- if ((dwVnum >= vnumlist[i]) && (dwVnum <= vnumlist[i]+9))
- {
- addon_type = -1;
- }
- }
- #endif
- return addon_type;
- }
- bool Set_Proto_Item_Table(CItemData::TItemTable *itemTable, cCsvTable &csvTable, std::map<int,const char*> &nameMap)
- {
- // vnum ¹× vnum range Àбâ.
- {
- std::string s(csvTable.AsStringByIndex(0));
- int pos = s.find("~");
- // vnum Çʵ忡 '~'°¡ ¾ø´Ù¸é Æнº
- if (std::string::npos == pos)
- {
- itemTable->dwVnum = atoi(s.c_str());
- if (0 == itemTable->dwVnum)
- {
- printf ("INVALID VNUM %s\n", s.c_str());
- return false;
- }
- itemTable->dwVnumRange = 0;
- }
- else
- {
- std::string s_start_vnum (s.substr(0, pos));
- std::string s_end_vnum (s.substr(pos +1 ));
- int start_vnum = atoi(s_start_vnum.c_str());
- int end_vnum = atoi(s_end_vnum.c_str());
- if (0 == start_vnum || (0 != end_vnum && end_vnum < start_vnum))
- {
- printf ("INVALID VNUM RANGE%s\n", s.c_str());
- return false;
- }
- itemTable->dwVnum = start_vnum;
- itemTable->dwVnumRange = end_vnum - start_vnum;
- }
- }
- int col = 1;
- strncpy(itemTable->szName, csvTable.AsStringByIndex(col++), CItemData::ITEM_NAME_MAX_LEN);
- std::map<int,const char*>::iterator it;
- it = nameMap.find(itemTable->dwVnum);
- if (it != nameMap.end()) {
- const char * localeName = it->second;
- strncpy(itemTable->szLocaleName, localeName, sizeof(itemTable->szLocaleName));
- } else { //³×ÀÓ ÆÄÀÏÀÌ Á¸ÀçÇÏÁö ¾ÊÀ¸¸é Çѱ۷Î..
- strncpy(itemTable->szLocaleName, itemTable->szName, sizeof(itemTable->szLocaleName));
- }
- itemTable->bType = get_Item_Type_Value(csvTable.AsStringByIndex(col++));
- itemTable->bSubType = get_Item_SubType_Value(itemTable->bType, csvTable.AsStringByIndex(col++));
- itemTable->bSize = atoi(csvTable.AsStringByIndex(col++));
- itemTable->dwAntiFlags = get_Item_AntiFlag_Value(csvTable.AsStringByIndex(col++));
- itemTable->dwFlags = get_Item_Flag_Value(csvTable.AsStringByIndex(col++));
- itemTable->dwWearFlags = get_Item_WearFlag_Value(csvTable.AsStringByIndex(col++));
- itemTable->dwImmuneFlag = get_Item_Immune_Value(csvTable.AsStringByIndex(col++));
- itemTable->dwIBuyItemPrice = atoi(csvTable.AsStringByIndex(col++));
- itemTable->dwISellItemPrice = atoi(csvTable.AsStringByIndex(col++));
- itemTable->dwRefinedVnum = atoi(csvTable.AsStringByIndex(col++));
- itemTable->wRefineSet = atoi(csvTable.AsStringByIndex(col++));
- itemTable->bAlterToMagicItemPct = atoi(csvTable.AsStringByIndex(col++));
- int i;
- for (i = 0; i < CItemData::ITEM_LIMIT_MAX_NUM; ++i)
- {
- itemTable->aLimits[i].bType = get_Item_LimitType_Value(csvTable.AsStringByIndex(col++));
- itemTable->aLimits[i].lValue = atoi(csvTable.AsStringByIndex(col++));
- }
- for (i = 0; i < CItemData::ITEM_APPLY_MAX_NUM; ++i)
- {
- itemTable->aApplies[i].bType = get_Item_ApplyType_Value(csvTable.AsStringByIndex(col++));
- itemTable->aApplies[i].lValue = atoi(csvTable.AsStringByIndex(col++));
- }
- for (i = 0; i < CItemData::ITEM_VALUES_MAX_NUM; ++i)
- itemTable->alValues[i] = atoi(csvTable.AsStringByIndex(col++));
- itemTable->bSpecular = atoi(csvTable.AsStringByIndex(col++));
- itemTable->bGainSocketPct = atoi(csvTable.AsStringByIndex(col++));
- col++; //AddonType
- itemTable->bWeight = 0;
- return true;
- }
- bool BuildItemTable()
- {
- //%%% <ÇÔ¼ö ¼³¸í> %%%//
- //1. ¿ä¾à : 'item_proto.txt', 'item_proto_test.txt', 'item_names.txt' ÆÄÀÏÀ» Àаí,
- // m_pItemTable ¸¦ ±¸¼ºÇÑ´Ù.
- //2. ¼ø¼
- // 1)'item_names.txt' ÆÄÀÏÀ» ÀÐ¾î¼ vnum:name ¸ÊÀ» ¸¸µç´Ù.
- // 2)'item_proto_test.txt' ÆÄÀÏÀ» Àоî¼,
- // test_item_table ¸¦ ¸¸µé°í,
- // vnum:TClientItemTable ¸ÊÀ» ¸¸µç´Ù.
- // 3)'item_proto.txt' ÆÄÀÏÀ» Àаí, m_pItemTable¸¦ ±¸¼ºÇÑ´Ù.
- // test_item_table¿¡ ÀÖ´Â vnumÀº Å×½ºÆ® µ¥ÀÌÅ͸¦ ³Ö´Â´Ù.
- // 4)test_item_table µ¥ÀÌÅÍÁß¿¡, m_pItemTable ¿¡ ¾ø´Â µ¥ÀÌÅ͸¦ Ãß°¡ÇÑ´Ù.
- //3. Å×½ºÆ®
- // 1)'item_proto.txt' Á¤º¸°¡ m_pItemTable¿¡ Àß µé¾î°¬´ÂÁö.
- // 2)'item_names.txt' Á¤º¸°¡ m_pItemTable¿¡ Àß µé¾î°¬´ÂÁö.
- // 3)'item_proto_test.txt' ¿¡¼ [°ãÄ¡´Â] Á¤º¸°¡ m_pItemTable ¿¡ Àß µé¾î°¬´ÂÁö.
- // 4)'item_proto_test.txt' ¿¡¼ [»õ·Î¿î] Á¤º¸°¡ m_pItemTable ¿¡ Àß µé¾î°¬´ÂÁö.
- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
- fprintf(stderr, "sizeof(TClientItemTable): %u\n", sizeof(CItemData::TItemTable));
- //=================================================================//
- // 1)'item_names.txt' ÆÄÀÏÀ» ÀÐ¾î¼ vnum:name ¸ÊÀ» ¸¸µç´Ù.
- //=================================================================//
- bool isNameFile = true;
- std::map<int,const char*> localMap;
- cCsvTable nameData;
- if(!nameData.Load("item_names.txt",'\t'))
- {
- fprintf(stderr, "item_names.txt Unable to read file\n");
- isNameFile = false;
- } else {
- nameData.Next();
- while(nameData.Next()) {
- localMap[atoi(nameData.AsStringByIndex(0))] = nameData.AsStringByIndex(1);
- }
- }
- //_________________________________________________________________//
- //===================== =======================//
- // 2)'item_proto_test.txt' ÆÄÀÏÀ» Àоî¼,
- // test_item_table ¸¦ ¸¸µé°í,
- // vnum:TClientItemTable ¸ÊÀ» ¸¸µç´Ù.
- //=============================================//
- std::map<DWORD, CItemData::TItemTable *> test_map_itemTableByVnum;
- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
- //================================================================//
- // 3)'item_proto.txt' ÆÄÀÏÀ» Àаí, m_pItemTable¸¦ ±¸¼ºÇÑ´Ù.
- // test_item_table¿¡ ÀÖ´Â vnumÀº Å×½ºÆ® µ¥ÀÌÅ͸¦ ³Ö´Â´Ù.
- //================================================================//
- std::set<int> vnumSet;
- //ÆÄÀÏ Àоî¿À±â.
- cCsvTable data;
- if(!data.Load("item_proto.txt",'\t'))
- {
- fprintf(stderr, "item_proto.txt Unable to read file\n");
- return false;
- }
- data.Next(); //¸Ç ÀÁÙ Á¦¿Ü (¾ÆÀÌÅÛ Ä®·³À» ¼³¸íÇÏ´Â ºÎºÐ)
- if (m_pItemTable)
- {
- free(m_pItemTable);
- m_pItemTable = NULL;
- }
- //===== ¾ÆÀÌÅÛ Å×ÀÌºí »ý¼º =====//
- //»õ·Î Ãß°¡µÇ´Â °¹¼ö¸¦ ÆľÇÇÑ´Ù.
- int addNumber = 0;
- while(data.Next()) {
- int vnum = atoi(data.AsStringByIndex(0));
- std::map<DWORD, CItemData::TItemTable *>::iterator it_map_itemTable;
- it_map_itemTable = test_map_itemTableByVnum.find(vnum);
- if(it_map_itemTable != test_map_itemTableByVnum.end()) {
- addNumber++;
- }
- }
- //data¸¦ ´Ù½Ã ùÁÙ·Î ¿Å±ä´Ù.(´Ù½Ã Àоî¿Â´Ù;;)
- data.Destroy();
- if(!data.Load("item_proto.txt",'\t'))
- {
- fprintf(stderr, "item_proto.txt Unable to read file\n");
- return false;
- }
- data.Next(); //¸Ç ÀÁÙ Á¦¿Ü (¾ÆÀÌÅÛ Ä®·³À» ¼³¸íÇÏ´Â ºÎºÐ)
- m_iItemTableSize = data.m_File.GetRowCount()-1+addNumber;
- m_pItemTable = new CItemData::TItemTable[m_iItemTableSize];
- memset(m_pItemTable, 0, sizeof(CItemData::TItemTable) * m_iItemTableSize);
- CItemData::TItemTable * item_table = m_pItemTable;
- while (data.Next())
- {
- int col = 0;
- //Å×½ºÆ® ÆÄÀÏ¿¡ °°Àº vnumÀÌ ÀÖ´ÂÁö Á¶»ç.
- std::map<DWORD, CItemData::TItemTable *>::iterator it_map_itemTable;
- it_map_itemTable = test_map_itemTableByVnum.find(atoi(data.AsStringByIndex(col)));
- if(it_map_itemTable == test_map_itemTableByVnum.end()) {
- if (!Set_Proto_Item_Table(item_table, data, localMap))
- {
- fprintf(stderr, "Mob prototype table setting failed.\n");
- }
- } else { //$$$$$$$$$$$$$$$$$$$$$$$ Å×½ºÆ® ¾ÆÀÌÅÛ Á¤º¸°¡ ÀÖ´Ù!
- CItemData::TItemTable *tempTable = it_map_itemTable->second;
- item_table->dwVnum = tempTable->dwVnum;
- strncpy(item_table->szName, tempTable->szName, CItemData::ITEM_NAME_MAX_LEN);
- strncpy(item_table->szLocaleName, tempTable->szLocaleName, CItemData::ITEM_NAME_MAX_LEN);
- item_table->bType = tempTable->bType;
- item_table->bSubType = tempTable->bSubType;
- item_table->bSize = tempTable->bSize;
- item_table->dwAntiFlags = tempTable->dwAntiFlags;
- item_table->dwFlags = tempTable->dwFlags;
- item_table->dwWearFlags = tempTable->dwWearFlags;
- item_table->dwImmuneFlag = tempTable->dwImmuneFlag;
- item_table->dwIBuyItemPrice = tempTable->dwIBuyItemPrice;
- item_table->dwISellItemPrice = tempTable->dwISellItemPrice;
- item_table->dwRefinedVnum = tempTable->dwRefinedVnum;
- item_table->wRefineSet = tempTable->wRefineSet;
- item_table->bAlterToMagicItemPct = tempTable->bAlterToMagicItemPct;
- int i;
- for (i = 0; i < CItemData::ITEM_LIMIT_MAX_NUM; ++i)
- {
- item_table->aLimits[i].bType = tempTable->aLimits[i].bType;
- item_table->aLimits[i].lValue = tempTable->aLimits[i].lValue;
- }
- for (i = 0; i < CItemData::ITEM_APPLY_MAX_NUM; ++i)
- {
- item_table->aApplies[i].bType = tempTable->aApplies[i].bType;
- item_table->aApplies[i].lValue = tempTable->aApplies[i].lValue;
- }
- for (i = 0; i < CItemData::ITEM_VALUES_MAX_NUM; ++i)
- item_table->alValues[i] = tempTable->alValues[i];
- item_table->bSpecular = tempTable->bSpecular;
- item_table->bGainSocketPct = tempTable->bGainSocketPct;
- item_table->bWeight = tempTable->bWeight;
- }
- fprintf(stdout, "ITEM #%-5u %-24s %-24s VAL: %ld %ld %ld %ld %ld %ld WEAR %u ANTI %u IMMUNE %u REFINE %u\n",
- item_table->dwVnum,
- item_table->szName,
- item_table->szLocaleName,
- item_table->alValues[0],
- item_table->alValues[1],
- item_table->alValues[2],
- item_table->alValues[3],
- item_table->alValues[4],
- item_table->alValues[5],
- item_table->dwWearFlags,
- item_table->dwAntiFlags,
- item_table->dwImmuneFlag,
- item_table->dwRefinedVnum);
- //vnum ÀúÀå.
- vnumSet.insert(item_table->dwVnum);
- ++item_table;
- }
- return true;
- }
- DWORD g_adwItemProtoKey[4] =
- {
- 173217,
- 72619434,
- 408587239,
- 27973291
- };
- // YMIR WON'T SAVE THE FOLLOWING FIELDS, SO YOU WILL GET 0 FROM THEM WHEN YOU UNPACK THE ITEM_PROTO:
- // addon_type
- void LoadItemProto()
- {
- FILE * fp;
- DWORD fourcc, tableSize, dataSize, protoVersion, structSize;
- fopen_s(&fp, "item_proto", "rb");
- if (fp==NULL)
- {
- printf("item_proto not found\n");
- return;
- }
- fread(&fourcc, sizeof(DWORD), 1, fp);
- fread(&protoVersion, sizeof(DWORD), 1, fp);
- fread(&structSize, sizeof(DWORD), 1, fp);
- fread(&tableSize, sizeof(DWORD), 1, fp);
- fread(&dataSize, sizeof(DWORD), 1, fp);
- BYTE * data = (BYTE *) malloc(dataSize);
- printf("fourcc %u\n", fourcc);
- printf("protoVersion %u\n", protoVersion);
- printf("struct_size %u\n", structSize);
- printf("tableSize %u\n", tableSize);
- printf("dataSize %u\n", dataSize);
- #ifdef ENABLE_PROTOSTRUCT_AUTODETECT
- if (!CItemData::TItemTableAll::IsValidStruct(structSize))
- #else
- if (structSize != sizeof(CItemData::TItemTable))
- #endif
- {
- printf("LoadItemProto: invalid item_proto structSize[%d] != sizeof(SItemTable)\n", structSize, sizeof(CItemData::TItemTable));
- return;
- }
- if (data)
- {
- fread(data, dataSize, 1, fp);
- CLZObject zObj;
- if (CLZO::instance().Decompress(zObj, data, g_adwItemProtoKey))
- {
- printf("real_size %u\n", zObj.GetSize());
- if (LoadNPrint)
- {
- for (DWORD i = 0; i < tableSize; ++i)
- {
- #ifdef ENABLE_PROTOSTRUCT_AUTODETECT
- CItemData::TItemTable rTable = {0};
- CItemData::TItemTableAll::Process(zObj.GetBuffer(), structSize, i, rTable);
- #else
- CItemData::TItemTable & rTable = *((CItemData::TItemTable *) zObj.GetBuffer() + i);
- #endif
- printf("%u %s\n", rTable.dwVnum, rTable.szLocaleName);
- }
- }
- else
- {
- FILE * mf1; fopen_s(&mf1, "item_names.txt", "w");
- FILE * mf2; fopen_s(&mf2, "item_proto.txt", "w");
- if (mf1==NULL)
- {
- printf("item_names.txt not writable");
- return;
- }
- if (mf2==NULL)
- {
- printf("item_proto.txt not writable");
- return;
- }
- fprintf(mf1, "VNUM\tLOCALE_NAME\n");
- fprintf(mf2, "ITEM_VNUM~RANGE\tITEM_NAME(K)\tITEM_TYPE\tSUB_TYPE\tSIZE\tANTI_FLAG\tFLAG\tITEM_WEAR\tIMMUNE\tGOLD\tSHOP_BUY_PRICE\tREFINE\tREFINESET\tMAGIC_PCT\tLIMIT_TYPE0\tLIMIT_VALUE0\tLIMIT_TYPE1\tLIMIT_VALUE1\tADDON_TYPE0\tADDON_VALUE0\tADDON_TYPE1\tADDON_VALUE1\tADDON_TYPE2\tADDON_VALUE2\tVALUE0\tVALUE1\tVALUE2\tVALUE3\tVALUE4\tVALUE5\tSpecular\tSOCKET\tATTU_ADDON\n");
- for (DWORD i = 0; i < tableSize; ++i)
- {
- #ifdef ENABLE_PROTOSTRUCT_AUTODETECT
- CItemData::TItemTable rTable = {0};
- CItemData::TItemTableAll::Process(zObj.GetBuffer(), structSize, i, rTable);
- #else
- CItemData::TItemTable & rTable = *((CItemData::TItemTable *) zObj.GetBuffer() + i);
- #endif
- fprintf(mf1, "%u %s\n", rTable.dwVnum, rTable.szLocaleName);
- fprintf(mf2,
- "%s %s" // 2
- " %s %s %u %s" // 6
- " %s %s %s" // 9
- " %u %u %u %u %u" // 14
- " %s %d %s %d" // 18
- " %s %d %s %d %s %d" // 24
- " %d %d %d %d %d %d" // 30
- " %u %u %d" // 33
- "\n",
- retrieveVnumRange(rTable.dwVnum, rTable.dwVnumRange).c_str(), rTable.szName, // 2
- set_Item_Type_Value(rTable.bType).c_str(), set_Item_SubType_Value(rTable.bType, rTable.bSubType).c_str(), rTable.bSize, set_Item_AntiFlag_Value(rTable.dwAntiFlags).c_str(), // 6
- set_Item_Flag_Value(rTable.dwFlags).c_str(), set_Item_WearFlag_Value(rTable.dwWearFlags).c_str(), set_Item_Immune_Value(rTable.dwImmuneFlag).c_str(), // 9
- rTable.dwIBuyItemPrice, rTable.dwISellItemPrice, rTable.dwRefinedVnum, rTable.wRefineSet, rTable.bAlterToMagicItemPct, // 14
- set_Item_LimitType_Value(rTable.aLimits[0].bType).c_str(), rTable.aLimits[0].lValue, set_Item_LimitType_Value(rTable.aLimits[1].bType).c_str(), rTable.aLimits[1].lValue, // 18
- set_Item_ApplyType_Value(rTable.aApplies[0].bType).c_str(), rTable.aApplies[0].lValue, set_Item_ApplyType_Value(rTable.aApplies[1].bType).c_str(), rTable.aApplies[1].lValue,
- set_Item_ApplyType_Value(rTable.aApplies[2].bType).c_str(), rTable.aApplies[2].lValue, // 24
- rTable.alValues[0], rTable.alValues[1], rTable.alValues[2], rTable.alValues[3], rTable.alValues[4], rTable.alValues[5], // 30
- rTable.bSpecular, rTable.bGainSocketPct, retrieveAddonType(rTable.dwVnum) // 33
- );
- }
- ;
- }
- }
- free(data);
- }
- fclose(fp);
- }
- void SaveItemProto()
- {
- FILE * fp;
- fopen_s(&fp, "item_proto", "wb");
- if (!fp)
- {
- printf("cannot open %s for writing\n", "item_proto");
- return;
- }
- DWORD fourcc = MAKEFOURCC('M', 'I', 'P', 'X');
- fwrite(&fourcc, sizeof(DWORD), 1, fp);
- DWORD dwVersion = 0x00000001;
- fwrite(&dwVersion, sizeof(DWORD), 1, fp);
- DWORD dwStride = sizeof(CItemData::TItemTable);
- fwrite(&dwStride, sizeof(DWORD), 1, fp);
- DWORD dwElements = m_iItemTableSize;
- fwrite(&dwElements, sizeof(DWORD), 1, fp);
- CLZObject zObj;
- std::vector <CItemData::TItemTable> vec_item_table (&m_pItemTable[0], &m_pItemTable[m_iItemTableSize - 1]);
- std::sort (&m_pItemTable[0], &m_pItemTable[0] + m_iItemTableSize);
- if (!CLZO::instance().CompressEncryptedMemory(zObj, m_pItemTable, sizeof(CItemData::TItemTable) * m_iItemTableSize, g_adwItemProtoKey))
- {
- printf("cannot compress\n");
- fclose(fp);
- return;
- }
- const CLZObject::THeader & r = zObj.GetHeader();
- printf("Elements %d\n%u --Compress--> %u --Encrypt--> %u, GetSize %u\n",
- m_iItemTableSize,
- r.dwRealSize,
- r.dwCompressedSize,
- r.dwEncryptSize,
- zObj.GetSize());
- DWORD dwDataSize = zObj.GetSize();
- fwrite(&dwDataSize, sizeof(DWORD), 1, fp);
- fwrite(zObj.GetBuffer(), dwDataSize, 1, fp);
- fclose(fp);
- fopen_s(&fp, "item_proto", "rb");
- if (!fp)
- {
- printf("Error!!\n");
- return;
- }
- fread(&fourcc, sizeof(DWORD), 1, fp);
- fread(&dwElements, sizeof(DWORD), 1, fp);
- printf("Elements Check %u fourcc match %d\n", dwElements, fourcc == MAKEFOURCC('M', 'I', 'P', 'T'));
- fclose(fp);
- }
- #define NL "\n"
- #include "OptionParser.h"
- enum optionIndex { UNKNOWN, HELP, DEBUG_MODE, ITEM_PROTO, MOB_PROTO, PACK, UNPACK };
- const option::Descriptor usage[] = // don't use TAB in here!
- {
- {UNKNOWN, 0, "", "", option::Arg::None, "USAGE: example [options]"},
- {HELP, 0, "h", "help", option::Arg::None, " --help, -h Print usage and exit." },
- {DEBUG_MODE, 0, "d", "debug", option::Arg::None, " --debug, -d Enable debug mode" },
- {ITEM_PROTO, 0, "i", "iproto", option::Arg::None, " --iproto, -i Process item proto" },
- {MOB_PROTO, 0, "m", "mproto", option::Arg::None, " --mproto, -m Process mob proto" },
- {PACK, 0, "p", "pack", option::Arg::None, " --pack, -p Pack" },
- {UNPACK, 0, "u", "unpack", option::Arg::None, " --unpack, -u Unpack" },
- {UNKNOWN, 0, "", "", option::Arg::None, NL "Examples:"
- NL " dump_proto.exe --help"
- NL " dump_proto.exe -dpim"
- NL " dump_proto.exe -duim"
- NL " dump_proto.exe -dpm"
- NL " dump_proto.exe -dum"
- NL " dump_proto.exe -dpi"
- NL " dump_proto.exe -dui"
- },
- {0,0,0,0,0,0}
- };
- int main(int argc, char ** argv)
- {
- argc-=(argc>0); argv+=(argc>0); // skip program name argv[0] if present
- option::Stats stats(usage, argc, argv);
- std::vector<option::Option> options(stats.options_max);
- std::vector<option::Option> buffer(stats.buffer_max);
- option::Parser parse(usage, argc, argv, &options[0], &buffer[0]);
- if (parse.error())
- return 1;
- if (argc == 0)
- {
- if (BuildMobTable())
- {
- SaveMobProto();
- std::cout << "BuildMobTable working normal" << std::endl;
- }
- if (BuildItemTable())
- {
- SaveItemProto();
- std::cout << "BuildItemTable working normal" << std::endl;
- }
- return 0;
- }
- bool bAItemProto = false;
- bool bAMobProto = false;
- bool bXPhase = false;
- for (size_t idx1 = 0; idx1 < parse.optionsCount(); ++idx1)
- {
- option::Option& opt = buffer[idx1];
- switch (opt.index())
- {
- case DEBUG_MODE:
- bDebugFlag = true;
- break;
- case ITEM_PROTO:
- bAItemProto = true;
- break;
- case MOB_PROTO:
- bAMobProto = true;
- break;
- case PACK:
- bXPhase = false;
- break;
- case UNPACK:
- bXPhase = true;
- break;
- case HELP:
- default:
- option::printUsage(std::cout, usage);
- exit(0);
- break;
- }
- }
- #ifdef _DEBUG
- printf("sizeof(TItemTable) %d\n", sizeof(CItemData::TItemTable));
- #ifdef ENABLE_PROTOSTRUCT_AUTODETECT
- printf("sizeof(TItemTable_r152) %d\n", sizeof(CItemData::TItemTable_r152));
- printf("sizeof(TItemTable_r156) %d\n", sizeof(CItemData::TItemTable_r156));
- printf("sizeof(TItemTable_r158) %d\n", sizeof(CItemData::TItemTable_r158));
- #endif
- printf("sizeof(TMobTable) %d\n", sizeof(CPythonNonPlayer::TMobTable));
- #ifdef ENABLE_PROTOSTRUCT_AUTODETECT
- printf("sizeof(TMobTable_r235) %d\n", sizeof(CPythonNonPlayer::TMobTable_r235));
- printf("sizeof(TMobTable_r255) %d\n", sizeof(CPythonNonPlayer::TMobTable_r255));
- printf("sizeof(TMobTable_r256) %d\n", sizeof(CPythonNonPlayer::TMobTable_r256));
- printf("sizeof(TMobTable_r262) %d\n", sizeof(CPythonNonPlayer::TMobTable_r262));
- #endif
- #endif
- if (bAItemProto)
- {
- if (bXPhase)
- LoadItemProto();
- else if (BuildItemTable())
- SaveItemProto();
- }
- if (bAMobProto)
- {
- if (bXPhase)
- LoadMobProto();
- else if (BuildMobTable())
- SaveMobProto();
- }
- return 0;
- }
Er entpackt die Item_proto zwar komplett jedoch packt er sie nicht wieder, warscheinlich wegen den Fehler.
Wäre dankbar wenn mir jemand den Fehler erklären könnte^^
liebe grüße