Skip to content

Commit

Permalink
replace software, e-book functions with e-file
Browse files Browse the repository at this point in the history
item categories for software, files
  • Loading branch information
ShnitzelX2 committed Jan 23, 2025
1 parent 9e6ea30 commit 3cddba6
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 118 deletions.
16 changes: 16 additions & 0 deletions data/json/item_category.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
[
{
"id": "e_files",
"type": "ITEM_CATEGORY",
"name_header": { "str": "Files" },
"name_noun": { "ctxt": "item_category", "str": "file" },
"zone": "LOOT_OTHER",
"sort_rank": -25
},
{
"id": "software",
"type": "ITEM_CATEGORY",
"name_header": { "str": "Software" },
"name_noun": { "ctxt": "item_category", "str_sp": "software" },
"zone": "LOOT_OTHER",
"sort_rank": -24
},
{
"id": "guns",
"type": "ITEM_CATEGORY",
Expand Down
31 changes: 16 additions & 15 deletions data/json/items/software.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[
{
"id": "software",
"id": "abstract_software",
"copy-from": "abstract_efile",
"type": "GENERIC",
"name": { "str_sp": "software" },
"symbol": "#",
"container": "usb_drive",
"description": { "str": "IF YOU ARE SEEING THIS IT IS A BUG.", "//~": "NO_I18N" },
"flags": [ "IRREMOVABLE", "NO_DROP" ]
"category": "software",
"name": { "str_sp": "abstract software" },
"description": "Copy from this for any software",
"ememory_size": "1 KB"
},
{
"id": "software_useless",
"copy-from": "abstract_efile",
"copy-from": "abstract_software",
"type": "GENERIC",
"name": { "str_sp": "misc software" },
"description": "A miscellaneous piece of hobby software. Probably useless.",
Expand All @@ -20,7 +20,7 @@
},
{
"id": "software_hacking",
"copy-from": "abstract_efile",
"copy-from": "abstract_software",
"type": "GENERIC",
"name": { "str_sp": "hackPRO" },
"description": "A piece of hacking software.",
Expand All @@ -30,7 +30,7 @@
},
{
"id": "software_medical",
"copy-from": "abstract_efile",
"copy-from": "abstract_software",
"type": "GENERIC",
"name": { "str_sp": "MediSoft" },
"description": "A piece of medical software.",
Expand All @@ -40,7 +40,7 @@
},
{
"id": "software_math",
"copy-from": "abstract_efile",
"copy-from": "abstract_software",
"type": "GENERIC",
"name": { "str_sp": "MatheMAX" },
"description": "A piece of mathematical software.",
Expand All @@ -50,7 +50,7 @@
},
{
"id": "software_blood_data",
"copy-from": "abstract_efile",
"copy-from": "abstract_software",
"type": "GENERIC",
"name": { "str_sp": "infection data" },
"description": "Medical data on zombie blood.",
Expand All @@ -60,7 +60,7 @@
},
{
"id": "software_lab_data",
"copy-from": "abstract_efile",
"copy-from": "abstract_software",
"type": "GENERIC",
"name": { "str_sp": "lab data" },
"description": "Research archives from a government laboratory.",
Expand All @@ -70,7 +70,7 @@
},
{
"id": "software_encryption_codes",
"copy-from": "abstract_efile",
"copy-from": "abstract_software",
"type": "GENERIC",
"name": { "str_sp": "encryption codes" },
"description": "There are numerous security keys with dates for potential future access to encrypted archived data.",
Expand All @@ -80,7 +80,7 @@
},
{
"id": "software_archived_data",
"copy-from": "abstract_efile",
"copy-from": "abstract_software",
"type": "GENERIC",
"name": { "str_sp": "archive data" },
"description": "Extremely compressed research data, observation and experiment statistics. The only pattern you manage to recognize is an increase in the amount of report closer to the Cataclysm, but also a reduction in the number of facilities still submitting reports.",
Expand All @@ -90,7 +90,7 @@
},
{
"id": "software_electronics_reference",
"copy-from": "abstract_efile",
"copy-from": "abstract_software",
"type": "GENERIC",
"name": { "str": "integrated circuit datasheet archives", "str_pl": "misc software" },
"description": "Huge archives of numerous IC circuit datasheets from several major manufacturers. Probably valuable to the right person, as it would be hard to salvage and reuse these components without them.",
Expand All @@ -101,6 +101,7 @@
{
"abstract": "abstract_efile",
"type": "GENERIC",
"category": "e_files",
"symbol": "o",
"name": "abstract electronic file",
"description": "abstract electronic file, copy-from for any item that should solely be on an electronic storage medium",
Expand Down
1 change: 0 additions & 1 deletion src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ static const activity_id ACT_CONSUME( "ACT_CONSUME" );
static const activity_id ACT_CONSUME_MEDS_MENU( "ACT_CONSUME_MEDS_MENU" );
static const activity_id ACT_CRACKING( "ACT_CRACKING" );
static const activity_id ACT_CRAFT( "ACT_CRAFT" );
static const activity_id ACT_DATA_HANDLING( "ACT_DATA_HANDLING" );
static const activity_id ACT_DISABLE( "ACT_DISABLE" );
static const activity_id ACT_DISASSEMBLE( "ACT_DISASSEMBLE" );
static const activity_id ACT_DROP( "ACT_DROP" );
Expand Down
2 changes: 1 addition & 1 deletion src/character_crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ recipe_subset Character::get_recipes_from_ebooks( const inventory &crafting_inv

for( const std::list<item> *&stack : crafting_inv.const_slice() ) {
const item &ereader = stack->front();
if( !ereader.is_ebook_storage() || !ereader.ammo_sufficient( this ) ||
if( !ereader.is_estorage() || !ereader.ammo_sufficient( this ) ||
ereader.is_broken_on_active() ) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/character_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ int Character::count_softwares( const itype_id &id )
{
int count = 0;
for( const item_location &it_loc : all_items_loc() ) {
if( it_loc->is_software_storage() ) {
if( it_loc->is_estorage() ) {
for( const item *soft : it_loc->softwares() ) {
if( soft->typeId() == id ) {
count++;
Expand Down
44 changes: 24 additions & 20 deletions src/computer_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ bool computer_session::hack_attempt( Character &you, int Security ) const
return successful_attempt;
}

static item *pick_usb()
static item *pick_estorage( units::ememory can_hold_ememory )
{
auto filter = []( const item & it ) {
return it.typeId() == itype_usb_drive;
auto filter = [&can_hold_ememory]( const item & it ) {
return it.is_estorage() && it.remaining_ememory() >= can_hold_ememory;
};

item_location loc = game_menus::inv::titled_filter_menu( filter, get_avatar(),
_( "Choose drive:" ) );
_( "Choose device:" ) );
if( loc ) {
return &*loc;
}
Expand Down Expand Up @@ -1025,20 +1025,22 @@ void computer_session::action_repeater_mod()

void computer_session::action_download_software()
{
if( item *const usb = pick_usb() ) {
mission *miss = mission::find( comp.mission_id );
if( miss == nullptr ) {
debugmsg( _( "Computer couldn't find its mission!" ) );
return;
}
mission *miss = mission::find( comp.mission_id );
if( miss == nullptr ) {
debugmsg( _( "Computer couldn't find its mission!" ) );
return;
}
item software( miss->get_item_id(), calendar::turn_zero );
units::ememory downloaded_size = software.ememory_size();

if( item *const estorage = pick_estorage( downloaded_size ) ) {
get_player_character().mod_moves( -to_moves<int>( 1_seconds ) * 0.3 );
item software( miss->get_item_id(), calendar::turn_zero );
software.mission_id = comp.mission_id;
usb->clear_items();
usb->put_in( software, pocket_type::SOFTWARE );
print_line( _( "Software downloaded." ) );
estorage->put_in( software, pocket_type::E_FILE_STORAGE );
print_line( string_format( _( "%s downloaded." ), software.tname() ) );
} else {
print_error( _( "USB drive required!" ) );
print_error( string_format( _( "Electronic storage device with %s free required!" ),
units::display( downloaded_size ) ) );
}
query_any();
}
Expand Down Expand Up @@ -1074,14 +1076,16 @@ void computer_session::action_blood_anal()
print_line( _( "Result: Unknown blood type. Unknown pathogen found." ) );
}
print_line( _( "Pathogen bonded to erythrocytes and leukocytes." ) );
item software( itype_software_blood_data, calendar::turn_zero );
units::ememory downloaded_size = software.ememory_size();
if( query_bool( _( "Download data?" ) ) ) {
if( item *const usb = pick_usb() ) {
if( item *const estorage = pick_estorage( downloaded_size ) ) {
item software( itype_software_blood_data, calendar::turn_zero );
usb->clear_items();
usb->put_in( software, pocket_type::SOFTWARE );
print_line( _( "Software downloaded." ) );
estorage->put_in( software, pocket_type::E_FILE_STORAGE );
print_line( string_format( _( "%s downloaded." ), software.tname() ) );
} else {
print_error( _( "USB drive required!" ) );
print_error( string_format( _( "Electronic storage device with %s free required!" ),
units::display( downloaded_size ) ) );
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ bool Character::consume_software_container( const itype_id &software_id )
if( !it.get_item() ) {
continue;
}
if( it.get_item()->is_software_storage() ) {
if( it.get_item()->is_estorage() ) {
for( const item *soft : it.get_item()->softwares() ) {
if( soft->typeId() == software_id ) {
it.remove_item();
Expand Down
4 changes: 2 additions & 2 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ class ereader_inventory_preset : public pickup_inventory_preset
}

bool is_shown( const item_location &loc ) const override {
return loc->is_ebook_storage();
return loc->is_estorage();
}

std::string get_denial( const item_location &loc ) const override {
Expand Down Expand Up @@ -1463,7 +1463,7 @@ class read_inventory_preset: public pickup_inventory_preset
const item_location p_loc = loc.parent_item();

return ( loc->is_book() || loc->type->can_use( "learn_spell" ) ) &&
( p_loc.where() == item_location::type::invalid || !p_loc->is_ebook_storage() ||
( p_loc.where() == item_location::type::invalid || !p_loc->is_estorage() ||
!p_loc->uses_energy() ||
p_loc->energy_remaining( p_loc.carrier(), false ) >= 1_kJ );
}
Expand Down
2 changes: 1 addition & 1 deletion src/inventory_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ void inventory_selector::add_contained_gunmods( Character &you, item &gun )

void inventory_selector::add_contained_ebooks( item_location &container )
{
if( !container->is_ebook_storage() ) {
if( !container->is_estorage() ) {
return;
}

Expand Down
38 changes: 10 additions & 28 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ static const item_category_id item_category_container( "container" );
static const item_category_id item_category_drugs( "drugs" );
static const item_category_id item_category_food( "food" );
static const item_category_id item_category_maps( "maps" );
static const item_category_id item_category_software( "software" );
static const item_category_id item_category_spare_parts( "spare_parts" );
static const item_category_id item_category_tools( "tools" );
static const item_category_id item_category_weapons( "weapons" );
Expand Down Expand Up @@ -1290,10 +1291,6 @@ item item::in_container( const itype_id &cont, int qty, bool sealed,
}
container.add_automatic_whitelist();
return container;
} else if( is_software() && container.is_software_storage() ) {
container.put_in( *this, pocket_type::SOFTWARE );
container.invlet = invlet;
return container;
}
return *this;
}
Expand Down Expand Up @@ -4995,7 +4992,7 @@ void item::tool_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
}

// Display e-ink tablet ebook recipes
if( is_ebook_storage() && !is_broken_on_active() ) {
if( is_estorage() && !is_broken_on_active() ) {
std::vector<std::string> known_recipe_list;
std::vector<std::string> learnable_recipe_list;
std::vector<std::string> unlearnable_recipe_list;
Expand Down Expand Up @@ -8829,24 +8826,6 @@ bool item::is_cash_card() const
return typeId() == itype_cash_card;
}

bool item::is_software() const
{
if( const std::optional<itype_id> &cont = type->default_container ) {
return item( *cont ).is_software_storage();
}
return false;
}

bool item::is_software_storage() const
{
return contents.has_pocket_type( pocket_type::SOFTWARE );
}

bool item::is_ebook_storage() const
{
return contents.has_pocket_type( pocket_type::EBOOK );
}

bool item::is_estorage() const
{
return contents.has_pocket_type( pocket_type::E_FILE_STORAGE );
Expand Down Expand Up @@ -8991,6 +8970,11 @@ int item::total_photos() const
return extended_photos.size();
}

bool item::is_software() const
{
return type->category_force == item_category_software;
}

bool item::is_maybe_melee_weapon() const
{
item_category_id my_cat_id = get_category_shallow().id;
Expand Down Expand Up @@ -10743,7 +10727,7 @@ book_proficiency_bonuses item::get_book_proficiency_bonuses() const
{
book_proficiency_bonuses ret;

if( is_ebook_storage() ) {
if( is_estorage() ) {
for( const item *book : ebooks() ) {
ret += book->get_book_proficiency_bonuses();
}
Expand Down Expand Up @@ -15719,8 +15703,7 @@ item const *item::this_or_single_content() const
bool item::contents_only_one_type() const
{
std::list<const item *> const items = contents.all_items_top( []( item_pocket const & pkt ) {
return pkt.is_type( pocket_type::CONTAINER ) ||
pkt.is_type( pocket_type::SOFTWARE );
return pkt.is_type( pocket_type::CONTAINER );
} );
return items.size() == 1 ||
( items.size() > 1 &&
Expand Down Expand Up @@ -15766,8 +15749,7 @@ item::aggregate_t item::aggregated_contents( int depth, int maxdepth ) const
aggregate_t *running_max{};
aggregate_t *max_type{};
auto const cont_and_soft = []( item_pocket const & pkt ) {
return pkt.is_type( pocket_type::CONTAINER ) || pkt.is_type( pocket_type::SOFTWARE ) ||
pkt.is_type( pocket_type::E_FILE_STORAGE );
return pkt.is_type( pocket_type::CONTAINER ) || pkt.is_type( pocket_type::E_FILE_STORAGE );
};


Expand Down
5 changes: 2 additions & 3 deletions src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,7 @@ class item : public visitable
public:

bool is_cash_card() const;
bool is_software() const;
bool is_software_storage() const;

bool is_ebook_storage() const;
bool is_estorage() const;
bool is_estorable() const;
bool is_browsed() const;
Expand All @@ -388,6 +385,8 @@ class item : public visitable
const item *get_photo_gallery() const;
/** @return total number of photos this item holds */
int total_photos() const;
/** @return does this item have category `software`?*/
bool is_software() const;

/**
* Checks whether the item's components (and sub-components if deep_search) are food items
Expand Down
Loading

0 comments on commit 3cddba6

Please sign in to comment.