2496
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5
|
|
6 #define _CRT_SECURE_NO_WARNINGS
|
|
7 #include <stdlib.h>
|
2541
|
8 #include "Engine/Engine.h"
|
2496
|
9
|
|
10 #include "Overlays.h"
|
|
11 #include "Sprites.h"
|
2499
|
12 #include "../Tables/FrameTableInc.h"
|
|
13 #include "../Tables/IconFrameTable.h"
|
|
14 #include "../Timer.h"
|
|
15 #include "../Party.h"
|
|
16 #include "../TurnEngine/TurnEngine.h"
|
|
17 #include "../LOD.h"
|
2496
|
18 #include "Render.h"
|
2502
|
19 #include "GUI/GUIWindow.h"
|
2496
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25 struct OtherOverlayList *pOtherOverlayList = new OtherOverlayList; // idb
|
|
26 struct OverlayList *pOverlayList = new OverlayList;
|
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33 // inlined
|
|
34 //----- (mm6c::0045BD50) --------------------------------------------------
|
|
35 void OtherOverlayList::Reset()
|
|
36 {
|
|
37 for (uint i = 0; i < 50; ++i)
|
|
38 pOverlays[i].Reset();
|
|
39 }
|
|
40
|
|
41 //----- (004418B1) --------------------------------------------------------
|
|
42 int OtherOverlayList::_4418B1(int a2, int a3, int a4, int a5)
|
|
43 {
|
|
44 return 0;
|
|
45 }
|
|
46
|
|
47 //----- (004418B6) --------------------------------------------------------
|
|
48 int OtherOverlayList::_4418B6(int uOverlayID, __int16 a3, int a4, int a5, __int16 a6)
|
|
49 {
|
|
50 signed int v9; // esi@6
|
|
51 __int16 v11; // dx@11
|
|
52
|
|
53 for ( uint i = 0; i < 50; ++i )
|
|
54 {
|
|
55 if ( this->pOverlays[i].field_6 <= 0 )
|
|
56 {
|
|
57 this->pOverlays[i].field_0 = 0;
|
|
58 this->pOverlays[i].field_A = 0;
|
|
59 this->pOverlays[i].field_8 = 0;
|
|
60 this->pOverlays[i].field_C = a3;
|
|
61 v9 = 0;
|
|
62 for ( v9; v9 < (signed int)pOverlayList->uNumOverlays; ++v9 )
|
|
63 {
|
|
64 if ( uOverlayID == pOverlayList->pOverlays[v9].uOverlayID )
|
|
65 break;
|
|
66 }
|
|
67 this->pOverlays[i].field_2 = v9;
|
|
68 this->pOverlays[i].field_4 = 0;
|
|
69 if ( a4 )
|
|
70 v11 = a4;
|
|
71 else
|
|
72 v11 = 8 * pSpriteFrameTable->pSpriteSFrames[pOverlayList->pOverlays[v9].uSpriteFramesetID].uAnimLength;
|
|
73 this->pOverlays[i].field_6 = v11;
|
|
74 this->pOverlays[i].field_10 = a5;
|
|
75 this->pOverlays[i].field_E = a6;
|
|
76 bRedraw = true;
|
|
77 return true;
|
|
78 }
|
|
79 }
|
|
80 return 0;
|
|
81 }
|
|
82
|
|
83 //----- (00441964) --------------------------------------------------------
|
|
84 void OtherOverlayList::DrawTurnBasedIcon(int a2)
|
|
85 {
|
2575
|
86 Icon *frame; // eax@12
|
2496
|
87 unsigned int v5; // [sp-8h] [bp-Ch]@4
|
|
88
|
2541
|
89 if ( current_screen_type != SCREEN_GAME || !pParty->bTurnBasedModeOn)
|
2496
|
90 return;
|
|
91
|
|
92 if ( pTurnEngine->turn_stage == TE_MOVEMENT )//все персы отстрелялись(сжатый кулак)
|
|
93 frame = pIconsFrameTable->GetFrame(pIconIDs_Turn[5 - pTurnEngine->uActionPointsLeft / 26], pEventTimer->uStartTime);
|
|
94 else if ( pTurnEngine->turn_stage == TE_WAIT )
|
|
95 {
|
|
96 if ( dword_50C998_turnbased_icon_1A )
|
|
97 v5 = uIconID_TurnStart;//анимация руки(запуск пошагового режима)
|
|
98 else
|
|
99 v5 = uIconID_TurnHour; //группа ожидает(часы)
|
|
100 frame = pIconsFrameTable->GetFrame(v5, dword_50C994);
|
|
101 }
|
|
102 else if ( pTurnEngine->turn_stage == TE_ATTACK )//группа атакует(ладонь)
|
|
103 frame = pIconsFrameTable->GetFrame(uIconID_TurnStop, pEventTimer->uStartTime);
|
|
104 //if ( pRenderer->pRenderD3D )
|
2575
|
105 pRenderer->DrawTextureAlphaNew(394/640.0f, 288/480.0f, frame->texture);
|
2496
|
106 /*else
|
2524
|
107 pRenderer->DrawTextureIndexedAlpha(0x18Au, 0x120u, v7);*/
|
2496
|
108 if ( dword_50C994 < dword_50C998_turnbased_icon_1A )
|
|
109 {
|
|
110 dword_50C994 += pEventTimer->uTimeElapsed;
|
|
111 if ( (signed int)dword_50C994 >= dword_50C998_turnbased_icon_1A )
|
|
112 dword_50C998_turnbased_icon_1A = 0;
|
|
113 }
|
|
114 }
|
|
115
|
|
116
|
|
117 //----- (00458D97) --------------------------------------------------------
|
|
118 void OverlayList::InitializeSprites()
|
|
119 {
|
|
120 for (uint i = 0; i < uNumOverlays; ++i)
|
|
121 pSpriteFrameTable->InitializeSprite(pOverlays[i].uSpriteFramesetID);
|
|
122 }
|
|
123
|
|
124 //----- (00458DBC) --------------------------------------------------------
|
|
125 void OverlayList::ToFile()
|
|
126 {
|
|
127 FILE *v2; // eax@1
|
|
128 //FILE *v3; // edi@1
|
|
129
|
|
130 v2 = fopen("data\\doverlay.bin", "wb");
|
|
131 //v3 = v2;
|
|
132 if ( !v2 )
|
|
133 Error("Unable to save doverlay.bin!");
|
|
134 fwrite(this, 4, 1, v2);
|
|
135 fwrite(this->pOverlays, 8, this->uNumOverlays, v2);
|
|
136 fclose(v2);
|
|
137 }
|
|
138
|
|
139 //----- (00458E08) --------------------------------------------------------
|
|
140 void OverlayList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
|
|
141 {
|
|
142 uint num_mm6_overlays = data_mm6 ? *(int *)data_mm6 : 0,
|
|
143 num_mm7_overlays = data_mm7 ? *(int *)data_mm7 : 0,
|
|
144 num_mm8_overlays = data_mm8 ? *(int *)data_mm8 : 0;
|
|
145
|
|
146 uNumOverlays = num_mm6_overlays + num_mm7_overlays + num_mm8_overlays;
|
|
147 Assert(uNumOverlays);
|
|
148 Assert(!num_mm8_overlays);
|
|
149
|
|
150 pOverlays = (OverlayDesc *)malloc(uNumOverlays * sizeof(OverlayDesc));
|
|
151 memcpy(pOverlays, (char *)data_mm7 + 4, num_mm7_overlays * sizeof(OverlayDesc));
|
|
152 memcpy(pOverlays + num_mm7_overlays, (char *)data_mm6 + 4, num_mm6_overlays * sizeof(OverlayDesc));
|
|
153 memcpy(pOverlays + num_mm6_overlays + num_mm7_overlays, (char *)data_mm8 + 4, num_mm8_overlays * sizeof(OverlayDesc));
|
|
154 }
|
|
155
|
|
156 //----- (00458E4F) --------------------------------------------------------
|
|
157 bool OverlayList::FromFileTxt(const char *Args)
|
|
158 {
|
|
159 __int32 v3; // edi@1
|
|
160 FILE *v4; // eax@1
|
|
161 unsigned int v5; // esi@3
|
|
162 void *v7; // eax@9
|
|
163 //FILE *v8; // ST0C_4@11
|
|
164 char *i; // eax@11
|
|
165 char Buf; // [sp+10h] [bp-2F0h]@3
|
|
166 FrameTableTxtLine v18; // [sp+204h] [bp-FCh]@4
|
|
167 FrameTableTxtLine v19; // [sp+280h] [bp-80h]@4
|
|
168 FILE *File; // [sp+2FCh] [bp-4h]@1
|
|
169 unsigned int Argsa; // [sp+308h] [bp+8h]@3
|
|
170
|
|
171 free(this->pOverlays);
|
|
172 v3 = 0;
|
|
173 this->pOverlays = nullptr;
|
|
174 this->uNumOverlays = 0;
|
|
175 v4 = fopen(Args, "r");
|
|
176 File = v4;
|
|
177 if ( !v4 )
|
|
178 Error("ObjectDescriptionList::load - Unable to open file: %s.");
|
|
179
|
|
180 v5 = 0;
|
|
181 Argsa = 0;
|
|
182 if ( fgets(&Buf, 490, v4) )
|
|
183 {
|
|
184 do
|
|
185 {
|
|
186 *strchr(&Buf, 10) = 0;
|
|
187 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
|
|
188 if ( v19.uPropCount && *v19.pProperties[0] != 47 )
|
|
189 ++Argsa;
|
|
190 }
|
|
191 while ( fgets(&Buf, 490, File) );
|
|
192 v5 = Argsa;
|
|
193 v3 = 0;
|
|
194 }
|
|
195 this->uNumOverlays = v5;
|
|
196 v7 = malloc(8 * v5);
|
|
197 this->pOverlays = (OverlayDesc *)v7;
|
|
198 if ( v7 == (void *)v3 )
|
|
199 Error("OverlayDescriptionList::load - Out of Memory!");
|
|
200
|
|
201 memset(v7, v3, 8 * this->uNumOverlays);
|
|
202 //v8 = File;
|
|
203 this->uNumOverlays = v3;
|
|
204 fseek(File, v3, v3);
|
|
205 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
|
|
206 {
|
|
207 *strchr(&Buf, 10) = 0;
|
|
208 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
|
|
209 if ( v19.uPropCount && *v19.pProperties[0] != 47 )
|
|
210 {
|
|
211 this->pOverlays[this->uNumOverlays].uOverlayID = atoi(v19.pProperties[0]);
|
|
212 if ( _stricmp(v19.pProperties[1], "center") )
|
|
213 {
|
|
214 if ( !_stricmp(v19.pProperties[1], "transparent") )
|
|
215 this->pOverlays[this->uNumOverlays].uOverlayType = 2;
|
|
216 else
|
|
217 this->pOverlays[this->uNumOverlays].uOverlayType = 1;
|
|
218 }
|
|
219 else
|
|
220 this->pOverlays[this->uNumOverlays].uOverlayType = 0;
|
|
221 this->pOverlays[this->uNumOverlays++].uSpriteFramesetID = pSpriteFrameTable->FastFindSprite((char *)v19.pProperties[2]);
|
|
222 }
|
|
223 }
|
|
224 fclose(File);
|
|
225 return 1;
|
|
226 }
|
|
227
|
|
228 //----- (0045855F) --------------------------------------------------------
|
|
229 void OtherOverlay::Reset()
|
|
230 {
|
|
231 this->field_0 = 0;
|
|
232 this->field_2 = 0;
|
|
233 this->field_4 = 0;
|
|
234 this->field_6 = 0;
|
|
235 this->field_8 = 0;
|
|
236 this->field_A = 0;
|
|
237 this->field_C = 0;
|
|
238 this->field_E = 0;
|
|
239 this->field_10 = 65536;
|
|
240 }
|
|
241
|
|
242 //----- (004584B8) --------------------------------------------------------
|
|
243 OtherOverlay::OtherOverlay()
|
|
244 {
|
|
245 this->field_0 = 0;
|
|
246 this->field_2 = 0;
|
|
247 this->field_4 = 0;
|
|
248 this->field_6 = 0;
|
|
249 this->field_8 = 0;
|
|
250 this->field_A = 0;
|
|
251 this->field_C = 0;
|
|
252 this->field_E = 0;
|
|
253 this->field_10 = 65536;
|
|
254 } |