13 #include "../clib/fileutil.h" 14 #include "../clib/logfacility.h" 15 #include "../clib/passert.h" 16 #include "../clib/rawtypes.h" 17 #include "../plib/realmdescriptor.h" 18 #include "../plib/staticblock.h" 19 #include "../plib/systemstate.h" 34 for (
unsigned i = 0; i < vec.size(); ++i )
42 height == pheight && prec.
xy == xy && prec.
z == pstat->
z && prec.
hue == pstat->
hue )
52 unsigned int duplicates = 0;
53 unsigned int illegales = 0;
54 unsigned int statics = 0;
55 unsigned int empties = 0;
56 unsigned int nonempties = 0;
57 unsigned int maxcount = 0;
59 std::string directory =
"realm/" + realm +
"/";
61 std::string statidx_dat = directory +
"statidx.dat";
62 std::string statics_dat = directory +
"statics.dat";
63 std::string statidx_tmp = directory +
"statidx.tmp";
64 std::string statics_tmp = directory +
"statics.tmp";
70 FILE* fidx = fopen( statidx_tmp.c_str(),
"wb" );
71 FILE* fdat = fopen( statics_tmp.c_str(),
"wb" );
75 int lastprogress = -1;
76 unsigned int index = 0;
79 int progress = y * 100L / descriptor.height;
80 if ( progress != lastprogress )
82 INFO_PRINT <<
"\rCreating POL statics files: " << progress <<
"%";
83 lastprogress = progress;
89 fwrite( &idx,
sizeof idx, 1, fidx );
91 std::vector<USTRUCT_STATIC> pstat;
93 std::vector<Plib::STATIC_ENTRY> vec;
95 for (
int i = 0; i < num; ++i )
103 nrec.
objtype = pstat[i].graphic;
104 nrec.
xy = ( pstat[i].x_offset << 4 ) | pstat[i].y_offset;
106 nrec.
hue = pstat[i].hue;
107 vec.push_back( nrec );
119 if ( cfg_show_illegal_graphic_warning )
120 INFO_PRINT <<
" Warning: Item with illegal Graphic 0x" << fmt::hexu( pstat[i].graphic )
125 for (
unsigned i = 0; i < vec.size(); ++i )
134 if ( vec.size() > maxcount )
135 maxcount = static_cast<unsigned int>( vec.size() );
140 fwrite( &idx,
sizeof idx, 1, fidx );
142 int errors = ferror( fdat ) || ferror( fidx );
147 INFO_PRINT <<
"\rCreating POL statics files: Complete\n";
148 rename( statidx_tmp.c_str(), statidx_dat.c_str() );
149 rename( statics_tmp.c_str(), statics_dat.c_str() );
153 INFO_PRINT <<
"\rCreating POL statics files: Error\n";
159 << duplicates <<
" duplicates eliminated\n" 160 << illegales <<
" illegales eliminated\n" 161 << empties <<
" empties\n" 162 << nonempties <<
" nonempties\n" 163 << maxcount <<
" was the highest count\n";
static RealmDescriptor Load(const std::string &realm_name, const std::string &realm_path="")
bool cfg_show_illegal_graphic_warning
const unsigned STATICBLOCK_CHUNK
void readstaticblock(std::vector< USTRUCT_STATIC > *ppst, int *pnum, unsigned short x, unsigned short y)
char tileheight(unsigned short tilenum)
void RemoveFile(const std::string &fname)
bool newstat_dont_add(std::vector< Plib::STATIC_ENTRY > &vec, USTRUCT_STATIC *pstat)
#define passert_always(exp)
int write_pol_static_files(const std::string &realm)