Pol  Revision:cb584c9
UoToolMain.cpp
Go to the documentation of this file.
1 #include "UoToolMain.h"
2 
3 #include <assert.h>
4 #include <iosfwd>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <string>
9 
10 #include "../clib/Program/ProgramMain.h"
11 #include "../clib/cfgelem.h"
12 #include "../clib/cfgfile.h"
13 #include "../clib/fdump.h"
14 #include "../clib/fileutil.h"
15 #include "../clib/logfacility.h"
16 #include "../clib/rawtypes.h"
17 #include "../clib/stlutil.h"
18 #include "../clib/strutil.h"
19 #include "../plib/realmdescriptor.h"
20 #include "../plib/staticblock.h"
21 #include "../plib/systemstate.h"
22 #include "../pol/clidata.h"
23 #include "../pol/globals/multidefs.h"
24 #include "../pol/multi/multidef.h"
25 #include "../pol/objtype.h"
26 #include "../pol/polfile.h"
27 #include "../pol/poltype.h"
28 #include "../pol/uconst.h"
29 #include "../pol/udatfile.h"
30 #include "../pol/uofile.h"
31 #include "../pol/uofilei.h"
32 #include "../pol/ustruct.h"
33 #include "uofile2.h" //TODO: remove this file ASAP !!!
34 #include <format/format.h>
35 
36 namespace Pol
37 {
38 namespace Multi
39 {
40 void read_multidefs();
41 bool BoatShapeExists( unsigned short /*graphic*/ )
42 {
43  return true;
44 }
45 }
46 
47 namespace UoTool
48 {
49 using namespace std;
50 using namespace Pol::Core;
51 using namespace Pol::Plib;
52 
54 
55 int keyid[] = {
56  0x0002, 0x01f5, 0x0226, 0x0347, 0x0757, 0x0286, 0x03b6, 0x0327, 0x0e08, 0x0628, 0x0567, 0x0798,
57  0x19d9, 0x0978, 0x02a6, 0x0577, 0x0718, 0x05b8, 0x1cc9, 0x0a78, 0x0257, 0x04f7, 0x0668, 0x07d8,
58  0x1919, 0x1ce9, 0x03f7, 0x0909, 0x0598, 0x07b8, 0x0918, 0x0c68, 0x02d6, 0x1869, 0x06f8, 0x0939,
59  0x1cca, 0x05a8, 0x1aea, 0x1c0a, 0x1489, 0x14a9, 0x0829, 0x19fa, 0x1719, 0x1209, 0x0e79, 0x1f3a,
60  0x14b9, 0x1009, 0x1909, 0x0136, 0x1619, 0x1259, 0x1339, 0x1959, 0x1739, 0x1ca9, 0x0869, 0x1e99,
61  0x0db9, 0x1ec9, 0x08b9, 0x0859, 0x00a5, 0x0968, 0x09c8, 0x1c39, 0x19c9, 0x08f9, 0x18f9, 0x0919,
62  0x0879, 0x0c69, 0x1779, 0x0899, 0x0d69, 0x08c9, 0x1ee9, 0x1eb9, 0x0849, 0x1649, 0x1759, 0x1cd9,
63  0x05e8, 0x0889, 0x12b9, 0x1729, 0x10a9, 0x08d9, 0x13a9, 0x11c9, 0x1e1a, 0x1e0a, 0x1879, 0x1dca,
64  0x1dfa, 0x0747, 0x19f9, 0x08d8, 0x0e48, 0x0797, 0x0ea9, 0x0e19, 0x0408, 0x0417, 0x10b9, 0x0b09,
65  0x06a8, 0x0c18, 0x0717, 0x0787, 0x0b18, 0x14c9, 0x0437, 0x0768, 0x0667, 0x04d7, 0x08a9, 0x02f6,
66  0x0c98, 0x0ce9, 0x1499, 0x1609, 0x1baa, 0x19ea, 0x39fa, 0x0e59, 0x1949, 0x1849, 0x1269, 0x0307,
67  0x06c8, 0x1219, 0x1e89, 0x1c1a, 0x11da, 0x163a, 0x385a, 0x3dba, 0x17da, 0x106a, 0x397a, 0x24ea,
68  0x02e7, 0x0988, 0x33ca, 0x32ea, 0x1e9a, 0x0bf9, 0x3dfa, 0x1dda, 0x32da, 0x2eda, 0x30ba, 0x107a,
69  0x2e8a, 0x3dea, 0x125a, 0x1e8a, 0x0e99, 0x1cda, 0x1b5a, 0x1659, 0x232a, 0x2e1a, 0x3aeb, 0x3c6b,
70  0x3e2b, 0x205a, 0x29aa, 0x248a, 0x2cda, 0x23ba, 0x3c5b, 0x251a, 0x2e9a, 0x252a, 0x1ea9, 0x3a0b,
71  0x391b, 0x23ca, 0x392b, 0x3d5b, 0x233a, 0x2cca, 0x390b, 0x1bba, 0x3a1b, 0x3c4b, 0x211a, 0x203a,
72  0x12a9, 0x231a, 0x3e0b, 0x29ba, 0x3d7b, 0x202a, 0x3adb, 0x213a, 0x253a, 0x32ca, 0x23da, 0x23fa,
73  0x32fa, 0x11ca, 0x384a, 0x31ca, 0x17ca, 0x30aa, 0x2e0a, 0x276a, 0x250a, 0x3e3b, 0x396a, 0x18fa,
74  0x204a, 0x206a, 0x230a, 0x265a, 0x212a, 0x23ea, 0x3acb, 0x393b, 0x3e1b, 0x1dea, 0x3d6b, 0x31da,
75  0x3e5b, 0x3e4b, 0x207a, 0x3c7b, 0x277a, 0x3d4b, 0x0c08, 0x162a, 0x3daa, 0x124a, 0x1b4a, 0x264a,
76  0x33da, 0x1d1a, 0x1afa, 0x39ea, 0x24fa, 0x373b, 0x249a, 0x372b, 0x1679, 0x210a, 0x23aa, 0x1b8a,
77  0x3afb, 0x18ea, 0x2eca, 0x0627, 0x00d4 // terminator
78 };
79 
80 /* transforms table above into:
81  { nbits, bits_reversed [[ LSB .. MSB ]] },
82  */
83 static int print_ctable()
84 {
85  INFO_PRINT << "#include \"ctable.h\"\n\n"
86  << "SVR_KEYDESC keydesc[ 257 ] = {\n";
87  fmt::Writer _tmp;
88  for ( int i = 0; i <= 256; i++ )
89  {
90  int nbits = keyid[i] & 0x0F;
91  unsigned short inmask = 0x10;
92  const unsigned short val = static_cast<const unsigned short>( keyid[i] );
93  unsigned short valout = 0;
94  while ( nbits-- )
95  {
96  valout <<= 1;
97  if ( val & inmask )
98  valout |= 1;
99  inmask <<= 1;
100  }
101  _tmp.Format( " {{ {:>2}, 0x{:04X}, 0x{:04X}}},\n" )
102  << ( keyid[i] & 0x0F ) << ( keyid[i] >> 4 ) << valout;
103  }
104  _tmp << "};\n";
105  INFO_PRINT << _tmp.str();
106  return 0;
107 }
108 
109 unsigned char buffer[10000];
110 
111 #define TILES_START 0x68800
112 
113 static void display_tileinfo( unsigned short objtype, const Core::USTRUCT_TILE& tile )
114 {
115  fmt::Writer _tmp;
116  _tmp.Format( "objtype: 0x{:04X}\n" ) << objtype;
117  _tmp << " name: " << tile.name << "\n";
118  if ( tile.flags )
119  _tmp.Format( " flags: 0x{:08X}\n" ) << static_cast<unsigned long>( tile.flags );
120  if ( tile.weight )
121  _tmp.Format( " weight: 0x{:02X}\n" ) << (int)tile.weight;
122  if ( tile.layer )
123  _tmp.Format( " layer: 0x{:02X}\n" ) << (int)tile.layer;
124  if ( tile.unk6 )
125  _tmp.Format( " unk6: 0x{:02X}\n" ) << (int)tile.unk6;
126  if ( tile.unk7 )
127  _tmp.Format( " unk7: 0x{:02X}\n" ) << (int)tile.unk7;
128  if ( tile.unk8 )
129  _tmp.Format( " unk8: 0x{:02X}\n" ) << (int)tile.unk8;
130  if ( tile.unk9 )
131  _tmp.Format( " unk9: 0x{:02X}\n" ) << (int)tile.unk9;
132  if ( tile.anim )
133  _tmp.Format( " anim: 0x{:08X}\n" ) << static_cast<unsigned long>( tile.anim );
134  if ( tile.height )
135  _tmp.Format( " height: 0x{:02X}\n" ) << (int)tile.height;
136  if ( tile.unk14 )
137  _tmp.Format( " unk14: 0x{:02X}\n" ) << (int)tile.unk14;
138  if ( tile.unk15 )
139  _tmp.Format( " unk15: 0x{:02X}\n" ) << (int)tile.unk15;
140 }
141 
142 static int tiledump( int argc, char** argv )
143 {
144  Core::USTRUCT_TILE tile;
145  u32 version;
146  if ( argc != 3 )
147  return 1;
148 
149  FILE* fp = fopen( argv[2], "rb" );
150  fseek( fp, TILES_START, SEEK_SET );
151  int recnum = 0;
152  unsigned short objtype = 0;
153  for ( ;; )
154  {
155  if ( recnum == 0 )
156  {
157  if ( fread( &version, sizeof version, 1, fp ) != 1 )
158  break;
159  INFO_PRINT.Format( "Block Version: {:08X}\n" ) << static_cast<unsigned long>( version );
160  }
161  if ( fread( &tile, sizeof tile, 1, fp ) != 1 )
162  break;
163  display_tileinfo( objtype, tile );
164 
165  ++objtype;
166  ++recnum;
167  if ( recnum == 32 )
168  recnum = 0;
169  }
170  fclose( fp );
171  return 0;
172 }
173 
174 static int vertile()
175 {
176  Core::USTRUCT_TILE tile;
177 
180 
181  int i;
182  for ( i = 0; i <= 0xFFFF; i++ )
183  {
184  unsigned short objtype = (unsigned short)i;
185  read_objinfo( objtype, tile );
186  display_tileinfo( objtype, tile );
187  }
189  return 0;
190 }
191 
192 static int verlandtile()
193 {
194  Core::USTRUCT_LAND_TILE landtile;
195 
198 
199  int i;
200  for ( i = 0; i <= 0x3FFF; i++ )
201  {
202  unsigned short objtype = (unsigned short)i;
203  readlandtile( objtype, &landtile );
204  if ( landtile.flags || landtile.unk || landtile.name[0] )
205  {
206  INFO_PRINT << "Land Tile: 0x" << fmt::hexu( objtype ) << "\n"
207  << "\tflags: 0x" << fmt::hexu( landtile.flags ) << "\n"
208  << "\t unk: 0x" << fmt::hexu( landtile.unk ) << "\n"
209  << "\t name: " << landtile.name << "\n";
210  }
211  }
213  return 0;
214 }
215 
216 static int landtilehist()
217 {
218  Core::USTRUCT_LAND_TILE landtile;
219 
222 
223  typedef std::map<std::string, unsigned> M;
224  M tilecount;
225 
226  int i;
227  for ( i = 0; i < 0x4000; i++ )
228  {
229  unsigned short objtype = (unsigned short)i;
230  readlandtile( objtype, &landtile );
231  tilecount[landtile.name] = tilecount[landtile.name] + 1;
232  }
233 
234  fmt::Writer tmp;
235  for ( const auto& elem : tilecount )
236  {
237  tmp << elem.first << ": " << elem.second << "\n";
238  }
239  INFO_PRINT << tmp.str();
241  return 0;
242 }
243 
244 static int flagsearch( int argc, char** argv )
245 {
246  Core::USTRUCT_TILE tile;
247 
250 
251  if ( argc < 3 )
252  return 1;
253 
254  unsigned int flags = strtoul( argv[2], NULL, 0 );
255  unsigned int notflags = 0;
256  if ( argc >= 4 )
257  notflags = strtoul( argv[3], NULL, 0 );
258 
259  int i;
260  for ( i = 0; i <= 0xFFFF; i++ )
261  {
262  unsigned short objtype = (unsigned short)i;
263  read_objinfo( objtype, tile );
264  if ( ( ( tile.flags & flags ) == flags ) && ( ( ~tile.flags & notflags ) == notflags ) )
265  {
266  display_tileinfo( objtype, tile );
267  }
268  }
270  return 0;
271 }
272 
273 static int landtileflagsearch( int argc, char** argv )
274 {
277 
278  if ( argc < 3 )
279  return 1;
280 
281  unsigned int flags = strtoul( argv[2], NULL, 0 );
282  unsigned int notflags = 0;
283  if ( argc >= 4 )
284  notflags = strtoul( argv[3], NULL, 0 );
285 
286  Core::USTRUCT_LAND_TILE landtile;
287 
288  int i;
289  for ( i = 0; i < 0x4000; i++ )
290  {
291  unsigned short objtype = (unsigned short)i;
292  readlandtile( objtype, &landtile );
293  if ( ( landtile.flags & flags ) == flags && ( ~landtile.flags & notflags ) == notflags )
294  {
295  INFO_PRINT << "Land Tile: 0x" << fmt::hexu( objtype ) << "\n"
296  << "\tflags: 0x" << fmt::hexu( landtile.flags ) << "\n"
297  << "\t unk: 0x" << fmt::hexu( landtile.unk ) << "\n"
298  << "\t name: " << landtile.name << "\n";
299  }
300  }
302  return 0;
303 }
304 
305 static int loschange( int /*argc*/, char** /*argv*/ )
306 {
307  Core::USTRUCT_TILE tile;
308 
311 
312  for ( int i = 0; i <= 0xFFFF; i++ )
313  {
314  unsigned short objtype = (unsigned short)i;
315  read_objinfo( objtype, tile );
316 
317  bool old_lostest = ( tile.flags & Core::USTRUCT_TILE::FLAG_WALKBLOCK ) != 0;
318 
319  bool new_lostest = ( tile.flags & ( Core::USTRUCT_TILE::FLAG_WALKBLOCK |
321 
322  if ( old_lostest != new_lostest )
323  {
324  display_tileinfo( objtype, tile );
325  INFO_PRINT.Format( " Old LOS: %s\n New LOS: %s\n" )
326  << ( old_lostest ? "true" : "false" ) << ( new_lostest ? "true" : "false" );
327  }
328  }
330  return 0;
331 }
332 
333 static int print_verdata_info()
334 {
337  int num_version_records;
339 
340  // FIXME: should read this once per run, per file.
341  fseek( Core::verfile, 0, SEEK_SET );
342  fread( &num_version_records, sizeof num_version_records, 1, Core::verfile ); // ENDIAN-BROKEN
343 
344  INFO_PRINT << "There are " << num_version_records << " version records.\n";
345 
346  int filecount[32];
347  int inv_filecount = 0;
348  memset( filecount, 0, sizeof filecount );
349 
350  for ( int i = 0; i < num_version_records; i++ )
351  {
352  fread( &vrec, sizeof vrec, 1, Core::verfile );
353  if ( vrec.file < 32 )
354  ++filecount[vrec.file];
355  else
356  ++inv_filecount;
357  }
358  for ( int i = 0; i < 32; ++i )
359  {
360  if ( filecount[i] )
361  INFO_PRINT << "File 0x" << fmt::hexu( i ) << ": " << filecount[i] << " versioned blocks.\n";
362  }
363  if ( inv_filecount )
364  INFO_PRINT << inv_filecount << " invalid file indexes\n";
366  return 0;
367 }
368 
369 static int print_statics()
370 {
371  INFO_PRINT << "Reading UO data..\n";
374  int water = 0;
375  int strange_water = 0;
376  int cnt = 0;
377  for ( u16 y = 30; y < 50; y++ )
378  {
379  for ( u16 x = 5900; x < 5940; x++ )
380  {
381  std::vector<Core::StaticRec> vec;
382  Core::readallstatics( vec, x, y );
383 
384  if ( !vec.empty() )
385  {
386  bool hdrshown = false;
387  for ( const auto& elem : vec )
388  {
389  int height = Core::tileheight( elem.graphic );
390  if ( elem.graphic >= 0x1796 && elem.graphic <= 0x17b2 )
391  {
392  if ( elem.z == -5 && height == 0 )
393  water++;
394  else
395  strange_water++;
396  continue;
397  }
398  if ( !hdrshown )
399  INFO_PRINT << x << "," << y << ":\n";
400  hdrshown = true;
401  INFO_PRINT << "\tOBJT= 0x" << fmt::hexu( elem.graphic ) << " Z=" << int( elem.z )
402  << " HT=" << height << " FLAGS=0x"
403  << fmt::hexu( Core::tile_uoflags( elem.graphic ) ) << "\n";
404  ++cnt;
405  }
406  }
407  }
408  }
409  INFO_PRINT << cnt << " statics exist.\n"
410  << water << " water tiles exist.\n"
411  << strange_water << " strange water tiles exist.\n";
413  return 0;
414 }
415 
416 static int rawdump( int argc, char** argv )
417 {
418  if ( argc != 5 )
419  return 1;
420 
421  FILE* fp = fopen( argv[2], "rb" );
422  int hdrlen = atoi( argv[3] );
423  int reclen = atoi( argv[4] );
424  int recnum = 0;
425  if ( !fp )
426  return 1;
427 
428  if ( hdrlen )
429  {
430  if ( fread( buffer, hdrlen, 1, fp ) != 1 )
431  {
432  fclose( fp );
433  return 1;
434  }
435  fmt::Writer tmp;
436  tmp << "Header:\n";
437  Clib::fdump( tmp, buffer, hdrlen );
438  INFO_PRINT << tmp.str() << "\n";
439  }
440 
441  while ( fread( buffer, reclen, 1, fp ) == 1 )
442  {
443  fmt::Writer tmp;
444  tmp.Format( "Record {} (0x{:X}):\n" ) << recnum << recnum;
445  Clib::fdump( tmp, buffer, reclen );
446  INFO_PRINT << tmp.str() << "\n";
447 
448  ++recnum;
449  }
450  INFO_PRINT << recnum << " records read.\n";
451  fclose( fp );
452  return 0;
453 }
454 
455 static unsigned int read_ulong( std::istream& is )
456 {
457  unsigned char a[4];
458  is.read( (char*)a, sizeof a );
459  return ( a[3] << 24 ) | ( a[2] << 16 ) | ( a[1] << 8 ) | a[0];
460 }
461 
462 static int print_sndlist()
463 {
464  unsigned int offset;
465  unsigned int length;
466  unsigned int serial;
467  char filename[15];
468 
469  std::string soundidxname = Plib::systemstate.config.uo_datafile_root + "soundidx.mul";
470  std::string soundname = Plib::systemstate.config.uo_datafile_root + "sound.mul";
471  std::ifstream soundidx( soundidxname.c_str(), std::ios::in | std::ios::binary );
472  std::ifstream sound( soundname.c_str(), std::ios::in | std::ios::binary );
473  int i;
474  i = 0;
475  while ( soundidx.good() )
476  {
477  ++i;
478  offset = read_ulong( soundidx );
479  length = read_ulong( soundidx );
480  serial = read_ulong( soundidx );
481  if ( !soundidx.good() )
482  break;
483 
484  if ( offset == 0xFFffFFffLu )
485  continue;
486 
487  sound.seekg( offset, std::ios::beg );
488  if ( !sound.good() )
489  break;
490 
491  sound.read( filename, sizeof filename );
492  INFO_PRINT << "0x" << fmt::hexu( i ) << ", 0x" << fmt::hexu( serial ) << ": " << filename
493  << "\n"
494  << "len " << length << "\n";
495  }
496  return 0;
497 }
498 
499 static void print_multihull( u16 i, Multi::MultiDef* multi )
500 {
501  if ( multi->hull.empty() )
502  return;
503 
504  Core::USTRUCT_TILE tile;
505  read_objinfo( static_cast<u16>( i + ( Plib::systemstate.config.max_tile_id + 1 ) ), tile );
506  INFO_PRINT << "Multi 0x" << fmt::hexu( i + i + ( Plib::systemstate.config.max_tile_id + 1 ) )
507  << " -- " << tile.name << ":\n";
508  fmt::Writer tmp;
509  for ( short y = multi->minry; y <= multi->maxry; ++y )
510  {
511  for ( short x = multi->minrx; x <= multi->maxrx; ++x )
512  {
513  unsigned short key = multi->getkey( x, y );
514  bool external = multi->hull2.count( key ) != 0;
515  bool internal = multi->internal_hull2.count( key ) != 0;
516  bool origin = ( x == 0 && y == 0 );
517 
518  if ( external && !internal )
519  tmp << 'H';
520  else if ( !external && internal )
521  tmp << 'i';
522  else if ( external && internal )
523  tmp << 'I';
524  else if ( origin )
525  tmp << '*';
526  else
527  tmp << ' ';
528  }
529  tmp << "\n";
530  }
531  tmp << "\n";
532  INFO_PRINT << tmp.str();
533 }
534 
535 static void print_multidata( u16 i, Multi::MultiDef* multi )
536 {
537  if ( multi->hull.empty() )
538  return;
539 
540  Core::USTRUCT_TILE tile;
541  read_objinfo( static_cast<u16>( i + ( Plib::systemstate.config.max_tile_id + 1 ) ), tile );
542  INFO_PRINT << "Multi 0x" << fmt::hexu( i + ( Plib::systemstate.config.max_tile_id + 1 ) )
543  << " -- " << tile.name << ":\n";
544  fmt::Writer tmp;
545  for ( const auto& _itr : multi->components )
546  {
547  const Multi::MULTI_ELEM* elem = _itr.second;
548  tmp << "0x" << fmt::hexu( elem->objtype ) << " 0x" << fmt::hexu( (int)elem->is_static ) << ":"
549  << elem->x << "," << elem->y << "," << elem->z << "\n";
550  }
551  INFO_PRINT << tmp.str();
552 }
553 
554 static int print_multis()
555 {
556  INFO_PRINT << "Reading UO data..\n";
560 
561  for ( u16 i = 0; i < 0x1000; ++i )
562  {
563  if ( Multi::multidef_buffer.multidefs_by_multiid[i] )
564  {
565  print_multihull( i, Multi::multidef_buffer.multidefs_by_multiid[i] );
566  print_multidata( i, Multi::multidef_buffer.multidefs_by_multiid[i] );
567  }
568  }
570  return 0;
571 }
572 
573 static int z_histogram()
574 {
575  unsigned int zcount[256];
576  memset( zcount, 0, sizeof( zcount ) );
577 
578  INFO_PRINT << "Reading UO data..\n";
581  for ( u16 x = 0; x < 6143; ++x )
582  {
583  INFO_PRINT << ".";
584  for ( u16 y = 0; y < 4095; ++y )
585  {
587  short z;
588  getmapinfo( x, y, &z, &mi );
589  assert( z >= Core::ZCOORD_MIN && z <= Core::ZCOORD_MAX );
590  ++zcount[z + 128];
591  }
592  }
593  INFO_PRINT << "\n";
594  for ( int i = 0; i < 256; ++i )
595  {
596  if ( zcount[i] )
597  INFO_PRINT << i - 128 << ": " << zcount[i] << "\n";
598  }
600  return 0;
601 }
602 
603 static int statics_histogram()
604 {
605  unsigned int counts[1000];
606  memset( counts, 0, sizeof counts );
607  INFO_PRINT << "Reading UO data..\n";
610  for ( u16 x = 0; x < 6143; x += 8 )
611  {
612  INFO_PRINT << ".";
613  for ( u16 y = 0; y < 4095; y += 8 )
614  {
615  std::vector<Core::USTRUCT_STATIC> p;
616  int count;
617 
618  readstaticblock( &p, &count, x, y );
619  if ( count < 1000 )
620  ++counts[count];
621  else
622  ERROR_PRINT << "doh: count=" << count << "\n";
623  }
624  }
625  INFO_PRINT << "\n";
626  for ( int i = 0; i < 1000; ++i )
627  {
628  if ( counts[i] )
629  INFO_PRINT << i << ": " << counts[i] << "\n";
630  }
632  return 0;
633 }
634 
635 static int write_polmap( const char* filename, unsigned short xbegin, unsigned short xend )
636 {
637  INFO_PRINT << "Writing " << filename << "\n";
638  FILE* fp = fopen( filename, "wb" );
639  int num = xend + 1 - xbegin;
640  for ( u16 xs = xbegin; xs < xend; xs += 8 )
641  {
642  int percent = ( xs - xbegin ) * 100 / num;
643  INFO_PRINT << "\r" << percent << "%";
644  for ( u16 ys = 0; ys < 4096; ys += 8 )
645  {
646  short z;
648  memset( &blk, 0, sizeof blk );
649  for ( u16 xi = 0; xi < 8; ++xi )
650  {
651  for ( u16 yi = 0; yi < 8; ++yi )
652  {
653  u16 x = xs + xi;
654  u16 y = ys + yi;
655  if ( x == 6143 )
656  x = 6142;
657  if ( y == 4095 )
658  y = 4094;
659  bool walkok = Core::groundheight( x, y, &z );
660  blk.z[xi][yi] = static_cast<signed char>( z );
661  if ( walkok )
662  blk.walkok[xi] |= ( 1 << yi );
663  }
664  }
665  fwrite( &blk, sizeof blk, 1, fp );
666  }
667  }
668  fclose( fp );
669  return 0;
670 }
671 
672 static int write_polmap()
673 {
674  INFO_PRINT << "Reading UO data..\n";
677  write_polmap( "dngnmap0.pol", 5120, 6144 );
678  write_polmap( "map0.pol", 0, 6144 );
680  return 0;
681 }
682 
683 static int print_water_data()
684 {
686  Core::readwater();
687  return 0;
688 }
689 
690 static bool has_water( u16 x, u16 y )
691 {
692  Core::StaticList vec;
693  vec.clear();
694  Core::readstatics( vec, x, y );
695  for ( const auto& rec : vec )
696  {
697  if ( iswater( rec.graphic ) )
698  return true;
699  }
700  return false;
701 }
702 
703 static int water_search()
704 {
705  u16 wxl = 1420, wxh = 1480, wyl = 1760, wyh = 1780;
707  for ( u16 y = wyl; y < wyh; y++ )
708  {
709  for ( u16 x = wxl; x < wxh; x++ )
710  {
711  if ( has_water( x, y ) )
712  INFO_PRINT << "W";
713  else
714  INFO_PRINT << ".";
715  }
716  INFO_PRINT << "\n";
717  }
718  INFO_PRINT << "\n";
719  return 0;
720 }
721 
722 static int mapdump( int argc, char* argv[] )
723 {
724  u16 wxl = 5485, wxh = 5500, wyl = 0, wyh = 30;
725 
726  if ( argc >= 4 )
727  {
728  wxl = wxh = static_cast<u16>( atoi( argv[2] ) );
729  wyl = wyh = static_cast<u16>( atoi( argv[3] ) );
730  }
731  if ( argc >= 6 )
732  {
733  wxh = static_cast<u16>( atoi( argv[4] ) );
734  wyh = static_cast<u16>( atoi( argv[5] ) );
735  }
736 
739 
740  std::ofstream ofs( "mapdump.html" );
741 
742  ofs << "<table border=1 cellpadding=5 cellspacing=0>" << std::endl;
743  ofs << "<tr><td>&nbsp;</td>";
744  for ( u16 x = wxl; x <= wxh; ++x )
745  {
746  ofs << "<td align=center>" << x << "</td>";
747  }
748  ofs << "</tr>" << std::endl;
749  for ( u16 y = wyl; y <= wyh; ++y )
750  {
751  ofs << "<tr><td valign=center>" << y << "</td>" << std::endl;
752  for ( u16 x = wxl; x <= wxh; ++x )
753  {
754  ofs << "<td align=left valign=top>";
755  short z;
757  safe_getmapinfo( x, y, &z, &mi );
758  Core::USTRUCT_LAND_TILE landtile;
759  readlandtile( mi.landtile, &landtile );
760  ofs << "z=" << z << "<br>";
761  ofs << "landtile=" << Clib::hexint( mi.landtile ) << " " << landtile.name << "<br>";
762  ofs << "&nbsp;flags=" << Clib::hexint( landtile.flags ) << "<br>";
763  ofs << "mapz=" << (int)mi.z << "<br>";
764 
765  Core::StaticList statics;
766  readallstatics( statics, x, y );
767  if ( !statics.empty() )
768  {
769  ofs << "<table border=1 cellpadding=5 cellspacing=0>" << std::endl;
770  ofs << "<tr><td>graphic</td><td>z</td><td>flags</td><td>ht</td>" << std::endl;
771  for ( const auto& rec : statics )
772  {
773  ofs << "<tr>";
774  ofs << "<td>" << Clib::hexint( rec.graphic ) << "</td>";
775  ofs << "<td>" << int( rec.z ) << "</td>";
776  ofs << "<td>" << Clib::hexint( rec.flags ) << "</td>";
777  ofs << "<td>" << int( rec.height ) << "</td>";
778  ofs << "</tr>" << std::endl;
779  }
780  ofs << "</table>" << std::endl;
781  }
782  ofs << "</td>" << std::endl;
783  }
784  ofs << "</tr>" << std::endl;
785  }
786  ofs << "</table>" << std::endl;
788  return 0;
789 }
790 
792 {
793  signed char z[6144][4096];
794 };
795 
796 static int contour()
797 {
800 
801  auto mc = new MapContour;
802  for ( u16 y = 0; y < 4095; ++y )
803  {
804  for ( u16 x = 0; x < 6143; ++x )
805  {
806  static Core::StaticList vec;
807 
808  vec.clear();
809 
810  readstatics( vec, x, y );
811 
812  bool result;
813  short newz;
814  standheight( Core::MOVEMODE_LAND, vec, x, y, 127, &result, &newz );
815  if ( result )
816  {
817  mc->z[x][y] = static_cast<signed char>( newz );
818  }
819  else
820  {
821  mc->z[x][y] = 127;
822  }
823  }
824  }
825 
826  std::ofstream ofs( "contour.dat", std::ios::trunc | std::ios::out | std::ios::binary );
827  ofs.write( reinterpret_cast<const char*>( mc ), sizeof( MapContour ) );
829  delete mc;
830  return 0;
831 }
832 
833 static int findlandtile( int /*argc*/, char** argv )
834 {
835  int landtile = strtoul( argv[1], NULL, 0 );
838 
839  for ( u16 y = 0; y < 4095; ++y )
840  {
841  for ( u16 x = 0; x < 6143; ++x )
842  {
843  short z;
845  safe_getmapinfo( x, y, &z, &mi );
846  if ( mi.landtile == landtile )
847  {
848  INFO_PRINT << x << "," << y << "," << (int)mi.z;
849  if ( mi.z != z )
850  INFO_PRINT << " (" << z << ")";
851  INFO_PRINT << "\n";
852  }
853  }
854  }
855 
857  return 0;
858 }
859 
860 static int findgraphic( int /*argc*/, char** argv )
861 {
862  int graphic = strtoul( argv[1], NULL, 0 );
863  INFO_PRINT << "Searching map for statics with graphic=0x" << fmt::hexu( graphic ) << "\n";
864 
867 
868  for ( u16 y = 0; y < 4095; ++y )
869  {
870  for ( u16 x = 0; x < 6143; ++x )
871  {
872  Core::StaticList statics;
873  readallstatics( statics, x, y );
874  for ( const auto& rec : statics )
875  {
876  if ( rec.graphic == graphic )
877  {
878  INFO_PRINT << x << "," << y << "," << rec.z << "\n";
879  }
880  }
881  }
882  }
884  return 0;
885 }
886 
887 static int findlandtileflags( int /*argc*/, char** argv )
888 {
889  unsigned int flags = strtoul( argv[1], NULL, 0 );
892 
893  for ( u16 y = 0; y < 4095; ++y )
894  {
895  for ( u16 x = 0; x < 6143; ++x )
896  {
897  short z;
899  safe_getmapinfo( x, y, &z, &mi );
900  if ( Core::landtile_uoflags( mi.landtile ) & flags )
901  {
902  INFO_PRINT << x << "," << y << "," << (int)mi.z << ": landtile 0x"
903  << fmt::hexu( mi.landtile ) << ", flags 0x"
904  << fmt::hexu( Core::landtile_uoflags( mi.landtile ) ) << "\n";
905  }
906  }
907  }
908 
910  return 0;
911 }
912 
913 static int defragstatics( int argc, char** argv )
914 {
915  const char* realm;
916  if ( argc < 2 )
917  realm = "britannia";
918  else
919  realm = argv[1];
920 
922 
923  Core::uo_mapid = descriptor.uomapid;
924  Core::uo_usedif = descriptor.uodif;
925  Core::uo_map_width = static_cast<unsigned short>( descriptor.width );
926  Core::uo_map_height = static_cast<unsigned short>( descriptor.height );
927 
930 
931  std::string statidx = "staidx" + Clib::tostring( Core::uo_mapid ) + ".mul";
932  std::string statics = "statics" + Clib::tostring( Core::uo_mapid ) + ".mul";
933  Clib::RemoveFile( statidx );
934  Clib::RemoveFile( statics );
935 
936  FILE* fidx = fopen( statidx.c_str(), "wb" );
937  FILE* fmul = fopen( statics.c_str(), "wb" );
938 
939  int lastprogress = -1;
940  for ( u16 x = 0; x < descriptor.width; x += Plib::STATICBLOCK_CHUNK )
941  {
942  int progress = x * 100L / descriptor.width;
943  if ( progress != lastprogress )
944  {
945  INFO_PRINT << "\rRewriting statics files: " << progress << "%";
946  lastprogress = progress;
947  }
948  for ( u16 y = 0; y < descriptor.height; y += Plib::STATICBLOCK_CHUNK )
949  {
950  std::vector<Core::USTRUCT_STATIC> pstat;
951  int num;
952  std::vector<Core::USTRUCT_STATIC> tilelist;
953  readstaticblock( &pstat, &num, x, y );
954  if ( num > 0 )
955  {
956  int currwritepos = ftell( fmul );
957  for ( int i = 0; i < num; ++i )
958  {
959  Core::USTRUCT_STATIC& tile = pstat[i];
960  if ( tile.graphic < 0x4000 )
961  {
962  bool first = true;
963  for ( const auto& stile : tilelist )
964  {
965  if ( ( tile.graphic == stile.graphic ) && ( tile.x_offset == stile.x_offset ) &&
966  ( tile.y_offset == stile.y_offset ) && ( tile.z == stile.z ) &&
967  ( tile.hue == stile.hue ) )
968  {
969  first = false;
970  break;
971  }
972  }
973  if ( first )
974  {
975  Core::USTRUCT_STATIC newtile;
976  newtile.graphic = tile.graphic;
977  newtile.x_offset = tile.x_offset;
978  newtile.y_offset = tile.y_offset;
979  newtile.z = tile.z;
980  newtile.hue = tile.hue;
981  tilelist.push_back( newtile );
982  }
983  }
984  }
985  Core::USTRUCT_IDX idx;
986  idx.offset = ~0u;
987  idx.length = ~0u;
988  idx.unknown = ~0u;
989  if ( !tilelist.empty() )
990  {
991  idx.offset = currwritepos;
992  for ( const auto& elem : tilelist )
993  {
994  fwrite( &elem, sizeof( Core::USTRUCT_STATIC ), 1, fmul );
995  }
996  currwritepos = ftell( fmul ) - currwritepos;
997  idx.length = currwritepos;
998  idx.unknown = 0;
999  tilelist.clear();
1000  }
1001  fwrite( &idx, sizeof idx, 1, fidx );
1002  }
1003  else
1004  {
1005  Core::USTRUCT_IDX idx;
1006  idx.offset = ~0u;
1007  idx.length = ~0u;
1008  idx.unknown = ~0u;
1009  fwrite( &idx, sizeof idx, 1, fidx );
1010  }
1011  }
1012  }
1013 
1014  INFO_PRINT << "\rRewriting statics files: Complete\n";
1015  fclose( fidx );
1016  fclose( fmul );
1017  return 0;
1018 }
1019 
1020 static int format_description( int argc, char** argv )
1021 {
1022  std::string name = "";
1023  for ( int i = 1; i < argc; ++i )
1024  {
1025  name.append( argv[i] );
1026  if ( i < ( argc - 1 ) )
1027  name.append( " " );
1028  }
1029  if ( name.length() == 0 )
1030  return 1;
1031  for ( unsigned short amount = 1; amount <= 2; ++amount )
1032  {
1033  const char* src = name.c_str();
1034 
1035  std::string desc;
1036 
1037  if ( amount != 1 )
1038  {
1039  char s[15];
1040  sprintf( s, "%hu ", amount );
1041  desc = s;
1042  }
1043 
1044  int singular = ( amount == 1 );
1045  int plural_handled = 0;
1046  int phase = 0; /* 0= first part, 1=plural part, 2=singular part, 3=rest */
1047  char ch;
1048  while ( '\0' != ( ch = *src ) )
1049  {
1050  if ( phase == 0 )
1051  {
1052  if ( ch == '%' )
1053  {
1054  plural_handled = 1;
1055  phase = 1;
1056  }
1057  else
1058  {
1059  desc += ch;
1060  }
1061  }
1062  else if ( phase == 1 )
1063  {
1064  if ( ch == '%' )
1065  phase = 3;
1066  else if ( ch == '/' )
1067  phase = 2;
1068  else if ( !singular )
1069  desc += ch;
1070  }
1071  else if ( phase == 2 )
1072  {
1073  if ( ch == '%' )
1074  phase = 3;
1075  else if ( singular )
1076  desc += ch;
1077  }
1078  // if phase == 3 that means there are more words to come,
1079  // lets loop through them to support singular/plural stuff in more than just the first word of
1080  // the desc.
1081  else
1082  {
1083  desc += ch;
1084  phase = 0;
1085  }
1086  ++src;
1087  }
1088 
1089  if ( !singular && !plural_handled )
1090  desc += 's';
1091 
1092  if ( amount == 1 )
1093  INFO_PRINT << "Singular: " << desc << "\n";
1094  else
1095  INFO_PRINT << "Plural: " << desc << "\n";
1096  }
1097  return 0;
1098 }
1099 
1100 static int checkmultis()
1101 {
1102  FILE* multi_idx = Core::open_uo_file( "multi.idx" );
1103  FILE* multi_mul = Core::open_uo_file( "multi.mul" );
1104  if ( fseek( multi_idx, 0, SEEK_SET ) != 0 )
1105  {
1106  fclose( multi_idx );
1107  fclose( multi_mul );
1108  INFO_PRINT << "Failed seek check\n";
1109  return 0;
1110  }
1111  unsigned count = 0;
1112  unsigned warnings = 0;
1113  unsigned errors = 0;
1114  unsigned invisitems = 0;
1116  for ( int i = 0; fread( &idxrec, sizeof idxrec, 1, multi_idx ) == 1; ++i )
1117  {
1118  if ( idxrec.offset == 0xFFffFFffLu )
1119  continue;
1120  fseek( multi_mul, idxrec.offset, SEEK_SET );
1122  fread( &elem, sizeof elem, 1, multi_mul );
1123  if ( elem.x != 0 || elem.y != 0 || elem.z != 0 )
1124  {
1125  INFO_PRINT << "ERROR: First tile not in center: " << elem.x << " " << elem.y << " " << elem.z
1126  << " (" << elem.flags << ") MultiID: 0x" << fmt::hexu( i ) << "\n";
1127  ++errors;
1128  }
1129  else if ( elem.graphic == 0x0001 )
1130  {
1131  ++invisitems;
1132  unsigned int itemcount = idxrec.length / sizeof elem;
1133  --itemcount;
1134  while ( itemcount-- )
1135  {
1136  fread( &elem, sizeof elem, 1, multi_mul );
1137  if ( elem.x == 0 && elem.y == 0 && elem.z == 0 && elem.graphic != 0x0001 && elem.flags )
1138  {
1139  INFO_PRINT << "Warning: Found invis tile as center, but could use 0x"
1140  << fmt::hexu( elem.graphic ) << " at 0 0 0 MultiID: 0x" << fmt::hexu( i )
1141  << "\n";
1142  ++warnings;
1143  break;
1144  }
1145  }
1146  }
1147  ++count;
1148  }
1149  INFO_PRINT << "Checked Multis: " << count << " with invis center: " << invisitems
1150  << " Warnings: " << warnings << " Errors: " << errors << "\n";
1151  fclose( multi_idx );
1152  fclose( multi_mul );
1153  return 1;
1154 }
1155 
1156 
1158 
1159 UoToolMain::UoToolMain() : Pol::Clib::ProgramMain() {}
1162 
1164 {
1165  ERROR_PRINT << "Usage:\n"
1166  << " \n"
1167  << " UOTOOL command [options ...]\n"
1168  << " \n"
1169  << " Commands:\n"
1170  << " tiledump filename Dump object information\n"
1171  << " vertile Dump updated object info\n"
1172  << " rawdump filename hdrlen reclen\n"
1173  << " ctable Print Server encryption table\n"
1174  << " findgraphic graphic finds coords of statics with graphic\n"
1175  << " findlandtileflags flags finds landtiles with flags\n"
1176  << " contour write binary file 6144x4096 z heights\n"
1177  << " mapdump x1 y1 [x2 y2] dumps map+statics info to html tables\n"
1178  << " landtileflagsearch flags [notflags] prints landtiles matching args\n"
1179  << " flagsearch flags [notflags] prints tiles matching flags\n"
1180  << " landtilehist prints landtile histogram\n"
1181  << " staticshist histogram of number of statics at a location\n"
1182  << " zhist histogram of map z\n"
1183  << " multis prints multi definitions \n"
1184  << " verdata prints verdata info\n"
1185  << " statics prints statics info\n"
1186  << " sndlist prints sound list info\n"
1187  << " verlandtile prints verdata landtile info\n"
1188  << " loschange prints differences in LOS handling \n"
1189  << " staticdefrag [realm] recreates static files {default britannia} \n"
1190  << " formatdesc name prints plural and singular form of name \n"
1191  << " checkmultis prints infos about multi center items \n";
1192 }
1193 
1194 static int s_argc;
1195 static char** s_argv;
1196 
1198 {
1199  const std::vector<std::string>& binArgs = programArgs();
1200 
1201  /**********************************************
1202  * show help
1203  **********************************************/
1204  if ( binArgs.size() == 1 )
1205  {
1206  showHelp();
1207  return 0; // return "okay"
1208  }
1209 
1210  /**********************************************
1211  * TODO: rework the following cruft from former uotool.cpp
1212  **********************************************/
1213  Clib::ConfigFile cf( "pol.cfg" );
1214  Clib::ConfigElem elem;
1215 
1216  cf.readraw( elem );
1217 
1218  Plib::systemstate.config.uo_datafile_root = elem.remove_string( "UoDataFileRoot" );
1220  Clib::normalized_dir_form( Plib::systemstate.config.uo_datafile_root );
1221 
1222  unsigned short max_tile = elem.remove_ushort( "MaxTileID", UOBJ_DEFAULT_MAX );
1223 
1224  if ( max_tile != UOBJ_DEFAULT_MAX && max_tile != UOBJ_SA_MAX && max_tile != UOBJ_HSA_MAX )
1226  else
1228 
1229  std::string argvalue = binArgs[1];
1230  if ( argvalue[0] == '/' || argvalue[0] == ':' )
1231  {
1233  if ( binArgs.size() < 3 )
1234  {
1235  showHelp();
1236  return 0;
1237  }
1238  argvalue = binArgs[2];
1239  }
1240 
1241  std::transform( argvalue.begin(), argvalue.end(), argvalue.begin(),
1242  []( char c ) { return static_cast<char>( ::tolower( c ) ); } );
1243 
1244  if ( argvalue == "tiledump" )
1245  {
1246  return UoTool::tiledump( s_argc, s_argv );
1247  }
1248  else if ( argvalue == "vertile" )
1249  {
1250  return UoTool::vertile();
1251  }
1252  else if ( argvalue == "verlandtile" )
1253  {
1254  return UoTool::verlandtile();
1255  }
1256  else if ( argvalue == "landtilehist" )
1257  {
1258  return UoTool::landtilehist();
1259  }
1260  else if ( argvalue == "flagsearch" )
1261  {
1262  return UoTool::flagsearch( s_argc, s_argv );
1263  }
1264  else if ( argvalue == "landtileflagsearch" )
1265  {
1266  return UoTool::landtileflagsearch( s_argc, s_argv );
1267  }
1268  else if ( argvalue == "loschange" )
1269  {
1270  return UoTool::loschange( s_argc, s_argv );
1271  }
1272  else if ( argvalue == "rawdump" )
1273  {
1274  return UoTool::rawdump( s_argc, s_argv );
1275  }
1276  else if ( argvalue == "ctable" )
1277  {
1278  return UoTool::print_ctable();
1279  }
1280  else if ( argvalue == "sndlist" )
1281  {
1282  return UoTool::print_sndlist();
1283  }
1284  else if ( argvalue == "statics" )
1285  {
1286  return UoTool::print_statics();
1287  }
1288  else if ( argvalue == "verdata" )
1289  {
1290  return UoTool::print_verdata_info();
1291  }
1292  else if ( argvalue == "multis" )
1293  {
1294  return UoTool::print_multis();
1295  }
1296  else if ( argvalue == "water" )
1297  {
1298  return UoTool::print_water_data();
1299  }
1300  else if ( argvalue == "newstatics" )
1301  {
1302  return Core::write_pol_static_files( "main" );
1303  }
1304  else if ( argvalue == "staticsmax" )
1305  {
1307  Core::staticsmax();
1308  return 0;
1309  }
1310  else if ( argvalue == "watersearch" )
1311  {
1312  return UoTool::water_search();
1313  }
1314  else if ( argvalue == "zhist" )
1315  {
1316  return UoTool::z_histogram();
1317  }
1318  else if ( argvalue == "staticshist" )
1319  {
1320  return UoTool::statics_histogram();
1321  }
1322  else if ( argvalue == "writedungmap" )
1323  {
1324  return UoTool::write_polmap();
1325  }
1326  else if ( argvalue == "writekeys" )
1327  {
1328  INFO_PRINT << "Keys written to current.key\n";
1329  return 0;
1330  }
1331  else if ( argvalue == "mapdump" )
1332  {
1333  return UoTool::mapdump( s_argc, s_argv );
1334  }
1335  else if ( argvalue == "contour" )
1336  {
1337  return UoTool::contour();
1338  }
1339  else if ( argvalue == "findlandtile" )
1340  {
1341  return UoTool::findlandtile( s_argc - 1, s_argv + 1 );
1342  }
1343  else if ( argvalue == "findlandtileflags" )
1344  {
1345  return UoTool::findlandtileflags( s_argc - 1, s_argv + 1 );
1346  }
1347  else if ( argvalue == "findgraphic" )
1348  {
1349  return UoTool::findgraphic( s_argc - 1, s_argv + 1 );
1350  }
1351  else if ( argvalue == "defragstatics" )
1352  {
1353  return UoTool::defragstatics( s_argc - 1, s_argv + 1 );
1354  }
1355  else if ( argvalue == "formatdesc" )
1356  {
1357  return UoTool::format_description( s_argc - 1, s_argv + 1 );
1358  }
1359  else if ( argvalue == "checkmultis" )
1360  {
1361  return UoTool::checkmultis();
1362  }
1363 
1364  showHelp();
1365  return 0;
1366 }
1367 }
1368 } // namespaces
1369 
1373 
1374 int main( int argc, char* argv[] )
1375 {
1376  Pol::UoTool::s_argc = argc;
1377  Pol::UoTool::s_argv = argv;
1378 
1380  UoToolMain->start( argc, argv );
1381 }
#define TILES_START
Definition: UoToolMain.cpp:111
static RealmDescriptor Load(const std::string &realm_name, const std::string &realm_path="")
void staticsmax()
Definition: uofile05.cpp:17
static int print_statics()
Definition: UoToolMain.cpp:369
static int z_histogram()
Definition: UoToolMain.cpp:573
static int print_multis()
Definition: UoToolMain.cpp:554
static int findlandtileflags(int, char **argv)
Definition: UoToolMain.cpp:887
static int print_verdata_info()
Definition: UoToolMain.cpp:333
std::string remove_string(const char *propname)
Definition: cfgfile.cpp:381
const std::vector< std::string > & programArgs() const
static int write_polmap()
Definition: UoToolMain.cpp:672
std::vector< StaticRec > StaticList
Definition: udatfile.h:38
void readstatics(StaticList &vec, unsigned short x, unsigned short y)
Definition: uofile07.cpp:20
SystemState systemstate
Definition: systemstate.cpp:12
void readallstatics(StaticList &vec, unsigned short x, unsigned short y)
Definition: uofile07.cpp:84
Core::PolConfig config
Definition: systemstate.h:43
unsigned int tile_uoflags(unsigned short tilenum)
Definition: polfile2.cpp:61
static int vertile()
Definition: UoToolMain.cpp:174
void open_uo_data_files(void)
Definition: uofile00.cpp:91
void clear_tiledata()
Definition: uofile01.cpp:389
bool BoatShapeExists(u16 multiid)
Definition: boat.cpp:276
char * binary(unsigned int val, int nbits)
static unsigned int read_ulong(std::istream &is)
Definition: UoToolMain.cpp:455
virtual void showHelp()
void read_objinfo(u16 graphic, struct USTRUCT_TILE &objinfo)
Definition: uofile01.cpp:223
STL namespace.
HullList2 internal_hull2
Definition: multidef.h:80
Components components
Definition: multidef.h:87
const unsigned STATICBLOCK_CHUNK
Definition: staticblock.h:37
static int landtilehist()
Definition: UoToolMain.cpp:216
void start(int argc, char *argv[])
Definition: ProgramMain.cpp:42
static int print_water_data()
Definition: UoToolMain.cpp:683
void getmapinfo(unsigned short x, unsigned short y, short *z, USTRUCT_MAPINFO *mi)
Definition: uofile08.cpp:99
#define UOBJ_SA_MAX
Definition: objtype.h:16
void fdump(fmt::Writer &writer, const void *data, int len)
Definition: fdump.cpp:40
unsigned int max_tile_id
Definition: polcfg.h:61
static unsigned short getkey(short rx, short ry)
Definition: multidef.h:128
void readlandtile(unsigned short tilenum, USTRUCT_LAND_TILE *landtile)
Definition: uofile01.cpp:163
void readraw(ConfigElem &elem)
Definition: cfgfile.cpp:1028
#define UOBJ_HSA_MAX
Definition: objtype.h:15
#define UOBJ_DEFAULT_MAX
Definition: objtype.h:17
int uo_mapid
Definition: uofile00.cpp:85
std::string hexint(unsigned short v)
Definition: strutil.cpp:23
unsigned short u16
Definition: rawtypes.h:26
unsigned char buffer[10000]
Definition: UoToolMain.cpp:109
unsigned int u32
Definition: rawtypes.h:27
void readwater()
Definition: uofile04.cpp:25
unsigned int landtile_uoflags(unsigned short landtile)
Definition: landtile.cpp:41
void safe_getmapinfo(unsigned short x, unsigned short y, short *z, USTRUCT_MAPINFO *mi)
Definition: uofile08.cpp:129
static int loschange(int, char **)
Definition: UoToolMain.cpp:305
static int defragstatics(int argc, char **argv)
Definition: UoToolMain.cpp:913
USTRUCT_IDX idxrec
Definition: uofile02.cpp:34
static int verlandtile()
Definition: UoToolMain.cpp:192
const short ZCOORD_MIN
Definition: poltype.h:15
static int findlandtile(int, char **argv)
Definition: UoToolMain.cpp:833
static int statics_histogram()
Definition: UoToolMain.cpp:603
std::string tostring(const Bscript::BTokenType &v)
Definition: tokens.cpp:19
static int print_ctable()
Definition: UoToolMain.cpp:83
std::set< unsigned int > water
Definition: uofile04.cpp:18
void readstaticblock(std::vector< USTRUCT_STATIC > *ppst, int *pnum, unsigned short x, unsigned short y)
Definition: uofile02.cpp:68
void standheight(MOVEMODE movemode, StaticList &statics, unsigned short x, unsigned short y, short oldz, bool *result_out, short *newz_out)
Definition: uofile06.cpp:27
char tileheight(unsigned short tilenum)
Definition: polfile2.cpp:34
HullList2 hull2
Definition: multidef.h:79
static void print_multihull(u16 i, Multi::MultiDef *multi)
Definition: UoToolMain.cpp:499
static int flagsearch(int argc, char **argv)
Definition: UoToolMain.cpp:244
static void print_multidata(u16 i, Multi::MultiDef *multi)
Definition: UoToolMain.cpp:535
static int tiledump(int argc, char **argv)
Definition: UoToolMain.cpp:142
static int water_search()
Definition: UoToolMain.cpp:703
static char ** s_argv
static void display_tileinfo(unsigned short objtype, const Core::USTRUCT_TILE &tile)
Definition: UoToolMain.cpp:113
static int findgraphic(int, char **argv)
Definition: UoToolMain.cpp:860
bool groundheight(unsigned short x, unsigned short y, short *z)
Definition: uofile08.cpp:77
FILE * verfile
Definition: uofile00.cpp:24
unsigned short uo_map_height
Definition: uofile00.cpp:90
static int mapdump(int argc, char *argv[])
Definition: UoToolMain.cpp:722
static int print_sndlist()
Definition: UoToolMain.cpp:462
static int format_description(int argc, char **argv)
static int s_argc
static bool has_water(u16 x, u16 y)
Definition: UoToolMain.cpp:690
static int landtileflagsearch(int argc, char **argv)
Definition: UoToolMain.cpp:273
static int rawdump(int argc, char **argv)
Definition: UoToolMain.cpp:416
void read_uo_data(void)
Definition: uofile01.cpp:414
const short ZCOORD_MAX
Definition: poltype.h:16
void RemoveFile(const std::string &fname)
Definition: fileutil.cpp:143
static int write_polmap(const char *filename, unsigned short xbegin, unsigned short xend)
Definition: UoToolMain.cpp:635
unsigned short remove_ushort(const char *propname)
Definition: cfgfile.cpp:318
std::string name
Definition: osmod.cpp:943
static int contour()
Definition: UoToolMain.cpp:796
FILE * open_uo_file(const std::string &filename_part)
Definition: uofile00.cpp:47
unsigned short uo_map_width
Definition: uofile00.cpp:89
int uo_usedif
Definition: uofile00.cpp:86
#define ERROR_PRINT
Definition: logfacility.h:230
void read_multidefs()
Definition: multidef.cpp:309
std::string normalized_dir_form(const std::string &istr)
Definition: fileutil.cpp:25
std::string uo_datafile_root
Definition: polcfg.h:27
#define INFO_PRINT
Definition: logfacility.h:223
static int checkmultis()
Definition: berror.cpp:12
int write_pol_static_files(const std::string &realm)
Definition: polfile1.cpp:50
MultiDefBuffer multidef_buffer
Definition: multidefs.cpp:19
unsigned short objtype
Definition: multidef.h:46
bool iswater(u16 objtype)
Definition: uofile04.cpp:20