Mercurial > mm7
annotate NPC.cpp @ 1198:98a70229c271
Merge
author | Gloval |
---|---|
date | Sat, 08 Jun 2013 22:46:30 +0400 |
parents | 29a8defbad9e |
children | ab6560001f5b |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
3 #endif |
251 | 4 |
5 #include "Allocator.h" | |
6 #include "texts.h" | |
7 #include "LOD.h" | |
8 #include "Autonotes.h" | |
9 #include "Awards.h" | |
10 #include "mm7_data.h" | |
11 #include "MM7.h" | |
1016 | 12 #include "Party.h" |
251 | 13 #include "NPC.h" |
14 | |
629 | 15 int pDialogueNPCCount; |
16 struct Texture *pDialogueNPCPortraits[6]; | |
17 int uNumDialogueNPCPortraits; // weak | |
18 struct NPCStats *pNPCStats = nullptr; | |
19 | |
251 | 20 void InitializeAwards(); |
21 void InitializeScrolls(); | |
22 void InitializeMerchants(); | |
23 void InitializeTransitions(); | |
24 void InitializeAutonotes(); | |
25 void InitializeQuests(); | |
307 | 26 bool CheckPortretAgainstSex(int portret_num, int sex); |
251 | 27 |
781 | 28 //----- (004459F9) -------------------------------------------------------- |
29 NPCData *__fastcall GetNPCData(signed int npcid) | |
30 { | |
31 unsigned int v1; // esi@1 | |
32 NPCData *result; // eax@5 | |
33 int v3; // esi@9 | |
34 int v4; // ecx@9 | |
35 //int v5; // edx@9 | |
36 //NPCData *v6; // eax@9 | |
37 char *v7; // ebx@14 | |
38 NPCData *v8; // edi@14 | |
39 char v9; // al@22 | |
40 char v10; | |
41 //std::string v10; // [sp-18h] [bp-2Ch]@4 | |
42 int v11; | |
43 //const char *v11; // [sp-8h] [bp-1Ch]@4 | |
44 int v12; // [sp-4h] [bp-18h]@4 | |
45 int v13; | |
46 char *v14; | |
47 //std::string *v13; // [sp+Ch] [bp-8h]@4 | |
48 int a3; // [sp+13h] [bp-1h]@4 | |
49 int i; | |
50 | |
51 /*v1 = npcid; | |
52 if ( (npcid & 0x80000000u) == 0 ) | |
53 { | |
54 if ( (signed int)npcid < 5000 ) | |
55 { | |
56 if ( (signed int)npcid >= 501 ) | |
57 { | |
58 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0); | |
59 } | |
60 return &pNPCStats->pNewNPCData[v1]; | |
61 } | |
62 return &pNPCStats->array_13EF4[npcid - 5000]; | |
63 } | |
64 if ( (signed int)npcid >= 5000 ) | |
65 return &pNPCStats->array_13EF4[npcid - 5000]; | |
66 if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) | |
67 { | |
68 result = 0; | |
69 } | |
70 else | |
71 { | |
72 v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1; | |
73 v4 = 0; | |
74 v5 = 0; | |
75 v6 = pParty->pHirelings; | |
76 do | |
77 { | |
78 if ( v6->pName ) | |
79 pTmpBuf[v4++] = v5; | |
80 ++v6; | |
81 ++v5; | |
82 } | |
83 while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); | |
84 v13 = 0; | |
85 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
86 { | |
87 v7 = &pTmpBuf[v4]; | |
88 v8 = pNPCStats->pNewNPCData; | |
89 do | |
90 { | |
91 if ( v8->uFlags & 0x80 | |
92 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) | |
93 && (!pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName)) ) | |
94 *v7++ = (char)v13 + 2; | |
95 v13 = (std::string *)((char *)v13 + 1); | |
96 ++v8; | |
97 } | |
98 while ( (signed int)v13 < (signed int)pNPCStats->uNumNewNPCs ); | |
99 } | |
100 v9 = pTmpBuf[v3]; | |
101 if ( (unsigned __int8)v9 >= 2u ) | |
102 result = &pNPCStats->pNPCData[(unsigned __int8)v9 + 499]; | |
103 else | |
104 result = &pParty->pHirelings[(unsigned __int8)v9]; | |
105 } | |
106 return result;*/ | |
107 v1 = npcid; | |
108 if ( npcid >= 0 ) | |
109 { | |
110 if ( npcid < 5000 ) | |
111 { | |
112 if ( npcid >= 501 ) | |
113 { | |
114 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0); | |
115 } | |
116 return &pNPCStats->pNewNPCData[v1];// - 1]; | |
117 } | |
118 return &pNPCStats->pAdditionalNPC[npcid - 5000]; | |
119 } | |
120 | |
121 | |
122 if ( npcid >= 5000 ) | |
123 return &pNPCStats->pAdditionalNPC[npcid - 5000]; | |
124 if (sDialogue_SpeakingActorNPC_ID >= 0) | |
125 { | |
126 result = 0; | |
127 } | |
128 else | |
129 { | |
130 v3 = abs(sDialogue_SpeakingActorNPC_ID) - 1; | |
131 v4 = 0; | |
132 | |
133 for (i = 0; i < 2; ++i) | |
134 { | |
135 if (pParty->pHirelings[i].pName) | |
136 pTmpBuf[v4++] = i; | |
137 } | |
138 | |
139 if (pNPCStats->uNumNewNPCs > 0) | |
140 { | |
141 for (i = 0; i < pNPCStats->uNumNewNPCs; ++i) | |
142 { | |
143 if (pNPCStats->pNewNPCData[i].Hired()) | |
144 { | |
145 if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName)) | |
146 { | |
147 if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName)) | |
148 pTmpBuf[v4++] = i + 2; | |
149 } | |
150 } | |
151 } | |
152 } | |
153 | |
154 v9 = pTmpBuf[v3]; | |
155 if ( v9 >= 2 ) | |
156 result = &pNPCStats->pNPCData[499 + v9]; | |
157 else | |
158 result = &pParty->pHirelings[v9]; | |
159 } | |
1099 | 160 return result; |
781 | 161 } |
162 | |
163 //----- (00445B2C) -------------------------------------------------------- | |
1094 | 164 struct NPCData * GetNewNPCData( signed int npcid, int* npc_indx ) |
165 { | |
166 | |
167 int* v3; // edi@1 | |
781 | 168 NPCData *result; // eax@5 |
169 int v5; // esi@9 | |
170 int v6; // ecx@9 | |
171 char v11; // al@23 | |
172 | |
1094 | 173 v3 = npc_indx; |
781 | 174 if ( npcid >= 0 ) |
175 { | |
176 if ( npcid < 5000 ) | |
177 { | |
178 if ( npcid >= 501 ) | |
179 { | |
1094 | 180 MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:2040", 0); |
781 | 181 } |
1094 | 182 *v3 = npcid; |
183 return &pNPCStats->pNewNPCData[npcid]; | |
781 | 184 } |
1094 | 185 *npc_indx = npcid - 5000; |
781 | 186 return &pNPCStats->pAdditionalNPC[npcid - 5000]; |
187 } | |
188 if ( npcid >= 5000 ) | |
1094 | 189 { |
190 *npc_indx = npcid - 5000; | |
191 return &pNPCStats->pAdditionalNPC[npcid - 5000]; | |
192 } | |
781 | 193 if ( sDialogue_SpeakingActorNPC_ID >= 0 ) |
194 { | |
1094 | 195 *npc_indx = 0; |
196 result = NULL; | |
781 | 197 } |
198 else | |
199 { | |
1094 | 200 v5 = abs(sDialogue_SpeakingActorNPC_ID) - 1; |
781 | 201 v6 = 0; |
1094 | 202 for (int i=0; i<2; ++i) |
781 | 203 { |
1094 | 204 if ( pParty->pHirelings[i].pName ) |
205 pTmpBuf[v6++] = i; | |
206 | |
207 } | |
208 for (int i=0; i< pNPCStats->uNumNewNPCs; ++i) | |
781 | 209 { |
1094 | 210 if ( pNPCStats->pNewNPCData[i].Hired() |
211 && (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName)) | |
212 && (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName)) ) | |
213 { | |
214 pTmpBuf[v6++]=i+2; | |
215 } | |
781 | 216 } |
217 v11 = pTmpBuf[v5]; | |
1094 | 218 |
219 if ( v11 >= 2u ) | |
781 | 220 { |
1094 | 221 *v3 = v11 - 2; |
222 result = &pNPCStats->pNewNPCData[v11 - 2]; | |
781 | 223 } |
224 else | |
225 { | |
1094 | 226 *v3 = v11; |
227 result = &pParty->pHirelings[v11]; | |
781 | 228 } |
229 } | |
230 return result; | |
231 } | |
232 | |
251 | 233 //----- (00476977) -------------------------------------------------------- |
291 | 234 void NPCStats::InitializeNPCText() |
251 | 235 { |
236 int i; | |
237 char* test_string; | |
238 unsigned char c; | |
239 bool break_loop; | |
240 unsigned int temp_str_len; | |
241 char* tmp_pos; | |
242 int decode_step; | |
243 | |
244 if (pNPCTextTXT_Raw) | |
245 pAllocator->FreeChunk(pNPCTextTXT_Raw); | |
246 pNPCTextTXT_Raw =NULL; | |
247 pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); | |
248 strtok(pNPCTextTXT_Raw, "\r"); | |
249 | |
250 for (i=0; i<789; ++i) | |
251 { | |
252 test_string = strtok(NULL, "\r") + 1; | |
253 break_loop = false; | |
254 decode_step=0; | |
255 do | |
256 { | |
257 c = *(unsigned char*)test_string; | |
258 temp_str_len = 0; | |
259 while((c!='\t')&&(c>0)) | |
260 { | |
261 ++temp_str_len; | |
262 c=test_string[temp_str_len]; | |
263 } | |
264 tmp_pos=test_string+temp_str_len; | |
265 if (*tmp_pos == 0) | |
266 break_loop = true; | |
267 *tmp_pos = 0; | |
268 if (temp_str_len) | |
269 { | |
270 if ( decode_step == 1) | |
271 pNPCTopics[i].pText =RemoveQuotes(test_string); | |
272 } | |
273 else | |
274 { | |
275 break_loop = true; | |
276 } | |
277 ++decode_step; | |
278 test_string=tmp_pos+1; | |
279 } while ((decode_step<2)&&!break_loop); | |
280 } | |
281 | |
282 if (pNPCTopicTXT_Raw) | |
283 pAllocator->FreeChunk(pNPCTopicTXT_Raw); | |
284 pNPCTopicTXT_Raw =NULL; | |
285 pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0); | |
286 strtok(pNPCTopicTXT_Raw, "\r"); | |
287 | |
288 for (i=0; i<579; ++i) | |
289 { | |
290 test_string = strtok(NULL, "\r") + 1; | |
291 break_loop = false; | |
292 decode_step=0; | |
293 do | |
294 { | |
295 c = *(unsigned char*)test_string; | |
296 temp_str_len = 0; | |
297 while((c!='\t')&&(c>0)) | |
298 { | |
299 ++temp_str_len; | |
300 c=test_string[temp_str_len]; | |
301 } | |
302 tmp_pos=test_string+temp_str_len; | |
303 if (*tmp_pos == 0) | |
304 break_loop = true; | |
305 *tmp_pos = 0; | |
306 if (temp_str_len) | |
307 { | |
308 if ( decode_step == 1) | |
309 pNPCTopics[i].pTopic = RemoveQuotes(test_string); | |
310 } | |
311 else | |
312 { | |
313 break_loop = true; | |
314 } | |
315 ++decode_step; | |
316 test_string=tmp_pos+1; | |
317 } while ((decode_step<2)&&!break_loop); | |
318 } | |
319 | |
320 if (pNPCDistTXT_Raw) | |
321 pAllocator->FreeChunk(pNPCDistTXT_Raw); | |
322 pNPCDistTXT_Raw = NULL; | |
323 pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0); | |
324 strtok(pNPCDistTXT_Raw, "\r"); | |
325 strtok(NULL, "\r"); | |
326 | |
327 for (i=1; i<59; ++i) | |
328 { | |
329 test_string = strtok(NULL, "\r") + 1; | |
330 break_loop = false; | |
331 decode_step=0; | |
332 do | |
333 { | |
334 c = *(unsigned char*)test_string; | |
335 temp_str_len = 0; | |
336 while((c!='\t')&&(c>0)) | |
337 { | |
338 ++temp_str_len; | |
339 c=test_string[temp_str_len]; | |
340 } | |
341 tmp_pos=test_string+temp_str_len; | |
342 if (*tmp_pos == 0) | |
343 break_loop = true; | |
344 *tmp_pos = 0; | |
345 if (temp_str_len) | |
346 { | |
347 if ((decode_step>0)&&(decode_step<77)) | |
348 { | |
291 | 349 pProfessionChance[decode_step].professionChancePerArea[i]=atoi(test_string); |
251 | 350 } |
351 else if (decode_step==0) | |
352 { | |
291 | 353 pProfessionChance[0].professionChancePerArea[i]=10; |
251 | 354 } |
355 } | |
356 else | |
357 { | |
358 break_loop = true; | |
359 } | |
360 ++decode_step; | |
361 test_string=tmp_pos+1; | |
362 } while ((decode_step<78)&&!break_loop); | |
363 } | |
364 | |
825 | 365 for ( i = 0; i < 77; ++i ) |
251 | 366 { |
291 | 367 pProfessionChance[i].uTotalprofChance=0; |
825 | 368 for ( int ii = 1; ii < 59; ++ii ) |
251 | 369 { |
291 | 370 pProfessionChance[i].uTotalprofChance+=pProfessionChance[i].professionChancePerArea[ii]; |
251 | 371 } |
293 | 372 pProfessionChance[i].professionChancePerArea[0]=0; |
373 pProfessionChance[i].professionChancePerArea[59]=0; | |
251 | 374 } |
375 | |
376 if (pNPCDistTXT_Raw) | |
377 { | |
378 pAllocator->FreeChunk(pNPCDistTXT_Raw); | |
379 pNPCDistTXT_Raw = NULL; | |
380 } | |
381 } | |
382 | |
383 //----- (00476C60) -------------------------------------------------------- | |
384 void NPCStats::_476C60() | |
385 { | |
386 for (unsigned int i = 1; i < uNumNewNPCs; ++i) | |
291 | 387 pNewNPCData[i].pName = pNPCUnicNames[i - 1]; |
251 | 388 |
389 if (pParty->pHirelings[0].pName) | |
390 pParty->pHirelings[0].pName = pParty->pHireling1Name; | |
391 if (pParty->pHirelings[1].pName) | |
392 pParty->pHirelings[1].pName = pParty->pHireling2Name; | |
393 } | |
394 | |
395 //----- (00476CB5) -------------------------------------------------------- | |
291 | 396 void NPCStats::InitializeNPCData() |
251 | 397 { |
291 | 398 int i; |
399 char* test_string; | |
400 unsigned char c; | |
401 bool break_loop; | |
402 unsigned int temp_str_len; | |
403 char* tmp_pos; | |
404 int decode_step; | |
405 | |
406 pNPCDataTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdata.txt", 0); | |
407 strtok(pNPCDataTXT_Raw, "\r"); | |
408 strtok(NULL, "\r"); | |
251 | 409 |
291 | 410 for (i=0; i<500; ++i) |
251 | 411 { |
291 | 412 test_string = strtok(NULL, "\r") + 1; |
413 break_loop = false; | |
414 decode_step=0; | |
415 do | |
251 | 416 { |
291 | 417 c = *(unsigned char*)test_string; |
418 temp_str_len = 0; | |
419 while((c!='\t')&&(c>0)) | |
251 | 420 { |
291 | 421 ++temp_str_len; |
422 c=test_string[temp_str_len]; | |
423 } | |
424 tmp_pos=test_string+temp_str_len; | |
425 if (*tmp_pos == 0) | |
426 break_loop = true; | |
427 *tmp_pos = 0; | |
428 if (temp_str_len) | |
429 { //i+1 | |
430 switch (decode_step) | |
251 | 431 { |
291 | 432 case 1: |
433 pNPCUnicNames[i] = RemoveQuotes(test_string); | |
434 pNPCData[i+1].pName=pNPCUnicNames[i]; | |
251 | 435 break; |
291 | 436 case 2: |
437 pNPCData[i+1].uPortraitID = atoi(test_string); | |
251 | 438 break; |
439 case 6: | |
291 | 440 pNPCData[i+1].Location2D = atoi(test_string); |
251 | 441 break; |
442 case 7: | |
291 | 443 pNPCData[i+1].uProfession = atoi(test_string); |
251 | 444 break; |
445 case 8: | |
291 | 446 pNPCData[i+1].greet = atoi(test_string); |
251 | 447 break; |
448 case 9: | |
291 | 449 pNPCData[i+1].joins = (*test_string == 'y')?1:0; |
251 | 450 break; |
451 case 10: | |
291 | 452 pNPCData[i+1].evt_A = atoi(test_string); |
251 | 453 break; |
454 case 11: | |
291 | 455 pNPCData[i+1].evt_B = atoi(test_string); |
251 | 456 break; |
457 case 12: | |
291 | 458 pNPCData[i+1].evt_C = atoi(test_string); |
251 | 459 break; |
460 case 13: | |
291 | 461 pNPCData[i+1].evt_D = atoi(test_string); |
251 | 462 break; |
463 case 14: | |
291 | 464 pNPCData[i+1].evt_E = atoi(test_string); |
251 | 465 break; |
291 | 466 case 15: |
467 pNPCData[i+1].evt_F = atoi(test_string); | |
251 | 468 break; |
469 } | |
470 } | |
291 | 471 ++decode_step; |
472 test_string=tmp_pos+1; | |
473 } while ((decode_step<16)&&!break_loop); | |
251 | 474 } |
291 | 475 uNumNewNPCs = 501; |
476 pNPCGreetTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgreet.txt", 0); | |
477 strtok(pNPCGreetTXT_Raw, "\r"); | |
478 for (i=0; i<205; ++i) | |
479 { | |
480 test_string = strtok(NULL, "\r") + 1; | |
481 break_loop = false; | |
482 decode_step=0; | |
483 do | |
251 | 484 { |
291 | 485 c = *(unsigned char*)test_string; |
486 temp_str_len = 0; | |
487 while((c!='\t')&&(c>0)) | |
251 | 488 { |
291 | 489 ++temp_str_len; |
490 c=test_string[temp_str_len]; | |
491 } | |
492 tmp_pos=test_string+temp_str_len; | |
493 if (*tmp_pos == 0) | |
494 break_loop = true; | |
495 *tmp_pos = 0; | |
496 if (temp_str_len) | |
497 { //i+1 | |
498 switch (decode_step) | |
251 | 499 { |
291 | 500 case 1: |
501 pNPCGreetings[i].pGreeting1 = RemoveQuotes(test_string); | |
502 break; | |
503 case 2: | |
504 pNPCGreetings[i].pGreeting2 = RemoveQuotes(test_string); | |
505 break; | |
251 | 506 } |
507 } | |
291 | 508 ++decode_step; |
509 test_string=tmp_pos+1; | |
510 } while ((decode_step<3)&&!break_loop); | |
511 } | |
512 | |
513 pNCPGroupTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcgroup.txt", 0); | |
514 strtok(pNCPGroupTXT_Raw, "\r"); | |
515 | |
516 for (i=0; i<51; ++i) | |
517 { | |
518 test_string = strtok(NULL, "\r") + 1; | |
519 break_loop = false; | |
520 decode_step=0; | |
521 do | |
522 { | |
523 c = *(unsigned char*)test_string; | |
524 temp_str_len = 0; | |
525 while((c!='\t')&&(c>0)) | |
526 { | |
527 ++temp_str_len; | |
528 c=test_string[temp_str_len]; | |
529 } | |
530 tmp_pos=test_string+temp_str_len; | |
531 if (*tmp_pos == 0) | |
532 break_loop = true; | |
533 *tmp_pos = 0; | |
534 if (temp_str_len) | |
535 { //i+1 | |
536 if (decode_step==1) | |
251 | 537 { |
291 | 538 pGroups[i] = atoi(test_string); |
251 | 539 } |
291 | 540 } |
541 ++decode_step; | |
542 test_string=tmp_pos+1; | |
543 } while ((decode_step<2)&&!break_loop); | |
544 } | |
545 | |
546 pNPCNewsTXT_Raw = (char*)pEvents_LOD->LoadRaw("npcnews.txt", 0); | |
547 strtok(pNPCNewsTXT_Raw, "\r"); | |
548 | |
549 | |
550 for (i=0; i<51; ++i) | |
551 { | |
552 test_string = strtok(NULL, "\r") + 1; | |
553 break_loop = false; | |
554 decode_step=0; | |
555 do | |
556 { | |
557 c = *(unsigned char*)test_string; | |
558 temp_str_len = 0; | |
559 while((c!='\t')&&(c>0)) | |
560 { | |
561 ++temp_str_len; | |
562 c=test_string[temp_str_len]; | |
563 } | |
564 tmp_pos=test_string+temp_str_len; | |
565 if (*tmp_pos == 0) | |
566 break_loop = true; | |
567 *tmp_pos = 0; | |
568 if (temp_str_len) | |
569 { //i+1 | |
570 if (decode_step==1) | |
571 pCatchPhrases[i] = RemoveQuotes(test_string); | |
572 } | |
573 ++decode_step; | |
574 test_string=tmp_pos+1; | |
575 } while ((decode_step<2)&&!break_loop); | |
576 } | |
251 | 577 } |
578 | |
579 //----- (0047702F) -------------------------------------------------------- | |
580 void NPCStats::Initialize() | |
291 | 581 { |
582 int i; | |
583 char* test_string; | |
584 unsigned char c; | |
585 bool break_loop; | |
586 unsigned int temp_str_len; | |
587 char* tmp_pos; | |
588 int decode_step; | |
251 | 589 |
291 | 590 InitializeNPCData(); |
591 InitializeNPCText(); | |
592 InitializeQuests(); | |
593 InitializeAutonotes(); | |
594 InitializeAwards(); | |
595 InitializeTransitions(); | |
596 InitializeMerchants(); | |
597 InitializeScrolls(); | |
251 | 598 |
291 | 599 pNPCNamesTXT_Raw = NULL; |
600 pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); | |
601 strtok(pNPCNamesTXT_Raw, "\r"); | |
602 | |
603 uNewlNPCBufPos = 0; | |
604 | |
605 for (i=0; i<540; ++i) | |
251 | 606 { |
291 | 607 test_string = strtok(NULL, "\r") + 1; |
608 break_loop = false; | |
609 decode_step=0; | |
610 do | |
251 | 611 { |
291 | 612 c = *(unsigned char*)test_string; |
613 temp_str_len = 0; | |
614 if (c=='\t') | |
251 | 615 { |
291 | 616 if ( (decode_step == 1)&&(!uNumNPCNames[1])) |
617 uNumNPCNames[1]=i; | |
251 | 618 } |
619 else | |
620 { | |
291 | 621 while((c!='\n')&&(c!='\t')&&(c>0)) |
622 { | |
623 ++temp_str_len; | |
624 c=test_string[temp_str_len]; | |
625 } | |
626 tmp_pos=test_string+temp_str_len; | |
627 if (*tmp_pos == 0) | |
628 break_loop = true; | |
629 | |
630 if (temp_str_len) | |
631 { | |
632 *tmp_pos = 0; | |
633 if ( decode_step == 0) | |
634 pNPCNames[i][0] =RemoveQuotes(test_string); | |
635 else if ( decode_step == 1) | |
636 pNPCNames[i][1] =RemoveQuotes(test_string); | |
637 } | |
638 else | |
639 { | |
640 if ( (decode_step == 1)&&(!uNumNPCNames[1])) | |
641 uNumNPCNames[1]=i; | |
642 } | |
251 | 643 } |
291 | 644 ++decode_step; |
645 test_string=tmp_pos+1; | |
646 } while ((decode_step<2)&&!break_loop); | |
647 } | |
648 uNumNPCNames[0] = i; | |
649 | |
650 pNPCProfTXT_Raw = NULL; | |
651 pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); | |
652 strtok(pNPCProfTXT_Raw, "\r"); | |
653 strtok(NULL, "\r"); | |
654 strtok(NULL, "\r"); | |
655 strtok(NULL, "\r"); | |
656 | |
657 for (i=1; i<59; ++i) | |
658 { | |
659 test_string = strtok(NULL, "\r") + 1; | |
660 break_loop = false; | |
661 decode_step=0; | |
662 do | |
251 | 663 { |
667 | 664 //while (*test_string == '\t') // some steps are separated by multiple \t's |
665 //++test_string; | |
652 | 666 |
291 | 667 c = *(unsigned char*)test_string; |
668 temp_str_len = 0; | |
669 while((c!='\t')&&(c>0)) | |
251 | 670 { |
291 | 671 ++temp_str_len; |
672 c=test_string[temp_str_len]; | |
673 } | |
674 tmp_pos=test_string+temp_str_len; | |
675 if (*tmp_pos == 0) | |
676 break_loop = true; | |
677 *tmp_pos = 0; | |
678 if (temp_str_len) | |
679 { | |
680 switch(decode_step) | |
681 { | |
682 case 2: | |
683 pProfessions[i].uHirePrice = atoi(test_string); | |
684 break; | |
685 case 3: | |
686 pProfessions[i].pActionText = RemoveQuotes(test_string); | |
687 break; | |
688 case 4: | |
689 pProfessions[i].pBenefits= RemoveQuotes(test_string); | |
690 break; | |
691 case 5: | |
692 pProfessions[i].pJoinText = RemoveQuotes(test_string); | |
693 break; | |
694 case 6: | |
695 pProfessions[i].pDismissText = RemoveQuotes(test_string); | |
696 } | |
251 | 697 } |
291 | 698 else |
699 { | |
667 | 700 if (!decode_step) |
291 | 701 break_loop = true; |
702 } | |
703 ++decode_step; | |
704 test_string=tmp_pos+1; | |
705 } while ((decode_step<7)&&!break_loop); | |
251 | 706 } |
291 | 707 uNumNPCProfessions = 59; |
251 | 708 } |
709 | |
710 //----- (00477266) -------------------------------------------------------- | |
711 void NPCStats::Release() | |
712 { | |
291 | 713 pAllocator->FreeChunk(pNPCTopicTXT_Raw); |
714 pNPCTopicTXT_Raw = NULL; | |
715 pAllocator->FreeChunk(pNPCTextTXT_Raw); | |
716 pNPCTextTXT_Raw = NULL; | |
717 pAllocator->FreeChunk(pNPCNewsTXT_Raw); | |
718 pNPCNewsTXT_Raw = NULL; | |
719 pAllocator->FreeChunk(pNPCProfTXT_Raw); | |
720 pNPCProfTXT_Raw = NULL; | |
721 pAllocator->FreeChunk(pNPCNamesTXT_Raw); | |
722 pNPCNamesTXT_Raw = NULL; | |
723 pAllocator->FreeChunk(pNPCDataTXT_Raw); | |
724 pNPCDataTXT_Raw = NULL; | |
725 pAllocator->FreeChunk(pNPCDistTXT_Raw); | |
726 pNPCDistTXT_Raw = NULL; | |
727 pAllocator->FreeChunk(pNPCGreetTXT_Raw); | |
728 pNPCGreetTXT_Raw = NULL; | |
729 pAllocator->FreeChunk(pNCPGroupTXT_Raw); | |
730 pNCPGroupTXT_Raw = NULL; | |
251 | 731 } |
732 | |
733 //----- (0047730C) -------------------------------------------------------- | |
307 | 734 bool CheckPortretAgainstSex(int a1, int) |
251 | 735 { |
291 | 736 return true; |
251 | 737 } |
738 // 47730C: using guessed type int __stdcall const_1(int); | |
739 | |
740 //----- (0047732C) -------------------------------------------------------- | |
291 | 741 void NPCStats::InitializeAdditionalNPCs(NPCData *pNPCDataBuff, int npc_uid, int uLocation2D, int uMapId) |
251 | 742 { |
292 | 743 int rep_gen; |
291 | 744 int uNPCSex; // esi@1 |
745 int uGeneratedPortret; // ecx@23 | |
746 int test_prof_summ; // ecx@37 | |
747 int gen_profession; // eax@37 | |
748 int max_prof_cap; // edx@37 | |
251 | 749 signed int result; // eax@39 |
291 | 750 int uRace; // [sp+Ch] [bp-Ch]@1 |
751 bool break_gen; // [sp+10h] [bp-8h]@1 | |
752 signed int gen_attempts; // [sp+14h] [bp-4h]@1 | |
753 int uPortretMin; // [sp+24h] [bp+Ch]@1 | |
754 int uPortretMax; | |
755 | |
756 static const unsigned __int8 NPCSexGenTable[86] ={ | |
293 | 757 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
758 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, | |
759 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, | |
760 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
761 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }; | |
762 static const unsigned __int8 NPCRaceGenTable[86] ={ | |
763 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, | |
764 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
765 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, | |
766 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
767 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0}; | |
251 | 768 |
307 | 769 unsigned __int8 seed = (unsigned __int8)((double)(npc_uid - 1)/3.0); |
291 | 770 uNPCSex = NPCSexGenTable[seed]; |
771 uRace = NPCRaceGenTable[seed]; | |
772 pNPCDataBuff->uSex = uNPCSex; | |
773 pNPCDataBuff->pName = pNPCNames[rand() % uNumNPCNames[uNPCSex]][uNPCSex]; | |
774 | |
775 gen_attempts = 0; | |
776 break_gen = false; | |
251 | 777 |
291 | 778 do |
251 | 779 { |
293 | 780 switch ( uRace ) |
781 { | |
782 case 0: | |
783 if ( uNPCSex == 0 ) | |
291 | 784 { |
785 uPortretMin = 2; | |
786 uPortretMax = 100; | |
251 | 787 } |
788 else | |
789 { | |
293 | 790 uPortretMin = 201; |
791 uPortretMax = 250; | |
792 } | |
793 case 1: | |
794 if ( uNPCSex == 0 ) | |
795 { | |
796 uPortretMin = 400; | |
797 uPortretMax = 430; | |
798 } | |
799 else | |
800 { | |
801 uPortretMin = 460; | |
802 uPortretMax = 490; | |
803 } | |
804 break; | |
805 case 2: | |
806 if ( uNPCSex == 0 ) | |
807 { | |
808 uPortretMin = 500; | |
809 uPortretMax = 520; | |
810 } | |
811 else | |
812 { | |
813 uPortretMin = 530; | |
814 uPortretMax = 550; | |
815 } | |
816 break; | |
817 case 3: | |
818 if ( uNPCSex == 0 ) | |
819 { | |
820 uPortretMin = 300; | |
821 uPortretMax = 330; | |
822 } | |
823 else | |
824 { | |
825 uPortretMin = 360; | |
826 uPortretMax = 387; | |
251 | 827 } |
291 | 828 |
293 | 829 break; |
830 } | |
831 | |
291 | 832 uGeneratedPortret = uPortretMin + rand() % (uPortretMax - uPortretMin + 1); |
307 | 833 if ( CheckPortretAgainstSex(uGeneratedPortret, uNPCSex)) |
291 | 834 break_gen = true; |
835 ++gen_attempts; | |
836 if ( gen_attempts >= 4 ) | |
251 | 837 { |
291 | 838 uGeneratedPortret = uPortretMin; |
839 break_gen = true; | |
251 | 840 } |
841 } | |
291 | 842 while(!break_gen); |
251 | 843 |
293 | 844 pNPCDataBuff->uPortraitID = uGeneratedPortret; |
845 pNPCDataBuff->uFlags = 0; | |
846 pNPCDataBuff->fame = 0; | |
847 //generate reputation | |
848 rep_gen = rand() % 100 + 1; | |
251 | 849 |
293 | 850 if ( rep_gen >= 60 ) |
251 | 851 { |
293 | 852 if ( rep_gen >= 90 ) |
251 | 853 { |
293 | 854 if ( rep_gen >= 95 ) |
855 { | |
856 if ( rep_gen >= 98 ) | |
857 pNPCDataBuff->rep = -600; | |
858 else | |
859 pNPCDataBuff->rep = 400; | |
860 } | |
251 | 861 else |
293 | 862 pNPCDataBuff->rep = -300; |
251 | 863 } |
864 else | |
293 | 865 pNPCDataBuff->rep = 200; |
251 | 866 } |
867 else | |
293 | 868 pNPCDataBuff->rep = 0; |
291 | 869 |
293 | 870 max_prof_cap = rand() % pProfessionChance[uMapId].uTotalprofChance+1; |
871 test_prof_summ = 0; | |
872 gen_profession = 0; | |
251 | 873 |
293 | 874 if ( max_prof_cap > 0 ) |
875 { | |
876 do | |
877 test_prof_summ += pProfessionChance[uMapId].professionChancePerArea[gen_profession++]; | |
878 while ( test_prof_summ < max_prof_cap ); | |
879 } | |
880 pNPCDataBuff->uProfession = gen_profession - 1; | |
881 pNPCDataBuff->Location2D = uLocation2D; | |
882 pNPCDataBuff->field_24 = 1; | |
883 pNPCDataBuff->joins = 1; | |
659 | 884 pNPCDataBuff->evt_A = 0; |
885 pNPCDataBuff->evt_B = 0; | |
886 pNPCDataBuff->evt_C = 0; | |
887 pNPCDataBuff->evt_D = 0; | |
888 pNPCDataBuff->evt_E = 0; | |
889 pNPCDataBuff->evt_F = 0; | |
251 | 890 } |
891 | |
257 | 892 //----- (00476387) -------------------------------------------------------- |
893 bool PartyHasDragon() | |
894 { | |
895 return pNPCStats->pNewNPCData[57].Hired(); | |
896 } | |
251 | 897 |
898 //----- (00476395) -------------------------------------------------------- | |
899 //0x26 Wizard eye at skill level 2 | |
900 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession) | |
1094 | 901 { |
902 | |
903 if ( bNoNPCHiring == 1 ) | |
904 return 0; | |
251 | 905 |
1094 | 906 for (int i=0; i<pNPCStats->uNumNewNPCs; ++i ) |
907 { | |
908 if ( pNPCStats->pNewNPCData[i].uProfession == uProfession && | |
909 (pNPCStats->pNewNPCData[i].uFlags & 0x80) ) | |
910 return true; | |
911 } | |
912 if ( pParty->pHirelings[0].uProfession == uProfession || | |
913 pParty->pHirelings[1].uProfession == uProfession) | |
914 return true; | |
915 else | |
916 return false; | |
917 | |
918 } | |
251 | 919 // 6BE3C5: using guessed type char bNoNPCHiring; |
920 | |
921 //----- (004763E0) -------------------------------------------------------- | |
922 void InitializeAwards() | |
949 | 923 { |
251 | 924 int i; |
925 char* test_string; | |
926 unsigned char c; | |
927 bool break_loop; | |
928 unsigned int temp_str_len; | |
929 char* tmp_pos; | |
930 int decode_step; | |
931 | |
932 if ( pAwardsTXT_Raw ) | |
933 pAllocator->FreeChunk(pAwardsTXT_Raw); | |
934 pAwardsTXT_Raw = NULL; | |
935 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0); | |
936 strtok(pAwardsTXT_Raw, "\r"); | |
937 | |
949 | 938 for (i=1; i<105; ++i) |
251 | 939 { |
940 test_string = strtok(NULL, "\r") + 1; | |
941 break_loop = false; | |
942 decode_step=0; | |
943 do | |
944 { | |
945 c = *(unsigned char*)test_string; | |
946 temp_str_len = 0; | |
947 while((c!='\t')&&(c>0)) | |
948 { | |
949 ++temp_str_len; | |
950 c=test_string[temp_str_len]; | |
951 } | |
952 tmp_pos=test_string+temp_str_len; | |
953 if (*tmp_pos == 0) | |
954 break_loop = true; | |
955 *tmp_pos = 0; | |
956 if (temp_str_len) | |
957 { | |
958 if (decode_step==1) | |
959 pAwards[i].pText=RemoveQuotes(test_string); | |
960 else if (decode_step==2) | |
949 | 961 pAwards[i].uPriority = atoi(test_string); |
251 | 962 } |
963 else | |
964 { | |
965 break_loop = true; | |
966 } | |
967 ++decode_step; | |
968 test_string=tmp_pos+1; | |
969 } while ((decode_step<3)&&!break_loop); | |
970 } | |
971 } | |
972 // 7241C8: using guessed type int dword_7241C8; | |
973 | |
974 //----- (004764C2) -------------------------------------------------------- | |
975 void InitializeScrolls() | |
976 { | |
977 | |
978 int i; | |
979 char* test_string; | |
980 unsigned char c; | |
981 bool break_loop; | |
982 unsigned int temp_str_len; | |
983 char* tmp_pos; | |
984 int decode_step; | |
985 | |
986 if ( pScrollsTXT_Raw ) | |
987 pAllocator->FreeChunk(pScrollsTXT_Raw); | |
988 pScrollsTXT_Raw = NULL; | |
989 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0); | |
990 strtok(pScrollsTXT_Raw, "\r"); | |
991 for (i=0; i<82; ++i) | |
992 { | |
993 test_string = strtok(NULL, "\r") + 1; | |
994 break_loop = false; | |
995 decode_step=0; | |
996 do | |
997 { | |
998 c = *(unsigned char*)test_string; | |
999 temp_str_len = 0; | |
1000 while((c!='\t')&&(c>0)) | |
1001 { | |
1002 ++temp_str_len; | |
1003 c=test_string[temp_str_len]; | |
1004 } | |
1005 tmp_pos=test_string+temp_str_len; | |
1006 if (*tmp_pos == 0) | |
1007 break_loop = true; | |
1008 *tmp_pos = 0; | |
1009 if (temp_str_len) | |
1010 { | |
1011 if ( decode_step == 1) | |
1012 pScrolls[i]=RemoveQuotes(test_string); | |
1013 } | |
1014 else | |
1015 { | |
1016 break_loop = true; | |
1017 } | |
1018 ++decode_step; | |
1019 test_string=tmp_pos+1; | |
1020 } while ((decode_step<2)&&!break_loop); | |
1021 } | |
1022 } | |
1023 | |
1024 //----- (00476590) -------------------------------------------------------- | |
1025 void InitializeMerchants() | |
1026 { | |
1027 int i; | |
1028 char* test_string; | |
1029 unsigned char c; | |
1030 bool break_loop; | |
1031 unsigned int temp_str_len; | |
1032 char* tmp_pos; | |
1033 int decode_step; | |
1034 | |
1035 if ( pMerchantsTXT_Raw ) | |
1036 pAllocator->FreeChunk(pMerchantsTXT_Raw); | |
1037 pMerchantsTXT_Raw = NULL; | |
1038 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0); | |
1039 strtok(pMerchantsTXT_Raw, "\r"); | |
1040 | |
1041 for (i=0; i<7; ++i) | |
1042 { | |
1043 test_string = strtok(NULL, "\r") + 1; | |
1044 break_loop = false; | |
1045 decode_step=0; | |
1046 do | |
1047 { | |
1048 c = *(unsigned char*)test_string; | |
1049 temp_str_len = 0; | |
1050 while((c!='\t')&&(c>0)) | |
1051 { | |
1052 ++temp_str_len; | |
1053 c=test_string[temp_str_len]; | |
1054 } | |
1055 tmp_pos=test_string+temp_str_len; | |
1056 if (*tmp_pos == 0) | |
1057 break_loop = true; | |
1058 *tmp_pos = 0; | |
1059 if (temp_str_len) | |
1060 { | |
1061 switch (decode_step) | |
1062 { | |
1063 case 1: | |
1064 pMerchantsBuyPhrases[i]=RemoveQuotes(test_string); | |
1065 break; | |
1066 case 2: | |
1067 pMerchantsSellPhrases[i]=RemoveQuotes(test_string); | |
1068 break; | |
1069 case 3: | |
1070 pMerchantsRepairPhrases[i]=RemoveQuotes(test_string); | |
1071 break; | |
1072 case 4: | |
1073 pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string); | |
1074 break; | |
1075 } | |
1076 } | |
1077 else | |
1078 { | |
1079 break_loop = true; | |
1080 } | |
1081 ++decode_step; | |
1082 test_string=tmp_pos+1; | |
1083 } while ((decode_step<5)&&!break_loop); | |
1084 } | |
1085 | |
1086 } | |
1087 | |
1088 //----- (00476682) -------------------------------------------------------- | |
1089 void InitializeTransitions() | |
1090 { | |
1091 int i; | |
1092 char* test_string; | |
1093 unsigned char c; | |
1094 bool break_loop; | |
1095 unsigned int temp_str_len; | |
1096 char* tmp_pos; | |
1097 int decode_step; | |
1098 | |
1099 if ( pTransitionsTXT_Raw ) | |
1100 pAllocator->FreeChunk(pTransitionsTXT_Raw); | |
1101 pTransitionsTXT_Raw = NULL; | |
1102 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0); | |
1103 strtok(pTransitionsTXT_Raw, "\r"); | |
1104 | |
1105 for (i=0; i<464; ++i) | |
1106 { | |
1107 test_string = strtok(NULL, "\r") + 1; | |
1108 break_loop = false; | |
1109 decode_step=0; | |
1110 do | |
1111 { | |
1112 c = *(unsigned char*)test_string; | |
1113 temp_str_len = 0; | |
1114 while((c!='\t')&&(c>0)) | |
1115 { | |
1116 ++temp_str_len; | |
1117 c=test_string[temp_str_len]; | |
1118 } | |
1119 tmp_pos=test_string+temp_str_len; | |
1120 if (*tmp_pos == 0) | |
1121 break_loop = true; | |
1122 *tmp_pos = 0; | |
1123 if (temp_str_len) | |
1124 { | |
1125 if ( decode_step == 1) | |
434 | 1126 pTransitionStrings[i + 1]=RemoveQuotes(test_string); |
251 | 1127 } |
1128 else | |
1129 { | |
1130 break_loop = true; | |
1131 } | |
1132 ++decode_step; | |
1133 test_string=tmp_pos+1; | |
1134 } while ((decode_step<2)&&!break_loop); | |
1135 } | |
1136 } | |
1137 | |
1138 //----- (00476750) -------------------------------------------------------- | |
1139 void __cdecl InitializeAutonotes() | |
1140 { | |
1141 int i; | |
1142 char* test_string; | |
1143 unsigned char c; | |
1144 bool break_loop; | |
1145 unsigned int temp_str_len; | |
1146 char* tmp_pos; | |
1147 int decode_step; | |
1148 | |
1149 if ( pAutonoteTXT_Raw ) | |
1150 pAllocator->FreeChunk(pAutonoteTXT_Raw); | |
1151 pAutonoteTXT_Raw = 0; | |
1152 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0); | |
1153 strtok(pAutonoteTXT_Raw, "\r"); | |
1154 | |
1155 for (i=0; i<195; ++i) | |
1156 { | |
1157 test_string = strtok(NULL, "\r") + 1; | |
1158 break_loop = false; | |
1159 decode_step=0; | |
1160 do | |
1161 { | |
1162 c = *(unsigned char*)test_string; | |
1163 temp_str_len = 0; | |
1164 while((c!='\t')&&(c>0)) | |
1165 { | |
1166 ++temp_str_len; | |
1167 c=test_string[temp_str_len]; | |
1168 } | |
1169 tmp_pos=test_string+temp_str_len; | |
1170 if (*tmp_pos == 0) | |
1171 break_loop = true; | |
1172 *tmp_pos = 0; | |
1173 if (temp_str_len) | |
1174 { | |
1175 switch (decode_step) | |
1176 { | |
1177 case 1: | |
1178 pAutonoteTxt[i].pText=RemoveQuotes(test_string); | |
1179 break; | |
1180 case 2: | |
1181 { | |
1104 | 1182 if ( !_stricmp(test_string, "potion")) |
251 | 1183 { |
1184 pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE; | |
1185 break; | |
1186 } | |
1104 | 1187 if ( !_stricmp(test_string, "stat") ) |
251 | 1188 { |
1189 pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT; | |
1190 break; | |
1191 } | |
1104 | 1192 if ( !_stricmp(test_string, "seer") ) |
251 | 1193 { |
1194 pAutonoteTxt[i].eType = AUTONOTE_SEER; | |
1195 break; | |
1196 } | |
1104 | 1197 if ( !_stricmp(test_string, "obelisk") ) |
251 | 1198 { |
1199 pAutonoteTxt[i].eType = AUTONOTE_OBELISK; | |
1200 break; | |
1201 } | |
1104 | 1202 if ( !_stricmp(test_string, "teacher") ) |
251 | 1203 { |
1204 pAutonoteTxt[i].eType = AUTONOTE_TEACHER; | |
1205 break; | |
1206 } | |
1207 pAutonoteTxt[i].eType =AUTONOTE_MISC; | |
1208 break; | |
1209 } | |
1210 } | |
1211 } | |
1212 else | |
1213 { | |
1214 break_loop = true; | |
1215 } | |
1216 ++decode_step; | |
1217 test_string=tmp_pos+1; | |
1218 } while ((decode_step<3)&&!break_loop); | |
1219 } | |
1220 } | |
1221 | |
1222 | |
1223 //----- (004768A9) -------------------------------------------------------- | |
1224 void __cdecl InitializeQuests() | |
1225 { | |
1226 int i; | |
1227 char* test_string; | |
1228 unsigned char c; | |
1229 bool break_loop; | |
1230 unsigned int temp_str_len; | |
1231 char* tmp_pos; | |
1232 int decode_step; | |
1233 | |
1234 if ( pQuestsTXT_Raw ) | |
1235 pAllocator->FreeChunk(pQuestsTXT_Raw); | |
1236 pQuestsTXT_Raw = NULL; | |
1237 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0); | |
1238 strtok(pQuestsTXT_Raw, "\r"); | |
1239 | |
1240 for (i=0; i<512; ++i) | |
1241 { | |
1242 test_string = strtok(NULL, "\r") + 1; | |
1243 break_loop = false; | |
1244 decode_step=0; | |
1245 do | |
1246 { | |
1247 c = *(unsigned char*)test_string; | |
1248 temp_str_len = 0; | |
1249 while((c!='\t')&&(c>0)) | |
1250 { | |
1251 ++temp_str_len; | |
1252 c=test_string[temp_str_len]; | |
1253 } | |
1254 tmp_pos=test_string+temp_str_len; | |
1255 if (*tmp_pos == 0) | |
1256 break_loop = true; | |
1257 *tmp_pos = 0; | |
1258 if (temp_str_len) | |
1259 { | |
1260 if ( decode_step == 1) | |
1261 pQuestTable[i] =RemoveQuotes(test_string); | |
1262 } | |
1263 else | |
1264 { | |
1265 break_loop = true; | |
1266 } | |
1267 ++decode_step; | |
1268 test_string=tmp_pos+1; | |
1269 } while ((decode_step<2)&&!break_loop); | |
1270 } | |
1271 } | |
1272 |