Skip to content

Commit ce18204

Browse files
committed
stop processing npc actions if marked for kick
1 parent dbec732 commit ce18204

File tree

18 files changed

+28
-19
lines changed

18 files changed

+28
-19
lines changed

Server/Components/NPCs/NPC/npc.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/.
55
*
6-
* The original code is copyright (c) 2022, open.mp team and contributors.
6+
* The original code is copyright (c) 2025, open.mp team and contributors.
77
*/
88

99
#include "npc.hpp"
@@ -33,6 +33,7 @@ NPC::NPC(NPCComponent* component, IPlayer* playerPtr)
3333
, specialAction_(SpecialAction_None)
3434
, invulnerable_(false)
3535
, spawning_(false)
36+
, markedForKick_(false)
3637
, meleeAttacking_(false)
3738
, meleeAttackDelay_(0)
3839
, meleeSecondaryAttack_(false)
@@ -2574,7 +2575,7 @@ int NPC::getCurrentPathPointIndex() const
25742575

25752576
void NPC::tick(Microseconds elapsed, TimePoint now)
25762577
{
2577-
if (player_)
2578+
if (player_ && !markedForKick_)
25782579
{
25792580
auto state = player_->getState();
25802581

@@ -2798,7 +2799,7 @@ void NPC::tick(Microseconds elapsed, TimePoint now)
27982799

27992800
// Check shooting again because NPC::shoot actually calls events and people may use stopAim in them.
28002801
// Therefore we are already in shooting_ == true scope, but it's not true anymore, so we don't want to
2801-
// Be stuck with the wrong applied keys. But let it do the rest, let it reduce ammo count and do reload checks.
2802+
// Be stuck with the wrong applied keys. But let it do the rest, let it reduce ammo count and do reload checks.
28022803
if (shooting_)
28032804
{
28042805
applyKey(Key::AIM);

Server/Components/NPCs/NPC/npc.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/.
55
*
6-
* The original code is copyright (c) 2022, open.mp team and contributors.
6+
* The original code is copyright (c) 2025, open.mp team and contributors.
77
*/
88

99
#pragma once
@@ -371,6 +371,11 @@ class NPC : public INPC, public PoolIDProvider, public NoCopy
371371
return vehicle_ && vehicleSeat_ != SEAT_NONE;
372372
}
373373

374+
inline void setKickMarkState(bool state)
375+
{
376+
markedForKick_ = true;
377+
}
378+
374379
private:
375380
// The NPC's player pointer.
376381
IPlayer* player_;
@@ -403,6 +408,7 @@ class NPC : public INPC, public PoolIDProvider, public NoCopy
403408
bool invulnerable_;
404409
PlayerSurfingData surfingData_;
405410
bool spawning_;
411+
bool markedForKick_;
406412

407413
// Attack data
408414
bool meleeAttacking_;

Server/Components/NPCs/Network/npcs_network.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <sdk.hpp>
1111
#include <Server/Components/NPCs/npcs.hpp>
1212
#include <Impl/network_impl.hpp>
13+
#include "../NPC/npc.hpp"
1314

1415
using namespace Impl;
1516

@@ -77,6 +78,7 @@ class NPCNetwork : public Impl::Network
7778
auto npc = npcComponent->get(id);
7879
if (npc)
7980
{
81+
reinterpret_cast<NPC*>(npc)->setKickMarkState(true);
8082
markedToBeKicked.push_back(npc->getID());
8183
}
8284
}

Server/Components/NPCs/Node/node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/.
55
*
6-
* The original code is copyright (c) 2022, open.mp team and contributors.
6+
* The original code is copyright (c) 2025, open.mp team and contributors.
77
*/
88

99
#include "node.hpp"

Server/Components/NPCs/Node/node.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/.
55
*
6-
* The original code is copyright (c) 2022, open.mp team and contributors.
6+
* The original code is copyright (c) 2025, open.mp team and contributors.
77
*/
88

99
#pragma once

Server/Components/NPCs/Node/node_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/.
55
*
6-
* The original code is copyright (c) 2022, open.mp team and contributors.
6+
* The original code is copyright (c) 2025, open.mp team and contributors.
77
*/
88

99
#include "node_manager.hpp"

Server/Components/NPCs/Node/node_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/.
55
*
6-
* The original code is copyright (c) 2022, open.mp team and contributors.
6+
* The original code is copyright (c) 2025, open.mp team and contributors.
77
*/
88

99
#pragma once

Server/Components/NPCs/Path/path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/.
55
*
6-
* The original code is copyright (c) 2022, open.mp team and contributors.
6+
* The original code is copyright (c) 2025, open.mp team and contributors.
77
*/
88

99
#include "path.hpp"

Server/Components/NPCs/Path/path.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/.
55
*
6-
* The original code is copyright (c) 2022, open.mp team and contributors.
6+
* The original code is copyright (c) 2025, open.mp team and contributors.
77
*/
88

99
#pragma once

Server/Components/NPCs/Path/path_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/.
55
*
6-
* The original code is copyright (c) 2022, open.mp team and contributors.
6+
* The original code is copyright (c) 2025, open.mp team and contributors.
77
*/
88

99
#include "path_pool.hpp"

0 commit comments

Comments
 (0)