コード例 #1
0
ファイル: minecraft.c プロジェクト: espes/craftd
SVMetadata*
SV_ConcatDatas (SVMetadata* metadata, SVData** items, size_t length)
{
	for (size_t i = 0; i < length; i++) {
		SV_AppendData(metadata, items[i]);
	}

	return metadata;
}
コード例 #2
0
ファイル: Buffer.c プロジェクト: alyawn/craftd-huh
SVMetadata*
SV_BufferRemoveMetadata (CDBuffer* self)
{
    SVMetadata* metadata = SV_CreateMetadata();
    SVData*     current  = NULL;
    SVByte      type     = 0;

    // Format strings of the different metadata types
    static char* formats[] = { "b", "s", "i", "f", "S" };

    while (!CD_BufferEmpty(self)) {
        type = SV_BufferRemoveByte(self);

        if (type == 127) {
            break;
        }

        current       = SV_CreateData();
        current->type = type >> 5;

        if (current->type == SVTypeShortByteShort) {
            SV_BufferRemoveFormat(self, "sbs",
                &current->data.sbs.first,
                &current->data.sbs.second,
                &current->data.sbs.third
            );
        }
        else {
            SV_BufferRemoveFormat(self, formats[current->type], &current->data);
        }

        SV_AppendData(metadata, current);
    }

    return metadata;
}