Ejemplo n.º 1
0
int LuaGlobalFunctions_ToLower(lua_State * L)
{
	std::string oldstring = luaL_checkstring(L,1);
	if (!oldstring.size())
		RET_NIL(true);

	lua_pushstring(L, HEARTHSTONE_TOLOWER_RETURN(oldstring).c_str());
	return 1;
}
Ejemplo n.º 2
0
void AuctionHouse::SendAuctionList(Player* plr, WorldPacket * packet)
{
	uint32 start_index, current_index = 0;
	uint32 counted_items = 0;
	std::string auctionString;
	uint8 levelRange1, levelRange2, usableCheck;
	int32 inventory_type, itemclass, itemsubclass, rarityCheck;

	*packet >> start_index;
	*packet >> auctionString;
	*packet >> levelRange1 >> levelRange2;
	*packet >> inventory_type >> itemclass >> itemsubclass;
	*packet >> rarityCheck >> usableCheck;

	// convert auction string to lowercase for faster parsing.
	if(auctionString.length() > 0)
	{
		for(uint32 j = 0; j < auctionString.length(); ++j)
			auctionString[j] = tolower(auctionString[j]);
	}

	WorldPacket data(SMSG_AUCTION_LIST_RESULT, 7000);
	data << uint32(0);

	auctionLock.AcquireReadLock();
	HM_NAMESPACE::hash_map<uint32, Auction*>::iterator itr = auctions.begin();
	ItemPrototype * proto;
	for(; itr != auctions.end(); itr++)
	{
		if(itr->second->Deleted) continue;
		proto = itr->second->pItem->GetProto();

		// Check the auction for parameters

		// inventory type
		if(inventory_type != -1 && inventory_type != (int32)proto->InventoryType)
			continue;

		// class
		if(itemclass != -1 && itemclass != (int32)proto->Class)
			continue;

		// subclass
		if(itemsubclass != -1 && itemsubclass != (int32)proto->SubClass)
			continue;

		// this is going to hurt. - name
		if(auctionString.length() > 0 && !FindXinYString(auctionString, HEARTHSTONE_TOLOWER_RETURN(proto->Name1)))
			continue;

		// rarity
		if(rarityCheck != -1 && rarityCheck > (int32)proto->Quality)
			continue;

		// level range check - lower boundary
		if(levelRange1 && proto->RequiredLevel < levelRange1)
			continue;

		// level range check - high boundary
		if(levelRange2 && proto->RequiredLevel > levelRange2)
			continue;

		// usable check - this will hurt too :(
		if(usableCheck)
		{
			// allowed class
			if(proto->AllowableClass && !(plr->getClassMask() & proto->AllowableClass))
				continue;

			if(proto->RequiredLevel && proto->RequiredLevel > plr->getLevel())
				continue;

			if(proto->AllowableRace && !(plr->getRaceMask() & proto->AllowableRace))
				continue;

			if(proto->Class == 4 && proto->SubClass && !(plr->GetArmorProficiency()&(((uint32)(1))<<proto->SubClass)))
				continue;

			if(proto->Class == 2 && proto->SubClass && !(plr->GetWeaponProficiency()&(((uint32)(1))<<proto->SubClass)))
				continue;

			if(proto->RequiredSkill && (!plr->_HasSkillLine(proto->RequiredSkill) || proto->RequiredSkillRank > plr->_GetSkillLineCurrent(proto->RequiredSkill, true)))
				continue;
		}

		// Page system.
		++counted_items;
		if(counted_items >= start_index + 50)
			continue;
		current_index++;
		if(start_index && current_index < start_index) continue;

		// all checks passed -> add to packet.
		itr->second->AddToPacket(data);
		(*(uint32*)&data.contents()[0])++;
	}

	// total count
	data << uint32(1 + counted_items);
	auctionLock.ReleaseReadLock();
	plr->GetSession()->SendPacket(&data);
}