bool player_activity::can_resume_with( const player_activity &other, const Character & ) const { // Should be used for relative positions // And to forbid resuming now-invalid crafting // @todo: Once activity_handler_actors exist, the less ugly method of using a // pure virtual can_resume_with should be used if( !*this || !other || type->no_resume() ) { return false; } if( id() == activity_id( "ACT_CRAFT" ) || id() == activity_id( "ACT_LONGCRAFT" ) ) { if( !containers_equal( values, other.values ) || !containers_equal( coords, other.coords ) ) { return false; } } else if( id() == activity_id( "ACT_CLEAR_RUBBLE" ) ) { if( other.coords.empty() || other.coords[0] != coords[0] ) { return false; } } else if( id() == activity_id( "ACT_READ" ) ) { // Return false if any NPCs joined or left the study session // the vector {1, 2} != {2, 1}, so we'll have to check manually if( values.size() != other.values.size() ) { return false; } for( int foo : other.values ) { if( std::find( values.begin(), values.end(), foo ) == values.end() ) { return false; } } if( targets.empty() || other.targets.empty() || targets[0] != other.targets[0] ) { return false; } } return !auto_resume && id() == other.id() && index == other.index && position == other.position && name == other.name && targets == other.targets; }
bool player_activity::can_resume_with( const player_activity &other, const Character &who ) const { // Should be used for relative positions // And to forbid resuming now-invalid crafting ( void )who; switch( type ) { case ACT_NULL: case NUM_ACTIVITIES: return false; case ACT_RELOAD: case ACT_READ: case ACT_GAME: case ACT_REFILL_VEHICLE: break; case ACT_WAIT: case ACT_WAIT_NPC: case ACT_WAIT_WEATHER: case ACT_ARMOR_LAYERS: case ACT_PULP: case ACT_AIM: case ACT_LONGSALVAGE: case ACT_ATM: case ACT_DROP: case ACT_STASH: case ACT_PICKUP: case ACT_MOVE_ITEMS: case ACT_ADV_INVENTORY: case ACT_START_FIRE: case ACT_FILL_LIQUID: // Those shouldn't be resumed // They don't store their progress in moves return false; case ACT_CRAFT: case ACT_LONGCRAFT: // Batch size is stored in values // Coords may be matched incorrectly in some rare cases // But it will not result in a false negative if( !containers_equal( values, other.values ) || !containers_equal( coords, other.coords ) ) { return false; } break; case ACT_DISASSEMBLE: // Disassembling is currently hardcoded in such a way // that easy resuming isn't possible case ACT_FORAGE: case ACT_OPEN_GATE: case ACT_OXYTORCH: case ACT_CRACKING: case ACT_FISH: case ACT_PICKAXE: case ACT_BURROW: // Those should check position // But position isn't set here yet! // @todo Update the functions that set those activities case ACT_BUTCHER: case ACT_TRAIN: case ACT_HOTWIRE_CAR: case ACT_START_ENGINES: case ACT_BUILD: case ACT_VEHICLE: case ACT_FIRSTAID: case ACT_VIBE: case ACT_MAKE_ZLAVE: case ACT_GUNMOD_ADD: case ACT_REPAIR_ITEM: case ACT_MEND_ITEM: // Those should have extra limitations // But for now it's better to allow too much than too little break; } return !auto_resume && type == other.type && index == other.index && position == other.position && name == other.name; }