[FIXED] PC vendors: No Price displayed.

Here we stuff all the bugs we've managed to squash/squish/squelch.
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

After some testing I found that chars that don't own the player vendor could actually put items into the vendors backpack, but without beeing asked for a price and description.

I have fixed this now. Normal players can now only put items into the player vendors backpack when they own the vendor. Counselors/GMs/Admins will be asked for a price and description, even if they don't own the vendor.
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Well, to reproduce, I simply added an empty deed ('ADD 0x14f0 I think) and set it to a player vendor deed ('SET TYPE 217) then doubleclicked it in the middle of nowhere. I was using a GM character at the time.
-= Ho Eyo He Hum =-
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

How does the vendor respond to the "vendor gold" or "vendor status" command. The only reason I can think of that he wasn't asking for a price is that your char no longer is the owner of that vendor.
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Oops, sorry, missed that. Both "vendor status" and "vendor gold" makes the vendor respond with "I don't work for you!".
-= Ho Eyo He Hum =-
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

Oops, sorry, missed that. Both "vendor status" and "vendor gold" makes the vendor respond with "I don't work for you!".
So your char is no longer the owner of the vendor. Can you take a look at the wordfiles and compare the OwnerID tag to the serial of the char that should own the vendor?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Hmm. After adding a new player vendor, I saved and then checked the worldfiles; the new player vendor has OwnerID=0x0 (my character has the serial 0x0 0x0 0x0 0x0 overhead). After a restart, the OwnerID tag seems to be removed (possibly because it's 0).

I tried the same with a different character, and the vendor is still owned by that character after a restart.

So the problem lies with the serial of my GM character (0x0 0x0 0x0 0x0) and thus only affects the very first character created on a shard.
-= Ho Eyo He Hum =-
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Yes, that is the case, and I found the reason why line 1824 in CBaseObject.cpp remove the lines

Code: Select all

	if( owner != NULL )
	{
line 1827 add the line

Code: Select all

	if( tmpSerial != INVALIDSERIAL )
line 1829 remove the line

Code: Select all

	}
Scott
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

But the owner is intialised with NULL, not INVALIDSERIAL. Wouldn't this cause that the very first character to own almost everything on the shard?
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Nope, because that is in PostLoadProcessing(), which means it happens immediately after we load the world, during which we bruteforce owner to store a SERIAL value rather than the CChar* it was meant to hold (this is due to the serial hash table not yet being populated completely).

So by the time we hit that check, owner will actually have a SERIAL value in it, and since serial's are always initialized as INVALIDSERIAL (and anything else is a valid serial) it should function just fine.

[EDIT]

As a bit of a side-note, the only circumstance in which this could cause a problem would be if a user did not have an owner= tag. In which case their owner would be set to 0. The only way around that would be always storing the owner as a SERIAL rather than a CChar*.
Scott
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

As a bit of a side-note, the only circumstance in which this could cause a problem would be if a user did not have an owner= tag. In which case their owner would be set to 0.
That's how it currently is for all objects without an owner. From the DumpBody() function:

Code: Select all

	if( ValidateObject( owner ) )
	{
		dumping << "OwnerID=" << "0x";
		try
		{
			dumping <<owner>GetSerial() << std::endl;
		}
		catch( ... )
		{
			dumping << "FFFFFFFF" << std::endl;
			Console << "EXCEPTION: CBaseObject::DumpBody(" << name << "[" << serial << "]) - 'Owner' points to invalid memory." << myendl;
		}
	}
The owner tag is only added if there is a valid owner.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

That being the case, for this fix to be backward compatible with old worldfiles, we'll need to change our storage of owner in CBaseObject to a SERIAL, re-calcing the owner every time we call GetOwner(). At which point the bit of code there in PostLoadProcessing() will be unnecesarry.
Scott
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

That being the case, for this fix to be backward compatible with old worldfiles, we'll need to change our storage of owner in CBaseObject to a SERIAL, re-calcing the owner every time we call GetOwner(). At which point the bit of code there in PostLoadProcessing() will be unnecesarry.
That seems to be the cleanest solution.
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Good work guys!

Just one request, when you get the backwards compatability issue sorted out, tell me which build it is in. All of the vendors on my shard are owned by GM at 0x000, I'd hate to get the ownership stripped when updating.

Just post which version it's in and I'll wait for Grimson's update.

Thanks again. Now I'm going to have to start what limited scripting I can do, so I feel like I'm contributing as well. 8)
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

Ok, I have put the fix on CVS. Xuri can you test if your char is now the owner of the vendor again (test it with "vendor status" or "vendor gold").
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Nope. The player vendor now has this in the worldfiles:
OwnerID=0xffffffff
-= Ho Eyo He Hum =-
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Have you tried setting yourself to be the owner again, saving, shutting down, restarting, and checking it?
Scott
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Bah, well THAT works. ;)
-= Ho Eyo He Hum =-
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Yeah, we can't always fix things retroactively. :)
Scott
Post Reply