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 {
|
|
86 IconFrame *frame; // eax@12
|
|
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 )
|
|
105 pRenderer->DrawTextureIndexed(394, 288, &pIcons_LOD->pTextures[frame->uTextureID]);
|
|
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 }
|
2541
|
115 // 4E28F8: using guessed type int current_screen_type;
|
2496
|
116 // 50C994: using guessed type int dword_50C994;
|
|
117 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
|
|
118
|
|
119
|
|
120 //----- (00458D97) --------------------------------------------------------
|
|
121 void OverlayList::InitializeSprites()
|
|
122 {
|
|
123 for (uint i = 0; i < uNumOverlays; ++i)
|
|
124 pSpriteFrameTable->InitializeSprite(pOverlays[i].uSpriteFramesetID);
|
|
125 }
|
|
126
|
|
127 //----- (00458DBC) --------------------------------------------------------
|
|
128 void OverlayList::ToFile()
|
|
129 {
|
|
130 FILE *v2; // eax@1
|
|
131 //FILE *v3; // edi@1
|
|
132
|
|
133 v2 = fopen("data\\doverlay.bin", "wb");
|
|
134 //v3 = v2;
|
|
135 if ( !v2 )
|
|
136 Error("Unable to save doverlay.bin!");
|
|
137 fwrite(this, 4, 1, v2);
|
|
138 fwrite(this->pOverlays, 8, this->uNumOverlays, v2);
|
|
139 fclose(v2);
|
|
140 }
|
|
141
|
|
142 //----- (00458E08) --------------------------------------------------------
|
|
143 void OverlayList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
|
|
144 {
|
|
145 uint num_mm6_overlays = data_mm6 ? *(int *)data_mm6 : 0,
|
|
146 num_mm7_overlays = data_mm7 ? *(int *)data_mm7 : 0,
|
|
147 num_mm8_overlays = data_mm8 ? *(int *)data_mm8 : 0;
|
|
148
|
|
149 uNumOverlays = num_mm6_overlays + num_mm7_overlays + num_mm8_overlays;
|
|
150 Assert(uNumOverlays);
|
|
151 Assert(!num_mm8_overlays);
|
|
152
|
|
153 pOverlays = (OverlayDesc *)malloc(uNumOverlays * sizeof(OverlayDesc));
|
|
154 memcpy(pOverlays, (char *)data_mm7 + 4, num_mm7_overlays * sizeof(OverlayDesc));
|
|
155 memcpy(pOverlays + num_mm7_overlays, (char *)data_mm6 + 4, num_mm6_overlays * sizeof(OverlayDesc));
|
|
156 memcpy(pOverlays + num_mm6_overlays + num_mm7_overlays, (char *)data_mm8 + 4, num_mm8_overlays * sizeof(OverlayDesc));
|
|
157 }
|
|
158
|
|
159 //----- (00458E4F) --------------------------------------------------------
|
|
160 bool OverlayList::FromFileTxt(const char *Args)
|
|
161 {
|
|
162 __int32 v3; // edi@1
|
|
163 FILE *v4; // eax@1
|
|
164 unsigned int v5; // esi@3
|
|
165 void *v7; // eax@9
|
|
166 //FILE *v8; // ST0C_4@11
|
|
167 char *i; // eax@11
|
|
168 char Buf; // [sp+10h] [bp-2F0h]@3
|
|
169 FrameTableTxtLine v18; // [sp+204h] [bp-FCh]@4
|
|
170 FrameTableTxtLine v19; // [sp+280h] [bp-80h]@4
|
|
171 FILE *File; // [sp+2FCh] [bp-4h]@1
|
|
172 unsigned int Argsa; // [sp+308h] [bp+8h]@3
|
|
173
|
|
174 free(this->pOverlays);
|
|
175 v3 = 0;
|
|
176 this->pOverlays = nullptr;
|
|
177 this->uNumOverlays = 0;
|
|
178 v4 = fopen(Args, "r");
|
|
179 File = v4;
|
|
180 if ( !v4 )
|
|
181 Error("ObjectDescriptionList::load - Unable to open file: %s.");
|
|
182
|
|
183 v5 = 0;
|
|
184 Argsa = 0;
|
|
185 if ( fgets(&Buf, 490, v4) )
|
|
186 {
|
|
187 do
|
|
188 {
|
|
189 *strchr(&Buf, 10) = 0;
|
|
190 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
|
|
191 if ( v19.uPropCount && *v19.pProperties[0] != 47 )
|
|
192 ++Argsa;
|
|
193 }
|
|
194 while ( fgets(&Buf, 490, File) );
|
|
195 v5 = Argsa;
|
|
196 v3 = 0;
|
|
197 }
|
|
198 this->uNumOverlays = v5;
|
|
199 v7 = malloc(8 * v5);
|
|
200 this->pOverlays = (OverlayDesc *)v7;
|
|
201 if ( v7 == (void *)v3 )
|
|
202 Error("OverlayDescriptionList::load - Out of Memory!");
|
|
203
|
|
204 memset(v7, v3, 8 * this->uNumOverlays);
|
|
205 //v8 = File;
|
|
206 this->uNumOverlays = v3;
|
|
207 fseek(File, v3, v3);
|
|
208 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
|
|
209 {
|
|
210 *strchr(&Buf, 10) = 0;
|
|
211 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
|
|
212 if ( v19.uPropCount && *v19.pProperties[0] != 47 )
|
|
213 {
|
|
214 this->pOverlays[this->uNumOverlays].uOverlayID = atoi(v19.pProperties[0]);
|
|
215 if ( _stricmp(v19.pProperties[1], "center") )
|
|
216 {
|
|
217 if ( !_stricmp(v19.pProperties[1], "transparent") )
|
|
218 this->pOverlays[this->uNumOverlays].uOverlayType = 2;
|
|
219 else
|
|
220 this->pOverlays[this->uNumOverlays].uOverlayType = 1;
|
|
221 }
|
|
222 else
|
|
223 this->pOverlays[this->uNumOverlays].uOverlayType = 0;
|
|
224 this->pOverlays[this->uNumOverlays++].uSpriteFramesetID = pSpriteFrameTable->FastFindSprite((char *)v19.pProperties[2]);
|
|
225 }
|
|
226 }
|
|
227 fclose(File);
|
|
228 return 1;
|
|
229 }
|
|
230
|
|
231 //----- (0045855F) --------------------------------------------------------
|
|
232 void OtherOverlay::Reset()
|
|
233 {
|
|
234 this->field_0 = 0;
|
|
235 this->field_2 = 0;
|
|
236 this->field_4 = 0;
|
|
237 this->field_6 = 0;
|
|
238 this->field_8 = 0;
|
|
239 this->field_A = 0;
|
|
240 this->field_C = 0;
|
|
241 this->field_E = 0;
|
|
242 this->field_10 = 65536;
|
|
243 }
|
|
244
|
|
245 //----- (004584B8) --------------------------------------------------------
|
|
246 OtherOverlay::OtherOverlay()
|
|
247 {
|
|
248 this->field_0 = 0;
|
|
249 this->field_2 = 0;
|
|
250 this->field_4 = 0;
|
|
251 this->field_6 = 0;
|
|
252 this->field_8 = 0;
|
|
253 this->field_A = 0;
|
|
254 this->field_C = 0;
|
|
255 this->field_E = 0;
|
|
256 this->field_10 = 65536;
|
|
257 } |