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

Unlimited map memory #47253

Merged
merged 26 commits into from
Jul 9, 2021
Merged

Conversation

kevingranade
Copy link
Member

@kevingranade kevingranade commented Feb 5, 2021

Summary

Features "Make map memory unlimited"

Purpose of change

The current map memory feature utilizes a lru cache to globally store the most recently seen X tiles or symbols of map data. While helpful, this is considered by many to be very limiting.
Closes #49696

Describe the solution

Changes backported from BrightNights PRs cataclysmbnteam/Cataclysm-BN#247 cataclysmbnteam/Cataclysm-BN#252 and cataclysmbnteam/Cataclysm-BN#310

Perform streaming serialization/deserialization of map memory to disk just like with map data so that the amount of memorised map is essentially unlimited.

Testing

Navigate around world, visually checking consistency of map memory.

@KorGgenT KorGgenT added Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Mechanics: Map Memory Performance issues, weird behavior, improvements to map memory feature labels Feb 5, 2021
@ToxiClay
Copy link
Contributor

ToxiClay commented Feb 5, 2021

Obsoletes #47079. Thanks so much!

@kevingranade
Copy link
Member Author

Not totally obsoleted, this doesn't actually touch the traits that try to manipulate map memory capacity, but it does remove the code that makes them do anything.

@ToxiClay
Copy link
Contributor

ToxiClay commented Feb 5, 2021

True. I'll just pull those changes into a separate PR.

@kevingranade kevingranade force-pushed the unlimited-map-memory branch 2 times, most recently from e7616f6 to 50f1746 Compare February 6, 2021 00:34
Copy link
Contributor

@jbytheway jbytheway left a comment

Choose a reason for hiding this comment

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

Are you planning to merge this before release? It seems like a pretty big feature.

src/game_constants.h Outdated Show resolved Hide resolved
Comment on lines +68 to +71
half_open_rectangle<point> r1( point( 0, 0 ), point( 2,
2 ) ); // NOLINT(cata-use-named-point-constants)
half_open_rectangle<point> r2( point( 2, 2 ), point( 3, 3 ) );
half_open_rectangle<point> r3( point( 0, 0 ), point( 2,
1 ) ); // NOLINT(cata-use-named-point-constants)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like these are cases where you could happily use point_zero. But if you really don't want to, then I think these NOLINT comments won't work when on the next line like this (maybe they do; looks like the error hasn't occurred yet).

@lgtm-com
Copy link

lgtm-com bot commented Feb 6, 2021

This pull request introduces 1 alert when merging 50f1746 into b4ab3df - view on LGTM.com

new alerts:

  • 1 for Multiplication result converted to larger type

@kevingranade kevingranade marked this pull request as draft February 6, 2021 07:02
@kevingranade
Copy link
Member Author

Yea as sad as it is not to put this in right away, it needs to wait for release.

@lgtm-com
Copy link

lgtm-com bot commented Feb 6, 2021

This pull request introduces 1 alert when merging 5c936e6 into 0c1ca59 - view on LGTM.com

new alerts:

  • 1 for Multiplication result converted to larger type

src/map_memory.cpp Outdated Show resolved Hide resolved
@kevingranade kevingranade force-pushed the unlimited-map-memory branch from 5c936e6 to 2bf8f19 Compare July 8, 2021 21:19
@kevingranade kevingranade force-pushed the unlimited-map-memory branch from 2bf8f19 to d08b44d Compare July 8, 2021 21:29
@kevingranade kevingranade force-pushed the unlimited-map-memory branch from d08b44d to 89a1240 Compare July 8, 2021 21:46
@kevingranade
Copy link
Member Author

Rebased and hypothetically ready to go!

@kevingranade kevingranade marked this pull request as ready for review July 8, 2021 21:46
@I-am-Erk
Copy link
Member

I-am-Erk commented Jul 9, 2021

So, in the spirit of cavalierly merging things I don't understand and that could possibly entirely break the game, since we're just a few days into a new experimental, let's see if this weird "Calvin Grenade" character actually does test things.

@I-am-Erk I-am-Erk merged commit 789c7a4 into CleverRaven:master Jul 9, 2021
@kevingranade kevingranade deleted the unlimited-map-memory branch July 9, 2021 07:31
@eltank eltank mentioned this pull request Jul 11, 2021
11 tasks
anothersimulacrum added a commit to anothersimulacrum/Cataclysm-DDA that referenced this pull request Jul 27, 2021
anothersimulacrum added a commit to anothersimulacrum/Cataclysm-DDA that referenced this pull request Jul 27, 2021
eltank pushed a commit to eltank/Cataclysm-DDA that referenced this pull request Sep 3, 2021
* Encapsulate map::drawsq() arguments and clarify their meaning

* Split map memory into submap-sized chunks

Note: this naive implementation significantly lowers FPS

* Optimize map memory access

Move memorized submaps that would be
affected during drawing into a 2d array.

* Save/load memorized submaps; migrate old mm file

* Remove leftovers from map memory limit

* Some map memory cleanup

* Don't save empty mm submaps

* Deallocate far-away mm submaps on save; report save failure

* Rework tests for map memory

* Don't re-allocate region if old region contains required submaps

* Remove map_memory.h from avatar.h

* Rename memorized_submap -> mm_submap

* Rename mm_submap::clean -> mm_submap::empty, add comments.

* Improve drawsq_params interface

* Remove map_memory.h from lru_cache.cpp

* Add function for rectangle overlapping

* Save mm_submaps in regions

* Fix save/load not using avatar's global pos, improve docs.

* When saving, compress mm_submaps using RLE

* Simplify map rendering in ascii mode

Collect map::draw code in one place, simplify indexing/bound checks.
Remove the "batch drawing" optimization: it doesn't help with drawing, but harms code clarity. Instead, convert all relevant draw methods to use 'wputch' and rely on caller to position the cursor properly.

* Memorize off-screen tiles in ascii mode

* Fix copypasted code

* Fix tile memory saving code, minor cleanup.

* Add debug logging for tile memory operations

* Fix broken saving for tile memory submaps with z != 0

* Lazy allocation for tile memory submaps

Co-authored-by: olanti-p <olanti-p@yandex.ru>
esotericist pushed a commit to esotericist/Cataclysm-DDA that referenced this pull request Sep 4, 2021
* Encapsulate map::drawsq() arguments and clarify their meaning

* Split map memory into submap-sized chunks

Note: this naive implementation significantly lowers FPS

* Optimize map memory access

Move memorized submaps that would be
affected during drawing into a 2d array.

* Save/load memorized submaps; migrate old mm file

* Remove leftovers from map memory limit

* Some map memory cleanup

* Don't save empty mm submaps

* Deallocate far-away mm submaps on save; report save failure

* Rework tests for map memory

* Don't re-allocate region if old region contains required submaps

* Remove map_memory.h from avatar.h

* Rename memorized_submap -> mm_submap

* Rename mm_submap::clean -> mm_submap::empty, add comments.

* Improve drawsq_params interface

* Remove map_memory.h from lru_cache.cpp

* Add function for rectangle overlapping

* Save mm_submaps in regions

* Fix save/load not using avatar's global pos, improve docs.

* When saving, compress mm_submaps using RLE

* Simplify map rendering in ascii mode

Collect map::draw code in one place, simplify indexing/bound checks.
Remove the "batch drawing" optimization: it doesn't help with drawing, but harms code clarity. Instead, convert all relevant draw methods to use 'wputch' and rely on caller to position the cursor properly.

* Memorize off-screen tiles in ascii mode

* Fix copypasted code

* Fix tile memory saving code, minor cleanup.

* Add debug logging for tile memory operations

* Fix broken saving for tile memory submaps with z != 0

* Lazy allocation for tile memory submaps

Co-authored-by: olanti-p <olanti-p@yandex.ru>
BrettDong added a commit that referenced this pull request Nov 26, 2021
ZhilkinSerg pushed a commit that referenced this pull request Nov 27, 2021
@Brambor Brambor mentioned this pull request Mar 30, 2024
28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Mechanics: Map Memory Performance issues, weird behavior, improvements to map memory feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Good Memory" and "Forgetful" traits are crippled by an optionality of Skill Rust
7 participants