World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Overlays.cpp
См. документацию.
2 
3 #include "Engine/Engine.h"
4 #include "Engine/LOD.h"
5 #include "Engine/Party.h"
6 #include "Engine/Time.h"
7 
9 
12 
14 
15 #include "GUI/GUIWindow.h"
16 
17 #include "Sprites.h"
18 
21 
22 // inlined
23 //----- (mm6c::0045BD50) --------------------------------------------------
25  for (uint i = 0; i < 50; ++i) pOverlays[i].Reset();
26 }
27 
28 //----- (004418B1) --------------------------------------------------------
29 int OtherOverlayList::_4418B1(int a2, int a3, int a4, int a5) { return 0; }
30 
31 //----- (004418B6) --------------------------------------------------------
32 int OtherOverlayList::_4418B6(int uOverlayID, __int16 a3, int a4, int a5,
33  __int16 a6) {
34  signed int v9; // esi@6
35  __int16 v11; // dx@11
36 
37  for (uint i = 0; i < 50; ++i) {
38  if (this->pOverlays[i].field_6 <= 0) {
39  this->pOverlays[i].field_0 = 0;
40  this->pOverlays[i].screen_space_y = 0;
41  this->pOverlays[i].screen_space_x = 0;
42  this->pOverlays[i].field_C = a3;
43  v9 = 0;
44  for (v9; v9 < (signed int)pOverlayList->uNumOverlays; ++v9) {
45  if (uOverlayID == pOverlayList->pOverlays[v9].uOverlayID) break;
46  }
47  this->pOverlays[i].field_2 = v9;
48  this->pOverlays[i].sprite_frame_time = 0;
49  if (a4)
50  v11 = a4;
51  else
52  v11 = 8 * pSpriteFrameTable
55  .uAnimLength;
56  this->pOverlays[i].field_6 = v11;
57  this->pOverlays[i].field_10 = a5;
58  this->pOverlays[i].field_E = a6;
59  bRedraw = true;
60  return true;
61  }
62  }
63  return 0;
64 }
65 
66 //----- (00441964) --------------------------------------------------------
68  Icon *frame; // eax@12
69  unsigned int v5; // [sp-8h] [bp-Ch]@4
70 
72 
73  if (pTurnEngine->turn_stage == TE_MOVEMENT) { // все персы отстрелялись(сжатый кулак)
74  frame = pIconsFrameTable->GetFrame(
77  } else if (pTurnEngine->turn_stage == TE_WAIT) {
79  v5 = uIconID_TurnStart; //анимация руки(запуск пошагового режима)
80  else
81  v5 = uIconID_TurnHour; //группа ожидает(часы)
83  } else if (pTurnEngine->turn_stage == TE_ATTACK) { //группа атакует(ладонь)
86  }
87  // if ( render->pRenderD3D )
88  render->DrawTextureAlphaNew(394 / 640.0f, 288 / 480.0f,
89  frame->GetTexture());
90  /*else
91  render->DrawTextureIndexedAlpha(0x18Au, 0x120u, v7);*/
96  }
97 }
98 
99 //----- (00458D97) --------------------------------------------------------
101  for (uint i = 0; i < uNumOverlays; ++i)
103 }
104 
105 //----- (00458DBC) --------------------------------------------------------
107  FILE *v2; // eax@1
108  // FILE *v3; // edi@1
109 
110  v2 = fopen("data\\doverlay.bin", "wb");
111  // v3 = v2;
112  if (!v2) Error("Unable to save doverlay.bin!");
113  fwrite(this, 4, 1, v2);
114  fwrite(this->pOverlays, 8, this->uNumOverlays, v2);
115  fclose(v2);
116 }
117 
118 //----- (00458E08) --------------------------------------------------------
119 void OverlayList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) {
120  uint num_mm6_overlays = data_mm6 ? *(int *)data_mm6 : 0,
121  num_mm7_overlays = data_mm7 ? *(int *)data_mm7 : 0,
122  num_mm8_overlays = data_mm8 ? *(int *)data_mm8 : 0;
123 
124  uNumOverlays = num_mm6_overlays + num_mm7_overlays + num_mm8_overlays;
125  Assert(uNumOverlays);
126  Assert(!num_mm8_overlays);
127 
128  pOverlays = (OverlayDesc *)malloc(uNumOverlays * sizeof(OverlayDesc));
129  memcpy(pOverlays, (char *)data_mm7 + 4,
130  num_mm7_overlays * sizeof(OverlayDesc));
131  memcpy(pOverlays + num_mm7_overlays, (char *)data_mm6 + 4,
132  num_mm6_overlays * sizeof(OverlayDesc));
133  memcpy(pOverlays + num_mm6_overlays + num_mm7_overlays,
134  (char *)data_mm8 + 4, num_mm8_overlays * sizeof(OverlayDesc));
135 }
136 
137 //----- (00458E4F) --------------------------------------------------------
138 bool OverlayList::FromFileTxt(const char *Args) {
139  __int32 v3; // edi@1
140  FILE *v4; // eax@1
141  unsigned int v5; // esi@3
142  void *v7; // eax@9
143  // FILE *v8; // ST0C_4@11
144  char *i; // eax@11
145  char Buf; // [sp+10h] [bp-2F0h]@3
146  FrameTableTxtLine v18; // [sp+204h] [bp-FCh]@4
147  FrameTableTxtLine v19; // [sp+280h] [bp-80h]@4
148  FILE *File; // [sp+2FCh] [bp-4h]@1
149  unsigned int Argsa; // [sp+308h] [bp+8h]@3
150 
151  free(this->pOverlays);
152  v3 = 0;
153  this->pOverlays = nullptr;
154  this->uNumOverlays = 0;
155  v4 = fopen(Args, "r");
156  File = v4;
157  if (!v4) Error("ObjectDescriptionList::load - Unable to open file: %s.");
158 
159  v5 = 0;
160  Argsa = 0;
161  if (fgets(&Buf, 490, v4)) {
162  do {
163  *strchr(&Buf, 10) = 0;
164  memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
165  if (v19.uPropCount && *v19.pProperties[0] != 47) ++Argsa;
166  } while (fgets(&Buf, 490, File));
167  v5 = Argsa;
168  v3 = 0;
169  }
170  this->uNumOverlays = v5;
171  v7 = malloc(sizeof(OverlayDesc) * v5);
172  this->pOverlays = (OverlayDesc *)v7;
173  if (v7 == NULL)
174  Error("OverlayDescriptionList::load - Out of Memory!");
175 
176  memset(v7, v3, sizeof(OverlayDesc) * this->uNumOverlays);
177  // v8 = File;
178  this->uNumOverlays = v3;
179  fseek(File, v3, v3);
180  for (i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File)) {
181  *strchr(&Buf, 10) = 0;
182  memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
183  if (v19.uPropCount && *v19.pProperties[0] != 47) {
184  this->pOverlays[this->uNumOverlays].uOverlayID =
185  atoi(v19.pProperties[0]);
186  if (_stricmp(v19.pProperties[1], "center")) {
187  if (!_stricmp(v19.pProperties[1], "transparent"))
188  this->pOverlays[this->uNumOverlays].uOverlayType = 2;
189  else
190  this->pOverlays[this->uNumOverlays].uOverlayType = 1;
191  } else {
192  this->pOverlays[this->uNumOverlays].uOverlayType = 0;
193  }
194  this->pOverlays[this->uNumOverlays++].uSpriteFramesetID =
196  }
197  }
198  fclose(File);
199  return 1;
200 }
201 
202 //----- (0045855F) --------------------------------------------------------
204  this->field_0 = 0;
205  this->field_2 = 0;
206  this->sprite_frame_time = 0;
207  this->field_6 = 0;
208  this->screen_space_x = 0;
209  this->screen_space_y = 0;
210  this->field_C = 0;
211  this->field_E = 0;
212  this->field_10 = 65536;
213 }
214 
215 //----- (004584B8) --------------------------------------------------------
TE_MOVEMENT
@ TE_MOVEMENT
Definition: TurnEngine.h:22
OtherOverlay::field_10
int field_10
Definition: Overlays.h:19
IconFrameTable.h
OverlayDesc::uOverlayID
uint16_t uOverlayID
Definition: Overlays.h:45
TE_ATTACK
@ TE_ATTACK
Definition: TurnEngine.h:21
FrameTableTxtLine::uPropCount
int uPropCount
Definition: FrameTableInc.h:12
FrameTableTxtLine::pProperties
const char * pProperties[30]
Definition: FrameTableInc.h:13
pIconIDs_Turn
std::array< unsigned int, 5 > pIconIDs_Turn
Definition: mm7_data.cpp:570
Timer::uTimeElapsed
unsigned int uTimeElapsed
Definition: Time.h:133
LOD.h
OverlayDesc
Definition: Overlays.h:44
pSpriteFrameTable
struct SpriteFrameTable * pSpriteFrameTable
Definition: Sprites.cpp:22
OverlayList::OverlayList
OverlayList()
Definition: Overlays.h:54
OverlayList::InitializeSprites
void InitializeSprites()
Definition: Overlays.cpp:100
OtherOverlayList::_4418B6
int _4418B6(int uOverlayID, int16_t a3, int a4, int a5, int16_t a6)
Definition: Overlays.cpp:32
OverlayDesc::uSpriteFramesetID
uint16_t uSpriteFramesetID
Definition: Overlays.h:47
pIconsFrameTable
struct IconFrameTable * pIconsFrameTable
Definition: mm7_data.cpp:168
OtherOverlayList::_4418B1
int _4418B1(int a2, int a3, int a4, int a5)
Definition: Overlays.cpp:29
OtherOverlayList::bRedraw
int bRedraw
Definition: Overlays.h:38
OtherOverlay::sprite_frame_time
int16_t sprite_frame_time
Definition: Overlays.h:13
Overlays.h
OverlayList
Definition: Overlays.h:53
OtherOverlay::field_C
int16_t field_C
Definition: Overlays.h:17
uIconID_TurnStop
unsigned int uIconID_TurnStop
Definition: mm7_data.cpp:571
OtherOverlay::field_0
int16_t field_0
Definition: Overlays.h:11
Icon::GetTexture
Texture * GetTexture()
Definition: IconFrameTable.cpp:9
TurnEngine.h
Engine.h
current_screen_type
enum CURRENT_SCREEN current_screen_type
Definition: GUIWindow.cpp:83
dword_50C998_turnbased_icon_1A
int dword_50C998_turnbased_icon_1A
Definition: mm7_data.cpp:576
pTurnEngine
struct stru262_TurnBased * pTurnEngine
Definition: TurnEngine.cpp:21
OtherOverlayList::OtherOverlayList
OtherOverlayList()
Definition: Overlays.h:26
OtherOverlayList::pOverlays
OtherOverlay pOverlays[50]
Definition: Overlays.h:36
uIconID_TurnStart
unsigned int uIconID_TurnStart
Definition: mm7_data.cpp:574
pParty
Party * pParty
Definition: Party.cpp:30
OverlayList::FromFileTxt
bool FromFileTxt(const char *Args)
Definition: Overlays.cpp:138
IRender.h
dword_50C994
int dword_50C994
Definition: mm7_data.cpp:575
OverlayDesc::uOverlayType
uint16_t uOverlayType
Definition: Overlays.h:46
OtherOverlay::screen_space_y
int16_t screen_space_y
Definition: Overlays.h:16
OtherOverlayList::DrawTurnBasedIcon
void DrawTurnBasedIcon(int a2)
Definition: Overlays.cpp:67
SpriteFrameTable::pSpriteSFrames
SpriteFrame * pSpriteSFrames
Definition: Sprites.h:77
Party.h
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
OtherOverlay::field_6
int16_t field_6
Definition: Overlays.h:14
TE_WAIT
@ TE_WAIT
Definition: TurnEngine.h:20
SpriteFrameTable::InitializeSprite
void InitializeSprite(signed int uSpriteID)
Definition: Sprites.cpp:46
txt_file_frametable_parser
FrameTableTxtLine * txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table)
Definition: FrameTableInc.cpp:8
Party::bTurnBasedModeOn
bool bTurnBasedModeOn
Definition: Party.h:305
uIconID_TurnHour
unsigned int uIconID_TurnHour
Definition: mm7_data.cpp:572
CURRENT_SCREEN::SCREEN_GAME
@ SCREEN_GAME
IconFrameTable::GetFrame
Icon * GetFrame(unsigned int uIconID, unsigned int frame_time)
Definition: IconFrameTable.cpp:39
SpriteFrameTable::FastFindSprite
int FastFindSprite(const char *pSpriteName)
Definition: Sprites.cpp:243
FrameTableInc.h
OtherOverlay::field_E
int16_t field_E
Definition: Overlays.h:18
SpriteFrame::uAnimLength
int uAnimLength
Definition: Sprites.h:53
pOtherOverlayList
struct OtherOverlayList * pOtherOverlayList
Definition: Overlays.cpp:19
OtherOverlay::screen_space_x
int16_t screen_space_x
Definition: Overlays.h:15
Icon
Definition: IconFrameTable.h:8
v2
GLfloat GLfloat GLfloat v2
Definition: SDL_opengl_glext.h:695
uint
unsigned int uint
Definition: MM7.h:4
v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: SDL_opengl_glext.h:696
pOverlayList
struct OverlayList * pOverlayList
Definition: Overlays.cpp:20
OverlayList::uNumOverlays
unsigned int uNumOverlays
Definition: Overlays.h:64
Timer::uStartTime
unsigned int uStartTime
Definition: Time.h:129
OverlayList::pOverlays
struct OverlayDesc * pOverlays
Definition: Overlays.h:65
OtherOverlayList
Definition: Overlays.h:25
GUIWindow.h
OtherOverlay::field_2
int16_t field_2
Definition: Overlays.h:12
OtherOverlay::OtherOverlay
OtherOverlay()
Definition: Overlays.cpp:216
stru262_TurnBased::turn_stage
int turn_stage
Definition: TurnEngine.h:75
pEventTimer
Timer * pEventTimer
Definition: Time.cpp:8
Sprites.h
OverlayList::FromFile
void FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
Definition: Overlays.cpp:119
FrameTableTxtLine
Definition: FrameTableInc.h:11
OverlayList::ToFile
void ToFile()
Definition: Overlays.cpp:106
OtherOverlayList::Reset
void Reset()
Definition: Overlays.cpp:24
stru262_TurnBased::uActionPointsLeft
int uActionPointsLeft
Definition: TurnEngine.h:79
Time.h
OtherOverlay::Reset
void Reset()
Definition: Overlays.cpp:203
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52