Page 2 of 2

Re: r7399 | bot not creating instance for maps.txt

Posted: 12 Jul 2011, 12:06
by EternalHarvest
Since maps may be aliased not only in case they're identical to each other, but just because they use the same "base" (pvp_y_1-1.gat#prontera.gat#), there's many possible bugs there.

saveMap;
lockMap;
allowedMaps;
can't move to any map with name different from baseName, would move to baseName instead;
NPC name cache;
portals (at least in Wx);
party member positions (at least in Wx);
displayed field names (at least in Wx - map, NPC Talk);
etc

Approach like "threat all copies as they would have been the single location" may work with instances (or maybe not), but it isn't suitable for aliased maps at all.

Re: r7399 | bot not creating instance for maps.txt

Posted: 03 Aug 2011, 20:37
by EternalHarvest
Field-related macro test fails.

Re: r7399 | bot not creating instance for maps.txt

Posted: 28 Aug 2011, 18:58
by EternalHarvest
Undefined $field causes "random" errors since many things expect it to be defined.

Re: r7399 | bot not creating instance for maps.txt

Posted: 11 Jul 2012, 19:41
by EternalHarvest
How about we redefine Field->baseName to mean "true field's name, just without instance ID"? Probably nothing (except some user interface) should ever care about which name is being aliased to which.

Tested: portals, NPCs, lockMap.

Code: Select all

Index: src/Field.pm
===================================================================
--- src/Field.pm	(revision 8047)
+++ src/Field.pm	(working copy)
@@ -380,8 +380,10 @@
 # and/or the distance map file.
 sub loadByName {
 	my ($self, $name, $loadDistanceMap) = @_;
-	($self->{baseName}, $self->{instanceID}) = $self->nameToBaseName($name);
-	my $file = $self->{baseName} . ".fld";
+	my $baseName;
+	($baseName, $self->{instanceID}) = $self->nameToBaseName($name);
+	$self->{baseName} = $baseName;
+	my $file = $self->sourceName . ".fld";
 
 	if ($Settings::fields_folder) {
 		$file = File::Spec->catfile($Settings::fields_folder, $file);
@@ -392,6 +394,7 @@
 
 	if (-f $file) {
 		$self->loadFile($file, $loadDistanceMap);
+		$self->{baseName} = $baseName;
 		$self->{name} = $name;
 	} else {
 		FileNotFoundException->throw("No corresponding field file found for field '$name'.");
@@ -402,13 +405,21 @@
 sub nameToBaseName {
 	my ($self, $name) = @_;
 	
-	my ($baseName, $instanceID);
+	my ($instanceID);
 
 	if ($name =~ /^(\d{3})(\d@.*)/) { # instanced maps, ex: 0021@cata
 		$instanceID = $1;
 		$name = $2;
 	}
 
+	return ($name, $instanceID);
+}
+
+sub sourceName {
+	my ($self) = @_;
+	my $name = $self->baseName;
+	my $baseName;
+
 	if ($baseName = $masterServer->{"field_$name"}) {
 		# Handle server-specific versions of the field from servers.txt
 	} elsif ($baseName = $mapAlias_lut{"$name"}) {
@@ -421,9 +432,7 @@
 		$baseName = $name;
 	}
 
-	return ($baseName, $instanceID);
-
-	# tl;dr $name =~ s/^\d{3}(?=\d@)//; return $masterServer->{"field_$name"} || $mapAlias_lut{$name} || $name;
+	return $baseName;
 }
 
 1;
Index: src/Interface/Wx/MapViewer.pm
===================================================================
--- src/Interface/Wx/MapViewer.pm	(revision 8047)
+++ src/Interface/Wx/MapViewer.pm	(working copy)
@@ -463,7 +463,7 @@
 sub _loadMapImage {
 	my $self = shift;
 	my $field = shift;
-	my $name = $field->baseName;
+	my $name = $field->sourceName;
 
 	if (-f $self->_map("$name.jpg")) {
 		return _loadImage($self->_map("$name.jpg"), $self->{zoom});

Re: r7399 | bot not creating instance for maps.txt

Posted: 11 Jul 2012, 20:08
by kLabMouse
Hmm. I think it's OK. "baseName" should just that. or Not?

Re: r7399 | bot not creating instance for maps.txt

Posted: 15 Jul 2012, 20:12
by EternalHarvest
In r8069 for testing.

Re: r7399 | bot not creating instance for maps.txt

Posted: 05 Feb 2013, 04:47
by pl4y8oy
Hi,

Sorry to bringup old subject, but is openkore still support instanced map ?

I tried on 1@mist, and it doesnt work. I need to do manual things:
1. copy the 1@mist.fld to the instanced name (e.g. 0o71@mist.fld)
2. add it in maps.txt
3. change the map name in portals.txt

and it works, but each time I re-enter the new instanced map, I need to do all again.

Thx in advance.

PS. I'm botting in iRO.

Re: r7399 | bot not creating instance for maps.txt

Posted: 30 Mar 2013, 06:35
by rocknroll

Code: Select all

sub nameToBaseName {
	my ($self, $name) = @_;
	
	my ($instanceID);

	if ($name =~ /^(\w{3})(\d@.*)/) { # instanced maps, ex: 0021@cata
		$instanceID = $1;
		$name = $2;
	}

	return ($name, $instanceID);
}
instanceID is not only a digit, am i wrong change that with \w ??
*sorry for my english is bad :(