Need some Help form a Dev

Forum where anything UOX3-related goes - including, but not limited to: newbie-support, ideas, general questions, comments, etc and-so-forth.
Post Reply
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Need some Help form a Dev

Post by dragon slayer »

I am working on lw/ww and i was wondering how you guys fixed the architect bug. where it shows names of the scripted item name again??

i need pretty much detail because i have tryed about everything in my know how to fix it.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Not quite sure what you mean. It, if I understand correctly, single click at issue. Notably CPISingleClick::Handle() in cPlayerAction.cpp. The code you want, I think, is his:

Code: Select all

	if( i->GetName()[0] != '#' )
	{
		if( i->GetID() == 0x0ED5 )//guildstone
			realname = UString::sprintf( Dictionary->GetEntry( 101, tSock->Language() ).c_str(), i->GetName().c_str() );
		if( !i->isPileable() || getAmount == 1 )
		{
			if( mChar->IsGM() && !i->isCorpse() && getAmount > 1 )
				realname = UString::sprintf( "%s (%u)", i->GetName().c_str(), getAmount );
			else
				realname = i->GetName();
		}
		else
			realname = UString::sprintf( "%u %ss", getAmount, i->GetName().c_str() );
	}
	else
	{
		getTileName( (*i), realname );
		if( i->GetAmount() > 1 )
			realname = UString::number( getAmount ) + " " + realname;
	}
Basically, if it has a script given name (not '#'), then use it instead of looking it up.

Let me know if that doesn't cover it. If not, if you can describe better I'll help as best as I can.
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

Sorry should of said vendors

Remember the bug that was introduced around 4.0.3 and up clients. Where if you went to the architect and tryed to buy a house deed, and all it said was deed and not the scripted name. So you didnt see small house deed.

Will your single click fix that?
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Nope, thats a different ball of wax. That is the buy window. Similar concept though. CPacketSend.cpp, CPOpenBuyWindow class. This code is what you want I think. Similar idea of '#' vs named.

Code: Select all

void CPOpenBuyWindow::AddItem( CItem *toAdd, CTownRegion *tReg, UI16 &baseOffset )
{
	UI32 value = toAdd->GetBuyValue();
	if( cwmWorldState->ServerData()->RankSystemStatus() )
		value = calcValue( toAdd, value );
	if( cwmWorldState->ServerData()->TradeSystemStatus() )
		value = calcGoodValue( tReg, toAdd, value, false );

	std::string itemname;
	itemname.reserve( MAX_NAME );
	UI08 sLen = 0;
	UString temp	= toAdd->GetName() ;
	temp			= temp.simplifyWhiteSpace();
	if( temp.substr( 0, 1 ) == "#" )
	{
		itemname = UString::number( 1020000 + toAdd->GetID() );
		sLen = static_cast<UI08>(itemname.size() + 1);
	}
	else
		sLen = static_cast<UI08>(getTileName( (*toAdd), itemname )); // Item name length, don't strip the NULL (3D client doesn't like it)

	pStream.ReserveSize( baseOffset + 5 + sLen );
	pStream.WriteLong(   baseOffset, value );
	pStream.WriteByte(   baseOffset += 4, sLen );
	pStream.WriteString( baseOffset += 1, itemname, sLen );
	baseOffset += sLen;
}
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

Okay here is what i came up with I'm not to much of a coder my brother does most of it but he is stumped about this code as well.
Any help fixing this bug I'm sure lw users and ww users will be so gracefull

Code: Select all

bool sendshopinfo(int s, P_CHAR Vendor, P_ITEM pi)
{
	unsigned char m1[6096];
	unsigned char m2[6096];
	char itemname[256];
	char cFoundItems=0;
	memset(m1,0,6096);
	memset(m2,0,6096);
	memset(itemname,0,256);
	int k, m1t=0, m2t=0, value;
	unsigned char slen;

	m1[0]=0x3C; // Container content message
	m1[1]=0;// Size of message
	m1[2]=0;// Size of message
	m1[3]=0;//  Count of items
	m1[4]=0;// Count of items

	m2[0]=0x74;// Buy window details message
	m2[1]=0;// Size of message
	m2[2]=0;// Size of message
	LongToCharPtr(pi->serial,m2+3); //container serial number
	m2[7]=0; // Count of items;
	m1t=5;
	m2t=8;

#define ARCHIBUG 0
#if ARCHIBUG
	int num = pi->CountItems();
#endif

	int ci=0,loopexit=0;
	P_ITEM pj;
	while ( ((pj=pi->Search(&ci)) != NULL) && (++loopexit <MAXLOOPS>amount>0)		// don't count items with 0 amount 
								// (0x1a container items should never be deleted, hence they get a 0 if item out of stock 
		{
			if (m2t>6000 || m1t>6000) break;
					
			LongToCharPtr(pj->serial,m1+m1t+0);		//Item serial number
			ShortToCharPtr(pj->id(),m1+m1t+4);		//ID
			//m1[m1t+6]=0;							// Always zero (but already 0'ed out)
			ShortToCharPtr(pj->amount,m1+m1t+7);	// amount

#if ARCHIBUG
			ShortToCharPtr(num--,m1+m1t+9);
#else
			ShortToCharPtr(m1t,m1+m1t+9);
#endif

			ShortToCharPtr(m1t,m1+m1t+11);

			/// note, that's actually kind of a client bug resp. oddity
			/// normally, those two are for x/y of item
			/// but client sorts the items in 0x3c's by x/y after 0x74 being send, not like it had been added
			/// it does NOT sort 0x74. so we get a mismatch of ID+description if we add real x/y's
			/// to get them synched (both lists in same order) we need to add dummy x/y's that have same order like being added
			/// eg m1t, itemcount would work as well. just has to be monotonic increasing with itemcount		

			LongToCharPtr(pi->serial,m1+m1t+13);	// container serial
			ShortToCharPtr(pj->color(),m1+m1t+17);	// Item color

			m1[4]++; // Increase item count.
			m1t += 19;

			value=pj->calcBuyPrice(Vendor->region);

			LongToCharPtr(value,m2+m2t+0);			// item value
			if (!"#")
			{

	         slen=m2[m2t+4]=pj->getName(itemname);	// Item name length

			 for(k=0;k<slen;k++)
			 {
				m2[m2t+5+k]=itemname[k];			// item name
			 }
			}

			//slen = 7;
			//m2[m2t+4]=slen;
		

			//m2[m2t+5+0]='5';
			//m2[m2t+5+1]='0';
			//m2[m2t+5+2]='0';
			//m2[m2t+5+3]='0';
			//m2[m2t+5+4]='5';
			//m2[m2t+5+5]='5';
			//m2[m2t+5+6]=0;
			//m2[m2t+5+7]=0;
			
			
			
			m2[7]++;
			m2t += slen+5;		
			cFoundItems=1; //we found items so send message			
		}
	}

	if (cFoundItems==1)
	{
		ShortToCharPtr(m1t,m1+1);
		ShortToCharPtr(m2t,m2+1);
		
		XStartPkt(0x3c, m1t);
		XAddPkt(&m1[0+3], m1t-3);
		XFinishPkt(s);
		
		XStartPkt(0x74, m2t);
		XAddPkt(&m2[0+3], m2t-3);
		XFinishPkt(s);
		
		return true;
	}
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

dragon slayer wrote:Okay here is what i came up with I'm not to much of a coder my brother does most of it but he is stumped about this code as well.
Any help fixing this bug I'm sure lw users and ww users will be so gracefull

<snip>

Code: Select all

			if (!"#")
			{

	         slen=m2[m2t+4]=pj->getName(itemname);	// Item name length

			 for(k=0;k<slen;k++)
			 {
				m2[m2t+5+k]=itemname[k];			// item name
			 }
			}
That if condition is a tad funky. Could be the board though. Not sure on the behaviour of getName either. But I'd see it more like

Code: Select all

slen = pj->getName(itemname);
if( itemname != '#' )
{
         m2[m2t+4] = slen;	// Item name length

         for(k=0;k<slen;k++)
         {
                  m2[m2t+5+k]=itemname[k];			// item name
         }
}
That is my guess. But that seems funky if you have a name that IS '#'. I'll have a better look later.
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

Okay i tryed that but had to [0] for first letter but still

Code: Select all

		   if( itemname[0]!= '#' ) 
		   { 
                m2[m2t+4] = slen; // Item name length 

                for(k=0;k<slen;k++) 
				{ 
                   m2[m2t+5+k]=itemname[k]; // item name 
				} 
		   }
well this didnt change the effect of the name still see deed.

I'm just so stumped on this
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Oops, sorry. That is quite strange. I'll give it some more thought, but it should work I'd think?
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

what is so stange is if you remove the 4 on the id line and make it 0 you see the scripted names but if you put the 4 back you see the .mul names.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Which line specifically do you mean?
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

ShortToCharPtr(pj->id(),m1+m1t+4); //ID

this line
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Yeah... I remember fixing that bug in UOX....

Now the real issue, remembering HOW I fixed it. :P
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Think I found the problem.

The OpenBuyWindow (0x74) packet also uses the ItemsInContainer (0x3C) packet. However along with each item sent for the ItesmInContainer packet we also send 0xD6, which is the ToolTip packet introduced in AOS. You can find the full detail of how we implemented that packet around line 4615 of CPacketSend.cpp, but what is most important for the vendor buy window is the chunk around 4803 inside the block if( playerVendor )

Once you include that packet it should correctly display the custom names in the buy window again.
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

thank you so much for all of your help that bug has put lw and ww on a stand still since it came and well we just started to try and fix it again that info right there will fix it.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

*bows to giwo* You really took the ball and ran with it. I know I did a lot, but no doubt you know the codebase inside and out :) We've dumped a few hours int this puppy haven't we? lol
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Hey Maarc!

Yeah, I guess once I pound something in to this thick skull of mine, it's not very likely to fall out. :P

Of course I'd probably still be playing with HTML if you and EviL hadn't gotten me started tooling in C++.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Nah, you took to it like a duck to water, and done bloody well. Uox owes you for the hard work :)
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 »

Hear, hear! There have been many who've come along, stayed a short while and then moved on over the years, but you've stuck to UOX like a fly on sticky paper, giwo. ;) Excellent work.
-= Ho Eyo He Hum =-
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

I may not use uox as my emu but I do think all the work you have done here is very great and its agreat community. Even Fraz would tell you about how good uox has been to him.

Thinking about fraz and me was talking about uox the other night how it was are first emu. Oh i remember boats still beable to move across land the great days. I remember users asking and begging for a fix for that LOL because boats being parked at britain bank. LOL I remember when fix was added how many thank you. You all got.

I remember Xuri shard for uox was in dev for years. was a great world map. I can't beleive its gone now tho. the great days of uo can still be alive if we all make it.
Post Reply