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

Allow changing player name #51142

Merged
merged 4 commits into from
Aug 29, 2021
Merged

Conversation

Saicchi
Copy link
Contributor

@Saicchi Saicchi commented Aug 28, 2021

Summary

Features "Change name in game"

Purpose of change

Add an option to change the player at any time in game.
This is different from the debug menu command in that it only changes the display name, while the debug command changes the save file name.

Describe the solution

Add a new variable play_name which is the display name.
Change Character::get_name() to return that variable instead, or the regular name if play_name is empty.
Change all direct references of name to get_name(). Note that save files, activitives and zones are still directly calling name.

play_name is the name you introduce yourself to NPCs and new people you meet.
name is your save file name and Pre-Cataclysm name, the one registered in the police database and linked to your credit card in a bank.

Describe alternatives you've considered

Split name into name for save file and pre_cata_name for pre-cataclysm name.

Testing

  • Saving / loading game
  • Multi activities
  • Zones
  • Factions ( Simple Test )

Additional context

Places where name was used that were not changed:

File Line Character Type
src/activity_handlers.cpp 1016 54 MULTI_ACTIVITY
src/activity_handlers.cpp 1035 54 MULTI_ACTIVITY
src/activity_handlers.cpp 1076 59 MULTI_ACTIVITY
src/activity_handlers.cpp 1805 48 MULTI_ACTIVITY
src/activity_handlers.cpp 2836 48 MULTI_ACTIVITY
src/activity_handlers.cpp 3590 39 MULTI_ACTIVITY
src/activity_handlers.cpp 3595 43 MULTI_ACTIVITY
src/activity_handlers.cpp 3600 43 MULTI_ACTIVITY
src/activity_handlers.cpp 3666 48 MULTI_ACTIVITY
src/activity_item_handling.cpp 1682 85 MULTI_ACTIVITY
src/activity_item_handling.cpp 1766 53 MULTI_ACTIVITY
src/activity_item_handling.cpp 1806 47 MULTI_ACTIVITY
src/activity_item_handling.cpp 2268 109 MULTI_ACTIVITY
src/activity_item_handling.cpp 706 45 MULTI_ACTIVITY
src/auto_pickup.cpp 102 31 MULTI_ACTIVITY
src/auto_pickup.cpp 188 86 MULTI_ACTIVITY
src/auto_pickup.cpp 388 86 MULTI_ACTIVITY
src/auto_pickup.cpp 417 27 MULTI_ACTIVITY
src/auto_pickup.cpp 429 27 MULTI_ACTIVITY
src/cata_tiles.cpp 2128 47 SAVE/LOAD
src/character.cpp 497 5 SAVE/LOAD
src/debug_menu.cpp 1438 88 SAVE/LOAD
src/debug_menu.cpp 1445 52 SAVE/LOAD
src/debug_menu.cpp 1452 29 SAVE/LOAD
src/debug_menu.cpp 2233 33 FACTIONS
src/debug_menu.cpp 2235 84 FACTIONS
src/do_turn.cpp 273 37 SAVE/LOAD
src/game.cpp 11113 24 FACTIONS
src/game.cpp 11115 72 FACTIONS
src/game.cpp 11359 64 SAVE/LOAD
src/game.cpp 11368 47 SAVE/LOAD
src/game.cpp 11371 54 SAVE/LOAD
src/game.cpp 11538 92 SAVE/LOAD
src/game.cpp 2280 57 SAVE/LOAD
src/game.cpp 2356 7 SAVE/LOAD
src/game.cpp 2630 82 SAVE/LOAD
src/game.cpp 2679 31 SAVE/LOAD
src/game.cpp 2689 45 SAVE/LOAD
src/game.cpp 2689 67 SAVE/LOAD
src/game.cpp 2695 49 SAVE/LOAD
src/game.cpp 854 64 ACHIEVEMENTS
src/gamemode_tutorial.cpp 127 22 CHARACTER CREATION
src/iexamine.cpp 2332 48 MULTI_ACTIVITY
src/iuse.cpp 7310 41 ?
src/iuse.cpp 7312 40 ?
src/main_menu.cpp 1236 74 SAVE/LOAD
src/main_menu.cpp 967 65 SAVE/LOAD
src/memorial_logger.cpp 428 49 SAVE/LOAD
src/monattack.cpp 285 9 ?
src/newcharacter.cpp 282 9 CHARACTER_CREATION
src/newcharacter.cpp 284 9 CHARACTER_CREATION
src/newcharacter.cpp 3354 13 CHARACTER_CREATION
src/newcharacter.cpp 3356 13 CHARACTER_CREATION
src/newcharacter.cpp 339 9 CHARACTER_CREATION
src/newcharacter.cpp 3611 24 CHARACTER_CREATION
src/newcharacter.cpp 3614 70 CHARACTER_CREATION
src/newcharacter.cpp 3739 21 CHARACTER_CREATION
src/newcharacter.cpp 3874 39 CHARACTER_CREATION
src/newcharacter.cpp 3880 39 CHARACTER_CREATION
src/newcharacter.cpp 3908 32 CHARACTER_CREATION
src/newcharacter.cpp 3910 25 CHARACTER_CREATION
src/newcharacter.cpp 3911 43 CHARACTER_CREATION
src/newcharacter.cpp 4221 13 CHARACTER_CREATION
src/newcharacter.cpp 615 29 CHARACTER_CREATION
src/newcharacter.cpp 668 42 CHARACTER_CREATION
src/npc.cpp 173 11 CHARACTER_CREATION
src/npc.cpp 213 9 CHARACTER_CREATION
src/npc.cpp 345 5 CHARACTER_CREATION
src/npc.cpp 351 9 CHARACTER_CREATION
src/npctalk_funcs.cpp 1059 39 MULTI_ACTIVITY
src/npctalk_funcs.cpp 810 21 FACTIONS
src/npctalk_funcs.cpp 810 21 FACTIONS
src/npctalk_funcs.cpp 810 21 FACTIONS
src/npctalk_funcs.cpp 813 72 FACTIONS
src/npctalk_funcs.cpp 813 72 FACTIONS
src/npctalk_funcs.cpp 813 72 FACTIONS
src/safemode_ui.cpp 206 54 CHARACTER_CREATION
src/safemode_ui.cpp 276 61 CHARACTER_CREATION
src/safemode_ui.cpp 276 61 CHARACTER_CREATION
src/safemode_ui.cpp 331 58 CHARACTER_CREATION
src/safemode_ui.cpp 331 58 CHARACTER_CREATION
src/safemode_ui.cpp 490 35 CHARACTER_CREATION
src/safemode_ui.cpp 490 35 CHARACTER_CREATION
src/safemode_ui.cpp 513 26 CHARACTER_CREATION
src/safemode_ui.cpp 513 26 CHARACTER_CREATION
src/savegame_json.cpp 1761 24 SAVE/LOAD
src/savegame_json.cpp 1976 26 SAVE/LOAD
src/turret.cpp 529 9 CHARACTER_CREATION
src/veh_interact.cpp 3430 53 ?

I tested it by changing the name variable to another name and making a list of where it complained about a missing variable.

@Saicchi Saicchi requested a review from KorGgenT as a code owner August 28, 2021 01:57
src/character.cpp Outdated Show resolved Hide resolved
@actual-nh actual-nh added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. labels Aug 28, 2021
@dseguin
Copy link
Member

dseguin commented Aug 28, 2021

I tried this out and it works:
menu1

menu2

result

Nice work!

@kevingranade kevingranade merged commit 1eea751 into CleverRaven:master Aug 29, 2021
Venera3 pushed a commit to Venera3/Cataclysm-DDA that referenced this pull request Sep 21, 2021
* play_name variable and getter

* menu to change name and gender
only allow changing gender and name of npc if debug

* change usable of name into get_name() when possible

* play_name into cata::optional

Co-authored-by: Saicchi <Saicchi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Info / User Interface Game - player communication, menus, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants