void do_whistle( char_data* ch, char* ) { obj_data* obj; oprog_data* oprog; player_data* pc; int range = 15; if( !can_talk( ch, "whistle" ) ) return; if( ( obj = has_whistle( ch ) ) != NULL ) { for( oprog = obj->pIndexData->oprog; oprog != NULL; oprog = oprog->next ) if( oprog->trigger == OPROG_TRIGGER_USE ) { var_victim = NULL; var_mob = NULL; var_room = ch->in_room; var_ch = ch; if( !execute( oprog ) ) return; break; } if( oprog == NULL ) { send( ch, "You blow %s producing a loud shriek.\r\n", obj ); send( *ch->array, "%s blows %s producing a loud shriek.\r\n", ch, obj ); } range = obj->value[0]; } else { if( ch->shdata->race == RACE_LIZARD ) { send( ch, "You try to whistle but the best you can do is hiss loudly.\r\n" ); send( *ch->array, "%s hisses loudly - you are not sure what it means.\r\n", ch ); return; } send( ch, "You whistle as loud as you can.\r\n" ); send( *ch->array, "%s whistles loudly.\r\n", ch ); } exec_range( ch, range, hear_whistle ); if( ( pc = player( ch ) ) != NULL && pc->whistle++ >= 3 ) { send( ch, whistle_msg ); spell_silence( ch, ch, NULL, 10, 5 ); } }
void *Knight(void* thread_data) { ThreadData data = (*(ThreadData*)thread_data); set_name(&data); printf("%s come\n", data.name); data.round = 0; while (data.round < MAX_ROUND) { int want_to_talk = RANDOM_BOOL; int repeat = 1; lock_table_mutex(data); do { if (want_to_talk && (can_talk(data))) { if (data.id == KING) { set_king_state(data, IS_TALKING); } talk(data.name); if (data.id == KING) { set_king_state(data, ACTIVE); } break; } else if (!want_to_talk) { lock_cup_and_plate_mutex(data); wait_for_meal_and_eat(&data); break; } else { pthread_cond_wait(&data.cond[TALKING_COND], &data.table_m[LEFT]); } } while (repeat); unlock_mutex_and_broadcast(data); } quit_party(data); pthread_exit(NULL); }