World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
ObjectList.cpp
См. документацию.
2 
4 
6 
7 unsigned int ObjectList::ObjectIDByItemID(unsigned int uItemID) {
8  unsigned int res = 0;
9 
10  for (unsigned int i = 0; i < uNumObjects; i++) {
11  if (uItemID == pObjects[i].uObjectID) {
12  res = i;
13  break;
14  }
15  }
16 
17  return res;
18 }
19 
21  for (unsigned int i = 0; i < uNumObjects; ++i) {
23  }
24 }
25 
27  for (unsigned int i = 0; i < pObjectList->uNumObjects; ++i) {
29  ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorB) |
30  ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorG << 8) |
31  ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorR << 16);
32  }
33 }
34 
35 #pragma pack(push, 1)
37  inline bool NoSprite() const { return uFlags & OBJECT_DESC_NO_SPRITE; }
38 
39  char field_0[32];
52 };
53 #pragma pack(pop)
54 
55 void ObjectList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) {
56  static_assert(sizeof(ObjectDesc_mm6) == 52, "Wrong type size");
57  static_assert(sizeof(ObjectDesc) == 56, "Wrong type size");
58 
59  unsigned int num_mm6_objs = data_mm6 ? *(uint32_t*)data_mm6 : 0;
60  unsigned int num_mm7_objs = data_mm7 ? *(uint32_t*)data_mm7 : 0;
61  unsigned int num_mm8_objs = data_mm8 ? *(uint32_t*)data_mm8 : 0;
62 
63  uNumObjects = num_mm6_objs + num_mm7_objs + num_mm8_objs;
64  assert(uNumObjects != 0);
65  assert(num_mm8_objs == 0);
66 
67  pObjects = (ObjectDesc*)malloc(uNumObjects * sizeof(ObjectDesc));
68  memcpy(pObjects, (char*)data_mm7 + 4, num_mm7_objs * sizeof(ObjectDesc));
69  for (unsigned int i = 0; i < num_mm6_objs; ++i) {
70  auto src = (ObjectDesc_mm6 *)((char *)data_mm6 + 4) + i;
71  ObjectDesc *dst = &pObjects[num_mm7_objs + i];
72  memcpy(dst->field_0, src->field_0, sizeof(dst->field_0));
73  dst->uObjectID = src->uObjectID;
74  dst->uRadius = src->uRadius;
75  dst->uHeight = src->uHeight;
76  dst->uFlags = src->uFlags;
77  dst->uSpriteID = src->uSpriteID;
78  dst->uLifetime = src->uLifetime;
79  dst->uParticleTrailColor = src->uParticleTrailColor;
80  dst->uSpeed = src->uSpeed;
81  dst->uParticleTrailColorR = src->uParticleTrailColorR;
82  dst->uParticleTrailColorG = src->uParticleTrailColorG;
83  dst->uParticleTrailColorB = src->uParticleTrailColorB;
84  dst->field_35_clr = src->field_35_clr;
85  dst->field_36_clr = 0;
86  dst->field_37_clr = 0;
87  }
88 }
uint16_t
unsigned __int16 uint16_t
Definition: SDL_config.h:37
ObjectDesc_mm6::uRadius
int16_t uRadius
Definition: ObjectList.cpp:41
int16_t
signed __int16 int16_t
Definition: SDL_config.h:36
ObjectDesc_mm6::uLifetime
int16_t uLifetime
Definition: ObjectList.cpp:45
pSpriteFrameTable
struct SpriteFrameTable * pSpriteFrameTable
Definition: Sprites.cpp:22
ObjectDesc_mm6::field_0
char field_0[32]
Definition: ObjectList.cpp:39
ObjectList::InitializeColors
void InitializeColors()
Definition: ObjectList.cpp:26
ObjectDesc
Definition: ObjectList.h:20
ObjectList::ObjectIDByItemID
unsigned int ObjectIDByItemID(unsigned int uItemID)
Definition: ObjectList.cpp:7
ObjectDesc_mm6::uParticleTrailColorB
char uParticleTrailColorB
Definition: ObjectList.cpp:50
ObjectDesc_mm6::uObjectID
int16_t uObjectID
Definition: ObjectList.cpp:40
ObjectDesc_mm6::uParticleTrailColorR
char uParticleTrailColorR
Definition: ObjectList.cpp:48
ObjectDesc_mm6::NoSprite
bool NoSprite() const
Definition: ObjectList.cpp:37
ObjectDesc_mm6::field_35_clr
char field_35_clr
Definition: ObjectList.cpp:51
ObjectDesc::uParticleTrailColor
uint32_t uParticleTrailColor
Definition: ObjectList.h:30
src
GLenum src
Definition: SDL_opengl_glext.h:1740
ObjectDesc_mm6::uSpeed
int16_t uSpeed
Definition: ObjectList.cpp:47
ObjectDesc_mm6::uSpriteID
uint16_t uSpriteID
Definition: ObjectList.cpp:44
ObjectDesc_mm6
Definition: ObjectList.cpp:36
OBJECT_DESC_NO_SPRITE
@ OBJECT_DESC_NO_SPRITE
Definition: ObjectList.h:6
ObjectList
Definition: ObjectList.h:41
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1740
ObjectList::InitializeSprites
void InitializeSprites()
Definition: ObjectList.cpp:20
ObjectDesc_mm6::uParticleTrailColor
uint16_t uParticleTrailColor
Definition: ObjectList.cpp:46
ObjectDesc_mm6::uHeight
int16_t uHeight
Definition: ObjectList.cpp:42
SpriteFrameTable::InitializeSprite
void InitializeSprite(signed int uSpriteID)
Definition: Sprites.cpp:46
ObjectDesc::uParticleTrailColorB
uint8_t uParticleTrailColorB
Definition: ObjectList.h:34
ObjectDesc_mm6::uFlags
int16_t uFlags
Definition: ObjectList.cpp:43
ObjectDesc::uParticleTrailColorG
uint8_t uParticleTrailColorG
Definition: ObjectList.h:33
ObjectList::uNumObjects
unsigned int uNumObjects
Definition: ObjectList.h:51
ObjectList::pObjects
struct ObjectDesc * pObjects
Definition: ObjectList.h:54
ObjectDesc::uParticleTrailColorR
uint8_t uParticleTrailColorR
Definition: ObjectList.h:32
ObjectList.h
res
GLuint res
Definition: SDL_opengl_glext.h:7940
uint32_t
unsigned __int32 uint32_t
Definition: SDL_config.h:39
ObjectDesc_mm6::uParticleTrailColorG
char uParticleTrailColorG
Definition: ObjectList.cpp:49
Sprites.h
pObjectList
struct ObjectList * pObjectList
Definition: ObjectList.cpp:5
ObjectList::FromFile
void FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
Definition: ObjectList.cpp:55