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

Make creature's "moves" a protected variable #72258

Merged
merged 5 commits into from
Mar 20, 2024

Conversation

RenechCDDA
Copy link
Member

@RenechCDDA RenechCDDA commented Mar 9, 2024

Summary

None

Purpose of change

Magic numbers bad

Accessing a creature's moves directly, also bad

Describe the solution

Replaced some instances of other arbitrary valuations with calculations for fractions of get_speed() that matched the previous numbers, assuming speed == 100

Actions which were related to the character performing a task use get_speed() to calculate their new time. Actions which were related to things happening (e.g. interacting with a computer) calculate their new move cost in seconds. For creatures with speed of == 100 (and indeed, most of these are just hardcoded player actions) there is no functional change.

Describe alternatives you've considered

Testing

Compiles 👍

Reviewers are advised to scrutinize the monster files in particular... my best effort was made to make sense of what was going on in there but I annotated at least two places where functionality has changed. Previous behavior of modifying monster moves' by flat value assumed to be a bug.

Additional context

@github-actions github-actions bot added NPC / Factions NPCs, AI, Speech, Factions, Ownership Vehicles Vehicles, parts, mechanics & interactions [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Mar 9, 2024
@mqrause
Copy link
Contributor

mqrause commented Mar 9, 2024

Still plenty of unguarded access to creatures' moves.

I'd recommend making the member protected and then fixing all the errors at once.

@RenechCDDA
Copy link
Member Author

Still plenty of unguarded access to creatures' moves.

I'd recommend making the member protected and then fixing all the errors at once.

What, and make more work for myself? Fine, fine. Reason wins again.

@RenechCDDA RenechCDDA marked this pull request as draft March 9, 2024 02:14
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Mar 9, 2024
@github-actions github-actions bot added the Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. label Mar 9, 2024
@RenechCDDA RenechCDDA marked this pull request as ready for review March 9, 2024 21:03
@github-actions github-actions bot added Info / User Interface Game - player communication, menus, etc. Mechanics: Enchantments / Spells Enchantments and spells Items: Armor / Clothing Armor and clothing labels Mar 9, 2024
@RenechCDDA RenechCDDA changed the title Sanitize more magic numbers, guard more access to creature moves Make creature's "moves" a protected variable Mar 9, 2024
@github-actions github-actions bot requested review from dseguin and KorGgenT March 9, 2024 21:03
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-requesting reviews from non-collaborators: @wapcaplet

@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Mar 9, 2024
@github-actions github-actions bot added Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Code: Tests Measurement, self-control, statistics, balancing. Monsters Monsters both friendly and unfriendly. Items: Containers Things that hold other things BasicBuildPassed This PR builds correctly, label assigned by github actions labels Mar 9, 2024
Copy link
Contributor

@Fris0uman Fris0uman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few notes on some potential errors of conversion

src/computer_session.cpp Outdated Show resolved Hide resolved
src/iexamine.cpp Outdated Show resolved Hide resolved
src/iuse.cpp Outdated Show resolved Hide resolved
src/iuse_actor.cpp Outdated Show resolved Hide resolved
src/map_field.cpp Show resolved Hide resolved
src/monmove.cpp Outdated Show resolved Hide resolved
src/monmove.cpp Outdated Show resolved Hide resolved
src/monmove.cpp Outdated Show resolved Hide resolved
src/npcmove.cpp Show resolved Hide resolved
src/npcmove.cpp Show resolved Hide resolved
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Mar 19, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Mar 19, 2024
@kevingranade kevingranade merged commit b1857d6 into CleverRaven:master Mar 20, 2024
23 of 26 checks passed
@RenechCDDA RenechCDDA deleted the magic_BAD branch March 20, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Info / User Interface Game - player communication, menus, etc. Items: Armor / Clothing Armor and clothing Items: Containers Things that hold other things json-styled JSON lint passed, label assigned by github actions Mechanics: Enchantments / Spells Enchantments and spells Monsters Monsters both friendly and unfriendly. NPC / Factions NPCs, AI, Speech, Factions, Ownership Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants