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 int_id::operator int explicit #37387

Merged
merged 1 commit into from
Jan 28, 2020

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Jan 25, 2020

Summary

SUMMARY: None

Purpose of change

Make int_id::operator int explicit for better type safety

Testing

It compiles.

Additional context

This also revealed a bug in mapgen where terrain ids were used as randomization range, perhaps a relic from before the JSON era. Since int ids now depend on the loading order of JSON files, it could cause weird terrain tiles to be generated. Fixed by randomizing from a list of actually intended terrain ids.

@@ -222,7 +222,7 @@ void editmap_hilight::draw( editmap &em, bool update )
char t_sym = terrain.symbol();
nc_color t_col = terrain.color();

if( g->m.furn( p ) > 0 ) {
if( g->m.furn( p ).to_i() > 0 ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We really need a is_null function in int_id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fully agree, but that should perhaps come in a separate PR.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels Jan 28, 2020
@ZhilkinSerg ZhilkinSerg merged commit 8393b66 into CleverRaven:master Jan 28, 2020
@Qrox Qrox deleted the explicit-int-id branch January 30, 2020 02:08
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` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants