Skip to content

bugfix(worldbuilder): Draw maps larger than 1024x1024 through the partial terrain window - #3502

Open
tintinhamans wants to merge 3 commits into
TheSuperHackers:mainfrom
tintinhamans:arctic/fix/worldbuilder-large-map-draw
Open

tintinhamans wants to merge 3 commits into
TheSuperHackers:mainfrom
tintinhamans:arctic/fix/worldbuilder-large-map-draw

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 13, 2026 •

Copy link
Copy Markdown

⚠️ Merge after: #3501


WorldBuilder draws the entire map by default, which keeps a vertex buffer and a system memory copy for every 32x32 tile, about 256 bytes per cell. Past roughly 1200x1200 that alone pushes the 32 bit process out of memory.

Maps larger than 1024x1024 now use the partial terrain window, which follows the camera, and the show entire map option is disabled for them. With the terrain no longer scaling with the map, the new map memory warning moves up to 2048x2048.

1300x1300 map, border 30 Private memory
Before 870 MB
After 400 MB

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a8120138-f485-4d1f-9f96-da735fa3cbed
📥 Commits

Reviewing files that changed from the base of the PR and between f8bb8fc and a2b7b04.

📒 Files selected for processing (12)
  • Core/GameEngine/Include/Common/MapReaderWriterInfo.h
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
  • Generals/Code/Tools/WorldBuilder/include/WHeightMapEdit.h
  • Generals/Code/Tools/WorldBuilder/src/NewHeightMap.cpp
  • Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
  • Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
  • Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/include/WHeightMapEdit.h
  • GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Walkthrough

Map-size limits now apply to height-map parsing and World Builder editing. Both World Builder variants also limit full-map terrain rendering by area.

Changes

Map size handling

Layer / File(s) Summary
Validate parsed height-map data
Core/GameEngine/Include/Common/MapReaderWriterInfo.h, Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
The shared limits set a maximum dimension of 8192 and a maximum area of 4096 × 4096 cells. Both height-map parsers reject invalid dimensions, borders, or chunk data sizes before allocating data.
Validate maps during World Builder editing
Generals/Code/Tools/WorldBuilder/include/WHeightMapEdit.h, Generals/Code/Tools/WorldBuilder/src/*, GeneralsMD/Code/Tools/WorldBuilder/include/WHeightMapEdit.h, GeneralsMD/Code/Tools/WorldBuilder/src/*
Both variants add isValidMapSize and apply it to map construction, resizing, new-map dialogs, and document initialization. New-map dialogs prompt for confirmation when the bordered area exceeds 2048 × 2048 cells. Resize paths adjust height-buffer allocation, use array deletion, and zero-initialize cliff and flip state arrays.
Limit entire-map terrain rendering
Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp, GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp
Both variants allow entire-map rendering only when the height-map area is at most 1,048,576 cells. Larger maps use the existing partial-map path. The menu command is disabled for ineligible maps, and its checkmark requires both eligibility and the enabled setting.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: xezon

Merge Risk: ⚪ Minimal · up to a2b7b

Maps larger than 1024x1024 now use the partial terrain window, and invalid map sizes are rejected. I found no remaining merge-blocking risk.

Pre-merge checks: Passed 4
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly describes the main change: larger WorldBuilder maps use the partial terrain window.
Description check Passed The description directly explains the memory issue, the partial terrain window change, the disabled option, and the updated warning threshold.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp Outdated
@Mauller Mauller added WorldBuilder Relates to World Builder Gen Relates to Generals ZH Relates to Zero Hour Memory Is memory related Bug Something is not working right, typically is user facing labels Oct 13, 2026
Comment thread Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp Outdated
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-large-map-draw branch from 6091bdb to f8bb8fc Compare October 13, 2026 13:17
@tintinhamans tintinhamans changed the title bugfix(worldbuilder): Draw maps larger than 1024 through the partial terrain window bugfix(worldbuilder): Draw maps larger than 1024x1024 through the partial terrain window Oct 13, 2026
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-large-map-draw branch 3 times, most recently from 93ffa84 to a2b7b04 Compare October 13, 2026 13:44
@tintinhamans
tintinhamans marked this pull request as ready for review October 13, 2026 13:47
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-large-map-draw branch from a2b7b04 to 415d94a Compare October 13, 2026 13:52
@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge after its stated prerequisite.

Summary

Large maps now use a camera-following terrain window instead of drawing the whole map.

  • Large maps render through a camera-following terrain window.
  • WorldBuilder keeps new and resized maps within shared size limits.
  • The game engine checks map size and height data before loading it.

No actionable new issues were found. The changes are mirrored in both WorldBuilder editions.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Load or resize map] --> B{Show entire map enabled<br/>and area at most 1024 squared?}
  B -->|Yes| C[Build terrain for the whole map]
  B -->|No| D[Build the partial terrain window]
  D --> E[Move the window with the camera]
Loading

Reviews (5) · Last reviewed commit: "bugfix(worldbuilder): Draw maps larger t..." · Reviewed by Greptile

Comment thread Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp Outdated
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-large-map-draw branch 2 times, most recently from 53d9809 to fc6bcdc Compare October 13, 2026 16:29
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-large-map-draw branch from fc6bcdc to f30a5e5 Compare October 13, 2026 18:49
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-large-map-draw branch from f30a5e5 to 9701a1b Compare October 13, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals Memory Is memory related WorldBuilder Relates to World Builder ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants