Repository navigation
bugfix(w3droadbuffer): Ensure road type buffer fits all roads from Roads.ini - #3731
Jaredl-Dev wants to merge 3 commits into
Conversation
74ae9c4 to
5fcbb7c
Compare
|
No actionable comments were generated in the recent review. WalkthroughThe W3D road-buffer implementation is registered in Core and removed from the Generals build paths. Its allocation logic now raises the road-type capacity to match the number of defined roads when that count is larger. ChangesW3D Road Buffer
Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix · Severity of issue fixed: Medium Possibly related PRs
Suggested reviewers: Merge Risk:
|
[Medium impact] The PR appears safe to merge; no new actionable issues were found.
|
| // TheSuperHackers @bugfix Jaredl-Dev 27/11/2026 Ensure m_maxRoadTypes fits all roads defined in Roads.ini. | ||
| TerrainRoadType *road; | ||
| Int roadCount = 0; | ||
| for( road = TheTerrainRoads->firstRoad(); road; road = TheTerrainRoads->nextRoad( road ) ) |
There was a problem hiding this comment.
I think
Int roadCount = 0;
TerrainRoadType *road =TheTerrainRoads->firstRoad();
do {
roadCount++;
}
while (road = TheTerrainRoads->nextRoad( road ))
is cleaner, although that may be personal.
I do think the counting of roads needs to be done in the TerrainRoadCollection and then call TheTerrainRoads->roadCount(). Standard collection types like lists usually provide a count as well and it looks cleaner
There was a problem hiding this comment.
I'll move the count into TerrainRoadCollection. How about a roadCount() method that walks m_roadList?
Int TerrainRoadCollection::roadCount()
{
Int count = 0;
for( TerrainRoadType *road = m_roadList; road; road = nextRoad( road ) )
++count;
return count;
}allocateRoadBuffers() would then raise m_maxRoadTypes to TheTerrainRoads->roadCount() when it's lower.
With the do/while, couldn't it possibly end up calling nextRoad() with a null pointer? If no roads are defined, firstRoad() returns null, but the body still runs once and then calls nextRoad( nullptr ).
Closes #3729
Depends on #3730
Cause
Retail Generals
GameData.inisetsMaxRoadTypes = 35whileRoads.inidefines 36 roads. BecauseTerrainRoadCollection::newRoad()prepends tom_roadList,TwoLane(first inRoads.ini) is visited 36th and skipped inW3DRoadBuffer::allocateRoadBuffers(). This was previously masked in Release builds byLOAD_TEST_ASSETSadding4tom_maxRoadTypesbefore #1485 restricted it to debug builds.Fix
In
W3DRoadBuffer::allocateRoadBuffers(), count the roads inTheTerrainRoadsand raisem_maxRoadTypesto at least that count before allocatingm_roadTypes.Verification
TwoLaneroads render on Alpine Assault in a VC6 Release build of Generals.