Hooks
static bool BeforeCvPlot_shouldProcessDisplacementPlot(const CvPlot* self, int dx, int dy, int arg2, DirectionTypes eFacingDirection, bool& result);static void AfterCvPlot_shouldProcessDisplacementPlot(const CvPlot* self, int dx, int dy, int arg2, DirectionTypes eFacingDirection, bool& result);static bool ReplaceCvPlot_shouldProcessDisplacementPlot(bool (*original)(const CvPlot*, int, int, int, DirectionTypes), const CvPlot* self, int dx, int dy, int arg2, DirectionTypes eFacingDirection);CivRegisterBefore<CivHooks::CvPlot_shouldProcessDisplacementPlot>(host, &BeforeCvPlot_shouldProcessDisplacementPlot);CivRegisterAfter<CivHooks::CvPlot_shouldProcessDisplacementPlot>(host, &AfterCvPlot_shouldProcessDisplacementPlot);CivRegisterReplace<CivHooks::CvPlot_shouldProcessDisplacementPlot>(host, &ReplaceCvPlot_shouldProcessDisplacementPlot);
Code
1914bool CvPlot::shouldProcessDisplacementPlot(int dx, int dy, int, DirectionTypes eFacingDirection) const1915{1916 if(eFacingDirection == NO_DIRECTION)1917 {1918 return true;1919 }1920 else if((dx == 0) && (dy == 0)) //always process this plot1921 {1922 return true;1923 }1924 else1925 {1926 // NE E SE SW W NW1927 double displacements[6][2] = { {0.5f, 0.866025f}, {1, 0}, {0.5f, -0.866025f}, {-0.5f, -0.866025f}, {-1, 0}, {-0.5f, -0.866025f}};19281929 double directionX = displacements[eFacingDirection][0];1930 double directionY = displacements[eFacingDirection][1];19311932 //compute angle off of direction1933 double crossProduct = directionX * dy - directionY * dx; //cross product1934 double dotProduct = directionX * dx + directionY * dy; //dot product19351936 double theta = atan2(crossProduct, dotProduct);1937 double spread = 75 * (double) M_PI / 180;1938 if((abs(dx) <= 1) && (abs(dy) <= 1)) //close plots use wider spread1939 {1940 spread = 90 * (double) M_PI / 180;1941 }19421943 if((theta >= -spread / 2) && (theta <= spread / 2))1944 {1945 return true;1946 }1947 else1948 {1949 return false;1950 }1951 }1952}