Beispiel #1
0
    OptionalOffset
    ContentFolder::doFindOffsetWhereMetaDataShouldBeWritten()
    {

        // loop over all entries and try and find a previously deleted one
        // If its deleted, the first bit of the entry metadata will be unset

        // Note possible way of optimizing this? Store in cache available entries
        // to overwrite?
        if(m_checkForEarlyMetaData) { // optimization
            for (long entryIndex = 0; entryIndex < m_entryCount; ++entryIndex) {
                auto metaData(doSeekAndReadOfEntryMetaData(m_folderData, entryIndex));
                if (!entryMetaDataIsEnabled(metaData)) {
                    uint32_t bufferSize = 1 + detail::MAX_FILENAME_LENGTH + 8;
                    std::ios_base::streamoff offset = (8 + (entryIndex * bufferSize));
                    return OptionalOffset(offset);
                }
            }

            // couldn't be found before, means that it won't be found in future
            m_checkForEarlyMetaData = false;
        }

        m_oldSpaceAvailableForEntry = false;

        // free entry not found so signify that we should seek right to
        // end by returning an empty optional
        return OptionalOffset();
    }
Beispiel #2
0
	STARTDECL(ph_createcircle) (Value &position, Value &radius, Value &offset, Value &other_id)
	{
		auto &body = GetBody(other_id, position);
		b2CircleShape shape;
		auto off = OptionalOffset(offset);
		shape.m_p.Set(off.x, off.y);
		shape.m_radius = radius.fval;
		return CreateFixture(body, shape);
	}
Beispiel #3
0
	STARTDECL(ph_createbox) (Value &position, Value &size, Value &offset, Value &rot, Value &other_id)
	{
		auto &body = GetBody(other_id, position);
		auto sz = ValueDecTo<float2>(size);
		auto r = rot.True() ? rot.fval : 0;
		b2PolygonShape shape;
		shape.SetAsBox(sz.x(), sz.y(), OptionalOffset(offset), r * RAD);
		return CreateFixture(body, shape);
	}