-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[WIP] Jsonize Move Modes #38299
[WIP] Jsonize Move Modes #38299
Conversation
Fix cycle_move_mode
Remove ability to exclude stances from cycle movement mode
Minor cleanup
MM_RUN, | ||
MM_CROUCH; | ||
|
||
void move_modes::set_move_mode_ids() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, we don't really want this. The whole point of generic_factory is that you don't define all of them in C++. if you need to use them elsewhere you can define them there.
move_mode_str_id id; | ||
bool was_loaded = false; | ||
|
||
public: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suggest you make every single one of these private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these members instead be accessed through functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, absolutely. set_ and get_ and maybe functions with context names. was_loaded is an exception, it needs to be public because of generic_factory. i can't recall off hand if id is the same
@@ -46,6 +46,7 @@ MAKE_NULL_ID2( trap, "tr_null" ) | |||
MAKE_NULL_ID2( construction_category, "NULL", -1 ) | |||
MAKE_NULL_ID2( ammo_effect, "AE_NULL", 0 ) | |||
MAKE_NULL_ID2( field_type, "fd_null", 0 ) | |||
MAKE_NULL_ID2( move_mode, "MM_NULL", 0 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we really use null ids anymore? i've made several generic_factory things and have never needed to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, null ids are terrible. If you need a variable that can contain either an id or nothing, wrap the id into std::optional
.
With null ids, you never know where a null id is allowed / supported / will trigger some special behaviour.
So a couple things with the generic factory here: there's not a need to use int_id here, which means you can also change move_mode_str_id to just move_mode_id. additionally, There isn't a need for the NULL move mode as you're just checking it in code as if you'd check an empty string, which string_id can do anyway. |
"display_colour": "light_gray", | ||
"display_character": "W", | ||
"minimum_required_legs": 0, | ||
"flavor_text": "You start walking.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translatable strings in JSON require separate code in "lang/extract_json_strings.py" to extract them for translation.
move_mode new_mode = mode.obj(); | ||
|
||
if( new_mode.minimum_required_legs > get_working_leg_count() ) { | ||
add_msg( m_bad, string_format( _( "You do not have enough functioning legs to %s." ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_msg
already does formatting, you should not do it yourself.
Same for more calls to add_msg
below.
mod_stamina( -( ( moves * burn_ratio ) / 100.0 ) * stamina_move_cost_modifier() ); | ||
burn_ratio = burn_ratio * current_move_mode->stamina_burn_multiplier; | ||
|
||
mod_stamina( -( ( moves * burn_ratio ) / 100.0 ) * current_move_mode->stamina_burn_multiplier ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mod_stamina( -( ( moves * burn_ratio ) / 100.0 ) * current_move_mode->stamina_burn_multiplier ); | |
mod_stamina( -moves * burn_ratio / 100.0 * current_move_mode->stamina_burn_multiplier ); |
Co-Authored-By: BevapDin <tho_ki@gmx.de>
Feel free to reopen if you want working on it again. |
Summary
SUMMARY: Features "Move modes converted to json"
Purpose of change
To collate move mode data (such as volume reduction, speed and flavor texts) in a single location rather than have them spread through multiple files
Describe the solution
Have the settings be loaded from a json file, and referenced from a single location where needed
Describe alternatives you've considered
Converting move modes to a collection of structs
Testing
Confirmed the move menu and cycle move mode keybinds continue to work
Confirmed that swimming costs continue to be calculated correctly (needs additional testing, confirmed using debugger rather than ingame effect)
Confirmed that volume is correctly calculated (Possible bug noticed, volume indicator on the right bar indicated 0 volume - debugger showed correct value)
Confirmed move costs are consistent with original values
TODO : Confirm stamina costs for running are consistent with original values, feels higher currently
TODO : Confirm vehicle safe auto follow speed
Additional context
N/A