diff Items.cpp @ 212:9f349addbe00

Слияние
author Ritor1
date Sat, 16 Feb 2013 22:14:04 +0600
parents 821fd955c379
children 30aa44013f7a 8113753ed2ae
line wrap: on
line diff
--- a/Items.cpp	Sat Feb 16 22:13:54 2013 +0600
+++ b/Items.cpp	Sat Feb 16 22:14:04 2013 +0600
@@ -1492,89 +1492,78 @@
 //----- (00453B3C) --------------------------------------------------------
 void ItemsTable::LoadPotions()
 {
-  char *i; // eax@3
-  signed int v2; // esi@11
-  char *v3; // eax@16
-  char *v4; // edi@16
-  __int16 v5; // ax@17
-  char *v6; // esi@17
-  CHAR Text; // [sp+Ch] [bp-6Ch]@26
-  ItemsTable *v8; // [sp+68h] [bp-10h]@1
-  int v9; // [sp+6Ch] [bp-Ch]@10
-  int v10; // [sp+70h] [bp-8h]@10
-  char *v11; // [sp+74h] [bp-4h]@4
+  
+  CHAR Text[90]; // [sp+Ch] [bp-6Ch]@26
+  char* test_string;
+  unsigned int uRow;
+  unsigned int uColumn;
+  unsigned __int8 potion_value;
 
-  v8 = this;
   if ( pPotionsTXT_Raw )
     pAllocator->FreeChunk(pPotionsTXT_Raw);
-  pPotionsTXT_Raw = 0;
+  pPotionsTXT_Raw = NULL;
   pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0);
-  for ( i = strtok(pPotionsTXT_Raw, "\t\r\n"); ; i = strtok(0, "\t\r\n") )
-  {
-    v11 = i;
-    if ( !strcmp(i, "222") )
-      break;
-    if ( !v11 )
-    {
-LABEL_20:
-      MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", 0x10u);
-      return;
-    }
-  }
+	test_string = strtok(pPotionsTXT_Raw,"\t\r\n");
+	while ( 1 )
+		{
+		if ( !test_string )
+			{
+			MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+			return;
+			}
+		if ( !strcmp(test_string, "222") )
+			break;
+		
+		test_string = strtok(NULL, "\t\r\n");
+		}
   while ( 1 )
   {
-    v11 = strtok(0, "\t\r\n");
-    if ( !strcmp(v11, "222") )
+    test_string = strtok(NULL, "\t\r\n");
+    
+    if ( !test_string )
+		{
+		MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+		return;
+		}
+if ( !strcmp(test_string, "222") )
       break;
-    if ( !v11 )
-      goto LABEL_20;
   }
-  v9 = 0;
-  v10 = 30642;
-  do
+
+  for (uRow = 0;uRow < 50; ++uRow)
   {
-    v11 = 0;
-    v2 = 0;
-    do
-    {
-      if ( !strtok(0, "\r\t\n") )
-        break;
-      ++v2;
-    }
-    while ( v2 < 6 );
-    if ( v2 != 6 )
-      break;
-    v11 = 0;
-    do
+    int skip_count;
+    for (skip_count = 0;skip_count < 6; ++skip_count)
     {
-      v3 = strtok(0, "\r\t\n");
-      v4 = v3;
-      if ( !v3 )
+      if ( !strtok(NULL, "\r\t\n") )
         break;
-      v5 = atoi(v3);
-      v6 = (char *)v8 + 2 * (uint)&v11[v10];
-      *(_WORD *)v6 = v5;
-      if ( !v5 )
+    }
+    if ( skip_count != 6 )
+      break;
+	for (uColumn = 0; uColumn < 50; ++uColumn)
+		{
+      test_string = strtok(NULL, "\r\t\n");   
+      if ( !test_string )
+        break;
+      potion_value = atoi(test_string);
+	  char c=*test_string;
+      if ( !potion_value )
       {
-        if ( tolower((unsigned __int8)*v4) == 101 )
-          *(_WORD *)v6 = atoi(v4 + 1);
+        if ( tolower(c) == 'e' )
+          potion_value = atoi(test_string + 1);
         else
-          *(_WORD *)v6 = 0;
+          potion_value = 0;
       }
-      ++v11;
+	  this->potion_data[uRow][uColumn]=potion_value;
     }
-    while ( (signed int)v11 < 50 );
-    if ( v11 != (char *)50 )
+    if ( uColumn != 50 )
       break;
-    strtok(0, "\r\t\n");
-    v10 += 50;
-    ++v9;
+    strtok(NULL, "\r\t\n");
   }
-  while ( v10 < 33142 );
-  if ( v9 != 50 )
+
+  if ( uRow != 50 )
   {
-    wsprintfA(&Text, "Error Parsing Potion Table at Row: %d Column: %d", v9, v11);
-    MessageBoxA(0, &Text, "Parsing Error", 0x10u);
+    wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn);
+    MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
   }
   if ( pPotionsTXT_Raw )
   {
@@ -1586,100 +1575,79 @@
 //----- (00453CE5) --------------------------------------------------------
 void ItemsTable::LoadPotionNotes()
 {
-  char *i; // eax@3
-  signed int v2; // esi@11
-  char *v3; // eax@16
-  char *v4; // edi@16
-  __int16 v5; // ax@17
-  char *v6; // esi@17
-  CHAR *v7; // [sp-Ch] [bp-84h]@20
-  const CHAR *v8; // [sp-8h] [bp-80h]@20
-  UINT v9; // [sp-4h] [bp-7Ch]@20
-  CHAR Text; // [sp+Ch] [bp-6Ch]@26
-  ItemsTable *v11; // [sp+68h] [bp-10h]@1
-  int v12; // [sp+6Ch] [bp-Ch]@10
-  int v13; // [sp+70h] [bp-8h]@10
-  char *v14; // [sp+74h] [bp-4h]@4
+  
+  CHAR Text[90]; 
+  char* test_string;
+  unsigned int uRow;
+  unsigned int uColumn;
+  unsigned __int8 potion_note;
 
-  v11 = this;
   if ( pPotionNotesTXT_Raw )
     pAllocator->FreeChunk(pPotionNotesTXT_Raw);
-  pPotionNotesTXT_Raw = 0;
+  pPotionNotesTXT_Raw = NULL;
   pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0);
-  for ( i = strtok(pPotionNotesTXT_Raw, "\t\r\n"); ; i = strtok(0, "\t\r\n") )
-  {
-    v14 = i;
-    if ( !strcmp(i, "222") )
-      break;
-    if ( !v14 )
-    {
-LABEL_20:
-      v9 = 16;
-      v8 = "Load Error";
-      v7 = "Error Pre-Parsing Potion Table";
-LABEL_27:
-      MessageBoxA(0, v7, v8, v9);
-      return;
-    }
-  }
+  test_string = strtok(pPotionNotesTXT_Raw ,"\t\r\n");
   while ( 1 )
-  {
-    v14 = strtok(0, "\t\r\n");
-    if ( !strcmp(v14, "222") )
-      break;
-    if ( !v14 )
-      goto LABEL_20;
-  }
-  v12 = 0;
-  v13 = 33142;
-  do
-  {
-    v14 = 0;
-    v2 = 0;
-    do
-    {
-      if ( !strtok(0, "\r\t\n") )
-        break;
-      ++v2;
-    }
-    while ( v2 < 6 );
-    if ( v2 != 6 )
-      break;
-    v14 = 0;
-    do
-    {
-      v3 = strtok(0, "\r\t\n");
-      v4 = v3;
-      if ( !v3 )
-        break;
-      v5 = atoi(v3);
-      v6 = (char *)v11 + 2 * (unsigned int)&v14[v13];
-      *(unsigned short *)v6 = v5;
-      if ( !v5 )
-      {
-        if ( tolower((unsigned __int8)*v4) == 101 )
-          *(unsigned short *)v6 = atoi(v4 + 1);
-        else
-          *(unsigned short *)v6 = 0;
-      }
-      ++v14;
-    }
-    while ( (signed int)v14 < 50 );
-    if ( v14 != (char *)50 )
-      break;
-    strtok(0, "\r\t\n");
-    v13 += 50;
-    ++v12;
-  }
-  while ( v13 < 35642 );
-  if ( v12 != 50 )
-  {
-    wsprintfA(&Text, "Error Parsing Potion Autonote Table at Row: %d Column: %d", v12, v14);
-    v9 = 16;
-    v8 = "Parsing Error";
-    v7 = &Text;
-    goto LABEL_27;
-  }
+	  {
+	    
+	  if ( !test_string )
+		  {
+		  MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+		  return;
+		  }	
+	  if ( !strcmp(test_string, "222") )
+		  break;
+	  test_string = strtok(NULL, "\t\r\n");
+	  }
+	  while ( 1 )
+		  {
+		  test_string = strtok(NULL, "\t\r\n");
+		  
+		  if ( !test_string )
+			  {
+			  MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+			  return;
+			  }
+		  if ( !strcmp(test_string, "222") )
+			  break;
+		  }
+ 
+  for (uRow = 0;uRow < 50; ++uRow)
+	  {
+	  int skip_count;
+	  for (skip_count = 0;skip_count < 6; ++skip_count)
+		  {
+		  if ( !strtok(NULL, "\r\t\n") )
+			  break;
+		  }
+	  if ( skip_count != 6 )
+		  break;
+	  for (uColumn = 0; uColumn < 50; ++uColumn)
+		  {
+		  test_string = strtok(NULL, "\r\t\n");   
+		  if ( !test_string )
+			  break;
+		  potion_note = atoi(test_string);
+		  char c=*test_string;
+		  if ( !potion_note )
+			  {
+			  if ( tolower(c) == 'e' )
+				  potion_note = atoi(test_string + 1);
+			  else
+				  potion_note = 0;
+			  }
+		  this->potion_note[uRow][uColumn]=potion_note;
+		  }
+	  if ( uColumn != 50 )
+		  break;
+	  strtok(NULL, "\r\t\n");
+	  }
+
+  if ( uRow != 50 )
+	  {
+	  wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn);
+	  MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE);
+	  }
 }