items_control.txt and Mercenary Scrolls

This place is for Closed bug reports only. NOT for asking help!

Moderators: Moderators, Developers

Message
Author
sampah001
Noob
Noob
Posts: 3
Joined: 29 Jun 2009, 10:27
Noob?: Yes

Re: items_control.txt and Mercenary Scrolls

#11 Post by sampah001 »

i never see any item names with \"
some item names use \'
i think it will be no problem if we use \" to indicate item sentence start and end

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: items_control.txt and Mercenary Scrolls

#12 Post by EternalHarvest »

So you just want to switch from one unusable in configuration character to another and not to solve the problem. Why not use something like Text::Balanced::extract_quotelike which supports escaped delimiters and other stuff?

sampah001
Noob
Noob
Posts: 3
Joined: 29 Jun 2009, 10:27
Noob?: Yes

Re: items_control.txt and Mercenary Scrolls

#13 Post by sampah001 »

how about this? :?

Code: Select all

use Text::Balanced qw(extract_quotelike);
...
sub parseItemsControl {
	my $file = shift;
	my $r_hash = shift;
	undef %{$r_hash};
	my ($key, $args_text, %cache);

	my $reader = new Utils::TextReader($file);
	while (!$reader->eof()) {
		my $line = $reader->readLine();
		$line =~ s/\x{FEFF}//g;
		next if ($line =~ /^#/);
		$line =~ s/[\r\n]//g;
		$line =~ s/\s+$//g;
		if ($line =~ tr/"// eq 2) {
			$key = extract_quotelike($line);
			$args_text = $line;
			$args_text =~ s/$key//gs;
			$args_text =~ s/^\s//gs;
			$key =~ s/"//g;
		}
		else {
			$line =~ s/"//g;
			($key, $args_text) = $line =~ /^([\s\S]+?) (\d+[\s\S]*)/i;
		}
		next if ($key eq "");

		if ($cache{$args_text}) {
			$r_hash->{$key} = $cache{$args_text};
		} else {
			my @args = split / /, $args_text;
			my %item = (
				keep => $args[0],
				storage => $args[1],
				sell => $args[2],
				cart_add => $args[3],
				cart_get => $args[4]
			);
			# Cache similar entries to save memory.
			$r_hash->{$key} = $cache{$args_text} = \%item;
		}
	}
	return 1;
}
...

User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: items_control.txt and Mercenary Scrolls

#14 Post by kLabMouse »

Patch accepted.
moved to Fixed bug's.

midnytblu
Developers
Developers
Posts: 90
Joined: 14 Apr 2008, 09:37
Noob?: No
Location: prt_fild08 134 362

Re: items_control.txt and Mercenary Scrolls

#15 Post by midnytblu »

Unfortunately, a new bug emerges after this fix.
Seems like all items in items_control.txt that has spaces, has to be put inside quotation marks.

Should it be this way from now on?

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: items_control.txt and Mercenary Scrolls

#16 Post by EternalHarvest »

That was fixed in r7519.

Seems like item IDs are not supported here, but that's independent issue.

Post Reply