Mercurial > mm7
changeset 703:a9c1fb7483c2
monster parser almost complete.
author | Gloval |
---|---|
date | Tue, 19 Mar 2013 01:33:35 +0400 |
parents | d5b16a44d9b3 |
children | ef4d646d738d |
files | AudioPlayer.cpp Chest.cpp FrameTableInc.cpp FrameTableInc.h Monsters.cpp Overlays.cpp mm7_2.cpp mm7_4.cpp mm7_5.cpp |
diffstat | 9 files changed, 230 insertions(+), 252 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.cpp Mon Mar 18 22:53:56 2013 +0400 +++ b/AudioPlayer.cpp Tue Mar 19 01:33:35 2013 +0400 @@ -469,7 +469,7 @@ do { *strchr(&Buf, 10) = 0; - memcpy(&v19, texture_frame_table_txt_parser(&Buf, &v18), sizeof(v19)); + memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); if ( v19.uPropCount && *v19.pProperties[0] != 47 ) ++Argsa; } @@ -489,7 +489,7 @@ for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) { *strchr(&Buf, 10) = 0; - memcpy(&v19, texture_frame_table_txt_parser(&Buf, &v18), sizeof(v19)); + memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); if ( v19.uPropCount && *v19.pProperties[0] != 47 ) { sprintf(v2->pSounds[v2->uNumSounds].pSoundName, "%s", v19.pProperties[0]);
--- a/Chest.cpp Mon Mar 18 22:53:56 2013 +0400 +++ b/Chest.cpp Tue Mar 19 01:33:35 2013 +0400 @@ -686,7 +686,7 @@ do { *strchr(&Buf, 10) = 0; - memcpy(&v17, texture_frame_table_txt_parser(&Buf, &v16), sizeof(v17)); + memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17)); if ( v17.uPropCount && *v17.pProperties[0] != 47 ) ++Argsa; } @@ -707,7 +707,7 @@ for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) { *strchr(&Buf, 10) = 0; - memcpy(&v17, texture_frame_table_txt_parser(&Buf, &v16), sizeof(v17)); + memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17)); if ( v17.uPropCount && *v17.pProperties[0] != 47 ) { strcpy(v2->pChests[v2->uNumChests].pName, v17.pProperties[0]);
--- a/FrameTableInc.cpp Mon Mar 18 22:53:56 2013 +0400 +++ b/FrameTableInc.cpp Tue Mar 19 01:33:35 2013 +0400 @@ -3,7 +3,7 @@ //identical function to work in differnt threads //----- (004BE3BF) -------------------------------------------------------- -FrameTableTxtLine *texture_frame_table_txt_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table) +FrameTableTxtLine* txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table) { bool new_token_flag; // edx@3 bool in_quotes; // [sp+Ch] [bp-4h]@3
--- a/FrameTableInc.h Mon Mar 18 22:53:56 2013 +0400 +++ b/FrameTableInc.h Tue Mar 19 01:33:35 2013 +0400 @@ -13,16 +13,14 @@ /* 359 */ #pragma pack(push, 1) -struct FrameTableTxtLine +struct FrameTableTxtLine //7C { int uPropCount; - const char *pProperties[31]; - // const char *pProperties2[16]; - // int field_78; + const char *pProperties[30]; }; #pragma pack(pop) -FrameTableTxtLine *texture_frame_table_txt_parser(const char *_this, FrameTableTxtLine *a2); +FrameTableTxtLine* txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table); FrameTableTxtLine *frame_table_txt_parser(const char *pString, FrameTableTxtLine *a2); \ No newline at end of file
--- a/Monsters.cpp Mon Mar 18 22:53:56 2013 +0400 +++ b/Monsters.cpp Tue Mar 19 01:33:35 2013 +0400 @@ -16,7 +16,7 @@ struct MonsterStats *pMonsterStats; struct MonsterList *pMonsterList; -unsigned int __fastcall ParseSpellType(struct FrameTableTxtLine *, int a2); +unsigned int ParseSpellType(struct FrameTableTxtLine* tbl, int* next_token); int ParseAttackType(const char *damage_type_str); void ParseDamage( char *damage_str, unsigned __int8* dice_rolls, unsigned __int8* dice_sides, unsigned __int8* dmg_bonus ); @@ -24,238 +24,151 @@ int ParseSpecialAttack(const char *spec_att_str); //----- (004548E2) -------------------------------------------------------- -unsigned int __fastcall ParseSpellType(FrameTableTxtLine *a1, int a2) +unsigned int ParseSpellType( struct FrameTableTxtLine * tbl, int* next_token ) { - int v2; // edi@1 - int v3; // esi@1 - unsigned int result; // eax@1 - std::string v5; // [sp-18h] [bp-28h]@75 - const char *v6; // [sp-8h] [bp-18h]@75 - signed int v7; // [sp-4h] [bp-14h]@3 - std::string *v8; // [sp+8h] [bp-8h]@75 - int a3; // [sp+Fh] [bp-1h]@75 - v2 = (int)a1; - v3 = a2; - result = (int)a1->pProperties[0]; - if ( result ) + if (!tbl->pProperties[0] ) + { + ++*next_token; + return 0; + } + if ( !_strcmpi(tbl->pProperties[0], "Dispel") ) //dispel magic + { + ++*next_token; + return 80; + } + else if ( !_strcmpi(tbl->pProperties[0], "Day") ) //day of protection + { + *next_token+=2;; + return 85; + } + else if ( !_strcmpi(tbl->pProperties[0], "Hour") ) //hour of power + { + *next_token+=2;; + return 86; + } + else if ( !_strcmpi(tbl->pProperties[0], "Shield") ) + return 17; + else if ( !_strcmpi(tbl->pProperties[0], "Spirit") ) + { + ++*next_token; + return 52; + } + else if ( !_strcmpi(tbl->pProperties[0], "Power") ) //power cure + { + ++*next_token; + return 77; + } + else if ( !_strcmpi(tbl->pProperties[0], "Meteor") ) //meteot shower + { + ++*next_token; + return 9; + } + else if ( !_strcmpi(tbl->pProperties[0], "Lightning") ) //Lightning bolt + { + ++*next_token; + return 18; + } + else if ( !_strcmpi(tbl->pProperties[0], "Implosion") ) + return 20; + else if ( !_strcmpi(tbl->pProperties[0], "Stone") ) + { + ++*next_token; + return 38; + } + else if ( !_strcmpi(tbl->pProperties[0], "Haste") ) + return 5; + else if ( !_strcmpi(tbl->pProperties[0], "Heroism") ) + return 51; + else if ( !_strcmpi(tbl->pProperties[0], "Pain") ) //pain reflection + { + ++*next_token; + return 95; + } + else if ( !_strcmpi(tbl->pProperties[0], "Sparks") ) + return 15; + else if ( !_strcmpi(tbl->pProperties[0], "Light") ) + { + ++*next_token; + return 78; + } + else if ( !_strcmpi(tbl->pProperties[0], "Toxic") ) //toxic cloud { - if ( !_strcmpi((const char *)result, "Dispel") ) - { - v7 = 80; -LABEL_71: - result = v7; -LABEL_76: - ++*(int *)v3; - return result; - } - if ( _strcmpi(*(const char **)(v2 + 4), "Day") ) - { - if ( _strcmpi(*(const char **)(v2 + 4), "Hour") ) - { - if ( _strcmpi(*(const char **)(v2 + 4), "Shield") ) - { - if ( !_strcmpi(*(const char **)(v2 + 4), "Spirit") ) - { - v7 = 52; - goto LABEL_71; - } - if ( !_strcmpi(*(const char **)(v2 + 4), "Power") ) - { - v7 = 77; - goto LABEL_71; - } - if ( !_strcmpi(*(const char **)(v2 + 4), "Meteor") ) - { - v7 = 9; - goto LABEL_71; - } - if ( !_strcmpi(*(const char **)(v2 + 4), "Lightning") ) - { - v7 = 18; - goto LABEL_71; - } - if ( _strcmpi(*(const char **)(v2 + 4), "Implosion") ) - { - if ( !_strcmpi(*(const char **)(v2 + 4), "Stone") ) - { - v7 = 38; - goto LABEL_71; - } - if ( _strcmpi(*(const char **)(v2 + 4), "Haste") ) - { - if ( _strcmpi(*(const char **)(v2 + 4), "Heroism") ) - { - if ( !_strcmpi(*(const char **)(v2 + 4), "Pain") ) - { - v7 = 95; - goto LABEL_71; - } - if ( _strcmpi(*(const char **)(v2 + 4), "Sparks") ) - { - if ( !_strcmpi(*(const char **)(v2 + 4), "Light") ) - { - v7 = 78; - goto LABEL_71; - } - if ( !_strcmpi(*(const char **)(v2 + 4), "Toxic") ) - { - v7 = 90; - goto LABEL_71; - } - if ( _strcmpi(*(const char **)(v2 + 4), "ShrapMetal") ) - { - if ( _strcmpi(*(const char **)(v2 + 4), "Paralyze") ) - { - if ( _strcmpi(*(const char **)(v2 + 4), "Fireball") ) - { - if ( _strcmpi(*(const char **)(v2 + 4), "Incinerate") ) - { - if ( !_strcmpi(*(const char **)(v2 + 4), "Fire") ) - { - v7 = 2; - goto LABEL_71; - } - if ( !_strcmpi(*(const char **)(v2 + 4), "Rock") ) - { - v7 = 41; - goto LABEL_71; - } - if ( !_strcmpi(*(const char **)(v2 + 4), "Mass") ) - { - v7 = 44; - goto LABEL_71; - } - if ( !_strcmpi(*(const char **)(v2 + 4), "Ice") ) - { - v7 = 26; - goto LABEL_71; - } - if ( !_strcmpi(*(const char **)(v2 + 4), "Acid") ) - { - v7 = 29; - goto LABEL_71; - } - if ( _strcmpi(*(const char **)(v2 + 4), "Bless") ) - { - if ( !_strcmpi(*(const char **)(v2 + 4), "Dragon") ) - { - v7 = 97; - goto LABEL_71; - } - if ( _strcmpi(*(const char **)(v2 + 4), "Reanimate") ) - { - if ( !_strcmpi(*(const char **)(v2 + 4), "Summon") ) - { - v7 = 82; - goto LABEL_71; - } - if ( _strcmpi(*(const char **)(v2 + 4), "Fate") ) - { - if ( _strcmpi(*(const char **)(v2 + 4), "Harm") ) - { - if ( !_strcmpi(*(const char **)(v2 + 4), "Mind") ) - { - v7 = 57; - goto LABEL_71; - } - if ( _strcmpi(*(const char **)(v2 + 4), "Blades") ) - { - if ( !_strcmpi(*(const char **)(v2 + 4), "Psychic") ) - { - v7 = 65; - goto LABEL_71; - } - if ( _strcmpi(*(const char **)(v2 + 4), "Hammerhands") ) - { - sprintf(pTmpBuf, "Unknown monster spell %s", *(int *)(v2 + 4)); - MessageBoxA(nullptr, pTmpBuf, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:1562", 0); - result = 0; - goto LABEL_76; - } - v7 = 73; - } - else - { - v7 = 39; - } - } - else - { - v7 = 70; - } - } - else - { - v7 = 47; - } - } - else - { - v7 = 89; - } - } - else - { - v7 = 46; - } - } - else - { - v7 = 11; - } - } - else - { - v7 = 6; - } - } - else - { - v7 = 81; - } - } - else - { - v7 = 93; - } - } - else - { - v7 = 15; - } - } - else - { - v7 = 51; - } - } - else - { - v7 = 5; - } - } - else - { - v7 = 20; - } - } - else - { - v7 = 17; - } - return v7; - } - v7 = 86; - } - else - { - v7 = 85; - } - *(int *)v3 += 2; - result = v7; + ++*next_token; + return 90; + } + else if ( !_strcmpi(tbl->pProperties[0], "ShrapMetal") ) + return 93; + else if ( !_strcmpi(tbl->pProperties[0], "Paralyze") ) + return 81; + else if ( !_strcmpi(tbl->pProperties[0], "Fireball") ) + return 6; + else if ( !_strcmpi(tbl->pProperties[0], "Incinerate") ) + return 11; + else if ( !_strcmpi(tbl->pProperties[0], "Fire") ) + { + ++*next_token; + return 2; + } + else if ( !_strcmpi(tbl->pProperties[0], "Rock") ) + { + ++*next_token; + return 41; + } + else if ( !_strcmpi(tbl->pProperties[0], "Mass") ) + { + ++*next_token; + return 44; + } + else if ( !_strcmpi(tbl->pProperties[0], "Ice") ) + { + ++*next_token; + return 26; + } + else if ( !_strcmpi(tbl->pProperties[0], "Acid") ) + { + ++*next_token; + return 29; } - return result; + else if ( !_strcmpi(tbl->pProperties[0], "Bless") ) + return 46; + else if ( !_strcmpi(tbl->pProperties[0], "Dragon") ) + { + ++*next_token; + return 97; + } + else if ( !_strcmpi(tbl->pProperties[0], "Reanimate") ) + return 89; + else if ( !_strcmpi(tbl->pProperties[0], "Summon") ) + { + ++*next_token; + return 82; + } + else if ( !_strcmpi(tbl->pProperties[0], "Fate") ) + return 47; + else if ( !_strcmpi(tbl->pProperties[0], "Harm") ) + return 70; + else if ( !_strcmpi(tbl->pProperties[0], "Mind") ) + { + ++*next_token; + return 57; + } + else if ( !_strcmpi(tbl->pProperties[0], "Blades") ) + return 39; + else if ( !_strcmpi(tbl->pProperties[0], "Psychic") ) + { + ++*next_token; + return 65; + } + else if ( !_strcmpi(tbl->pProperties[0], "Hammerhands") ) + return 73; + else + { + sprintf(pTmpBuf, "Unknown monster spell %s", tbl->pProperties[0]); + MessageBoxA(nullptr, pTmpBuf, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:1562", 0); + ++*next_token; + return 0; + } } //----- (00454CB4) -------------------------------------------------------- @@ -348,8 +261,9 @@ } -int ParseSpecialAttack(const char *spec_att_str) +int ParseSpecialAttack(char *spec_att_str) { + _strlwr(spec_att_str); if ( strstr(spec_att_str, "curse") ) return 1; else if ( strstr(spec_att_str, "weak") ) @@ -742,7 +656,7 @@ char Src[120]; // [sp+184h] [bp-2D4h]@317 FrameTableTxtLine v89; // [sp+1FCh] [bp-25Ch]@249 FrameTableTxtLine v90; // [sp+278h] [bp-1E0h]@240 - char Str[64]; // [sp+2F4h] [bp-164h]@240 + char Dest[64]; // [sp+334h] [bp-124h]@249 char v93[64]; // [sp+374h] [bp-E4h]@297 FrameTableTxtLine v94; // [sp+3B4h] [bp-A4h]@297 @@ -765,6 +679,7 @@ int decode_step; int item_counter; int curr_rec_num; + char parse_str[64]; v1 = this; v102 = this; @@ -1079,7 +994,25 @@ break; case 16: { - + int str_len=0; + int str_pos=0; + pInfos[curr_rec_num].uSpecialAttackType=1; + pInfos[curr_rec_num].uSpecialAttack=0; + str_len=strlen(test_string); + if (str_len>1) + { + for (str_pos=0;str_pos<str_len;++str_pos ) + { + if (tolower(test_string[str_pos])=='x') + { + test_string[str_pos]='\0'; + pInfos[curr_rec_num].uSpecialAttackType=atoi(&test_string[str_pos+1]); + test_string[str_pos]='x'; + break; + } + } + pInfos[curr_rec_num].uSpecialAttack=ParseSpecialAttack(test_string); + } } break; case 17: @@ -1116,6 +1049,30 @@ break; case 25: { + int param_num; + char type_flag; + strcpy(parse_str,test_string); + parse_str[0]=' '; + parse_str[strlen(parse_str)-1]=' '; + frame_table_txt_parser(parse_str,&v85); + if (v85.uPropCount>2) + { + param_num=1; + pInfos[curr_rec_num].uSpell1ID=ParseSpellType(&v85,¶m_num); + type_flag=*v85.pProperties[param_num]; + pInfos[curr_rec_num].uSpellSkillAndMastery1=atoi(v85.pProperties[param_num+1])&0x003F; + switch(type_flag) + { + case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0040; break; + case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0080; break; + case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0100; break; + } + } + else + { + pInfos[curr_rec_num].uSpell1ID=0; + pInfos[curr_rec_num].uSpellSkillAndMastery1=0; + } } break; @@ -1124,7 +1081,30 @@ break; case 27: { - + int param_num; + char type_flag; + strcpy(parse_str,test_string); + parse_str[0]=' '; + parse_str[strlen(parse_str)-1]=' '; + frame_table_txt_parser(parse_str,&v85); + if (v85.uPropCount>2) + { + param_num=1; + pInfos[curr_rec_num].uSpell2ID=ParseSpellType(&v85,¶m_num); + type_flag=*v85.pProperties[param_num]; + pInfos[curr_rec_num].uSpellSkillAndMastery2=atoi(v85.pProperties[param_num+1])&0x003F; + switch(type_flag) + { + case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0040; break; + case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0080; break; + case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0100; break; + } + } + else + { + pInfos[curr_rec_num].uSpell2ID=0; + pInfos[curr_rec_num].uSpellSkillAndMastery2=0; + } } break; case 28:
--- a/Overlays.cpp Mon Mar 18 22:53:56 2013 +0400 +++ b/Overlays.cpp Tue Mar 19 01:33:35 2013 +0400 @@ -219,7 +219,7 @@ do { *strchr(&Buf, 10) = 0; - memcpy(&v19, texture_frame_table_txt_parser(&Buf, &v18), sizeof(v19)); + memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); if ( v19.uPropCount && *v19.pProperties[0] != 47 ) ++Argsa; } @@ -240,7 +240,7 @@ for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) { *strchr(&Buf, 10) = 0; - memcpy(&v19, texture_frame_table_txt_parser(&Buf, &v18), sizeof(v19)); + memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); if ( v19.uPropCount && *v19.pProperties[0] != 47 ) { v10 = atoi(v19.pProperties[0]);
--- a/mm7_2.cpp Mon Mar 18 22:53:56 2013 +0400 +++ b/mm7_2.cpp Tue Mar 19 01:33:35 2013 +0400 @@ -4764,7 +4764,7 @@ do { *strchr(&Buf, 10) = 0; - memcpy(&v21, texture_frame_table_txt_parser(&Buf, &v20), 0x7Cu); + memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); if ( v21 && *Str1 != 47 ) { if ( v21 < 2 ) @@ -4788,7 +4788,7 @@ for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) { *strchr(&Buf, 10) = 0; - memcpy(&v21, texture_frame_table_txt_parser(&Buf, &v20), 0x7Cu); + memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); if ( v21 && *Str1 != 47 ) { strcpy(v2->pTextures[v2->uNumTextures].pTextureName, Str1);
--- a/mm7_4.cpp Mon Mar 18 22:53:56 2013 +0400 +++ b/mm7_4.cpp Tue Mar 19 01:33:35 2013 +0400 @@ -1943,7 +1943,7 @@ for ( i = v3; fgets(&Buf, 490, i); i = File ) { *strchr(&Buf, 10) = 0; - memcpy(&v84, texture_frame_table_txt_parser(&Buf, &v85), sizeof(v84)); + memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); if ( v84.uPropCount && *v84.pProperties[0] != 47 ) ++v4; } @@ -1960,7 +1960,7 @@ while ( 1 ) { *strchr(&Buf, 10) = 0; - memcpy(&v84, texture_frame_table_txt_parser(&Buf, &v85), sizeof(v84)); + memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); if ( v84.uPropCount ) { if ( *v84.pProperties[0] != 47 ) @@ -4426,7 +4426,7 @@ do { *strchr(&Buf, 10) = 0; - memcpy(&v24, texture_frame_table_txt_parser(&Buf, &v23), sizeof(v24)); + memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); if ( v24.uPropCount && *v24.pProperties[0] != 47 ) { if ( v24.uPropCount < 3 ) @@ -4449,7 +4449,7 @@ for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) { *strchr(&Buf, 10) = 0; - memcpy(&v24, texture_frame_table_txt_parser(&Buf, &v23), sizeof(v24)); + memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); if ( v24.uPropCount && *v24.pProperties[0] != 47 ) { v8 = atoi(v24.pProperties[0]);
--- a/mm7_5.cpp Mon Mar 18 22:53:56 2013 +0400 +++ b/mm7_5.cpp Tue Mar 19 01:33:35 2013 +0400 @@ -2284,7 +2284,7 @@ case UIMSG_DD: LABEL_524: sprintf(pTmpBuf, "%s", pKeyActionMap->pPressedKeysBuffer); - memcpy(&v216, texture_frame_table_txt_parser((const char *)pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216)); + memcpy(&v216, txt_file_frametable_parser((const char *)pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216)); if ( v216.uPropCount == 1 ) { pNPCData4 = (NPCData *)((signed int)pGames_LOD->uNumSubIndices / 2);