Skip to content

Commit

Permalink
disallow attacking with disabled attacks via [do_command]
Browse files Browse the repository at this point in the history
this fixes some rare cheats in mp.
  • Loading branch information
gfgtdf committed Jun 16, 2018
1 parent ca00829 commit 881bce4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/actions/attack.cpp
Expand Up @@ -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_));

Expand All @@ -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();
}
Expand Down

0 comments on commit 881bce4

Please sign in to comment.