Skip to content

Commit

Permalink
remove now-obsolete e-storage code
Browse files Browse the repository at this point in the history
  • Loading branch information
ShnitzelX2 committed Jan 21, 2025
1 parent 672a2b7 commit 9e6ea30
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 681 deletions.
15 changes: 0 additions & 15 deletions data/json/item_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,21 +374,11 @@
"id": "EHANDCUFFS",
"name": { "str": "Take off" }
},
{
"type": "item_action",
"id": "EINKTABLETPC",
"name": { "str": "Use SD-Card apps" }
},
{
"type": "item_action",
"id": "EBOOKSAVE",
"name": { "str": "Store books" }
},
{
"type": "item_action",
"id": "EBOOKREAD",
"name": { "str": "Read stored books" }
},
{
"type": "item_action",
"id": "EMF_PASSIVE_ON",
Expand Down Expand Up @@ -699,11 +689,6 @@
"id": "PROZAC",
"name": { "str": "Take" }
},
{
"type": "item_action",
"id": "ELECTRICSTORAGE",
"name": { "str": "Manage external storage" }
},
{
"type": "item_action",
"id": "E_FILE_DEVICE",
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/fake.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"name": { "str": "Integrated AR System" },
"description": "Extremely thin lenses provides user with augmented reality overlay allowing the user to zoom, and it displays handy information about local topology.",
"charges_per_use": 1,
"use_action": [ "CAMERA", "PORTABLE_GAME", "EINKTABLETPC", "ELECTRICSTORAGE", "EBOOKSAVE", "EBOOKREAD" ],
"use_action": [ "CAMERA", "PORTABLE_GAME", "EBOOKSAVE", "E_FILE_DEVICE" ],
"pocket_data": [
{
"pocket_type": "EBOOK",
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/tool_armor.json
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@
"color": "light_gray",
"ammo": "battery",
"charges_per_use": 1,
"use_action": [ "CAMERA", "PORTABLE_GAME", "EINKTABLETPC", "ELECTRICSTORAGE", "EBOOKSAVE", "EBOOKREAD" ],
"use_action": [ "CAMERA", "PORTABLE_GAME", "EBOOKSAVE", "E_FILE_DEVICE" ],
"tick_action": [ "EPIC_MUSIC" ],
"pocket_data": [
{
Expand Down
226 changes: 0 additions & 226 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,231 +1038,6 @@ std::unique_ptr<activity_actor> bookbinder_copy_activity_actor::deserialize( Jso
return actor.clone();
}

data_handling_activity_actor::data_handling_activity_actor(
const item_location &recorder, const std::vector<item_location> &targets )
: recorder( recorder ), targets( targets ) {}

static int get_quality_from_string( const std::string_view s )
{
const ret_val<int> try_quality = try_parse_integer<int>( s, false );
if( try_quality.success() ) {
return try_quality.value();
} else {
debugmsg( "Error parsing photo quality: %s", try_quality.str() );
return 0;
}
}

void data_handling_activity_actor::start( player_activity &act, Character & )
{
act.moves_left = act.moves_total = targets.size() * to_moves<int>( time_per_card );
}

void data_handling_activity_actor::do_turn( player_activity &act, Character &p )
{
if( !recorder || !recorder->ammo_sufficient( &p ) ) {
p.cancel_activity();
p.add_msg_if_player( m_warning, _( "%s appears to have no energy." ), recorder->display_name() );
return;
}
if( calendar::once_every( 5_minutes ) ) {
recorder->ammo_consume( recorder->type->charges_to_use(), p.pos_bub(), &p );
}
time_until_next_card -= 1_seconds;
if( time_until_next_card > 0_seconds ) {
return; // not yet
}
item &eink = *recorder;
item &mc = *targets.back();
targets.pop_back();
if( targets.empty() ) {
act.moves_left = 0;
}
time_until_next_card = time_per_card;
handled_cards++;

if( mc.has_var( "MC_EXTENDED_PHOTOS" ) ) {
std::vector<item::extended_photo_def> extended_photos;
try {
mc.read_extended_photos( extended_photos, "MC_EXTENDED_PHOTOS", false );
eink.read_extended_photos( extended_photos, "EIPC_EXTENDED_PHOTOS", true );
eink.write_extended_photos( extended_photos, "EIPC_EXTENDED_PHOTOS" );
downloaded_extended_photos++;
} catch( const JsonError &e ) {
debugmsg( "Error card reading photos (loaded photos = %i) : %s", extended_photos.size(),
e.c_str() );
}
}

const std::string monster_photos = mc.get_var( "MC_MONSTER_PHOTOS" );
if( !monster_photos.empty() ) {
downloaded_monster_photos++;
std::string photos = eink.get_var( "EINK_MONSTER_PHOTOS" );
if( photos.empty() ) {
eink.set_var( "EINK_MONSTER_PHOTOS", monster_photos );
} else {
std::istringstream f( monster_photos );
std::string s;
while( getline( f, s, ',' ) ) {
if( s.empty() ) {
continue;
}
const std::string mtype = s;
getline( f, s, ',' );
const int quality = get_quality_from_string( s );

const size_t eink_strpos = photos.find( "," + mtype + "," );

if( eink_strpos == std::string::npos ) {
photos += mtype + "," + string_format( "%d", quality ) + ",";
} else {
const size_t strqpos = eink_strpos + mtype.size() + 2;
const size_t next_comma = photos.find( ',', strqpos );
const int old_quality =
get_quality_from_string( photos.substr( strqpos, next_comma ) );

if( quality > old_quality ) {
const std::string quality_s = string_format( "%d", quality );
cata_assert( quality_s.size() == 1 );
photos[strqpos] = quality_s.front();
}
}

}
eink.set_var( "EINK_MONSTER_PHOTOS", photos );
}
}
const memory_card_info *mmd = mc.type->memory_card_data ? &*mc.type->memory_card_data : nullptr;
const bool failed_encrypted = mmd && mmd->data_chance < rng_float( 0.0, 1.0 );
if( mmd && mmd->on_read_convert_to.is_valid() ) {
mc.clear_vars();
mc.unset_flags();
mc.convert( mmd->on_read_convert_to );
} // mc is invalid past this point
if( !mmd || failed_encrypted ) {
encrypted_cards += failed_encrypted ? 1 : 0;
return;
}
if( mmd->photos_chance >= rng_float( 0.0, 1.0 ) ) {
const int new_photos = rng( 1, mmd->photos_amount );
eink.set_var( "EIPC_PHOTOS", eink.get_var( "EIPC_PHOTOS", 0 ) + new_photos );
downloaded_photos += new_photos;
}
if( mmd->songs_chance >= rng_float( 0.0, 1.0 ) ) {
const int new_songs = rng( 1, mmd->songs_amount );
eink.set_var( "EIPC_MUSIC", eink.get_var( "EIPC_MUSIC", 0 ) + new_songs );
downloaded_songs += new_songs;
}
if( mmd->recipes_chance >= rng_float( 0.0, 1.0 ) ) {
std::set<recipe_id> saved_recipes = eink.get_saved_recipes();
std::set<recipe_id> candidates;
for( const auto& [rid, r] : recipe_dict ) {
if( r.never_learn || r.obsolete || mmd->recipes_categories.count( r.category ) == 0 ||
saved_recipes.count( rid ) ||
r.difficulty > mmd->recipes_level_max || r.difficulty < mmd->recipes_level_min ||
( r.has_flag( "SECRET" ) && !mmd->secret_recipes ) ) {
continue;
}
candidates.emplace( rid );
}

const int recipe_num = rng( 1, mmd->recipes_amount );
for( int i = 0; i < recipe_num && !candidates.empty(); i++ ) {
const recipe_id rid = random_entry_removed( candidates );
if( saved_recipes.emplace( rid ).second ) {
downloaded_recipes.emplace_back( rid );
} else {
debugmsg( "failed saving '%s' to '%s'", rid.str(), eink.display_name() );
}
}
eink.set_saved_recipes( saved_recipes );
}
}

static void print_data_handling_tally( Character &who, int encrypted_cards, int photos, int songs,
const std::vector<recipe_id> &recipes, int extended_photos, int monster_photos )
{
if( !recipes.empty() ) {
who.add_msg_if_player( m_good, _( "Downloaded %d %s: %s." ), recipes.size(),
n_gettext( "recipe", "recipes", recipes.size() ),
enumerate_as_string( recipes, []( const recipe_id & rid ) {
return rid->result_name();
} ) );
}
if( monster_photos > 0 ) {
who.add_msg_if_player( m_good, _( "You have updated your monster collection." ) );
}
if( extended_photos > 0 ) {
who.add_msg_if_player( m_good, _( "You have downloaded your photos." ) );
}
if( encrypted_cards > 0 ) {
who.add_msg_if_player( m_bad, _( "%d %s appeared to be encrypted or corrupted." ),
encrypted_cards, n_gettext( "card", "cards", encrypted_cards ) );
}
if( photos > 0 && who.is_avatar() ) {
who.add_msg_if_player( m_good, _( "Downloaded %d new %s." ),
photos, n_gettext( "photo", "photos", photos ) );
}
if( songs > 0 && who.is_avatar() ) {
who.add_msg_if_player( m_good, _( "Downloaded %d new %s." ),
songs, n_gettext( "song", "songs", songs ) );
}
if( !( photos || songs || monster_photos || extended_photos || !recipes.empty() ) ) {
who.add_msg_if_player( m_warning, _( "No new data has been discovered." ) );
}
}

void data_handling_activity_actor::canceled( player_activity &act, Character &p )
{
print_data_handling_tally( p, encrypted_cards, downloaded_photos, downloaded_songs,
downloaded_recipes, downloaded_extended_photos, downloaded_monster_photos );
p.add_msg_if_player( m_info, _( "You stop downloading data after %d %s." ),
handled_cards, n_gettext( "card", "cards", handled_cards ) );
act.set_to_null();
}

void data_handling_activity_actor::finish( player_activity &act, Character &p )
{
print_data_handling_tally( p, encrypted_cards, downloaded_photos, downloaded_songs,
downloaded_recipes, downloaded_extended_photos, downloaded_monster_photos );
p.add_msg_if_player( m_info, _( "You finish downloading data from %d %s." ),
handled_cards, n_gettext( "card", "cards", handled_cards ) );
act.set_to_null();
}

void data_handling_activity_actor::serialize( JsonOut &jsout ) const
{
jsout.start_object();
jsout.member( "recorder", recorder );
jsout.member( "targets", targets );
jsout.member( "time_until_next_action", time_until_next_card );
jsout.member( "handled_cards", handled_cards );
jsout.member( "encrypted_cards", encrypted_cards );
jsout.member( "downloaded_photos", downloaded_photos );
jsout.member( "downloaded_songs", downloaded_songs );
jsout.member( "downloaded_recipes", downloaded_recipes );
jsout.member( "downloaded_extended_photos", downloaded_extended_photos );
jsout.member( "downloaded_monster_photos", downloaded_monster_photos );
jsout.end_object();
}

std::unique_ptr<activity_actor> data_handling_activity_actor::deserialize( JsonValue &jsin )
{
data_handling_activity_actor actor;
JsonObject jsobj = jsin.get_object();
jsobj.read( "recorder", actor.recorder );
jsobj.read( "targets", actor.targets );
jsobj.read( "time_until_next_action", actor.time_until_next_card );
jsobj.read( "handled_cards", actor.handled_cards );
jsobj.read( "encrypted_cards", actor.encrypted_cards );
jsobj.read( "downloaded_photos", actor.downloaded_photos );
jsobj.read( "downloaded_songs", actor.downloaded_songs );
jsobj.read( "downloaded_recipes", actor.downloaded_recipes );
jsobj.read( "downloaded_extended_photos", actor.downloaded_extended_photos );
jsobj.read( "downloaded_monster_photos", actor.downloaded_monster_photos );
return actor.clone();
}

void hotwire_car_activity_actor::start( player_activity &act, Character & )
{
act.moves_total = moves_total;
Expand Down Expand Up @@ -8837,7 +8612,6 @@ deserialize_functions = {
{ ACT_CONSUME, &consume_activity_actor::deserialize },
{ ACT_CRACKING, &safecracking_activity_actor::deserialize },
{ ACT_CRAFT, &craft_activity_actor::deserialize },
{ ACT_DATA_HANDLING, &data_handling_activity_actor::deserialize },
{ ACT_DISABLE, &disable_activity_actor::deserialize },
{ ACT_DISASSEMBLE, &disassemble_activity_actor::deserialize },
{ ACT_DROP, &drop_activity_actor::deserialize },
Expand Down
40 changes: 0 additions & 40 deletions src/activity_actor_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,46 +309,6 @@ class bookbinder_copy_activity_actor: public activity_actor
static std::unique_ptr<activity_actor> deserialize( JsonValue &jsin );
};

class data_handling_activity_actor: public activity_actor
{
public:
explicit data_handling_activity_actor() = default;
explicit data_handling_activity_actor( const item_location &, const std::vector<item_location> & );

const activity_id &get_type() const override {
static const activity_id ACT_DATA_HANDLING( "ACT_DATA_HANDLING" );
return ACT_DATA_HANDLING;
}

bool can_resume_with_internal( const activity_actor &, const Character & ) const override {
return false;
}

void start( player_activity &, Character & ) override;
void do_turn( player_activity &, Character & ) override;
void finish( player_activity &, Character & ) override;
void canceled( player_activity &, Character & ) override;

std::unique_ptr<activity_actor> clone() const override {
return std::make_unique<data_handling_activity_actor>( *this );
}

void serialize( JsonOut & ) const override;
static std::unique_ptr<activity_actor> deserialize( JsonValue & );
private:
static constexpr time_duration time_per_card = 1_minutes;
item_location recorder;
std::vector<item_location> targets;
time_duration time_until_next_card = 0_seconds;
int handled_cards = 0;
int encrypted_cards = 0;
int downloaded_photos = 0;
int downloaded_songs = 0;
std::vector<recipe_id> downloaded_recipes;
int downloaded_extended_photos = 0;
int downloaded_monster_photos = 0;
};

class hotwire_car_activity_actor : public activity_actor
{
private:
Expand Down
Loading

0 comments on commit 9e6ea30

Please sign in to comment.