Pol
Revision:cb584c9
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
{
27
Core::USTRUCT_IDX
idxrec
;
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
{
45
Core::USTRUCT_STATIC
srec;
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
}
Pol::Core::USTRUCT_STATIC::x_offset
s8 x_offset
Definition:
ustruct.h:31
Pol::Core::USTRUCT_STATIC::y_offset
s8 y_offset
Definition:
ustruct.h:32
u16
unsigned short u16
Definition:
rawtypes.h:26
Pol::Core::readwater
void readwater()
Definition:
uofile04.cpp:25
Pol::Core::USTRUCT_STATIC
Definition:
ustruct.h:28
Pol::Core::sidxfile
FILE * sidxfile
Definition:
uofile00.cpp:22
Pol::Core::idxrec
USTRUCT_IDX idxrec
Definition:
uofile02.cpp:34
Pol::Core::water
std::set< unsigned int > water
Definition:
uofile04.cpp:18
Pol::Core::USTRUCT_IDX
Definition:
ustruct.h:38
Pol::Core::USTRUCT_IDX::offset
u32 offset
Definition:
ustruct.h:40
INFO_PRINT
#define INFO_PRINT
Definition:
logfacility.h:223
Pol::Core::statfile
FILE * statfile
Definition:
uofile00.cpp:23
Pol::Core::USTRUCT_IDX::length
u32 length
Definition:
ustruct.h:41
Pol
Definition:
berror.cpp:12
Pol::Core::USTRUCT_STATIC::graphic
u16 graphic
Definition:
ustruct.h:30
Pol::Core::USTRUCT_STATIC::z
s8 z
Definition:
ustruct.h:33
Pol::Core::iswater
bool iswater(u16 objtype)
Definition:
uofile04.cpp:20
uotool
uofile04.cpp
Generated on Wed Oct 10 2018 02:42:39 for Pol by
1.8.11