comparison mm7_3.cpp @ 263:8cf4fe6b4941

Слияние
author Ritor1
date Mon, 18 Feb 2013 12:38:38 +0600
parents c3bfe1eb3de7 96f3a1177b37
children 006188b68143
comparison
equal deleted inserted replaced
262:2d6dda2e0405 263:8cf4fe6b4941
4701 --uNumActions; 4701 --uNumActions;
4702 4702
4703 return result; 4703 return result;
4704 } 4704 }
4705 4705
4706 //----- (00476387) -------------------------------------------------------- 4706
4707 bool PartyHasDragon() 4707
4708 { 4708
4709 return pNPCStats->pNewNPCData[57].Hired();
4710 }
4711
4712 //----- (00476395) --------------------------------------------------------
4713 //0x26 Wizard eye at skill level 2
4714 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
4715 {
4716 bool result; // eax@2
4717 signed int v2; // esi@3
4718 char *v3; // eax@4
4719
4720 if ( bNoNPCHiring == 1 )
4721 return 0;
4722 v2 = 0;
4723 if ( (signed int)pNPCStats->uNumNewNPCs <= 0 )
4724 {
4725 LABEL_8:
4726 result = 0;
4727 if ( pParty->pHirelings[0].uProfession != uProfession )
4728 {
4729 LOBYTE(result) = pParty->pHirelings[1].uProfession == uProfession;
4730 return result;
4731 }
4732 }
4733 else
4734 {
4735 v3 = (char *)&pNPCStats->pNewNPCData[0].uFlags;
4736 while ( *((int *)v3 + 4) != uProfession || !(*v3 & 0x80) )
4737 {
4738 ++v2;
4739 v3 += 76;
4740 if ( v2 >= (signed int)pNPCStats->uNumNewNPCs )
4741 goto LABEL_8;
4742 }
4743 result = 0;
4744 }
4745 ++result;
4746 return result;
4747 }
4748 // 6BE3C5: using guessed type char bNoNPCHiring;
4749
4750 //----- (004763E0) --------------------------------------------------------
4751 void InitializeAwards()
4752 {
4753
4754 int i;
4755 char* test_string;
4756 unsigned char c;
4757 bool break_loop;
4758 unsigned int temp_str_len;
4759 char* tmp_pos;
4760 int decode_step;
4761 int item_counter;
4762
4763 if ( pAwardsTXT_Raw )
4764 pAllocator->FreeChunk(pAwardsTXT_Raw);
4765 pAwardsTXT_Raw = NULL;
4766 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
4767 strtok(pAwardsTXT_Raw, "\r");
4768
4769 for (i=1; i<104; ++i)
4770 {
4771 test_string = strtok(NULL, "\r") + 1;
4772 break_loop = false;
4773 decode_step=0;
4774 do
4775 {
4776 c = *(unsigned char*)test_string;
4777 temp_str_len = 0;
4778 while((c!='\t')&&(c>0))
4779 {
4780 ++temp_str_len;
4781 c=test_string[temp_str_len];
4782 }
4783 tmp_pos=test_string+temp_str_len;
4784 if (*tmp_pos == 0)
4785 break_loop = true;
4786 *tmp_pos = 0;
4787 if (temp_str_len)
4788 {
4789 if (decode_step==1)
4790 pAwards[i].pText=RemoveQuotes(test_string);
4791 else if (decode_step==2)
4792 pAwards[i].uSort=atoi(test_string);
4793 }
4794 else
4795 {
4796 break_loop = true;
4797 }
4798 ++decode_step;
4799 test_string=tmp_pos+1;
4800 } while ((decode_step<3)&&!break_loop);
4801 }
4802
4803 }
4804 // 7241C8: using guessed type int dword_7241C8;
4805
4806 //----- (004764C2) --------------------------------------------------------
4807 void InitializeScrolls()
4808 {
4809
4810 int i;
4811 char* test_string;
4812 unsigned char c;
4813 bool break_loop;
4814 unsigned int temp_str_len;
4815 char* tmp_pos;
4816 int decode_step;
4817 int item_counter;
4818
4819 if ( pScrollsTXT_Raw )
4820 pAllocator->FreeChunk(pScrollsTXT_Raw);
4821 pScrollsTXT_Raw = NULL;
4822 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
4823 strtok(pScrollsTXT_Raw, "\r");
4824 for (i=0; i<82; ++i)
4825 {
4826 test_string = strtok(NULL, "\r") + 1;
4827 break_loop = false;
4828 decode_step=0;
4829 do
4830 {
4831 c = *(unsigned char*)test_string;
4832 temp_str_len = 0;
4833 while((c!='\t')&&(c>0))
4834 {
4835 ++temp_str_len;
4836 c=test_string[temp_str_len];
4837 }
4838 tmp_pos=test_string+temp_str_len;
4839 if (*tmp_pos == 0)
4840 break_loop = true;
4841 *tmp_pos = 0;
4842 if (temp_str_len)
4843 {
4844 if ( decode_step == 1)
4845 pScrolls[i]=RemoveQuotes(test_string);
4846 }
4847 else
4848 {
4849 break_loop = true;
4850 }
4851 ++decode_step;
4852 test_string=tmp_pos+1;
4853 } while ((decode_step<2)&&!break_loop);
4854 }
4855 }
4856
4857
4858 //----- (00476590) --------------------------------------------------------
4859 void InitializeMerchants()
4860 {
4861 int i;
4862 char* test_string;
4863 unsigned char c;
4864 bool break_loop;
4865 unsigned int temp_str_len;
4866 char* tmp_pos;
4867 int decode_step;
4868 int item_counter;
4869
4870 if ( pMerchantsTXT_Raw )
4871 pAllocator->FreeChunk(pMerchantsTXT_Raw);
4872 pMerchantsTXT_Raw = NULL;
4873 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
4874 strtok(pMerchantsTXT_Raw, "\r");
4875
4876 for (i=0; i<7; ++i)
4877 {
4878 test_string = strtok(NULL, "\r") + 1;
4879 break_loop = false;
4880 decode_step=0;
4881 do
4882 {
4883 c = *(unsigned char*)test_string;
4884 temp_str_len = 0;
4885 while((c!='\t')&&(c>0))
4886 {
4887 ++temp_str_len;
4888 c=test_string[temp_str_len];
4889 }
4890 tmp_pos=test_string+temp_str_len;
4891 if (*tmp_pos == 0)
4892 break_loop = true;
4893 *tmp_pos = 0;
4894 if (temp_str_len)
4895 {
4896 switch (decode_step)
4897 {
4898 case 1:
4899 pMerchantsBuyPhrases[i]=RemoveQuotes(test_string);
4900 break;
4901 case 2:
4902 pMerchantsSellPhrases[i]=RemoveQuotes(test_string);
4903 break;
4904 case 3:
4905 pMerchantsRepairPhrases[i]=RemoveQuotes(test_string);
4906 break;
4907 case 4:
4908 pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string);
4909 break;
4910 }
4911 }
4912 else
4913 {
4914 break_loop = true;
4915 }
4916 ++decode_step;
4917 test_string=tmp_pos+1;
4918 } while ((decode_step<5)&&!break_loop);
4919 }
4920
4921 }
4922
4923 //----- (00476682) --------------------------------------------------------
4924 void InitializeTransitions()
4925 {
4926 int i;
4927 char* test_string;
4928 unsigned char c;
4929 bool break_loop;
4930 unsigned int temp_str_len;
4931 char* tmp_pos;
4932 int decode_step;
4933 int item_counter;
4934
4935 if ( pTransitionsTXT_Raw )
4936 pAllocator->FreeChunk(pTransitionsTXT_Raw);
4937 pTransitionsTXT_Raw = NULL;
4938 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
4939 strtok(pTransitionsTXT_Raw, "\r");
4940
4941 for (i=0; i<464; ++i)
4942 {
4943 test_string = strtok(NULL, "\r") + 1;
4944 break_loop = false;
4945 decode_step=0;
4946 do
4947 {
4948 c = *(unsigned char*)test_string;
4949 temp_str_len = 0;
4950 while((c!='\t')&&(c>0))
4951 {
4952 ++temp_str_len;
4953 c=test_string[temp_str_len];
4954 }
4955 tmp_pos=test_string+temp_str_len;
4956 if (*tmp_pos == 0)
4957 break_loop = true;
4958 *tmp_pos = 0;
4959 if (temp_str_len)
4960 {
4961 if ( decode_step == 1)
4962 pTransitionStrings[i]=RemoveQuotes(test_string);
4963 }
4964 else
4965 {
4966 break_loop = true;
4967 }
4968 ++decode_step;
4969 test_string=tmp_pos+1;
4970 } while ((decode_step<2)&&!break_loop);
4971 }
4972 }
4973
4974 //----- (00476750) --------------------------------------------------------
4975 void __cdecl InitializeAutonotes()
4976 {
4977 int i;
4978 char* test_string;
4979 unsigned char c;
4980 bool break_loop;
4981 unsigned int temp_str_len;
4982 char* tmp_pos;
4983 int decode_step;
4984 int item_counter;
4985
4986 if ( pAutonoteTXT_Raw )
4987 pAllocator->FreeChunk(pAutonoteTXT_Raw);
4988 pAutonoteTXT_Raw = 0;
4989 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
4990 strtok(pAutonoteTXT_Raw, "\r");
4991
4992 for (i=0; i<195; ++i)
4993 {
4994 test_string = strtok(NULL, "\r") + 1;
4995 break_loop = false;
4996 decode_step=0;
4997 do
4998 {
4999 c = *(unsigned char*)test_string;
5000 temp_str_len = 0;
5001 while((c!='\t')&&(c>0))
5002 {
5003 ++temp_str_len;
5004 c=test_string[temp_str_len];
5005 }
5006 tmp_pos=test_string+temp_str_len;
5007 if (*tmp_pos == 0)
5008 break_loop = true;
5009 *tmp_pos = 0;
5010 if (temp_str_len)
5011 {
5012 switch (decode_step)
5013 {
5014 case 1:
5015 pAutonoteTxt[i].pText=RemoveQuotes(test_string);
5016 break;
5017 case 2:
5018 {
5019 if ( !_strcmpi(test_string, "potion"))
5020 {
5021 pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
5022 break;
5023 }
5024 if ( !_strcmpi(test_string, "stat") )
5025 {
5026 pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
5027 break;
5028 }
5029 if ( !_strcmpi(test_string, "seer") )
5030 {
5031 pAutonoteTxt[i].eType = AUTONOTE_SEER;
5032 break;
5033 }
5034 if ( !_strcmpi(test_string, "obelisk") )
5035 {
5036 pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
5037 break;
5038 }
5039 if ( !_strcmpi(test_string, "teacher") )
5040 {
5041 pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
5042 break;
5043 }
5044 pAutonoteTxt[i].eType =AUTONOTE_MISC;
5045 break;
5046 }
5047 }
5048 }
5049 else
5050 {
5051 break_loop = true;
5052 }
5053 ++decode_step;
5054 test_string=tmp_pos+1;
5055 } while ((decode_step<3)&&!break_loop);
5056 }
5057 }
5058
5059
5060 //----- (004768A9) --------------------------------------------------------
5061 void __cdecl InitializeQuests()
5062 {
5063 int i;
5064 char* test_string;
5065 unsigned char c;
5066 bool break_loop;
5067 unsigned int temp_str_len;
5068 char* tmp_pos;
5069 int decode_step;
5070 int item_counter;
5071
5072 if ( pQuestsTXT_Raw )
5073 pAllocator->FreeChunk(pQuestsTXT_Raw);
5074 pQuestsTXT_Raw = NULL;
5075 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
5076 strtok(pQuestsTXT_Raw, "\r");
5077
5078 for (i=0; i<512; ++i)
5079 {
5080 test_string = strtok(NULL, "\r") + 1;
5081 break_loop = false;
5082 decode_step=0;
5083 do
5084 {
5085 c = *(unsigned char*)test_string;
5086 temp_str_len = 0;
5087 while((c!='\t')&&(c>0))
5088 {
5089 ++temp_str_len;
5090 c=test_string[temp_str_len];
5091 }
5092 tmp_pos=test_string+temp_str_len;
5093 if (*tmp_pos == 0)
5094 break_loop = true;
5095 *tmp_pos = 0;
5096 if (temp_str_len)
5097 {
5098 if ( decode_step == 1)
5099 pQuestTable[i] =RemoveQuotes(test_string);
5100 }
5101 else
5102 {
5103 break_loop = true;
5104 }
5105 ++decode_step;
5106 test_string=tmp_pos+1;
5107 } while ((decode_step<2)&&!break_loop);
5108 }
5109 }
5110
5111
5112
5113 //----- (00476977) --------------------------------------------------------
5114 void NPCStats::Initialize2()
5115 {
5116 int i;
5117 char* test_string;
5118 unsigned char c;
5119 bool break_loop;
5120 unsigned int temp_str_len;
5121 char* tmp_pos;
5122 int decode_step;
5123 int item_counter;
5124
5125
5126 if (pNPCTextTXT_Raw)
5127 pAllocator->FreeChunk(pNPCTextTXT_Raw);
5128 pNPCTextTXT_Raw =NULL;
5129 pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0);
5130 strtok(pNPCTextTXT_Raw, "\r");
5131
5132 for (i=0; i<789; ++i)
5133 {
5134 test_string = strtok(NULL, "\r") + 1;
5135 break_loop = false;
5136 decode_step=0;
5137 do
5138 {
5139 c = *(unsigned char*)test_string;
5140 temp_str_len = 0;
5141 while((c!='\t')&&(c>0))
5142 {
5143 ++temp_str_len;
5144 c=test_string[temp_str_len];
5145 }
5146 tmp_pos=test_string+temp_str_len;
5147 if (*tmp_pos == 0)
5148 break_loop = true;
5149 *tmp_pos = 0;
5150 if (temp_str_len)
5151 {
5152 if ( decode_step == 1)
5153 pNPCTopics[i].pText =RemoveQuotes(test_string);
5154 }
5155 else
5156 {
5157 break_loop = true;
5158 }
5159 ++decode_step;
5160 test_string=tmp_pos+1;
5161 } while ((decode_step<2)&&!break_loop);
5162 }
5163
5164 if (pNPCTopicTXT_Raw)
5165 pAllocator->FreeChunk(pNPCTopicTXT_Raw);
5166 pNPCTopicTXT_Raw =NULL;
5167 pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0);
5168 strtok(pNPCTopicTXT_Raw, "\r");
5169
5170 for (i=0; i<579; ++i)
5171 {
5172 test_string = strtok(NULL, "\r") + 1;
5173 break_loop = false;
5174 decode_step=0;
5175 do
5176 {
5177 c = *(unsigned char*)test_string;
5178 temp_str_len = 0;
5179 while((c!='\t')&&(c>0))
5180 {
5181 ++temp_str_len;
5182 c=test_string[temp_str_len];
5183 }
5184 tmp_pos=test_string+temp_str_len;
5185 if (*tmp_pos == 0)
5186 break_loop = true;
5187 *tmp_pos = 0;
5188 if (temp_str_len)
5189 {
5190 if ( decode_step == 1)
5191 pNPCTopics[i].pTopic = RemoveQuotes(test_string);
5192 }
5193 else
5194 {
5195 break_loop = true;
5196 }
5197 ++decode_step;
5198 test_string=tmp_pos+1;
5199 } while ((decode_step<2)&&!break_loop);
5200 }
5201
5202 if (pNPCDistTXT_Raw)
5203 pAllocator->FreeChunk(pNPCDistTXT_Raw);
5204 pNPCDistTXT_Raw = NULL;
5205 pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0);
5206 strtok(pNPCDistTXT_Raw, "\r");
5207 strtok(NULL, "\r");
5208
5209 for (i=1; i<59; ++i)
5210 {
5211 test_string = strtok(NULL, "\r") + 1;
5212 break_loop = false;
5213 decode_step=0;
5214 do
5215 {
5216 c = *(unsigned char*)test_string;
5217 temp_str_len = 0;
5218 while((c!='\t')&&(c>0))
5219 {
5220 ++temp_str_len;
5221 c=test_string[temp_str_len];
5222 }
5223 tmp_pos=test_string+temp_str_len;
5224 if (*tmp_pos == 0)
5225 break_loop = true;
5226 *tmp_pos = 0;
5227 if (temp_str_len)
5228 {
5229 if ((decode_step>0)&&(decode_step<77))
5230 {
5231 array_16544[decode_step].field_4[i]=atoi(test_string);
5232 }
5233 else if (decode_step==0)
5234 {
5235 array_16544[0].field_4[i]=10;
5236 }
5237 }
5238 else
5239 {
5240 break_loop = true;
5241 }
5242 ++decode_step;
5243 test_string=tmp_pos+1;
5244 } while ((decode_step<78)&&!break_loop);
5245 }
5246
5247 for (i=0; i<78; ++i)
5248 {
5249 array_16544[i].field_0=0;
5250 for (int ii=1; ii<59; ++ii)
5251 {
5252 array_16544[i].field_0+=array_16544[i].field_4[ii];
5253 }
5254 }
5255
5256 if (pNPCDistTXT_Raw)
5257 {
5258 pAllocator->FreeChunk(pNPCDistTXT_Raw);
5259 pNPCDistTXT_Raw = NULL;
5260 }
5261 }
5262
5263 //----- (00476C60) --------------------------------------------------------
5264 void NPCStats::_476C60()
5265 {
5266 for (uint i = 1; i < uNumNewNPCs; ++i)
5267 pNewNPCData[i].pName = pNPCNames2[i - 1];
5268
5269 if (pParty->pHirelings[0].pName)
5270 pParty->pHirelings[0].pName = pParty->pHireling1Name;
5271 if (pParty->pHirelings[1].pName)
5272 pParty->pHirelings[1].pName = pParty->pHireling2Name;
5273 }
5274
5275 //----- (00476CB5) --------------------------------------------------------
5276 void NPCStats::Initialize1()
5277 {
5278 NPCStats *pNPCStats; // esi@1
5279 char *pRaw; // eax@1
5280 char *pHouse; // edi@1
5281 char *v4; // eax@2
5282 char v5; // dl@3
5283 int v6; // ecx@3
5284 char *v7; // eax@11
5285 char *v8; // eax@26
5286 char *v9; // ecx@27
5287 char v10; // dl@28
5288 int v11; // eax@28
5289 int v12; // edi@32
5290 char *v13; // eax@42
5291 char *v14; // eax@43
5292 char v15; // dl@44
5293 int v16; // ecx@44
5294 int v17; // edi@48
5295 char *v18; // eax@56
5296 char *v19; // eax@57
5297 char v20; // cl@58
5298 int v21; // edi@58
5299 int v22; // esi@62
5300 int v23; // [sp+Ch] [bp-14h]@7
5301 signed int v24; // [sp+10h] [bp-10h]@1
5302 signed int v25; // [sp+10h] [bp-10h]@26
5303 signed int v26; // [sp+10h] [bp-10h]@42
5304 signed int v27; // [sp+10h] [bp-10h]@56
5305 char *Str; // [sp+14h] [bp-Ch]@1
5306 NPCGreeting *pGreetings; // [sp+14h] [bp-Ch]@26
5307 unsigned __int16 *pGroups; // [sp+14h] [bp-Ch]@42
5308 char **pCatchPhrase; // [sp+14h] [bp-Ch]@56
5309 signed int v32; // [sp+18h] [bp-8h]@2
5310 signed int v33; // [sp+18h] [bp-8h]@27
5311 signed int v34; // [sp+18h] [bp-8h]@43
5312 signed int v35; // [sp+18h] [bp-8h]@57
5313 signed int v36; // [sp+1Ch] [bp-4h]@2
5314 signed int v37; // [sp+1Ch] [bp-4h]@27
5315 signed int v38; // [sp+1Ch] [bp-4h]@43
5316 signed int v39; // [sp+1Ch] [bp-4h]@57
5317
5318 pNPCStats = this;
5319 pRaw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0);
5320 pNPCStats->pNPCDataTXT_Raw = pRaw;
5321 strtok(pRaw, "\r");
5322 strtok(0, "\r");
5323 pHouse = (char *)&pNPCStats->pNPCData[1].house;
5324 Str = (char *)pNPCStats->pNPCNames2;
5325 v24 = 500;
5326 do
5327 {
5328 v32 = 0;
5329 v4 = strtok(0, "\r") + 1;
5330 v36 = -1;
5331 do
5332 {
5333 v5 = *v4;
5334 v6 = 0;
5335 while ( v5 != 9 && v5 )
5336 {
5337 ++v6;
5338 v5 = v4[v6];
5339 }
5340 v23 = (int)&v4[v6];
5341 if ( !v4[v6] )
5342 v32 = 1;
5343 v4[v6] = 0;
5344 if ( v6 )
5345 {
5346 switch ( v36 )
5347 {
5348 case 0:
5349 v7 = RemoveQuotes(v4);
5350 *((int *)pHouse - 5) = (int)v7;
5351 *(int *)Str = (int)v7;
5352 break;
5353 case 1:
5354 *((int *)pHouse - 4) = atoi(v4);
5355 break;
5356 case 5:
5357 *(int *)pHouse = atoi(v4);
5358 break;
5359 case 6:
5360 *((int *)pHouse + 1) = atoi(v4);
5361 break;
5362 case 7:
5363 *((int *)pHouse + 2) = atoi(v4);
5364 break;
5365 case 8:
5366 *((int *)pHouse + 3) = *v4 == 121;
5367 break;
5368 case 9:
5369 *((int *)pHouse + 5) = atoi(v4);
5370 break;
5371 case 10:
5372 *((int *)pHouse + 6) = atoi(v4);
5373 break;
5374 case 11:
5375 *((int *)pHouse + 7) = atoi(v4);
5376 break;
5377 case 12:
5378 *((int *)pHouse + 8) = atoi(v4);
5379 break;
5380 case 13:
5381 *((int *)pHouse + 9) = atoi(v4);
5382 break;
5383 case 14:
5384 *((int *)pHouse + 10) = atoi(v4);
5385 break;
5386 default:
5387 break;
5388 }
5389 }
5390 ++v36;
5391 v4 = (char *)(v23 + 1);
5392 }
5393 while ( v36 + 1 <= 15 && !v32 );
5394 Str += 4;
5395 pHouse += 76;
5396 --v24;
5397 }
5398 while ( v24 );
5399 pNPCStats->uNumNewNPCs = 501;
5400 v8 = (char *)pEvents_LOD->LoadRaw("npcgreet.txt", 0);
5401 pNPCStats->pNPCGreetTXT_Raw = v8;
5402 strtok(v8, "\r");
5403 pGreetings = pNPCStats->pNPCGreetings;
5404 v25 = 205;
5405 do
5406 {
5407 v37 = 0;
5408 v33 = 0;
5409 v9 = strtok(0, "\r") + 1;
5410 do
5411 {
5412 v10 = *v9;
5413 v11 = 0;
5414 while ( v10 != 9 && v10 )
5415 {
5416 ++v11;
5417 v10 = v9[v11];
5418 }
5419 v12 = (int)&v9[v11];
5420 if ( !v9[v11] )
5421 v33 = 1;
5422 *(char *)v12 = 0;
5423 if ( v11 )
5424 {
5425 if ( v37 == 1 )
5426 {
5427 pGreetings->pGreeting1 = (char *)RemoveQuotes(v9);
5428 }
5429 else
5430 {
5431 if ( v37 == 2 )
5432 pGreetings->pGreeting2 = (char *)RemoveQuotes(v9);
5433 }
5434 }
5435 ++v37;
5436 v9 = (char *)(v12 + 1);
5437 }
5438 while ( v37 <= 2 && !v33 );
5439 ++pGreetings;
5440 --v25;
5441 }
5442 while ( v25 );
5443 v13 = (char *)pEvents_LOD->LoadRaw("npcgroup.txt", 0);
5444 pNPCStats->pNCPGroupTXT_Raw = v13;
5445 strtok(v13, "\r");
5446 pGroups = pNPCStats->pGroups;
5447 v26 = 51;
5448 do
5449 {
5450 v14 = strtok(0, "\r") + 1;
5451 v38 = 0;
5452 v34 = 0;
5453 do
5454 {
5455 v15 = *v14;
5456 v16 = 0;
5457 while ( v15 != 9 && v15 )
5458 {
5459 ++v16;
5460 v15 = v14[v16];
5461 }
5462 v17 = (int)&v14[v16];
5463 if ( !v14[v16] )
5464 v34 = 1;
5465 *(char *)v17 = 0;
5466 if ( v16 && v38 == 1 )
5467 *pGroups = atoi(v14);
5468 ++v38;
5469 v14 = (char *)(v17 + 1);
5470 }
5471 while ( v38 <= 1 && !v34 );
5472 ++pGroups;
5473 --v26;
5474 }
5475 while ( v26 );
5476 v18 = (char *)pEvents_LOD->LoadRaw("npcnews.txt", 0);
5477 pNPCStats->pNPCNewsTXT_Raw = v18;
5478 strtok(v18, "\r");
5479 pCatchPhrase = pNPCStats->pCatchPhrases;
5480 v27 = 51;
5481 do
5482 {
5483 v19 = strtok(0, "\r") + 1;
5484 v39 = 0;
5485 v35 = 0;
5486 do
5487 {
5488 v20 = *v19;
5489 v21 = 0;
5490 while ( v20 != 9 && v20 )
5491 {
5492 ++v21;
5493 v20 = v19[v21];
5494 }
5495 v22 = (int)&v19[v21];
5496 if ( !v19[v21] )
5497 v35 = 1;
5498 *(char *)v22 = 0;
5499 if ( v21 && v39 == 1 )
5500 *pCatchPhrase = (char *)RemoveQuotes(v19);
5501 ++v39;
5502 v19 = (char *)(v22 + 1);
5503 }
5504 while ( v39 <= 1 && !v35 );
5505 ++pCatchPhrase;
5506 --v27;
5507 }
5508 while ( v27 );
5509 }
5510
5511 //----- (0047702F) --------------------------------------------------------
5512 void NPCStats::Initialize()
5513 {
5514 //NPCStats *v1; // edi@1
5515 char *v2; // ebx@1
5516 //char *v3; // eax@1
5517 char *v4; // ebx@3
5518 char v5; // al@4
5519 int v6; // ecx@4
5520 //char *v7; // eax@18
5521 char *v8; // ebx@18
5522 char *v9; // ecx@19
5523 char v10; // dl@20
5524 int v11; // eax@20
5525 char v12; // zf@41
5526 signed int v13; // [sp+Ch] [bp-14h]@18
5527 int v14; // [sp+10h] [bp-10h]@4
5528 int v15; // [sp+10h] [bp-10h]@24
5529 char *v16; // [sp+14h] [bp-Ch]@1
5530 signed int v17; // [sp+14h] [bp-Ch]@19
5531 unsigned int v18; // [sp+18h] [bp-8h]@1
5532 char *v19; // [sp+18h] [bp-8h]@18
5533 signed int v20; // [sp+1Ch] [bp-4h]@3
5534 signed int v21; // [sp+1Ch] [bp-4h]@19
5535 //v1 = this;
5536
5537 Initialize1();
5538 Initialize2();
5539
5540 InitializeQuests();
5541 InitializeAutonotes();
5542 InitializeAwards();
5543 InitializeTransitions();
5544 InitializeMerchants();
5545 InitializeScrolls();
5546 v2 = 0;
5547 field_17FC0 = 0;
5548 pNPCNamesTXT_Raw = 0;
5549 //v3 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
5550 pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0);
5551 strtok(pNPCNamesTXT_Raw, "\r");
5552 v18 = 0;
5553 v16 = (char *)pNPCNames;
5554 while ( 1 )
5555 {
5556 v4 = strtok(v2, "\r") + 1;
5557 v20 = 0;
5558 do
5559 {
5560 v5 = *v4;
5561 v6 = 0;
5562 v14 = 0;
5563 if ( *v4 == 9 )
5564 goto LABEL_45;
5565 do
5566 {
5567 if ( !v5 )
5568 break;
5569 if ( v5 == 10 )
5570 break;
5571 ++v6;
5572 v14 = v6;
5573 v5 = v4[v6];
5574 }
5575 while ( v5 != 9 );
5576 if ( v6 )
5577 {
5578 v4[v6] = 0;
5579 if ( v20 )
5580 {
5581 if ( v20 == 1 )
5582 *((int *)v16 + 1) = (int)RemoveQuotes(v4);
5583 }
5584 else
5585 {
5586 *(int *)v16 = (int)RemoveQuotes(v4);
5587 }
5588 }
5589 else
5590 {
5591 LABEL_45:
5592 if ( v20 == 1 && !uNumNPCNames[1] )
5593 uNumNPCNames[1] = v18;
5594 }
5595 ++v20;
5596 v4 += v14 + 1;
5597 }
5598 while ( v20 <= 1 );
5599 ++v18;
5600 v16 += 8;
5601 if ( (signed int)v18 >= 540 )
5602 break;
5603 v2 = 0;
5604 }
5605 pNPCProfTXT_Raw = 0;
5606 uNumNPCNames[0] = v18;
5607 //v7 = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
5608 pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0);
5609 strtok(pNPCProfTXT_Raw, "\r");
5610 strtok(0, "\r");
5611 strtok(0, "\r");
5612 strtok(0, "\r");
5613 v8 = (char *)&pProfessions[0].pJoinText;
5614 v19 = (char *)&pProfessions[0].pJoinText;
5615 v13 = 58;
5616 do
5617 {
5618 v21 = 0;
5619 v9 = strtok(0, "\r") + 1;
5620 v17 = 0;
5621 do
5622 {
5623 v10 = *v9;
5624 v11 = 0;
5625 if ( *v9 != 9 )
5626 {
5627 do
5628 {
5629 if ( !v10 )
5630 break;
5631 ++v11;
5632 v10 = v9[v11];
5633 }
5634 while ( v10 != 9 );
5635 v8 = v19;
5636 }
5637 v15 = (int)&v9[v11];
5638 if ( !v9[v11] )
5639 v17 = 1;
5640 *(char *)v15 = 0;
5641 if ( v11 )
5642 {
5643 switch ( v21 )
5644 {
5645 case 2:
5646 *((int *)v8 - 3) = atoi(v9);
5647 break;
5648 case 3:
5649 *((int *)v8 - 1) = (int)RemoveQuotes(v9);
5650 break;
5651 case 4:
5652 *((int *)v8 - 2) = (int)RemoveQuotes(v9);
5653 break;
5654 case 5:
5655 *(int *)v8 = (int)RemoveQuotes(v9);
5656 break;
5657 case 6:
5658 *((int *)v8 + 1) = (int)RemoveQuotes(v9);
5659 break;
5660 }
5661 }
5662 else
5663 {
5664 if ( !v21 )
5665 v17 = 1;
5666 }
5667 ++v21;
5668 v9 = (char *)(v15 + 1);
5669 }
5670 while ( v21 <= 6 && !v17 );
5671 v8 += 20;
5672 v12 = v13-- == 1;
5673 v19 = v8;
5674 }
5675 while ( !v12 );
5676 uNumNPCProfessions = 59;
5677 }
5678
5679 //----- (00477266) --------------------------------------------------------
5680 void NPCStats::Release()
5681 {
5682 NPCStats *v1; // esi@1
5683 void *v2; // ST00_4@1
5684 int v3; // ebx@1
5685
5686 v1 = this;
5687 pAllocator->FreeChunk(this->pNPCTopicTXT_Raw);
5688 v2 = v1->pNPCTextTXT_Raw;
5689 v1->pNPCNewsTXT_Raw = 0;
5690 pAllocator->FreeChunk(v2);
5691 v1->pNPCNewsTXT_Raw = 0;
5692 pAllocator->FreeChunk(0);
5693 v1->pNPCNewsTXT_Raw = 0;
5694 pAllocator->FreeChunk(v1->pNPCProfTXT_Raw);
5695 v1->pNPCProfTXT_Raw = 0;
5696 pAllocator->FreeChunk(v1->pNPCNamesTXT_Raw);
5697 v1->pNPCNamesTXT_Raw = 0;
5698 pAllocator->FreeChunk(v1->pNPCDataTXT_Raw);
5699 v1->pNPCDataTXT_Raw = 0;
5700 pAllocator->FreeChunk(v1->pNPCDistTXT_Raw);
5701 v1->pNPCDistTXT_Raw = 0;
5702 v3 = (int)&v1->pNPCGreetTXT_Raw;
5703 pAllocator->FreeChunk(v1->pNPCGreetTXT_Raw);
5704 v1 = (NPCStats *)((char *)v1 + 98296);
5705 *(int *)v3 = 0;
5706 pAllocator->FreeChunk(v1->pNPCData[0].pName);
5707 v1->pNPCData[0].pName = 0;
5708 }
5709
5710 //----- (0047730C) --------------------------------------------------------
5711 int __fastcall const_1(int a1, int)
5712 {
5713 return 1;
5714 }
5715 // 47730C: using guessed type int __stdcall const_1(int);
5716
5717 //----- (0047732C) --------------------------------------------------------
5718 bool NPCStats::InitializeAdditionalNPCs(NPCData *a2, int a3, int a4, int a5)
5719 {
5720 //NPCStats *v5; // ebx@1
5721 signed __int64 v6; // qax@1
5722 int v7; // esi@1
5723 int v8; // edx@1
5724 NPCData *v9; // edi@1
5725 int v10; // eax@1
5726 //int v11; // eax@23
5727 int v12; // ecx@23
5728 int v13; // edx@28
5729 int v14; // esi@37
5730 int v15; // edx@37
5731 int v16; // ecx@37
5732 int v17; // eax@37
5733 int v18; // edx@37
5734 signed int result; // eax@39
5735 int v20; // [sp+Ch] [bp-Ch]@1
5736 signed int v21; // [sp+10h] [bp-8h]@1
5737 signed int v22; // [sp+14h] [bp-4h]@1
5738 int v23; // [sp+24h] [bp+Ch]@1
5739
5740
5741 v23 = a3 - 1;
5742 //v5 = this;
5743 v6 = (signed __int64)((double)v23 * -0.33333334);
5744 v7 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 28];
5745 v20 = (unsigned __int8)byte_4E8394[-(_DWORD)v6 + 116];
5746 v8 = rand() % uNumNPCNames[v7];
5747 v9 = a2;
5748 a2->uSex = v7;
5749 a2->pName = pNPCNames[v8][v7];
5750 v10 = 0;
5751 v22 = 0;
5752 v21 = 0;
5753
5754 while ( 1 )
5755 {
5756 if ( v20 == v10 )
5757 {
5758 if ( v7 == v10 )
5759 {
5760 v23 = 2;
5761 a2 = (NPCData *)100;
5762 }
5763 else
5764 {
5765 if ( v7 - v10 == 1 )
5766 {
5767 v23 = 201;
5768 a2 = (NPCData *)250;
5769 }
5770 }
5771 }
5772 else
5773 {
5774 switch ( v20 - v10 )
5775 {
5776 case 1:
5777 if ( v7 == v10 )
5778 {
5779 v23 = 400;
5780 a2 = (NPCData *)430;
5781 }
5782 else
5783 {
5784 if ( v7 - v10 == 1 )
5785 {
5786 v23 = 460;
5787 a2 = (NPCData *)490;
5788 }
5789 }
5790 break;
5791 case 2:
5792 if ( v7 == v10 )
5793 {
5794 v23 = 500;
5795 a2 = (NPCData *)520;
5796 }
5797 else
5798 {
5799 if ( v7 - v10 == 1 )
5800 {
5801 v23 = 530;
5802 a2 = (NPCData *)550;
5803 }
5804 }
5805 break;
5806 case 3:
5807 if ( v7 == v10 )
5808 {
5809 v23 = 300;
5810 a2 = (NPCData *)330;
5811 }
5812 else
5813 {
5814 if ( v7 - v10 == 1 )
5815 {
5816 v23 = 360;
5817 a2 = (NPCData *)387;
5818 }
5819 }
5820 break;
5821 }
5822 }
5823 v12 = v23 + rand() % ((int)a2 - v23 + 1);
5824 if ( const_1(v12, v7) == 1 )
5825 v21 = 1;
5826 ++v22;
5827 if ( v22 >= 4 )
5828 {
5829 v12 = v23;
5830 v21 = 1;
5831 }
5832 if ( v21 )
5833 break;
5834 v10 = 0;
5835 }
5836
5837 v9->uPortraitID = v12;
5838 v9->uFlags = 0;
5839 v9->fame = 0;
5840 v13 = rand() % 100 + 1;
5841
5842 if ( v13 >= 60 )
5843 {
5844 if ( v13 >= 90 )
5845 {
5846 if ( v13 >= 95 )
5847 {
5848 if ( v13 >= 98 )
5849 v9->rep = -600;
5850 else
5851 v9->rep = 400;
5852 }
5853 else
5854 {
5855 v9->rep = -300;
5856 }
5857 }
5858 else
5859 {
5860 v9->rep = 200;
5861 }
5862 }
5863 else
5864 {
5865 v9->rep = 0;
5866 }
5867
5868 //v14 = (int)((char *)v5 + 64 * a5);
5869 //v15 = rand() % *(_DWORD *)(v14 + 91460);
5870 v15 = rand() % array_16544[a5].field_0;
5871 v16 = 0;
5872 v17 = 0;
5873 v18 = v15 + 1;
5874
5875 if ( v18 > 0 )
5876 {
5877 do
5878 //v14 += *(char *)(v14 + v17++ + 0x16548);
5879 v16 += array_16544[a5].field_4[v17++];
5880 while ( v16 < v18 );
5881 }
5882 v9->uProfession = v17 - 1;
5883 v9->house = a4;
5884 v9->field_24 = 1;
5885 v9->joins = 1;
5886 return true;
5887 }
5888 // 47730C: using guessed type int __stdcall const_1(int); 4709 // 47730C: using guessed type int __stdcall const_1(int);
5889 4710
5890 //----- (0047752B) -------------------------------------------------------- 4711 //----- (0047752B) --------------------------------------------------------
5891 int __cdecl GetPartyReputation() 4712 int __cdecl GetPartyReputation()
5892 { 4713 {
16295 case DIALOGUE_PROFESSION_DETAILS: 15116 case DIALOGUE_PROFESSION_DETAILS:
16296 { 15117 {
16297 if (dialogue_show_profession_details) 15118 if (dialogue_show_profession_details)
16298 { 15119 {
16299 v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pBenefits; 15120 v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pBenefits;
16300 v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0); 15121 v7 = BuilDialogueString(v6, uActiveCharacter - 1, 0, 0, 0, 0);
16301 pInString = v7; 15122 pInString = v7;
16302 pWindow.uFrameWidth = 460; 15123 pWindow.uFrameWidth = 460;
16303 pWindow.uFrameZ = 452; 15124 pWindow.uFrameZ = 452;
16304 pOutString = pFontArrus; 15125 pOutString = pFontArrus;
16305 v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; 15126 v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
16315 pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); 15136 pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
16316 } 15137 }
16317 else if (pNPC->Hired()) 15138 else if (pNPC->Hired())
16318 { 15139 {
16319 v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pDismissText; 15140 v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pDismissText;
16320 v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0); 15141 v7 = BuilDialogueString(v6, uActiveCharacter - 1, 0, 0, 0, 0);
16321 pInString = v7; 15142 pInString = v7;
16322 pWindow.uFrameWidth = 460; 15143 pWindow.uFrameWidth = 460;
16323 pWindow.uFrameZ = 452; 15144 pWindow.uFrameZ = 452;
16324 pOutString = pFontArrus; 15145 pOutString = pFontArrus;
16325 v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; 15146 v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
16335 pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); 15156 pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
16336 } 15157 }
16337 else 15158 else
16338 { 15159 {
16339 v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText; 15160 v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText;
16340 v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0); 15161 v7 = BuilDialogueString(v6, uActiveCharacter - 1, 0, 0, 0, 0);
16341 pInString = v7; 15162 pInString = v7;
16342 pWindow.uFrameWidth = 460; 15163 pWindow.uFrameWidth = 460;
16343 pWindow.uFrameZ = 452; 15164 pWindow.uFrameZ = 452;
16344 pOutString = pFontArrus; 15165 pOutString = pFontArrus;
16345 v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; 15166 v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
16437 pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0); 15258 pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
16438 } 15259 }
16439 else if ( uDialogueType == DIALOGUE_13 ) 15260 else if ( uDialogueType == DIALOGUE_13 )
16440 { 15261 {
16441 v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText; 15262 v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText;
16442 v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0); 15263 v7 = BuilDialogueString(v6, uActiveCharacter - 1, 0, 0, 0, 0);
16443 pInString = v7; 15264 pInString = v7;
16444 pWindow.uFrameWidth = 460; 15265 pWindow.uFrameWidth = 460;
16445 pWindow.uFrameZ = 452; 15266 pWindow.uFrameZ = 452;
16446 pOutString = pFontArrus; 15267 pOutString = pFontArrus;
16447 v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; 15268 v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
16512 { 15333 {
16513 if (pNPC->Hired()) 15334 if (pNPC->Hired())
16514 v9 = pNPCStats->pProfessions[pNPC->uProfession].pDismissText; 15335 v9 = pNPCStats->pProfessions[pNPC->uProfession].pDismissText;
16515 else 15336 else
16516 v9 = pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed" 15337 v9 = pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed"
16517 pInString = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0); 15338 pInString = BuilDialogueString(v9, uActiveCharacter - 1, 0, 0, 0, 0);
16518 if ( pInString != NULL ) 15339 if ( pInString != NULL )
16519 { 15340 {
16520 pWindow.uFrameWidth = 460; 15341 pWindow.uFrameWidth = 460;
16521 pWindow.uFrameZ = 452; 15342 pWindow.uFrameZ = 452;
16522 pOutString = pFontArrus; 15343 pOutString = pFontArrus;