Ejemplo n.º 1
0
void Container::LoadFromDB(Field* fields)
{

    uint32 itemid = fields[2].GetUInt32();
    m_itemProto = ItemPrototypeStorage.LookupEntry(itemid);

    ARCEMU_ASSERT(m_itemProto != NULL);
    SetEntry(itemid);


    SetCreatorGUID(fields[5].GetUInt32());
    SetStackCount(1);

    SetUInt32Value(ITEM_FIELD_FLAGS, fields[8].GetUInt32());
    SetItemRandomPropertyId(fields[9].GetUInt32());

    SetDurabilityMax(m_itemProto->MaxDurability);
    SetDurability(fields[12].GetUInt32());


    SetNumSlots(m_itemProto->ContainerSlots);

    m_Slot = new Item*[m_itemProto->ContainerSlots];
    memset(m_Slot, 0, sizeof(Item*) * (m_itemProto->ContainerSlots));

}
Ejemplo n.º 2
0
void scAbstractArray::AppendData( const ElementPtr	elemptr,
								  long				elements )
{
	SetNumSlots( fNumItems + elements );

	ElementPtr	ptr = Lock();
	SCmemmove( ptr + ( (long)fNumItems * fElemSize ),
			 elemptr,
			 (fElemSize * elements) );
	Unlock();
	fNumItems += elements;
}
Ejemplo n.º 3
0
int scCharArray::Insert( const USTR& str,
						  int32 			  start,
						  int32 			  end )
{
	long	oldNumItems = fNumItems;
	scAssert( end < fNumItems );

	int32	diff = ( str.len - ( end - start ) );
	
	if ( diff > 0 )
		SetNumSlots( GetNumItems() + diff );

	{
		scHandleArrayLock	h( this );
		CharRecordP 		dstCh = (CharRecordP)*h;

		memmove( dstCh + end + diff,
				 dstCh + end,
				 ( oldNumItems - end ) * fElemSize );


	
		dstCh += start;

		for ( UINT i = 0; i < str.len; i++ ) {
			dstCh[i].ClearFlags();
			dstCh[i].character = str.ptr[i];
		}
	}

	if ( diff < 0 )
		SetNumSlots( GetNumItems() + diff );

	fNumItems += diff;

	return diff;
}
Ejemplo n.º 4
0
void scCharArray::Insert( const CharRecordP srcCh,
						  long				offset,
						  long				len )
{
	long	oldNumItems = fNumItems;
	
	SetNumSlots( GetNumItems() + len );
	
	scHandleArrayLock	h( this );
	CharRecordP 		dstCh = (CharRecordP)*h;

	memmove( dstCh + offset + len,
			 dstCh + offset,
			 ( oldNumItems - offset ) * fElemSize );

	memcpy( dstCh + offset, srcCh, len * fElemSize );

	fNumItems += len;
}
Ejemplo n.º 5
0
void scAbstractArray::InsertAt( long		index,
								ElementPtr	elemptr,
								long		elements )
{
	SetNumSlots( fNumItems + elements );

	ElementPtr	ptr = Lock();

	SCmemmove( ptr + ( ( index + elements ) * fElemSize ),
			 ptr + ( index * fElemSize ),
			 ( fNumItems - index ) * fElemSize	);
	
	SCmemmove(	ptr + ( index * fElemSize ),
			  elemptr,
			  elements * fElemSize );

	Unlock();

	fNumItems += elements;
}
Ejemplo n.º 6
0
void scCharArray::Insert( const UCS2* ch, long offset, long len )
{
	long	oldNumItems = fNumItems;
	
	SetNumSlots( GetNumItems() + len );
	
	scHandleArrayLock	h( this );
	CharRecordP 		dstCh = (CharRecordP)*h;

	memmove( dstCh + offset + len,
			 dstCh + offset,
			 ( oldNumItems - offset ) * fElemSize );

	for ( dstCh += offset; len--; dstCh++, ch++ )	{
		dstCh->charflags	= 0;
		dstCh->character	= *ch;
		dstCh->escapement	= 0;
	}

	fNumItems += len;
}
Ejemplo n.º 7
0
void scCharArray::Read( APPCtxPtr	ctxPtr,
						IOFuncPtr	readFunc )
{
	long			numItems,
					leftToRead;
	uchar			buf[256];
	const uchar*	pbuf = buf;

	ReadLong( numItems, ctxPtr, readFunc, kIntelOrder );
	SetNumSlots( numItems );

	scHandleArrayLock	h( this );
	CharRecordP chRec = (CharRecordP)*h;

	leftToRead = numItems;
		
	while ( leftToRead > 0 ) {
		ulong readin;

		if ( leftToRead > ( sizeof( buf ) / sizeof( long ) ) ) {
			ReadBytes( buf, ctxPtr, readFunc, sizeof( buf ) );
			readin = sizeof( buf );
		}
		else {
			ReadBytes( buf, ctxPtr, readFunc, leftToRead * sizeof ( long ) );
			readin = leftToRead * sizeof ( long );
		}
							 
		leftToRead -= ( readin / sizeof( long ) );

		pbuf = buf;
			
		while ( readin > 0 ) {
			pbuf = BufGet_long( pbuf, chRec->charflags, kIntelOrder );
			chRec++, readin -= sizeof( long );
		}
	}
	fNumItems = numItems;
	Validate();
}
Ejemplo n.º 8
0
void Container::Create(uint32 itemid, Player* owner)
{

    m_itemProto = ItemPrototypeStorage.LookupEntry(itemid);
    ARCEMU_ASSERT(m_itemProto != NULL);

    SetEntry(itemid);

    ///\todo this shouldn't get NULL form containers in mail fix me
    if (owner != NULL)
    {
        SetOwnerGUID(0);
        SetContainerGUID(owner->GetGUID());
    }
    SetStackCount(1);
    SetNumSlots(m_itemProto->ContainerSlots);

    m_Slot = new Item*[m_itemProto->ContainerSlots];
    memset(m_Slot, 0, sizeof(Item*) * (m_itemProto->ContainerSlots));

    m_owner = owner;
}
Ejemplo n.º 9
0
void scCharArray::SetContentSize( long size )
{
	SetNumSlots( ( ( (size+1) / fBlockSize ) + 1 ) * fBlockSize );	
}