Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor battery usage #48608

Merged
merged 87 commits into from
Jul 20, 2021
Merged
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
d89a3c9
convert electrick jackhammer
Hirmuolio Apr 19, 2021
b94fa40
item pwr drain refactor
Hirmuolio Apr 19, 2021
d78c3c4
jackhammering works
Hirmuolio Apr 19, 2021
ae7263d
ammo req
Hirmuolio Apr 19, 2021
5491d15
has_enough_electr
Hirmuolio Apr 19, 2021
c409944
maybe works now
Hirmuolio Apr 19, 2021
0992ef8
it compiles
Hirmuolio Apr 20, 2021
b79085d
use has_enough_electr
Hirmuolio Apr 20, 2021
c92187b
lint
Hirmuolio Apr 20, 2021
3dc28fd
UPS ammo does not exist anymore
Hirmuolio Apr 20, 2021
29a275e
use new method in places
Hirmuolio Apr 20, 2021
2dab75a
use new method in ranged
Hirmuolio Apr 20, 2021
822a4c4
ups in generic_game_turn_handler
Hirmuolio Apr 20, 2021
d7ece5a
new methods in more places
Hirmuolio Apr 20, 2021
448ca88
why is tis 2x I do not know
Hirmuolio Apr 20, 2021
39cb825
fix comparison
Hirmuolio Apr 20, 2021
af501ee
use new method
Hirmuolio Apr 20, 2021
360f6dd
astyle
Hirmuolio Apr 20, 2021
d92544c
fix item process
Hirmuolio Apr 20, 2021
313f58c
probably safe
Hirmuolio Apr 20, 2021
aa7572f
astyle
Hirmuolio Apr 20, 2021
6ffa402
cleanup
Hirmuolio Apr 20, 2021
a300df9
unused line
Hirmuolio Apr 20, 2021
1a01e10
reqrite
Hirmuolio Apr 20, 2021
52ba316
astyle
Hirmuolio Apr 20, 2021
6d2b4ac
ammo_consume(
Hirmuolio Apr 20, 2021
34e0065
astyle
Hirmuolio Apr 20, 2021
b99d6d2
ammo_remaining(
Hirmuolio Apr 20, 2021
58a2a9b
fix ups weapon
Hirmuolio Apr 20, 2021
e0e5086
unused variables
Hirmuolio Apr 21, 2021
0cd8c18
fix grenade
Hirmuolio Apr 21, 2021
f965076
wrong statement
Hirmuolio Apr 21, 2021
0d04c09
random fixes
Hirmuolio Apr 21, 2021
2183686
fix ammo count
Hirmuolio Apr 21, 2021
60b66bf
misc adjustments
Hirmuolio Apr 21, 2021
70d042c
fix grenade (again)
Hirmuolio Apr 21, 2021
0faffab
Use Character
Hirmuolio Apr 21, 2021
499b168
electr firestarter
Hirmuolio Apr 21, 2021
11fd91a
electr firestarter
Hirmuolio Apr 21, 2021
5d41aaf
astyle
Hirmuolio Apr 21, 2021
d855061
revert jackhammer
Hirmuolio Apr 22, 2021
a186738
seems like dead code
Hirmuolio Apr 22, 2021
f0be867
not used anymore
Hirmuolio Apr 22, 2021
45dae0f
unused ups code
Hirmuolio Apr 22, 2021
e0f0dc1
simplify check
Hirmuolio Apr 22, 2021
9a58010
small miss
Hirmuolio Apr 22, 2021
d5534f8
fix crafting with ups
Hirmuolio Apr 22, 2021
75ea210
crafting ups use
Hirmuolio Apr 22, 2021
b03ae52
cleaner
Hirmuolio Apr 22, 2021
815bef1
minimal improvements
Hirmuolio Apr 22, 2021
e8938d6
code that shouldn't run gives debug msg if it is spotted
Hirmuolio Apr 22, 2021
752accf
minor comment
Hirmuolio Apr 23, 2021
a32d59b
these parts are still used
Hirmuolio Apr 23, 2021
c9d7e75
duplicate check
Hirmuolio Apr 23, 2021
65a4334
available_ups()
Hirmuolio Apr 25, 2021
7119ffd
consume_ups faster
Hirmuolio Apr 25, 2021
95d3fb5
just call available_ups
Hirmuolio Apr 25, 2021
3ebbbbe
prevent overdrain
Hirmuolio May 1, 2021
70de4d2
large UPS rewrites
Hirmuolio May 3, 2021
65a6dbd
fix things
Hirmuolio May 3, 2021
b83b005
ups map drain
Hirmuolio May 3, 2021
d073d22
cleaner
Hirmuolio May 3, 2021
f1a1bf9
astyle
Hirmuolio May 3, 2021
8ac075b
unnecessary const
Hirmuolio May 3, 2021
1500c7d
fix bionic power for crafting tools
Hirmuolio May 3, 2021
4659148
ups from map and inventory
Hirmuolio May 6, 2021
c1498af
don't run this twice
Hirmuolio May 6, 2021
a45817a
mandatory carrier for ammo_sufficient
Hirmuolio May 7, 2021
d3fb832
unnecessary double check
Hirmuolio May 7, 2021
eb49809
obsolete adv ups
Hirmuolio May 14, 2021
38721c4
ups bionic for crafting
Hirmuolio Jun 19, 2021
d18daef
return pure ups power only
Hirmuolio Jun 19, 2021
c8cfbd4
removed comment
Hirmuolio Jun 19, 2021
3f00f7f
unnecessary is_tool check
Hirmuolio Jun 30, 2021
6a3e3cb
improved charges_of_internal
Hirmuolio Jun 30, 2021
47fb870
force-push improvements
Hirmuolio Jul 4, 2021
5d7fa38
astyle
Hirmuolio Jul 4, 2021
8c15666
fix starting repair
Hirmuolio Jul 7, 2021
1185428
fix repair bionic consumption
Hirmuolio Jul 7, 2021
1bb36f0
rebase fixes
Hirmuolio Jul 12, 2021
42ce4c1
unused itype_toolset
Hirmuolio Jul 12, 2021
14a87cd
aftershock migration
Hirmuolio Jul 12, 2021
60ffaf5
info in json
Hirmuolio Jul 12, 2021
bf0ebce
astyle
Hirmuolio Jul 12, 2021
c0f9a4b
unused variable
Hirmuolio Jul 13, 2021
cc0bdb2
adv ups not more efficient
Hirmuolio Jul 14, 2021
cc25bc5
remove Character::has_enough_charges
Hirmuolio Jul 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
code that shouldn't run gives debug msg if it is spotted
  • Loading branch information
Hirmuolio committed Jul 14, 2021
commit e8938d642021b0030ded9f391b8a2600f0be7691
6 changes: 5 additions & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
@@ -1179,6 +1179,7 @@ void player::process_items()

// Load all items that use the UPS to their minimal functional charge,
// The tool is not really useful if its charges are below charges_to_use
int ups_used = 0;
const auto inv_use_ups = items_with( []( const item & itm ) {
return itm.has_flag( flag_USE_UPS );
} );
@@ -1192,10 +1193,13 @@ void player::process_items()
it->deactivate();
} else if( available_ups() > 0 &&
it->ammo_remaining() < it->ammo_capacity( ammotype( "battery" ) ) ) {
consume_ups( 1 );
ups_used++;
it->ammo_set( itype_battery, it->ammo_remaining() + 1 );
}
}
if( ups_used > 0 ) {
consume_ups( ups_used );
}
}

bool player::add_faction_warning( const faction_id &id )
2 changes: 2 additions & 0 deletions src/visitable.cpp
Original file line number Diff line number Diff line change
@@ -797,6 +797,7 @@ int inventory::charges_of( const itype_id &what, int limit,
{
if( what == itype_UPS ) {
// Nothing should come here. But until all the charges_of and charges_of_internal no longer use itype_UPS I don't feel safe removing this
debugmsg( _( "Please report how your UPS led you to inventory::charges_of" ) );
int qty = 0;
qty = sum_no_wrap( qty, charges_of( itype_UPS_off ) );
qty = sum_no_wrap( qty, static_cast<int>( charges_of( itype_adv_UPS_off ) / 0.6 ) );
@@ -834,6 +835,7 @@ int Character::charges_of( const itype_id &what, int limit,

if( what == itype_UPS ) {
// Nothing should come here. But until all the charges_of and charges_of_internal no longer use itype_UPS I don't feel safe removing this
debugmsg( _( "Please report how your UPS led you to Character::charges_of" ) );
int qty = 0;
qty = sum_no_wrap( qty, charges_of( itype_UPS_off ) );
qty = sum_no_wrap( qty, static_cast<int>( charges_of( itype_adv_UPS_off ) / 0.6 ) );