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