mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-17 11:28:16 +00:00
Output formula errors in unit filters to WML error stream
(And consider them to match no units)
This commit is contained in:
parent
26a2638f2c
commit
240b5f61a7
@ -59,7 +59,7 @@
|
||||
[/event]
|
||||
)}
|
||||
|
||||
{GENERIC_UNIT_TEST filter_this_unit_fai_short (
|
||||
{GENERIC_UNIT_TEST filter_fai_unit (
|
||||
[event]
|
||||
name=prestart
|
||||
[modify_unit]
|
||||
@ -76,3 +76,15 @@
|
||||
)}
|
||||
[/event]
|
||||
)}
|
||||
|
||||
{GENERIC_UNIT_TEST filter_fai_unit_error (
|
||||
[event]
|
||||
name=prestart
|
||||
{RETURN (
|
||||
[have_unit]
|
||||
id=bob
|
||||
formula="+ max_moves"
|
||||
[/have_unit]
|
||||
)}
|
||||
[/event]
|
||||
)}
|
||||
|
@ -19,17 +19,24 @@
|
||||
#include "formula.hpp"
|
||||
#include "formula_string_utils.hpp"
|
||||
#include "map_location.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
bool unit_formula_manager::matches_filter(const std::string & cfg_formula, const map_location & loc, const unit & me)
|
||||
{
|
||||
const unit_callable callable(loc,me);
|
||||
const game_logic::formula form(cfg_formula);
|
||||
if(!form.evaluate(callable).as_bool()) {///@todo use formula_ai
|
||||
try {
|
||||
const unit_callable callable(loc,me);
|
||||
const game_logic::formula form(cfg_formula);
|
||||
if(!form.evaluate(callable).as_bool()) {///@todo use formula_ai
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch(game_logic::formula_error& e) {
|
||||
lg::wml_error << "Formula error in unit filter: " << e.type << " at " << e.filename << ':' << e.line << ")\n";
|
||||
// Formulae with syntax errors match nothing
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void unit_formula_manager::add_formula_var(std::string str, variant var)
|
||||
|
@ -147,7 +147,8 @@
|
||||
0 filter_this_unit_wml
|
||||
0 filter_this_unit_tl
|
||||
0 filter_this_unit_fai
|
||||
0 filter_this_unit_fai_short
|
||||
0 filter_fai_unit
|
||||
1 filter_fai_unit_error
|
||||
# Interrupt tag tests
|
||||
0 check_interrupts_break
|
||||
0 check_interrupts_return
|
||||
|
Loading…
x
Reference in New Issue
Block a user