Pol  Revision:cb584c9
uofile07.cpp
Go to the documentation of this file.
1 
7 #include "clidata.h"
8 #include "udatfile.h"
9 #include "uofile.h"
10 #include "ustruct.h"
11 
12 namespace Pol
13 {
14 namespace Core
15 {
16 extern bool static_debug_on;
17 
18 // I'd put these in an anonymous namespace, but the debugger can't see 'em...at least not easily.
19 
20 void readstatics( StaticList& vec, unsigned short x, unsigned short y )
21 {
22  std::vector<USTRUCT_STATIC> srecarr;
23  int nrec;
24 
25  readstaticblock( &srecarr, &nrec, x, y );
26  if ( nrec )
27  {
28  unsigned short x_offset, y_offset;
29  x_offset = x & 0x7;
30  y_offset = y & 0x7;
31 
32  for ( int i = 0; i < nrec; ++i )
33  {
34  USTRUCT_STATIC* srec = &srecarr[i];
35 
36 #if ENABLE_POLTEST_OUTPUT
37  if ( static_debug_on )
38  {
39  INFO_PRINT << "static: " << int( srec->x_offset ) << " " << int( srec->y_offset ) << " "
40  << int( srec->z ) << " 0x" << fmt::hexu( srec->graphic ) << "\n";
41  }
42 #endif
43 
44  if ( ( srec->x_offset == x_offset ) && ( srec->y_offset == y_offset ) &&
46  {
47  vec.push_back( StaticRec( srec->graphic, srec->z ) );
48  }
49  }
50  }
51 }
52 void readstatics( StaticList& vec, unsigned short x, unsigned short y, unsigned int flags )
53 {
54  std::vector<USTRUCT_STATIC> srecarr;
55  int nrec;
56 
57  readstaticblock( &srecarr, &nrec, x, y );
58  if ( nrec )
59  {
60  unsigned short x_offset, y_offset;
61  x_offset = x & 0x7;
62  y_offset = y & 0x7;
63 
64  for ( int i = 0; i < nrec; ++i )
65  {
66  USTRUCT_STATIC* srec = &srecarr[i];
67 
68 #if ENABLE_POLTEST_OUTPUT
69  if ( static_debug_on )
70  {
71  INFO_PRINT << "static: " << int( srec->x_offset ) << " " << int( srec->y_offset ) << " "
72  << int( srec->z ) << " 0x" << fmt::hexu( srec->graphic ) << "\n";
73  }
74 #endif
75 
76  if ( ( srec->x_offset == x_offset ) && ( srec->y_offset == y_offset ) &&
77  ( tile_uoflags( srec->graphic ) & flags ) )
78  {
79  vec.push_back( StaticRec( srec->graphic, srec->z ) );
80  }
81  }
82  }
83 }
84 void readallstatics( StaticList& vec, unsigned short x, unsigned short y )
85 {
86  std::vector<USTRUCT_STATIC> srecarr;
87  int nrec;
88 
89  readstaticblock( &srecarr, &nrec, x, y );
90  if ( nrec )
91  {
92  unsigned short x_offset, y_offset;
93  x_offset = x & 0x7;
94  y_offset = y & 0x7;
95 
96  for ( int i = 0; i < nrec; ++i )
97  {
98  USTRUCT_STATIC* srec = &srecarr[i];
99 
100 #if ENABLE_POLTEST_OUTPUT
101  if ( static_debug_on )
102  {
103  INFO_PRINT << "static: " << int( srec->x_offset ) << " " << int( srec->y_offset ) << " "
104  << int( srec->z ) << " 0x" << fmt::hexu( srec->graphic ) << "\n";
105  }
106 #endif
107 
108  if ( ( srec->x_offset == x_offset ) && ( srec->y_offset == y_offset ) )
109  {
110  vec.push_back( StaticRec( srec->graphic, srec->z ) );
111  }
112  }
113  }
114 }
115 }
116 }
std::vector< StaticRec > StaticList
Definition: udatfile.h:38
void readstatics(StaticList &vec, unsigned short x, unsigned short y)
Definition: uofile07.cpp:20
void readallstatics(StaticList &vec, unsigned short x, unsigned short y)
Definition: uofile07.cpp:84
unsigned int tile_uoflags(unsigned short tilenum)
Definition: polfile2.cpp:61
bool static_debug_on
Definition: uofile02.cpp:29
void readstaticblock(std::vector< USTRUCT_STATIC > *ppst, int *pnum, unsigned short x, unsigned short y)
Definition: uofile02.cpp:68
#define INFO_PRINT
Definition: logfacility.h:223
Definition: berror.cpp:12