r7399 | bot not creating instance for maps.txt

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderators: Moderators, Developers

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

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

#11 Post 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.

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

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

#12 Post by EternalHarvest »

Field-related macro test fails.

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

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

#13 Post by EternalHarvest »

Undefined $field causes "random" errors since many things expect it to be defined.

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

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

#14 Post 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});

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

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

#15 Post by kLabMouse »

Hmm. I think it's OK. "baseName" should just that. or Not?

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

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

#16 Post by EternalHarvest »

In r8069 for testing.

pl4y8oy
Human
Human
Posts: 48
Joined: 21 Dec 2012, 07:48
Noob?: Yes

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

#17 Post 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.

rocknroll
Been there done that!
Been there done that!
Posts: 118
Joined: 19 Sep 2011, 07:30
Noob?: Yes

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

#18 Post 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 :(
Sorry, my english is very bad !

Locked