<!-- SAGA-STAGING · part 75 -->
| 1, b.sy || 1, b.sz || 1);
      mesh.userData.bam = {w:b.w, h:b.h, d:b.d};
      mesh.userData.staysOnMap = true;
      scene.add(mesh);
      window._bamBlocks.push(mesh);
    });
    if(list.length && typeof say === 'function') say(list.length + ' blocks restored');
  }catch(e){ console.error(e); }
}
window.__sagaExecMark('6050');

/* Restore the King's castles on every load — forever means forever */
restoreCastles();
restoreBamBlocks();

/* THE HEROES LOCKER — the one block that holds every inventory. King order 2026-10-05. */
function lockerInventory(){
  var inv = {castles:[], blocks:[]};
  try{ inv.castles = JSON.parse(localStorage.getItem('saga-staging-castles') || '[]'); }catch(e){ console.error(e); }
  try{ inv.blocks = JSON.parse(localStorage.getItem('saga-staging-blocks') || '[]'); }catch(e){ console.error(e); }
  return inv;
}
function sayLocker(){
  var inv = lockerInventory();
  var msg = 'Heroes Locker: ' + inv.castles.length + ' castle' + (inv.castles.length === 1 ? '' : 's') +
    ', ' + inv.blocks.length + ' block' + (inv.blocks.length === 1 ? '' : 's');
  if(typeof say === 'function') say(msg);
}
function buildHeroesLocker(){
  if(window.STAGING_CLEAN_MAP) return; // Clean map: old builder disabled
  try{
    var lx = 30, lz = 30;
    var g = new THREE.Group();
    var dark = new THREE.MeshStandardMaterial({color:0x1a1a2e, roughness:0.5, metalness:0.6});
    var gold = new THREE.MeshStandardMaterial({color:0xd8a920, roughness:0.3, metalness:0.8});
    var body = new THREE.Mesh(new THREE.BoxGeometry(6, 8, 4), dark);
    body.position.y = 4; g.add(body);
    var trim = new THREE.Mesh(new THREE.BoxGeometry(6.6, 0.8, 4.6), gold);
    trim.position.y = 8.2; g.add(trim);
    var base = new THREE.Mesh(new THREE.BoxGeometry(6.6, 0.8, 4.6), gold);
    base.position.y = 0.4; g.add(base);
    var cv = document.createElement('canvas'); cv.width = 256; cv.height = 128;
    var c = cv.getContext('2d');
    c.fillStyle = '#0a0a12'; c.fillRect(0, 0, 256, 128);
    c.strokeStyle = '#ffd700'; c.lineWidth = 5; c.strokeRect(6, 6, 244, 116);
    c.font = 'bold 30px Georgia'; c.textAlign = 'center';
    c.fillStyle = '#ffe9a8'; c.fillText('HEROES', 128, 55); c.fillText('LOCKER', 128, 95);
    var tex = new THREE.CanvasTexture(cv);
    var face = new THREE.Mesh(new THREE.PlaneGeometry(5.4, 2.7),
      new THREE.MeshBasicMaterial({map:tex}));
    face.position.set(0, 4.5, 2.05); g.add(face);
    g.position.set(lx, 0, lz);
    g.userData.toolName = 'locker';
    g.userData.isLocker = true;
    scene.add(g);
    if(!window._toolSwitches) window._toolSwitches = [];
    window._toolSwitches.push(body); body.userData.toolName = 'locker';
    window._toolSwitches.push(face); face.userData.toolName = 'locker';
    /* gold beacon so the locker is findable */
    var beam = new THREE.Mesh(
      new THREE.CylinderGeometry(0.8, 0.8, 300, 8),
      new THREE.MeshBasicMaterial({color:0xffd700, transparent:true, opacity:0.3, blending:THREE.AdditiveBlending, depthWrite:false})
    );
    beam.position.set(lx, 150, lz);
    scene.add(beam);
    if(typeof trackNewThing === 'function') trackNewThing('heroes-locker', 'The Heroes Locker — source of every inventory on the map');
  }catch(e){ console.error(e); }
}
CODES['briefing'] = {cat:'Special', desc:'The Morning Briefing — in memory of all memories before', fn:function(a){
  var m = window.readMemory ? window.readMemory(5) : [];
  say(m.length ? m.map(function(e){ return e.what; }).join('; ') : 'nothing yet');
}};
CODES['memory'] = {cat:'Special', desc:'Alias for briefing', fn:function(a){ runCode('briefing'); }};
CODES['locker'] = {cat:'Special', desc:'Go to the Heroes Locker — every inventory', fn:function(a){
  kingPos.set(30, 0, 30);
  sayLocker();
}};
buildHeroesLocker();
/* CANNON — v79, King's orders 2026-10-05: button by the OS toggle, tap = FIRE, no folders, no digging.
   Gold button above the hamburger. Fires a blazing cannonball on a ballistic arc.
   Spawns a cannon first if none stands near. */
window._cannons = window._cannons || [];
function buildCannon(){
  if(window.STAGING_CLEAN_MAP) return; // Clean map: old builder disabled
  try{
    var g = new THREE.Group();
    var darkMetal = new THREE.MeshStandardMaterial({color:0x2a2a35, roughness:0.35, metalness:0.85});
    var gold = new THREE.MeshStandardMaterial({color:0xd8a920, roughness:0.3, metalness:0.8});
    var base = new THREE.Mesh(new THREE.BoxGeometry(2.2, 0.5, 1.4), darkMetal);
    base.position.y = 0.65; g.add(base);
    var wheelGeo = new THREE.CylinderGeometry(0.55, 0.55, 0.25, 16);
    var hubGeo = new THREE.CylinderGeometry(0.18, 0.18, 0.3, 12);
    [-0.85, 0.85].forEach(function(wx){
      var w = new THREE.Mesh(wheelGeo, darkMetal);
      w.rotation.z = Math.PI/2; w.position.set(wx, 0.55, 0); g.add(w);
      var hub = new THREE.Mesh(hubGeo, gold);
      hub.rotation.z = Math.PI/2; hub.position.set(wx, 0.55, 0); g.add(hub);
    });
    var barrel = new THREE.