<!-- RUBY-BACKUP · part 256 -->
    if(o.isMesh && o.position){
              var dx = o.position.x - ex, dz = o.position.z - ez;
              if(dx*dx + dz*dz < 400) clear = false;
            }
          });
          if(clear) found.push({lat: ez, lon: ex});
        }
      }
      var fout = ['--- EMPTY LAND ---'];
      found.forEach(function(f){ fout.push('LAT ' + f.lat + ' LON ' + f.lon); });
      if(typeof codeStatus === 'function') codeStatus(fout.join('\n'));
    }catch(e){}
    return;
  }
  if(tl==='mapwater'){
    try{
      var waters = [];
      for(var wx = -500; wx <= 500; wx += 50){
        for(var wz = -500; wz <= 500; wz += 50){
          if(typeof window.isWater === 'function' && window.isWater(wx, wz)){
            waters.push({lat: wz, lon: wx});
            wx += 100; /* skip ahead */
          }
        }
      }
      var wout = ['--- WATERS (' + waters.length + ') ---'];
      waters.slice(0, 10).forEach(function(w){ wout.push('LAT ' + w.lat + ' LON ' + w.lon); });
      if(typeof codeStatus === 'function') codeStatus(wout.join('\n'));
    }catch(e){}
    return;
  }
  if(tl==='guardframe'){
    try{
      var surfOK = typeof fortifiedGroundY === 'function';
      var blockCount = (window._solidBlocks || []).length;
      var gout = ['--- FRAME GUARD ---'];
      gout.push('surface: ' + (surfOK ? 'OK' : 'BROKEN'));
      gout.push('solid blocks: ' + blockCount);
      gout.push('baby steps: checking...');
      var babyCount = 0;
      scene.traverse(function(o){
        if(o.userData && o.userData.babyStep) babyCount++;
      });
      gout.push('baby steps: ' + babyCount);
      gout.push(surfOK && blockCount > 0 ? 'FRAME HOLDS' : 'FRAME WEAK');
      if(typeof codeStatus === 'function') codeStatus(gout.join('\n'));
    }catch(e){}
    return;
  }
  if(tl==='enforcelaws'){
    try{
      var violations = [];
      if(window._solidBlocks){
        window._solidBlocks.forEach(function(b, i){
          var bx = Math.round(b.position.x), bz = Math.round(b.position.z);
          if(bx === 0 || bz === 0) violations.push('block ' + i + ' on zero line!');
        });
      }
      scene.traverse(function(o){
        if(o.userData && o.userData.nature){
          var nx = o.position.x, nz = o.position.z;
          if(typeof inRespectZone === 'function' && inRespectZone(nx, nz))
            violations.push('nature on protected zone at LAT ' + nz.toFixed(0));
        }
      });
      var eout = violations.length === 0 ? 'all laws hold' : 'VIOLATIONS:\n' + violations.slice(0, 5).join('\n');
      if(typeof codeStatus === 'function') codeStatus(eout);
    }catch(e){}
    return;
  }
  if(tl==='bestspots'){
    try{
      var highest = {h: -999, lat: 0, lon: 0};
      var flattest = {v: 999, lat: 0, lon: 0};
      for(var bx = -400; bx <= 400; bx += 40){
        for(var bz = -400; bz <= 400; bz += 40){
          if(bx === 0 || bz === 0) continue;
          var bh = fortifiedGroundY(bx, bz);
          if(bh > highest.h) highest = {h: bh, lat: bz, lon: bx};
          var v1 = Math.abs(fortifiedGroundY(bx+5, bz) - bh);
          var v2 = Math.abs(fortifiedGroundY(bx, bz+5) - bh);
          var vv = v1 + v2;
          if(vv < flattest.v) flattest = {v: vv, lat: bz, lon: bx};
        }
      }
      var bout = ['--- BEST SPOTS ---'];
      bout.push('highest: LAT ' + highest.lat + ' LON ' + highest.lon + ' (HGT ' + highest.h.toFixed(1) + ')');
      bout.push('flattest: LAT ' + flattest.lat + ' LON ' + flattest.lon);
      if(typeof codeStatus === 'function') codeStatus(bout.join('\n'));
    }catch(e){}
    return;
  }
  if(tl==='measurecity'){
    try{
      var cc = (typeof getCityCenter === 'function' ? getCityCenter() : {x: 25, z: -10});
      var bldgs = 0, roadLen = 0;
      scene.traverse(function(o){
        if(o.isMesh && o.position){
          var dx = o.position.x - cc.x, dz = o.position.z - cc.z;
          if(dx*dx + dz*dz < 900){
            if(o.geometry && o.geometry.type === 'BoxGeometry'){
              var p = o.geometry.parameters;
              if(p.height > 5) bldgs++;
              if(p.height < 2 && (p.width > 20 || p.depth > 20)) roadLen += Math.max(p.width, p.depth);
            }
          }
        }
      });
      var mout = ['--- CITY ---'];
      mout.push('center: LAT ' + cc.z + ' LON ' + cc.x);
      mout.push('buildings: ' + bldgs);
      mout.push('road length: ' + roadLen.toFixed(0));
      if(typeof codeStatus === 'function') codeStatus(mout.join('\n'));
    }catch(e){}
    return;
  }
  if(tl.indexOf('goroad') === 0){
    try{
      var parts = tl.split(' ');
      var idx = parseInt(parts[1] || '0');
      var rds2 = findRoads();
      if(rds2[idx]){
        var r = rds2[idx];
        if(typeof mePos !== 'undefined'){
          mePos.x = r.x; mePos.z = r.z;
          if(typeof codeStatus === 'function') codeStatus('at road ' + idx + ' — LAT ' + r.z.toFixed(0) + ' LON ' + r.x.toFixed(0));
        }
      } else {
        if(typeof codeStatus === 'function