Otclient  14/8/2020
thingtype.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #include "thingtype.h"
24 #include "spritemanager.h"
25 #include "game.h"
26 #include "lightview.h"
27 
33 #include <framework/otml/otml.h>
34 
36 {
37  m_category = ThingInvalidCategory;
38  m_id = 0;
39  m_null = true;
40  m_exactSize = 0;
41  m_realSize = 0;
42  m_animator = nullptr;
43  m_numPatternX = m_numPatternY = m_numPatternZ = 0;
44  m_animationPhases = 0;
45  m_layers = 0;
46  m_elevation = 0;
47  m_opacity = 1.0f;
48 }
49 
51 {
52  for(int i = 0; i < ThingLastAttr; ++i) {
53  if(!hasAttr((ThingAttr)i))
54  continue;
55 
56  int attr = i;
57  if(g_game.getClientVersion() >= 780) {
58  if(attr == ThingAttrChargeable)
59  attr = ThingAttrWritable;
60  else if(attr >= ThingAttrWritable)
61  attr += 1;
62  } else if(g_game.getClientVersion() >= 1000) {
63  if(attr == ThingAttrNoMoveAnimation)
64  attr = 16;
65  else if(attr >= ThingAttrPickupable)
66  attr += 1;
67  }
68 
69  fin->addU8(attr);
70  switch(attr) {
71  case ThingAttrDisplacement: {
72  fin->addU16(m_displacement.x);
73  fin->addU16(m_displacement.y);
74  break;
75  }
76  case ThingAttrLight: {
77  Light light = m_attribs.get<Light>(attr);
78  fin->addU16(light.intensity);
79  fin->addU16(light.color);
80  break;
81  }
82  case ThingAttrMarket: {
83  MarketData market = m_attribs.get<MarketData>(attr);
84  fin->addU16(market.category);
85  fin->addU16(market.tradeAs);
86  fin->addU16(market.showAs);
87  fin->addString(market.name);
88  fin->addU16(market.restrictVocation);
89  fin->addU16(market.requiredLevel);
90  break;
91  }
92  case ThingAttrUsable:
93  case ThingAttrElevation:
94  case ThingAttrGround:
95  case ThingAttrWritable:
98  case ThingAttrCloth:
99  case ThingAttrLensHelp:
100  fin->addU16(m_attribs.get<uint16>(attr));
101  break;
102  default:
103  break;
104  };
105  }
106  fin->addU8(ThingLastAttr);
107 
108  fin->addU8(m_size.width());
109  fin->addU8(m_size.height());
110 
111  if(m_size.width() > 1 || m_size.height() > 1)
112  fin->addU8(m_realSize);
113 
114  fin->addU8(m_layers);
115  fin->addU8(m_numPatternX);
116  fin->addU8(m_numPatternY);
117  fin->addU8(m_numPatternZ);
118  fin->addU8(m_animationPhases);
119 
121  if(m_animationPhases > 1 && m_animator != nullptr) {
122  m_animator->serialize(fin);
123  }
124  }
125 
126  for(int i: m_spritesIndex) {
128  fin->addU32(i);
129  else
130  fin->addU16(i);
131  }
132 }
133 
134 void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileStreamPtr& fin)
135 {
136  m_null = false;
137  m_id = clientId;
138  m_category = category;
139 
140  int count = 0, attr = -1;
141  bool done = false;
142  for(int i = 0 ; i < ThingLastAttr;++i) {
143  count++;
144  attr = fin->getU8();
145  if(attr == ThingLastAttr) {
146  done = true;
147  break;
148  }
149 
150  if(g_game.getClientVersion() >= 1000) {
151  /* In 10.10+ all attributes from 16 and up were
152  * incremented by 1 to make space for 16 as
153  * "No Movement Animation" flag.
154  */
155  if(attr == 16)
157  else if(attr > 16)
158  attr -= 1;
159  } else if(g_game.getClientVersion() >= 860) {
160  /* Default attribute values follow
161  * the format of 8.6-9.86.
162  * Therefore no changes here.
163  */
164  } else if(g_game.getClientVersion() >= 780) {
165  /* In 7.80-8.54 all attributes from 8 and higher were
166  * incremented by 1 to make space for 8 as
167  * "Item Charges" flag.
168  */
169  if(attr == 8) {
170  m_attribs.set(ThingAttrChargeable, true);
171  continue;
172  } else if(attr > 8)
173  attr -= 1;
174  } else if(g_game.getClientVersion() >= 755) {
175  /* In 7.55-7.72 attributes 23 is "Floor Change". */
176  if(attr == 23)
177  attr = ThingAttrFloorChange;
178  } else if(g_game.getClientVersion() >= 740) {
179  /* In 7.4-7.5 attribute "Ground Border" did not exist
180  * attributes 1-15 have to be adjusted.
181  * Several other changes in the format.
182  */
183  if(attr > 0 && attr <= 15)
184  attr += 1;
185  else if(attr == 16)
186  attr = ThingAttrLight;
187  else if(attr == 17)
188  attr = ThingAttrFloorChange;
189  else if(attr == 18)
190  attr = ThingAttrFullGround;
191  else if(attr == 19)
192  attr = ThingAttrElevation;
193  else if(attr == 20)
194  attr = ThingAttrDisplacement;
195  else if(attr == 22)
196  attr = ThingAttrMinimapColor;
197  else if(attr == 23)
198  attr = ThingAttrRotateable;
199  else if(attr == 24)
200  attr = ThingAttrLyingCorpse;
201  else if(attr == 25)
202  attr = ThingAttrHangable;
203  else if(attr == 26)
204  attr = ThingAttrHookSouth;
205  else if(attr == 27)
206  attr = ThingAttrHookEast;
207  else if(attr == 28)
208  attr = ThingAttrAnimateAlways;
209 
210  /* "Multi Use" and "Force Use" are swapped */
211  if(attr == ThingAttrMultiUse)
212  attr = ThingAttrForceUse;
213  else if(attr == ThingAttrForceUse)
214  attr = ThingAttrMultiUse;
215  }
216 
217  switch(attr) {
218  case ThingAttrDisplacement: {
219  if(g_game.getClientVersion() >= 755) {
220  m_displacement.x = fin->getU16();
221  m_displacement.y = fin->getU16();
222  } else {
223  m_displacement.x = 8;
224  m_displacement.y = 8;
225  }
226  m_attribs.set(attr, true);
227  break;
228  }
229  case ThingAttrLight: {
230  Light light;
231  light.intensity = fin->getU16();
232  light.color = fin->getU16();
233  m_attribs.set(attr, light);
234  break;
235  }
236  case ThingAttrMarket: {
237  MarketData market;
238  market.category = fin->getU16();
239  market.tradeAs = fin->getU16();
240  market.showAs = fin->getU16();
241  market.name = fin->getString();
242  market.restrictVocation = fin->getU16();
243  market.requiredLevel = fin->getU16();
244  m_attribs.set(attr, market);
245  break;
246  }
247  case ThingAttrElevation: {
248  m_elevation = fin->getU16();
249  m_attribs.set(attr, m_elevation);
250  break;
251  }
252  case ThingAttrUsable:
253  case ThingAttrGround:
254  case ThingAttrWritable:
257  case ThingAttrCloth:
258  case ThingAttrLensHelp:
259  m_attribs.set(attr, fin->getU16());
260  break;
261  default:
262  m_attribs.set(attr, true);
263  break;
264  };
265  }
266 
267  if(!done)
268  stdext::throw_exception(stdext::format("corrupt data (id: %d, category: %d, count: %d, lastAttr: %d)",
269  m_id, m_category, count, attr));
270 
271  bool hasFrameGroups = (category == ThingCategoryCreature && g_game.getFeature(Otc::GameIdleAnimations));
272  uint8 groupCount = hasFrameGroups ? fin->getU8() : 1;
273 
274  m_animationPhases = 0;
275  int totalSpritesCount = 0;
276 
277  for(int i = 0; i < groupCount; ++i) {
278  uint8 frameGroupType = FrameGroupDefault;
279  if(hasFrameGroups)
280  frameGroupType = fin->getU8();
281 
282  uint8 width = fin->getU8();
283  uint8 height = fin->getU8();
284  m_size = Size(width, height);
285  if(width > 1 || height > 1) {
286  m_realSize = fin->getU8();
287  m_exactSize = std::min<int>(m_realSize, std::max<int>(width * 32, height * 32));
288  }
289  else
290  m_exactSize = 32;
291 
292  m_layers = fin->getU8();
293  m_numPatternX = fin->getU8();
294  m_numPatternY = fin->getU8();
295  if(g_game.getClientVersion() >= 755)
296  m_numPatternZ = fin->getU8();
297  else
298  m_numPatternZ = 1;
299 
300  int groupAnimationsPhases = fin->getU8();
301  m_animationPhases += groupAnimationsPhases;
302 
303  if(groupAnimationsPhases > 1 && g_game.getFeature(Otc::GameEnhancedAnimations)) {
304  m_animator = AnimatorPtr(new Animator);
305  m_animator->unserialize(groupAnimationsPhases, fin);
306  }
307 
308  int totalSprites = m_size.area() * m_layers * m_numPatternX * m_numPatternY * m_numPatternZ * groupAnimationsPhases;
309 
310  if((totalSpritesCount+totalSprites) > 4096)
311  stdext::throw_exception("a thing type has more than 4096 sprites");
312 
313  m_spritesIndex.resize((totalSpritesCount+totalSprites));
314  for(int j = totalSpritesCount; j < (totalSpritesCount+totalSprites); j++)
315  m_spritesIndex[j] = g_game.getFeature(Otc::GameSpritesU32) ? fin->getU32() : fin->getU16();
316 
317  totalSpritesCount += totalSprites;
318  }
319 
320  m_textures.resize(m_animationPhases);
321  m_texturesFramesRects.resize(m_animationPhases);
322  m_texturesFramesOriginRects.resize(m_animationPhases);
323  m_texturesFramesOffsets.resize(m_animationPhases);
324 }
325 
326 void ThingType::exportImage(std::string fileName)
327 {
328  if(m_null)
329  stdext::throw_exception("cannot export null thingtype");
330 
331  if(m_spritesIndex.empty())
332  stdext::throw_exception("cannot export thingtype without sprites");
333 
334  ImagePtr image(new Image(Size(32 * m_size.width() * m_layers * m_numPatternX, 32 * m_size.height() * m_animationPhases * m_numPatternY * m_numPatternZ)));
335  for(int z = 0; z < m_numPatternZ; ++z) {
336  for(int y = 0; y < m_numPatternY; ++y) {
337  for(int x = 0; x < m_numPatternX; ++x) {
338  for(int l = 0; l < m_layers; ++l) {
339  for(int a = 0; a < m_animationPhases; ++a) {
340  for(int w = 0; w < m_size.width(); ++w) {
341  for(int h = 0; h < m_size.height(); ++h) {
342  image->blit(Point(32 * (m_size.width() - w - 1 + m_size.width() * x + m_size.width() * m_numPatternX * l),
343  32 * (m_size.height() - h - 1 + m_size.height() * y + m_size.height() * m_numPatternY * a + m_size.height() * m_numPatternY * m_animationPhases * z)),
344  g_sprites.getSpriteImage(m_spritesIndex[getSpriteIndex(w, h, l, x, y, z, a)]));
345  }
346  }
347  }
348  }
349  }
350  }
351  }
352 
353  image->savePNG(fileName);
354 }
355 
357 {
358  for(const OTMLNodePtr& node2 : node->children()) {
359  if(node2->tag() == "opacity")
360  m_opacity = node2->value<float>();
361  else if(node2->tag() == "notprewalkable")
362  m_attribs.set(ThingAttrNotPreWalkable, node2->value<bool>());
363  else if(node2->tag() == "image")
364  m_customImage = node2->value();
365  else if(node2->tag() == "full-ground") {
366  if(node2->value<bool>())
367  m_attribs.set(ThingAttrFullGround, true);
368  else
369  m_attribs.remove(ThingAttrFullGround);
370  }
371  }
372 }
373 
374 void ThingType::draw(const Point& dest, float scaleFactor, int layer, int xPattern, int yPattern, int zPattern, int animationPhase, LightView *lightView)
375 {
376  if(m_null)
377  return;
378 
379  if(animationPhase >= m_animationPhases)
380  return;
381 
382  const TexturePtr& texture = getTexture(animationPhase); // texture might not exists, neither its rects.
383  if(!texture)
384  return;
385 
386  uint frameIndex = getTextureIndex(layer, xPattern, yPattern, zPattern);
387  if(frameIndex >= m_texturesFramesRects[animationPhase].size())
388  return;
389 
390  Point textureOffset;
391  Rect textureRect;
392 
393  if(scaleFactor != 1.0f) {
394  textureRect = m_texturesFramesOriginRects[animationPhase][frameIndex];
395  } else {
396  textureOffset = m_texturesFramesOffsets[animationPhase][frameIndex];
397  textureRect = m_texturesFramesRects[animationPhase][frameIndex];
398  }
399 
400  Rect screenRect(dest + (textureOffset - m_displacement - (m_size.toPoint() - Point(1, 1)) * 32) * scaleFactor,
401  textureRect.size() * scaleFactor);
402 
403  bool useOpacity = m_opacity < 1.0f;
404 
405  if(useOpacity)
406  g_painter->setColor(Color(1.0f,1.0f,1.0f,m_opacity));
407 
408  g_painter->drawTexturedRect(screenRect, texture, textureRect);
409 
410  if(useOpacity)
412 
413  if(lightView && hasLight()) {
414  Light light = getLight();
415  if(light.intensity > 0)
416  lightView->addLightSource(screenRect.center(), scaleFactor, light);
417  }
418 }
419 
420 const TexturePtr& ThingType::getTexture(int animationPhase)
421 {
422  TexturePtr& animationPhaseTexture = m_textures[animationPhase];
423  if(!animationPhaseTexture) {
424  bool useCustomImage = false;
425  if(animationPhase == 0 && !m_customImage.empty())
426  useCustomImage = true;
427 
428  // we don't need layers in common items, they will be pre-drawn
429  int textureLayers = 1;
430  int numLayers = m_layers;
431  if(m_category == ThingCategoryCreature && numLayers >= 2) {
432  // 5 layers: outfit base, red mask, green mask, blue mask, yellow mask
433  textureLayers = 5;
434  numLayers = 5;
435  }
436 
437  int indexSize = textureLayers * m_numPatternX * m_numPatternY * m_numPatternZ;
438  Size textureSize = getBestTextureDimension(m_size.width(), m_size.height(), indexSize);
439  ImagePtr fullImage;
440 
441  if(useCustomImage)
442  fullImage = Image::load(m_customImage);
443  else
444  fullImage = ImagePtr(new Image(textureSize * Otc::TILE_PIXELS));
445 
446  m_texturesFramesRects[animationPhase].resize(indexSize);
447  m_texturesFramesOriginRects[animationPhase].resize(indexSize);
448  m_texturesFramesOffsets[animationPhase].resize(indexSize);
449 
450  for(int z = 0; z < m_numPatternZ; ++z) {
451  for(int y = 0; y < m_numPatternY; ++y) {
452  for(int x = 0; x < m_numPatternX; ++x) {
453  for(int l = 0; l < numLayers; ++l) {
454  bool spriteMask = (m_category == ThingCategoryCreature && l > 0);
455  int frameIndex = getTextureIndex(l % textureLayers, x, y, z);
456  Point framePos = Point(frameIndex % (textureSize.width() / m_size.width()) * m_size.width(),
457  frameIndex / (textureSize.width() / m_size.width()) * m_size.height()) * Otc::TILE_PIXELS;
458 
459  if(!useCustomImage) {
460  for(int h = 0; h < m_size.height(); ++h) {
461  for(int w = 0; w < m_size.width(); ++w) {
462  uint spriteIndex = getSpriteIndex(w, h, spriteMask ? 1 : l, x, y, z, animationPhase);
463  ImagePtr spriteImage = g_sprites.getSpriteImage(m_spritesIndex[spriteIndex]);
464  if(spriteImage) {
465  if(spriteMask) {
466  static Color maskColors[] = { Color::red, Color::green, Color::blue, Color::yellow };
467  spriteImage->overwriteMask(maskColors[l - 1]);
468  }
469  Point spritePos = Point(m_size.width() - w - 1,
470  m_size.height() - h - 1) * Otc::TILE_PIXELS;
471 
472  fullImage->blit(framePos + spritePos, spriteImage);
473  }
474  }
475  }
476  }
477 
478  Rect drawRect(framePos + Point(m_size.width(), m_size.height()) * Otc::TILE_PIXELS - Point(1,1), framePos);
479  for(int fx = framePos.x; fx < framePos.x + m_size.width() * Otc::TILE_PIXELS; ++fx) {
480  for(int fy = framePos.y; fy < framePos.y + m_size.height() * Otc::TILE_PIXELS; ++fy) {
481  uint8 *p = fullImage->getPixel(fx,fy);
482  if(p[3] != 0x00) {
483  drawRect.setTop (std::min<int>(fy, (int)drawRect.top()));
484  drawRect.setLeft (std::min<int>(fx, (int)drawRect.left()));
485  drawRect.setBottom(std::max<int>(fy, (int)drawRect.bottom()));
486  drawRect.setRight (std::max<int>(fx, (int)drawRect.right()));
487  }
488  }
489  }
490 
491  m_texturesFramesRects[animationPhase][frameIndex] = drawRect;
492  m_texturesFramesOriginRects[animationPhase][frameIndex] = Rect(framePos, Size(m_size.width(), m_size.height()) * Otc::TILE_PIXELS);
493  m_texturesFramesOffsets[animationPhase][frameIndex] = drawRect.topLeft() - framePos;
494  }
495  }
496  }
497  }
498  animationPhaseTexture = TexturePtr(new Texture(fullImage, true));
499  animationPhaseTexture->setSmooth(true);
500  }
501  return animationPhaseTexture;
502 }
503 
504 Size ThingType::getBestTextureDimension(int w, int h, int count)
505 {
506  const int MAX = 32;
507 
508  int k = 1;
509  while(k < w)
510  k<<=1;
511  w = k;
512 
513  k = 1;
514  while(k < h)
515  k<<=1;
516  h = k;
517 
518  int numSprites = w*h*count;
519  assert(numSprites <= MAX*MAX);
520  assert(w <= MAX);
521  assert(h <= MAX);
522 
523  Size bestDimension = Size(MAX, MAX);
524  for(int i=w;i<=MAX;i<<=1) {
525  for(int j=h;j<=MAX;j<<=1) {
526  Size candidateDimension = Size(i, j);
527  if(candidateDimension.area() < numSprites)
528  continue;
529  if((candidateDimension.area() < bestDimension.area()) ||
530  (candidateDimension.area() == bestDimension.area() && candidateDimension.width() + candidateDimension.height() < bestDimension.width() + bestDimension.height()))
531  bestDimension = candidateDimension;
532  }
533  }
534 
535  return bestDimension;
536 }
537 
538 uint ThingType::getSpriteIndex(int w, int h, int l, int x, int y, int z, int a) {
539  uint index =
540  ((((((a % m_animationPhases)
541  * m_numPatternZ + z)
542  * m_numPatternY + y)
543  * m_numPatternX + x)
544  * m_layers + l)
545  * m_size.height() + h)
546  * m_size.width() + w;
547  assert(index < m_spritesIndex.size());
548  return index;
549 }
550 
551 uint ThingType::getTextureIndex(int l, int x, int y, int z) {
552  return ((l * m_numPatternZ + z)
553  * m_numPatternY + y)
554  * m_numPatternX + x;
555 }
556 
557 int ThingType::getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase)
558 {
559  if(m_null)
560  return 0;
561 
562  getTexture(animationPhase); // we must calculate it anyway.
563  int frameIndex = getTextureIndex(layer, xPattern, yPattern, zPattern);
564  Size size = m_texturesFramesOriginRects[animationPhase][frameIndex].size() - m_texturesFramesOffsets[animationPhase][frameIndex].toSize();
565  return std::max<int>(size.width(), size.height());
566 }
567 
569 {
570  if(var == true)
571  m_attribs.remove(ThingAttrNotPathable);
572  else
573  m_attribs.set(ThingAttrNotPathable, true);
574 }
Painter::setColor
virtual void setColor(const Color &color)
Definition: painter.h:77
ThingAttrNoMoveAnimation
@ ThingAttrNoMoveAnimation
Definition: thingtype.h:96
ThingAttrLyingCorpse
@ ThingAttrLyingCorpse
Definition: thingtype.h:78
Otc::TILE_PIXELS
@ TILE_PIXELS
Definition: const.h:29
lightview.h
MarketData::requiredLevel
uint16 requiredLevel
Definition: thingtype.h:111
graphics.h
ThingAttrFullGround
@ ThingAttrFullGround
Definition: thingtype.h:82
Color
Definition: color.h:32
TPoint::y
T y
Definition: point.h:83
z
gc sort z
Definition: CMakeLists.txt:176
otml.h
ThingAttrHookEast
@ ThingAttrHookEast
Definition: thingtype.h:71
TRect< int >
FileStream::addU32
void addU32(uint32 v)
Definition: filestream.cpp:377
Image::load
static ImagePtr load(std::string file)
Definition: image.cpp:39
ThingAttrGround
@ ThingAttrGround
Definition: thingtype.h:52
Animator::unserialize
void unserialize(int animationPhases, const FileStreamPtr &fin)
Definition: animator.cpp:43
FrameGroupDefault
@ FrameGroupDefault
Definition: thingtype.h:37
Texture
Definition: texture.h:28
ThingAttrMinimapColor
@ ThingAttrMinimapColor
Definition: thingtype.h:80
ThingAttrHangable
@ ThingAttrHangable
Definition: thingtype.h:69
LightView::addLightSource
void addLightSource(const Point &center, float scaleFactor, const Light &light)
Definition: lightview.cpp:79
ThingAttrChargeable
@ ThingAttrChargeable
Definition: thingtype.h:97
ThingAttrUsable
@ ThingAttrUsable
Definition: thingtype.h:86
Otc::GameEnhancedAnimations
@ GameEnhancedAnimations
Definition: const.h:402
TSize::area
T area() const
Definition: size.h:101
ThingAttrRotateable
@ ThingAttrRotateable
Definition: thingtype.h:72
ThingAttrWritableOnce
@ ThingAttrWritableOnce
Definition: thingtype.h:61
ThingAttrWritable
@ ThingAttrWritable
Definition: thingtype.h:60
ThingType::ThingType
ThingType()
Definition: thingtype.cpp:35
Game::getClientVersion
int getClientVersion()
Definition: game.h:316
texturemanager.h
ThingType::hasLight
bool hasLight()
Definition: thingtype.h:186
MarketData::category
int category
Definition: thingtype.h:110
ThingAttrFloorChange
@ ThingAttrFloorChange
Definition: thingtype.h:95
Otc::GameIdleAnimations
@ GameIdleAnimations
Definition: const.h:414
OTMLNode::children
OTMLNodeList children()
Definition: otmlnode.cpp:170
ThingType::unserializeOtml
void unserializeOtml(const OTMLNodePtr &node)
Definition: thingtype.cpp:356
ThingType::getLight
Light getLight()
Definition: thingtype.h:159
g_game
Game g_game
Definition: game.cpp:37
Point
TPoint< int > Point
Definition: point.h:86
Animator::serialize
void serialize(const FileStreamPtr &fin)
Definition: animator.cpp:62
FileStream::getString
std::string getString()
Definition: filestream.cpp:309
SpriteManager::getSpriteImage
ImagePtr getSpriteImage(int id)
Definition: spritemanager.cpp:127
ThingAttrDisplacement
@ ThingAttrDisplacement
Definition: thingtype.h:76
stdext::format
std::string format()
Definition: format.h:82
ThingAttrCloth
@ ThingAttrCloth
Definition: thingtype.h:84
ImagePtr
stdext::shared_object_ptr< Image > ImagePtr
Definition: declarations.h:46
TSize::width
int width() const
Definition: size.h:43
ThingInvalidCategory
@ ThingInvalidCategory
Definition: thingtype.h:47
LightView
Definition: lightview.h:37
FileStream::addString
void addString(const std::string &v)
Definition: filestream.cpp:448
uint16
uint16_t uint16
Definition: types.h:36
ThingType::serialize
void serialize(const FileStreamPtr &fin)
Definition: thingtype.cpp:50
Otc::GameSpritesU32
@ GameSpritesU32
Definition: const.h:363
ThingType::hasAttr
bool hasAttr(ThingAttr attr)
Definition: thingtype.h:139
Color::green
static const Color green
Definition: color.h:105
Image
Definition: image.h:29
ThingType::unserialize
void unserialize(uint16 clientId, ThingCategory category, const FileStreamPtr &fin)
Definition: thingtype.cpp:134
Light::intensity
uint8 intensity
Definition: thingtype.h:119
ThingAttrMultiUse
@ ThingAttrMultiUse
Definition: thingtype.h:59
stdext::dynamic_storage::set
void set(const Key &k, const T &value)
Definition: dynamic_storage.h:35
uint
unsigned int uint
Definition: types.h:31
ThingCategoryCreature
@ ThingCategoryCreature
Definition: thingtype.h:44
FileStream::getU16
uint16 getU16()
Definition: filestream.cpp:199
g_sprites
SpriteManager g_sprites
Definition: spritemanager.cpp:29
spritemanager.h
ThingAttrNotPathable
@ ThingAttrNotPathable
Definition: thingtype.h:67
Color::white
static const Color white
Definition: color.h:101
MarketData::tradeAs
uint16 tradeAs
Definition: thingtype.h:114
image.h
Size
TSize< int > Size
Definition: size.h:107
TPoint::x
T x
Definition: point.h:83
Game::getFeature
bool getFeature(Otc::GameFeature feature)
Definition: game.h:310
ThingAttr
ThingAttr
Definition: thingtype.h:51
TexturePtr
stdext::shared_object_ptr< Texture > TexturePtr
Definition: declarations.h:49
MarketData::showAs
uint16 showAs
Definition: thingtype.h:113
Color::blue
static const Color blue
Definition: color.h:107
stdext::dynamic_storage::get
T get(const Key &k) const
Definition: dynamic_storage.h:48
stdext::throw_exception
void throw_exception(const std::string &what)
Throws a generic exception.
Definition: exception.h:43
Rect
TRect< int > Rect
Definition: rect.h:319
ThingAttrElevation
@ ThingAttrElevation
Definition: thingtype.h:77
filestream.h
TSize::height
int height() const
Definition: size.h:44
ThingLastAttr
@ ThingLastAttr
Definition: thingtype.h:98
texture.h
ThingAttrAnimateAlways
@ ThingAttrAnimateAlways
Definition: thingtype.h:79
stdext::dynamic_storage::remove
bool remove(const Key &k)
Definition: dynamic_storage.h:40
stdext::shared_object_ptr< FileStream >
ThingAttrLight
@ ThingAttrLight
Definition: thingtype.h:73
ThingAttrHookSouth
@ ThingAttrHookSouth
Definition: thingtype.h:70
ThingType::draw
void draw(const Point &dest, float scaleFactor, int layer, int xPattern, int yPattern, int zPattern, int animationPhase, LightView *lightView=nullptr)
Definition: thingtype.cpp:374
Texture::setSmooth
virtual void setSmooth(bool smooth)
Definition: texture.cpp:127
g_painter
Painter * g_painter
Definition: painter.cpp:28
ThingAttrPickupable
@ ThingAttrPickupable
Definition: thingtype.h:68
Light::color
uint8 color
Definition: thingtype.h:120
AnimatorPtr
stdext::shared_object_ptr< Animator > AnimatorPtr
Definition: declarations.h:72
MarketData
Definition: thingtype.h:108
Light
Definition: thingtype.h:117
FileStream::getU32
uint32 getU32()
Definition: filestream.cpp:215
Color::red
static const Color red
Definition: color.h:103
TSize::toPoint
TPoint< T > toPoint() const
Definition: size.h:37
game.h
ThingCategory
ThingCategory
Definition: thingtype.h:42
ThingType::setPathable
void setPathable(bool var)
Definition: thingtype.cpp:568
ThingAttrForceUse
@ ThingAttrForceUse
Definition: thingtype.h:58
MarketData::name
std::string name
Definition: thingtype.h:109
ThingAttrMarket
@ ThingAttrMarket
Definition: thingtype.h:85
TPoint< int >
thingtype.h
TRect::size
TSize< T > size() const
Definition: rect.h:71
FileStream::addU8
void addU8(uint8 v)
Definition: filestream.cpp:354
ThingType::exportImage
void exportImage(std::string fileName)
Definition: thingtype.cpp:326
MarketData::restrictVocation
uint16 restrictVocation
Definition: thingtype.h:112
TRect::center
TPoint< T > center() const
Definition: rect.h:68
ThingAttrNotPreWalkable
@ ThingAttrNotPreWalkable
Definition: thingtype.h:93
Animator
Definition: animator.h:43
TSize< int >
ThingAttrLensHelp
@ ThingAttrLensHelp
Definition: thingtype.h:81
FileStream::getU8
uint8 getU8()
Definition: filestream.cpp:183
ThingType::getExactSize
int getExactSize(int layer=0, int xPattern=0, int yPattern=0, int zPattern=0, int animationPhase=0)
Definition: thingtype.cpp:557
uint8
uint8_t uint8
Definition: types.h:37
Color::yellow
static const Color yellow
Definition: color.h:111
Painter::drawTexturedRect
virtual void drawTexturedRect(const Rect &dest, const TexturePtr &texture, const Rect &src)=0
FileStream::addU16
void addU16(uint16 v)
Definition: filestream.cpp:365