Skip to content

Commit 29511a3

Browse files
author
mqrause
committed
player_activity::moves_left initializes to calendar::INDEFINITELY_LONG
1 parent 671245d commit 29511a3

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/activity_actor.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "avatar.h"
2222
#include "avatar_action.h"
2323
#include "bodypart.h"
24-
#include "calendar.h"
2524
#include "character.h"
2625
#include "coordinates.h"
2726
#include "contents_change_handler.h"
@@ -464,7 +463,7 @@ void aim_activity_actor::unload_RAS_weapon()
464463
}
465464
}
466465

467-
void autodrive_activity_actor::start( player_activity &act, Character &who )
466+
void autodrive_activity_actor::start( player_activity &, Character &who )
468467
{
469468
const bool in_vehicle = who.in_vehicle && who.controlling_vehicle;
470469
const optional_vpart_position vp = get_map().veh_at( who.pos() );
@@ -475,7 +474,6 @@ void autodrive_activity_actor::start( player_activity &act, Character &who )
475474

476475
player_vehicle = &vp->vehicle();
477476
player_vehicle->is_autodriving = true;
478-
act.moves_left = calendar::INDEFINITELY_LONG;
479477
}
480478

481479
void autodrive_activity_actor::do_turn( player_activity &act, Character &who )
@@ -2572,7 +2570,7 @@ std::unique_ptr<activity_actor> open_gate_activity_actor::deserialize( JsonValue
25722570

25732571
void consume_activity_actor::start( player_activity &act, Character &guy )
25742572
{
2575-
int moves;
2573+
int moves = 0;
25762574
Character &player_character = get_player_character();
25772575
if( consume_location ) {
25782576
ret_val<edible_rating> ret = ret_val<edible_rating>::make_success();
@@ -2587,9 +2585,9 @@ void consume_activity_actor::start( player_activity &act, Character &guy )
25872585
consume_menu_selections = std::vector<int>();
25882586
consume_menu_selected_items.clear();
25892587
consume_menu_filter.clear();
2590-
return;
2588+
} else {
2589+
moves = to_moves<int>( guy.get_consume_time( *consume_location ) );
25912590
}
2592-
moves = to_moves<int>( guy.get_consume_time( *consume_location ) );
25932591
} else if( !consume_item.is_null() ) {
25942592
ret_val<edible_rating> ret = ret_val<edible_rating>::make_success();
25952593
if( refuel ) {
@@ -2602,13 +2600,12 @@ void consume_activity_actor::start( player_activity &act, Character &guy )
26022600
consume_menu_selections = std::vector<int>();
26032601
consume_menu_selected_items.clear();
26042602
consume_menu_filter.clear();
2605-
return;
2603+
} else {
2604+
moves = to_moves<int>( guy.get_consume_time( consume_item ) );
26062605
}
2607-
moves = to_moves<int>( guy.get_consume_time( consume_item ) );
26082606
} else {
26092607
debugmsg( "Item/location to be consumed should not be null." );
26102608
canceled = true;
2611-
return;
26122609
}
26132610

26142611
act.moves_total = moves;
@@ -3038,7 +3035,6 @@ void craft_activity_actor::start( player_activity &act, Character &crafter )
30383035
if( !check_if_craft_okay( craft_item, crafter ) ) {
30393036
act.set_to_null();
30403037
}
3041-
act.moves_left = calendar::INDEFINITELY_LONG;
30423038
activity_override = craft_item.get_item()->get_making().exertion_level();
30433039
cached_crafting_speed = 0;
30443040
}
@@ -4438,7 +4434,6 @@ void disassemble_activity_actor::start( player_activity &act, Character &who )
44384434
// Mark the item, not available for other characters
44394435
target->set_var( "activity_var", who.name );
44404436

4441-
act.moves_left = calendar::INDEFINITELY_LONG;
44424437
activity_override = target->get_making().exertion_level();
44434438
}
44444439

@@ -5570,6 +5565,10 @@ std::unique_ptr<activity_actor> forage_activity_actor::deserialize( JsonValue &j
55705565
void longsalvage_activity_actor::start( player_activity &act, Character & )
55715566
{
55725567
act.index = index;
5568+
5569+
//todo: refactor the actor to process items in ::do_turn, then remove setting the moves to 0
5570+
//this currently still can't get interrupted before you get attacked
5571+
act.moves_left = 0;
55735572
}
55745573

55755574
void longsalvage_activity_actor::finish( player_activity &act, Character &who )

src/activity_actor_definitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class autodrive_activity_actor : public activity_actor
117117
return activity_id( "ACT_AUTODRIVE" );
118118
}
119119

120-
void start( player_activity &act, Character & ) override;
120+
void start( player_activity &, Character & ) override;
121121
void do_turn( player_activity &, Character & ) override;
122122
void canceled( player_activity &, Character & ) override;
123123
void finish( player_activity &act, Character & ) override;

src/player_activity.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <vector>
1212

1313
#include "activity_actor.h"
14+
#include "calendar.h"
1415
#include "clone_ptr.h"
1516
#include "compatibility.h"
1617
#include "enums.h"
@@ -41,7 +42,7 @@ class player_activity
4142
/** Total number of moves required to complete the activity */
4243
int moves_total = 0;
4344
/** The number of moves remaining in this activity before it is complete. */
44-
int moves_left = 0;
45+
int moves_left = calendar::INDEFINITELY_LONG;
4546
/** Controls whether this activity can be cancelled at all */
4647
bool interruptable = true;
4748
/** Controls whether this activity can be cancelled with 'pause' action */

0 commit comments

Comments
 (0)