Beispiel #1
0
	//	Return the number of unique items matching the ids
	//
	int List::get_count(Uint16 item_id, int image_id)
	{
		info_available();
		if (last_count.matches(item_id, image_id))
			return last_count.get_count();
		int match_count = 0;
		for (size_t i=0; i<the_list.size(); ++i)
			if (the_list[i]->compare(item_id, image_id))
				match_count++;
		last_count.set(item_id, image_id, match_count);
		return last_count.get_count();
	}
Beispiel #2
0
	//	If the item_info file is missing or item_uid not enabled, show one time help
	//
	void List::help_if_needed(void)
	{
		if (shown_help)
			return;
		if (!info_available())
		{
			std::string message = "Could not load the item information file: " + item_info_filename;
			LOG_TO_CONSOLE(c_red1, message.c_str());
		}
		if (!item_uid_enabled)
			LOG_TO_CONSOLE(c_red1, "Use #item_uid (set to 1) to enable unique item information.");
		shown_help = true;
	}
Beispiel #3
0
	//	Find and item by the ids
	//
	Item *List::get_item(Uint16 item_id, int image_id)
	{
		info_available();
		if (last_item && last_item->compare(item_id, image_id))
			return last_item;
		for (size_t i=0; i<the_list.size(); ++i)
			if (the_list[i]->compare(item_id, image_id))
			{
				last_item = the_list[i];
				return last_item;
			}
		return 0;
	}
Beispiel #4
0
	void List::help_if_needed(void)
	{
		if (shown_help)
			return;
		if (!info_available())
		{
			std::string url("Download from: http://el.other-life.com/downloads/item_info.txt");
			find_all_url(url.c_str(), url.size());
			LOG_TO_CONSOLE(c_red1, "Could not load the item information file.");
			LOG_TO_CONSOLE(c_red1, url.c_str());
			LOG_TO_CONSOLE(c_red1, "Save the file in the data or updates/x_y_z directory then restart.");
		}
		if (!item_uid_enabled)
			LOG_TO_CONSOLE(c_red1, "Use #item_uid (set to 1) to enable unique item information.");
		shown_help = true;
	}
Beispiel #5
0
	//	Match passed string against specified item descriptions and return details for matches
	//	Element in results array set to zero if their description matches the passed string
	//
	void List::filter_by_description(Uint8 *storage_items_filter, const ground_item *storage_items, const char *filter_item_text, int no_storage)
	{
		if (!info_available() || (no_storage<=0) || !storage_items_filter || !storage_items)
			return;
		std::string needle(filter_item_text);
		std::transform(needle.begin(), needle.end(), needle.begin(), tolower);
		for (size_t i=0; i<static_cast<size_t>(no_storage); i++)
		{
			storage_items_filter[i] = 1;
			Item *item = get_item(storage_items[i].id, storage_items[i].image_id);
			if (item)
			{
				std::string haystack(item->get_description());
				std::transform(haystack.begin(), haystack.end(), haystack.begin(), tolower);
				if (haystack.find(needle) != std::string::npos)
					storage_items_filter[i] = 0;
			}
		}
	}