2020-05-30 10:26 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000619AIAIpublic2007-09-02 12:37
Reporterpbrook 
Assigned ToKloot 
PrioritynormalSeveritycrashReproducibilityrandom
StatusresolvedResolutionfixed 
Summary0000619: [patch] Fix AAI crash
DescriptionAAI crashes frequently for me, often immediately after starting the same.
The crash occurs with a coupld of different mods (xTA, AA), many differnt maps, and both linux and windows hosts.

The attached patch fixes this.
Additional InformationThe crash occurs because AAIMap::GetCenterBuildsite calls AAIMap::CanBuildAt with a negative yPos.

GetCenterBuildsite works by scanning the perimiter of an increasingly large bounding box until it either finds a suitable location or the box becomes larger than the target area.

For non-square target areas the code disables either the horizontal or vertical scan when that side of the scan box exceeds the target area. However the scan box is still square, so the ends of the other dimension end up exceeding the requested area. In many cases this is relatively harmless (worst case we build something where we didn't mean to. Other times we end up walking off the edge of the map and segfault.

The fix is to clip the scan box dimensons in addition to disabling scanning that side.

Hopefully this explamation makes sense. I can draw pictures to help explain if it doesn't.
TagsNo tags attached.
Attached Files
  • ? file icon patch (845 bytes) 2007-09-02 03:17 -
    Index: AI/Global/AAI/AAIMap.cpp
    ===================================================================
    --- AI/Global/AAI/AAIMap.cpp	(revision 4288)
    +++ AI/Global/AAI/AAIMap.cpp	(working copy)
    @@ -846,10 +846,16 @@
     			}
     		}
     
    -		hIterator += 2;
    +		if (!hStop)
    +		{
    +			hIterator += 2;
     
    -		if(hCenter - hIterator < xStart || hCenter + hIterator > xEnd)
    -			hStop = true;
    +			if(hCenter - hIterator < xStart || hCenter + hIterator > xEnd)
    +			{
    +				hStop = true;
    +				hIterator -= 2;
    +			}
    +		}
     
     		if(!hStop)
     		{
    @@ -905,10 +911,16 @@
     			}
     		}
     
    -		vIterator += 2;
    +		if (!vStop)
    +		{
    +			vIterator += 2;
     
    -		if(vCenter - vIterator < yStart || vCenter + vIterator > yEnd)
    -			vStop = true;
    +			if(vCenter - vIterator < yStart || vCenter + vIterator > yEnd)
    +			{
    +				vStop = true;
    +				vIterator -= 2;
    +			}
    +		}
     	}
     
     	return ZeroVector;
    
    ? file icon patch (845 bytes) 2007-09-02 03:17 +

-Relationships
+Relationships

-Notes

~0001207

pbrook (reporter)

Patch is against SVN r4289

~0001209

Kloot (developer)

commited in r4294, thanks for your efforts :)
+Notes

-Issue History
Date Modified Username Field Change
2007-09-02 03:17 pbrook New Issue
2007-09-02 03:17 pbrook File Added: patch
2007-09-02 03:33 pbrook Note Added: 0001207
2007-09-02 12:36 Kloot Note Added: 0001209
2007-09-02 12:37 Kloot Status new => resolved
2007-09-02 12:37 Kloot Resolution open => fixed
2007-09-02 12:37 Kloot Assigned To => Kloot
+Issue History