Treads are a problem. The simplest solution I can think of, would be to have a sprocket and rollers as a special kind of frame (limited to armor, panels, and so on). Treads are placed on these tiles and can be damaged individually. If the tread or sprocket is damaged, or more then half the rollers, then that entire side no longer works. This would all have to be analyzed in vertical lines in start/end groups.
Off the top of my head, something like this probably to detect them.
int start_y = -1;
for(int x = 0; x < max_x; ++x) {
start_y = -1;
for(int y = 0; y < max_y; ++y) {
int type = vmap[y][x].frame;
if(type == VTYPE_SPROCKET || type == VTYPE_ROLLER) {
if(start_y == -1) start_y = y;
} else if(start_y != -1) {
add_tread(x, start_y, y - 1);
start_y = -1;
}
}
if(start_y != -1) {
add_tread(x, start_y, max_y - 1);
}
}
Then in add_tread, check contents for actual tread pieces, their conditions and so forth.