annotate Chest.cpp @ 402:74205b91647b

Слияние
author Ritor1
date Sat, 23 Feb 2013 15:10:34 +0600
parents 9c0607679772
children 80a5aab68b67
rev   line source
0
Ritor1
parents:
diff changeset
1 #include <stdio.h>
Ritor1
parents:
diff changeset
2
Ritor1
parents:
diff changeset
3 #include "Chest.h"
Ritor1
parents:
diff changeset
4 #include "FrameTableInc.h"
Ritor1
parents:
diff changeset
5 #include "Allocator.h"
Ritor1
parents:
diff changeset
6
Ritor1
parents:
diff changeset
7 #include "mm7_data.h"
Ritor1
parents:
diff changeset
8
Ritor1
parents:
diff changeset
9
Ritor1
parents:
diff changeset
10
Ritor1
parents:
diff changeset
11
Ritor1
parents:
diff changeset
12 size_t uNumChests; // idb
Ritor1
parents:
diff changeset
13 struct ChestList *pChestList;
Ritor1
parents:
diff changeset
14 Chest pChests[20];
Ritor1
parents:
diff changeset
15
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19
Ritor1
parents:
diff changeset
20 //----- (00458B03) --------------------------------------------------------
Ritor1
parents:
diff changeset
21 void ChestList::ToFile()
Ritor1
parents:
diff changeset
22 {
Ritor1
parents:
diff changeset
23 ChestList *v1; // esi@1
Ritor1
parents:
diff changeset
24 FILE *v2; // eax@1
Ritor1
parents:
diff changeset
25 FILE *v3; // edi@1
Ritor1
parents:
diff changeset
26
Ritor1
parents:
diff changeset
27 v1 = this;
Ritor1
parents:
diff changeset
28 v2 = fopen("data\\dchest.bin", "wb");
Ritor1
parents:
diff changeset
29 v3 = v2;
Ritor1
parents:
diff changeset
30 if ( !v2 )
Ritor1
parents:
diff changeset
31 Abortf("Unable to save dchest.bin!");
Ritor1
parents:
diff changeset
32 fwrite(v1, 4u, 1u, v2);
Ritor1
parents:
diff changeset
33 fwrite(v1->pChests, 0x24u, v1->uNumChests, v3);
Ritor1
parents:
diff changeset
34 fclose(v3);
Ritor1
parents:
diff changeset
35 }
Ritor1
parents:
diff changeset
36
Ritor1
parents:
diff changeset
37
Ritor1
parents:
diff changeset
38 //----- (00458B4F) --------------------------------------------------------
Ritor1
parents:
diff changeset
39 void ChestList::FromFile(void *pSerialized)
Ritor1
parents:
diff changeset
40 {
Ritor1
parents:
diff changeset
41 uNumChests = *(int *)pSerialized;
Ritor1
parents:
diff changeset
42 pChests = (ChestDesc *)pAllocator->AllocNamedChunk(pChests, 36 * uNumChests, "Chest Descrip");
Ritor1
parents:
diff changeset
43 memcpy(pChests, (char *)pSerialized + 4, 36 * uNumChests);
Ritor1
parents:
diff changeset
44 }
Ritor1
parents:
diff changeset
45
Ritor1
parents:
diff changeset
46
Ritor1
parents:
diff changeset
47 //----- (00458B9C) --------------------------------------------------------
Ritor1
parents:
diff changeset
48 int ChestList::FromFileTxt(const char *Args)
Ritor1
parents:
diff changeset
49 {
Ritor1
parents:
diff changeset
50 ChestList *v2; // ebx@1
Ritor1
parents:
diff changeset
51 __int32 v3; // edi@1
Ritor1
parents:
diff changeset
52 FILE *v4; // eax@1
Ritor1
parents:
diff changeset
53 unsigned int v5; // esi@3
Ritor1
parents:
diff changeset
54 const void *v6; // ST18_4@9
Ritor1
parents:
diff changeset
55 void *v7; // eax@9
Ritor1
parents:
diff changeset
56 FILE *v8; // ST0C_4@11
Ritor1
parents:
diff changeset
57 char *i; // eax@11
Ritor1
parents:
diff changeset
58 char v10; // al@14
Ritor1
parents:
diff changeset
59 const char *v11; // ST14_4@14
Ritor1
parents:
diff changeset
60 char v12; // al@14
Ritor1
parents:
diff changeset
61 const char *v13; // ST10_4@14
Ritor1
parents:
diff changeset
62 char Buf; // [sp+8h] [bp-2F0h]@3
Ritor1
parents:
diff changeset
63 FrameTableTxtLine v16; // [sp+1FCh] [bp-FCh]@4
Ritor1
parents:
diff changeset
64 FrameTableTxtLine v17; // [sp+278h] [bp-80h]@4
Ritor1
parents:
diff changeset
65 FILE *File; // [sp+2F4h] [bp-4h]@1
Ritor1
parents:
diff changeset
66 unsigned int Argsa; // [sp+300h] [bp+8h]@3
Ritor1
parents:
diff changeset
67
Ritor1
parents:
diff changeset
68 v2 = this;
Ritor1
parents:
diff changeset
69 pAllocator->FreeChunk(this->pChests);
Ritor1
parents:
diff changeset
70 v3 = 0;
Ritor1
parents:
diff changeset
71 v2->pChests = 0;
Ritor1
parents:
diff changeset
72 v2->uNumChests = 0;
Ritor1
parents:
diff changeset
73 v4 = fopen(Args, "r");
Ritor1
parents:
diff changeset
74 File = v4;
Ritor1
parents:
diff changeset
75 if ( !v4 )
Ritor1
parents:
diff changeset
76 Abortf("ChestDescriptionList::load - Unable to open file: %s.");
Ritor1
parents:
diff changeset
77 v5 = 0;
Ritor1
parents:
diff changeset
78 Argsa = 0;
Ritor1
parents:
diff changeset
79 if ( fgets(&Buf, 490, v4) )
Ritor1
parents:
diff changeset
80 {
Ritor1
parents:
diff changeset
81 do
Ritor1
parents:
diff changeset
82 {
Ritor1
parents:
diff changeset
83 *strchr(&Buf, 10) = 0;
Ritor1
parents:
diff changeset
84 memcpy(&v17, texture_frame_table_txt_parser(&Buf, &v16), sizeof(v17));
Ritor1
parents:
diff changeset
85 if ( v17.field_0 && *v17.pProperties[0] != 47 )
Ritor1
parents:
diff changeset
86 ++Argsa;
Ritor1
parents:
diff changeset
87 }
Ritor1
parents:
diff changeset
88 while ( fgets(&Buf, 490, File) );
Ritor1
parents:
diff changeset
89 v5 = Argsa;
Ritor1
parents:
diff changeset
90 v3 = 0;
Ritor1
parents:
diff changeset
91 }
Ritor1
parents:
diff changeset
92 v6 = v2->pChests;
Ritor1
parents:
diff changeset
93 v2->uNumChests = v5;
Ritor1
parents:
diff changeset
94 v7 = pAllocator->AllocNamedChunk(v6, 36 * v5, "Chest Descrip");
Ritor1
parents:
diff changeset
95 v2->pChests = (ChestDesc *)v7;
Ritor1
parents:
diff changeset
96 if ( v7 == (void *)v3 )
Ritor1
parents:
diff changeset
97 Abortf("ChestDescriptionList::load - Out of Memory!");
Ritor1
parents:
diff changeset
98 memset(v7, v3, 36 * v2->uNumChests);
Ritor1
parents:
diff changeset
99 v8 = File;
Ritor1
parents:
diff changeset
100 v2->uNumChests = v3;
Ritor1
parents:
diff changeset
101 fseek(v8, v3, v3);
Ritor1
parents:
diff changeset
102 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
Ritor1
parents:
diff changeset
103 {
Ritor1
parents:
diff changeset
104 *strchr(&Buf, 10) = 0;
Ritor1
parents:
diff changeset
105 memcpy(&v17, texture_frame_table_txt_parser(&Buf, &v16), sizeof(v17));
Ritor1
parents:
diff changeset
106 if ( v17.field_0 && *v17.pProperties[0] != 47 )
Ritor1
parents:
diff changeset
107 {
Ritor1
parents:
diff changeset
108 strcpy(v2->pChests[v2->uNumChests].pName, v17.pProperties[0]);
Ritor1
parents:
diff changeset
109 v10 = atoi(v17.pProperties[1]);
Ritor1
parents:
diff changeset
110 v11 = v17.pProperties[2];
Ritor1
parents:
diff changeset
111 v2->pChests[v2->uNumChests].uWidth = v10;
Ritor1
parents:
diff changeset
112 v12 = atoi(v11);
Ritor1
parents:
diff changeset
113 v13 = v17.pProperties[3];
Ritor1
parents:
diff changeset
114 v2->pChests[v2->uNumChests].uHeight = v12;
Ritor1
parents:
diff changeset
115 v2->pChests[v2->uNumChests++].uTextureID = atoi(v13);
Ritor1
parents:
diff changeset
116 }
Ritor1
parents:
diff changeset
117 }
Ritor1
parents:
diff changeset
118 fclose(File);
Ritor1
parents:
diff changeset
119 return 1;
Ritor1
parents:
diff changeset
120 }