bool is_lpc_available(unsigned int target_residency)
{
	if (!lpc_enabled)
		return false;

	if (is_busy(target_residency, cpu_online_mask))
		return false;

	if (check_hw_status(lpc_regs, lpc_reg_num))
		return false;

	if (exynos_lpc_prepare())
		return false;

	if (pwm_check_enable_cnt())
		return false;

#if defined(CONFIG_GPS_BCMxxxxx)
	if (check_gps_op())
		return false;
#endif

	if (check_cp_status())
		return false;

	return true;
}
Beispiel #2
0
void
on_cvs_add_response(GtkDialog* dialog, gint response, CVSData* data)
{
	if (is_busy(data->plugin, dialog))
		return;
	
	switch (response)
	{
	case GTK_RESPONSE_OK:
	{
		GtkWidget* binary = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_binary"));
		GtkWidget* fileentry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_add_filename"));
	
		const gchar* filename = gtk_entry_get_text(GTK_ENTRY(fileentry));
		if (!check_filename(dialog, filename))
			break;
		
		anjuta_cvs_add(ANJUTA_PLUGIN(data->plugin), filename, 
			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(binary)), NULL); 
		
		gtk_widget_destroy(GTK_WIDGET(dialog));
		cvs_data_free(data);
		break;
	}
	default:
		gtk_widget_destroy (GTK_WIDGET(dialog));
		cvs_data_free(data);
	}
}
Beispiel #3
0
string ask_job()
{
        object obj, place, *inv, me = this_player();

        if( is_fighting() || is_busy() )
                return "我正忙着。";

        if( (string)me->query("gender") != "男性" )
                return "阿弥陀佛!善哉!善哉!女施主莫开老纳的玩笑。";

        if( (string)me->query("class") != "bonze" )
                return "阿弥陀佛!善哉!善哉!施主不是佛门弟子,还是请回吧。";

        if( (int)me->query_skill("buddhism", 1) < 120 )
                return "本寺只延请高僧前来讲经说佛。";

        if( day_event() != "event_dawn" )
                return "本寺撞钟诵经时辰已过," + RANK_D->query_respect(me) + "下次再来吧。";

        if( me->query_condition("lyjob") )
                return RANK_D->query_respect(me) + "已经在讲经说佛了。";

        command("nod");
        me->apply_condition("lyjob", 3 + random(3));

        if( random((int)me->query_temp("lypoint")) > 1
        && !(present("jiasha", me)) ) {
                obj = new("/d/hangzhou/obj/jiasha");
                obj->move(me);
                message_vision("旁边一僧将一件红衣袈裟披在$N身上。\n", me);
        }
Beispiel #4
0
nb_smart_fight()
{
	object target=select_opponent();
	if (is_busy())
		return;
	ccommand("perform zonghengtianxia");
	return;
}
Beispiel #5
0
void
on_cvs_commit_response(GtkDialog* dialog, gint response, CVSData* data)
{
	if (is_busy(data->plugin, dialog))
		return;
	
	switch (response)
	{
	case GTK_RESPONSE_OK:
	{
		gchar* log;
		const gchar* rev;
		GtkWidget* logtext;
		GtkWidget* revisionentry;
		GtkWidget* norecurse;
		GtkWidget* fileentry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_commit_filename"));
		const gchar* filename = gtk_entry_get_text(GTK_ENTRY(fileentry));
				
		logtext = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_commit_log"));
		log = get_log_from_textview(logtext);
		if (!g_utf8_strlen(log, -1))
		{
			gint result;
			GtkWidget* dlg = gtk_message_dialog_new(GTK_WINDOW(dialog), 
				GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO,
				GTK_BUTTONS_YES_NO, 
				_("Are you sure that you want to pass an empty log message?"));
			result = gtk_dialog_run(GTK_DIALOG(dlg));
			if (result == GTK_RESPONSE_NO)
			{
				gtk_widget_hide(dlg);
				gtk_widget_destroy(dlg);
				break;
			}
			gtk_widget_destroy(dlg);
		}
		
		revisionentry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_commit_revision"));
		rev = gtk_entry_get_text(GTK_ENTRY(revisionentry));

		norecurse = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_commit_norecurse"));
		
		if (!check_filename(dialog, filename))
			break;	
		
		anjuta_cvs_commit(ANJUTA_PLUGIN(data->plugin), filename, log, rev,
			!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(norecurse)), NULL);		
		
		cvs_data_free(data);
		gtk_widget_destroy(GTK_WIDGET(dialog));
		break;
		}
	default:
		gtk_widget_destroy (GTK_WIDGET(dialog));
		cvs_data_free(data);
		break;
	}
}
Beispiel #6
0
void
on_cvs_diff_response(GtkDialog* dialog, gint response, CVSData* data)
{
	if (is_busy(data->plugin, dialog))
		return;
	
	switch (response)
	{
	case GTK_RESPONSE_OK:
	{
		const gchar* rev;
		int diff_type_nr;
		gboolean unified = FALSE;
		gboolean patch_style = FALSE;
		
		GtkWidget* norecurse;
		GtkWidget* revisionentry;
		GtkWidget* diff_type;
		GtkWidget* unified_diff;
		
		GtkWidget* fileentry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_diff_filename"));
		const gchar* filename = g_strdup(gtk_entry_get_text(GTK_ENTRY(fileentry)));
		

		revisionentry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_diff_revision"));
		rev = gtk_entry_get_text(GTK_ENTRY(revisionentry));
		norecurse = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_diff_norecurse"));
		
		diff_type = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_diff_type"));
		unified_diff = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_unified"));
		diff_type_nr = gtk_combo_box_get_active(GTK_COMBO_BOX(diff_type));
		if (diff_type_nr == DIFF_PATCH)
		{
			unified = TRUE;
			/* FIXME: rdiff do not take -u in my cvs */
			/* diff = "rdiff"; */
		}
		
		if (!check_filename(dialog, filename))
			break;	
		
		anjuta_cvs_diff(ANJUTA_PLUGIN(data->plugin), filename, rev, 
			!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(norecurse)), patch_style,
			unified, NULL);
		
		cvs_data_free(data);
		gtk_widget_destroy (GTK_WIDGET(dialog));	
		break;
		}
	default:
		cvs_data_free(data);
		gtk_widget_destroy (GTK_WIDGET(dialog));	
		break;
	}
}
Beispiel #7
0
int heal_up()
{
        if(environment() && !is_fighting() && !is_busy()
                && query("startroom") 
                && file_name(environment()) != query("startroom")) {
//              command("say ok");
                return_home(query("startroom"));
                return 1;
        }
        return ::heal_up() + 1;
}     
Beispiel #8
0
void PngyuMainWindow::dragEnterEvent( QDragEnterEvent *event )
{
  if( is_busy() )
  {
    return;
  }

  if( event->mimeData()->hasUrls() )
  {
    event->accept();
  }
}
bool BrowserWrapper::Wait() {
	bool is_navigating = true;

	//std::cout << "Navigate Events Completed." << std::endl;
	this->is_navigation_started_ = false;

	HWND dialog = this->GetActiveDialogWindowHandle();
	if (dialog != NULL) {
		//std::cout "Found alert. Aborting wait." << std::endl;
		this->wait_required_ = false;
		return true;
	}

	// Navigate events completed. Waiting for browser.Busy != false...
	is_navigating = this->is_navigation_started_;
	VARIANT_BOOL is_busy(VARIANT_FALSE);
	HRESULT hr = this->browser_->get_Busy(&is_busy);
	if (is_navigating || FAILED(hr) || is_busy) {
		//std::cout << "Browser busy property is true.\r\n";
		return false;
	}

	// Waiting for browser.ReadyState == READYSTATE_COMPLETE...;
	is_navigating = this->is_navigation_started_;
	READYSTATE ready_state;
	hr = this->browser_->get_ReadyState(&ready_state);
	if (is_navigating || FAILED(hr) || ready_state != READYSTATE_COMPLETE) {
		//std::cout << "readyState is not 'Complete'.\r\n";
		return false;
	}

	// Waiting for document property != null...
	is_navigating = this->is_navigation_started_;
	CComQIPtr<IDispatch> document_dispatch;
	hr = this->browser_->get_Document(&document_dispatch);
	if (is_navigating && FAILED(hr) && !document_dispatch) {
		//std::cout << "Get Document failed.\r\n";
		return false;
	}

	// Waiting for document to complete...
	CComPtr<IHTMLDocument2> doc;
	hr = document_dispatch->QueryInterface(&doc);
	if (SUCCEEDED(hr)) {
		is_navigating = this->IsDocumentNavigating(doc);
	}

	if (!is_navigating) {
		this->wait_required_ = false;
	}

	return !is_navigating;
}
Beispiel #10
0
MTNJOB *mtnexec_wait()
{
  int i;
  while(is_busy() && is_loop){
    mtnexec_poll();
  }
  if(is_loop){
    for(i=0;i<ctx->job_max;i++){
      if(ctx->job[i].pid == 0){
        return(&(ctx->job[i]));
      }
    }
  }
  return(NULL);
}
Beispiel #11
0
void
on_cvs_update_response(GtkDialog* dialog, gint response, CVSData* data)
{
	if (is_busy(data->plugin, dialog))
		return;
	
	switch (response)
	{
	case GTK_RESPONSE_OK:
	{
		const gchar* revision;
		
		GtkWidget* createdir;
		GtkWidget* removedir;
		GtkWidget* norecurse;
		GtkWidget* removesticky;
		GtkWidget* revisionentry;
		GtkWidget* fileentry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_update_filename"));
		const gchar* filename = g_strdup(gtk_entry_get_text(GTK_ENTRY(fileentry)));
		
		norecurse = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_update_norecurse"));
		removedir = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_removedir"));
		createdir = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_createdir"));
		revisionentry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_update_revision"));
		revision = gtk_entry_get_text(GTK_ENTRY(revisionentry));
		removesticky = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_removesticky"));
				
		if (!check_filename(dialog, filename))
			break;	
		
		anjuta_cvs_update(ANJUTA_PLUGIN(data->plugin), filename, 
			!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(norecurse)),
			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(removedir)),		
			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(createdir)),
			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(removesticky)), 
			revision, NULL);
		
		cvs_data_free(data);
		gtk_widget_destroy(GTK_WIDGET(dialog));
		break;
		}
	default:
		gtk_widget_destroy(GTK_WIDGET(dialog));
		cvs_data_free(data);
		break;
	}
}
Beispiel #12
0
void
on_cvs_remove_response(GtkDialog* dialog, gint response, CVSData* data)
{
	GFile* file;

	if (is_busy(data->plugin, dialog))
		return;
	
	switch (response)
	{
	case GTK_RESPONSE_OK:
	{
		GtkWidget* fileentry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_remove_filename"));
		const gchar* filename = gtk_entry_get_text(GTK_ENTRY(fileentry));
		
		if (!check_filename(dialog, filename))
			break;

		file = g_file_new_for_uri(gtk_entry_get_text(GTK_ENTRY(fileentry)));
		if (!g_file_delete(file, NULL, NULL))
		{
			anjuta_util_dialog_error
				(GTK_WINDOW(dialog),_("Unable to delete file"), NULL);
			gtk_widget_destroy(GTK_WIDGET(dialog));
			cvs_data_free(data);
			break;
		}
		g_object_unref(G_OBJECT(file));
	
		anjuta_cvs_remove(ANJUTA_PLUGIN(data->plugin), filename, NULL);
		gtk_widget_destroy (GTK_WIDGET(dialog));
		cvs_data_free(data);
		break;
		}
	default:
		cvs_data_free(data);
		gtk_widget_destroy (GTK_WIDGET(dialog));
	}
}
int determine_cpd(int index, int c2_index, unsigned int cpu,
		  unsigned int target_residency)
{
	exynos_cpu.power_down(cpu);

	if (index == c2_index)
		return c2_index;

#ifdef CONFIG_ARM_EXYNOS_SMP_CPUFREQ
	if (disabled_cluster_power_down)
		return c2_index;
#endif

	spin_lock(&cpd_lock);

	update_cpd_state(true, cpu);

	if (is_lpc_available(target_residency)) {
		set_lpc_flag();
		s3c24xx_serial_fifo_wait();
	}

	if (is_in_boot_cluster(cpu)) {
		index = c2_index;
		goto unlock;
	}

	if (is_busy(target_residency, cpu_coregroup_mask(cpu)))
		index = c2_index;
	else
		exynos_cpu_sequencer_ctrl(true);

unlock:
	spin_unlock(&cpd_lock);

	return index;
}
Beispiel #14
0
bool Browser::IsBusy() {
  VARIANT_BOOL is_busy(VARIANT_FALSE);
  HRESULT hr = this->browser_->get_Busy(&is_busy);
  return SUCCEEDED(hr) && is_busy == VARIANT_TRUE;
}
Beispiel #15
0
void heart_beat() {
    int wimpy_ratio, to_wimpy, cnd_flag, oldbusy;
    mapping my;
    object ob;
    string savemyass;

    if(!this_object()) {
        return;
    }

//	command("say start heart_beat");
//	command("say i am busy"+(string)query_busy());
    if (query_temp("in_heart_beat"))
        return;

    my = query_entire_dbase();

    // If we are dying because of mortal wounds?
    if( my["eff_kee"] < 0 || my["eff_sen"] < 0 || my["eff_gin"] < 0
            || my["kee"] < -2 * my["dur"]  || my["sen"] < -2 * my["dur"] || my["gin"] < -2 * my["dur"]) {
        remove_all_enemy();
        die();
        return;
    }

    // If we are unconcious, just return;
    if(query_temp("is_unconcious"))  {
        return;
    }

    // If we're dying or falling unconcious?
    if( my["kee"] < 0 || my["sen"] < 0 || my["gin"] < 0) {
        remove_all_enemy();
        unconcious();
        return;
    }


// let NPC do something in fight that won't be affected by busy...e.g talk
//	all actions in nb_chat will be executed in fight. They should never have busy()
//	as a consequence and they should be allowed to appear at same time.

    if (is_fighting())
        if(objectp(this_object()) && !userp(this_object())) {
            this_object()->nb_chat();
            if(!this_object()) {
                return;
            }
        }

    if (!is_busy()) {

        // (1) Do attack or clean up enemy if we have fleed.
        if(is_fighting()) {
            // Hey, NPC's 心神 doesn't need to be reduced here, let's save some resource
            // my["sen"]--;
            attack();
        }

        // (2) chat() may do anything -- include destruct(this_object())
        if(objectp(this_object()) && !userp(this_object())) {
            this_object()->chat();
            if(!this_object()) {
                return;
            }
        }
    }

    // If busy, continue action and return here.
    if(is_busy()) {
        continue_action();
        return;
    }

    if(tick--) {
        return;
    } else {
        tick = 5 + random(10);
    }

    cnd_flag = update_condition();
    if (!living(this_object())) return;

    // If we are compeletely in peace, turn off heart beat.
    // heal_up() must be called prior to other two to make sure it is called
    // because the && operator is lazy :P

    if( ((cnd_flag & CND_NO_HEAL_UP) || !heal_up()) && !is_fighting()
            && !interactive(this_object())) {
        if(environment()) {
            ob = first_inventory(environment());
            while(ob && !interactive(ob)) {
                ob = next_inventory(ob);
            }
        }
        if(!ob && !query("ALWAYS_ACTIVE")) set_heart_beat(0);
    }
    if(!this_object()) return;
    if(!interactive(this_object())) return;

}
Beispiel #16
0
void PngyuMainWindow::execute_compress_all( bool image_optim_enabled )
{
  if( is_busy() )
  {
    return;
  }

  // disable ui operation temporary
  set_busy_mode( true );

  ui->widget_executing->setVisible( true );
  ui->pushButton_exec->setVisible( false );
  ui->pushButton_stop_exec->setVisible( true );


  clear_compress_result();

  const bool b_overwrite_enable = file_overwrite_enabled();
  const bool b_force_execute_if_negative = is_force_execute_if_negative_enabled();

  const pngyu::PngquantOption &option = make_pngquant_option( QString() );
  const QString &pngquant_path = executable_pngquant_path();

  QQueue<pngyu::CompressQueueData> queue;

  QTableWidget *table_widget = file_list_table_widget();
  const int row_count = table_widget->rowCount();
  for( int row = 0; row < row_count; ++row )
  { // file list loop

    const QTableWidgetItem * const absolute_path_item = table_widget->item( row, pngyu::COLUMN_ABSOLUTE_PATH );
    if( ! absolute_path_item )
    {
      qWarning() << "Item is null. row: " << row;
      continue;
    }

    const QString &src_path = absolute_path_item->text();
    const QString &dst_path = make_output_file_path_string( src_path );

    pngyu::CompressQueueData data;
    data.src_path = src_path;
    data.dst_path = dst_path;
    data.pngquant_path = pngquant_path;
    data.pngquant_option = option;
    data.overwrite_enabled = b_overwrite_enable;
    data.force_execute_if_negative = b_force_execute_if_negative;
    data.table_widget = table_widget;
    data.table_row = row;

    queue.enqueue( data );

  } // end of file list loop

  const int n_thread = num_thread();

  QVector<ExecuteCompressWorkerThread*> workers;

  QMutex mutex;
  for( int i = 0; i < n_thread; ++i )
  {
    ExecuteCompressWorkerThread *worker = new ExecuteCompressWorkerThread();

    worker->set_queue_ptr( &queue, &mutex );
    workers.push_back( worker );
  }

  QApplication::processEvents();

  for( int i = 0; i < n_thread; ++i )
  {
    workers[i]->start( QThread::HighPriority );
  }

  QApplication::processEvents();

  for( int i = 0; i < n_thread; ++i )
  {
    ExecuteCompressWorkerThread *worker = workers[i];

    while( ! worker->wait(30) )
    {
      if( m_stop_request )
      {
        worker->stop_request();
      }
      ui->spinner_exec->redraw();
      ui->spinner_exec->update();
      QApplication::processEvents();
    }
  }


  QList<pngyu::CompressResult> result_list;

  for( int i = 0; i < n_thread; ++i )
  {
    ExecuteCompressWorkerThread *worker = workers[i];

    result_list += worker->compress_results();
  }

  for( int i = 0; i < n_thread; ++i )
  {
    ExecuteCompressWorkerThread *worker = workers[i];
    delete worker;
    workers[i] = 0;
  }

  workers.clear();


  // result
  qint64 total_saved_size = 0;
  QStringList succeed_src_filepaths;
  QStringList succeed_dst_filepaths;

  foreach( const pngyu::CompressResult &res, result_list )
  {
    if( res.result )
    {
      succeed_src_filepaths.push_back( res.src_path );
      succeed_dst_filepaths.push_back( res.dst_path );
      total_saved_size += res.src_size - res.dst_size;
    }
  }

  { // show result status bar
    const QString size_string = total_saved_size > 500 * 1024 ?
          pngyu::util::size_to_string_mb( total_saved_size ) :
          pngyu::util::size_to_string_kb( total_saved_size );
    ui->statusBar->showMessage( tr("Total %1 saved").arg(size_string) );
  }

  if( image_optim_enabled )
  {
    pngyu::util::open_with_mac_app( succeed_dst_filepaths, executable_image_optim_path() );
  }

  set_busy_mode( false );

  ui->widget_executing->setVisible( false );
  ui->pushButton_stop_exec->setVisible( false );
  ui->pushButton_exec->setVisible( true );

}
Beispiel #17
0
void
on_cvs_import_response(GtkDialog* dialog, gint response, CVSData* data)
{
	gchar* dirname = NULL;
	if (is_busy(data->plugin, dialog))
		return;
	
	switch (response)
	{
		case GTK_RESPONSE_OK:
		{
			GtkWidget* username;
			GtkWidget* password;
			GtkWidget* cvsroot_entry;
			GtkWidget* module_entry;
			GtkWidget* vendortag;
			GtkWidget* releasetag;
			GtkWidget* logtext;
			GtkWidget* typecombo;
			GtkFileChooser* dir;
			gchar* log;
			
			username = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_username"));
			password = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_password"));
			
			cvsroot_entry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_cvsroot"));
			if (!check_entry(dialog, cvsroot_entry, _("CVSROOT")))
				break;
			module_entry = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_module"));
			if (!check_entry(dialog, module_entry, _("Module")))
				break;
			vendortag = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_vendor"));
			if (!check_entry(dialog, vendortag, _("Vendor")))
				break;
			releasetag = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_release"));
			if (!check_entry(dialog, releasetag, _("Release")))
				break;
			typecombo = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_server_type"));
			dir = GTK_FILE_CHOOSER(gtk_builder_get_object(data->bxml, "cvs_rootdir"));
			dirname = gtk_file_chooser_get_filename (dir);
			if (!dirname)
				break;
			
			logtext = GTK_WIDGET(gtk_builder_get_object(data->bxml, "cvs_import_log"));
			log = get_log_from_textview(logtext);
			if (!strlen(log))
			{
				gint result;
				GtkWidget* dlg = gtk_message_dialog_new(GTK_WINDOW(dialog), 
				GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO,
				GTK_BUTTONS_YES_NO, 
				_("Are you sure that you do not want a log message?"));
				result = gtk_dialog_run(GTK_DIALOG(dlg));
				gtk_widget_destroy(dlg);
				if (result == GTK_RESPONSE_NO)
					break;
			}
			
			anjuta_cvs_import(ANJUTA_PLUGIN(data->plugin),
				dirname,
				gtk_entry_get_text(GTK_ENTRY(cvsroot_entry)),
				gtk_entry_get_text(GTK_ENTRY(module_entry)),
				gtk_entry_get_text(GTK_ENTRY(vendortag)),
				gtk_entry_get_text(GTK_ENTRY(releasetag)),
				log,
				gtk_combo_box_get_active(GTK_COMBO_BOX(typecombo)),
				gtk_entry_get_text(GTK_ENTRY(username)),
				gtk_entry_get_text(GTK_ENTRY(password)), NULL);
			
			cvs_data_free(data);
			gtk_widget_destroy(GTK_WIDGET(dialog));
			break;
		}
		default:
			cvs_data_free(data);
			gtk_widget_destroy(GTK_WIDGET(dialog));
			break;
	}
	g_free(dirname);
}
Beispiel #18
0
static void print_status(struct MPContext *mpctx)
{
    struct MPOpts *opts = mpctx->opts;

    update_window_title(mpctx, false);
    update_vo_playback_state(mpctx);

    if (!opts->use_terminal)
        return;

    if (opts->quiet || !mpctx->playback_initialized || !mpctx->playing_msg_shown)
    {
        term_osd_set_status(mpctx, "");
        return;
    }

    if (opts->status_msg) {
        char *r = mp_property_expand_escaped_string(mpctx, opts->status_msg);
        term_osd_set_status(mpctx, r);
        talloc_free(r);
        return;
    }

    char *line = NULL;

    // Playback status
    if (is_busy(mpctx)) {
        saddf(&line, "(...) ");
    } else if (mpctx->paused_for_cache && !opts->pause) {
        saddf(&line, "(Buffering) ");
    } else if (mpctx->paused) {
        saddf(&line, "(Paused) ");
    }

    if (mpctx->d_audio)
        saddf(&line, "A");
    if (mpctx->d_video)
        saddf(&line, "V");
    saddf(&line, ": ");

    // Playback position
    sadd_hhmmssff_u(&line, get_playback_time(mpctx), mpctx->opts->osd_fractions);

    double len = get_time_length(mpctx);
    if (len >= 0) {
        saddf(&line, " / ");
        sadd_hhmmssff(&line, len, mpctx->opts->osd_fractions);
    }

    sadd_percentage(&line, get_percent_pos(mpctx));

    // other
    if (opts->playback_speed != 1)
        saddf(&line, " x%4.2f", opts->playback_speed);

    // A-V sync
    if (mpctx->d_audio && mpctx->d_video && mpctx->sync_audio_to_video) {
        saddf(&line, " A-V:%7.3f", mpctx->last_av_difference);
        if (fabs(mpctx->total_avsync_change) > 0.05)
            saddf(&line, " ct:%7.3f", mpctx->total_avsync_change);
    }

#if HAVE_ENCODING
    double position = get_current_pos_ratio(mpctx, true);
    char lavcbuf[80];
    if (encode_lavc_getstatus(mpctx->encode_lavc_ctx, lavcbuf, sizeof(lavcbuf),
            position) >= 0)
    {
        // encoding stats
        saddf(&line, " %s", lavcbuf);
    } else
#endif
    {
        // VO stats
        if (mpctx->d_video) {
            if (mpctx->display_sync_active) {
                saddf(&line, " DS: %d/%"PRId64, mpctx->mistimed_frames_total,
                      vo_get_delayed_count(mpctx->video_out));
            }
            int64_t c = vo_get_drop_count(mpctx->video_out);
            if (c > 0 || mpctx->dropped_frames_total > 0) {
                saddf(&line, " Dropped: %"PRId64, c);
                if (mpctx->dropped_frames_total)
                    saddf(&line, "/%d", mpctx->dropped_frames_total);
            }
        }
    }

    if (mpctx->demuxer) {
        int64_t fill = -1;
        demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &fill);
        if (fill >= 0) {
            saddf(&line, " Cache: ");

            struct demux_ctrl_reader_state s = {.ts_duration = -1};
            demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s);

            if (s.ts_duration < 0) {
                saddf(&line, "???");
            } else {
                saddf(&line, "%2ds", (int)s.ts_duration);
            }
            if (fill >= 1024 * 1024) {
                saddf(&line, "+%lldMB", (long long)(fill / 1024 / 1024));
            } else {
                saddf(&line, "+%lldKB", (long long)(fill / 1024));
            }
        }
    }
Beispiel #19
0
void heart_beat()
{
	int wimpy_ratio, cnd_flag;
	mapping my;
	object ob;

	my = query_entire_dbase();

	// If we are dying because of mortal wounds?
	if( my["eff_kee"] < 0 || my["eff_sen"] < 0 || my["eff_gin"] < 0) {
		remove_all_enemy();
		die();
		return;
	}

	// If we're dying or falling unconcious?
	if( my["kee"] < 0 || my["sen"] < 0 || my["gin"] < 0) {
		remove_all_enemy();
		if( !living(this_object()) ) die();
		else unconcious();
		return;
	}

	// Do attack if we are fighting.
	if( is_busy() ) {
		continue_action();
		// We don't want heart beat be halt eventually, so return here.
		return;
	} else {
		// Is it time to flee?
		if( is_fighting()
		&&	intp(wimpy_ratio = (int)query("env/wimpy"))
		&&	wimpy_ratio > 0
		&&	(	my["kee"] * 100 / my["max_kee"] <= wimpy_ratio
			||	my["sen"] * 100 / my["max_sen"] <= wimpy_ratio
			||	my["gin"] * 100 / my["max_gin"] <= wimpy_ratio) )
			GO_CMD->do_flee(this_object());
		// Do attack or clean up enemy if we have fleed.
		attack();
	}

	if( !userp(this_object()) ) {
		this_object()->chat();
		// chat() may do anything -- include destruct(this_object())
		if( !this_object() ) return;	
	}

	if( tick--  ) return;
	else tick = 5 + random(10);

	cnd_flag = update_condition();

	// If we are compeletely in peace, turn off heart beat.
	// heal_up() must be called prior to other two to make sure it is called
	// because the && operator is lazy :P
	if( ((cnd_flag & CND_NO_HEAL_UP) || !heal_up())
	&&	!is_fighting() 
	&&	!interactive(this_object())) {
		if( environment() ) {
			ob = first_inventory(environment());
			while(ob && !interactive(ob))
				ob = next_inventory(ob);
		}
		if( !ob ) set_heart_beat(0);
	}

	if( !interactive(this_object()) ) return;

	// Make us a bit older. Only player's update_age is defined.
	// Note: update_age() is no need to be called every heart_beat, it
	//       remember how much time has passed since last call.
	this_object()->update_age();

	if(query_idle(this_object()) > IDLE_TIMEOUT)
		this_object()->user_dump(DUMP_IDLE);
}
Beispiel #20
0
void heart_beat()
{
        int t;
        int period;
        int wimpy_ratio, cnd_flag;
        mapping my;
        object ob;
	object me;
	string prompt;
	int is_player;

	me = this_object();
        my = query_entire_dbase();

        if (userp(me) && living(me) && mapp(my["env"]))
        {
                // update prompt
		prompt = my["env"]["prompt"];
                if ((prompt == "time" || prompt == "mud" || prompt == "hp") &&
		    is_waiting_command() && ! me->is_attach_system())
                    
                {
                        write_prompt();
                }
                
        }

        // If we're dying or falling unconcious?
        if (my["qi"] < 0 || my["jing"] < 0)
        {
                if (! living(me)) die();
                else unconcious();

                // Why does the living test? Because
                // The wizard may set immortal but his
                // qi was -1, so I don't want return,
                // or the continue_action will never be
                // called in such case.
                if (! me || ! living(me))
                        return;
        }

        if (is_p_busy())
        {
                continue_p_busy();
        }
        
        // Do attack if we are fighting.
        if (is_busy())
        {
                continue_action();
                // We don't want heart beat be halt eventually, so return here.
        } else
	if (living(me))
        {
                string apply;
                object apply_ob;

                // Is it time to flee?
                if (is_fighting() &&
                   intp(wimpy_ratio = (int)query("env/wimpy")) &&
                   wimpy_ratio > 0 &&
                   (my["qi"] * 100 / my["max_qi"] <= wimpy_ratio ||
                    my["jing"] * 100 / my["max_jing"] <= wimpy_ratio))
                {
                        if (stringp(apply = query("env/wimpy_apply")) &&
                            objectp(apply_ob = present(apply, me)) &&
                            apply_ob->query("can_apply_for_wimpy"))
                        {
                                apply_ob->apply_for_wimpy(this_object());
                        } else
                                GO_CMD->do_flee(this_object());
                }
                
                if (query("auto_perform") || me->query_auto_perform())
                {                       
                        if (my["eff_jing"] > 0 && my["jing"] * 100 / my["eff_jing"] <= 70)
                                SKILL_D("force/regenerate")->exert(me, me);
                        if (my["eff_qi"] > 0 && my["qi"] * 100 / my["eff_qi"] <= 70)
                                SKILL_D("force/recover")->exert(me, me);

                        // 如果不在打架而且处于受伤状态,则自行疗伤
                        if (! is_fighting())
                        {
                                if (my["eff_jing"] < my["max_jing"])
                                        SKILL_D("force/inspire")->exert(me, me);
                                if (my["eff_qi"] < my["max_qi"])
                                        SKILL_D("force/heal")->exert(me, me);
                        }
                }
                // Do attack or clean up enemy if we have fleed.
                if (is_busy())
                        continue_action();
                else
                        attack();
        }

        if (my["doing"] == "scheme")
                // executing schedule now
                SCHEME_CMD->execute_schedule(me);

        if (! me) return;

        if (! (is_player = playerp(me)))
        {
                me->scan();
                // scan() may do anything -- include destruct(this_object())
                if (! me) return;
        }

        if ((t = time()) < next_beat) return;
        else next_beat = t + 5 + random(10);

	if (! my["not_living"])
        	cnd_flag = update_condition();
	if (! me) return;

	if (! (cnd_flag & CND_NO_HEAL_UP))
		cnd_flag = heal_up();

        // If we are compeletely in peace, turn off heart beat.
        // heal_up() must be called prior to other two to make sure it is called
        // because the && operator is lazy :P
        if (! cnd_flag &&
	    ! is_player &&
            ! keep_beat_flag &&
            ! is_fighting() &&
	    ! is_busy() &&
            ! interactive(this_object()))
        {
                if (environment() && query("chat_msg"))
                {
                        ob = first_inventory(environment());
                        while (ob && ! interactive(ob))
                                ob = next_inventory(ob);
                } else
                        ob = 0;
                if (! ob) set_heart_beat(0);
        }

        update_all_limb_damage();
        
        if (! me || ! is_player) return;

        // Make us a bit older. Only player's update_age is defined.
        // Note: update_age() is no need to be called every heart_beat, it
        //       remember how much time has passed since last call.
        me->update_age();

#ifdef AUTO_SAVE
        if (living(me))
        {
            	period = t - ((int) my["last_save"]);
                if (period < 0 || period > 15 * 60)
            	{
                	string msg;
                        msg = HBCYN HIW "【档案存储】您的档案已经自动存盘,"
                              "欢迎访问论坛 http://bbs.mudbuilder.com/ 。\n" NOR;
                	if (! me->save())
                    	msg = HIR "【数据保护】由于数据异常,您的档"
                              "案本次存盘失败。\n" NOR;
                	set("last_save", t);
                	tell_object(me, msg);
            }
        }
#endif
	if (! interactive(me))
		return;

        if (my["food"] <= 0 || my["water"] <= 0)
        {
		if (environment() &&
		    ! environment()->is_chat_room() &&
                    ! wizardp(me) &&
                    ! query_condition("hunger"))
		{
			// born & enter the world
                        apply_condition("hunger", 1);
		}
        }

        if (query_idle(me) > IDLE_TIMEOUT && ! wizardp(me) &&
            (! mapp(my["env"]) || ! my["env"]["keep_idle"]))
                me->user_dump(DUMP_IDLE);
}