annotate Overlays.cpp @ 788:f004c7ceb7bd

Слияние
author Ritor1
date Mon, 25 Mar 2013 02:21:14 +0600
parents b27dd658ea77
children 5d5c78088274
rev   line source
0
Ritor1
parents:
diff changeset
1 #include <stdlib.h>
Ritor1
parents:
diff changeset
2
Ritor1
parents:
diff changeset
3 #include "Overlays.h"
Ritor1
parents:
diff changeset
4 #include "Sprites.h"
Ritor1
parents:
diff changeset
5 #include "FrameTableInc.h"
Ritor1
parents:
diff changeset
6 #include "Allocator.h"
Ritor1
parents:
diff changeset
7 #include "IconFrameTable.h"
Ritor1
parents:
diff changeset
8 #include "Time.h"
Ritor1
parents:
diff changeset
9 #include "Party.h"
Ritor1
parents:
diff changeset
10 #include "TurnEngine.h"
Ritor1
parents:
diff changeset
11 #include "LOD.h"
Ritor1
parents:
diff changeset
12 #include "Render.h"
569
f451efdb7c8b * Party buff icons drawing (right panel)
Nomad
parents: 472
diff changeset
13 #include "GUIWindow.h"
0
Ritor1
parents:
diff changeset
14
Ritor1
parents:
diff changeset
15 #include "mm7_data.h"
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
Ritor1
parents:
diff changeset
21 struct OtherOverlayList *pOtherOverlayList = new OtherOverlayList; // idb
Ritor1
parents:
diff changeset
22 struct OverlayList *pOverlayList = new OverlayList;
Ritor1
parents:
diff changeset
23
Ritor1
parents:
diff changeset
24
Ritor1
parents:
diff changeset
25
Ritor1
parents:
diff changeset
26
Ritor1
parents:
diff changeset
27
Ritor1
parents:
diff changeset
28
783
b27dd658ea77 Taveling by foot fixed.
Nomad
parents: 703
diff changeset
29 // inlined
b27dd658ea77 Taveling by foot fixed.
Nomad
parents: 703
diff changeset
30 //----- (mm6c::0045BD50) --------------------------------------------------
b27dd658ea77 Taveling by foot fixed.
Nomad
parents: 703
diff changeset
31 void OtherOverlayList::Reset()
b27dd658ea77 Taveling by foot fixed.
Nomad
parents: 703
diff changeset
32 {
b27dd658ea77 Taveling by foot fixed.
Nomad
parents: 703
diff changeset
33 for (uint i = 0; i < 50; ++i)
b27dd658ea77 Taveling by foot fixed.
Nomad
parents: 703
diff changeset
34 pOverlays[i].Reset();
b27dd658ea77 Taveling by foot fixed.
Nomad
parents: 703
diff changeset
35 }
0
Ritor1
parents:
diff changeset
36
Ritor1
parents:
diff changeset
37 //----- (004418B1) --------------------------------------------------------
Ritor1
parents:
diff changeset
38 int OtherOverlayList::_4418B1(int a2, int a3, int a4, int a5)
Ritor1
parents:
diff changeset
39 {
Ritor1
parents:
diff changeset
40 return 0;
Ritor1
parents:
diff changeset
41 }
Ritor1
parents:
diff changeset
42
Ritor1
parents:
diff changeset
43 //----- (004418B6) --------------------------------------------------------
Ritor1
parents:
diff changeset
44 int OtherOverlayList::_4418B6(int uOverlayID, __int16 a3, int a4, int a5, __int16 a6)
Ritor1
parents:
diff changeset
45 {
Ritor1
parents:
diff changeset
46 signed int v6; // edx@1
Ritor1
parents:
diff changeset
47 OtherOverlayList *v7; // eax@1
142
8b8fd4d83fdc Various things here and there
Nomad
parents: 0
diff changeset
48 //signed int result; // eax@4
0
Ritor1
parents:
diff changeset
49 signed int v9; // esi@6
Ritor1
parents:
diff changeset
50 __int16 v10; // dx@9
Ritor1
parents:
diff changeset
51 __int16 v11; // dx@11
Ritor1
parents:
diff changeset
52
Ritor1
parents:
diff changeset
53 v6 = 0;
Ritor1
parents:
diff changeset
54 v7 = this;
Ritor1
parents:
diff changeset
55 while ( v7->pOverlays[0].field_6 > 0 )
Ritor1
parents:
diff changeset
56 {
Ritor1
parents:
diff changeset
57 ++v6;
Ritor1
parents:
diff changeset
58 v7 = (OtherOverlayList *)((char *)v7 + 20);
Ritor1
parents:
diff changeset
59 if ( v6 >= 50 )
Ritor1
parents:
diff changeset
60 return 0;
Ritor1
parents:
diff changeset
61 }
Ritor1
parents:
diff changeset
62 v7->pOverlays[0].field_0 = 0;
Ritor1
parents:
diff changeset
63 v7->pOverlays[0].field_A = 0;
Ritor1
parents:
diff changeset
64 v7->pOverlays[0].field_8 = 0;
Ritor1
parents:
diff changeset
65 v7->pOverlays[0].field_C = a3;
Ritor1
parents:
diff changeset
66 v9 = 0;
Ritor1
parents:
diff changeset
67 if ( (signed int)pOverlayList->uNumOverlays <= 0 )
Ritor1
parents:
diff changeset
68 {
Ritor1
parents:
diff changeset
69 LABEL_9:
Ritor1
parents:
diff changeset
70 v10 = 0;
Ritor1
parents:
diff changeset
71 }
Ritor1
parents:
diff changeset
72 else
Ritor1
parents:
diff changeset
73 {
Ritor1
parents:
diff changeset
74 while ( uOverlayID != pOverlayList->pOverlays[v9].uOverlayID )
Ritor1
parents:
diff changeset
75 {
Ritor1
parents:
diff changeset
76 ++v9;
Ritor1
parents:
diff changeset
77 if ( v9 >= (signed int)pOverlayList->uNumOverlays )
Ritor1
parents:
diff changeset
78 goto LABEL_9;
Ritor1
parents:
diff changeset
79 }
Ritor1
parents:
diff changeset
80 v10 = v9;
Ritor1
parents:
diff changeset
81 }
Ritor1
parents:
diff changeset
82 v7->pOverlays[0].field_2 = v10;
Ritor1
parents:
diff changeset
83 v7->pOverlays[0].field_4 = 0;
Ritor1
parents:
diff changeset
84 if ( a4 )
Ritor1
parents:
diff changeset
85 v11 = a4;
Ritor1
parents:
diff changeset
86 else
Ritor1
parents:
diff changeset
87 v11 = 8 * pSpriteFrameTable->pSpriteSFrames[pOverlayList->pOverlays[v10].uSpriteFramesetID].uAnimLength;
Ritor1
parents:
diff changeset
88 v7->pOverlays[0].field_6 = v11;
Ritor1
parents:
diff changeset
89 v7->pOverlays[0].field_10 = a5;
Ritor1
parents:
diff changeset
90 v7->pOverlays[0].field_E = a6;
142
8b8fd4d83fdc Various things here and there
Nomad
parents: 0
diff changeset
91
8b8fd4d83fdc Various things here and there
Nomad
parents: 0
diff changeset
92 bRedraw = true;
8b8fd4d83fdc Various things here and there
Nomad
parents: 0
diff changeset
93 return true;
0
Ritor1
parents:
diff changeset
94 }
Ritor1
parents:
diff changeset
95
Ritor1
parents:
diff changeset
96 //----- (00441964) --------------------------------------------------------
569
f451efdb7c8b * Party buff icons drawing (right panel)
Nomad
parents: 472
diff changeset
97 void OtherOverlayList::DrawTurnBasedIcon(int a2)
0
Ritor1
parents:
diff changeset
98 {
Ritor1
parents:
diff changeset
99 unsigned int result; // eax@1
Ritor1
parents:
diff changeset
100 IconFrameTable *v3; // ecx@6
Ritor1
parents:
diff changeset
101 void *v4; // eax@12
Ritor1
parents:
diff changeset
102 unsigned int v5; // [sp-8h] [bp-Ch]@4
Ritor1
parents:
diff changeset
103 int v6; // [sp-4h] [bp-8h]@4
Ritor1
parents:
diff changeset
104 Texture *v7; // [sp-4h] [bp-8h]@14
Ritor1
parents:
diff changeset
105
569
f451efdb7c8b * Party buff icons drawing (right panel)
Nomad
parents: 472
diff changeset
106 if ( pCurrentScreen != SCREEN_GAME || !pParty->bTurnBasedModeOn)
f451efdb7c8b * Party buff icons drawing (right panel)
Nomad
parents: 472
diff changeset
107 return;
f451efdb7c8b * Party buff icons drawing (right panel)
Nomad
parents: 472
diff changeset
108
0
Ritor1
parents:
diff changeset
109 if ( pTurnEngine->field_4 == 3 )
Ritor1
parents:
diff changeset
110 {
Ritor1
parents:
diff changeset
111 v6 = pEventTimer->uStartTime;
Ritor1
parents:
diff changeset
112 v5 = pIconIDs_Turn[5 - pTurnEngine->uActionPointsLeft / 26];
Ritor1
parents:
diff changeset
113 }
Ritor1
parents:
diff changeset
114 else
Ritor1
parents:
diff changeset
115 {
Ritor1
parents:
diff changeset
116 if ( pTurnEngine->field_4 == 1 )
Ritor1
parents:
diff changeset
117 {
Ritor1
parents:
diff changeset
118 v6 = dword_50C994;
Ritor1
parents:
diff changeset
119 v3 = pIconsFrameTable;
Ritor1
parents:
diff changeset
120 if ( dword_50C998_turnbased_icon_1A )
Ritor1
parents:
diff changeset
121 v5 = uIconID_TurnStart;
Ritor1
parents:
diff changeset
122 else
Ritor1
parents:
diff changeset
123 v5 = uIconID_TurnHour;
Ritor1
parents:
diff changeset
124 goto LABEL_12;
Ritor1
parents:
diff changeset
125 }
Ritor1
parents:
diff changeset
126 if ( pTurnEngine->field_4 != 2 )
Ritor1
parents:
diff changeset
127 {
Ritor1
parents:
diff changeset
128 v4 = this;
Ritor1
parents:
diff changeset
129 goto LABEL_14;
Ritor1
parents:
diff changeset
130 }
Ritor1
parents:
diff changeset
131 v6 = pEventTimer->uStartTime;
Ritor1
parents:
diff changeset
132 v5 = uIconID_TurnStop;
Ritor1
parents:
diff changeset
133 }
Ritor1
parents:
diff changeset
134 v3 = pIconsFrameTable;
Ritor1
parents:
diff changeset
135 LABEL_12:
Ritor1
parents:
diff changeset
136 v4 = pIconsFrameTable->GetFrame(v5, v6);
Ritor1
parents:
diff changeset
137 LABEL_14:
Ritor1
parents:
diff changeset
138 v7 = &pIcons_LOD->pTextures[*((short *)v4 + 15)];
Ritor1
parents:
diff changeset
139 if ( pRenderer->pRenderD3D )
Ritor1
parents:
diff changeset
140 pRenderer->DrawTextureIndexed(0x18Au, 0x120u, v7);
Ritor1
parents:
diff changeset
141 else
Ritor1
parents:
diff changeset
142 pRenderer->DrawTextureTransparent(0x18Au, 0x120u, v7);
Ritor1
parents:
diff changeset
143 result = dword_50C994;
Ritor1
parents:
diff changeset
144 if ( dword_50C994 < dword_50C998_turnbased_icon_1A )
Ritor1
parents:
diff changeset
145 {
Ritor1
parents:
diff changeset
146 result = pEventTimer->uTimeElapsed + dword_50C994;
Ritor1
parents:
diff changeset
147 dword_50C994 = result;
Ritor1
parents:
diff changeset
148 if ( (signed int)result >= dword_50C998_turnbased_icon_1A )
Ritor1
parents:
diff changeset
149 dword_50C998_turnbased_icon_1A = 0;
Ritor1
parents:
diff changeset
150 }
Ritor1
parents:
diff changeset
151 }
Ritor1
parents:
diff changeset
152 // 4E28F8: using guessed type int pCurrentScreen;
Ritor1
parents:
diff changeset
153 // 50C994: using guessed type int dword_50C994;
Ritor1
parents:
diff changeset
154 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
Ritor1
parents:
diff changeset
155
Ritor1
parents:
diff changeset
156
Ritor1
parents:
diff changeset
157 //----- (00458D97) --------------------------------------------------------
Ritor1
parents:
diff changeset
158 void OverlayList::InitializeSprites()
Ritor1
parents:
diff changeset
159 {
472
7dfe960c323c BLV_UpdateDoors
Nomad
parents: 142
diff changeset
160 for (uint i = 0; i < uNumOverlays; ++i)
7dfe960c323c BLV_UpdateDoors
Nomad
parents: 142
diff changeset
161 pSpriteFrameTable->InitializeSprite(pOverlays[i].uSpriteFramesetID);
0
Ritor1
parents:
diff changeset
162 }
Ritor1
parents:
diff changeset
163
Ritor1
parents:
diff changeset
164 //----- (00458DBC) --------------------------------------------------------
Ritor1
parents:
diff changeset
165 void OverlayList::ToFile()
Ritor1
parents:
diff changeset
166 {
Ritor1
parents:
diff changeset
167 OverlayList *v1; // esi@1
Ritor1
parents:
diff changeset
168 FILE *v2; // eax@1
Ritor1
parents:
diff changeset
169 FILE *v3; // edi@1
Ritor1
parents:
diff changeset
170
Ritor1
parents:
diff changeset
171 v1 = this;
Ritor1
parents:
diff changeset
172 v2 = fopen("data\\doverlay.bin", "wb");
Ritor1
parents:
diff changeset
173 v3 = v2;
Ritor1
parents:
diff changeset
174 if ( !v2 )
Ritor1
parents:
diff changeset
175 Abortf("Unable to save doverlay.bin!");
Ritor1
parents:
diff changeset
176 fwrite(v1, 4u, 1u, v2);
Ritor1
parents:
diff changeset
177 fwrite(v1->pOverlays, 8u, v1->uNumOverlays, v3);
Ritor1
parents:
diff changeset
178 fclose(v3);
Ritor1
parents:
diff changeset
179 }
Ritor1
parents:
diff changeset
180
Ritor1
parents:
diff changeset
181 //----- (00458E08) --------------------------------------------------------
Ritor1
parents:
diff changeset
182 void OverlayList::FromFile(void *pSerialized)
Ritor1
parents:
diff changeset
183 {
Ritor1
parents:
diff changeset
184 uNumOverlays = *(int *)pSerialized;
Ritor1
parents:
diff changeset
185 pOverlays = (OverlayDesc *)pAllocator->AllocNamedChunk(pOverlays, 8 * uNumOverlays, "Ovl Des.");
Ritor1
parents:
diff changeset
186 memcpy(pOverlays, (char *)pSerialized + 4, 8 * uNumOverlays);
Ritor1
parents:
diff changeset
187 }
Ritor1
parents:
diff changeset
188
Ritor1
parents:
diff changeset
189 //----- (00458E4F) --------------------------------------------------------
Ritor1
parents:
diff changeset
190 bool OverlayList::FromFileTxt(const char *Args)
Ritor1
parents:
diff changeset
191 {
Ritor1
parents:
diff changeset
192 OverlayList *v2; // ebx@1
Ritor1
parents:
diff changeset
193 __int32 v3; // edi@1
Ritor1
parents:
diff changeset
194 FILE *v4; // eax@1
Ritor1
parents:
diff changeset
195 unsigned int v5; // esi@3
Ritor1
parents:
diff changeset
196 const void *v6; // ST18_4@9
Ritor1
parents:
diff changeset
197 void *v7; // eax@9
Ritor1
parents:
diff changeset
198 FILE *v8; // ST0C_4@11
Ritor1
parents:
diff changeset
199 char *i; // eax@11
Ritor1
parents:
diff changeset
200 unsigned __int16 v10; // ax@14
Ritor1
parents:
diff changeset
201 const char *v11; // ST1C_4@14
Ritor1
parents:
diff changeset
202 int v12; // eax@16
Ritor1
parents:
diff changeset
203 OverlayDesc *v13; // ecx@16
Ritor1
parents:
diff changeset
204 char v14; // zf@16
Ritor1
parents:
diff changeset
205 unsigned int v15; // eax@16
Ritor1
parents:
diff changeset
206 char Buf; // [sp+10h] [bp-2F0h]@3
Ritor1
parents:
diff changeset
207 FrameTableTxtLine v18; // [sp+204h] [bp-FCh]@4
Ritor1
parents:
diff changeset
208 FrameTableTxtLine v19; // [sp+280h] [bp-80h]@4
Ritor1
parents:
diff changeset
209 FILE *File; // [sp+2FCh] [bp-4h]@1
Ritor1
parents:
diff changeset
210 unsigned int Argsa; // [sp+308h] [bp+8h]@3
Ritor1
parents:
diff changeset
211
Ritor1
parents:
diff changeset
212 v2 = this;
Ritor1
parents:
diff changeset
213 pAllocator->FreeChunk(this->pOverlays);
Ritor1
parents:
diff changeset
214 v3 = 0;
Ritor1
parents:
diff changeset
215 v2->pOverlays = 0;
Ritor1
parents:
diff changeset
216 v2->uNumOverlays = 0;
Ritor1
parents:
diff changeset
217 v4 = fopen(Args, "r");
Ritor1
parents:
diff changeset
218 File = v4;
Ritor1
parents:
diff changeset
219 if ( !v4 )
Ritor1
parents:
diff changeset
220 Abortf("ObjectDescriptionList::load - Unable to open file: %s.");
Ritor1
parents:
diff changeset
221 v5 = 0;
Ritor1
parents:
diff changeset
222 Argsa = 0;
Ritor1
parents:
diff changeset
223 if ( fgets(&Buf, 490, v4) )
Ritor1
parents:
diff changeset
224 {
Ritor1
parents:
diff changeset
225 do
Ritor1
parents:
diff changeset
226 {
Ritor1
parents:
diff changeset
227 *strchr(&Buf, 10) = 0;
703
a9c1fb7483c2 monster parser almost complete.
Gloval
parents: 701
diff changeset
228 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
701
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 569
diff changeset
229 if ( v19.uPropCount && *v19.pProperties[0] != 47 )
0
Ritor1
parents:
diff changeset
230 ++Argsa;
Ritor1
parents:
diff changeset
231 }
Ritor1
parents:
diff changeset
232 while ( fgets(&Buf, 490, File) );
Ritor1
parents:
diff changeset
233 v5 = Argsa;
Ritor1
parents:
diff changeset
234 v3 = 0;
Ritor1
parents:
diff changeset
235 }
Ritor1
parents:
diff changeset
236 v6 = v2->pOverlays;
Ritor1
parents:
diff changeset
237 v2->uNumOverlays = v5;
Ritor1
parents:
diff changeset
238 v7 = pAllocator->AllocNamedChunk(v6, 8 * v5, "Ovl Des.");
Ritor1
parents:
diff changeset
239 v2->pOverlays = (OverlayDesc *)v7;
Ritor1
parents:
diff changeset
240 if ( v7 == (void *)v3 )
Ritor1
parents:
diff changeset
241 Abortf("OverlayDescriptionList::load - Out of Memory!");
Ritor1
parents:
diff changeset
242 memset(v7, v3, 8 * v2->uNumOverlays);
Ritor1
parents:
diff changeset
243 v8 = File;
Ritor1
parents:
diff changeset
244 v2->uNumOverlays = v3;
Ritor1
parents:
diff changeset
245 fseek(v8, v3, v3);
Ritor1
parents:
diff changeset
246 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
Ritor1
parents:
diff changeset
247 {
Ritor1
parents:
diff changeset
248 *strchr(&Buf, 10) = 0;
703
a9c1fb7483c2 monster parser almost complete.
Gloval
parents: 701
diff changeset
249 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
701
d5b16a44d9b3 frame_table parser, new files for UI func
Gloval
parents: 569
diff changeset
250 if ( v19.uPropCount && *v19.pProperties[0] != 47 )
0
Ritor1
parents:
diff changeset
251 {
Ritor1
parents:
diff changeset
252 v10 = atoi(v19.pProperties[0]);
Ritor1
parents:
diff changeset
253 v11 = v19.pProperties[1];
Ritor1
parents:
diff changeset
254 v2->pOverlays[v2->uNumOverlays].uOverlayID = v10;
Ritor1
parents:
diff changeset
255 if ( _strcmpi(v11, "center") )
Ritor1
parents:
diff changeset
256 {
Ritor1
parents:
diff changeset
257 v12 = _strcmpi(v19.pProperties[1], "transparent");
Ritor1
parents:
diff changeset
258 v13 = v2->pOverlays;
Ritor1
parents:
diff changeset
259 v14 = v12 == 0;
Ritor1
parents:
diff changeset
260 v15 = v2->uNumOverlays;
Ritor1
parents:
diff changeset
261 if ( v14 )
Ritor1
parents:
diff changeset
262 v13[v15].uOverlayType = 2;
Ritor1
parents:
diff changeset
263 else
Ritor1
parents:
diff changeset
264 v13[v15].uOverlayType = 1;
Ritor1
parents:
diff changeset
265 }
Ritor1
parents:
diff changeset
266 else
Ritor1
parents:
diff changeset
267 {
Ritor1
parents:
diff changeset
268 v2->pOverlays[v2->uNumOverlays].uOverlayType = 0;
Ritor1
parents:
diff changeset
269 }
Ritor1
parents:
diff changeset
270 v2->pOverlays[v2->uNumOverlays++].uSpriteFramesetID = pSpriteFrameTable->FastFindSprite(
Ritor1
parents:
diff changeset
271 (char *)v19.pProperties[2]);
Ritor1
parents:
diff changeset
272 }
Ritor1
parents:
diff changeset
273 }
Ritor1
parents:
diff changeset
274 fclose(File);
Ritor1
parents:
diff changeset
275 return 1;
Ritor1
parents:
diff changeset
276 }
Ritor1
parents:
diff changeset
277
Ritor1
parents:
diff changeset
278
Ritor1
parents:
diff changeset
279 //----- (0045855F) --------------------------------------------------------
Ritor1
parents:
diff changeset
280 void OtherOverlay::Reset()
Ritor1
parents:
diff changeset
281 {
Ritor1
parents:
diff changeset
282 this->field_10 = 65536;
Ritor1
parents:
diff changeset
283 this->field_A = 0;
Ritor1
parents:
diff changeset
284 this->field_8 = 0;
Ritor1
parents:
diff changeset
285 this->field_6 = 0;
Ritor1
parents:
diff changeset
286 this->field_4 = 0;
Ritor1
parents:
diff changeset
287 this->field_2 = 0;
Ritor1
parents:
diff changeset
288 this->field_C = 0;
Ritor1
parents:
diff changeset
289 this->field_E = 0;
Ritor1
parents:
diff changeset
290 }
Ritor1
parents:
diff changeset
291
Ritor1
parents:
diff changeset
292 //----- (004584B8) --------------------------------------------------------
Ritor1
parents:
diff changeset
293 OtherOverlay::OtherOverlay()
Ritor1
parents:
diff changeset
294 {
Ritor1
parents:
diff changeset
295 this->field_A = 0;
Ritor1
parents:
diff changeset
296 this->field_8 = 0;
Ritor1
parents:
diff changeset
297 this->field_6 = 0;
Ritor1
parents:
diff changeset
298 this->field_4 = 0;
Ritor1
parents:
diff changeset
299 this->field_2 = 0;
Ritor1
parents:
diff changeset
300 this->field_C = 0;
Ritor1
parents:
diff changeset
301 this->field_E = 0;
Ritor1
parents:
diff changeset
302 this->field_10 = 65536;
Ritor1
parents:
diff changeset
303 }