2016-02-11 22:54:43 +01:00
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* @par History
|
2016-02-19 19:26:35 +01:00
|
|
|
* - 2006/12/05 Shinigami: removed dummy floor creation in MultiDef::readobjects and
|
|
|
|
|
* MultiDef::readshapes
|
2016-02-11 22:54:43 +01:00
|
|
|
* - 2009/09/03 MuadDib: Relocation of multi related cpp/h
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2018-12-21 20:27:05 +01:00
|
|
|
#include "../../plib/clidata.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
#include "../../plib/mapcell.h"
|
|
|
|
|
#include "../../plib/mapshape.h"
|
|
|
|
|
#include "../../plib/systemstate.h"
|
2018-12-21 20:27:05 +01:00
|
|
|
#include "../../plib/tiles.h"
|
|
|
|
|
#include "../../plib/udatfile.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "../item/itemdesc.h"
|
|
|
|
|
#include "multidef.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2026-01-17 10:30:21 +01:00
|
|
|
|
|
|
|
|
namespace Pol::Multi
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
// 8/9/03 this seems to be used only by uofile03 -Syz
|
2021-11-09 20:01:16 +01:00
|
|
|
bool MultiDef::readobjects( Plib::StaticList& vec, const Core::Vec2d& rxy, short zbase ) const
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2021-11-09 20:01:16 +01:00
|
|
|
if ( !within_multi( rxy ) )
|
|
|
|
|
return false;
|
|
|
|
|
Components::const_iterator itr, end;
|
|
|
|
|
if ( !findcomponents( itr, end, rxy ) )
|
|
|
|
|
return false;
|
2016-02-19 19:26:35 +01:00
|
|
|
bool result = false;
|
2021-11-09 20:01:16 +01:00
|
|
|
for ( ; itr != end; ++itr )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2021-11-09 20:01:16 +01:00
|
|
|
const MULTI_ELEM* elem = ( *itr ).second;
|
|
|
|
|
unsigned short graphic = Items::getgraphic( elem->objtype );
|
|
|
|
|
if ( Plib::tile_flags( graphic ) & Plib::FLAG::WALKBLOCK )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2021-11-09 20:01:16 +01:00
|
|
|
if ( elem->is_static )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2026-01-16 13:22:43 +01:00
|
|
|
vec.emplace_back( graphic, static_cast<signed char>( elem->relpos.z() + zbase ) );
|
2021-11-09 20:01:16 +01:00
|
|
|
result = true;
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
2021-11-09 20:01:16 +01:00
|
|
|
// Shinigami: removed. doesn't make sense. non-static
|
|
|
|
|
// items are normal items an can be removed etc.
|
|
|
|
|
/* else // put a dummy floor tile there
|
|
|
|
|
{
|
|
|
|
|
vec.push_back( StaticRec( 0x495, elem->z+zbase ) );
|
|
|
|
|
result = true;
|
|
|
|
|
} */
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2021-11-09 20:01:16 +01:00
|
|
|
bool MultiDef::readshapes( Plib::MapShapeList& vec, const Core::Vec2d& rxy, short zbase,
|
2016-02-19 19:26:35 +01:00
|
|
|
unsigned int anyflags ) const
|
|
|
|
|
{
|
2021-11-09 20:01:16 +01:00
|
|
|
if ( !within_multi( rxy ) )
|
|
|
|
|
return false;
|
|
|
|
|
Components::const_iterator itr, end;
|
|
|
|
|
if ( !findcomponents( itr, end, rxy ) )
|
|
|
|
|
return false;
|
2016-02-19 19:26:35 +01:00
|
|
|
bool result = false;
|
2021-11-09 20:01:16 +01:00
|
|
|
for ( ; itr != end; ++itr )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2021-11-09 20:01:16 +01:00
|
|
|
const MULTI_ELEM* elem = ( *itr ).second;
|
2025-03-05 21:38:37 +01:00
|
|
|
// use raw objtype instead of itemdesc.graphic to ensure correct Line of Sight checks
|
|
|
|
|
unsigned short graphic = elem->objtype;
|
2021-11-09 20:01:16 +01:00
|
|
|
if ( Plib::tile_flags( graphic ) & anyflags )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2021-11-09 20:01:16 +01:00
|
|
|
if ( elem->is_static )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2021-11-09 20:01:16 +01:00
|
|
|
Plib::MapShape shape;
|
|
|
|
|
shape.z = elem->relpos.z() + zbase;
|
|
|
|
|
shape.height = Plib::tileheight( graphic );
|
|
|
|
|
shape.flags = Plib::systemstate.tile[graphic].flags; // pol_flags_by_tile( graphic );
|
|
|
|
|
if ( !shape.height )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2021-11-09 20:01:16 +01:00
|
|
|
++shape.height;
|
|
|
|
|
--shape.z;
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
2021-11-09 20:01:16 +01:00
|
|
|
vec.push_back( shape );
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
// Shinigami: removed. doesn't make sense. non-static
|
|
|
|
|
// items are normal items an can be removed etc.
|
|
|
|
|
// Turley: BOAT added so hold count as boat item (who.multi) (and walkable)
|
2025-04-15 12:03:35 +02:00
|
|
|
else if ( is_boat ) // put a dummy floor there
|
2021-11-09 20:01:16 +01:00
|
|
|
{
|
|
|
|
|
Plib::MapShape shape;
|
|
|
|
|
shape.z = elem->relpos.z() + zbase - 1;
|
|
|
|
|
shape.height = 1;
|
|
|
|
|
shape.flags = Plib::FLAG::MOVELAND | Plib::FLAG::ALLOWDROPON | Plib::FLAG::BLOCKSIGHT |
|
|
|
|
|
Plib::FLAG::OVERFLIGHT;
|
|
|
|
|
vec.push_back( shape );
|
|
|
|
|
result = true;
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
2016-02-11 22:54:43 +01:00
|
|
|
}
|
2016-02-19 19:26:35 +01:00
|
|
|
return result;
|
|
|
|
|
}
|
2026-01-17 10:30:21 +01:00
|
|
|
} // namespace Pol::Multi
|