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
|
825
|
388 for ( i = 0; i < 77; ++i )
|
251
|
389 {
|
291
|
390 pProfessionChance[i].uTotalprofChance=0;
|
825
|
391 for ( int ii = 1; ii < 59; ++ii )
|
251
|
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()
|
949
|
961 {
|
251
|
962 int i;
|
|
963 char* test_string;
|
|
964 unsigned char c;
|
|
965 bool break_loop;
|
|
966 unsigned int temp_str_len;
|
|
967 char* tmp_pos;
|
|
968 int decode_step;
|
|
969
|
|
970 if ( pAwardsTXT_Raw )
|
|
971 pAllocator->FreeChunk(pAwardsTXT_Raw);
|
|
972 pAwardsTXT_Raw = NULL;
|
|
973 pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
|
|
974 strtok(pAwardsTXT_Raw, "\r");
|
|
975
|
949
|
976 for (i=1; i<105; ++i)
|
251
|
977 {
|
|
978 test_string = strtok(NULL, "\r") + 1;
|
|
979 break_loop = false;
|
|
980 decode_step=0;
|
|
981 do
|
|
982 {
|
|
983 c = *(unsigned char*)test_string;
|
|
984 temp_str_len = 0;
|
|
985 while((c!='\t')&&(c>0))
|
|
986 {
|
|
987 ++temp_str_len;
|
|
988 c=test_string[temp_str_len];
|
|
989 }
|
|
990 tmp_pos=test_string+temp_str_len;
|
|
991 if (*tmp_pos == 0)
|
|
992 break_loop = true;
|
|
993 *tmp_pos = 0;
|
|
994 if (temp_str_len)
|
|
995 {
|
|
996 if (decode_step==1)
|
|
997 pAwards[i].pText=RemoveQuotes(test_string);
|
|
998 else if (decode_step==2)
|
949
|
999 pAwards[i].uPriority = atoi(test_string);
|
251
|
1000 }
|
|
1001 else
|
|
1002 {
|
|
1003 break_loop = true;
|
|
1004 }
|
|
1005 ++decode_step;
|
|
1006 test_string=tmp_pos+1;
|
|
1007 } while ((decode_step<3)&&!break_loop);
|
|
1008 }
|
|
1009 }
|
|
1010 // 7241C8: using guessed type int dword_7241C8;
|
|
1011
|
|
1012 //----- (004764C2) --------------------------------------------------------
|
|
1013 void InitializeScrolls()
|
|
1014 {
|
|
1015
|
|
1016 int i;
|
|
1017 char* test_string;
|
|
1018 unsigned char c;
|
|
1019 bool break_loop;
|
|
1020 unsigned int temp_str_len;
|
|
1021 char* tmp_pos;
|
|
1022 int decode_step;
|
|
1023
|
|
1024 if ( pScrollsTXT_Raw )
|
|
1025 pAllocator->FreeChunk(pScrollsTXT_Raw);
|
|
1026 pScrollsTXT_Raw = NULL;
|
|
1027 pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0);
|
|
1028 strtok(pScrollsTXT_Raw, "\r");
|
|
1029 for (i=0; i<82; ++i)
|
|
1030 {
|
|
1031 test_string = strtok(NULL, "\r") + 1;
|
|
1032 break_loop = false;
|
|
1033 decode_step=0;
|
|
1034 do
|
|
1035 {
|
|
1036 c = *(unsigned char*)test_string;
|
|
1037 temp_str_len = 0;
|
|
1038 while((c!='\t')&&(c>0))
|
|
1039 {
|
|
1040 ++temp_str_len;
|
|
1041 c=test_string[temp_str_len];
|
|
1042 }
|
|
1043 tmp_pos=test_string+temp_str_len;
|
|
1044 if (*tmp_pos == 0)
|
|
1045 break_loop = true;
|
|
1046 *tmp_pos = 0;
|
|
1047 if (temp_str_len)
|
|
1048 {
|
|
1049 if ( decode_step == 1)
|
|
1050 pScrolls[i]=RemoveQuotes(test_string);
|
|
1051 }
|
|
1052 else
|
|
1053 {
|
|
1054 break_loop = true;
|
|
1055 }
|
|
1056 ++decode_step;
|
|
1057 test_string=tmp_pos+1;
|
|
1058 } while ((decode_step<2)&&!break_loop);
|
|
1059 }
|
|
1060 }
|
|
1061
|
|
1062 //----- (00476590) --------------------------------------------------------
|
|
1063 void InitializeMerchants()
|
|
1064 {
|
|
1065 int i;
|
|
1066 char* test_string;
|
|
1067 unsigned char c;
|
|
1068 bool break_loop;
|
|
1069 unsigned int temp_str_len;
|
|
1070 char* tmp_pos;
|
|
1071 int decode_step;
|
|
1072
|
|
1073 if ( pMerchantsTXT_Raw )
|
|
1074 pAllocator->FreeChunk(pMerchantsTXT_Raw);
|
|
1075 pMerchantsTXT_Raw = NULL;
|
|
1076 pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0);
|
|
1077 strtok(pMerchantsTXT_Raw, "\r");
|
|
1078
|
|
1079 for (i=0; i<7; ++i)
|
|
1080 {
|
|
1081 test_string = strtok(NULL, "\r") + 1;
|
|
1082 break_loop = false;
|
|
1083 decode_step=0;
|
|
1084 do
|
|
1085 {
|
|
1086 c = *(unsigned char*)test_string;
|
|
1087 temp_str_len = 0;
|
|
1088 while((c!='\t')&&(c>0))
|
|
1089 {
|
|
1090 ++temp_str_len;
|
|
1091 c=test_string[temp_str_len];
|
|
1092 }
|
|
1093 tmp_pos=test_string+temp_str_len;
|
|
1094 if (*tmp_pos == 0)
|
|
1095 break_loop = true;
|
|
1096 *tmp_pos = 0;
|
|
1097 if (temp_str_len)
|
|
1098 {
|
|
1099 switch (decode_step)
|
|
1100 {
|
|
1101 case 1:
|
|
1102 pMerchantsBuyPhrases[i]=RemoveQuotes(test_string);
|
|
1103 break;
|
|
1104 case 2:
|
|
1105 pMerchantsSellPhrases[i]=RemoveQuotes(test_string);
|
|
1106 break;
|
|
1107 case 3:
|
|
1108 pMerchantsRepairPhrases[i]=RemoveQuotes(test_string);
|
|
1109 break;
|
|
1110 case 4:
|
|
1111 pMerchantsIdentifyPhrases[i]=RemoveQuotes(test_string);
|
|
1112 break;
|
|
1113 }
|
|
1114 }
|
|
1115 else
|
|
1116 {
|
|
1117 break_loop = true;
|
|
1118 }
|
|
1119 ++decode_step;
|
|
1120 test_string=tmp_pos+1;
|
|
1121 } while ((decode_step<5)&&!break_loop);
|
|
1122 }
|
|
1123
|
|
1124 }
|
|
1125
|
|
1126 //----- (00476682) --------------------------------------------------------
|
|
1127 void InitializeTransitions()
|
|
1128 {
|
|
1129 int i;
|
|
1130 char* test_string;
|
|
1131 unsigned char c;
|
|
1132 bool break_loop;
|
|
1133 unsigned int temp_str_len;
|
|
1134 char* tmp_pos;
|
|
1135 int decode_step;
|
|
1136
|
|
1137 if ( pTransitionsTXT_Raw )
|
|
1138 pAllocator->FreeChunk(pTransitionsTXT_Raw);
|
|
1139 pTransitionsTXT_Raw = NULL;
|
|
1140 pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0);
|
|
1141 strtok(pTransitionsTXT_Raw, "\r");
|
|
1142
|
|
1143 for (i=0; i<464; ++i)
|
|
1144 {
|
|
1145 test_string = strtok(NULL, "\r") + 1;
|
|
1146 break_loop = false;
|
|
1147 decode_step=0;
|
|
1148 do
|
|
1149 {
|
|
1150 c = *(unsigned char*)test_string;
|
|
1151 temp_str_len = 0;
|
|
1152 while((c!='\t')&&(c>0))
|
|
1153 {
|
|
1154 ++temp_str_len;
|
|
1155 c=test_string[temp_str_len];
|
|
1156 }
|
|
1157 tmp_pos=test_string+temp_str_len;
|
|
1158 if (*tmp_pos == 0)
|
|
1159 break_loop = true;
|
|
1160 *tmp_pos = 0;
|
|
1161 if (temp_str_len)
|
|
1162 {
|
|
1163 if ( decode_step == 1)
|
434
|
1164 pTransitionStrings[i + 1]=RemoveQuotes(test_string);
|
251
|
1165 }
|
|
1166 else
|
|
1167 {
|
|
1168 break_loop = true;
|
|
1169 }
|
|
1170 ++decode_step;
|
|
1171 test_string=tmp_pos+1;
|
|
1172 } while ((decode_step<2)&&!break_loop);
|
|
1173 }
|
|
1174 }
|
|
1175
|
|
1176 //----- (00476750) --------------------------------------------------------
|
|
1177 void __cdecl InitializeAutonotes()
|
|
1178 {
|
|
1179 int i;
|
|
1180 char* test_string;
|
|
1181 unsigned char c;
|
|
1182 bool break_loop;
|
|
1183 unsigned int temp_str_len;
|
|
1184 char* tmp_pos;
|
|
1185 int decode_step;
|
|
1186
|
|
1187 if ( pAutonoteTXT_Raw )
|
|
1188 pAllocator->FreeChunk(pAutonoteTXT_Raw);
|
|
1189 pAutonoteTXT_Raw = 0;
|
|
1190 pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0);
|
|
1191 strtok(pAutonoteTXT_Raw, "\r");
|
|
1192
|
|
1193 for (i=0; i<195; ++i)
|
|
1194 {
|
|
1195 test_string = strtok(NULL, "\r") + 1;
|
|
1196 break_loop = false;
|
|
1197 decode_step=0;
|
|
1198 do
|
|
1199 {
|
|
1200 c = *(unsigned char*)test_string;
|
|
1201 temp_str_len = 0;
|
|
1202 while((c!='\t')&&(c>0))
|
|
1203 {
|
|
1204 ++temp_str_len;
|
|
1205 c=test_string[temp_str_len];
|
|
1206 }
|
|
1207 tmp_pos=test_string+temp_str_len;
|
|
1208 if (*tmp_pos == 0)
|
|
1209 break_loop = true;
|
|
1210 *tmp_pos = 0;
|
|
1211 if (temp_str_len)
|
|
1212 {
|
|
1213 switch (decode_step)
|
|
1214 {
|
|
1215 case 1:
|
|
1216 pAutonoteTxt[i].pText=RemoveQuotes(test_string);
|
|
1217 break;
|
|
1218 case 2:
|
|
1219 {
|
|
1220 if ( !_strcmpi(test_string, "potion"))
|
|
1221 {
|
|
1222 pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE;
|
|
1223 break;
|
|
1224 }
|
|
1225 if ( !_strcmpi(test_string, "stat") )
|
|
1226 {
|
|
1227 pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT;
|
|
1228 break;
|
|
1229 }
|
|
1230 if ( !_strcmpi(test_string, "seer") )
|
|
1231 {
|
|
1232 pAutonoteTxt[i].eType = AUTONOTE_SEER;
|
|
1233 break;
|
|
1234 }
|
|
1235 if ( !_strcmpi(test_string, "obelisk") )
|
|
1236 {
|
|
1237 pAutonoteTxt[i].eType = AUTONOTE_OBELISK;
|
|
1238 break;
|
|
1239 }
|
|
1240 if ( !_strcmpi(test_string, "teacher") )
|
|
1241 {
|
|
1242 pAutonoteTxt[i].eType = AUTONOTE_TEACHER;
|
|
1243 break;
|
|
1244 }
|
|
1245 pAutonoteTxt[i].eType =AUTONOTE_MISC;
|
|
1246 break;
|
|
1247 }
|
|
1248 }
|
|
1249 }
|
|
1250 else
|
|
1251 {
|
|
1252 break_loop = true;
|
|
1253 }
|
|
1254 ++decode_step;
|
|
1255 test_string=tmp_pos+1;
|
|
1256 } while ((decode_step<3)&&!break_loop);
|
|
1257 }
|
|
1258 }
|
|
1259
|
|
1260
|
|
1261 //----- (004768A9) --------------------------------------------------------
|
|
1262 void __cdecl InitializeQuests()
|
|
1263 {
|
|
1264 int i;
|
|
1265 char* test_string;
|
|
1266 unsigned char c;
|
|
1267 bool break_loop;
|
|
1268 unsigned int temp_str_len;
|
|
1269 char* tmp_pos;
|
|
1270 int decode_step;
|
|
1271
|
|
1272 if ( pQuestsTXT_Raw )
|
|
1273 pAllocator->FreeChunk(pQuestsTXT_Raw);
|
|
1274 pQuestsTXT_Raw = NULL;
|
|
1275 pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0);
|
|
1276 strtok(pQuestsTXT_Raw, "\r");
|
|
1277
|
|
1278 for (i=0; i<512; ++i)
|
|
1279 {
|
|
1280 test_string = strtok(NULL, "\r") + 1;
|
|
1281 break_loop = false;
|
|
1282 decode_step=0;
|
|
1283 do
|
|
1284 {
|
|
1285 c = *(unsigned char*)test_string;
|
|
1286 temp_str_len = 0;
|
|
1287 while((c!='\t')&&(c>0))
|
|
1288 {
|
|
1289 ++temp_str_len;
|
|
1290 c=test_string[temp_str_len];
|
|
1291 }
|
|
1292 tmp_pos=test_string+temp_str_len;
|
|
1293 if (*tmp_pos == 0)
|
|
1294 break_loop = true;
|
|
1295 *tmp_pos = 0;
|
|
1296 if (temp_str_len)
|
|
1297 {
|
|
1298 if ( decode_step == 1)
|
|
1299 pQuestTable[i] =RemoveQuotes(test_string);
|
|
1300 }
|
|
1301 else
|
|
1302 {
|
|
1303 break_loop = true;
|
|
1304 }
|
|
1305 ++decode_step;
|
|
1306 test_string=tmp_pos+1;
|
|
1307 } while ((decode_step<2)&&!break_loop);
|
|
1308 }
|
|
1309 }
|
|
1310
|