예제 #1
0
/* shamelessly copied from gweather code */
static gboolean
find_location (GtkTreeModel *model, GtkTreeIter *iter, const gchar *location, gboolean go_parent)
{
	GtkTreeIter iter_child;
	GtkTreeIter iter_parent;
	gchar *aux_loc;
	gboolean valid;
	int len;

	len = strlen (location);

	if (len <= 0) {
		return FALSE;
	}
	
	do {
		
		gtk_tree_model_get (model, iter, GWEATHER_XML_COL_LOC, &aux_loc, -1);

		if (g_ascii_strncasecmp (aux_loc, location, len) == 0) {
			g_free (aux_loc);
			return TRUE;
		}

		if (gtk_tree_model_iter_has_child (model, iter)) {
			gtk_tree_model_iter_nth_child (model, &iter_child, iter, 0);

			if (find_location (model, &iter_child, location, FALSE)) {
				/* Manual copying of the iter */
				iter->stamp = iter_child.stamp;
				iter->user_data = iter_child.user_data;
				iter->user_data2 = iter_child.user_data2;
				iter->user_data3 = iter_child.user_data3;

				g_free (aux_loc);
				
				return TRUE;
			}
		}
		g_free (aux_loc);

		valid = gtk_tree_model_iter_next (model, iter);		
	} while (valid);

	if (go_parent) {
		iter_parent = *iter;
		if (gtk_tree_model_iter_parent (model, iter, &iter_parent) && gtk_tree_model_iter_next (model, iter)) {
			return find_location (model, iter, location, TRUE);
		}
	}
	return FALSE;
}
예제 #2
0
bool WorldDB::get_chest_info(ChestInfo *info,
                             int id, const char *location_name) const
{
    bool result = false;
    WorldLocation *location = find_location(location_name);

    if (location) {
        for (std::list<WorldNode*>::iterator it = location->m_nodes.begin();
             it != location->m_nodes.end();
             ++it) {
            if ((*it)->m_type == WorldNode::TypeChest) {
                WorldChest *chest = (WorldChest *) *it;
                if (chest->m_integers[std::string("id")] == id) {
                    info->key = chest->m_key;
                    info->once = chest->m_integers["once"];
                    info->user = chest->m_user;
                    info->num_objects = chest->m_objects.size();
                    for (int i = 0; i < info->num_objects; i++) {
                        result = load_object_info(&info->objects[i],
                                                  chest->m_objects[i]);
                        if (!result) {
                            info->num_objects = i;
                            goto error;
                        }
                    }
                    break;
                }
            }
        }
    }

error:
    return result;
}
예제 #3
0
/*
 * Lets the mobile goto any location it wishes that is not private.
 *
 * Syntax: mob goto [location]
 */
void do_mpgoto( CHAR_DATA *ch, char *argument )
{
    char             arg[ MAX_INPUT_LENGTH ];
    ROOM_INDEX_DATA *location;

    one_argument( argument, arg );
    if ( arg[0] == '\0' )
    {
	bug( "Mpgoto - No argument from vnum %d.", 
		IS_NPC(ch) ? ch->pIndexData->vnum : 0 );
	return;
    }

    if ( ( location = find_location( ch, arg ) ) == NULL )
    {
	bug( "Mpgoto - No such location from vnum %d.", 
		IS_NPC(ch) ? ch->pIndexData->vnum : 0 );
	return;
    }

    if ( ch->fighting != NULL )
	stop_fighting( ch, TRUE );

    char_from_room( ch );
    char_to_room( ch, location );

    return;
}
예제 #4
0
void
find_entry_changed (GtkEditable *entry/*, GWeatherPref *pref*/)
{
	GtkTreeModel *model;
	GtkTreeSelection *selection;
	GtkTreeIter iter;
	GtkTreePath *path;
	GtkWidget *nextbutton;
	const gchar *location;

	nextbutton = (GtkWidget *) glade_xml_get_widget(glade_xml, "findnextbutton");

	model = gtk_tree_view_get_model (GTK_TREE_VIEW(locations_widgets->tree));

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (locations_widgets->tree));
	gtk_tree_model_get_iter_first (model, &iter);

	location = gtk_entry_get_text (GTK_ENTRY (entry));

	if (find_location (model, &iter, location, TRUE)) 
	{
		gtk_widget_set_sensitive (nextbutton , TRUE);

		path = gtk_tree_model_get_path (model, &iter);
		gtk_tree_view_expand_to_path (GTK_TREE_VIEW(locations_widgets->tree), path);
		gtk_tree_selection_select_iter (selection, &iter);
		gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(locations_widgets->tree), path, NULL, TRUE, 0.5, 0);

		gtk_tree_path_free (path);
	} 
	else 
	{
		gtk_widget_set_sensitive (nextbutton, FALSE);
	}
}
예제 #5
0
static void find_entry_changed(GtkEditable* entry, MateWeatherPref* pref)
{
	GtkTreeView *tree;
	GtkTreeModel *model;
	GtkTreeSelection *selection;
	GtkTreeIter iter;
	GtkTreePath *path;
	const gchar *location;

	tree = GTK_TREE_VIEW (pref->priv->tree);
	model = gtk_tree_view_get_model (tree);

	g_return_if_fail (model != NULL);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
	gtk_tree_model_get_iter_first (model, &iter);

	location = gtk_entry_get_text (GTK_ENTRY (entry));

	if (find_location (model, &iter, location, TRUE))
	{
		gtk_widget_set_sensitive (pref->priv->find_next_btn, TRUE);

		path = gtk_tree_model_get_path (model, &iter);
		gtk_tree_view_expand_to_path (tree, path);
		gtk_tree_selection_select_iter (selection, &iter);
		gtk_tree_view_scroll_to_cell (tree, path, NULL, TRUE, 0.5, 0);

		gtk_tree_path_free (path);
	}
	else
	{
		gtk_widget_set_sensitive (pref->priv->find_next_btn, FALSE);
	}
}
예제 #6
0
/*
 * Lets the mobile to transfer an object. The object must be in the same
 * room with the mobile.
 *
 * Syntax: mob otransfer [item name] [location]
 */
void do_mpotransfer(CHAR_DATA * ch, char *argument)
{
    OBJ_DATA *obj;
    ROOM_INDEX_DATA *location;
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_INPUT_LENGTH];

    argument = one_argument(argument, arg);
    if (arg[0] == '\0') {
	bug("MpOTransfer - Missing argument from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    }
    one_argument(argument, buf);
    if ((location = find_location(ch, buf)) == NULL) {
	bug("MpOTransfer - No such location from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    }
    if ((obj = get_obj_here(ch, arg)) == NULL)
	return;
    if (obj->carried_by == NULL)
	obj_from_room(obj);
    else {
	if (obj->wear_loc != WEAR_NONE)
	    unequip_char(ch, obj);
	obj_from_char(obj);
    }
    obj_to_room(obj, location);
}
예제 #7
0
bool WorldDB::get_lock_info(LockInfo *info,
                            int id, const char *location_name) const
{
    bool result = false;
    WorldLocation *location = find_location(location_name);

    if (location) {
        for (std::list<WorldNode*>::iterator it = location->m_nodes.begin();
             it != location->m_nodes.end();
             ++it) {
            if ((*it)->m_type == WorldNode::TypeLock) {
                WorldLock *lock = (WorldLock *) *it;
                if (lock->m_integers[std::string("id")] == id) {
                    info->key = lock->m_key;
                    info->type_name =
                        lock->m_strings[std::string("type")].c_str();
                    info->lock_name =
                        lock->m_strings[std::string("lock")].c_str();
                    info->once = lock->m_integers["once"];
                    result = true;
                    break;
                }
            }
        }
    }

    return result;
}
예제 #8
0
/*
 * update_cursor:
 * @area: a #UmCropArea
 * @x: x coordinate
 * @y: y coordinate
 *
 * Update the type of the cursor, depending on which point of the crop
 * rectangle the pointer is over.
 */
static void
update_cursor (UmCropArea *area,
               gint           x,
               gint           y)
{
        UmCropAreaPrivate *priv = um_crop_area_get_instance_private (area);
        gint cursor_type;
        GdkRectangle crop;
        gint region;

        region = priv->active_region;
        if (region == OUTSIDE) {
                crop_to_widget (area, &crop);
                region = find_location (&crop, x, y);
        }

        switch (region) {
        case OUTSIDE:
                cursor_type = GDK_LEFT_PTR;
                break;
        case TOP_LEFT:
                cursor_type = GDK_TOP_LEFT_CORNER;
                break;
        case TOP:
                cursor_type = GDK_TOP_SIDE;
                break;
        case TOP_RIGHT:
                cursor_type = GDK_TOP_RIGHT_CORNER;
                break;
        case LEFT:
                cursor_type = GDK_LEFT_SIDE;
                break;
        case INSIDE:
                cursor_type = GDK_FLEUR;
                break;
        case RIGHT:
                cursor_type = GDK_RIGHT_SIDE;
                break;
        case BOTTOM_LEFT:
                cursor_type = GDK_BOTTOM_LEFT_CORNER;
                break;
        case BOTTOM:
                cursor_type = GDK_BOTTOM_SIDE;
                break;
        case BOTTOM_RIGHT:
                cursor_type = GDK_BOTTOM_RIGHT_CORNER;
                break;
	default:
		g_assert_not_reached ();
        }

        if (cursor_type != priv->current_cursor) {
                GdkCursor *cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (area)),
                                                                cursor_type);
                gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (area)), cursor);
                g_object_unref (cursor);
                priv->current_cursor = cursor_type;
        }
}
예제 #9
0
/*
 * Lets the mobile transfer people.  The 'all' argument transfers
 *  everyone in the current room to the specified location
 *
 * Syntax: mob transfer [target|'all'] [location]
 */
void do_mptransfer(CHAR_DATA * ch, char *argument)
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    ROOM_INDEX_DATA *location;
    CHAR_DATA *victim;

    argument = one_argument(argument, arg1);
    argument = one_argument(argument, arg2);

    if (arg1[0] == '\0') {
	bug("Mptransfer - Bad syntax from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    }
    if (!str_cmp(arg1, "all")) {
	CHAR_DATA *victim_next;

	for (victim = ch->in_room->people; victim != NULL; victim = victim_next) {
	    victim_next = victim->next_in_room;
	    if (!IS_NPC(victim)) {
		sprintf(buf, "%s %s", victim->name, arg2);
		do_mptransfer(ch, buf);
	    }
	}
	return;
    }
    /*
     * Thanks to Grodyn for the optional location parameter.
     */
    if (arg2[0] == '\0') {
	location = ch->in_room;
    } else {
	if ((location = find_location(ch, arg2)) == NULL) {
	    bug("Mptransfer - No such location from vnum %d.",
		IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	    return;
	}
	if (room_is_private(location))
	    return;
    }

    if ((victim = get_char_world(ch, arg1)) == NULL)
	return;

    if (victim->in_room == NULL)
	return;

    if (victim->fighting != NULL)
	stop_fighting(victim, TRUE);
    char_from_room(victim);
    char_to_room(victim, location);
    do_look(victim, "auto");

    return;
}
예제 #10
0
void unit_creator::add_unit(const config &cfg, const vconfig* vcfg)
{
	config temp_cfg(cfg);
	temp_cfg["side"] = team_.side();

	const std::string& id =(cfg)["id"];
	bool animate = temp_cfg["animate"].to_bool();
	temp_cfg.remove_attribute("animate");

	unit_ptr recall_list_element = team_.recall_list().find_if_matches_id(id);

	if ( !recall_list_element ) {
		//make the new unit
		unit_ptr new_unit(new unit(temp_cfg, true, vcfg));
		map_location loc = find_location(temp_cfg, new_unit.get());
		if ( loc.valid() ) {
			//add the new unit to map
			board_->units().replace(loc, *new_unit);
			LOG_NG << "inserting unit for side " << new_unit->side() << "\n";
			post_create(loc,*(board_->units().find(loc)),animate);
		}
		else if ( add_to_recall_ ) {
			//add to recall list
			team_.recall_list().add(new_unit);
			DBG_NG << "inserting unit with id=["<<id<<"] on recall list for side " << new_unit->side() << "\n";
			preferences::encountered_units().insert(new_unit->type_id());
		}
	} else {
		//get unit from recall list
		map_location loc = find_location(temp_cfg, recall_list_element.get());
		if ( loc.valid() ) {
			board_->units().replace(loc, *recall_list_element);
			LOG_NG << "inserting unit from recall list for side " << recall_list_element->side()<< " with id="<< id << "\n";
			post_create(loc,*(board_->units().find(loc)),animate);
			//if id is not empty, delete units with this ID from recall list
			team_.recall_list().erase_if_matches_id( id);
		}
		else if ( add_to_recall_ ) {
			LOG_NG << "wanted to insert unit on recall list, but recall list for side " << (cfg)["side"] << "already contains id=" <<id<<"\n";
			return;
		}
	}
}
예제 #11
0
static void find_next_clicked(GtkButton* button, MateWeatherPref* pref)
{
	GtkTreeView *tree;
	GtkTreeModel *model;
	GtkEntry *entry;
	GtkTreeSelection *selection;
	GtkTreeIter iter;
	GtkTreeIter iter_parent;
	GtkTreePath *path;
	const gchar *location;

	tree = GTK_TREE_VIEW (pref->priv->tree);
	model = gtk_tree_view_get_model (tree);
	entry = GTK_ENTRY (pref->priv->find_entry);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));

	if (gtk_tree_selection_count_selected_rows (selection) >= 1)
	{
		gtk_tree_selection_get_selected (selection, &model, &iter);
		/* Select next or select parent */
		if (!gtk_tree_model_iter_next (model, &iter))
		{
			iter_parent = iter;

			if (!gtk_tree_model_iter_parent (model, &iter, &iter_parent) || !gtk_tree_model_iter_next (model, &iter))
			{
				gtk_tree_model_get_iter_first (model, &iter);
			}
		}

	}
	else
	{
		gtk_tree_model_get_iter_first (model, &iter);
	}

	location = gtk_entry_get_text (entry);

	if (find_location (model, &iter, location, TRUE))
	{
		gtk_widget_set_sensitive (pref->priv->find_next_btn, TRUE);

		path = gtk_tree_model_get_path (model, &iter);
		gtk_tree_view_expand_to_path (tree, path);
		gtk_tree_selection_select_path (selection, path);
		gtk_tree_view_scroll_to_cell (tree, path, NULL, TRUE, 0.5, 0);

		gtk_tree_path_free (path);
	}
	else
	{
		gtk_widget_set_sensitive (pref->priv->find_next_btn, FALSE);
	}
}
예제 #12
0
void do_mpat( CHAR_DATA *ch, char *argument )
{
    char             arg[ MAX_INPUT_LENGTH ];
    ROOM_INDEX_DATA *location;
    ROOM_INDEX_DATA *original;
    CHAR_DATA       *wch;

    if ( !IS_NPC( ch ) )
    {
	typo_message( ch );
	return;
    }
 
    if ( IS_SET( ch->act , ACT_PET ) || IS_AFFECTED( ch, AFF_CHARM ) )
      return;

    argument = one_argument( argument, arg );

    if ( arg[0] == '\0' || argument[0] == '\0' )
    {
        sprintf( log_buf, "Mpat - Bad argument: vnum %d name %s short %s.",
                 ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
	return;
    }

    if ( ( location = find_location( ch, arg ) ) == NULL )
    {
        sprintf( log_buf, "Mpat - No such location: vnum %d name %s short %s.",
                 ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
	return;
    }

    original = ch->in_room;
    char_from_room( ch );
    char_to_room( ch, location );
    interpret( ch, argument );

    /*
     * See if 'ch' still exists before continuing!
     * Handles 'at XXXX quit' case.
     */
    for ( wch = char_list; wch != NULL; wch = wch->next )
    {
	if ( wch == ch )
	{
	    char_from_room( ch );
	    char_to_room( ch, original );
	    break;
	}
    }

    return;
}
예제 #13
0
WorldLocation* WorldDB::get_location(const char *name)
{
    // Check if location exists, otherwise allocate new and insert
    WorldLocation *location = find_location(name);
    if (!location) {
        location = new WorldLocation;
        m_locations[std::string(name)] = location;
    }

    return location;
}
예제 #14
0
void do_mpat( CHAR_DATA *ch, char *argument )
{
    char             arg[ MAX_INPUT_LENGTH ];
    ROOM_INDEX_DATA *location;
    ROOM_INDEX_DATA *original;
    CHAR_DATA       *wch;

    if ( !IS_NPC( ch ) )
    {
        send_to_char( C_DEFAULT, "Huh?\n\r", ch );
	return;
    }
 
    if ( IS_AFFECTED( ch, AFF_CHARM ) )
    {
        return;
    }

    argument = one_argument( argument, arg );

    if ( arg[0] == '\0' || argument[0] == '\0' )
    {
	bug( "Mpat - Bad argument: vnum %d.", ch->pIndexData->vnum );
	return;
    }

    if ( ( location = find_location( ch, arg ) ) == NULL )
    {
	bug( "Mpat - No such location: vnum %d.", ch->pIndexData->vnum );
	return;
    }

    original = ch->in_room;
    char_from_room( ch );
    char_to_room( ch, location );
    interpret( ch, argument );

    /*
     * See if 'ch' still exists before continuing!
     * Handles 'at XXXX quit' case.
     */
    for ( wch = char_list; wch != NULL; wch = wch->next )
    {
	if ( wch == ch )
	{
	    char_from_room( ch );
	    char_to_room( ch, original );
	    break;
	}
    }

    return;
}
예제 #15
0
// we need to find the first location at depth depth in the table
huff_table_t *find_location(huff_table_t *root, uint16_t depth) {
    huff_table_t *return_ptr = NULL;
    if (root->is_elt == 0) {
        if (depth == 0) {
            return root;
        }
        if (root->left == NULL) {
            root->left = (huff_table_t *)malloc(sizeof(huff_table_t));
            root->left->value = 0;
            root->left->code = (root->code) << 1;
            root->left->is_elt = 0;
            root->left->left = NULL;
            root->left->right = NULL;
            root->left->parent = root;
        }
        return_ptr = find_location(root->left, depth-1);
        if (return_ptr != NULL) {
            return return_ptr;
        }
        if (root->right == NULL) {
            root->right = (huff_table_t *)malloc(sizeof(huff_table_t));
            root->right->value = 0;
            root->right->code = ((root->code) << 1)| 1;
            root->right->is_elt = 0;
            root->right->left = NULL;
            root->right->right = NULL;
            root->right->parent = root;
        }
        return_ptr = find_location(root->right, depth-1);
        if (return_ptr != NULL) {
            return return_ptr;
        }
    } else {
        return NULL;
    }
    return NULL;
}
예제 #16
0
/* 
 * Lets the mobile do a command at another location.
 *
 * Syntax: mob at [location] [commands]
 */
void do_mpat( CHAR_DATA *ch, char *argument )
{
    char             arg[ MAX_INPUT_LENGTH ];
    ROOM_INDEX_DATA *location;
    ROOM_INDEX_DATA *original;
    CHAR_DATA       *wch;
    OBJ_DATA 	    *on;

    argument = one_argument( argument, arg );

    if ( arg[0] == '\0' || argument[0] == '\0' )
    {
	bug( "Mpat - Bad argument from vnum %d.", 
		IS_NPC(ch) ? ch->pIndexData->vnum : 0 );
	return;
    }

    if ( ( location = find_location( ch, arg ) ) == NULL )
    {
	bug( "Mpat - No such location from vnum %d.",
		IS_NPC(ch) ? ch->pIndexData->vnum : 0 );
	return;
    }

    original = ch->in_room;
    on = ch->on;
    char_from_room( ch );
    char_to_room( ch, location );
    interpret( ch, argument );

    /*
     * See if 'ch' still exists before continuing!
     * Handles 'at XXXX quit' case.
     */
    for ( wch = char_list; wch != NULL; wch = wch->next )
    {
	if ( wch == ch )
	{
	    char_from_room( ch );
	    char_to_room( ch, original );
	    ch->on = on;
	    break;
	}
    }

    return;
}
예제 #17
0
    void
    Solver::restart() {
	complete = false;
	puzzle.restart();

	located_piece_indice.clear();
	current_piece_index = 0;
	if (!find_location())
	    complete = true;
	current_direction = right0;

	int total_piece_size = 0;
	for (std::size_t i = 0; i < puzzle.get_piece_count(); i++)
	    total_piece_size += puzzle.get_piece(i).get_size();
	if (total_piece_size != puzzle.get_board().get_blank_count())
	    complete = true;
    }
예제 #18
0
void
find_next_clicked (GtkButton *button)
{
	GtkTreeModel *model;
	GtkEntry *entry;
	GtkTreeSelection *selection;
	GtkTreeIter iter;
	GtkTreeIter iter_parent;
	GtkTreePath *path;
	const gchar *location;

	model = gtk_tree_view_get_model (GTK_TREE_VIEW(locations_widgets->tree));
	entry = GTK_ENTRY (glade_xml_get_widget(glade_xml, "location_search_entry"));

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (locations_widgets->tree));

	if (gtk_tree_selection_count_selected_rows (selection) >= 1) {
		gtk_tree_selection_get_selected (selection, &model, &iter);
		/* Select next or select parent */
		if (!gtk_tree_model_iter_next (model, &iter)) {
			iter_parent = iter;
			if (!gtk_tree_model_iter_parent (model, &iter, &iter_parent) || !gtk_tree_model_iter_next (model, &iter))
				gtk_tree_model_get_iter_first (model, &iter);
		}

	} else {
		gtk_tree_model_get_iter_first (model, &iter);
	}

	location = gtk_entry_get_text (entry);

	if (find_location (model, &iter, location, TRUE)) {
		gtk_widget_set_sensitive ((GtkWidget *)button, TRUE);

		path = gtk_tree_model_get_path (model, &iter);
		gtk_tree_view_expand_to_path (GTK_TREE_VIEW(locations_widgets->tree), path);
		gtk_tree_selection_select_path (selection, path);
		gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(locations_widgets->tree), path, NULL, TRUE, 0.5, 0);

		gtk_tree_path_free (path);
	} else {
		gtk_widget_set_sensitive ((GtkWidget * )button, FALSE);
	}
}
예제 #19
0
파일: cvs2sql.c 프로젝트: Rjoydip/libwww
PRIVATE int add_location (HTSQL * sql, const char * location)
{
    if (sql && location) {
        int index = -1;

        /* If we can't find the LOCATION then add it */
        if ((index = find_location(sql, location)) < 0) {
            char buf[4096];
            char * query = HTSQL_printf(buf, 4096, "insert into %s (location) values (%S)",
                                        DEFAULT_SQL_LOCATION_TABLE, location);
            if (HTSQL_query(sql, query) != YES) {
                return -1;
            }
            index = HTSQL_getLastInsertId(sql);
        }
        return index;
    }
    return -1;
}
예제 #20
0
    bool
    Solver::unlocate_last_piece() {
	if (located_piece_indice.empty())
	    return false;

	current_piece_index = located_piece_indice.back();
	current_direction
	    = puzzle.get_piece(current_piece_index).get_direction();
	located_piece_indice.pop_back();

	if (!puzzle.unlocate_piece(current_piece_index))
	    throw std::logic_error("Ubongo::Solver::unlocate_last_piece");
	if (!find_location())
	    throw std::logic_error("Ubongo::Solver::unlocate_last_piece");

	if (next_direction())
	    return true;
	return next_piece();
    }
예제 #21
0
void do_mpgoto( CHAR_DATA *ch, char *argument )
{
    char             arg[ MAX_INPUT_LENGTH ];
    ROOM_INDEX_DATA *location;

    if ( !IS_NPC( ch ) )
    {
	typo_message( ch );
	return;
    }

    if ( IS_SET( ch->act , ACT_PET ) || IS_AFFECTED( ch, AFF_CHARM ) )
      return;

    one_argument( argument, arg );
    if ( arg[0] == '\0' )
    {
        sprintf( log_buf, "Mpgoto - No argument: vnum %d name %s short %s.",
                 ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
	return;
    }

    if ( ( location = find_location( ch, arg ) ) == NULL )
    {
        sprintf( log_buf, "Mpgoto - No such location: vnum %d name %s short %s.",
                 ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
	return;
    }

    if ( location == ch->in_room )
      return;

    if ( ch->fighting != NULL )
	stop_fighting( ch, TRUE );

    char_from_room( ch );
    char_to_room( ch, location );

    return;
}
예제 #22
0
bool WorldDB::get_object_info(ObjectInfo *info,
                              int id, const char *location_name) const
{
    bool result = false;
    WorldLocation *location = find_location(location_name);

    if (location) {
        for (std::list<WorldNode*>::iterator it = location->m_nodes.begin();
             it != location->m_nodes.end();
             ++it) {
            if ((*it)->m_type == WorldNode::TypeObject) {
                WorldObject *object = (WorldObject *) *it;
                if (object->m_integers[std::string("id")] == id) {
                    result = load_object_info(info, object);
                }
            }
        }
    }

    return result;
}
예제 #23
0
int main() {
    int i;
    monte_carlo_init();
    Map map;
    Particle particles[NUM_PARTICLES];
    float block_positions[NUM_BLOCKS];

    block_positions[0] = BLOCK_POS_1;
    block_positions[1] = BLOCK_POS_2;
    block_positions[2] = BLOCK_POS_3;

    map = create_map(NUM_BLOCKS, block_positions, 0);

    for (i = 0; i < NUM_PARTICLES; i++) {
        particles[i].position = (random_float()) * 360;
    }

    find_location(map, particles);

    return 0;
}
예제 #24
0
/*
 * Ancienne version de load_huffman.
 * On ne devrait plus en avoir besoin, mais le main appelle encore
 * cette version.
 */
int load_huffman_table_size(FILE * movie,
                            uint16_t DHT_section_length,
                            uint8_t DHT_section_info,
                            huff_table_t * ht)
{
    uint8_t buffer = 0;
    int32_t size = 0, i = 0, j = 0;
    uint8_t num_values[16];
    huff_table_t *current_ptr = NULL;
    // ht est la racine de l'arbre
    // rien d'autre n'est alloué !!!

    ht->code = 0;
    ht->value = 0;
    ht->is_elt = 0;
    ht->parent = NULL;
    ht->left = NULL;
    ht->right = NULL;
    // récupération des longueurs :
    for (i=0 ; i < 16 ; i++) {
        NEXT_TOKEN(buffer);
        num_values[i] = buffer;
    }
    size = 16;
    for (i = 0 ; i < 16 ; i++) {
        for (j = 0 ; j < num_values[i] ; j++) {
            current_ptr = find_location(ht, i+1);
            if(current_ptr == NULL) {
                printf("Oops ! No location found, exiting...\n");
                return -1;
            }
            size++;
            NEXT_TOKEN(buffer);
            current_ptr->value = buffer;
            APRINTF("Value %02x has code %02x(%d)\n", buffer, current_ptr->code,i+1);
            current_ptr->is_elt = 1;
        }
    }
    return (size);
}
예제 #25
0
void do_mpgoto( CHAR_DATA *ch, char *argument )
{
    char             arg[ MAX_INPUT_LENGTH ];
    ROOM_INDEX_DATA *location;

    if ( !IS_NPC( ch ) )
    {
        send_to_char( C_DEFAULT, "Huh?\n\r", ch );
	return;
    }

    if ( IS_AFFECTED( ch, AFF_CHARM ) )
    {
        return;
    }

    one_argument( argument, arg );
    if ( arg[0] == '\0' )
    {
	bug( "Mpgoto - No argument: vnum %d.", ch->pIndexData->vnum );
	return;
    }

    if ( ( location = find_location( ch, arg ) ) == NULL )
    {
	bug( "Mpgoto - No such location: vnum %d.", ch->pIndexData->vnum );
	return;
    }

    if ( location == ch->in_room )
      return;

    if ( ch->fighting != NULL )
	stop_fighting( ch, TRUE );

    char_from_room( ch );
    char_to_room( ch, location );

    return;
}
static gboolean
um_crop_area_button_press_event (GtkWidget      *widget,
                                 GdkEventButton *event)
{
        UmCropArea *area = UM_CROP_AREA (widget);
        GdkRectangle crop;

        if (area->priv->browse_pixbuf == NULL)
                return FALSE;

        crop_to_widget (area, &crop);

        area->priv->last_press_x = (event->x - area->priv->image.x) / area->priv->scale;
        area->priv->last_press_y = (event->y - area->priv->image.y) / area->priv->scale;
        area->priv->active_region = find_location (&crop, event->x, event->y);

        gtk_widget_queue_draw_area (widget,
                                    crop.x - 1, crop.y - 1,
                                    crop.width + 2, crop.height + 2);

        return FALSE;
}
예제 #27
0
void print_graph( struct ID_table *ID )
{
    int i, j;
    int row = 0, col = 0;
    int tmp_row = 0, tmp_col = 0;
    
    find_location( ID -> birth_location, &row, &col);
    
    if( ID -> sex == 'M' )
        printf("%s", KBLU);
    else
        printf("%s", KRED);
    for( i = 0 ; i <= row ; i++ )
    {
        system("clear");
        for( j = 0 ; j < 59 ; j++ )
            if( i == j )
                printf("%.*s%s%s", tmp_row, taiwan_map[j], ID -> result, taiwan_map[j] + 10);
            else
                printf("%s", taiwan_map[j]);
        usleep(100000);
    }
    for( i = 0 ; i <= col ; i++ )
    {
        system("clear");
        for( j = 0 ; j < 59 ; j++ )
            if( j == row )
            {
                printf("%.*s%s%s", tmp_col, taiwan_map[j], ID -> result, taiwan_map[j] + 10 + tmp_col);
                tmp_col++;
            }
            else
                printf("%s", taiwan_map[j]);
        usleep(100000);
    }
    
}
예제 #28
0
void generate_quest( CHAR_DATA * ch, CHAR_DATA * questman ) {
  CHAR_DATA * vsearch, * vsearch_next;
  CHAR_DATA * victim = NULL;
  /*  ROOM_INDEX_DATA *room;*/
  OBJ_INDEX_DATA * pObjIndex;
  OBJ_DATA * questitem;
  char       buf[ MAX_STRING_LENGTH ];
  long       mcounter;
  int        level_diff;

  /*  Randomly selects a mob from the world mob list. If you don't
     want a mob to be selected, make sure it is immune to summon.
     Or, you could add a new mob flag called ACT_NOQUEST. The mob
     is selected for both mob and obj quests, even tho in the obj
     quest the mob is not used. This is done to assure the level
     of difficulty for the area isn't too great for the player. */

  mcounter = 0;

  for ( vsearch = char_list; vsearch; vsearch = vsearch_next ) {
    vsearch_next = vsearch->next;

    if ( vsearch->deleted ) {
      continue;
    }

    level_diff = ch->level - vsearch->level;

    if ( ( level_diff <= 3 && level_diff > -5 )
         && ( IS_NPC( vsearch ) )
         && ( !CHECK_BIT( vsearch->in_room->area->area_flags, AREA_PROTOTYPE ) )
         && ( !CHECK_BIT( vsearch->in_room->area->area_flags, AREA_NO_QUEST ) )
         && ( vsearch->pIndexData->pShop == NULL )
         && ( vsearch->pIndexData->vnum != 1351 )
         && ( vsearch->pIndexData->vnum != 1350 )
         && ( ch->level <= vsearch->in_room->area->ulevel )
         && ( ch->level > vsearch->in_room->area->llevel )
         && ( !CHECK_BIT( vsearch->act, ACT_TRAIN ) )
         && ( !CHECK_BIT( vsearch->act, ACT_PRACTICE ) )
         && ( !CHECK_BIT( vsearch->in_room->room_flags, ROOM_SAFE ) )
         && ( !CHECK_BIT( vsearch->in_room->room_flags, ROOM_NO_OFFENSIVE ) ) ) {
      if ( number_range( 0, mcounter ) == 0 ) {
        victim = vsearch;
        mcounter++;
      }
    }
  }

  if ( !victim ) {
    sprintf( buf, "I'm sorry, but I don't have any quests for you at this time." );
    do_say( questman, buf );
    sprintf( buf, "Try again later." );
    do_say( questman, buf );
    ch->nextquest = 10;
    return;
  }

  if ( ( room = find_location( ch, victim->name ) ) == NULL ) {
    sprintf( buf, "I'm sorry, but I don't have any quests for you at this time." );
    do_say( questman, buf );
    sprintf( buf, "Try again later." );
    do_say( questman, buf );
    ch->nextquest = 10;
    return;
  }

  // 50% chance it will send the player on a 'recover item' quest.
  if ( chance( 50 ) ) {
    pObjIndex = get_obj_index( OBJ_VNUM_DUMMY );
    questitem = create_object( pObjIndex, ch->level );

    // pick a random item from the table
    struct quest_item_type item = quest_item_table[ RANDOM( quest_item_table ) ];

    questitem->name         = str_dup( item.name );

    sprintf( buf, "%s &R[QUEST]&X", item.short_desc);

    questitem->short_descr  = str_dup( buf );

    sprintf( buf, "%s &R[QUEST]&X", item.long_desc);

    questitem->description  = str_dup( buf );

    questitem->item_type    = ITEM_TRASH;
    questitem->wear_flags  ^= ITEM_TAKE;
    questitem->extra_flags ^= ITEM_GLOW;
    questitem->extra_flags ^= ITEM_NO_LOCATE;

    ch->questobj = questitem;

    if ( chance ( 50 ) ) {
      obj_to_room( questitem, room );
      sprintf( buf, "Vile pilferers have stolen %s from the royal treasury!", questitem->short_descr );
    } else {
      obj_to_char( questitem, victim );
      sprintf( buf, "An enemy of mine, %s, has stolen %s from the royal treasury!", victim->short_descr, questitem->short_descr );
    }

    do_say(questman, buf);

    do_say(questman, "My court wizardess, with her magic mirror, has pinpointed its location.");
    sprintf(buf, "Look in the general area of %s...", room->area->name);
    do_say(questman, buf);
    return;
  } else {
    switch ( number_range( 0, 1 ) ) {
      case 0:
        sprintf( buf, "An enemy of mine, %s, is making vile threats against the Oracle!", victim->short_descr );
        do_say( questman, buf );
        sprintf( buf, "This threat must be eliminated!" );
        do_say( questman, buf );
        break;

      case 1:
        sprintf( buf, "The realm's most heinous criminal, %s, has escaped from the dungeon!", victim->short_descr );
        do_say( questman, buf );
        sprintf( buf, "Since the escape, %s has murdered %d civilians!", victim->short_descr, number_range( 2, 20 ) );
        do_say( questman, buf );
        do_say( questman, "The penalty for this crime is death, and you are to deliver the sentence!" );
        break;
    }

    if ( room->name != NULL ) {
      sprintf(buf, "Seek %s out somewhere in the vicinity of %s!", victim->short_descr, room->area->name);
      do_say(questman, buf);
    }

    ch->questmob = victim;
  }

  return;
}
예제 #29
0
int main(int argc, char* argv[]){

  moab::ErrorCode rval;
  rval = dag->load_file("test_slabs.h5m");
  if(rval != moab::MB_SUCCESS) return -1;
  rval = dag->init_OBBTree();
  if(rval != moab::MB_SUCCESS) return -1;

  double x = 2.5;
  double y = 0.0;
  double z = 1.0;
  
  double t_l[15];

  generator_store *rn = new generator_store(omp_get_num_threads(),12345);

  unsigned int nps = 1000000;
  // loop over the history like loop
  #pragma omp parallel for  \
   private(rval) shared(t_l) 
  // #pragma omp parallel for
  for ( unsigned int i = 0 ; i < nps ; i++ ) {

    // each thread gets rn generator
    rn->reseed(omp_get_thread_num(),i);
    // make each seed unique
    //srand(i*123456);

    bool alive = true;
    moab::EntityHandle volume;
    double pos[3] = {x,y,z};
    //    double dir[3] = {1,0,0};
    double dir[3];
    dir[0] = rn->sample(omp_get_thread_num()); //rand();
    dir[1] = rn->sample(omp_get_thread_num()); //rand();
    dir[2] = rn->sample(omp_get_thread_num()); // rand();

    double magnitude = sqrt(dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2]);
    dir[0] = dir[0]/magnitude;
    dir[1] = dir[1]/magnitude;
    dir[2] = dir[2]/magnitude;

    // determine the start volume
    volume = find_location(x,y,z);
    while (alive) {
      moab::EntityHandle surf;
      double dist;
      if(dag->is_implicit_complement(volume)){
	alive = false;
	break;
      } else {
	rval = dag->ray_fire(volume,pos,dir,surf,dist);
	if(surf == 0 ) {
	  alive = false;
	  break;
	}
	rval = dag->next_vol(surf,volume,volume);
	pos[0] += dist*dir[0];
	pos[1] += dist*dir[1];
	pos[2] += dist*dir[2];
	
	int cel = dag->index_by_handle(volume);
        #pragma omp atomic
	t_l[cel] += dist;
      }
    }
  }

  for ( unsigned int i = 0 ; i < 10 ; i++ ) {
    std::cout << i+1 << " " << t_l[i+1]/(double)nps << std::endl;
  }
  return 0;
}
예제 #30
0
void do_at(struct char_data *ch, const char *argument)
{
    struct room_index_data *location = NULL;
    struct room_index_data *original;
    struct char_data *wch = NULL;
    struct char_data *vch = NULL;
    struct gameobject *on;
    char arg[MAX_INPUT_LENGTH];
    char cmd[MAX_STRING_LENGTH];

    DENY_NPC(ch)

        argument = one_argument(argument, arg);
    if (arg[0] == '\0' || argument[0] == '\0'
        || arg[0] == '?' || !str_cmp(arg, "help")) {
        show_help(ch->desc, "at_imm_command", NULL);
        return;
    }

    if (!str_prefix(arg, "random")) {
        struct area_data *area;
        char check[MAX_INPUT_LENGTH];

        argument = one_argument(argument, arg);
        area = NULL;
        one_argument(argument, check);
        if (!str_prefix(check, "area")) {
            argument = one_argument(argument, check);
            area = ch->in_room->area;
        }

        if (!str_prefix(arg, "room")) {
            location = get_random_room(ch, area);
        } else if (!str_prefix(arg, "mob")) {
            vch = get_random_npc(ch, area);
            location = vch->in_room;
        } else if (!str_prefix(arg, "char") || !str_prefix(arg, "player")) {
            vch = get_random_pc(ch, area);
            location = vch->in_room;
        }
    } else {
        location = find_location(ch, arg);
    }

    if (location == NULL) {
        send_to_char("No such location.\n\r", ch);
        return;
    }

    if (!is_room_owner(ch, location) && room_is_private(location) && get_trust(ch) < LEVEL_IMMORTAL) {
        send_to_char("That room is private right now.\n\r", ch);
        return;
    }

    original = ch->in_room;
    on = ch->on;

    char_from_room(ch);
    char_to_room(ch, location);
    if (vch != NULL) {
        if (expand_cmd(vch, argument, cmd, '@'))
            interpret(ch, cmd);
    } else {
        interpret(ch, argument);
    }
    /*
     * See if 'ch' still exists before continuing!
     * Handles 'at XXXX quit' case.
     */
    for (wch = char_list; wch != NULL; wch = wch->next) {
        if (wch == ch) {
            char_from_room(ch);
            char_to_room(ch, original);
            ch->on = on;
            break;
        }
    }

    return;
}