Пример #1
0
	void Entity::getUpdate(int time, BufferPointer buffer, int client)
	{
		bool local = client == getOwner();
		for (unsigned int i = 0; i < properties.size(); i++)
		{
			if (local && ((properties[i].getFlags() & EPF_OwnerUpdates) == 0))
			{
				// Potential update ignored because of property flags.
				buffer->writeUnsignedInt(0, 1);
				continue;
			}
			if (properties[i].getChangeTime() > time)
			{
				// Bit set: Property changed.
				buffer->writeUnsignedInt(1, 1);
				// Write the property to the stream.
				properties[i].write(buffer);
			}
			else
			{
				// Bit not set: Property remained unchanged.
				buffer->writeUnsignedInt(0, 1);
			}
		}
	}
Пример #2
0
	void Entity::getState(BufferPointer buffer)
	{
		const std::vector<Property> &tplproperties = tpl->getProperties();
		for (unsigned int i = 0; i < properties.size(); i++)
		{
			if (properties[i] != tplproperties[i])
			{
				// Bit set: Property changed.
				buffer->writeUnsignedInt(1, 1);
				// Write the property to the stream.
				properties[i].write(buffer);
			}
			else
			{
				// Bit not set: Property remained unchanged.
				buffer->writeUnsignedInt(0, 1);
			}
		}
	}