Easy: i've just copied & pasted your function, and changed it a bit to use Record instead of CreateUnit:
void RecordBase(BuildingGroup grp,int x,int y,struct BaseInfo &baseInfo)
{
int i;
int curX, curY;
int curX2, curY2;
// Create the buildings
for (i = 0; i < baseInfo.numBuilding; i++)
{
BuildingInfo &curItem = baseInfo.bldnInfo[i];
curX = x + curItem.x;
curY = y + curItem.y;
grp.RecordBuilding(LOCATION(curX,curY),curItem.type,mapNone);
}
// Create the tube lines
for (i = 0; i < baseInfo.numTubeLine; i++)
{
TubeWallInfo &curItem = baseInfo.tubeInfo[i];
curX = x + curItem.fromX;
curY = y + curItem.fromY;
curX2 = x + curItem.toX;
curY2 = y + curItem.toY;
RecordTubeOrWall(grp,LOCATION(curX,curY),LOCATION(curX2,curY2),mapTube);
}
// Create the wall lines
for (i = 0; i < baseInfo.numWallLine; i++)
{
TubeWallInfo &curItem = baseInfo.wallInfo[i];
curX = x + curItem.fromX;
curY = y + curItem.fromY;
curX2 = x + curItem.toX;
curY2 = y + curItem.toY;
RecordTubeOrWall(grp,LOCATION(curX,curY),LOCATION(curX2,curY2),mapWall);
}
// Create the vehicles
for (i = 0; i < baseInfo.numVehicle; i++)
{
VehicleInfo &curItem = baseInfo.vehicleInfo[i];
if (curItem.type==mapGuardPost)
{
curX = x + curItem.x;
curY = y + curItem.y;
grp.RecordBuilding(LOCATION(curX,curY),curItem.type,mapNone);
}
}
}
I'm not sure the RecordTubeOrWall function is made by you, or added by me - if you dont have that, let me know, i'll post it also
Same thing: i'ts a mere copy of your code, amended to use Record functions instead:
void RecordTubeOrWall(BuildingGroup grp,LOCATION start,LOCATION end,map_id type)
{
int increment=1;
if (start.x==end.x) // vertical tube
{
if (type==mapTube) grp.RecordTube(LOCATION(start.x,start.y));
else grp.RecordWall(LOCATION(start.x,start.y),type);
if (start.y==end.y) increment=0;
else increment=(start.y<=end.y?1:-1);
do
{
start.y+=increment;
if (type==mapTube) grp.RecordTube(LOCATION(start.x,start.y));
else grp.RecordWall(LOCATION(start.x,start.y),type);
}
while (start.y!=end.y);
}
else if (start.y==end.y) // horizontal tube
{
if (type==mapTube) grp.RecordTube(LOCATION(start.x,start.y));
else grp.RecordWall(LOCATION(start.x,start.y),type);
if (start.x==end.x) increment=0;
else increment=(start.x<=end.x?1:-1);
do
{
start.x+=increment;
if (type==mapTube) grp.RecordTube(LOCATION(start.x,start.y));
else grp.RecordWall(LOCATION(start.x,start.y),type);
}
while (start.x!=end.x);
}
else // diagonal -> horizontal first, then vertical:
{
RecordTubeOrWall(grp,start,LOCATION(end.x,start.y),type);
RecordTubeOrWall(grp,LOCATION(end.x,start.y),end,type);
}
}