mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* origin/master: (93 commits) Add support for dictionary creation (#277) Add do-while statement (#276) Add foreach loops (#275) New compiler: array initialization (#274) Disambiguator: figure out if label is a case statement dispatch selector, or should apply to a statement within the case dispatch group's block. (#273) New compiler: Add support for case statements (#272) Change "logical" to "bitwise". (#258) Fix divide-by-zero errors, and mask FormatError if it were thrown in a destructor. (#271) Add break and continue statements. (#270) New compiler: assignment to local and global variables. (#269) Add support for while loops (#268) Optimize if statements, and emit module functions in legacy order (#267) Optimizations: binary operators (#266) Add binary operators (#265) Add support for const declarations (#264) Handle default parameter values, pass-by-name, and return statements in functions. (#263) Add limited support for user functions (#262) New compiler: add return and exit statements (#261) Add support for if-then-else statements (#259) OG compiler: set module to Mod_Basic when a token is an identifier (#257) ...
74 lines
1.8 KiB
C++
74 lines
1.8 KiB
C++
/** @file
|
|
*
|
|
* @par History
|
|
* - 2005/11/26 MuadDib: Added update code for updating highlight packet to client.
|
|
* - 2005/11/26 Shinigami: added Character check
|
|
* - 2005/11/25 MuadDib: Added distance check in handle_attack.
|
|
* - 2006/03/07 MuadDib: Added Justice Region NoCombat check to attack request.
|
|
* - 2009/01/03 MuadDib: Removed logging of null defenders. Who cares if it's empty :o
|
|
*/
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
#include "../../clib/clib_endian.h"
|
|
#include "../../clib/rawtypes.h"
|
|
#include "../cmbtcfg.h"
|
|
#include "../globals/settings.h"
|
|
#include "regions/guardrgn.h"
|
|
#include "../network/client.h"
|
|
#include "../network/pktin.h"
|
|
#include "../ufunc.h"
|
|
#include "charactr.h"
|
|
|
|
namespace Pol
|
|
{
|
|
namespace Mobile
|
|
{
|
|
void handle_attack( Network::Client* client, Core::PKTIN_05* msg )
|
|
{
|
|
if ( client->chr->dead() )
|
|
{
|
|
private_say_above( client->chr, client->chr, "I am dead and cannot do that." );
|
|
return;
|
|
}
|
|
|
|
u32 serial = cfBEu32( msg->serial );
|
|
Character* defender = Core::find_character( serial );
|
|
if ( defender != nullptr )
|
|
{
|
|
if ( !( Core::settingsManager.combat_config.attack_self ) )
|
|
{
|
|
if ( defender->serial == client->chr->serial )
|
|
{
|
|
client->chr->send_highlight();
|
|
return;
|
|
}
|
|
}
|
|
|
|
if ( !client->chr->is_visible_to_me( defender ) )
|
|
{
|
|
client->chr->send_highlight();
|
|
return;
|
|
}
|
|
|
|
if ( !client->chr->pos().inRange( defender->pos(), 20 ) )
|
|
{
|
|
client->chr->send_highlight();
|
|
return;
|
|
}
|
|
|
|
if ( defender->acct != nullptr )
|
|
{
|
|
if ( Core::JusticeRegion::RunNoCombatCheck( defender->client ) == true )
|
|
{
|
|
client->chr->send_highlight();
|
|
Core::send_sysmessage( client, "Combat is not allowed in this area." );
|
|
return;
|
|
}
|
|
}
|
|
client->chr->select_opponent( serial );
|
|
}
|
|
}
|
|
} // namespace Mobile
|
|
} // namespace Pol
|