int main(string arg) { object who, victim; WIZ_CHECK if( !arg ) return notify_fail("==> [Format] frotz victim\n"); victim = find_player(arg); if( !victim ) return notify_fail("I can't find any such player '"+arg+"' to zap.\n"); AUDIO_DAEMON->sfx_mud("thunder.wav"); foreach( who : users() ) { set_actor( this_player() ); set_target( victim ); set_listener( who ); msg_object(who,"~CTITFROTZ! ~CBRT~Name ~verbstrike ~targ with lightning.~CDEF"); } victim->set_env_var( "cause_of_death", "was frotzed by "+capitalize(this_player()->query_name())+"." ); victim->add_hp( this_player()->query_level() / -4); return 1; }
int BsdAttachListener::init() { char path[UNIX_PATH_MAX]; // socket file char initial_path[UNIX_PATH_MAX]; // socket file during setup int listener; // listener socket (file descriptor) // register function to cleanup ::atexit(listener_cleanup); int n = snprintf(path, UNIX_PATH_MAX, "%s/.java_pid%d", os::get_temp_directory(), os::current_process_id()); if (n < (int)UNIX_PATH_MAX) { n = snprintf(initial_path, UNIX_PATH_MAX, "%s.tmp", path); } if (n >= (int)UNIX_PATH_MAX) { return -1; } // create the listener socket listener = ::socket(PF_UNIX, SOCK_STREAM, 0); if (listener == -1) { return -1; } // bind socket struct sockaddr_un addr; addr.sun_family = AF_UNIX; strcpy(addr.sun_path, initial_path); ::unlink(initial_path); int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); if (res == -1) { ::close(listener); return -1; } // put in listen mode, set permissions, and rename into place res = ::listen(listener, 5); if (res == 0) { RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res); if (res == 0) { // make sure the file is owned by the effective user and effective group // (this is the default on linux, but not on mac os) RESTARTABLE(::chown(initial_path, geteuid(), getegid()), res); if (res == 0) { res = ::rename(initial_path, path); } } } if (res == -1) { ::close(listener); ::unlink(initial_path); return -1; } set_path(path); set_listener(listener); return 0; }
int main( string str ) { string pname, comm; object ob; if(this_player()->query_level() < WIZLEVEL) { msg("==> [Error] Access denied"); return 0; } if(!str || sscanf(str, "%s %s", pname, comm) != 2) { msg("==> [Format] force player command"); return 1; } ob = find_player(pname); if( !ob ) ob = find_living(pname); if(!ob) { msg("==> [Error] Could not find that player or creature."); return 1; } if(ob->query_level() < this_player()->query_level() || this_player()->query_level() >= ADMLEVEL ) { set_actor( this_player() ); set_listener( ob ); msg_object(ob, "~Name forces you to "+comm+"."); msg("You force them to "+comm); ob->receive( "\n"+this_player()->query_specific()+" forces you to '"+comm+"':\n" ); command(comm, ob); if( ob ) ob->receive( ob->query_prompt() ); } else { msg("==> [Error] Access denied."); set_actor( this_player() ); set_listener( ob ); msg_object(ob, "~CWRN~Name tried to force you to ~CCOM"+comm+"~CWRN.~CDEF"); msg("~CWRNThey have been notified of your attempt.~CDEF"); } return 1; }
void DatalinkPrivate::attachToBuiltInTopic( DDSDataReaderListener* listener, char const * topicName, DDS_StatusMask mask ) { auto builtin_subscriber = participant->get_builtin_subscriber(); // builtin_reader for new publications: topic DDS_SUBSCRIPTION_TOPIC_NAME auto builtin_sub_reader = builtin_subscriber->lookup_datareader(topicName); if (builtin_sub_reader == nullptr) { qCritical("error getting builtin_sub_reader\n"); return; } DDS_ReturnCode_t retcode = builtin_sub_reader->set_listener(listener, mask); if (retcode != DDS_RETCODE_OK) { qCritical("set_listener builtin_sub_reader error %d\n", retcode); return; } DDS_DataReaderQos defReaderQoS; builtin_sub_reader->get_qos(defReaderQoS); if( defReaderQoS.liveliness.lease_duration.is_infinite() ) { qDebug() << "For topic" << topicName <<"the built-in reader liveliness lease duration is INFINITY."; } else { qDebug() << "For topic" << topicName <<"the built-in reader liveliness lease duration is" << QString("%1.%2") .arg(defReaderQoS.liveliness.lease_duration.sec) .arg(defReaderQoS.liveliness.lease_duration.nanosec) << "seconds."; } }
dmz::Boolean dmz::AudioModuleFMOD::destroy_listener (const Handle ListenerHandle) { Boolean result (False); if (_system) { ListenerStruct *listener = _listenerHandleTable.lookup (ListenerHandle); if (listener) { Int32 numListeners = _listenerHandleTable.get_count (); if (listener->index == (numListeners - 1)) { // Can simply reduce listener count in FMOD without rearranging indices FMOD_RESULT fmodResult (FMOD_OK); Boolean muteSuccess (True); // FMOD requires at least one listener if (numListeners > 1) { fmodResult = _system->set3DNumListeners (numListeners - 1); } else { // To simulate a lack of any listeners, mute all sounds muteSuccess = set_mute_all_state (True); } if (_error_check ("Destroying a Listener", fmodResult) && muteSuccess) { // Delete the listener _listenerHandleTable.remove (ListenerHandle); _listenerNameTable.remove (listener->Name); _listenerIndexTable.remove (listener->index); delete listener; listener = 0; result = True; } } else { // FMOD only allows the adjustment of the total number of listeners, so // we must swap the listener to be deleted with the last listener and // then reduce the total number of listeners in FMOD // Get last listener ListenerStruct *lastListener = _listenerIndexTable.lookup (numListeners - 1); if (lastListener) { // Get the position and orientation of listener to be moved Vector copiedPosition; Matrix copiedOrientation; Vector copiedVelocity; if (get_listener ( listener->get_handle (), copiedPosition, copiedOrientation, copiedVelocity)) { // Change the FMOD listener index to the index of the listener to be // deleted lastListener->index = listener->index; // Override the listener attributes in the index location of the deleted // listener if (set_listener ( lastListener->get_handle (), copiedPosition, copiedOrientation, copiedVelocity)) { // Reduce reduce listener count in FMOD to erase the old data // of the now duplicated listener at the end. FMOD_RESULT fmodResult ( _system->set3DNumListeners (numListeners - 1)); if (_error_check ("Destroying a Listener", fmodResult)) { // Delete the listener _listenerHandleTable.remove (ListenerHandle); _listenerNameTable.remove (listener->Name); _listenerIndexTable.remove (listener->index); delete listener; listener = 0; result = True; } } } } } } } return result; }
/// Dig in the direction given in \a param, offsetting the player. int on_dig( int param ) { string *res; int i, pos; object *picks; if( !param ) return 0; // Doesn't apply picks = filter(all_inventory(this_player()), (: ($1->query_held() && HAS_ASPECT($1, C_PICKAXE)) :)); if ( !sizeof( picks )) { msg("You need to be holding a pickaxe."); return 0; } pos = OFFSET_C(this_player()->query_coord(), param); // Hmm ... this'll break horribly if there are multiple // diggable things in the room, but I can't think of // a good solution right now, since validity checking has // to be procrastinated. if( !query_has_spot(pos) ) { msg("Digging that direction didn't work."); return 0; // Action disappears if you moved. } this_player()->set_coord(pos); this_object()->remove_spot(pos); environment(this_player())->clear_map(); this_player()->msg_local("~CACT~Name ~verbdig into the rock.~CDEF"); this_player()->add_readiness( -500 ); res = query_resource_types(); if( res ) { object ob; i = 0; while( random(2) && i < sizeof(res) ) i++; if( i == sizeof(res) ) i = 0; if( !res[i] ) { msg("There was nothing interesting here."); } else { ob = clone_object( res[i] ); // TODO: chance of getting more of the item // ob->set_quantity(result) ob->move( this_player() ); set_target(ob); set_listener(this_player()); msg("You get ~targ."); // chance of digging a gem if( random(200)-1 < 2*this_player()->query_skill("knowledge.geology") ) { string gemname = "/daemon/gemstone"->query_gem_name(ob->query_name()); if( gemname ) { ob = clone_object( "/econ/gem/"+gemname ); // TODO: chance of getting more than one in terribly rich veins ob->move(this_player()); msg("You also got ~targ!"); } } } } // this should probably be dependant on ob's durability, // but we don't have a stat for that picks[0]->add_condition(-1); if (sizeof(query_spots()) <= 0) destruct(this_object()); return 1; }
int LinuxAttachListener::init() { char path[PATH_MAX+1]; // socket file int listener; // listener socket (file descriptor) // register function to cleanup ::atexit(listener_cleanup); #ifdef AZ_PROXIED char buffer[O_BUFLEN]; int res = proxy_invoke_remote_VMAttachInitialize(StartAttachListener, &listener, &path[0], os::get_current_directory(buffer, sizeof(buffer)), os::get_temp_directory(),os::current_process_id()); if (res == -1) { RESTARTABLE(VM_ATTACH_CLOSE(listener), res); ::unlink(path); set_path(NULL); return -1; } else { set_path(path); set_listener(listener); } #else // !AZ_PROXIED // create the listener socket listener = ::socket(PF_UNIX, SOCK_STREAM, 0); if (listener == -1) { return -1; } int res = -1; struct sockaddr_un addr; addr.sun_family = AF_UNIX; // FIXME: Prior to b39 the tool-side API expected to find the well // known file in the working directory. To allow this libjvm.so work with // a pre-b39 SDK we create it in the working directory if // +StartAttachListener is used is used. All unit tests for this feature // currently used this flag. Once b39 SDK has been promoted we can remove // this code. if (StartAttachListener) { sprintf(path, ".java_pid%d", os::current_process_id()); strcpy(addr.sun_path, path); ::unlink(path); res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); } if (res == -1) { sprintf(path, "%s/.java_pid%d", os::get_temp_directory(), os::current_process_id()); strcpy(addr.sun_path, path); ::unlink(path); res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); } if (res == -1) { RESTARTABLE(VM_ATTACH_CLOSE(listener),res); return -1; } set_path(path); // put in listen mode and set permission if ((::listen(listener, 5) == -1) || (::chmod(path, S_IREAD|S_IWRITE) == -1)) { RESTARTABLE(VM_ATTACH_CLOSE(listener),res); ::unlink(path); set_path(NULL); return -1; } set_listener(listener); #endif // !AZ_PROXIED return 0; }