From 881bce4d1a20d26e92ad9451764a25be8f4c76cf Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Sat, 16 Jun 2018 21:46:10 +0200 Subject: [PATCH] disallow attacking with disabled attacks via [do_command] this fixes some rare cheats in mp. --- src/actions/attack.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/actions/attack.cpp b/src/actions/attack.cpp index e4a8cbabf7c8..00215f8196ce 100644 --- a/src/actions/attack.cpp +++ b/src/actions/attack.cpp @@ -1403,6 +1403,11 @@ void attack::perform() return; } + if(a_.get_unit().attacks_left() <= 0) { + LOG_NG << "attack::perform(): not enough ap.\n"; + return; + } + a_.get_unit().set_facing(a_.loc_.get_relative_dir(d_.loc_)); d_.get_unit().set_facing(d_.loc_.get_relative_dir(a_.loc_)); @@ -1424,6 +1429,11 @@ void attack::perform() a_stats_ = &bc_->get_attacker_stats(); d_stats_ = &bc_->get_defender_stats(); + if(a_stats_->disable) { + LOG_NG << "attack::perform(): tried to attack with a disabled attack.\n"; + return; + } + if(a_stats_->weapon) { a_.weap_id_ = a_stats_->weapon->id(); }