Mercurial > mm7
annotate IconFrameTable.cpp @ 1808:4002c0fe5efc
Слияние
author | Ritor1 |
---|---|
date | Mon, 07 Oct 2013 09:31:32 +0600 |
parents | 75fafd8ced59 |
children | c1c74df0a33e |
rev | line source |
---|---|
1295 | 1 #include "IconFrameTable.h" |
2 #include "LOD.h" | |
3 #include "mm7_data.h" | |
4 #include "FrameTableInc.h" | |
5 | |
6 //----- (00494F3A) -------------------------------------------------------- | |
7 unsigned int IconFrameTable::FindIcon(const char *pIconName) | |
8 { | |
9 IconFrameTable *v2; // esi@1 | |
10 int v3; // ebx@1 | |
11 unsigned int uID; // edi@1 | |
12 unsigned int result; // eax@4 | |
13 | |
14 v2 = this; | |
15 v3 = 0; | |
16 uID = 0; | |
17 if ( (signed int)this->uNumIcons <= 0 ) | |
18 { | |
19 LABEL_4: | |
20 result = 0; | |
21 } | |
22 else | |
23 { | |
24 while ( _stricmp(pIconName, v2->pIcons[v3].pAnimationName) ) | |
25 { | |
26 ++uID; | |
27 ++v3; | |
28 if ( (signed int)uID >= (signed int)v2->uNumIcons ) | |
29 goto LABEL_4; | |
30 } | |
31 result = uID; | |
32 } | |
33 return result; | |
34 } | |
35 | |
36 //----- (00494F70) -------------------------------------------------------- | |
37 IconFrame *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int uFrameID) | |
38 { | |
39 IconFrame *v3; // edi@1 | |
40 IconFrame *v4; // ecx@1 | |
41 __int16 v5; // dx@2 | |
42 int v6; // edx@3 | |
43 unsigned int v7; // eax@3 | |
44 char *i; // ecx@3 | |
45 int v9; // esi@5 | |
46 IconFrame *result; // eax@6 | |
47 | |
48 v3 = this->pIcons; | |
49 v4 = &v3[uIconID]; | |
50 if ( v4->uFlags & 1 && (v5 = v4->uAnimLength) != 0 ) | |
51 { | |
52 v6 = ((signed int)uFrameID >> 3) % (unsigned __int16)v5; | |
53 v7 = uIconID; | |
54 for ( i = (char *)&v4->uAnimTime; ; i += 32 ) | |
55 { | |
56 v9 = *(short *)i; | |
57 if ( v6 <= v9 ) | |
58 break; | |
59 v6 -= v9; | |
60 ++v7; | |
61 } | |
62 result = &v3[v7]; | |
63 } | |
64 else | |
65 { | |
66 result = &v3[uIconID]; | |
67 } | |
68 return result; | |
69 } | |
70 | |
71 //----- (00494FBF) -------------------------------------------------------- | |
72 void IconFrameTable::InitializeAnimation(unsigned int uIconID) | |
73 { | |
74 IconFrameTable *v2; // esi@1 | |
75 unsigned int v3; // edi@3 | |
76 const char *i; // eax@3 | |
77 IconFrame *v5; // eax@5 | |
78 | |
79 v2 = this; | |
80 if ( (signed int)uIconID <= (signed int)this->uNumIcons && (uIconID & 0x80000000u) == 0 ) | |
81 { | |
82 v3 = uIconID; | |
83 for ( i = this->pIcons[uIconID].pTextureName; ; i = v5[v3].pTextureName ) | |
84 { | |
85 v2->pIcons[v3].uTextureID = pIcons_LOD->LoadTexture(i, TEXTURE_16BIT_PALETTE); | |
86 v5 = v2->pIcons; | |
87 if ( !(v5[v3].uFlags & 1) ) | |
88 break; | |
89 ++v3; | |
90 } | |
91 } | |
92 } | |
93 | |
94 //----- (0049500A) -------------------------------------------------------- | |
95 void IconFrameTable::ToFile() | |
96 { | |
97 IconFrameTable *v1; // esi@1 | |
98 FILE *v2; // eax@1 | |
99 FILE *v3; // edi@1 | |
100 | |
101 auto Str = this; | |
102 | |
103 v1 = Str; | |
104 v2 = fopen("data\\dift.bin", "wb"); | |
105 v3 = v2; | |
106 if ( !v2 ) | |
1545 | 107 Error("Unable to save dift.bin!"); |
1295 | 108 fwrite(v1, 4u, 1u, v2); |
109 fwrite(v1->pIcons, 0x20u, v1->uNumIcons, v3); | |
110 fclose(v3); | |
111 } | |
112 | |
113 //----- (00495056) -------------------------------------------------------- | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
114 void IconFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) |
1295 | 115 { |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
116 uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
117 num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
118 num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
119 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
120 uNumIcons = num_mm6_frames + num_mm7_frames + num_mm8_frames; |
1545 | 121 Assert(uNumIcons); |
122 Assert(!num_mm8_frames); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
123 |
1583 | 124 pIcons = (IconFrame *)malloc(uNumIcons * sizeof(IconFrame)); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
125 memcpy(pIcons, (char *)data_mm7 + 4, num_mm7_frames * sizeof(IconFrame)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
126 memcpy(pIcons + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(IconFrame)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1296
diff
changeset
|
127 memcpy(pIcons + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(IconFrame)); |
1295 | 128 } |
129 | |
130 //----- (0049509D) -------------------------------------------------------- | |
131 int IconFrameTable::FromFileTxt(const char *Args) | |
132 { | |
133 IconFrameTable *v2; // ebx@1 | |
134 FILE *v3; // eax@1 | |
135 int v4; // esi@3 | |
136 void *v5; // eax@10 | |
137 FILE *v6; // ST0C_4@12 | |
138 char *i; // eax@12 | |
139 const char *v8; // ST00_4@15 | |
140 int v9; // eax@16 | |
141 int v10; // edx@20 | |
142 int v11; // ecx@21 | |
143 int v12; // eax@22 | |
144 signed int j; // edx@25 | |
145 IconFrame *v14; // ecx@26 | |
146 int v15; // esi@26 | |
147 int k; // eax@27 | |
148 signed int result; // eax@11 | |
149 char Buf; // [sp+Ch] [bp-2F8h]@3 | |
150 FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4 | |
151 FrameTableTxtLine v20; // [sp+27Ch] [bp-88h]@4 | |
152 int v21; // [sp+2F8h] [bp-Ch]@3 | |
153 int v22; // [sp+2FCh] [bp-8h]@3 | |
154 FILE *File; // [sp+300h] [bp-4h]@1 | |
155 int Argsa; // [sp+30Ch] [bp+8h]@26 | |
156 | |
157 v2 = this; | |
158 //TileTable::dtor((TileTable *)this); | |
159 v3 = fopen(Args, "r"); | |
160 File = v3; | |
161 if ( !v3 ) | |
1545 | 162 Error("IconFrameTable::load - Unable to open file: %s.", Args); |
1295 | 163 v4 = 0; |
164 v21 = 0; | |
165 v22 = 1; | |
166 if ( fgets(&Buf, 490, v3) ) | |
167 { | |
168 do | |
169 { | |
170 *strchr(&Buf, 10) = 0; | |
171 memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); | |
172 if ( v20.uPropCount && *v20.pProperties[0] != 47 ) | |
173 { | |
174 if ( v20.uPropCount < 3 ) | |
1545 | 175 Error("IconFrameTable::loadText, too few arguments, %s line %i.", Args, v22); |
1295 | 176 ++v21; |
177 } | |
178 ++v22; | |
179 } | |
180 while ( fgets(&Buf, 490, File) ); | |
181 v4 = v21; | |
182 } | |
183 v2->uNumIcons = v4; | |
1583 | 184 v5 = malloc(32 * v4);//, "I Frames"); |
1295 | 185 v2->pIcons = (IconFrame *)v5; |
186 if ( v5 ) | |
187 { | |
188 v6 = File; | |
189 v2->uNumIcons = 0; | |
190 fseek(v6, 0, 0); | |
191 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | |
192 { | |
193 *strchr(&Buf, 10) = 0; | |
194 memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); | |
195 if ( v20.uPropCount && *v20.pProperties[0] != 47 ) | |
196 { | |
197 strcpy(v2->pIcons[v2->uNumIcons].pAnimationName, v20.pProperties[0]); | |
198 strcpy(v2->pIcons[v2->uNumIcons].pTextureName, v20.pProperties[1]); | |
199 v8 = v20.pProperties[2]; | |
200 v2->pIcons[v2->uNumIcons].uFlags = 0; | |
201 if ( !_stricmp(v8, "new") ) | |
202 { | |
203 v9 = (int)&v2->pIcons[v2->uNumIcons].uFlags; | |
204 *(char *)v9 |= 4u; | |
205 } | |
206 v2->pIcons[v2->uNumIcons].uAnimTime = atoi(v20.pProperties[3]); | |
207 v2->pIcons[v2->uNumIcons].uAnimLength = 0; | |
208 v2->pIcons[v2->uNumIcons++].uTextureID = 0; | |
209 } | |
210 } | |
211 fclose(File); | |
212 v10 = 0; | |
213 if ( (signed int)(v2->uNumIcons - 1) > 0 ) | |
214 { | |
215 v11 = 0; | |
216 do | |
217 { | |
218 v12 = (int)&v2->pIcons[v11]; | |
219 if ( !(*(char *)(v12 + 60) & 4) ) | |
220 *(char *)(v12 + 28) |= 1u; | |
221 ++v10; | |
222 ++v11; | |
223 } | |
224 while ( v10 < (signed int)(v2->uNumIcons - 1) ); | |
225 } | |
226 for ( j = 0; j < (signed int)v2->uNumIcons; *(short *)(Argsa + 26) = v15 ) | |
227 { | |
228 v14 = v2->pIcons; | |
229 Argsa = (int)&v14[j]; | |
230 v15 = *(short *)(Argsa + 24); | |
231 if ( *(char *)(Argsa + 28) & 1 ) | |
232 { | |
233 ++j; | |
234 for ( k = (int)&v14[j]; *(char *)(k + 28) & 1; k += 32 ) | |
235 { | |
236 v15 += *(short *)(k + 24); | |
237 ++j; | |
238 } | |
239 LOWORD(v15) = v14[j].uAnimTime + v15; | |
240 } | |
241 ++j; | |
242 } | |
243 result = 1; | |
244 } | |
245 else | |
246 { | |
247 fclose(File); | |
248 result = 0; | |
249 } | |
250 return result; | |
1296 | 251 } |
252 //----- (0042EB78) -------------------------------------------------------- | |
253 int IconFrameTable::GetIconAnimLength(unsigned int uIconID) | |
254 { | |
255 return 8 * this->pIcons[uIconID].uAnimLength; | |
1295 | 256 } |