Pol  Revision:4b29d2b
multidef2.cpp
Go to the documentation of this file.
1 
10 #include "../../plib/mapcell.h"
11 #include "../../plib/mapshape.h"
12 #include "../../plib/systemstate.h"
13 #include "../clidata.h"
14 #include "../item/itemdesc.h"
15 #include "../tiles.h"
16 #include "../udatfile.h"
17 #include "multidef.h"
18 
19 namespace Pol
20 {
21 namespace Multi
22 {
23 // 8/9/03 this seems to be used only by uofile03 -Syz
24 bool MultiDef::readobjects( Core::StaticList& vec, short x, short y, short zbase ) const
25 {
26  bool result = false;
27  if ( x >= minrx && x <= maxrx && y >= minry && y <= maxry )
28  {
29  Components::const_iterator itr, end;
30  if ( findcomponents( itr, end, x, y ) )
31  {
32  for ( ; itr != end; ++itr )
33  {
34  const MULTI_ELEM* elem = ( *itr ).second;
35  unsigned short graphic = Items::getgraphic( elem->objtype );
36  if ( Core::tile_flags( graphic ) & Plib::FLAG::WALKBLOCK )
37  {
38  if ( elem->is_static )
39  {
40  vec.push_back(
41  Core::StaticRec( graphic, static_cast<signed char>( elem->z + zbase ) ) );
42  result = true;
43  }
44  // Shinigami: removed. doesn't make sense. non-static
45  // items are normal items an can be removed etc.
46  /* else // put a dummy floor tile there
47  {
48  vec.push_back( StaticRec( 0x495, elem->z+zbase ) );
49  result = true;
50  } */
51  }
52  }
53  }
54  }
55  return result;
56 }
57 
58 bool MultiDef::readshapes( Plib::MapShapeList& vec, short x, short y, short zbase,
59  unsigned int anyflags ) const
60 {
61  bool result = false;
62  if ( x >= minrx && x <= maxrx && y >= minry && y <= maxry )
63  {
64  Components::const_iterator itr, end;
65  if ( findcomponents( itr, end, x, y ) )
66  {
67  for ( ; itr != end; ++itr )
68  {
69  const MULTI_ELEM* elem = ( *itr ).second;
70  unsigned short graphic = Items::getgraphic( elem->objtype );
71  if ( Core::tile_flags( graphic ) & anyflags )
72  {
73  if ( elem->is_static )
74  {
75  Plib::MapShape shape;
76  shape.z = elem->z + zbase;
77  shape.height = Core::tileheight( graphic );
78  shape.flags = Plib::systemstate.tile[graphic].flags; // pol_flags_by_tile( graphic );
79  if ( !shape.height )
80  {
81  ++shape.height;
82  --shape.z;
83  }
84  vec.push_back( shape );
85  result = true;
86  }
87  // Shinigami: removed. doesn't make sense. non-static
88  // items are normal items an can be removed etc.
89  // Turley: BOAT added so hold count as boat item (who.multi) (and walkable)
90  else if ( type == BOAT ) // put a dummy floor there
91  {
92  Plib::MapShape shape;
93  shape.z = elem->z + zbase - 1;
94  shape.height = 1;
97  vec.push_back( shape );
98  result = true;
99  }
100  }
101  }
102  }
103  }
104  return result;
105 }
106 }
107 }
unsigned int tile_flags(unsigned short tilenum)
Definition: polfile2.cpp:49
unsigned int flags
Definition: mapshape.h:20
std::vector< StaticRec > StaticList
Definition: udatfile.h:38
SystemState systemstate
Definition: systemstate.cpp:12
ItrPair findcomponents(short rx, short ry)
bool readshapes(Plib::MapShapeList &vec, short rx, short ry, short zbase, unsigned int anyflags) const
Definition: multidef2.cpp:58
bool readobjects(Core::StaticList &vec, short rx, short ry, short zbase) const
Definition: multidef2.cpp:24
unsigned short getgraphic(u32 objtype)
Definition: itemdesc.cpp:906
unsigned int flags
Definition: tiles.h:24
char tileheight(unsigned short tilenum)
Definition: polfile2.cpp:34
enum Pol::Multi::MultiDef::HOUSETYPE type
Definition: berror.cpp:12
unsigned short objtype
Definition: multidef.h:46