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