void MidiNoteBuffer::putMidiNote(uint8_t noteNumber) { int i; // The index to put the data in // If this list is full, reject the insertion (huh huh) if (size == midiNoteBufSize) return; // Find this note's place in the list for (i=0; i < size; i++) { if (buffer[i] > noteNumber) { // Make a hole here for the note makeHole(i); // Insert the note buffer[i] = noteNumber; break; } // Do not add the same note twice (shouldn't happen, but safety measure) else if (buffer[i] == noteNumber) { return; } } // Put note into the end of the list if it's higher than all other notes if (i == size) { buffer[i] = noteNumber; } lastNote = i; size++; }
void DungeonGen::makeDoor(v3s16 doorplace, v3s16 doordir) { makeHole(doorplace); #ifdef DGEN_USE_TORCHES // Place torch (for testing) vm->m_data[vm->m_area.index(doorplace)] = MapNode(c_torch); #endif }
void DungeonGen::makeCorridor(v3s16 doorplace, v3s16 doordir, v3s16 &result_place, v3s16 &result_dir) { makeHole(doorplace); v3s16 p0 = doorplace; v3s16 dir = doordir; u32 length; /*if (random.next() % 2) length = random.range(1, 13); else length = random.range(1, 6);*/ length = random.range(1, 13); u32 partlength = random.range(1, 13); u32 partcount = 0; s16 make_stairs = 0; if (random.next() % 2 == 0 && partlength >= 3) make_stairs = random.next() % 2 ? 1 : -1; for (u32 i = 0; i < length; i++) { v3s16 p = p0 + dir; if (partcount != 0) p.Y += make_stairs; if (vmanip->m_area.contains(p) == true && vmanip->m_area.contains(p + v3s16(0, 1, 0)) == true) { if (make_stairs) { makeFill(p + v3s16(-1, -1, -1), v3s16(3, 5, 3), VMANIP_FLAG_DUNGEON_UNTOUCHABLE, MapNode(cid_cobble), 0); makeHole(p); makeHole(p - dir); // TODO: fix stairs code so it works 100% (quite difficult) // exclude stairs from the bottom step if (((make_stairs == 1) && i != 0) || ((make_stairs == -1) && i != length - 1)) { // rotate face 180 deg if making stairs backwards int facedir = dir_to_facedir(dir * make_stairs); u32 vi = vmanip->m_area.index(p.X - dir.X, p.Y - 1, p.Z - dir.Z); if (vmanip->m_data[vi].getContent() == cid_cobble) vmanip->m_data[vi] = MapNode(cid_cobblestair, 0, facedir); vi = vmanip->m_area.index(p.X, p.Y, p.Z); if (vmanip->m_data[vi].getContent() == cid_cobble) vmanip->m_data[vi] = MapNode(cid_cobblestair, 0, facedir); } } else { makeFill(p + v3s16(-1, -1, -1), v3s16(3, 4, 3), VMANIP_FLAG_DUNGEON_UNTOUCHABLE, MapNode(cid_cobble), 0); makeHole(p); } p0 = p; } else { // Can't go here, turn away dir = turn_xz(dir, random.range(0, 1)); make_stairs = -make_stairs; partcount = 0; partlength = random.range(1, length); continue; } partcount++; if (partcount >= partlength) { partcount = 0; dir = random_turn(random, dir); partlength = random.range(1,length); make_stairs = 0; if (random.next() % 2 == 0 && partlength >= 3) make_stairs = random.next() % 2 ? 1 : -1; } } result_place = p0; result_dir = dir; }
void DungeonGen::makeDoor(v3s16 doorplace, v3s16 doordir) { makeHole(doorplace); // Place torch (for testing) //vmanip->m_data[vmanip->m_area.index(doorplace)] = MapNode(cid_torch); }