Page 3 of 6

Re: In-memory inventory

Posted: Thu Jul 15, 2010 7:10 pm
by VoidMain
rock5 wrote:
VoidMain wrote:Unfortunately, no, if you move around some items and press sort, BagId changes...
I wasn't aware of that. I have never ever used sort (and probably never will)^^.
VoidMain wrote:As for SlotNumber, well, is not there, at least not yet, can you check with me if there is any other function than the autosell that uses it? If its just that one we can move it fully to igf...
The only places I see SlotNumber used will become obsolete. Looks like AutoSell is the only thing that actually needs it.
VoidMain wrote:Icon i'm not getting it because i didn't see it used anywhere but maybe i missed something but, honestly, we have no use for icon... I mean, as users, only uses for icon might be for an addon but outside the game has little to no meaning at all...
I think icon was just added because it was a value returned by GetBagItemInfo. I'm sure it has never and will never be used in rombot.
VoidMain wrote:About speed: What you noticed, how it behaves? In here it takes abot 26ms when printing the data and then 2-3ms to update...
I'm not sure what you mean. The yellow data takes about 6s. The white data takes a fraction of a second. Or do you mean this?

Code: Select all

Inventory update took: 167
Inventory update took: 9
Yeah, that, that is inventory update, you notice that when printing is a bit slow (anyway 167 ms is no that slow :P) and 9 ms to update full inventory without printing, i think its an improvement ^^

Now i'm able to get the cooldown for consumables, so i'm adding that, i can't see tho, where is that timer running but i think is not a problem, we can just put a flag on it when we use, li ke this:

Code: Select all

self.LastTimeUsed = getTime();
And then a check:

Code: Select all

if ( deltaTime( getTime(), self.LastTimeUsed ) / 1000 ) > self.CoolDown then -- Colldown finished, we can use it again
Gonna add that and finnish the inventory class now, i gonna need your help for translating the autosell to IGF, tho i know you were playing with it and its quests functions...

And then, well just wait for testing and Administrator aproval.

About timing to the initial parse of tables: I think that even if it takes 20 seconds (thats 10 times of what it takes here but lets supose i have a nice pc because i live of it and not everyone has one), 20 secs is not that much time if we are getting a nice implementation of an inventory capable of updating itself every second if we need it...

Re: In-memory inventory

Posted: Fri Jul 16, 2010 12:57 am
by VoidMain
Ok, these are complete replacements, in my testings it works just fine.

Added CEquipItem because i found equipment in memory and it has the same structure as inventory so we can now check for dura and equiped status alot more eficiently and faster.

To test just include it in userfunctions.lua and it will overwrite definitions from inventory and item because names are the same.

Code: Select all

include("classes/MemoryTable.lua");
include("classes/MemoryInventory.lua");
	LoadTables();
	inventory = CInventory();
It needs a bit more testing and we need to translate the autosell function to igf, other than that its working :)

Let me know what you see.

Re: In-memory inventory

Posted: Fri Jul 16, 2010 2:06 am
by rock5
VoidMain wrote:Let me know what you see.
I think you need to include your updated addresses.lua as it looks like some offsets may be missing.

The error I'm getting says itemCountOffset is a nil value and I don't see the value assigned anywhere.

Re: In-memory inventory

Posted: Fri Jul 16, 2010 2:24 am
by VoidMain
rock5 wrote:
VoidMain wrote:Let me know what you see.
I think you need to include your updated addresses.lua as it looks like some offsets may be missing.

The error I'm getting says itemCountOffset is a nil value and I don't see the value assigned anywhere.
I'm sorry, fixed now, addresses included, i moved all ofssets and addresses to addresses.lua.

Re: In-memory inventory

Posted: Fri Jul 16, 2010 6:48 am
by rock5
VoidMain wrote:I'm sorry, fixed now, addresses included, i moved all ofssets and addresses to addresses.lua.
Now I get an error when starting up;

Code: Select all

Table not found for ID: 211659
scripts\rev/bot.lua:17: ... Files/micromacro/scripts/rev/classes/MemoryItem.lua:
112: attempt to perform arithmetic on field 'BaseItemAddress' (a nil value)
That's my Staff of Admiration. I had this staff during the last tests and it didn't cause an error so I don't know why it does now.

Re: In-memory inventory

Posted: Fri Jul 16, 2010 7:41 am
by VoidMain
rock5 wrote:
VoidMain wrote:I'm sorry, fixed now, addresses included, i moved all ofssets and addresses to addresses.lua.
Now I get an error when starting up;

Code: Select all

Table not found for ID: 211659
scripts\rev/bot.lua:17: ... Files/micromacro/scripts/rev/classes/MemoryItem.lua:
112: attempt to perform arithmetic on field 'BaseItemAddress' (a nil value)
That's my Staff of Admiration. I had this staff during the last tests and it didn't cause an error so I don't know why it does now.
And even weirder that i have one too and no error, but i know where might be the error, the fragmentation of the tables mainly depends on fragmentation of your memory so lets do a quick try, put this:

Code: Select all

for i = 1, 100 do
In lines 135 and 164 of MemoryTable.lua and let know if that fixes it.

Re: In-memory inventory

Posted: Fri Jul 16, 2010 8:03 am
by rock5
VoidMain wrote:

Code: Select all

for i = 1, 100 do
In lines 135 and 164 of MemoryTable.lua and let know if that fixes it.
Now I get error;

Code: Select all

Table not found for ID: 211659
scripts\rev/bot.lua:17: ...m Files/micromacro/scripts/rev/classes/EquipItem.lua:
45: attempt to perform arithmetic on field 'BaseItemAddress' (a nil value)

Re: In-memory inventory

Posted: Fri Jul 16, 2010 8:28 am
by VoidMain
rock5 wrote:
VoidMain wrote:

Code: Select all

for i = 1, 100 do
In lines 135 and 164 of MemoryTable.lua and let know if that fixes it.
Now I get error;

Code: Select all

Table not found for ID: 211659
scripts\rev/bot.lua:17: ...m Files/micromacro/scripts/rev/classes/EquipItem.lua:
45: attempt to perform arithmetic on field 'BaseItemAddress' (a nil value)
Hmm, still the same error, let me try to get the right patter to follow table... I'll be back to you in a bit ^^

Re: In-memory inventory

Posted: Fri Jul 16, 2010 11:56 am
by rock5
VoidMain wrote:Hmm, still the same error, let me try to get the right patter to follow table... I'll be back to you in a bit ^^
Forgot to ask, is this still correct for myfunction.lua?

Code: Select all

include("classes/MemoryTable.lua");
include("classes/MemoryInventory.lua");
LoadTables();
inventory = CInventory();

Re: In-memory inventory

Posted: Fri Jul 16, 2010 5:46 pm
by VoidMain
rock5 wrote:
VoidMain wrote:Hmm, still the same error, let me try to get the right patter to follow table... I'll be back to you in a bit ^^
Forgot to ask, is this still correct for myfunction.lua?

Code: Select all

include("classes/MemoryTable.lua");
include("classes/MemoryInventory.lua");
LoadTables();
inventory = CInventory();
Yes that is correct, lets try this fix, here is a new approach, seems like tables get alot of fragmentation when you filled up your RAM and it becomes harder to find the next block i believe this will correct it and it will find the parts correctly now.

If you still have problems please set:

Code: Select all

local debugTableIndexes = false;
To:

Code: Select all

local debugTableIndexes = true;
At line 11 of this file and check the output for the range that the system can't find...

Let me know how it works.

Re: In-memory inventory

Posted: Fri Jul 16, 2010 10:09 pm
by rock5
VoidMain wrote:Yes that is correct, lets try this fix, here is a new approach, seems like tables get alot of fragmentation when you filled up your RAM and it becomes harder to find the next block i believe this will correct it and it will find the parts correctly now.

If you still have problems please set:

Code: Select all

local debugTableIndexes = false;
To:

Code: Select all

local debugTableIndexes = true;
At line 11 of this file and check the output for the range that the system can't find...

Let me know how it works.
Had to change the 3 dots to 2 again on the first 2 lines of the file. You didn't update the wrong version did you?

Still got error;

Code: Select all

Name:
Table not found for ID: 211659
scripts\rev/bot.lua:17: ...m Files/micromacro/scripts/rev/classes/EquipItem.lua:
45: attempt to perform arithmetic on field 'BaseItemAddress' (a nil value)
The server went down before i could try the debugging. I'll do that after the servers come back online in 3 hours.

Re: In-memory inventory

Posted: Fri Jul 16, 2010 10:26 pm
by VoidMain
rock5 wrote:
VoidMain wrote:Yes that is correct, lets try this fix, here is a new approach, seems like tables get alot of fragmentation when you filled up your RAM and it becomes harder to find the next block i believe this will correct it and it will find the parts correctly now.

If you still have problems please set:

Code: Select all

local debugTableIndexes = false;
To:

Code: Select all

local debugTableIndexes = true;
At line 11 of this file and check the output for the range that the system can't find...

Let me know how it works.
Had to change the 3 dots to 2 again on the first 2 lines of the file. You didn't update the wrong version did you?
No is the right version, i have it that way because i use it outside the bot to try, in fact those inlude lines can be safely comented out to try in the bot...
rock5 wrote:Still got error;

Code: Select all

Name:
Table not found for ID: 211659
scripts\rev/bot.lua:17: ...m Files/micromacro/scripts/rev/classes/EquipItem.lua:
45: attempt to perform arithmetic on field 'BaseItemAddress' (a nil value)
The server went down before i could try the debugging. I'll do that after the servers come back online in 3 hours.
Ok, about that info it will be usefull to know hoy many ranges it added to that table before stoping and at wich id it stops (all that info is spitted when you turn debug on)
Many thanks for helping ^^

P.S.: You can still try, just get to login screen, tables are already loaded by then, put this file i'm attaching in rom root folder and execute:

Code: Select all

rom/TestTables
The table we are interested in is: WeaponObjectDB i need to know wich ranges its loading for you.

Re: In-memory inventory

Posted: Fri Jul 16, 2010 11:05 pm
by rock5
Wasn't sure how much information you needed so here's all of it.

Code: Select all

Name: WeaponObjectDB
Table starts with id: 210001             Dir: 9BCCB20
Adding range. Start: 210001     End: 211626     Address: 9BCCB20        Table#: 25
Readed from 9BC0000      at 0x4 9BFFC00 Original pointer: 9BC0000
Readed at 9BC0000        in 0x8 9BFFE00 ID: 211642
Returning NIL
Readed from 9BC0020      at 0x4 9BC0040 Original pointer: 9BC0000
4Readed at 9BC0020       in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC0040      at 0x4 9BC0080 Original pointer: 9BC0000
4Readed at 9BC0040       in 0x8 9BC0020 ID: 211625
Returning NIL
Readed from 9BC0060      at 0x4 9BC0040 Original pointer: 9BC0000
Readed at 9BC0060        in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC0080      at 0x4 9BC0100 Original pointer: 9BC0000
4Readed at 9BC0080       in 0x8 9BC0040 ID: 211624
Returning NIL
Readed from 9BC00A0      at 0x4 9BC00C0 Original pointer: 9BC0000
4Readed at 9BC00A0       in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC00C0      at 0x4 9BC0080 Original pointer: 9BC0000
Readed at 9BC00C0        in 0x8 9BC00A0 ID: 211621
Returning NIL
Readed from 9BC00E0      at 0x4 9BC00C0 Original pointer: 9BC0000
Readed at 9BC00E0        in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC0100      at 0x4 9BC0200 Original pointer: 9BC0000
4Readed at 9BC0100       in 0x8 9BC0080 ID: 211622
Returning NIL
Readed from 9BC0120      at 0x4 9BC0140 Original pointer: 9BC0000
4Readed at 9BC0120       in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC0140      at 0x4 9BC0180 Original pointer: 9BC0000
4Readed at 9BC0140       in 0x8 9BC0120 ID: 211617
Returning NIL
Received: 9BC0000       Returning: 0

Re: In-memory inventory

Posted: Fri Jul 16, 2010 11:24 pm
by VoidMain
rock5 wrote:Wasn't sure how much information you needed so here's all of it.

Code: Select all

Name: WeaponObjectDB
Table starts with id: 210001             Dir: 9BCCB20
Adding range. Start: 210001     End: 211626     Address: 9BCCB20        Table#: 25
Readed from 9BC0000      at 0x4 9BFFC00 Original pointer: 9BC0000
Readed at 9BC0000        in 0x8 9BFFE00 ID: 211642
Returning NIL
Readed from 9BC0020      at 0x4 9BC0040 Original pointer: 9BC0000
4Readed at 9BC0020       in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC0040      at 0x4 9BC0080 Original pointer: 9BC0000
4Readed at 9BC0040       in 0x8 9BC0020 ID: 211625
Returning NIL
Readed from 9BC0060      at 0x4 9BC0040 Original pointer: 9BC0000
Readed at 9BC0060        in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC0080      at 0x4 9BC0100 Original pointer: 9BC0000
4Readed at 9BC0080       in 0x8 9BC0040 ID: 211624
Returning NIL
Readed from 9BC00A0      at 0x4 9BC00C0 Original pointer: 9BC0000
4Readed at 9BC00A0       in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC00C0      at 0x4 9BC0080 Original pointer: 9BC0000
Readed at 9BC00C0        in 0x8 9BC00A0 ID: 211621
Returning NIL
Readed from 9BC00E0      at 0x4 9BC00C0 Original pointer: 9BC0000
Readed at 9BC00E0        in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC0100      at 0x4 9BC0200 Original pointer: 9BC0000
4Readed at 9BC0100       in 0x8 9BC0080 ID: 211622
Returning NIL
Readed from 9BC0120      at 0x4 9BC0140 Original pointer: 9BC0000
4Readed at 9BC0120       in 0x8 C82420  ID: 0
4Returning NIL
Readed from 9BC0140      at 0x4 9BC0180 Original pointer: 9BC0000
4Readed at 9BC0140       in 0x8 9BC0120 ID: 211617
Returning NIL
Received: 9BC0000       Returning: 0
Hmmm it should be adding the range 211626-213414

Code: Select all

Readed at 9BC0000        in 0x8 9BFFE00 ID: 211642
There is the problem, lets increase the threshold, change:

Code: Select all

	if ( threshold == nil ) then
			threshold = 10;
		end;
In lines 132 to 134 of MemoryTable, to:

Code: Select all

	if ( threshold == nil ) then
			threshold = 20;
		end;
And:

Code: Select all

		for i = 1, 10 do
In line 193 to:

Code: Select all

		for i = 1, 20 do
That should solve the problem, it seems like as more fragmented the table gets, more differences returns, it should be getting you to, 3-4 lines up of where you should supose to be but it takes you 16 lines up, so this change should solve it...

Let me know how it goes...

Re: In-memory inventory

Posted: Fri Jul 16, 2010 11:58 pm
by rock5
VoidMain wrote:That should solve the problem, it seems like as more fragmented the table gets, more differences returns, it should be getting you to, 3-4 lines up of where you should supose to be but it takes you 16 lines up, so this change should solve it...

Let me know how it goes...
These are the ranges it adds now;

Code: Select all

Adding range. Start: 210001     End: 211627     Address: 9BCCB40        Table#: 25
Readed from 9BC0000      at 0x4 9BFFFE0 Original pointer: 9BC0000
Returning: 9BFFFE0
Received: 9BC0000       Returning: 9BFFFE0
Adding range. Start: 211628     End: 213414     Address: 9BFFFE0        Table#: 25
I thought that 'Returning' value was interesting as it looks like the only one that returns a non zero value so I'd add it in this paste.

So I take it it work now. I'll test it further when the server comes back online.

Re: In-memory inventory

Posted: Sat Jul 17, 2010 12:07 am
by VoidMain
rock5 wrote:
VoidMain wrote:That should solve the problem, it seems like as more fragmented the table gets, more differences returns, it should be getting you to, 3-4 lines up of where you should supose to be but it takes you 16 lines up, so this change should solve it...

Let me know how it goes...
These are the ranges it adds now;

Code: Select all

Adding range. Start: 210001     End: 211627     Address: 9BCCB40        Table#: 25
Readed from 9BC0000      at 0x4 9BFFFE0 Original pointer: 9BC0000
Returning: 9BFFFE0
Received: 9BC0000       Returning: 9BFFFE0
Adding range. Start: 211628     End: 213414     Address: 9BFFFE0        Table#: 25
I thought that 'Returning' value was interesting as it looks like the only one that returns a non zero value so I'd add it in this paste.

So I take it it work now. I'll test it further when the server comes back online.
Yeah, that put me in the right path, it makes me think, how much fragmentation those tables can get, i thnk a value of 20 would be safe to everyone, wee nee more testing of course but that would do it...

BTW, how much RAM do you have? Just to make an educated guess abot how it behaves with different amounts...

Re: In-memory inventory

Posted: Sat Jul 17, 2010 12:54 am
by rock5
VoidMain wrote:BTW, how much RAM do you have? Just to make an educated guess abot how it behaves with different amounts...
2 GB

Re: In-memory inventory

Posted: Sat Jul 17, 2010 5:48 am
by rock5
After the maintenance I get this error when I run the bot.

Code: Select all

Name:
scripts\rev/bot.lua:17: ... Files/micromacro/scripts/rev/classes/MemoryItem.lua:125:
 attempt to perform arithmetic on local 'skillItemAddress' (a nil value)
This is what the WeaponObjectDB section looks like.

Code: Select all

Received: 9BACB60       Returning: 0
Name: WeaponObjectDB
Table starts with id: 210001             Dir: 9BACB20
Adding range. Start: 210001     End: 211626     Address: 9BACB20        Table#: 25
Readed from 9BA0000      at 0x4 9BDFC00 Original pointer: 9BA0000
Readed at 9BA0000        in 0x8 9BDFE00 ID: 211642
Returning: 9BDFE00
Falla 3

Tenemos ID: 211626      En dir: 9BDFE00
Readed 2: 211641
Readed 2: 211640
Readed 2: 211639
Readed 2: 211638
Readed 2: 211637
Readed 2: 211636
Readed 2: 211635
Readed 2: 211634
Readed 2: 211633
Readed 2: 211632
Received: 9BA0000       Returning: 0
TestTables also errors.

Code: Select all

... Files/micromacro/scripts/rev/classes/MemoryItem.lua:125: attempt to perform arit
hmetic on local 'skillItemAddress' (a nil value)

Re: In-memory inventory

Posted: Sat Jul 17, 2010 4:36 pm
by VoidMain
rock5 wrote:After the maintenance I get this error when I run the bot.

Code: Select all

Name:
scripts\rev/bot.lua:17: ... Files/micromacro/scripts/rev/classes/MemoryItem.lua:125:
 attempt to perform arithmetic on local 'skillItemAddress' (a nil value)
This is what the WeaponObjectDB section looks like.

Code: Select all

Received: 9BACB60       Returning: 0
Name: WeaponObjectDB
Table starts with id: 210001             Dir: 9BACB20
Adding range. Start: 210001     End: 211626     Address: 9BACB20        Table#: 25
Readed from 9BA0000      at 0x4 9BDFC00 Original pointer: 9BA0000
Readed at 9BA0000        in 0x8 9BDFE00 ID: 211642
Returning: 9BDFE00
Falla 3

Tenemos ID: 211626      En dir: 9BDFE00
Readed 2: 211641
Readed 2: 211640
Readed 2: 211639
Readed 2: 211638
Readed 2: 211637
Readed 2: 211636
Readed 2: 211635
Readed 2: 211634
Readed 2: 211633
Readed 2: 211632
Received: 9BA0000       Returning: 0
TestTables also errors.

Code: Select all

... Files/micromacro/scripts/rev/classes/MemoryItem.lua:125: attempt to perform arit
hmetic on local 'skillItemAddress' (a nil value)
Hmm, seems like my "detection" of consumables isn't working properly, here is a fix for that, just replace these two files and let me know how it goes now.

Re: In-memory inventory

Posted: Mon Jul 19, 2010 3:38 pm
by VoidMain
Any news about this?
Did it worked properly after the las patches i posted?
I'm sorry for absence, i had some troubles with my ISP and got disconnected all weekend :S