Skip to content

Commit 54fc4a7

Browse files
committed
change some debugs to level 2
1 parent f6e8bf7 commit 54fc4a7

File tree

3 files changed

+93
-93
lines changed

3 files changed

+93
-93
lines changed

src/thing_ai.cpp

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ bool operator<(const class Path &lhs, const class Path &rhs)
4242
}
4343

4444
#define GOAL_ADD(prio, score, msg, it) \
45-
IF_DEBUG \
45+
IF_DEBUG2 \
4646
{ \
4747
auto s = string_sprintf("Add goal prio %d score %d @(%d,%d) %s", prio, score, p.x, p.y, msg); \
4848
AI_LOG(s, it); \
4949
} \
5050
goals.insert(Goal(prio, score, p, msg, it));
5151

5252
#define GOAL_AVOID_ADD(prio, score, msg, it) \
53-
IF_DEBUG \
53+
IF_DEBUG2 \
5454
{ \
5555
auto s = string_sprintf("Add goal (avoid) prio %d score %d @(%d,%d) %s", prio, score, p.x, p.y, msg); \
5656
AI_LOG(s, it); \
@@ -61,12 +61,12 @@ void Thing::ai_log(const std::string &msg, Thingp it)
6161
{
6262
TRACE_NO_INDENT();
6363

64-
IF_DEBUG
64+
IF_DEBUG2
6565
{
6666
if (it) {
67-
dbg("AI: %s, %s", msg.c_str(), it->to_short_string().c_str());
67+
dbg2("AI: %s, %s", msg.c_str(), it->to_short_string().c_str());
6868
} else {
69-
dbg("AI: %s", msg.c_str());
69+
dbg2("AI: %s", msg.c_str());
7070
}
7171
}
7272
}
@@ -86,7 +86,7 @@ bool Thing::ai_create_path_to_goal(int minx, int miny, int maxx, int maxy, int s
8686
// Choose goals (higher scores, lower costs are preferred)
8787
//
8888
std::string s = "Choose goal";
89-
IF_DEBUG { s = string_sprintf("Try to find goals, search-type %d", search_type); }
89+
IF_DEBUG2 { s = string_sprintf("Try to find goals, search-type %d", search_type); }
9090
AI_LOG(s);
9191
TRACE_AND_INDENT();
9292

@@ -140,7 +140,7 @@ bool Thing::ai_create_path_to_goal(int minx, int miny, int maxx, int maxy, int s
140140
return false;
141141
}
142142

143-
IF_DEBUG
143+
IF_DEBUG2
144144
{
145145
AI_LOG("All goals:");
146146
TRACE_AND_INDENT();
@@ -169,7 +169,7 @@ bool Thing::ai_create_path_to_goal(int minx, int miny, int maxx, int maxy, int s
169169
for (auto &g : goalmaps) {
170170
auto goal_dmap_copy = *g.dmap;
171171

172-
IF_DEBUG
172+
IF_DEBUG2
173173
{
174174
if (is_debug_type()) {
175175
AI_LOG("Pre modify dmap for terrain");
@@ -200,7 +200,7 @@ bool Thing::ai_create_path_to_goal(int minx, int miny, int maxx, int maxy, int s
200200
}
201201
}
202202

203-
IF_DEBUG
203+
IF_DEBUG2
204204
{
205205
if (is_debug_type()) {
206206
AI_LOG("Modified dmap for terrain");
@@ -230,7 +230,7 @@ bool Thing::ai_create_path_to_goal(int minx, int miny, int maxx, int maxy, int s
230230
}
231231
}
232232

233-
IF_DEBUG
233+
IF_DEBUG2
234234
{
235235
auto s = string_sprintf("Accept avoid goal score %d @(%d,%d) %s", (int) goal.score, (int) goal.at.x,
236236
(int) goal.at.y, goal.msg.c_str());
@@ -256,7 +256,7 @@ bool Thing::ai_create_path_to_goal(int minx, int miny, int maxx, int maxy, int s
256256
add_goal_penalty(goal.what);
257257
}
258258

259-
IF_DEBUG
259+
IF_DEBUG2
260260
{
261261
auto s = string_sprintf("Accept goal score %d @(%d,%d) %s", (int) goal.score, (int) goal.at.x,
262262
(int) goal.at.y, goal.msg.c_str());
@@ -274,7 +274,7 @@ bool Thing::ai_create_path_to_goal(int minx, int miny, int maxx, int maxy, int s
274274
bool Thing::ai_create_path_to_single_goal_do(int minx, int miny, int maxx, int maxy, const Goal &goal,
275275
const Dmap *saved_dmap, bool allow_diagonals)
276276
{
277-
IF_DEBUG
277+
IF_DEBUG2
278278
{
279279
auto s = string_sprintf("Process goal score %d @(%d,%d) %s", (int) goal.score, (int) goal.at.x, (int) goal.at.y,
280280
goal.msg.c_str());
@@ -395,7 +395,7 @@ bool Thing::ai_create_path_to_single_goal_do(int minx, int miny, int maxx, int m
395395
// Did we try or attempt to try to do something?
396396
//
397397
if (! game->tick_requested.empty()) {
398-
IF_DEBUG
398+
IF_DEBUG2
399399
{
400400
auto s = string_sprintf("Successfully requested a tick: %s", game->tick_requested.c_str());
401401
AI_LOG(s);
@@ -482,7 +482,7 @@ int Thing::ai_dmap_can_see_init(int minx, int miny, int maxx, int maxy, int sear
482482
point p(x, y);
483483

484484
if (! get(ai->can_see_ever.can_see, x, y)) {
485-
// dbg("can see walk %d,%d line %d", x, y, __LINE__);
485+
// dbg2("can see walk %d,%d line %d", x, y, __LINE__);
486486
continue;
487487
}
488488

@@ -494,13 +494,13 @@ int Thing::ai_dmap_can_see_init(int minx, int miny, int maxx, int maxy, int sear
494494
//
495495
if (0) {
496496
if (too_far_from_mob(p)) {
497-
// dbg("can see walk %d,%d line %d", x, y, __LINE__);
497+
// dbg2("can see walk %d,%d line %d", x, y, __LINE__);
498498
continue;
499499
}
500500

501501
if (too_far_from_leader(p)) {
502502
if (distance_from_leader() < too_far_from_leader(p)) {
503-
// dbg("can see walk %d,%d line %d", x, y, __LINE__);
503+
// dbg2("can see walk %d,%d line %d", x, y, __LINE__);
504504
continue;
505505
}
506506
}
@@ -547,7 +547,7 @@ int Thing::ai_dmap_can_see_init(int minx, int miny, int maxx, int maxy, int sear
547547
// So if we get here this thing is an AI obstacle. Can we jump over it?
548548
//
549549
if (! jump_allowed) {
550-
// dbg("can see walk %d,%d line %d", x, y, __LINE__);
550+
// dbg2("can see walk %d,%d line %d", x, y, __LINE__);
551551
continue;
552552
}
553553

@@ -908,20 +908,20 @@ int Thing::ai_dmap_can_see_init(int minx, int miny, int maxx, int maxy, int sear
908908
//
909909
set(dmap_can_see->val, start.x, start.y, DMAP_IS_GOAL);
910910

911-
IF_DEBUG
911+
IF_DEBUG2
912912
{
913913
if (is_debug_type()) {
914-
dbg("DMAP can see before processing:");
914+
dbg2("DMAP can see before processing:");
915915
dmap_print(dmap_can_see, curr_at, point(minx, miny), point(maxx, maxy));
916916
}
917917
}
918918

919919
dmap_process(dmap_can_see, point(minx, miny), point(maxx, maxy), true, true);
920920

921-
IF_DEBUG
921+
IF_DEBUG2
922922
{
923923
if (is_debug_type()) {
924-
dbg("DMAP can see:");
924+
dbg2("DMAP can see:");
925925
dmap_print(dmap_can_see, curr_at, point(minx, miny), point(maxx, maxy));
926926
}
927927
}
@@ -952,7 +952,7 @@ void Thing::ai_choose_can_see_goals(std::multiset< Goal > &goals, int minx, int
952952
}
953953
}
954954

955-
dbg("Choose can see goals between %d,%d and %d,%d", minx, miny, maxx, maxy);
955+
dbg2("Choose can see goals between %d,%d and %d,%d", minx, miny, maxx, maxy);
956956
TRACE_AND_INDENT();
957957

958958
for (int y = miny; y <= maxy; y++) {
@@ -1119,9 +1119,9 @@ void Thing::ai_choose_can_see_goals(std::multiset< Goal > &goals, int minx, int
11191119
// knowledge.
11201120
//
11211121
if (lit_recently) {
1122-
dbg("AI: Consider (my agg+health %d, its health %d) ? %s%s%s%s", my_health, it_health,
1123-
it->to_short_string().c_str(), is_enemy(it) ? ", is enemy" : "",
1124-
is_dangerous(it) ? ", is dangerous" : "", is_to_be_avoided(it) ? ", is to be avoided" : "");
1122+
dbg2("AI: Consider (my agg+health %d, its health %d) ? %s%s%s%s", my_health, it_health,
1123+
it->to_short_string().c_str(), is_enemy(it) ? ", is enemy" : "",
1124+
is_dangerous(it) ? ", is dangerous" : "", is_to_be_avoided(it) ? ", is to be avoided" : "");
11251125
TRACE_AND_INDENT();
11261126

11271127
if (is_enemy(it) && (dist <= max_dist)) {
@@ -1416,7 +1416,7 @@ void Thing::ai_choose_search_goals(std::multiset< Goal > &goals, int search_type
14161416
if (search_type < MONST_SEARCH_TYPE_LAST_RESORTS_NO_JUMP) {
14171417
continue;
14181418
}
1419-
IF_DEBUG
1419+
IF_DEBUG2
14201420
{
14211421
auto s = string_sprintf("Choose possible descend sewer at @(%d,%d)", o.x, o.y);
14221422
AI_LOG(s);
@@ -1434,7 +1434,7 @@ void Thing::ai_choose_search_goals(std::multiset< Goal > &goals, int search_type
14341434
if (search_type < MONST_SEARCH_TYPE_LAST_RESORTS_NO_JUMP) {
14351435
continue;
14361436
}
1437-
IF_DEBUG
1437+
IF_DEBUG2
14381438
{
14391439
auto s = string_sprintf("Choose possible ascend sewer at @(%d,%d)", o.x, o.y);
14401440
AI_LOG(s);
@@ -1452,7 +1452,7 @@ void Thing::ai_choose_search_goals(std::multiset< Goal > &goals, int search_type
14521452
if (search_type < MONST_SEARCH_TYPE_LAST_RESORTS_NO_JUMP) {
14531453
continue;
14541454
}
1455-
IF_DEBUG
1455+
IF_DEBUG2
14561456
{
14571457
auto s = string_sprintf("Choose possible descend dungeon at @(%d,%d)", o.x, o.y);
14581458
AI_LOG(s);
@@ -1470,7 +1470,7 @@ void Thing::ai_choose_search_goals(std::multiset< Goal > &goals, int search_type
14701470
if (search_type < MONST_SEARCH_TYPE_LAST_RESORTS_NO_JUMP) {
14711471
continue;
14721472
}
1473-
IF_DEBUG
1473+
IF_DEBUG2
14741474
{
14751475
auto s = string_sprintf("Choose possible ascend dungeon at @(%d,%d)", o.x, o.y);
14761476
AI_LOG(s);
@@ -1591,7 +1591,7 @@ void Thing::ai_choose_search_goals(std::multiset< Goal > &goals, int search_type
15911591
// No search destinations that are, for example, a chasm
15921592
//
15931593
if (is_hated_by_me(p)) {
1594-
IF_DEBUG
1594+
IF_DEBUG2
15951595
{
15961596
auto s = string_sprintf("Search cand is hated @(%d,%d)", p.x, p.y);
15971597
AI_LOG(s);
@@ -2037,7 +2037,7 @@ bool Thing::ai_choose_avoid_goals(std::multiset< Goal > &goals, const Goal &goal
20372037
//
20382038
bool Thing::ai_tick(bool recursing)
20392039
{
2040-
dbg("AI: tick");
2040+
dbg2("AI: tick");
20412041
TRACE_AND_INDENT();
20422042

20432043
auto ai = aip();
@@ -2194,18 +2194,18 @@ bool Thing::ai_tick(bool recursing)
21942194
//
21952195
// See if anything dangerous is close
21962196
//
2197-
dbg("AI: look for dangerous things");
2197+
dbg2("AI: look for dangerous things");
21982198
TRACE_AND_INDENT();
21992199

22002200
threat = most_dangerous_visible_thing();
22012201
if (threat) {
2202-
IF_DEBUG { ai_log("threat", threat); }
2202+
IF_DEBUG2 { ai_log("threat", threat); }
22032203
}
22042204

22052205
//
22062206
// A threat can be a few tiles away; but if one is standing literally next to us! then it takes priority.
22072207
//
2208-
dbg("AI: look for adjacent dangerous things");
2208+
dbg2("AI: look for adjacent dangerous things");
22092209
TRACE_AND_INDENT();
22102210

22112211
auto adjacent_threat = most_dangerous_adjacent_thing();
@@ -2437,13 +2437,13 @@ bool Thing::ai_tick(bool recursing)
24372437
}
24382438
}
24392439

2440-
dbg("AI: state handling");
2440+
dbg2("AI: state handling");
24412441
TRACE_AND_INDENT();
24422442

24432443
switch (infop()->monst_state) {
24442444
case MONST_STATE_IDLE :
24452445
{
2446-
dbg("AI: state idle");
2446+
dbg2("AI: state idle");
24472447
TRACE_AND_INDENT();
24482448

24492449
if (state_idle(threat, minx, miny, maxx, maxy)) {
@@ -2453,7 +2453,7 @@ bool Thing::ai_tick(bool recursing)
24532453
}
24542454
case MONST_STATE_MOVING :
24552455
{
2456-
dbg("AI: state moving");
2456+
dbg2("AI: state moving");
24572457
TRACE_AND_INDENT();
24582458

24592459
if (state_moving()) {
@@ -2463,7 +2463,7 @@ bool Thing::ai_tick(bool recursing)
24632463
}
24642464
case MONST_STATE_SLEEPING :
24652465
{
2466-
dbg("AI: state sleeping");
2466+
dbg2("AI: state sleeping");
24672467
TRACE_AND_INDENT();
24682468

24692469
if (state_sleeping(do_something, wait)) {
@@ -2473,7 +2473,7 @@ bool Thing::ai_tick(bool recursing)
24732473
}
24742474
case MONST_STATE_RESTING :
24752475
{
2476-
dbg("AI: state resting");
2476+
dbg2("AI: state resting");
24772477
TRACE_AND_INDENT();
24782478

24792479
if (state_resting(do_something, wait)) {
@@ -2483,7 +2483,7 @@ bool Thing::ai_tick(bool recursing)
24832483
}
24842484
case MONST_STATE_OPEN_INVENTORY :
24852485
{
2486-
dbg("AI: state open inventory");
2486+
dbg2("AI: state open inventory");
24872487
TRACE_AND_INDENT();
24882488

24892489
if (state_open_inventory()) {
@@ -2493,7 +2493,7 @@ bool Thing::ai_tick(bool recursing)
24932493
}
24942494
case MONST_STATE_USING_ENCHANTSTONE :
24952495
{
2496-
dbg("AI: state use enchantstone");
2496+
dbg2("AI: state use enchantstone");
24972497
TRACE_AND_INDENT();
24982498

24992499
if (state_using_enchantstone()) {
@@ -2503,7 +2503,7 @@ bool Thing::ai_tick(bool recursing)
25032503
}
25042504
case MONST_STATE_USING_SKILLSTONE :
25052505
{
2506-
dbg("AI: state use skillstone");
2506+
dbg2("AI: state use skillstone");
25072507
TRACE_AND_INDENT();
25082508

25092509
if (state_using_skillstone()) {
@@ -2513,7 +2513,7 @@ bool Thing::ai_tick(bool recursing)
25132513
}
25142514
case MONST_STATE_REPACK_INVENTORY :
25152515
{
2516-
dbg("AI: state repack inventory");
2516+
dbg2("AI: state repack inventory");
25172517
TRACE_AND_INDENT();
25182518

25192519
if (state_repack_inventory()) {

0 commit comments

Comments
 (0)