cMapObjects::getInstance()->add( pi );
void endtrade(SERIAL serial){	unsigned char msg[30];	P_ITEM pi_cont1 = NULL, pi_cont2 = NULL;	pi_cont1 = FindItemBySerial(serial);	if (pi_cont1 == NULL) 		return; // LB, crashfix	pi_cont2 = FindItemBySerial(calcserial(pi_cont1->moreb1(), pi_cont1->moreb2(), pi_cont1->moreb3(), pi_cont1->moreb4()));	if (pi_cont2 == NULL) return; // LB, crashfix	P_CHAR pc1 = FindCharBySerial(pi_cont1->contserial);	P_CHAR pc2 = FindCharBySerial(pi_cont2->contserial);	P_ITEM pi_bp1 = Packitem(pc1);	if (pi_bp1 == NULL) return;	P_ITEM pi_bp2 = Packitem(pc2);	if (pi_bp2 == NULL) return;	UOXSOCKET s1 = calcSocketFromChar(pc1);	UOXSOCKET s2 = calcSocketFromChar(pc2);	msg[0]=0x6F;//Header Byte	msg[1]=0x00;//Size	msg[2]=0x11;//Size	msg[3]=0x01;//State byte	LongToCharPtr(pi_cont1->serial,msg+4);	msg[8]=0;	msg[9]=0;	msg[10]=0;	msg[11]=0;	msg[12]=0;	msg[13]=0;	msg[14]=0;	msg[15]=0;	msg[16]=0;	if (s1 > -1)	// player may have been disconnected (Duke)		Xsend(s1, msg, 17);	msg[0]=0x6F;//Header Byte	msg[1]=0x00;//Size	msg[2]=0x11;//Size	msg[3]=0x01;//State byte	LongToCharPtr(pi_cont2->serial,msg+4);	msg[8]=0;	msg[9]=0;	msg[10]=0;	msg[11]=0;	msg[12]=0;	msg[13]=0;	msg[14]=0;	msg[15]=0;	msg[16]=0;	if (s2 > -1)	// player may have been disconnected (Duke)		Xsend(s2, msg, 17);	vector<SERIAL> vecContainer = contsp.getData(pi_cont1->serial);	unsigned int ci;	for ( ci = 0; ci < vecContainer.size(); ci++)	{		P_ITEM pi = FindItemBySerial(vecContainer[ci]);		if (pi != NULL)			if ((pi->contserial==pi_cont1->serial))			{				if (pi->glow != INVALID_SERIAL) 					glowsp.remove(pc2->serial, pi->serial); // lb, glowing stuff				pi->setContSerial(pi_bp1->serial);				if (pi->glow != INVALID_SERIAL) 					glowsp.insert(pc1->serial, pi->serial);				pi->pos.x = RandomNum(50, 130);				pi->pos.y = RandomNum(50, 130);				pi->pos.z=9;				if (s1 != -1)					pi->update();			}	}	vecContainer.clear();	vecContainer = contsp.getData(pi_cont2->serial);	for (ci = 0; ci < vecContainer.size(); ci++)	{		P_ITEM pi = FindItemBySerial(vecContainer[ci]);		if (pi != NULL)			if ((pi->contserial==pi_cont2->serial))			{				if (pi->glow != INVALID_SERIAL) 					glowsp.remove(pc2->serial, pi->serial); // lb, glowing stuff				pi->setContSerial(pi_bp2->serial);				if (pi->glow != INVALID_SERIAL) 					glowsp.insert(pc1->serial, pi->serial);				pi->pos.x=50+(rand()%80);				pi->pos.y=50+(rand()%80);				pi->pos.z=9;				if (s2 != -1)					pi->update();			}	}	Items->DeleItem(pi_cont1);	Items->DeleItem(pi_cont2);}