RaiseSkill.pm error | r7152

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

Moderators: Moderators, Developers

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

RaiseSkill.pm error | r7152

#1 Post by midnytblu »

Code: Select all

OpenKore version what-will-become-2.1 (SVN Version) 
@ai_seq = macro skill_raise
Network state = 5
Network handler = Network::DirectConnection
SVN revision: 7152
Loaded plugins:
  plugins/greed.pl (greedPlugin)
  plugins/macro.pl (macro)
  plugins/tele-search v2.pl (Tele-Search v2)

Error message:
Can't use an undefined value as an ARRAY reference at src/Task/RaiseSkill.pm line 114.

Stack trace:
Can't use an undefined value as an ARRAY reference at src/Task/RaiseSkill.pm line 114.
 at src/Task/RaiseSkill.pm line 109
	Task::RaiseSkill::onSkillInfo('packet_charSkills', 'HASH(0x4243894)', 'ARRAY(0x3d57cc4)') called at src/Plugins.pm line 431
	Plugins::callHook('packet_charSkills', 'HASH(0x4243894)') called at src/Network/Receive/ServerType0.pm line 5733
	Network::Receive::ServerType0::skills_list('Network::Receive::pRO=HASH(0x3ce1b34)', 'HASH(0x41df134)') called at src/Network/Receive.pm line 193
	Network::Receive::parse('Network::Receive::pRO=HASH(0x3ce1b34)', '\x{f}\x{1}\x{cc}\x{5}\x{1}\x{0}\x{0}\x{0}\x{0}\x{0}\x{9}\x{0}\x{0}\x{0}\x{1}\x{0}NV_BASIC\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{8}\x{0}\x{0}\x{0}\x{f}\x{0}\x{0}\x{0}\x{0}\x{9}\x{0}\x{0}\x{0}\x{0}\x{0}\x{5}\x{0}\x{0}\x{0}\x{1}\x{0}MG_SRECO...') called at src/functions.pl line 1319
	main::parseIncomingMessage('\x{f}\x{1}\x{cc}\x{5}\x{1}\x{0}\x{0}\x{0}\x{0}\x{0}\x{9}\x{0}\x{0}\x{0}\x{1}\x{0}NV_BASIC\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{8}\x{0}\x{0}\x{0}\x{f}\x{0}\x{0}\x{0}\x{0}\x{9}\x{0}\x{0}\x{0}\x{0}\x{0}\x{5}\x{0}\x{0}\x{0}\x{1}\x{0}MG_SRECO...') called at src/functions.pl line 664
	main::mainLoop_initialized() called at src/functions.pl line 70
	main::mainLoop() called at src/Interface.pm line 75
	Interface::mainLoop('Interface::Console::Win32=HASH(0x2d41c1c)') called at openkore.pl line 96
	main::__start() called at start.pl line 129

Died at this line:
  		}
* 	} elsif ($self->{state} == IDLE && $char->{points_skill} > 0 && @{$self->{skills}}) {
  		debug "RaiseSkill - onSkillInfo - IDLE\n", "Task::RaiseSkill" if DEBUG;

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

Re: RaiseSkill.pm error | r7152

#2 Post by midnytblu »

thanks EternalHarvest for the fix but how come the 'skill_raise' process is always in the AI sequence?

Code: Select all

ai_seq (auto) = skill_raise
it stays there and stops kore from functioning (and eventually start.exe crashes on some of my chars).
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: RaiseSkill.pm error | r7152

#3 Post by EternalHarvest »

Confirmed: things that depend on AI::isIdle (random walk) are broken because of permanent entity in AI sequence.

Also, "ai clear" wipes skill_raise and it never comes back because it's created at startup.
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: RaiseSkill.pm error | r7152

#4 Post by Technology »

midnytblu, thank you for reporting the bug.
midnytblu wrote:thanks EternalHarvest for the fix but how come the 'skill_raise' process is always in the AI sequence?

Code: Select all

ai_seq (auto) = skill_raise
The skill_raise task, how it is now, has to stay in the queue.
It is the first task of its kind in kore.
Other approaches are possible, but they would have to rely on externally (somewhere else in the code) re-adding a new task.
With the approach i used, the task is pretty much autonomous, it looks much like a plugin if you will.
What you see in SkillRaise.pm is what you get, it uses no global variables that are maliciously changed in various locations.
All the code in SkillRaise.pm has 1 goal, to upgrade your skills in the most effective (reliable) and efficient (using least amount of CPU) way.
(ex. To be efficient, the task also avoids unnecessary re-reading of skillsAddAuto_list and checking every time.)
(ex. To become effective, the task has 'almost all' relevant code in 1 file, providing a better oversight)

Tho, it would be good if the task could actually put itself in inactive tasks,
hooking on conditions to get itself out of inactive tasks under certain conditions.
(that tasks internal IDLE state is such attempt, but this way the task still stays active and thus requires attention of the TaskManager)
If we decide to go with permanent tasks, I'm not sure how to deal with priority, give them lowest?

The SkillRaise process, to me, looks like an embedded system in the way that it is never done.
The hooks represent IO, and interrupt calls (to get the processor out of its sleep).
As you can see, I'm just experimenting with what kore can do today.
The SkillRaise task is by no means perfect, but it will become better.
EternalHarvest wrote:Confirmed: things that depend on AI::isIdle (random walk) are broken because of permanent entity in AI sequence.

Also, "ai clear" wipes skill_raise and it never comes back because it's created at startup.
ah good point, AI::isIdle forgot about that.

What about remodeling the AI queue to:
- not remove permanent tasks
- not take these permanent tasks in account when checking for AI::isIdle
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: RaiseSkill.pm error | r7152

#5 Post by kLabMouse »

Technology wrote:
EternalHarvest wrote:Confirmed: things that depend on AI::isIdle (random walk) are broken because of permanent entity in AI sequence.

Also, "ai clear" wipes skill_raise and it never comes back because it's created at startup.
ah good point, AI::isIdle forgot about that.

What about remodeling the AI queue to:
- not remove permanent tasks
- not take these permanent tasks in account when checking for AI::isIdle
Hmm... May-be add special Case of Tasks: Passive Task.
These new Tasks can set Itself to Idle State, and wake based on Hook's.
Because task's could be Idle, the AI::isIdle will function normally.
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: RaiseSkill.pm error | r7152

#6 Post by Technology »

EternalHarvest wrote:Confirmed: things that depend on AI::isIdle (random walk) are broken because of permanent entity in AI sequence.
Just to be clear, this is not longer an issue, since Eternal added the task to the taskManager instead of to the queue.
EternalHarvest wrote:Also, "ai clear" wipes skill_raise and it never comes back because it's created at startup.
what about:
- let the task add another instance of itself whenever it was stopped using the onStop callbacklist (dunno if this is allowed)
- make the task to override stop and not actually set the task stopped (again, is this allowed?)

there are so many ways to do it, which one is best?
it seems like there are no rules that prevent the system from being misused :?

here's the patch for the first option:

Code: Select all

Index: Task/RaiseSkill.pm
===================================================================
--- Task/RaiseSkill.pm	(revision 7158)
+++ Task/RaiseSkill.pm	(working copy)
@@ -21,7 +21,7 @@
 use Carp::Assert;
 use base qw(Task);
 use Modules 'register';
-use Globals qw(%config $net $char $messageSender);
+use Globals qw(%config $net $char $messageSender $taskManager);
 use Network;
 use Plugins;
 use Skill;
@@ -43,6 +43,7 @@
 	my $self = $class->SUPER::new(@_);
 
 	$self->init();
+	$self->{callbackID} = $self->onStop->add($self, \&onStopMe);
 
 	my @holder = ($self);
 	Scalar::Util::weaken($holder[0]);
@@ -127,6 +128,13 @@
 	}
 }
 
+sub onStopMe {
+	my ($self) = @_;
+	$self->onStop->remove($self->{callbackID});
+	$taskManager->add(new Task::RaiseSkill());
+}
+
+# overriding Task's iterate
 sub iterate {
 	my ($self) = @_;
 	return if ($self->{state} == IDLE || !$char || $net->getState() != Network::IN_GAME);
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: RaiseSkill.pm error | r7152

#7 Post by kLabMouse »

Callback better after Weaken.
Or. if Base package has that method, just override it.
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: RaiseSkill.pm error | r7152

#8 Post by Technology »

kLabMouse wrote:Callback better after Weaken.
Or. if Base package has that method, just override it.
which method?
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: RaiseSkill.pm error | r7152

#9 Post by kLabMouse »

Technology wrote:
kLabMouse wrote:Callback better after Weaken.
Or. if Base package has that method, just override it.
which method?
You use Weaken on $self, so better to place it after you use Weaken on $self.
Or... Just override 'stop' sub.
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: RaiseSkill.pm error | r7152

#10 Post by Technology »

ok, the task now overrides task's stop

Code: Select all

sub stop {}
the task was also rewritten, so test please.

EDIT: this bug was fixed so closing
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!