Mercurial > mm7
annotate Overlays.cpp @ 2362:eb136041adf1
some more function shuffling
author | Grumpy7 |
---|---|
date | Thu, 01 May 2014 12:59:27 +0200 |
parents | d6887ee81068 |
children | bddcaf5d5db2 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2242
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
0 | 2 #include <stdlib.h> |
2336 | 3 #include "ErrorHandling.h" |
0 | 4 |
5 #include "Overlays.h" | |
6 #include "Sprites.h" | |
7 #include "FrameTableInc.h" | |
8 #include "IconFrameTable.h" | |
2044 | 9 #include "Timer.h" |
0 | 10 #include "Party.h" |
11 #include "TurnEngine.h" | |
12 #include "LOD.h" | |
13 #include "Render.h" | |
569 | 14 #include "GUIWindow.h" |
0 | 15 |
16 #include "mm7_data.h" | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 struct OtherOverlayList *pOtherOverlayList = new OtherOverlayList; // idb | |
23 struct OverlayList *pOverlayList = new OverlayList; | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
783 | 30 // inlined |
31 //----- (mm6c::0045BD50) -------------------------------------------------- | |
32 void OtherOverlayList::Reset() | |
33 { | |
34 for (uint i = 0; i < 50; ++i) | |
35 pOverlays[i].Reset(); | |
36 } | |
0 | 37 |
38 //----- (004418B1) -------------------------------------------------------- | |
39 int OtherOverlayList::_4418B1(int a2, int a3, int a4, int a5) | |
40 { | |
41 return 0; | |
42 } | |
43 | |
44 //----- (004418B6) -------------------------------------------------------- | |
45 int OtherOverlayList::_4418B6(int uOverlayID, __int16 a3, int a4, int a5, __int16 a6) | |
46 { | |
47 signed int v9; // esi@6 | |
48 __int16 v11; // dx@11 | |
49 | |
2274 | 50 for ( uint i = 0; i < 50; ++i ) |
0 | 51 { |
2274 | 52 if ( this->pOverlays[i].field_6 <= 0 ) |
0 | 53 { |
2274 | 54 this->pOverlays[i].field_0 = 0; |
55 this->pOverlays[i].field_A = 0; | |
56 this->pOverlays[i].field_8 = 0; | |
57 this->pOverlays[i].field_C = a3; | |
58 v9 = 0; | |
59 for ( v9; v9 < (signed int)pOverlayList->uNumOverlays; ++v9 ) | |
60 { | |
61 if ( uOverlayID == pOverlayList->pOverlays[v9].uOverlayID ) | |
62 break; | |
63 } | |
64 this->pOverlays[i].field_2 = v9; | |
65 this->pOverlays[i].field_4 = 0; | |
66 if ( a4 ) | |
67 v11 = a4; | |
68 else | |
69 v11 = 8 * pSpriteFrameTable->pSpriteSFrames[pOverlayList->pOverlays[v9].uSpriteFramesetID].uAnimLength; | |
70 this->pOverlays[i].field_6 = v11; | |
71 this->pOverlays[i].field_10 = a5; | |
72 this->pOverlays[i].field_E = a6; | |
73 bRedraw = true; | |
74 return true; | |
0 | 75 } |
76 } | |
2274 | 77 return 0; |
0 | 78 } |
79 | |
80 //----- (00441964) -------------------------------------------------------- | |
569 | 81 void OtherOverlayList::DrawTurnBasedIcon(int a2) |
0 | 82 { |
2242 | 83 IconFrame *frame; // eax@12 |
0 | 84 unsigned int v5; // [sp-8h] [bp-Ch]@4 |
85 | |
569 | 86 if ( pCurrentScreen != SCREEN_GAME || !pParty->bTurnBasedModeOn) |
87 return; | |
88 | |
2242 | 89 if ( pTurnEngine->turn_stage == TE_MOVEMENT )//все персы отстрелялись(сжатый кулак) |
90 frame = pIconsFrameTable->GetFrame(pIconIDs_Turn[5 - pTurnEngine->uActionPointsLeft / 26], pEventTimer->uStartTime); | |
91 else if ( pTurnEngine->turn_stage == TE_WAIT ) | |
0 | 92 { |
2242 | 93 if ( dword_50C998_turnbased_icon_1A ) |
94 v5 = uIconID_TurnStart;//анимация руки(запуск пошагового режима) | |
95 else | |
96 v5 = uIconID_TurnHour; //группа ожидает(часы) | |
97 frame = pIconsFrameTable->GetFrame(v5, dword_50C994); | |
0 | 98 } |
2242 | 99 else if ( pTurnEngine->turn_stage == TE_ATTACK )//группа атакует(ладонь) |
100 frame = pIconsFrameTable->GetFrame(uIconID_TurnStop, pEventTimer->uStartTime); | |
2154 | 101 //if ( pRenderer->pRenderD3D ) |
2242 | 102 pRenderer->DrawTextureIndexed(394, 288, &pIcons_LOD->pTextures[frame->uTextureID]); |
2154 | 103 /*else |
104 pRenderer->DrawTextureTransparent(0x18Au, 0x120u, v7);*/ | |
0 | 105 if ( dword_50C994 < dword_50C998_turnbased_icon_1A ) |
106 { | |
2242 | 107 dword_50C994 += pEventTimer->uTimeElapsed; |
108 if ( (signed int)dword_50C994 >= dword_50C998_turnbased_icon_1A ) | |
0 | 109 dword_50C998_turnbased_icon_1A = 0; |
110 } | |
111 } | |
112 // 4E28F8: using guessed type int pCurrentScreen; | |
113 // 50C994: using guessed type int dword_50C994; | |
114 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A; | |
115 | |
116 | |
117 //----- (00458D97) -------------------------------------------------------- | |
118 void OverlayList::InitializeSprites() | |
119 { | |
472 | 120 for (uint i = 0; i < uNumOverlays; ++i) |
121 pSpriteFrameTable->InitializeSprite(pOverlays[i].uSpriteFramesetID); | |
0 | 122 } |
123 | |
124 //----- (00458DBC) -------------------------------------------------------- | |
125 void OverlayList::ToFile() | |
126 { | |
127 FILE *v2; // eax@1 | |
2242 | 128 //FILE *v3; // edi@1 |
0 | 129 |
130 v2 = fopen("data\\doverlay.bin", "wb"); | |
2242 | 131 //v3 = v2; |
0 | 132 if ( !v2 ) |
1545 | 133 Error("Unable to save doverlay.bin!"); |
2242 | 134 fwrite(this, 4, 1, v2); |
135 fwrite(this->pOverlays, 8, this->uNumOverlays, v2); | |
136 fclose(v2); | |
0 | 137 } |
138 | |
139 //----- (00458E08) -------------------------------------------------------- | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
140 void OverlayList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) |
0 | 141 { |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
142 uint num_mm6_overlays = data_mm6 ? *(int *)data_mm6 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
143 num_mm7_overlays = data_mm7 ? *(int *)data_mm7 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
144 num_mm8_overlays = data_mm8 ? *(int *)data_mm8 : 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
145 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
146 uNumOverlays = num_mm6_overlays + num_mm7_overlays + num_mm8_overlays; |
1545 | 147 Assert(uNumOverlays); |
148 Assert(!num_mm8_overlays); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
149 |
1583 | 150 pOverlays = (OverlayDesc *)malloc(uNumOverlays * sizeof(OverlayDesc)); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
151 memcpy(pOverlays, (char *)data_mm7 + 4, num_mm7_overlays * sizeof(OverlayDesc)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
152 memcpy(pOverlays + num_mm7_overlays, (char *)data_mm6 + 4, num_mm6_overlays * sizeof(OverlayDesc)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
153 memcpy(pOverlays + num_mm6_overlays + num_mm7_overlays, (char *)data_mm8 + 4, num_mm8_overlays * sizeof(OverlayDesc)); |
0 | 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 | |
2274 | 163 //FILE *v8; // ST0C_4@11 |
0 | 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 | |
1583 | 171 free(this->pOverlays); |
0 | 172 v3 = 0; |
2242 | 173 this->pOverlays = 0; |
174 this->uNumOverlays = 0; | |
0 | 175 v4 = fopen(Args, "r"); |
176 File = v4; | |
177 if ( !v4 ) | |
1545 | 178 Error("ObjectDescriptionList::load - Unable to open file: %s."); |
179 | |
0 | 180 v5 = 0; |
181 Argsa = 0; | |
182 if ( fgets(&Buf, 490, v4) ) | |
183 { | |
184 do | |
185 { | |
186 *strchr(&Buf, 10) = 0; | |
703 | 187 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); |
701 | 188 if ( v19.uPropCount && *v19.pProperties[0] != 47 ) |
0 | 189 ++Argsa; |
190 } | |
191 while ( fgets(&Buf, 490, File) ); | |
192 v5 = Argsa; | |
193 v3 = 0; | |
194 } | |
2242 | 195 this->uNumOverlays = v5; |
1583 | 196 v7 = malloc(8 * v5); |
2242 | 197 this->pOverlays = (OverlayDesc *)v7; |
0 | 198 if ( v7 == (void *)v3 ) |
1545 | 199 Error("OverlayDescriptionList::load - Out of Memory!"); |
200 | |
2242 | 201 memset(v7, v3, 8 * this->uNumOverlays); |
2274 | 202 //v8 = File; |
2242 | 203 this->uNumOverlays = v3; |
2274 | 204 fseek(File, v3, v3); |
0 | 205 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) |
206 { | |
207 *strchr(&Buf, 10) = 0; | |
703 | 208 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); |
701 | 209 if ( v19.uPropCount && *v19.pProperties[0] != 47 ) |
0 | 210 { |
2242 | 211 this->pOverlays[this->uNumOverlays].uOverlayID = atoi(v19.pProperties[0]); |
212 if ( _stricmp(v19.pProperties[1], "center") ) | |
0 | 213 { |
2242 | 214 if ( !_stricmp(v19.pProperties[1], "transparent") ) |
215 this->pOverlays[this->uNumOverlays].uOverlayType = 2; | |
0 | 216 else |
2242 | 217 this->pOverlays[this->uNumOverlays].uOverlayType = 1; |
0 | 218 } |
219 else | |
2242 | 220 this->pOverlays[this->uNumOverlays].uOverlayType = 0; |
2274 | 221 this->pOverlays[this->uNumOverlays++].uSpriteFramesetID = pSpriteFrameTable->FastFindSprite((char *)v19.pProperties[2]); |
0 | 222 } |
223 } | |
224 fclose(File); | |
225 return 1; | |
226 } | |
227 | |
228 //----- (0045855F) -------------------------------------------------------- | |
229 void OtherOverlay::Reset() | |
230 { | |
2228 | 231 this->field_0 = 0; |
232 this->field_2 = 0; | |
233 this->field_4 = 0; | |
234 this->field_6 = 0; | |
0 | 235 this->field_8 = 0; |
2228 | 236 this->field_A = 0; |
0 | 237 this->field_C = 0; |
238 this->field_E = 0; | |
2228 | 239 this->field_10 = 65536; |
0 | 240 } |
241 | |
242 //----- (004584B8) -------------------------------------------------------- | |
243 OtherOverlay::OtherOverlay() | |
244 { | |
2242 | 245 this->field_0 = 0; |
246 this->field_2 = 0; | |
247 this->field_4 = 0; | |
0 | 248 this->field_6 = 0; |
2242 | 249 this->field_8 = 0; |
250 this->field_A = 0; | |
0 | 251 this->field_C = 0; |
252 this->field_E = 0; | |
253 this->field_10 = 65536; | |
254 } |