pi->pos = p_petowner->pos;
int unmounthorse(UOXSOCKET s) // Get off a horse (Remove horse item and spawn new horse) { 	unsigned int ci = 0;	int ch;	P_ITEM pi; 	const P_CHAR p_petowner = currchar[s];	vector<SERIAL> vecContainer = contsp.getData(p_petowner->serial);	for ( ci = 0; ci < vecContainer.size(); ci++)	{		pi = FindItemBySerial(vecContainer[ci]);		if (pi->layer == 0x19 && !pi->free)		{			//////////////////////////////////////			// Lets 'unstable' the mount.			// Unmount the horse and take him out of			// stable 0.						bool found = false;			int stablemaster_serial = p_petowner->serial;			P_CHAR  p_pet = NULL;						p_petowner->onhorse = false;						vector<SERIAL> pets = stablesp.getData(stablemaster_serial);			unsigned int i;			for (i = 0; i < pets.size(); i++) 			{ 				p_pet = FindCharBySerial(pets[i]);				if (p_pet != NULL) 				{ 					if ( p_petowner->Owns(p_pet) && p_pet->stablemaster_serial == stablemaster_serial) // already stabled and owned by claimer ? 					{ 						found = true; 						break; 					} 				} 			} 						if (found) 			{				stablesp.remove(stablemaster_serial, p_pet->serial);								p_pet->stablemaster_serial = INVALID_SERIAL; // actual unstabling 				p_pet->timeused_last = getNormalizedTime(); 				p_pet->time_unused = 0; 				p_pet->pos.x = p_petowner->pos.x; 				p_pet->pos.y = p_petowner->pos.y; 				p_pet->pos.z = p_petowner->pos.z;				p_pet->npcWander = 0;								mapRegions->Remove(p_pet); 				mapRegions->Add(p_pet); 								for (ch = 0; ch < now; ch++) 				{ 					if (perm[ch])						impowncreate(ch, p_pet, 0); 				} 			} 			Items->DeleItem(pi); 			return 0; 		} 	} 	return -1; }