mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* trigger tidy * Automated clang-tidy change: readability-else-after-return * compile test * rerun * Automated clang-tidy change: readability-else-after-return * trigger.. * Automated clang-tidy change: readability-else-after-return * manually removed a few * Automated clang-tidy change: readability-else-after-return * removed duplicate code * fix remaining warnings * fixed scope --------- Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>
119 lines
3.3 KiB
C++
119 lines
3.3 KiB
C++
/** @file
|
|
*
|
|
* @par History
|
|
* - 2006/09/26 Shinigami: GCC 3.4.x fix - added "template<>" to TmplExecutorModule
|
|
* - 2009/09/03 MuadDib: Changes for account related source file relocation
|
|
* Changes for multi related source file relocation
|
|
*/
|
|
|
|
|
|
#include "boatmod.h"
|
|
#include <stddef.h>
|
|
|
|
#include "../../bscript/berror.h"
|
|
#include "../../clib/rawtypes.h"
|
|
#include "../../plib/uconst.h"
|
|
#include "../multi/boat.h"
|
|
#include "../multi/multi.h"
|
|
#include "../realms/realm.h"
|
|
|
|
#include <module_defs/boat.h>
|
|
|
|
|
|
namespace Pol::Module
|
|
{
|
|
UBoatExecutorModule::UBoatExecutorModule( Bscript::Executor& exec )
|
|
: Bscript::TmplExecutorModule<UBoatExecutorModule, Core::PolModule>( exec )
|
|
{
|
|
}
|
|
|
|
Bscript::BObjectImp* UBoatExecutorModule::mf_MoveBoat()
|
|
{
|
|
Multi::UBoat* boat = nullptr;
|
|
int direction, speed;
|
|
if ( getUBoatParam( 0, boat ) && getParam( 1, direction, 0, 7 ) && getParam( 2, speed, 1, 4 ) )
|
|
{
|
|
Core::UFACING move_dir = static_cast<Core::UFACING>( direction & 7 );
|
|
return new Bscript::BLong( boat->move( move_dir, static_cast<u8>( speed ), false ) );
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
Bscript::BObjectImp* UBoatExecutorModule::mf_MoveBoatXY()
|
|
{
|
|
Multi::UBoat* boat = nullptr;
|
|
Core::Pos2d pos;
|
|
if ( getUBoatParam( 0, boat ) && getPos2dParam( 1, 2, &pos, boat->realm() ) )
|
|
return new Bscript::BLong( boat->move_to( Core::Pos4d( pos, boat->z(), boat->realm() ), 0 ) );
|
|
return new Bscript::BError( "Invalid Parameter type" );
|
|
}
|
|
|
|
Bscript::BObjectImp* UBoatExecutorModule::mf_TurnBoat()
|
|
{
|
|
Multi::UBoat* boat = nullptr;
|
|
int relative_dir;
|
|
if ( getUBoatParam( 0, boat ) && getParam( 1, relative_dir ) )
|
|
{
|
|
relative_dir &= 3;
|
|
return new Bscript::BLong(
|
|
boat->turn( static_cast<Multi::UBoat::RELATIVE_DIR>( relative_dir ) ) );
|
|
}
|
|
|
|
return new Bscript::BError( "Invalid Parameter type" );
|
|
}
|
|
|
|
Bscript::BObjectImp* UBoatExecutorModule::mf_MoveBoatRelative()
|
|
{
|
|
Multi::UBoat* boat = nullptr;
|
|
int direction, speed;
|
|
if ( getUBoatParam( 0, boat ) && getParam( 1, direction, 0, 7 ) && getParam( 2, speed, 1, 4 ) )
|
|
{
|
|
Core::UFACING move_dir = static_cast<Core::UFACING>( direction & 7 );
|
|
return new Bscript::BLong( boat->move( move_dir, static_cast<u8>( speed ), true ) );
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
Bscript::BObjectImp* UBoatExecutorModule::mf_RegisterItemWithBoat()
|
|
{
|
|
Multi::UBoat* boat = nullptr;
|
|
Core::UObject* obj = nullptr;
|
|
if ( getUBoatParam( 0, boat ) && getUObjectParam( 1, obj ) )
|
|
{
|
|
boat->register_object( obj );
|
|
return new Bscript::BLong( 1 );
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
Bscript::BObjectImp* UBoatExecutorModule::mf_SystemFindBoatBySerial()
|
|
{
|
|
Multi::UBoat* boat = nullptr;
|
|
if ( getUBoatParam( 0, boat ) )
|
|
{
|
|
return boat->make_ref();
|
|
}
|
|
|
|
return new Bscript::BError( "Boat not found." );
|
|
}
|
|
|
|
Bscript::BObjectImp* UBoatExecutorModule::mf_BoatFromItem()
|
|
{
|
|
Items::Item* item = nullptr;
|
|
if ( getItemParam( 0, item ) )
|
|
{
|
|
if ( item->ismulti() )
|
|
{
|
|
Multi::UMulti* multi = static_cast<Multi::UMulti*>( item );
|
|
Multi::UBoat* boat = multi->as_boat();
|
|
if ( boat != nullptr )
|
|
return boat->make_ref();
|
|
return new Bscript::BError( "Multi wasn't a boat" );
|
|
}
|
|
|
|
return new Bscript::BError( "Item wasn't a multi" );
|
|
}
|
|
|
|
return new Bscript::BError( "Invalid parameter type." );
|
|
}
|
|
} // namespace Pol::Module
|