Pol  Revision:cb584c9
realmfunc.cpp
Go to the documentation of this file.
1 
17 #include <stddef.h>
18 
19 #include "../../clib/rawtypes.h"
20 #include "../../plib/mapcell.h"
21 #include "../../plib/mapserver.h"
22 #include "../../plib/mapshape.h"
23 #include "../../plib/maptile.h"
24 #include "../../plib/maptileserver.h"
25 #include "../../plib/staticserver.h"
26 #include "../../plib/systemstate.h"
27 #include "../clidata.h"
28 #include "../fnsearch.h"
29 #include "../globals/uvars.h"
30 #include "../item/itemdesc.h"
31 #include "../mobile/charactr.h"
32 #include "../multi/customhouses.h"
33 #include "../multi/house.h"
34 #include "../multi/multi.h"
35 #include "../multi/multidef.h"
36 #include "../network/cgdata.h"
37 #include "../network/client.h"
38 #include "../objtype.h"
39 #include "../poltype.h"
40 #include "../tiles.h"
41 #include "../uconst.h"
42 #include "../udatfile.h"
43 #include "../uworld.h"
44 #include "realm.h"
45 
46 #define HULL_HEIGHT_BUFFER 2
47 namespace Pol
48 {
49 namespace Core
50 {
51 Items::Item* find_walkon_item( Core::ItemsVector& ivec, short z );
52 unsigned char flags_from_tileflags( unsigned int uoflags );
53 }
54 // namespace Multi {
55 // class UMulti;
56 // UMulti* find_supporting_multi( Realms::MultiList& mvec, short z );
57 // }
58 
59 namespace Realms
60 {
61 bool Realm::lowest_standheight( unsigned short x, unsigned short y, short* z ) const
62 {
63  static Plib::MapShapeList vec;
64  vec.clear();
65  getmapshapes(
66  vec, x, y,
68 
69  bool res = true;
70  lowest_standheight( Core::MOVEMODE_LAND, vec, *z, &res, z );
71  return res;
72 }
73 
74 void Realm::standheight( Core::MOVEMODE movemode, Plib::MapShapeList& shapes, short oldz,
75  bool* result_out, short* newz_out, short* gradual_boost )
76 {
77  static std::vector<const Plib::MapShape*> possible_shapes;
78  possible_shapes.clear();
79  bool land_ok = ( movemode & Core::MOVEMODE_LAND ) ? true : false;
80  bool sea_ok = ( movemode & Core::MOVEMODE_SEA ) ? true : false;
81  bool fly_ok = ( movemode & Core::MOVEMODE_FLY ) ? true : false;
82  short the_boost = 0;
83  short new_boost = 0;
84 
85  if ( gradual_boost != nullptr )
86  the_boost = *gradual_boost;
87  if ( the_boost < 5 )
88  the_boost = 5;
89 
90  short newz = -200;
91 
92  // first check only possible walkon shapes and build a list
93  for ( const auto& shape : shapes )
94  {
95  unsigned int flags = shape.flags;
96  short ztop = shape.z + shape.height;
97 #if ENABLE_POLTEST_OUTPUT
98  if ( static_debug_on )
99  {
100  INFO_PRINT << "static: graphic=0x" << fmt::hexu( srec.graphic ) << ", z=" << int( srec.z )
101  << ", ht=" << int( srec.height ) << "\n";
102  }
103 #endif
104 
105  if ( ( land_ok && ( flags & Plib::FLAG::MOVELAND ) ) ||
106  ( sea_ok && ( flags & Plib::FLAG::MOVESEA ) ) ||
107  ( fly_ok && ( flags & Plib::FLAG::OVERFLIGHT ) ) )
108  {
109  if ( ( ( ztop <= oldz + 2 + the_boost ) ||
110  ( ( flags & Plib::FLAG::GRADUAL ) &&
111  ( ztop <= oldz + 15 ) ) // not too high to step onto
112  || ( fly_ok && ( flags & Plib::FLAG::OVERFLIGHT ) &&
113  ( ztop <= oldz + 20 ) ) ) && // seems that flying allows higher steps
114  ( ztop >= newz ) ) // but above or same as the highest yet seen
115  {
116 #if ENABLE_POLTEST_OUTPUT
117  if ( static_debug_on )
118  INFO_PRINT << "Setting Z to " << int( ztemp ) << "\n";
119 #endif
120  possible_shapes.push_back( &shape );
121  newz = ztop;
122  }
123  }
124  if ( newz < shape.z &&
125  shape.z < newz + Core::settingsManager.ssopt
126  .default_character_height ) // space too small to stand?
127  {
128  if ( !possible_shapes.empty() )
129  possible_shapes.pop_back(); // remove the last pos_shape
130  }
131  }
132 
133  bool ret_result = false;
134  short ret_newz = -200;
135  if ( !possible_shapes.empty() )
136  {
137  // loop through all possible shapes and test if other shape blocks
138  for ( const auto& pos_shape : possible_shapes )
139  {
140  bool result = true;
141  newz = pos_shape->z + pos_shape->height;
142  for ( const auto& shape : shapes )
143  {
144  if ( ( shape.flags &
146  continue;
147  int shape_top = shape.z + shape.height;
148 
149  unsigned char default_character_height =
151  if ( ( newz < shape.z &&
152  // Must be left lower than 15 height like
153  // other checks, it will block char from walking down
154  // ladders in homes/dungeons if over 9.
155  shape.z <=
156  oldz + ( default_character_height < 9 ? default_character_height : 9 ) ) ||
157  ( shape.z < newz + default_character_height && shape_top > newz ) )
158  {
159 #if ENABLE_POLTEST_OUTPUT
160  if ( static_debug_on )
161  {
162  INFO_PRINT << "static: objtype=0x" << fmt::hexu( srec.graphic )
163  << ", z=" << int( srec.z ) << ", ht=" << int( srec.height )
164  << " blocks movement to z=" << int( newz ) << "\n";
165  }
166 #endif
167 
168  result = false;
169  break;
170  }
171  }
172  if ( result )
173  {
174  // if something was already found use the smallest step diff
175  if ( ( ret_result ) && ( labs( oldz - ret_newz ) < labs( oldz - newz ) ) )
176  continue;
177  ret_result = true;
178  ret_newz = newz;
179  if ( pos_shape->flags & Plib::FLAG::GRADUAL )
180  new_boost = pos_shape->height;
181  }
182  }
183  }
184 
185  *result_out = ret_result;
186  *newz_out = ret_newz;
187  if ( ret_result && ( gradual_boost != nullptr ) )
188  {
189  if ( new_boost > 11 )
190  *gradual_boost = 11;
191  else
192  *gradual_boost = new_boost;
193  }
194 }
195 
196 
197 void Realm::lowest_standheight( Core::MOVEMODE movemode, Plib::MapShapeList& shapes, short minz,
198  bool* result_out, short* newz_out, short* gradual_boost )
199 {
200  bool land_ok = ( movemode & Core::MOVEMODE_LAND ) ? true : false;
201  bool sea_ok = ( movemode & Core::MOVEMODE_SEA ) ? true : false;
202  bool fly_ok = ( movemode & Core::MOVEMODE_FLY ) ? true : false;
203  short the_boost = 0;
204  short new_boost = 0;
205 
206  if ( gradual_boost != nullptr )
207  the_boost = *gradual_boost;
208 
209  if ( shapes.size() == 1 ) // map only
210  {
211  const Plib::MapShape& shape = shapes.at( 0 );
212  if ( land_ok && ( shape.flags & ( Plib::FLAG::MOVELAND ) ) )
213  {
214  *result_out = true;
215  *newz_out = shape.z + shape.height;
216  return;
217  }
218  }
219 
220 
221  short newz = 255;
222  bool result = false;
223 
224  for ( const auto& shape : shapes )
225  {
226  unsigned int flags = shape.flags;
227  short ztop = shape.z + shape.height;
228 #if ENABLE_POLTEST_OUTPUT
229  if ( static_debug_on )
230  {
231  INFO_PRINT << "static: graphic=0x" << fmt::hexu( srec.graphic ) << ", z=" << int( srec.z )
232  << ", ht=" << int( srec.height ) << "\n";
233  }
234 #endif
235 
236  if ( the_boost < 5 )
237  the_boost = 5;
238 
239  if ( ( land_ok && ( flags & Plib::FLAG::MOVELAND ) ) ||
240  ( sea_ok && ( flags & Plib::FLAG::MOVESEA ) ) ||
241  ( fly_ok && ( flags & Plib::FLAG::OVERFLIGHT ) ) )
242  {
243  if ( ( ztop >= minz ) && // higher than our base
244  ( ztop < newz ) ) // lower than we've seen before
245  {
246 #if ENABLE_POLTEST_OUTPUT
247  if ( static_debug_on )
248  INFO_PRINT << "Setting Z to " << int( ztemp ) << "\n";
249 #endif
250  bool valid = true;
251  // validate that its actually standable
252  for ( const auto& shapeCheck : shapes )
253  {
254  if ( ( shapeCheck.flags &
255  ( Plib::FLAG::MOVELAND | Plib::FLAG::MOVESEA | Plib::FLAG::BLOCKING ) ) == 0 )
256  continue;
257 
258  unsigned char default_character_height =
260  if ( ( ( ztop < shapeCheck.z ) && // if the check-shape is higher than the location
261  ( shapeCheck.z < ztop + ( default_character_height < 9
262  ? default_character_height
263  : 9 ) ) ) // but low enough to block standing (9
264  // instead of 15 for ladders)
265  || // OR
266  ( ( shapeCheck.z <
267  ztop + default_character_height ) && // if the check-shape is sitting below the
268  // standing space of my new location
269  ( shapeCheck.z + shapeCheck.height >
270  ztop ) ) ) // and the top of the object is above my new location
271 
272  {
273 #if ENABLE_POLTEST_OUTPUT
274  if ( static_debug_on )
275  {
276  INFO_PRINT << "static: objtype=0x" << fmt::hexu( srec.graphic )
277  << ", z=" << int( srec.z ) << ", ht=" << int( srec.height )
278  << " blocks movement to z=" << int( newz ) << "\n";
279  }
280 #endif
281  valid = false;
282  break;
283  }
284  }
285 
286  // its the lowest and its legal
287  if ( valid )
288  {
289  newz = ztop;
290  result = true;
291  if ( flags & Plib::FLAG::GRADUAL )
292  new_boost = shape.height;
293  }
294  }
295  }
296  }
297 
298  *result_out = result;
299  *newz_out = newz;
300  if ( result && ( gradual_boost != nullptr ) )
301  {
302  if ( new_boost > 11 )
303  *gradual_boost = 11;
304  else
305  *gradual_boost = new_boost;
306  }
307 }
308 
309 
310 void Realm::readdynamics( Plib::MapShapeList& vec, unsigned short x, unsigned short y,
311  Core::ItemsVector& walkon_items, bool doors_block )
312 {
313  Core::ZoneItems& witems = Core::getzone( x, y, this ).items;
314  for ( const auto& item : witems )
315  {
316  if ( ( item->x == x ) && ( item->y == y ) )
317  {
318  if ( Core::tile_flags( item->graphic ) & Plib::FLAG::WALKBLOCK )
319  {
320  if ( doors_block || item->itemdesc().type != Items::ItemDesc::DOORDESC )
321  {
322  Plib::MapShape shape;
323  shape.z = item->z;
324  shape.height = item->height;
325  shape.flags = Plib::systemstate.tile[item->graphic].flags;
326  vec.push_back( shape );
327  }
328  }
329 
330  if ( !item->itemdesc().walk_on_script.empty() )
331  {
332  walkon_items.push_back( item );
333  }
334  }
335  }
336 }
337 
338 
339 // new Z given new X, Y, and old Z.
340 bool Realm::walkheight( unsigned short x, unsigned short y, short oldz, short* newz,
341  Multi::UMulti** pmulti, Items::Item** pwalkon, bool doors_block,
342  Core::MOVEMODE movemode, short* gradual_boost )
343 {
344  if ( x >= width() || y >= height() )
345  {
346  return false;
347  }
348 
349  static Plib::MapShapeList shapes;
350  static MultiList mvec;
351  static Core::ItemsVector walkon_items;
352  shapes.clear();
353  mvec.clear();
354  walkon_items.clear();
355 
356  readdynamics( shapes, x, y, walkon_items, doors_block /* true */ );
357  unsigned int flags = Plib::FLAG::MOVE_FLAGS;
358  if ( movemode & Core::MOVEMODE_FLY )
359  flags |= Plib::FLAG::OVERFLIGHT;
360  readmultis( shapes, x, y, flags, mvec );
361  getmapshapes( shapes, x, y, flags );
362 
363  bool result;
364  standheight( movemode, shapes, oldz, &result, newz, gradual_boost );
365 
366  if ( result && ( pwalkon != nullptr ) )
367  {
368  if ( !mvec.empty() )
369  {
370  *pmulti = find_supporting_multi( mvec, *newz );
371  }
372  else
373  {
374  *pmulti = nullptr;
375  }
376 
377  if ( !walkon_items.empty() )
378  {
379  *pwalkon = Core::find_walkon_item( walkon_items, *newz );
380  }
381  else
382  {
383  *pwalkon = nullptr;
384  }
385  }
386 
387  return result;
388 }
389 
390 // new Z given new X, Y, and old Z.
391 // dave: todo: return false if walking onto a custom house and not in the list of editing players,
392 // and no cmdlevel
393 bool Realm::walkheight( const Mobile::Character* chr, unsigned short x, unsigned short y,
394  short oldz, short* newz, Multi::UMulti** pmulti, Items::Item** pwalkon,
395  short* gradual_boost )
396 {
397  if ( x >= width() || y >= height() )
398  {
399  return false;
400  }
401 
402  static Plib::MapShapeList shapes;
403  static MultiList mvec;
404  static Core::ItemsVector walkon_items;
405  shapes.clear();
406  mvec.clear();
407  walkon_items.clear();
408 
409  readdynamics( shapes, x, y, walkon_items, chr->doors_block() );
410  unsigned int flags = Plib::FLAG::MOVE_FLAGS;
411  if ( chr->movemode & Core::MOVEMODE_FLY )
412  flags |= Plib::FLAG::OVERFLIGHT;
413  readmultis( shapes, x, y, flags, mvec );
414  getmapshapes( shapes, x, y, flags );
415 
416  bool result;
417  standheight( chr->movemode, shapes, oldz, &result, newz, gradual_boost );
418 
419  if ( result && ( pwalkon != nullptr ) )
420  {
421  if ( !mvec.empty() )
422  {
423  *pmulti = find_supporting_multi( mvec, *newz );
424  if ( *pmulti != nullptr )
425  {
426  Multi::UHouse* house = ( *pmulti )->as_house();
427  if ( house && house->editing && chr->client &&
428  ( chr->client->gd->custom_house_serial != house->serial ) )
429  result = false; // sendsysmessage to client ?
430  }
431  }
432  else
433  {
434  *pmulti = nullptr;
435  if ( chr->is_house_editing() )
436  {
438  if ( multi != nullptr )
439  {
440  Multi::UHouse* house = multi->as_house();
441  if ( house != nullptr )
442  {
443  Multi::CustomHouseStopEditing( const_cast<Mobile::Character*>( chr ), house );
445  }
446  }
447  }
448  }
449 
450  if ( !walkon_items.empty() )
451  {
452  *pwalkon = find_walkon_item( walkon_items, *newz );
453  }
454  else
455  {
456  *pwalkon = nullptr;
457  }
458  }
459 
460  return result;
461 }
462 
463 
464 bool Realm::lowest_walkheight( unsigned short x, unsigned short y, short oldz, short* newz,
465  Multi::UMulti** pmulti, Items::Item** pwalkon, bool doors_block,
466  Core::MOVEMODE movemode, short* gradual_boost )
467 {
468  if ( x >= width() || y >= height() )
469  {
470  return false;
471  }
472 
473  static Plib::MapShapeList shapes;
474  static MultiList mvec;
475  static Core::ItemsVector walkon_items;
476  shapes.clear();
477  mvec.clear();
478  walkon_items.clear();
479 
480  readdynamics( shapes, x, y, walkon_items, doors_block /* true */ );
481  unsigned int flags = Plib::FLAG::MOVE_FLAGS;
482  if ( movemode & Core::MOVEMODE_FLY )
483  flags |= Plib::FLAG::OVERFLIGHT;
484  readmultis( shapes, x, y, flags, mvec );
485  getmapshapes( shapes, x, y, flags );
486 
487  bool result;
488  lowest_standheight( movemode, shapes, oldz, &result, newz, gradual_boost );
489 
490  if ( result )
491  {
492  if ( !mvec.empty() )
493  {
494  *pmulti = find_supporting_multi( mvec, *newz );
495  }
496  else
497  {
498  *pmulti = nullptr;
499  }
500 
501  if ( !walkon_items.empty() )
502  {
503  *pwalkon = find_walkon_item( walkon_items, *newz );
504  }
505  else
506  {
507  *pwalkon = nullptr;
508  }
509  }
510 
511  return result;
512 }
513 
514 
515 bool Realm::dropheight( unsigned short dropx, unsigned short dropy, short dropz, short chrz,
516  short* newz, Multi::UMulti** pmulti )
517 {
518  if ( dropx >= width() || dropy >= height() )
519  {
520  return false;
521  }
522 
523  static Plib::MapShapeList shapes;
524  static MultiList mvec;
525  static Core::ItemsVector ivec;
526  shapes.clear();
527  mvec.clear();
528  ivec.clear();
529 
530  readdynamics( shapes, dropx, dropy, ivec, true /* doors_block */ );
531  readmultis( shapes, dropx, dropy, Plib::FLAG::DROP_FLAGS, mvec );
532  getmapshapes( shapes, dropx, dropy, Plib::FLAG::DROP_FLAGS );
533 
534  bool result = dropheight( shapes, dropz, chrz, newz );
535  if ( result )
536  {
537  if ( !mvec.empty() )
538  {
539  *pmulti = find_supporting_multi( mvec, *newz );
540  }
541  else
542  {
543  *pmulti = nullptr;
544  }
545  }
546  return result;
547 }
548 
549 // used to be statics_dropheight
550 bool Realm::dropheight( Plib::MapShapeList& shapes, short dropz, short chrz, short* newz )
551 {
552  short z = Core::ZCOORD_MIN;
553  bool result = false;
554 
555  for ( const auto& shape : shapes )
556  {
557  unsigned int flags = shape.flags;
558  short ztop = shape.z + shape.height;
559 #if ENABLE_POLTEST_OUTPUT
560  if ( static_debug_on )
561  {
562  INFO_PRINT << "static: graphic=0x" << fmt::hexu( srec.graphic ) << ", z=" << int( srec.z )
563  << ", ht=" << int( tileheight( srec.graphic ) ) << "\n";
564  }
565 #endif
566 
567  if ( flags & Plib::FLAG::ALLOWDROPON )
568  {
569  if ( ( ztop <=
570  chrz +
571  Core::settingsManager.ssopt.default_character_height ) && // not too high to reach
572  ( ztop >= z ) ) // but above or same as the highest yet seen
573  { // NOTE, the >= here is so statics at ground height
574  // will override a blocking map tile.
575 #if ENABLE_POLTEST_OUTPUT
576  if ( static_debug_on )
577  INFO_PRINT << "Setting Z to " << int( ztemp ) << "\n";
578 #endif
579  z = ztop;
580  result = true;
581  }
582  }
583  }
584 
585  *newz = z;
586 
587  if ( result )
588  {
589  for ( const auto& shape : shapes )
590  {
591  if ( shape.flags & Plib::FLAG::BLOCKING )
592  {
593  short ztop = shape.z + shape.height;
594 
595  if ( shape.z <= z && // location blocked by some object
596  z < ztop )
597  {
598 #if ENABLE_POLTEST_OUTPUT
599  if ( static_debug_on )
600  {
601  INFO_PRINT << "static: objtype=0x" << fmt::hexu( srec.graphic )
602  << ", z=" << int( srec.z ) << ", ht=" << int( tileheight( srec.graphic ) )
603  << " blocks movement to z=" << int( z ) << "\n";
604  }
605 #endif
606  result = false;
607  break;
608  }
609  else if ( z < ztop && ztop <= dropz )
610  {
611  // a blocking item somewhere between where they _tried_ to drop it,
612  // and where we decided to place it.
613  result = false;
614  break;
615  }
616  }
617  }
618  }
619 
620  return result;
621 }
622 
623 void Realm::readmultis( Plib::MapShapeList& vec, unsigned short x, unsigned short y,
624  unsigned int anyflags ) const
625 {
626  Core::WorldIterator<Core::MultiFilter>::InRange( x, y, this, 64, [&]( Multi::UMulti* multi ) {
627  Multi::UHouse* house = multi->as_house();
628  if ( house != nullptr && house->IsCustom() ) // readshapes switches to working design if the
629  // house is being edited,
630  // everyone in the house would use it for walking...
631  multi->readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z );
632  else
633  {
634  const Multi::MultiDef& def = multi->multidef();
635  def.readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z, anyflags );
636  }
637  } );
638 }
639 
640 void Realm::readmultis( Plib::MapShapeList& vec, unsigned short x, unsigned short y,
641  unsigned int anyflags, MultiList& mvec ) const
642 {
643  Core::WorldIterator<Core::MultiFilter>::InRange( x, y, this, 64, [&]( Multi::UMulti* multi ) {
644  Multi::UHouse* house = multi->as_house();
645  if ( house != nullptr && house->IsCustom() )
646  {
647  if ( multi->readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z ) )
648  mvec.push_back( multi );
649  }
650  else
651  {
652  const Multi::MultiDef& def = multi->multidef();
653  if ( def.readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z, anyflags ) )
654  {
655  mvec.push_back( multi );
656  }
657  }
658  } );
659 }
660 
661 void Realm::readmultis( Core::StaticList& vec, unsigned short x, unsigned short y ) const
662 {
663  Core::WorldIterator<Core::MultiFilter>::InRange( x, y, this, 64, [&]( Multi::UMulti* multi ) {
664  Multi::UHouse* house = multi->as_house();
665  if ( house != nullptr && house->IsCustom() ) // readshapes switches to working design if the
666  // house is being edited,
667  // everyone in the house would use it for walking...
668  multi->readobjects( vec, int( x ) - multi->x, int( y ) - multi->y, multi->z );
669  else
670  {
671  const Multi::MultiDef& def = multi->multidef();
672  def.readobjects( vec, int( x ) - multi->x, int( y ) - multi->y, multi->z );
673  }
674  } );
675 }
676 
677 bool Realm::navigable( unsigned short x, unsigned short y, short z, short height = 0 ) const
678 {
679  if ( !valid( x, y, z ) )
680  {
681  return false;
682  }
683 
684  bool onwater = false;
685 
686  static Plib::MapShapeList shapes;
687  shapes.clear();
688 
689  // possible: readdynamic, readmultis
690  getmapshapes( shapes, x, y, static_cast<u32>( Plib::FLAG::ALL ) );
691 
692  for ( const auto& shape : shapes )
693  {
694  if ( shape.flags & Plib::FLAG::MOVESEA )
695  {
696  onwater = true;
697  }
698  else
699  {
700  if ( ( ( z + height ) >= ( shape.z - HULL_HEIGHT_BUFFER ) ) &&
701  ( z < ( shape.z + shape.height + HULL_HEIGHT_BUFFER ) ) )
702  return false;
703  }
704  }
705 
706  return onwater;
707 }
708 
709 Multi::UMulti* Realm::find_supporting_multi( unsigned short x, unsigned short y, short z ) const
710 {
711  if ( !valid( x, y, z ) )
712  {
713  return nullptr;
714  }
715 
716  static Plib::MapShapeList vec;
717  static MultiList mvec;
718  vec.clear();
719  mvec.clear();
720  readmultis( vec, x, y, Plib::FLAG::MOVE_FLAGS, mvec );
721 
722  return find_supporting_multi( mvec, z );
723 }
724 
725 /* The supporting multi is the highest multi that is below or equal
726  * to the Z-coord of the supported object.
727  */
728 Multi::UMulti* Realm::find_supporting_multi( MultiList& mvec, short z ) const
729 {
730  Multi::UMulti* found = nullptr;
731  for ( auto& multi : mvec )
732  {
733  if ( multi->z <= z )
734  {
735  if ( ( found == nullptr ) || ( multi->z > found->z ) )
736  {
737  found = multi;
738  }
739  }
740  }
741  return found;
742 }
743 
744 bool Realm::findstatic( unsigned short x, unsigned short y, unsigned short objtype ) const
745 {
746  if ( is_shadowrealm )
747  return baserealm->_staticserver->findstatic( x, y, objtype );
748  else
749  return _staticserver->findstatic( x, y, objtype );
750 }
751 
752 void Realm::getstatics( Plib::StaticEntryList& statics, unsigned short x, unsigned short y ) const
753 {
754  if ( is_shadowrealm )
755  return baserealm->_staticserver->getstatics( statics, x, y );
756  else
757  _staticserver->getstatics( statics, x, y );
758 }
759 
760 bool Realm::groundheight( unsigned short x, unsigned short y, short* z ) const
761 {
762  Plib::MAPTILE_CELL cell = _maptileserver->GetMapTile( x, y );
763  *z = cell.z;
764 
765  if ( cell.landtile == GRAPHIC_NODRAW ) // it's a nodraw tile
766  *z = Core::ZCOORD_MIN;
767 
768  return ( ( cell.landtile < 0x4000 ) &&
769  ( ( Core::landtile_flags( cell.landtile ) & Plib::FLAG::BLOCKING ) == 0 ) );
770 }
771 
772 Plib::MAPTILE_CELL Realm::getmaptile( unsigned short x, unsigned short y ) const
773 {
774  if ( is_shadowrealm )
775  return baserealm->_maptileserver->GetMapTile( x, y );
776  else
777  return _maptileserver->GetMapTile( x, y );
778 }
779 
780 void Realm::getmapshapes( Plib::MapShapeList& shapes, unsigned short x, unsigned short y,
781  unsigned int anyflags ) const
782 {
783  if ( is_shadowrealm )
784  baserealm->_mapserver->GetMapShapes( shapes, x, y, anyflags );
785  else
786  _mapserver->GetMapShapes( shapes, x, y, anyflags );
787 }
788 }
789 }
unsigned short landtile
Definition: maptile.h:21
unsigned int tile_flags(unsigned short tilenum)
Definition: polfile2.cpp:49
unsigned int flags
Definition: mapshape.h:20
std::vector< StaticRec > StaticList
Definition: udatfile.h:38
SystemState systemstate
Definition: systemstate.cpp:12
Network::Client * client
Definition: charactr.h:871
bool readshapes(Plib::MapShapeList &vec, short rx, short ry, short zbase, unsigned int anyflags) const
Definition: multidef2.cpp:58
bool readobjects(Core::StaticList &vec, short rx, short ry, short zbase) const
Definition: multidef2.cpp:24
virtual bool readobjects(Core::StaticList &vec, s16 rx, s16 ry, s16 zbase)
Definition: multi.h:101
unsigned int landtile_flags(unsigned short landtile)
Definition: landtile.cpp:47
static void InRange(u16 x, u16 y, const Realms::Realm *realm, unsigned range, F &&f)
Definition: uworld.h:235
void CustomHouseStopEditing(Mobile::Character *chr, UHouse *house)
MOVEMODE
Definition: uconst.h:79
std::vector< Items::Item * > ZoneItems
Definition: uworld.h:66
#define HULL_HEIGHT_BUFFER
Definition: realmfunc.cpp:46
Multi::UMulti * system_find_multi(u32 serial)
Definition: fnsearch.cpp:50
virtual class UHouse * as_house()
Definition: multis.cpp:55
signed short s16
Definition: rawtypes.h:30
const short ZCOORD_MIN
Definition: poltype.h:15
bool static_debug_on
Definition: uofile02.cpp:29
bool doors_block() const
Definition: charactr.cpp:3629
unsigned int flags
Definition: tiles.h:24
Items::Item * find_walkon_item(ItemsVector &ivec, short z)
Definition: core.cpp:169
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
bool IsCustom() const
Definition: house.h:84
Core::MOVEMODE movemode
Definition: charactr.h:811
unsigned char flags_from_tileflags(unsigned int uoflags)
ClientGameData * gd
Definition: client.h:252
unsigned char default_character_height
Definition: ssopt.h:97
Zone & getzone(unsigned short x, unsigned short y, Realms::Realm *realm)
Definition: uworld.h:102
bool groundheight(unsigned short x, unsigned short y, short *z)
Definition: uofile08.cpp:77
bool is_house_editing() const
Definition: charactr.cpp:464
SettingsManager settingsManager
Definition: settings.cpp:14
std::vector< Multi::UMulti * > MultiList
Definition: realm.h:56
bool findstatic(unsigned short x, unsigned short y, unsigned short graphic)
ZoneItems items
Definition: uworld.h:72
virtual class UHouse * as_house() POL_OVERRIDE
Definition: house.cpp:244
const MultiDef & multidef() const
Definition: multis.cpp:69
void CustomHousesSendFull(UHouse *house, Network::Client *client, int design)
#define INFO_PRINT
Definition: logfacility.h:223
Definition: berror.cpp:12
#define GRAPHIC_NODRAW
Definition: objtype.h:19
virtual bool readshapes(Plib::MapShapeList &vec, s16 rx, s16 ry, s16 zbase)
Definition: multi.h:97