static int dorr(struct obj *otmp) { ringoff(otmp); off_msg(otmp); return(1); }
static int dorr(struct obj *otmp) { if(cursed(otmp)) return(0); ringoff(otmp); off_msg(otmp); return(1); }
bool armoroff(struct obj *otmp) { int delay = -objects[otmp->otyp].oc_delay; setworn(NULL, otmp->owornmask & W_ARMOR); if(delay) { nomul(delay); switch(otmp->otyp) { case HELMET: nomovemsg = "You finished taking off your helmet."; break; case PAIR_OF_GLOVES: nomovemsg = "You finished taking off your gloves"; break; default: nomovemsg = "You finished taking off your suit."; } } else { off_msg(otmp); } return(1); }
void Player::handle_message(Message msg) { if (msg.type == Message::TypeEmpty) { // status package, discard return; } Bus &bus = buses[msg.bus]; Channel &values = bus.channels[msg.bus_channel]; if (msg.type == Message::TypeMIDI) { if (msg.command == MIDI::CommandControlChange) { switch(msg.data1) { case MIDI::ControllerAllNotesOff: { for (NoteArray::iterator iter = bus.notes.begin(); iter != bus.notes.end(); ++iter) { *iter = -1; } on_message(msg); } break; default: { on_message(msg); } break; } return; } else if (msg.command == MIDI::CommandAftertouch) { if (values.note != ValueNone) { // insert note and pass on msg.data1 = values.note; on_message(msg); } else { msg.command = MIDI::CommandChannelPressure; msg.data1 = msg.data2; msg.data2 = 0; on_message(msg); } return; } else if (msg.command == MIDI::CommandNoteOff) { if (values.note != ValueNone) { int note = values.note; values.note = ValueNone; // see if that note is actually being played // on our channel, if yes, kill it. if (bus.notes[note] == msg.bus_channel) { bus.notes[note] = -1; msg.data1 = note; msg.data2 = 0; on_message(msg); } } return; } else if (msg.command == MIDI::CommandNoteOn) { if (values.note != ValueNone) { int note = values.note; values.note = ValueNone; // no matter where the note is played, kill it. bus.notes[note] = -1; Message off_msg(msg); off_msg.command = MIDI::CommandNoteOff; off_msg.data1 = note; off_msg.data2 = 0; on_message(off_msg); } values.note = msg.data1; int volume = std::min((int)((float)(msg.data2) * values.volume), 0x7f); msg.data2 = volume; bus.notes[values.note] = msg.bus_channel; on_message(msg); return; } } else if (msg.type == Message::TypeCommandChannelVolume) { values.volume = std::min((float)(msg.status) / 0x7f, 1.0f); } }