[FIXED] PC vendors: No Price displayed.
-
Grimson
- Developer
- Posts: 802
- Joined: Sat Jun 04, 2005 1:52 am
- Location: Germany
- Has thanked: 0
- Been thanked: 0
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.
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.
- Xuri
- Site Admin
- Posts: 3704
- Joined: Mon Jun 02, 2003 9:11 am
- Location: Norway
- Has thanked: 48 times
- Been thanked: 8 times
- Contact:
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.
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
Yes, that is the case, and I found the reason why line 1824 in CBaseObject.cpp remove the lines
line 1827 add the line
line 1829 remove the line
Code: Select all
if( owner != NULL )
{
Code: Select all
if( tmpSerial != INVALIDSERIAL )
Code: Select all
}
Scott
-
giwo
- Developer
- Posts: 1780
- Joined: Fri Jun 18, 2004 4:17 pm
- Location: California
- Has thanked: 0
- Been thanked: 0
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*.
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
That's how it currently is for all objects without an owner. From the DumpBody() function: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.
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;
}
}
-
Grimson
- Developer
- Posts: 802
- Joined: Sat Jun 04, 2005 1:52 am
- Location: Germany
- Has thanked: 0
- Been thanked: 0
That seems to be the cleanest solution.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.
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.
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.