Skip to content

bugfix(worldbuilder): Keep new and resized maps within the map size limit - #3501

Open
tintinhamans wants to merge 2 commits into
TheSuperHackers:mainfrom
tintinhamans:arctic/fix/worldbuilder-map-size
Open

tintinhamans wants to merge 2 commits into
TheSuperHackers:mainfrom
tintinhamans:arctic/fix/worldbuilder-map-size

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 13, 2026 •

Copy link
Copy Markdown

⚠️ Merge with Rebase


This change has 2 commits: resize-memory fixes first, then map-size validation.

The new map and resize dialog accepts sizes the loader rejects. isValidTotalMapSize enforces MAX_MAP_DIMENSION and MAX_MAP_AREA on dimensions that include the border. isValidPlayableMapSize checks that adding the border cannot overflow, then calls the same validator. WorldBuilder validates creation, resizing and saved defaults, and warns above 1024x1024.

resize also keeps the extra height-data row allocated by the constructor, frees its arrays with delete[], and clears the new flip and cliff state.

@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: f0fb0a21-8f5e-4a82-85c5-587af5452a68
📥 Commits

Reviewing files that changed from the base of the PR and between 0e70107 and f985cba.

📒 Files selected for processing: 4
  • Core/GameEngineDevice/Include/W3DDevice/GameClient/WorldHeightMap.h
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
  • Generals/Code/Tools/WorldBuilder/src/NewHeightMap.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp

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

Walkthrough

WorldHeightMap now separates total-map and playable-map size validation. Both WorldBuilder variants use playable-size checks when creating or resizing maps and when loading configured defaults. New-map dialogs request confirmation when the bordered map area exceeds 1024² cells.

Changes

Height-map validation

Layer / File(s) Summary
Total and playable map-size checks
Core/GameEngineDevice/Include/W3DDevice/GameClient/WorldHeightMap.h, Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
WorldHeightMap replaces isValidMapSize with isValidTotalMapSize and adds isValidPlayableMapSize. The validators check dimensions, borders, and map area. Height-map parsers validate loaded dimensions as total-map sizes.
Editor validation and resizing
Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp, GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
Both variants validate playable dimensions when constructing or resizing an editor map. Resizing changes height-data allocation, uses array deletion for buffers, and initializes cliff and flip state arrays.
Map creation and default dimensions
Generals/Code/Tools/WorldBuilder/src/NewHeightMap.cpp, GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp, Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp, GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
Both new-map dialogs reject invalid playable sizes and request confirmation when bordered area exceeds 1024² cells. Both document implementations replace invalid configured dimensions and borders with defaults.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: xezon

Merge Risk: ⚪ Minimal · up to f985c

This change makes WorldBuilder's new-map and resize dialogs reject sizes the loader would refuse, and warns before creating very large maps. No actionable merge-blocking risk remains in the supplied evidence.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: preventing new and resized WorldBuilder maps from exceeding the map size limit.
Description check Passed The description directly explains map-size validation, WorldBuilder coverage, resize memory fixes, and the 1024×1024 warning.
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.
  • 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.

@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch from ba592df to e9975d0 Compare October 13, 2026 08:55
@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

WorldBuilder now checks border-inclusive map limits before creating or resizing maps in both game editions.

  • WorldBuilder keeps new and resized maps within the loader’s size limits.
  • Resizing maps prepares the height and state buffers for the new dimensions.

No actionable new issues were found. No previous review threads were supplied.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Saved dimensions] --> B{Valid playable size?}
  B -->|No| C[Use safe defaults]
  B -->|Yes| D[New document]
  C --> D
  E[Create or resize dialog] --> F{Valid border-inclusive size?}
  F -->|No| G[Keep dialog open]
  F -->|Yes| H{Above warning threshold?}
  H -->|Yes| I[Ask user to continue]
  H -->|No| J[Create or resize map]
  I -->|Continue| J
Loading

Reviews (14) · Last reviewed commit: "fix(wheightmapedit): Validate new and re..." · Reviewed by Greptile

@tintinhamans tintinhamans added Bug Something is not working right, typically is user facing WorldBuilder Relates to World Builder Gen Relates to Generals ZH Relates to Zero Hour Memory Is memory related Minor Severity: Minor < Major < Critical < Blocker labels Oct 13, 2026
@Mauller

Mauller commented Oct 13, 2026 •

Copy link
Copy Markdown

As WWB2 mentioned in the other PR, we might want to limit the map Area rather than hard limit dimensions, since it's the overall area that causes problems and not just individual dimensions.

So the Max area being 4096 squared etc

@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch from e9975d0 to 679d8f2 Compare October 13, 2026 13:16
@tintinhamans

Copy link
Copy Markdown
Author

As WWB2 mentioned in the other PR, we might want to limit the map Area rather than hard limit dimensions, since it's the overall area that causes problems and not just individual dimensions.

So the Max area being 4096 squared etc

The limit is now an area of 4096x4096. Each side is still capped at 8192 because shoreline tiles pack coordinates into 16 bits and the shroud texture spans the map.

Comment thread GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch 2 times, most recently from df25ef5 to c12b922 Compare October 13, 2026 19:04
Comment thread Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp Outdated
Comment thread Generals/Code/Tools/WorldBuilder/src/NewHeightMap.cpp
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch from c12b922 to a72fd31 Compare October 13, 2026 19:23

@Mauller Mauller left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@xezon

xezon commented Oct 15, 2026

Copy link
Copy Markdown

Needs rebase?

@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch from a72fd31 to 17859d5 Compare October 15, 2026 19:37
Comment thread GeneralsMD/Code/Tools/WorldBuilder/include/WHeightMapEdit.h Outdated
Comment thread Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp Outdated
Comment thread GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp Outdated
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch from 17859d5 to 89141b1 Compare October 18, 2026 00:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 53dcd0b2-9b8e-4756-a3d8-b91caf5b9538
📥 Commits

Reviewing files that changed from the base of the PR and between 17859d5 and 89141b1.

📒 Files selected for processing: 4
  • Generals/Code/Tools/WorldBuilder/include/WHeightMapEdit.h
  • Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/include/WHeightMapEdit.h
  • GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp

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

Comment thread Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp Outdated
@tintinhamans
tintinhamans requested a review from xezon October 18, 2026 02:17
Comment thread Generals/Code/Tools/WorldBuilder/include/WHeightMapEdit.h Outdated
Comment thread Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp Outdated
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch 2 times, most recently from 4701c4e to 9594539 Compare October 18, 2026 12:01
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch 2 times, most recently from 5700853 to db6eb02 Compare October 18, 2026 12:23

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why do we need 2 different map validation methods? It looks like world builder uses a different one than game does.

Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp Outdated
Comment thread Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp Outdated
Comment thread GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch from db6eb02 to b0f7488 Compare October 18, 2026 13:26
@tintinhamans

Copy link
Copy Markdown
Author

Why do we need 2 different map validation methods? It looks like world builder uses a different one than game does.

both use the same validator now. the playable wrapper just safely adds the border before calling it.

@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch from b0f7488 to 0e70107 Compare October 18, 2026 13:30

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OK

Comment thread Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
Comment thread Core/GameEngineDevice/Include/W3DDevice/GameClient/WorldHeightMap.h
Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp Outdated
Comment thread GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp Outdated
Comment thread GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp Outdated
Comment thread GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp Outdated
@tintinhamans
tintinhamans force-pushed the arctic/fix/worldbuilder-map-size branch from 0e70107 to f985cba Compare October 18, 2026 18:37
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 Minor Severity: Minor < Major < Critical < Blocker 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