Mercurial > mm7
diff Monsters.cpp @ 237:2799737f8a74
more text parsers refactor
author | Gloval |
---|---|
date | Mon, 18 Feb 2013 00:47:36 +0400 |
parents | 9b77686e2239 |
children | 52329962fcdb |
line wrap: on
line diff
--- a/Monsters.cpp Sun Feb 17 18:50:35 2013 +0400 +++ b/Monsters.cpp Mon Feb 18 00:47:36 2013 +0400 @@ -215,67 +215,49 @@ //----- (00454F4E) -------------------------------------------------------- void MonsterStats::InitializePlacements() { - char *v1; // ebx@1 - MonsterStats *v2; // edi@1 - char *v3; // eax@2 - char v4; // dl@3 - char *v5; // ecx@3 - int v6; // esi@7 - signed int v7; // [sp+Ch] [bp-10h]@1 - char **v8; // [sp+10h] [bp-Ch]@1 - signed int v9; // [sp+14h] [bp-8h]@2 - char *v10; // [sp+18h] [bp-4h]@2 + int i; + char* test_string; + unsigned char c; + bool break_loop; + unsigned int temp_str_len; + char* tmp_pos; + int decode_step; + int item_counter; - v1 = 0; - v2 = this; pMonsterPlacementTXT_Raw = (char *)pEvents_LOD->LoadRaw("placemon.txt", 0); strtok(pMonsterPlacementTXT_Raw, "\r"); - v2->uNumPlacements = 31; - v8 = v2->pPlacement.pSubstrings; - v7 = 30; - do - { - v3 = strtok(v1, "\r") + 1; - v10 = v1; - v9 = (signed int)v1; - do - { - v4 = *v3; - v5 = 0; - if ( *v3 != 9 ) - { - v1 = 0; - do - { - if ( !v4 ) - break; - ++v5; - v4 = v3[(unsigned int)v5]; - } - while ( v4 != 9 ); - } - v6 = (int)&v3[(unsigned int)v5]; - if ( v3[(unsigned int)v5] == (unsigned char)v1 ) - v9 = 1; - *(unsigned char *)v6 = (unsigned char)v1; - if ( v5 == v1 ) - { - v9 = 1; - } - else - { - if ( v10 == (char *)1 ) - *v8 = (char *)RemoveQuotes(v3); - } - ++v10; - v3 = (char *)(v6 + 1); - } - while ( (signed int)(v10 - 1) <= 31 && (char *)v9 == v1 ); - ++v8; - --v7; - } - while ( v7 ); - v2->uNumPlacements = 31; + for (i=1; i<31; ++i) + { + test_string = strtok(NULL, "\r") + 1; + break_loop = false; + decode_step=0; + do + { + c = *(unsigned char*)test_string; + temp_str_len = 0; + while((c!='\t')&&(c>0)) + { + ++temp_str_len; + c=test_string[temp_str_len]; + } + tmp_pos=test_string+temp_str_len; + if (*tmp_pos == 0) + break_loop = true; + *tmp_pos = 0; + if (temp_str_len) + { + if (decode_step==1) + pPlaceStrings[i]=RemoveQuotes(test_string); + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<3)&&!break_loop); + } + uNumPlacements = 31; } //----- (0045501E) --------------------------------------------------------