Example #1
0
void colvar::distance_z::calc_value()
{
  if (fixed_axis) {
    if (!is_enabled(f_cvc_pbc_minimum_image)) {
      dist_v = main->center_of_mass() - ref1->center_of_mass();
    } else {
      dist_v = cvm::position_distance(ref1->center_of_mass(),
                                      main->center_of_mass());
    }
  } else {

    if (!is_enabled(f_cvc_pbc_minimum_image)) {
      dist_v = main->center_of_mass() -
               (0.5 * (ref1->center_of_mass() + ref2->center_of_mass()));
      axis = ref2->center_of_mass() - ref1->center_of_mass();
    } else {
      dist_v = cvm::position_distance(0.5 * (ref1->center_of_mass() +
                                             ref2->center_of_mass()),
                                      main->center_of_mass());
      axis = cvm::position_distance(ref1->center_of_mass(),
                                    ref2->center_of_mass());
    }
    axis_norm = axis.norm();
    axis = axis.unit();
  }
  x.real_value = axis * dist_v;
  this->wrap(x);
}
Example #2
0
/**
 * @brief Starts a dialog.
 *
 * If there was already a dialog, it must be finished.
 *
 * @param dialog_id of the dialog
 * @param issuer_script the script that issued the request to start a dialog
 * (will be notified when the dialog finishes), or NULL
 * @param vertical_position vertical position where to display the dialog box (default: auto)
 */
void DialogBox::start_dialog(const std::string& dialog_id, Script* issuer_script,
    VerticalPosition vertical_position) {

  Debug::check_assertion(!is_enabled() || is_full(), StringConcat()
      << "Cannot start dialog '" << dialog_id
      << "': another dialog '" << this->dialog_id << "' is already started");

  bool first = !is_enabled();
  if (first) {
    // save the action and sword keys
    KeysEffect& keys_effect = game.get_keys_effect();
    action_key_effect_saved = keys_effect.get_action_key_effect();
    sword_key_effect_saved = keys_effect.get_sword_key_effect();
    this->icon_number = -1;
    this->skip_mode = Dialog::SKIP_NONE;
    this->char_delay = char_delays[SPEED_FAST];
    this->dialog_id = dialog_id;
  }

  // initialize the dialog data
  this->dialog = DialogResource::get_dialog(dialog_id);
  this->line_it = dialog.get_lines().begin();
  this->line_index = 0;
  this->char_index = 0;
  this->skipped = false;

  if (dialog.get_skip_mode() != Dialog::SKIP_UNCHANGED) {
    this->skip_mode = dialog.get_skip_mode();
  }

  if (dialog.get_icon() != -2) { // -2 means unchanged
    this->icon_number = dialog.get_icon();
  }
  if (dialog.is_question()) {
    this->last_answer = 0;
  }
  else {
    this->last_answer = -1;
  }
  question_dst_position.set_y(box_dst_position.get_y() + 27);

  if (first) {
    set_vertical_position(vertical_position);

    // notify the scripts
    game.get_map_script().event_dialog_started(dialog_id);
    this->issuer_script = issuer_script;
    if (issuer_script != NULL) {
      issuer_script->event_dialog_started(dialog_id);
    }
  }

  // start displaying text
  show_more_lines();
}
Example #3
0
/**
 * \brief Enables or disables the dynamic tiles related to these stairs.
 *
 * The dynamic tiles impacted by this function are the ones whose prefix is
 * the stairs's name
 * followed by "_enabled" or "_disabled", depending on the stairs state.
 */
void Stairs::update_dynamic_tiles() {

  std::list<MapEntity*> tiles = get_entities().get_entities_with_prefix(
      EntityType::DYNAMIC_TILE, get_name() + "_enabled");
  for (MapEntity* tile: tiles) {
    tile->set_enabled(is_enabled());
  }

  tiles = get_entities().get_entities_with_prefix(
      EntityType::DYNAMIC_TILE, get_name() + "_disabled");
  for (MapEntity* tile: tiles) {
    tile->set_enabled(!is_enabled());
  }
}
Example #4
0
/**
 * @brief Enables or disables the dynamic tiles related to these stairs.
 *
 * The dynamic tiles impacted by this function are the ones whose prefix is the stairs's name
 * followed by "_enabled" or "_disabled", depending on the stairs state.
 */
void Stairs::update_dynamic_tiles() {

  std::list<MapEntity*> tiles = get_entities().get_entities_with_prefix(DYNAMIC_TILE, get_name() + "_enabled");
  std::list<MapEntity*>::iterator it;
  for (it = tiles.begin(); it != tiles.end(); it++) {
    DynamicTile *tile = (DynamicTile*) *it;
    tile->set_enabled(is_enabled());
  }

  tiles = get_entities().get_entities_with_prefix(DYNAMIC_TILE, get_name() + "_disabled");
  for (it = tiles.begin(); it != tiles.end(); it++) {
    DynamicTile *tile = (DynamicTile*) *it;
    tile->set_enabled(!is_enabled());
  }
}
Example #5
0
/**
 * \brief Returns whether this enemy is in a normal state.
 *
 * The enemy is considered to be in its normal state if
 * it is not disabled, dying, being hurt or immobilized.
 * When this method returns false, the subclasses of Enemy
 * should not change the enemy properties.
 *
 * \return true if this enemy is in a normal state
 */
bool Enemy::is_in_normal_state() const {
  return is_enabled()
    && !is_being_hurt()
    && get_life() > 0
    && !is_immobilized()
    && !is_being_removed();
}
Example #6
0
/**
 * @brief Updates the dialog box.
 *
 * This function is called repeatedly by the game
 * while the dialog box exists.
 */
void DialogBox::update() {

  if (!is_enabled()) {
    return; // nothing to update
  }

  // update the text displaying
  update_lines();

  // handle the end of the visible lines
  if (is_full()) {

    // update the message end arrow
    end_lines_sprite.update();

    // show the appropriate action icon
    KeysEffect& keys_effect = game.get_keys_effect();
    if (!end_lines_sprite.is_animation_started()) {

      if (has_more_lines()
          || dialog.has_next()
          || dialog.is_question()) {
        end_lines_sprite.set_current_animation("next");
        keys_effect.set_action_key_effect(KeysEffect::ACTION_KEY_NEXT);
      }
      else {
        keys_effect.set_action_key_effect(KeysEffect::ACTION_KEY_RETURN);
        end_lines_sprite.set_current_animation("last");
      }

      keys_effect.set_sword_key_effect(KeysEffect::SWORD_KEY_HIDDEN);
      Sound::play("message_end");
    }
  }
}
Example #7
0
File: log.c Project: Fiend90/obex
void __obex_log_init(const char *label, const char *debug, int detach)
{
	int option = LOG_NDELAY | LOG_PID;
	struct obex_debug_desc *desc;
	const char *name = NULL, *file = NULL;

	if (debug != NULL)
		enabled = g_strsplit_set(debug, ":, ", 0);

	for (desc = __start___debug; desc < __stop___debug; desc++) {
		if (file != NULL || name != NULL) {
			if (g_strcmp0(desc->file, file) == 0) {
				if (desc->name == NULL)
					desc->name = name;
			} else
				file = NULL;
		}

		if (is_enabled(desc))
			desc->flags |= OBEX_DEBUG_FLAG_PRINT;
	}

	if (!detach)
		option |= LOG_PERROR;

	openlog(label, option, LOG_DAEMON);

	syslog(LOG_INFO, "%s daemon %s", label, VERSION);
}
Example #8
0
bool Portal::_get(const StringName &p_name, Variant &r_ret) const {

	if (p_name == "shape") {
		Vector<Point2> points = get_shape();
		PoolVector<float> dst_coords;
		dst_coords.resize(points.size() * 2);

		for (int i = 0; i < points.size(); i++) {

			dst_coords.set(i * 2 + 0, points[i].x);
			dst_coords.set(i * 2 + 1, points[i].y);
		}

		r_ret = dst_coords;
	} else if (p_name == "enabled") {
		r_ret = is_enabled();
	} else if (p_name == "disable_distance") {
		r_ret = get_disable_distance();
	} else if (p_name == "disabled_color") {
		r_ret = get_disabled_color();
	} else if (p_name == "connect_range") {
		r_ret = get_connect_range();
	} else
		return false;
	return true;
}
Example #9
0
void NavigationMeshInstance::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_ENTER_TREE: {

			Spatial *c = this;
			while (c) {

				navigation = c->cast_to<Navigation>();
				if (navigation) {

					if (enabled && navmesh.is_valid()) {

						nav_id = navigation->navmesh_create(navmesh, get_relative_transform(navigation), this);
					}
					break;
				}

				c = c->get_parent_spatial();
			}

			if (navmesh.is_valid() && get_tree()->is_debugging_navigation_hint()) {

				MeshInstance *dm = memnew(MeshInstance);
				dm->set_mesh(navmesh->get_debug_mesh());
				if (is_enabled()) {
					dm->set_material_override(get_tree()->get_debug_navigation_material());
				} else {
					dm->set_material_override(get_tree()->get_debug_navigation_disabled_material());
				}
				add_child(dm);
				debug_view = dm;
			}

		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {

			if (navigation && nav_id != -1) {
				navigation->navmesh_set_transform(nav_id, get_relative_transform(navigation));
			}

		} break;
		case NOTIFICATION_EXIT_TREE: {

			if (navigation) {

				if (nav_id != -1) {
					navigation->navmesh_remove(nav_id);
					nav_id = -1;
				}
			}

			if (debug_view) {
				debug_view->queue_delete();
				debug_view = NULL;
			}
			navigation = NULL;
		} break;
	}
}
/**
 * \brief This function is called by the game when a command is pressed
 * while a dialog is active.
 *
 * Nothing happens if the dialog is handled in Lua.
 *
 * \param command The command pressed.
 * \return \c true if the command was handled (that is, if the dialog box
 * is active and is the built-in one).
 */
bool DialogBoxSystem::notify_command_pressed(GameCommand command) {

  if (!is_enabled()) {
    return false;
  }

  if (!built_in) {
    // The dialog box is handled by a Lua script.
    return false;
  }

  if (command == GameCommand::ACTION) {
    show_more_lines();
  }
  else if (command == GameCommand::UP || command == GameCommand::DOWN) {
    if (is_question && !has_more_lines()) {
      // Switch the selected answer.
      selected_first_answer = !selected_first_answer;
      int selected_line_index = selected_first_answer ? 1 : 2;
      for (int i = 0; i < nb_visible_lines; i++) {
        line_surfaces[i]->set_text_color(Color::white);
      }
      line_surfaces[selected_line_index]->set_text_color(Color::yellow);
    }
  }

  return true;
}
Example #11
0
/**
 * \copydoc Detector::notify_action_command_pressed
 */
bool Chest::notify_action_command_pressed() {

  if (is_enabled() &&
      get_hero().is_free() &&
      get_keys_effect().get_action_key_effect() != KeysEffect::ACTION_KEY_NONE
  ) {

    if (can_open()) {
      Sound::play("chest_open");
      set_open(true);
      treasure_date = System::now() + 300;

      get_keys_effect().set_action_key_effect(KeysEffect::ACTION_KEY_NONE);
      get_hero().start_freezed();
    }
    else if (!get_cannot_open_dialog_id().empty()) {
      Sound::play("wrong");
      get_game().start_dialog(get_cannot_open_dialog_id(), ScopedLuaRef(), ScopedLuaRef());
    }

    return true;
  }

  return false;
}
Example #12
0
    void widget_group::
    add (
        drawable& widget,
        unsigned long x,
        unsigned long y
    )
    {
        auto_mutex M(m); 
        drawable* w = &widget;
        relpos rp;
        rp.x = x;
        rp.y = y;
        if (widgets.is_in_domain(w))
        {
            widgets[w].x = x;
            widgets[w].y = y;
        }
        else
        {
            widgets.add(w,rp);
        }
        if (is_hidden())
            widget.hide();
        else
            widget.show();

        if (is_enabled())
            widget.enable();
        else
            widget.disable();

        widget.set_z_order(z_order());
        widget.set_pos(x+rect.left(),y+rect.top());
    }
Example #13
0
	bool sprite_instance::can_handle_mouse_event()
	// Return true if we have any mouse event handlers.
	{
		static const tu_stringi FN_NAMES[] =
		{
			"onKeyPress",
			"onRelease",
			"onDragOver",
			"onDragOut",
			"onPress",
			"onReleaseOutside",
			"onRollout",
			"onRollover",
		};

		if (is_enabled())
		{
			for (size_t i = 0; i < TU_ARRAYSIZE(FN_NAMES); i++)
			{
				as_value dummy;
				if (get_member(FN_NAMES[i], &dummy))
				{
					return true;
				}
			}
		}
		return false;
	}
Example #14
0
void colvar::distance_pairs::calc_value()
{
  x.vector1d_value.resize(group1->size() * group2->size());

  if (!is_enabled(f_cvc_pbc_minimum_image)) {
    size_t i1, i2;
    for (i1 = 0; i1 < group1->size(); i1++) {
      for (i2 = 0; i2 < group2->size(); i2++) {
        cvm::rvector const dv = (*group2)[i2].pos - (*group1)[i1].pos;
        cvm::real const d = dv.norm();
        x.vector1d_value[i1*group2->size() + i2] = d;
        (*group1)[i1].grad = -1.0 * dv.unit();
        (*group2)[i2].grad =  dv.unit();
      }
    }
  } else {
    size_t i1, i2;
    for (i1 = 0; i1 < group1->size(); i1++) {
      for (i2 = 0; i2 < group2->size(); i2++) {
        cvm::rvector const dv = cvm::position_distance((*group1)[i1].pos,
                                                       (*group2)[i2].pos);
        cvm::real const d = dv.norm();
        x.vector1d_value[i1*group2->size() + i2] = d;
        (*group1)[i1].grad = -1.0 * dv.unit();
        (*group2)[i2].grad =  dv.unit();
      }
    }
  }
}
Example #15
0
File: log.c Project: intgr/connman
void __connman_log_enable(struct connman_debug_desc *start,
					struct connman_debug_desc *stop)
{
	struct connman_debug_desc *desc;
	const char *name = NULL, *file = NULL;

	if (start == NULL || stop == NULL)
		return;

	for (desc = start; desc < stop; desc++) {
		if (desc->flags & CONNMAN_DEBUG_FLAG_ALIAS) {
			file = desc->file;
			name = desc->name;
			continue;
		}

		if (file != NULL || name != NULL) {
			if (g_strcmp0(desc->file, file) == 0) {
				if (desc->name == NULL)
					desc->name = name;
			} else
				file = NULL;
		}

		if (is_enabled(desc) == TRUE)
			desc->flags |= CONNMAN_DEBUG_FLAG_PRINT;
	}
}
Example #16
0
/**
 * \brief This function is called when another entity overlaps this entity.
 * \param entity_overlapping The other entity.
 * \param collision_mode The collision mode that detected the collision.
 */
void Stairs::notify_collision(
    MapEntity& entity_overlapping, CollisionMode collision_mode) {

  if (is_enabled()) {
    entity_overlapping.notify_collision_with_stairs(*this, collision_mode);
  }
}
	void help()
	{
		//print command-specific help if available, otherwise list commands
		if (help_command(get_arg(1))) {
			return;
		}
		std::stringstream ss;
		bool show_unavail = show_unavailable_ || get_arg(1) == "all";
		for (typename command_map::value_type i : command_map_) {
			if (show_unavail || is_enabled(i.second)) {
				ss << i.first;
				//if (!i.second.usage.empty()) {
				//	ss << " " << i.second.usage;
				//}
				//uncomment the above to display usage information in command list
				//which might clutter it somewhat
				if (!i.second.flags.empty()) {
					ss << " (" << i.second.flags << ") ";
				}
				ss << "; ";
			}
		}
		utils::string_map symbols;
		symbols["flags_description"] = get_flags_description();
		symbols["list_of_commands"] = ss.str();
		symbols["help_command"] = cmd_prefix_ + "help";
		print(_("help"), VGETTEXT("Available commands $flags_description:\n$list_of_commands", symbols));
		print(_("help"), VGETTEXT("Type $help_command <command> for more info.", symbols));
	}
Example #18
0
void colvar::distance_xy::calc_gradients()
{
  // Intermediate quantity (r_P3 / r_12 where P is the projection
  // of 3(main) on the plane orthogonal to 12, containing 1 (ref1))
  cvm::real A;
  cvm::real x_inv;

  if (x.real_value == 0.0) return;
  x_inv = 1.0 / x.real_value;

  if (fixed_axis) {
    ref1->set_weighted_gradient(-1.0 * x_inv * dist_v_ortho);
    main->set_weighted_gradient(       x_inv * dist_v_ortho);
  } else {
    if (!is_enabled(f_cvc_pbc_minimum_image)) {
      v13 = main->center_of_mass() - ref1->center_of_mass();
    } else {
      v13 = cvm::position_distance(ref1->center_of_mass(),
                                   main->center_of_mass());
    }
    A = (dist_v * axis) / axis_norm;

    ref1->set_weighted_gradient( (A - 1.0) * x_inv * dist_v_ortho);
    ref2->set_weighted_gradient( -A        * x_inv * dist_v_ortho);
    main->set_weighted_gradient(      1.0  * x_inv * dist_v_ortho);
  }
}
static int process_request(request_rec* r) {

    char message[MESSAGE_LEN];
    sprintf(message, "Starting Tractis auth module process for url %s\n", r->uri);
    log_debug(message);

    char *enabled = is_enabled(r);
    //Not enabled
    if (enabled == NULL || strcmp(enabled,"true") !=0) {
        char buff[MESSAGE_LEN];
        sprintf(buff,"Module not enabled for given url");
        log_debug(buff);
        return DECLINED;
    } else {
        char buff[MESSAGE_LEN];
        sprintf(buff,"Module enabled for given url");
        log_debug(buff);
    }

    //Recover credentials
    char *user = get_username(r);
    char *password = get_password(r);
    char *api_key = get_api_key(r);


    if (is_debug_enabled()) {
        char debug_message[MESSAGE_LEN];
        sprintf(debug_message, "Credentials are %s:%s and api key is %s", user,password,api_key);
        log_debug(debug_message);
    }

    char* certificate = (char*)apr_table_get(r->subprocess_env, "SSL_CLIENT_CERT");

    //The certificate is not present so the client is not allowed to use the service
    if (!certificate) {
        char error_message[MESSAGE_LEN];
        log_error(401, "No certificate has been provided");
        return 401; //HTTP unauthorized
    } else {
        if (is_debug_enabled()) {
            char message[MESSAGE_LEN + strlen(certificate)];
            sprintf(message, "User provided certificate \n->%s<-",certificate);
            log_debug(message);
        }
    }

    int certificate_status = validate_certificate(r,certificate, user, password, api_key);

    if (certificate_status == VALID) return OK;
    else {
        if(is_info_enabled()) {
            char validation_result[MESSAGE_LEN];
            sprintf(validation_result, "The provided certificate reported unsuccessful validation, result code is %d", certificate_status);
            log_info(validation_result);
        }
        //Non valid auth
        return 401;
    }
}
Example #20
0
/**
 * \brief Notifies this entity that its map has just become active.
 */
void Enemy::notify_map_opening_transition_finished() {

  Detector::notify_map_opening_transition_finished();

  if (is_enabled() && is_in_normal_state()) {
    restart();
  }
}
Example #21
0
bool
LM::Account::is_active () const
{
  if (!is_enabled ())
    return false;

  return true; // Isn't there a way to know if an account is active?
}
Example #22
0
/**
 * \brief Returns whether this entity is an obstacle for another one.
 * \param other Another entity.
 * \return \c true if this entity is an obstacle for the other one.
 */
bool Enemy::is_obstacle_for(const MapEntity& other) const {

  if (!is_enabled()) {
    return false;
  }

  return !is_traversable() || other.is_enemy_obstacle(*this);
}
Example #23
0
void Button::system_behaviour(const unsigned long e, const TEXEngine::Core::Message&){
	if(!is_enabled()) return;

	if(e == COMPONENT_ON_FOCUS_GAINED){
		m_render_border = true;
	}else if(e == COMPONENT_ON_FOCUS_LOST){
		m_render_border = false;
	}
}
Example #24
0
static int reload_module(void)
{
    char was_enabled = is_enabled();

    if (ast_ari_config_reload() != 0) {
        return AST_MODULE_LOAD_DECLINE;
    }

    if (was_enabled && !is_enabled()) {
        ast_debug(3, "Disabling ARI\n");
        ast_http_uri_unlink(&http_uri);
    } else if (!was_enabled && is_enabled()) {
        ast_debug(3, "Enabling ARI\n");
        ast_http_uri_link(&http_uri);
    }

    return AST_MODULE_LOAD_SUCCESS;
}
Example #25
0
void colvar::distance_vec::calc_value()
{
  if (!is_enabled(f_cvc_pbc_minimum_image)) {
    x.rvector_value = group2->center_of_mass() - group1->center_of_mass();
  } else {
    x.rvector_value = cvm::position_distance(group1->center_of_mass(),
                                             group2->center_of_mass());
  }
}
void G1StringDedup::unlink_or_oops_do(BoolObjectClosure* is_alive,
                                      OopClosure* keep_alive,
                                      bool allow_resize_and_rehash,
                                      G1GCPhaseTimes* phase_times) {
  assert(is_enabled(), "String deduplication not enabled");

  G1StringDedupUnlinkOrOopsDoTask task(is_alive, keep_alive, allow_resize_and_rehash, phase_times);
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
  g1h->workers()->run_task(&task);
}
Example #27
0
void colvar::distance::calc_force_invgrads()
{
  group1->read_total_forces();
  if (is_enabled(f_cvc_one_site_total_force)) {
    ft.real_value = -1.0 * (group1->total_force() * dist_v.unit());
  } else {
    group2->read_total_forces();
    ft.real_value = 0.5 * ((group2->total_force() - group1->total_force()) * dist_v.unit());
  }
}
Example #28
0
void colvar::distance::calc_value()
{
  if (!is_enabled(f_cvc_pbc_minimum_image)) {
    dist_v = group2->center_of_mass() - group1->center_of_mass();
  } else {
    dist_v = cvm::position_distance(group1->center_of_mass(),
                                    group2->center_of_mass());
  }
  x.real_value = dist_v.norm();
}
Example #29
0
void colvar::distance_xy::calc_force_invgrads()
{
  main->read_total_forces();

  if (fixed_axis && !is_enabled(f_cvc_one_site_total_force)) {
    ref1->read_total_forces();
    ft.real_value = 0.5 / x.real_value * ((main->total_force() - ref1->total_force()) * dist_v_ortho);
  } else {
    ft.real_value = 1.0 / x.real_value * main->total_force() * dist_v_ortho;
  }
}
Example #30
0
void colvar::distance_z::calc_force_invgrads()
{
  main->read_total_forces();

  if (fixed_axis && !is_enabled(f_cvc_one_site_total_force)) {
    ref1->read_total_forces();
    ft.real_value = 0.5 * ((main->total_force() - ref1->total_force()) * axis);
  } else {
    ft.real_value = main->total_force() * axis;
  }
}