Pol  Revision:cb584c9
uofile04.cpp
Go to the documentation of this file.
1 
6 #include <set>
7 #include <stdio.h>
8 
9 #include "../clib/logfacility.h"
10 #include "../clib/rawtypes.h"
11 #include "../pol/uofilei.h"
12 #include "../pol/ustruct.h"
13 
14 namespace Pol
15 {
16 namespace Core
17 {
18 std::set<unsigned int> water;
19 
20 bool iswater( u16 objtype )
21 {
22  return ( objtype >= 0x1796 && objtype <= 0x17b2 );
23 }
24 
25 void readwater()
26 {
28 
29  fseek( Core::sidxfile, 0, SEEK_SET );
30  for ( int xblock = 0; xblock < 6144 / 8; ++xblock )
31  {
32  INFO_PRINT << xblock << "..";
33  for ( int yblock = 0; yblock < 4096 / 8; ++yblock )
34  {
35  fread( &idxrec, sizeof idxrec, 1, Core::sidxfile );
36  int xbase = xblock * 8;
37  int ybase = yblock * 8;
38 
39  if ( idxrec.length != 0xFFffFFffLu )
40  {
41  fseek( Core::statfile, idxrec.offset, SEEK_SET );
42 
43  for ( idxrec.length /= 7; idxrec.length > 0; --idxrec.length )
44  {
46  fread( &srec, sizeof srec, 1, Core::statfile );
47 
48  if ( srec.z == -5 && iswater( srec.graphic ) )
49  {
50  int x = xbase + srec.x_offset;
51  int y = ybase + srec.y_offset;
52  unsigned int xy = x << 16 | y;
53  water.insert( xy );
54  }
55  }
56  }
57  }
58  }
59 }
60 }
61 }
unsigned short u16
Definition: rawtypes.h:26
void readwater()
Definition: uofile04.cpp:25
FILE * sidxfile
Definition: uofile00.cpp:22
USTRUCT_IDX idxrec
Definition: uofile02.cpp:34
std::set< unsigned int > water
Definition: uofile04.cpp:18
#define INFO_PRINT
Definition: logfacility.h:223
FILE * statfile
Definition: uofile00.cpp:23
Definition: berror.cpp:12
bool iswater(u16 objtype)
Definition: uofile04.cpp:20