"""Run shipped sheet geometry; no engine or multiplayer claims.""" import re from policy_harness import ROOT, body, run source = ROOT/'addons/core/Scripts/Game/ERR/30_Map/ERRM_SharedMapPages.c' def adapt(signature): text = body(source, signature) for a,b in [('out float zoom','float& zoom'),('out int columns','int& columns'),('out int rows','int& rows'),('SCR_MapConstants.MAX_PIX_PER_METER','20.f'),('Math.Min','minf'),('Math.Max','maxf'),('Math.Ceil','ceilf'),('Math.Clamp','clampf'),('static const int','static constexpr int')]: text=text.replace(a,b) return re.sub(r"out (int|vector) (\w+)", r"\1& \2", text) run(r''' #include #include #include #include using vector=std::array; vector Vector(float x,float y,float z){return {x,y,z};} float minf(float a,float b){return std::min(a,b);} float maxf(float a,float b){return std::max(a,b);} float clampf(float a,float b,float c){return std::clamp(a,b,c);} '''+'constexpr int COVER=16777215, OVERVIEW=16777214, REGION=16777216;\n'+adapt('static bool Layout(')+adapt('static vector Centre(')+''.join(adapt(sig) for sig in ['static bool IsRegion(', 'static int RegionColumns(', 'static int RegionRows(', 'static int RegionCount(', 'static int LastNumber(', 'static void RegionCells(', 'static int ParentRegion(', 'static float Boundary(', 'static void RegionBounds('])+adapt('static int Number(')+adapt('static int State(')+r''' void check(vector size, vector offset){ float zoom;int cols,rows; assert(Layout(size,.5f,zoom,cols,rows)); assert(cols>=1&&rows>=1&&cols*rows<=400); assert(Number(COVER,cols,rows)==0&&Number(OVERVIEW,cols,rows)==1); assert(State(0,cols,rows)==COVER&&State(1,cols,rows)==OVERVIEW); assert(State(-1,cols,rows)==-1&&State(LastNumber(cols,rows)+1,cols,rows)==-1); for(int n=2;n<=LastNumber(cols,rows);n++) assert(Number(State(n,cols,rows),cols,rows)==n); assert(LastNumber(cols,rows)<1000); for(int region=0;region=0&&t>=0&&r<=cols&&b<=rows&&r>l&&b>t&&r-l<=3&&b-t<=3); vector low,high; RegionBounds(REGION+region,cols,rows,size,zoom,low,high); assert(low[0]>=0&&low[2]>=0&&high[0]<=1&&high[2]<=1&&high[0]>low[0]&&high[2]>low[2]); for(int y=t;y0) { vector prevLow,prevHigh;RegionBounds(REGION+region-1,cols,rows,size,zoom,prevLow,prevHigh); assert(std::abs(prevHigh[0]-low[0])<.00001f); } } float w=744/zoom,h=1024/zoom; for(int row=0;row=offset[0]-.01f&&p[0]+w/2<=offset[0]+size[0]+.01f); assert(p[2]-h/2>=offset[2]-.01f&&p[2]+h/2<=offset[2]+size[2]+.01f); if(col) { auto prev=Centre(offset,size,zoom,cols,rows,col-1,row); assert(p[0]>prev[0]&&p[0]-prev[0]<=w*.91f); } if(row) { auto prev=Centre(offset,size,zoom,cols,rows,col,row-1); assert(p[2]