diff Spells.cpp @ 191:4813b57396ba

spell init in progress
author Gloval
date Sat, 16 Feb 2013 02:26:01 +0400
parents 038a4d09406f
children 1c8add70bcf9 29545d87e11d
line wrap: on
line diff
--- a/Spells.cpp	Sat Feb 16 00:44:38 2013 +0400
+++ b/Spells.cpp	Sat Feb 16 02:26:01 2013 +0400
@@ -107,202 +107,169 @@
 
 //----- (0045384A) --------------------------------------------------------
 void SpellStats::Initialize()
-{
-  SpellStats *v1; // esi@1
-  const char *v2; // ebp@3
-  char *v3; // edi@3
-  signed int v4; // ebx@4
-  char *v5; // esi@4
-  char v6; // cl@5
-  int v7; // eax@5
-  size_t v8; // ebp@40
-  int v9; // eax@41
-  int v10; // eax@42
-  int v11; // eax@43
-  char *v12; // [sp+10h] [bp-10h]@3
-  signed int v13; // [sp+14h] [bp-Ch]@4
-  signed int v14; // [sp+18h] [bp-8h]@3
-  int v15; // [sp+1Ch] [bp-4h]@9
+	{
 
-  v1 = this;
+	int decode_step;
+	char* test_string;
+	bool break_loop;
+	unsigned char c;
+	unsigned int temp_str_len;
+	char* tmp_pos;
 
-  if ( pSpellsTXT_Raw )
-    pAllocator->FreeChunk(pSpellsTXT_Raw);
-  pSpellsTXT_Raw = NULL;
+	if ( pSpellsTXT_Raw )
+		pAllocator->FreeChunk(pSpellsTXT_Raw);
+	pSpellsTXT_Raw = NULL;
 
-  pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0);
-  strtok(pSpellsTXT_Raw, "\r");
-  strtok(NULL, "\r");
-  v14 = 1;
-  v12 = (char *)&pSpellDatas[1].field_10;
-  v3 = (char *)&v1->pInfos[1].uSchool;
-  do
-  {
-    v4 = 0;
-    v5 = strtok(0, v2) + 1;
-    v13 = 0;
-    do
-    {
-      v6 = *v5;
-      v7 = 0;
-      while ( v6 != 9 && v6 )
-      {
-        ++v7;
-        v6 = v5[v7];
-      }
-      v15 = (int)&v5[v7];
-      if ( !v5[v7] )
-        v13 = 1;
-      v5[v7] = 0;
-      if ( v7 )
-      {
-        switch ( v4 )
-        {
-          case 2:
-            *((char **)v3 - 7) = RemoveQuotes(v5);
-            break;
-          case 3:
-            *v3 = 4;
-            if ( _strcmpi("fire", v5) )
-            {
-              if ( _strcmpi("air", v5) )
-              {
-                if ( _strcmpi("water", v5) )
-                {
-                  if ( _strcmpi("earth", v5) )
-                  {
-                    if ( _strcmpi("spirit", v5) )
-                    {
-                      if ( _strcmpi("mind", v5) )
-                      {
-                        if ( _strcmpi("body", v5) )
-                        {
-                          if ( _strcmpi("light", v5) )
-                          {
-                            if ( _strcmpi("dark", v5) )
-                            {
-                              if ( !_strcmpi("magic", v5) )
-                                *v3 = 5;
-                            }
-                            else
-                            {
-                              *v3 = 10;
-                            }
-                          }
-                          else
-                          {
-                            *v3 = 9;
-                          }
-                        }
-                        else
-                        {
-                          *v3 = 8;
-                        }
-                      }
-                      else
-                      {
-                        *v3 = 7;
-                      }
-                    }
-                    else
-                    {
-                      *v3 = 6;
-                    }
-                  }
-                  else
-                  {
-                    *v3 = 3;
-                  }
-                }
-                else
-                {
-                  *v3 = 2;
-                }
-              }
-              else
-              {
-                *v3 = 1;
-              }
-            }
-            else
-            {
-              *v3 = 0;
-            }
-            break;
-          case 4:
-            *((char **)v3 - 6) = RemoveQuotes(v5);
-            break;
-          case 5:
-            *((char **)v3 - 5) = RemoveQuotes(v5);
-            break;
-          case 6:
-            *((char **)v3 - 4) = RemoveQuotes(v5);
-            break;
-          case 7:
-            *((char **)v3 - 3) = RemoveQuotes(v5);
-            break;
-          case 8:
-            *((char **)v3 - 2) = RemoveQuotes(v5);
-            break;
-          case 9:
-            *((char **)v3 - 1) = RemoveQuotes(v5);
-            break;
-          case 10:
-            v4 = 0;
-            v8 = strlen(v5);
-            if ( (signed int)v8 > 0 )
-            {
-              do
-              {
-                v9 = tolower((unsigned __int8)v5[v4]) - 99;
-                if ( v9 )
-                {
-                  v10 = v9 - 2;
-                  if ( v10 )
-                  {
-                    v11 = v10 - 8;
-                    if ( v11 )
-                    {
-                      if ( v11 == 11 )
-                        *v12 |= 8u;
-                    }
-                    else
-                    {
-                      *v12 |= 1u;
-                    }
-                  }
-                  else
-                  {
-                    *v12 |= 2u;
-                  }
-                }
-                else
-                {
-                  *v12 |= 4u;
-                }
-                ++v4;
-              }
-              while ( v4 < (signed int)v8 );
-            }
-            v2 = "\r";
-            break;
-          default:
-            break;
-        }
-      }
-      else
-      {
-        v13 = 1;
-      }
-      ++v4;
-      v5 = (char *)(v15 + 1);
-    }
-    while ( v4 - 1 <= 10 && !v13 );
-    if ( !(v14 % 11) )
-      strtok(0, v2);
-    v12 += 20;
-    ++v14;
-    v3 += 36;
-  }
-  while ( (signed int)v12 <= (signed int)&pSpellDatas[90].field_12 );
-}
\ No newline at end of file
+	pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0);
+	strtok(pSpellsTXT_Raw, "\r");
+	strtok(NULL, "\r");
+	v14 = 1;
+	for(int i=1; i<100; ++i) 
+		{
+		test_string=strtok(NULL, "\r")+1;
+		decode_step =0;
+		break_loop=false;
+		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)
+				{		
+				switch (decode_step)
+					{	
+				case 2:
+					pInfos[i].pName=RemoveQuotes(test_string);
+					break;
+				case 3:
+					pInfos[i].uSchool = 4;
+					if (!_strcmpi("fire", test_string) )
+						{
+						pInfos[i].uSchool =0;
+						break;
+						}
+					if ( !_strcmpi("air", test_string) )	
+						{
+						pInfos[i].uSchool = 1;
+						break;
+						}
+					if ( !_strcmpi("water", test_string))	
+						{
+						pInfos[i].uSchool = 2;
+						break;
+						}	
+					if ( !_strcmpi("earth", test_string))	
+						{
+						pInfos[i].uSchool = 3;
+						break;
+						}	
+					if ( !_strcmpi("spirit", test_string))	
+						{
+						pInfos[i].uSchool = 6;
+						break;
+						}
+					if ( !_strcmpi("mind", test_string))	
+						{
+						pInfos[i].uSchool = 7;
+						break;
+						}
+					if ( !_strcmpi("body", test_string) )	
+						{
+						pInfos[i].uSchool = 8;
+						break;
+						}			
+					if ( !_strcmpi("light", test_string) )	
+						{
+						pInfos[i].uSchool = 9;
+						break;
+						}					
+					if ( !_strcmpi("dark", test_string))	
+						{
+						pInfos[i].uSchool = 10;
+						break;
+						}					
+
+					if ( !_strcmpi("magic", test_string))	
+						{
+						pInfos[i].uSchool = 5;
+						break;
+						}								
+
+					break;
+				case 4:
+					pInfos[i].pShortName=RemoveQuotes(test_string);
+					break;
+				case 5:
+					pInfos[i].pDescription=RemoveQuotes(test_string);
+					break;
+				case 6:
+					pInfos[i].pBasicSkillDesc=RemoveQuotes(test_string);
+					break;
+				case 7:
+					pInfos[i].pExpertSkillDesc=RemoveQuotes(test_string);
+					break;
+				case 8:
+					pInfos[i].pMasterSkillDesc=RemoveQuotes(test_string);
+					break;
+				case 9:
+					pInfos[i].pGrandmasterSkillDesc=RemoveQuotes(test_string);
+					break;
+				case 10:
+					int in_string_pos=0;
+					int in_str_len=strlen(test_string);
+					/*v4 = 0; fix_me
+					v8 = strlen(v5);
+					if ( (signed int)v8 > 0 )
+					{
+					do
+					{
+					v9 = tolower((unsigned __int8)v5[v4]) - 99;
+					if ( v9 )
+					{
+					v10 = v9 - 2;
+					if ( v10 )
+					{
+					v11 = v10 - 8;
+					if ( v11 )
+					{
+					if ( v11 == 11 )
+					*v12 |= 8u;
+					}
+					else
+					{
+					*v12 |= 1u;
+					}
+					}
+					else
+					{
+					*v12 |= 2u;
+					}
+					}
+					else
+					{
+					*v12 |= 4u;
+					}
+					++v4;
+					}
+					while ( v4 < (signed int)v8 );*/
+					break;
+					}
+				}
+			else
+				break_loop=true;
+			++decode_step;
+			test_string=tmp_pos+1;	
+			} while ((decode_step<11)&&!break_loop);
+			if ((i%11)==0)
+				strtok(NULL, "\r");
+		}
+
+	}
\ No newline at end of file