/* comefrom: MapScan */ DoFlood(void) { static short Dx[4] = { 0, 1, 0,-1}; static short Dy[4] = {-1, 0, 1, 0}; register short z, c, xx, yy, t; if (FloodCnt) for (z = 0; z < 4; z++) { if (!(Rand16() & 7)) { xx = SMapX + Dx[z]; yy = SMapY + Dy[z]; if (TestBounds(xx, yy)) { c = Map[xx][yy]; t = c & LOMASK; /* TILE_IS_FLOODABLE2(c) */ if ((c & BURNBIT) || (c == 0) || ((t >= WOODS5 /* XXX */) && (t < FLOOD))) { if (c & ZONEBIT) FireZone(xx, yy, c); Map[xx][yy] = FLOOD + Rand(2); } } } } else if (!(Rand16() & 15)) Map[SMapX][SMapY] = 0; }
/* comefrom: DoDisasters ScenarioDisaster */ MakeFlood(void) { static short Dx[4] = { 0, 1, 0,-1}; static short Dy[4] = {-1, 0, 1, 0}; register short xx, yy, c; short z, t, x, y; for (z = 0; z < 300; z++) { x = Rand(WORLD_X - 1); y = Rand(WORLD_Y - 1); c = Map[x][y] & LOMASK; /* XXX: & LOMASK */ /* TILE_IS_RIVER_EDGE(c) */ if ((c > 4) && (c < 21)) /* if riveredge */ for (t = 0; t < 4; t++) { xx = x + Dx[t]; yy = y + Dy[t]; if (TestBounds(xx, yy)) { c = Map[xx][yy]; /* TILE_IS_FLOODABLE(c) */ if ((c == 0) || ((c & BULLBIT) && (c & BURNBIT))) { Map[xx][yy] = FLOOD; FloodCnt = 30; SendMesAt(-42, xx, yy); FloodX = xx; FloodY = yy; return; } } } } }
////////////////////////////////////////////////////////////////////// // Harvest culling section. // These are the functions used on a built tree ////////////////////////////////////////////////////////////////////// plCullNode::plCullStatus plCullNode::ITestBoundsRecur(const hsBounds3Ext& bnd) const { plCullNode::plCullStatus retVal = TestBounds(bnd); // No Children, what we say goes. if( (fOuterChild < 0) && (fInnerChild < 0) ) return retVal; // No innerchild. If we cull, it's culled, else we // hope our outerchild culls it. if( fInnerChild < 0 ) { if( retVal == kCulled ) return kCulled; return IGetNode(fOuterChild)->ITestBoundsRecur(bnd); } // No outerchild. If we say it's clear, it's clear (or split), but if // it's culled, we have to pass it to innerchild, who may pronounce it clear if( fOuterChild < 0 ) { if( retVal == kClear ) return kClear; if( retVal == kSplit ) return kSplit; return IGetNode(fInnerChild)->ITestBoundsRecur(bnd); } // We've got both children to feed. // We pass the clear ones to the inner child, culled to outer, // and split to both. Remember, a both children have to agree to cull a split. if( retVal == kClear ) return IGetNode(fOuterChild)->ITestBoundsRecur(bnd); if( retVal == kCulled ) return IGetNode(fInnerChild)->ITestBoundsRecur(bnd); // Here's the split, to be culled, both children have to // say its culled. if( kCulled != IGetNode(fOuterChild)->ITestBoundsRecur(bnd) ) return kSplit; if( kCulled != IGetNode(fInnerChild)->ITestBoundsRecur(bnd) ) return kSplit; return kCulled; }
// For this Cull Node, recur down the space hierarchy pruning out who to test for the next Cull Node. plCullNode::plCullStatus plCullNode::ITestNode(const plSpaceTree* space, int16_t who, hsLargeArray<int16_t>& clear, hsLargeArray<int16_t>& split, hsLargeArray<int16_t>& culled) const { if( space->IsDisabled(who) || (space->GetNode(who).fWorldBounds.GetType() != kBoundsNormal) ) { culled.Append(who); return kCulled; } plCullStatus retVal = kClear; plCullStatus stat = TestBounds(space->GetNode(who).fWorldBounds); switch( stat ) { case kClear: clear.Append(who); retVal = kClear; break; case kCulled: culled.Append(who); retVal = kCulled; break; case kSplit: if( space->GetNode(who).fFlags & plSpaceTreeNode::kIsLeaf ) { // split.Append(who); retVal = kPureSplit; } else { plCullStatus child0 = ITestNode(space, space->GetNode(who).GetChild(0), clear, split, culled); plCullStatus child1 = ITestNode(space, space->GetNode(who).GetChild(1), clear, split, culled); if( child0 != child1 ) { if( child0 == kPureSplit ) split.Append(space->GetNode(who).GetChild(0)); else if( child1 == kPureSplit ) split.Append(space->GetNode(who).GetChild(1)); retVal = kSplit; } else if( child0 == kPureSplit ) { retVal = kPureSplit; } } } return retVal; }
/* comefrom: processWand */ put6x6Rubble(short x, short y) { register xx, yy, zz; for (xx = x - 1; xx < x + 5; xx++) { for (yy = y - 1; yy < y + 5; yy++) { if (TestBounds(xx, yy)) { zz = Map[xx][yy] & LOMASK; if ((zz != RADTILE) && (zz != 0)) { Map[xx][yy] = (DoAnimation ? (TINYEXP + Rand(2)) : SOMETINYEXP) | ANIMBIT | BULLBIT; } } } } }