12 #include "../clib/logfacility.h" 13 #include "../clib/passert.h" 14 #include "../clib/rawtypes.h" 15 #include "../clib/stlutil.h" 59 while ( fread( &blockid,
sizeof blockid, 1,
stadifl_file ) == 1 )
61 stadifl[blockid] = index;
68 void readstaticblock( std::vector<USTRUCT_STATIC>* ppst,
int* pnum,
unsigned short x,
71 if ( !rawstatic_init )
75 ERROR_PRINT <<
"readstaticblock: x=" << x <<
",y=" << y <<
"\n";
77 unsigned int x_block, y_block;
80 unsigned int block = ( x_block * (
uo_map_height / 8 ) + y_block );
81 *ppst = rawstatic_buffer_vec.at( block ).statics;
82 *pnum = rawstatic_buffer_vec.at( block ).count;
87 unsigned int block = 0;
89 while ( fread( &idx,
sizeof idx, 1,
sidxfile ) == 1 )
92 StaticDifBlockIndex::const_iterator citr = stadifl.find( block );
93 if ( citr == stadifl.end() )
95 if ( idx.
length != 0xFFffFFffLu && idx.
offset != 0xFFffFFffLu )
99 throw std::runtime_error(
"readstaticblock: fseek(statfile) to " +
102 srec_count = idx.
length /
sizeof srecs[0];
109 " - maybe double items... you've to reduce amount of " +
116 throw std::runtime_error(
"readstaticblock: fread(statfile) failed." +
121 if ( srec_count > cfg_warning_statics_per_block )
122 INFO_PRINT <<
" Warning: " << srec_count <<
" items found in area " << x <<
" " << y
123 <<
" " << ( x + 7 ) <<
" " << ( y + 7 ) <<
"\n";
135 unsigned dif_index = ( *citr ).second;
136 int offset = dif_index *
sizeof idx;
139 throw std::runtime_error(
"readstaticblock: fseek(stadifi) to " +
Clib::tostring( offset ) +
145 throw std::runtime_error(
"readstaticblock: fread(stadifi) failed." );
148 if ( idx.length != 0xFFffFFffLu )
150 if ( fseek(
stadif_file, idx.offset, SEEK_SET ) != 0 )
152 throw std::runtime_error(
"readstaticblock: fseek(stadif) to " +
156 srec_count = idx.length /
sizeof srecs[0];
163 " - maybe double items... you've to reduce amount of " +
167 if ( fread( srecs, idx.length, 1,
stadif_file ) != 1 )
169 throw std::runtime_error(
"readstaticblock: fread(stadif) failed." );
172 if ( srec_count > cfg_warning_statics_per_block )
173 INFO_PRINT <<
" Warning: " << srec_count <<
" items found in dif-area " << x <<
" " << y
174 <<
" " << ( x + 7 ) <<
" " << ( y + 7 ) <<
"\n";
187 rawstatic_buffer_vec.push_back( buf );
190 rawstatic_init =
true;
std::map< unsigned int, unsigned int > StaticDifBlockIndex
unsigned int num_static_patches
static bool rawstatic_init
bool cfg_use_new_hsa_format
int cfg_max_statics_per_block
std::string tostring(const Bscript::BTokenType &v)
void readstaticblock(std::vector< USTRUCT_STATIC > *ppst, int *pnum, unsigned short x, unsigned short y)
#define MAX_STATICS_PER_BLOCK
static std::vector< USTRUCT_STATIC_BUFFER > rawstatic_buffer_vec
#define passert_always_r(exp, reason)
unsigned short uo_map_height
StaticDifBlockIndex stadifl
unsigned short uo_map_width
std::vector< USTRUCT_STATIC > statics
USTRUCT_STATIC srecs[MAX_STATICS_PER_BLOCK]
int cfg_warning_statics_per_block