polserver/pol-core/pol/module/clmod.cpp

117 lines
3 KiB
C++
Raw Permalink Normal View History

/** @file
*
* @par History
* - 2006/10/07 Shinigami: GCC 3.4.x fix - added "template<>" to TmplExecutorModule
*/
2016-02-11 22:54:43 +01:00
#include "clmod.h"
#include "../../bscript/berror.h"
#include "../../bscript/impstr.h"
#include "../../clib/passert.h"
#include "../../clib/rawtypes.h"
#include "../clfunc.h"
2016-02-11 22:54:43 +01:00
#include "../mobile/charactr.h"
2018-12-30 21:35:54 +01:00
#include "../network/pktdef.h"
2016-02-11 22:54:43 +01:00
#include <module_defs/cliloc.h>
namespace Pol
{
namespace Module
{
using namespace Bscript;
ClilocExecutorModule::ClilocExecutorModule( Bscript::Executor& exec )
: Bscript::TmplExecutorModule<ClilocExecutorModule, Core::PolModule>( exec )
{
}
BObjectImp* ClilocExecutorModule::mf_SendSysMessageCL()
{
Mobile::Character* chr;
const String* text;
unsigned int cliloc_num;
unsigned short color;
unsigned short font;
if ( getCharacterParam( 0, chr ) && getParam( 1, cliloc_num ) &&
getUnicodeStringParam( 2, text ) && getParam( 3, font ) && getParam( 4, color ) )
{
passert_paranoid( chr != nullptr && text != nullptr );
if ( !chr->has_active_client() )
return new BError( "Mobile has no active client" );
if ( text->length() > SPEECH_MAX_LEN )
return new BError( "Text exceeds maximum size." );
2019-01-03 17:21:55 +01:00
Core::send_sysmessage_cl( chr->client, cliloc_num, text->value(), font, color );
return new BLong( 1 );
}
else
{
return new BError( "Invalid parameter type" );
}
}
BObjectImp* ClilocExecutorModule::mf_PrintTextAboveCL()
{
Core::UObject* obj;
const String* text;
unsigned int cliloc_num;
unsigned short color;
unsigned short font;
if ( getUObjectParam( 0, obj ) && getParam( 1, cliloc_num ) &&
getUnicodeStringParam( 2, text ) && getParam( 3, font ) && getParam( 4, color ) )
{
passert_paranoid( text != nullptr && obj != nullptr );
if ( text->length() > SPEECH_MAX_LEN )
return new BError( "Text exceeds maximum size." );
2019-01-03 17:21:55 +01:00
say_above_cl( obj, cliloc_num, text->value(), font, color );
return new BLong( 1 );
}
else
{
return new BError( "Invalid parameter type" );
}
}
BObjectImp* ClilocExecutorModule::mf_PrintTextAbovePrivateCL()
{
Mobile::Character* chr;
Core::UObject* obj;
const String* text;
unsigned int cliloc_num;
unsigned short color;
unsigned short font;
if ( getCharacterParam( 0, chr ) && getUObjectParam( 1, obj ) &&
getParam( 2, cliloc_num ) && getUnicodeStringParam( 3, text ) && getParam( 4, font ) &&
getParam( 5, color ) )
{
passert_paranoid( chr != nullptr && text != nullptr && obj != nullptr );
if ( !chr->has_active_client() )
return new BError( "Mobile has no active client" );
2020-04-05 23:16:44 +02:00
if ( chr->realm() != obj->toplevel_realm() )
return new BError( "Cannot print messages across realms!" );
if ( text->length() > SPEECH_MAX_LEN )
return new BError( "Text exceeds maximum size." );
2016-02-11 22:54:43 +01:00
2019-01-03 17:21:55 +01:00
private_say_above_cl( chr, obj, cliloc_num, text->value(), font, color );
return new BLong( 1 );
2016-02-11 22:54:43 +01:00
}
else
{
return new BError( "Invalid parameter type" );
2016-02-11 22:54:43 +01:00
}
}
2018-12-30 21:35:54 +01:00
} // namespace Module
} // namespace Pol