2499
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
2541
|
6
|
|
7 #include "Engine/Engine.h"
|
|
8
|
2499
|
9 #include "IconFrameTable.h"
|
|
10 #include "../LOD.h"
|
|
11 #include "FrameTableInc.h"
|
|
12
|
|
13 //----- (00494F3A) --------------------------------------------------------
|
|
14 unsigned int IconFrameTable::FindIcon(const char *pIconName)
|
|
15 {
|
|
16 for ( uint i = 0; i < (signed int)this->uNumIcons; i++ )
|
|
17 {
|
|
18 if ( !_stricmp(pIconName, this->pIcons[i].pAnimationName) )
|
|
19 return i;
|
|
20 }
|
|
21 return 0;
|
|
22 }
|
|
23
|
|
24 //----- (00494F70) --------------------------------------------------------
|
|
25 IconFrame *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int uFrameID)
|
|
26 {
|
|
27 int v6; // edx@3
|
|
28 uint i;
|
|
29
|
|
30 if ( this->pIcons[uIconID].uFlags & 1 && this->pIcons[uIconID].uAnimLength != 0 )
|
|
31 {
|
|
32 v6 = ((signed int)uFrameID >> 3) % (unsigned __int16)this->pIcons[uIconID].uAnimLength;
|
|
33 for ( i = uIconID; v6 > this->pIcons[i].uAnimTime; i++ )
|
|
34 v6 -= this->pIcons[i].uAnimTime;
|
|
35 return &this->pIcons[i];
|
|
36 }
|
|
37 else
|
|
38 return &this->pIcons[uIconID];
|
|
39 }
|
|
40
|
|
41 //----- (00494FBF) --------------------------------------------------------
|
|
42 void IconFrameTable::InitializeAnimation(unsigned int uIconID)
|
|
43 {
|
|
44 if ( uIconID && (signed int)uIconID <= (signed int)this->uNumIcons )
|
|
45 {
|
|
46 for ( uint i = uIconID; ; ++i )
|
|
47 {
|
|
48 this->pIcons[i].uTextureID = pIcons_LOD->LoadTexture(this->pIcons[i].pTextureName, TEXTURE_16BIT_PALETTE);
|
|
49 if ( !(this->pIcons[i].uFlags & 1) )
|
|
50 break;
|
|
51 }
|
|
52 }
|
|
53 }
|
|
54
|
|
55 //----- (0049500A) --------------------------------------------------------
|
|
56 void IconFrameTable::ToFile()
|
|
57 {
|
|
58 //IconFrameTable *v1; // esi@1
|
|
59 FILE *v2; // eax@1
|
|
60 //FILE *v3; // edi@1
|
|
61
|
|
62 //IconFrameTable* Str = this;
|
|
63
|
|
64 //v1 = Str;
|
|
65 v2 = fopen("data\\dift.bin", "wb");
|
|
66 //v3 = v2;
|
|
67 if ( !v2 )
|
|
68 Error("Unable to save dift.bin!");
|
|
69 fwrite(this, 4, 1, v2);
|
|
70 fwrite(this->pIcons, 0x20u, this->uNumIcons, v2);
|
|
71 fclose(v2);
|
|
72 }
|
|
73
|
|
74 //----- (00495056) --------------------------------------------------------
|
|
75 void IconFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
|
|
76 {
|
|
77 uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0,
|
|
78 num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0,
|
|
79 num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0;
|
|
80
|
|
81 uNumIcons = num_mm6_frames + num_mm7_frames + num_mm8_frames;
|
|
82 Assert(uNumIcons);
|
|
83 Assert(!num_mm8_frames);
|
|
84
|
|
85 pIcons = (IconFrame *)malloc(uNumIcons * sizeof(IconFrame));
|
|
86 memcpy(pIcons, (char *)data_mm7 + 4, num_mm7_frames * sizeof(IconFrame));
|
|
87 memcpy(pIcons + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(IconFrame));
|
|
88 memcpy(pIcons + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(IconFrame));
|
|
89 }
|
|
90
|
|
91 //----- (0049509D) --------------------------------------------------------
|
|
92 int IconFrameTable::FromFileTxt(const char *Args)
|
|
93 {
|
|
94 //IconFrameTable *v2; // ebx@1
|
|
95 FILE *v3; // eax@1
|
|
96 int v4; // esi@3
|
|
97 void *v5; // eax@10
|
|
98 FILE *v6; // ST0C_4@12
|
|
99 char *i; // eax@12
|
|
100 const char *v8; // ST00_4@15
|
|
101 int v9; // eax@16
|
|
102 int v10; // edx@20
|
|
103 int v11; // ecx@21
|
|
104 int v12; // eax@22
|
|
105 signed int j; // edx@25
|
|
106 IconFrame *v14; // ecx@26
|
|
107 int v15; // esi@26
|
|
108 int k; // eax@27
|
|
109 signed int result; // eax@11
|
|
110 char Buf; // [sp+Ch] [bp-2F8h]@3
|
|
111 FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4
|
|
112 FrameTableTxtLine v20; // [sp+27Ch] [bp-88h]@4
|
|
113 int v21; // [sp+2F8h] [bp-Ch]@3
|
|
114 int v22; // [sp+2FCh] [bp-8h]@3
|
|
115 FILE *File; // [sp+300h] [bp-4h]@1
|
|
116 int Argsa; // [sp+30Ch] [bp+8h]@26
|
|
117
|
|
118 //v2 = this;
|
|
119 //TileTable::dtor((TileTable *)this);
|
|
120 __debugbreak();//Ritor1: this function not used
|
|
121 v3 = fopen(Args, "r");
|
|
122 File = v3;
|
|
123 if ( !v3 )
|
|
124 Error("IconFrameTable::load - Unable to open file: %s.", Args);
|
|
125 v4 = 0;
|
|
126 v21 = 0;
|
|
127 v22 = 1;
|
|
128 if ( fgets(&Buf, 490, v3) )
|
|
129 {
|
|
130 do
|
|
131 {
|
|
132 *strchr(&Buf, 10) = 0;
|
|
133 memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20));
|
|
134 if ( v20.uPropCount && *v20.pProperties[0] != 47 )
|
|
135 {
|
|
136 if ( v20.uPropCount < 3 )
|
|
137 Error("IconFrameTable::loadText, too few arguments, %s line %i.", Args, v22);
|
|
138 ++v21;
|
|
139 }
|
|
140 ++v22;
|
|
141 }
|
|
142 while ( fgets(&Buf, 490, File) );
|
|
143 v4 = v21;
|
|
144 }
|
|
145 this->uNumIcons = v4;
|
|
146 v5 = malloc(32 * v4);//, "I Frames");
|
|
147 this->pIcons = (IconFrame *)v5;
|
|
148 if ( v5 )
|
|
149 {
|
|
150 v6 = File;
|
|
151 this->uNumIcons = 0;
|
|
152 fseek(v6, 0, 0);
|
|
153 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
|
|
154 {
|
|
155 *strchr(&Buf, 10) = 0;
|
|
156 memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20));
|
|
157 if ( v20.uPropCount && *v20.pProperties[0] != 47 )
|
|
158 {
|
|
159 strcpy(this->pIcons[this->uNumIcons].pAnimationName, v20.pProperties[0]);
|
|
160 strcpy(this->pIcons[this->uNumIcons].pTextureName, v20.pProperties[1]);
|
|
161 v8 = v20.pProperties[2];
|
|
162 this->pIcons[this->uNumIcons].uFlags = 0;
|
|
163 if ( !_stricmp(v8, "new") )
|
|
164 {
|
|
165 v9 = (int)&this->pIcons[this->uNumIcons].uFlags;
|
|
166 *(char *)v9 |= 4u;
|
|
167 }
|
|
168 this->pIcons[this->uNumIcons].uAnimTime = atoi(v20.pProperties[3]);
|
|
169 this->pIcons[this->uNumIcons].uAnimLength = 0;
|
|
170 this->pIcons[this->uNumIcons++].uTextureID = 0;
|
|
171 }
|
|
172 }
|
|
173 fclose(File);
|
|
174 v10 = 0;
|
|
175 if ( (signed int)(this->uNumIcons - 1) > 0 )
|
|
176 {
|
|
177 v11 = 0;
|
|
178 do
|
|
179 {
|
|
180 v12 = (int)&this->pIcons[v11];
|
|
181 if ( !(*(char *)(v12 + 60) & 4) )
|
|
182 *(char *)(v12 + 28) |= 1u;
|
|
183 ++v10;
|
|
184 ++v11;
|
|
185 }
|
|
186 while ( v10 < (signed int)(this->uNumIcons - 1) );
|
|
187 }
|
|
188 for ( j = 0; j < (signed int)this->uNumIcons; *(short *)(Argsa + 26) = v15 )
|
|
189 {
|
|
190 v14 = this->pIcons;
|
|
191 Argsa = (int)&v14[j];
|
|
192 v15 = *(short *)(Argsa + 24);
|
|
193 if ( *(char *)(Argsa + 28) & 1 )
|
|
194 {
|
|
195 ++j;
|
|
196 for ( k = (int)&v14[j]; *(char *)(k + 28) & 1; k += 32 )
|
|
197 {
|
|
198 v15 += *(short *)(k + 24);
|
|
199 ++j;
|
|
200 }
|
|
201 LOWORD(v15) = v14[j].uAnimTime + v15;
|
|
202 }
|
|
203 ++j;
|
|
204 }
|
|
205 result = 1;
|
|
206 }
|
|
207 else
|
|
208 {
|
|
209 fclose(File);
|
|
210 result = 0;
|
|
211 }
|
|
212 return result;
|
|
213 }
|
|
214 //----- (0042EB78) --------------------------------------------------------
|
|
215 int IconFrameTable::GetIconAnimLength(unsigned int uIconID)
|
|
216 {
|
|
217 return 8 * this->pIcons[uIconID].uAnimLength;
|
|
218 } |