setptr(&contsp[items[c].contserial%HASHMAX], c);
contsp.insert(items[c].contserial, items[c].serial);
void get_item(P_CLIENT ps) // Client grabs an item{	int x,  npc=-1, c, amount, update = 0, serial;//	tile_st tile;	int z;// antichrist for trade fix	UOXSOCKET s = ps->GetSocket();	int cc = ps->GetCurrChar();	P_CHAR pc_currchar = MAKE_CHARREF_LR(cc);			serial = calcserial(buffer[s][1], buffer[s][2], buffer[s][3], buffer[s][4]);	if (serial == INVALID_SERIAL || buffer[s][1] < 0x40)		return;	// landscape or a character	P_ITEM pi = FindItemBySerial(serial);	if (pi == NULL)		return;		pc_currchar->disturbMed(s); // Meditation		// Zippy's stealing changes  	x = DEREF_P_ITEM(pi);	if (!items[x].isInWorld())  // Find character owning item	{		int loopexit = 0;		do  // Find character owning item		{			if (isCharSerial(items[x].contserial))			{				npc = calcCharFromSer(items[x].contserial);			}			else  // its an item			{				if (items[x].isInWorld())				{					npc=-1;					break;				}				x = calcItemFromSer(items[x].contserial);				// ANTICHRIST -- SECURE TRADE FIX				if (x!=-1) // LB overwriting x is essential here, dont change it!!!				{					if (items[x].layer == 0 && items[x].id() == 0x1E5E)					{						// Trade window???						serial = calcserial(items[x].moreb1, items[x].moreb2, items[x].moreb3, items[x].moreb4);						if (serial == INVALID_SERIAL)							return;						z = calcItemFromSer(serial);						if (z!=-1)							if ((items[z].morez || items[x].morez))							{								items[z].morez = 0;								items[x].morez = 0;								sendtradestatus(z, x);							}					}					// Blackwinds Looting is crime implementation					// changed slightly by Ripper					if (items[x].corpse != 0 && !pc_currchar->Owns(&items[x])) 					{ 						P_CHAR co = FindCharBySerial(items[x].ownserial);						if (items[x].more2 == 1 && Guilds->Compare(cc, DEREF_P_CHAR(co)) == 0) 						{ 							pc_currchar->karma -= 5; 							criminal(cc);							sysmessage(s, "You lost some karma!"); 						} 						npc = 0;					} // Criminal stuff					if (items[x].corpse != 0)						npc = 0;				} // end if x!=-1								if (x==-1)					npc = 0; 			}		} while ((npc==-1) &&(++loopexit < MAXLOOPS));	}		if (npc>0) // 0=corpse, hence >0 ..	{		if (!(pc_currchar->isGM()) && npc != cc && ! pc_currchar->Owns(&chars[npc]))		{// Own serial stuff by Zippy -^ Pack aniamls and vendors.			bounce[1] = 0;			Xsend(s, bounce, 2);			if (ps->IsDragging())			{				ps->ResetDragging();				item_bounce3(pi);				pi->magic = 3;			} 			return;		}	}	// End Zippy's change		// Boats->	if (x!=-1 && npc!=-1)	{		if (items[x].multis>0)			imultisp.remove(items[x].multis, items[x].serial);		items[x].startDecay();		// End Boats Change				// AntiChrist -- for poisoned items		if (items[x].layer>0)		{			chars[npc].removeItemBonus(&items[x]);	// remove BONUS STATS given by equipped special items		}		if ((items[x].trigon==1) && (items[x].layer != 0) && (items[x].layer != 15) && (items[x].layer < 19))// -Frazurbluu- Trigger Type 2 is my new trigger type *-		{			triggerwitem(s, DEREF_P_ITEM(pi), 1); // trigger is fired		}				// AntiChrist -- for poisoned items		if (items[x].poisoned)		{			chars[npc].poison -= items[x].poisoned;			if (chars[npc].poison < 0)				chars[npc].poison = 0;		}	}	if (pi != NULL)	{		if (pi->corpse != 1)		{			UpdateStatusWindow(s, pi);			if (!pc_currchar->canPickUp(pi))			{				bounce[1] = 0;				Xsend(s, bounce, 2);				if (ps->IsDragging()) // only restore item if it got draggged before !!!				{					ps->ResetDragging();					item_bounce4(s, pi);				}			}			else			{				// AntiChrist bugfix for the bad bouncing bug ( disappearing items when bouncing )				DRAGGED[s] = 1;								pi->oldx = pi->pos.x;	// first let's save the position				pi->oldy = pi->pos.y;				pi->oldz = pi->pos.z;				pi->oldcontserial = pi->contserial;	// then let's save the container				pi->oldlayer = pi->layer;	// then the layer								pi->layer = 0;				if (!pi->isInWorld())					soundeffect(s, 0x00, 0x57);				if (pi->amount>1)				{					amount = (buffer[s][5] << 8) + buffer[s][6];					if (amount>pi->amount)						amount = pi->amount;					if (amount < pi->amount)					{						c=Items->MemItemFree();						items[c].Init(0);						memcpy(&items[c], pi, sizeof(cItem));  // Tauriel reduce code faster too						items[c].SetSerial(itemcount2);						itemcount2++;						items[c].amount = pi->amount - amount;						// Tauriel sorry, there is no way to make this call the item creation stuff// Why doing it twice?//						setptr(&itemsp[itemcount2%HASHMAX], c);//						itemcount2++; // important bugfix for items disappearing, lb						if (!items[c].isInWorld())							setptr(&contsp[items[c].contserial%HASHMAX], c);						if (items[c].ownserial!=-1)							setptr(&ownsp[items[c].ownserial%HASHMAX], c);						if (items[c].spawnserial!=-1)							setptr(&spawnsp[items[c].spawnserial%HASHMAX], c);												statwindow(s,cc);						RefreshItem(c);//AntiChrist					}										if (pi->id() == 0x0EED) // gold coin					{						int packnum = packitem(currchar[s]);						if (packnum!=-1) // lb							if (pi->contserial == items[packnum].serial)								update = 1;					}										pi->amount = amount;				}								// Tauriel remove item from world mapcells				mapRegions->Remove(pi); // remove this item from a map cell				pi->pos.x = 0;				pi->pos.y = 0;				pi->pos.z = 0;								pi->flags.isBeeingDragged=true;				pi->SetContSerial(-1);				if (pi != NULL) // Ripper...adds weight to the players cursor when carrying a item.				{					int amt = 0, wgt;					wgt = (int)Weight->LockeddownWeight(pi, &amt, 0);					pc_currchar->weight += wgt;					update = 1;				}			}		}	} // end of if i!=-1	if (update)		statwindow(s, DEREF_P_CHAR(pc_currchar));}