The getAuto do not work properly

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

Moderators: Moderators, Developers

Message
Author
sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

The getAuto do not work properly

#1 Post by sofax222 »

I found a problem with the getAuto setting.

When I set the "passive" to "0" and the "minAmount" to some number.
But it only is checked once, before open storage.
I traced the code. I found the following:
The code in src/Network/Receive/ServerType0.pm

Code: Select all

sub storage_opened {
	my ($self, $args) = @_;
	$storage{items} = $args->{items};
	$storage{items_max} = $args->{items_max};

	$ai_v{temp}{storage_opened} = 1;
	if (!$storage{opened}) {
		$storage{opened} = 1;
		$storage{openedThisSession} = 1;
		message T("Storage opened.\n"), "storage";
		Plugins::callHook('packet_storage_open');
	}
}
The global variable "$storage{openedThisSession}" is set to "1", after the storage is opened.
And then, it is never set back to "0".

The code in src/AI/CoreLogic.pm

Code: Select all

			if ($config{"getAuto_${i}_minAmount"} ne "" &&
			    $config{"getAuto_${i}_maxAmount"} ne "" &&
			    !$config{"getAuto_${i}_passive"} &&
			    (!$item ||
				 ($amount <= $config{"getAuto_${i}_minAmount"} &&
				  $amount < $config{"getAuto_${i}_maxAmount"})
			    )
			) {
				if ($storage{opened} && findKeyString(\%storage, "name", $config{"getAuto_$i"}) eq '') {
					if ($config{"getAuto_${i}_dcOnEmpty"}) {
 						message TF("Disconnecting on empty %s!\n", $config{"getAuto_$i"});
						chatLog("k", TF("Disconnecting on empty %s!\n", $config{"getAuto_$i"}));
						quit();
					}
				} else {
					if ($storage{openedThisSession} && findKeyString(\%storage, "name", $config{"getAuto_$i"}) eq '') {
					} else {
							my $sti = $config{"getAuto_$i"};
							if ($needitem eq "") {
								$needitem = "$sti";
							} else {$needitem = "$needitem, $sti";}
						}
				}
			}
.......
.......
		# Only autostorage when we're on an attack route, or not moving
		if ((!defined($routeIndex) || $attackOnRoute > 1) && $needitem ne "" &&
			$char->inventory->size() > 0 ){
	 		message TF("Auto-storaging due to insufficient %s\n", $needitem);
			AI::queue("storageAuto");
		}
		$timeout{'ai_storageAuto'}{'time'} = time;
We can see that, if the $storage{openedThisSession} is true (not 0), then never get the $needitem.
If the $needitem is empty, then never do the "storageAuto" task !

sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

Re: The getAuto do not work properly

#2 Post by sofax222 »

May be it is a problem in my configuration !
I will do more tests !

Locked