@@ -300,11 +300,21 @@ std::vector<mission *> avatar::get_failed_missions() const
300
300
return failed_missions;
301
301
}
302
302
303
+ std::vector<point_of_interest> avatar::get_points_of_interest () const
304
+ {
305
+ return points_of_interest;
306
+ }
307
+
303
308
mission *avatar::get_active_mission () const
304
309
{
305
310
return active_mission;
306
311
}
307
312
313
+ point_of_interest avatar::get_active_point_of_interest () const
314
+ {
315
+ return active_point_of_interest;
316
+ }
317
+
308
318
void avatar::reset_all_missions ()
309
319
{
310
320
active_mission = nullptr ;
@@ -315,10 +325,12 @@ void avatar::reset_all_missions()
315
325
316
326
tripoint_abs_omt avatar::get_active_mission_target () const
317
327
{
318
- if ( active_mission == nullptr ) {
319
- return tripoint_abs_omt::invalid;
328
+ if ( active_mission != nullptr ) {
329
+ return active_mission->get_target ();
330
+ } else {
331
+ // It's tripoint_abs_invalid if not active.
332
+ return active_point_of_interest.pos ;
320
333
}
321
- return active_mission->get_target ();
322
334
}
323
335
324
336
void avatar::set_active_mission ( mission &cur_mission )
@@ -329,7 +341,25 @@ void avatar::set_active_mission( mission &cur_mission )
329
341
cur_mission.mission_id ().c_str () );
330
342
} else {
331
343
active_mission = &cur_mission;
344
+ active_point_of_interest.pos = tripoint_abs_omt::invalid;
345
+ }
346
+ }
347
+
348
+ void avatar::set_active_point_of_interest ( const point_of_interest &active_point_of_interest )
349
+ {
350
+ for ( const point_of_interest &iter : points_of_interest ) {
351
+ // It's really sufficient to only check the position as used...
352
+ if ( iter.pos == active_point_of_interest.pos &&
353
+ iter.text == active_point_of_interest.text ) {
354
+ this ->active_point_of_interest = active_point_of_interest;
355
+ active_mission = nullptr ;
356
+ return ;
357
+ }
358
+
332
359
}
360
+
361
+ debugmsg ( " active point of interest %s is not in the points_of_interest list" ,
362
+ active_point_of_interest.text .c_str () );
333
363
}
334
364
335
365
void avatar::update_active_mission ()
@@ -399,6 +429,44 @@ void avatar::remove_active_mission( mission &cur_mission )
399
429
}
400
430
}
401
431
432
+ void avatar::add_point_of_interest ( const point_of_interest &new_point_of_interest )
433
+ {
434
+ for ( point_of_interest &existing_point_of_interest : points_of_interest ) {
435
+ if ( new_point_of_interest.pos == existing_point_of_interest.pos ) {
436
+ existing_point_of_interest.text = new_point_of_interest.text ;
437
+ active_mission = nullptr ;
438
+ active_point_of_interest = new_point_of_interest;
439
+ return ;
440
+ }
441
+ }
442
+
443
+ points_of_interest.push_back ( new_point_of_interest );
444
+ active_mission = nullptr ;
445
+ active_point_of_interest = new_point_of_interest;
446
+ }
447
+
448
+ void avatar::delete_point_of_interest ( tripoint_abs_omt pos )
449
+ {
450
+ for ( auto iter = points_of_interest.begin (); iter != points_of_interest.end (); iter++ ) {
451
+ if ( iter->pos == pos ) {
452
+ points_of_interest.erase ( iter );
453
+
454
+ if ( active_point_of_interest.pos == pos ) {
455
+ active_point_of_interest.pos = tripoint_abs_omt::invalid;
456
+
457
+ if ( !active_missions.empty () ) {
458
+ active_mission = active_missions.front ();
459
+ }
460
+ }
461
+
462
+ return ;
463
+ }
464
+ }
465
+
466
+ debugmsg ( " removed point of interest at %s was not in the points_of_interest list" ,
467
+ pos.to_string ().c_str () );
468
+ }
469
+
402
470
diary *avatar::get_avatar_diary ()
403
471
{
404
472
if ( a_diary == nullptr ) {
0 commit comments