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