Пример #1
0
void verifyAsset(zoneInfo_t* info, int type, const char* name)
{
	for (int i = 0; i<info->assetCount; i++)
	{
		if (info->assets[i].type == type && info->assets[i].name == R_HashString(name))
		{
			info->assets[i].verified = true;
		}
	}
}
Пример #2
0
void* getAsset(zoneInfo_t* info, int type, const char* name)
{
	for(int i=0; i<info->assetCount; i++)
	{
		if (info->assets[i].type == type && info->assets[i].name == R_HashString(name))
		{
			return info->assets[i].data;
		}
	}
	return NULL;
}
Пример #3
0
int containsAsset(zoneInfo_t* info, int type, const char* name)
{
	int str = R_HashString(name);

	for(int i=0; i<info->assetCount; i++)
	{
		if(info->assets[i].type != type) continue;
		if(info->assets[i].name != str) continue;
		return i;
	}
	return -1;
}
Пример #4
0
int addAsset(zoneInfo_t* info, int type, const char* name, void* data)
{
	if(info->assetCount >= MAX_ASSET_COUNT) Com_Error(true, "Tell Apadayo to increase MAX_ASSET_COUNT!");
	int a = containsAsset(info, type, name);
	if(a >= 0) return a;

	// force data to have correct name
	const char* assetName = getAssetName(type, data);
	if (strcmp(assetName, name))
	{
		setAssetName(type, data, name);
	}

	info->assets[info->assetCount].name = R_HashString(name);
	info->assets[info->assetCount].type = type;
	info->assets[info->assetCount].data = data;
#if ZB_DEBUG
	info->assets[info->assetCount].debugName = name;
	info->assets[info->assetCount].verified = false;
#endif

	return info->assetCount++;
}
Пример #5
0
void addMaterial(zoneInfo_t* info, const char* name, char* data, size_t dataLen)
{
	if(parseMatFile(data, dataLen) < 0) return;

	// load up the techset
	char techsetfname [128];
	_snprintf(techsetfname, 128, "techsets/%s.techset", techsetName);
	loadAsset(info, ASSET_TYPE_TECHSET, techsetfname, techsetName);

	int asset = addAsset(info, ASSET_TYPE_MATERIAL, name, NULL, 0);

	BUFFER* buf = new BUFFER(4096);

	Material* mat = new Material;
	memset(mat, 0, sizeof(Material));
	mat->name = (char*)0xFFFFFFFF;
	if(materialUsage == MATERIAL_USAGE_UI)
	{
		mat->flags = 0x2F;
		mat->animationX = 1;
		mat->animationY = 1;
		mat->unknown2 = 0xFFFFFFFF;
		mat->unknown3 = 0xFFFFFF00;
		memset(mat->unknown4, 0xFF, sizeof(mat->unknown4));
		mat->numMaps = materialMapCount;
		mat->stateMapCount = 1;
		mat->unknown6 = 3;
		mat->unknown7 = 4;
	}

	// null dem pointers!
	mat->techniqueSet = (MaterialTechniqueSet*)0x0;//0xFFFFFFFF;
	mat->maps = (MaterialTextureDef*)0xFFFFFFFF;
	mat->stateMap = (void*)0xFFFFFFFF;

	buf->write(mat, sizeof(Material), 1);
	buf->write((void*)name, strlen(name) + 1, 1);

	// techset
	int assetPatchTo = containsAsset(info, ASSET_TYPE_TECHSET, techsetName);
	addFixup(info, asset, 80, assetPatchTo);

	// maps
	for(int i=0; i<materialMapCount; i++)
	{
		MaterialTextureDef* tex = new MaterialTextureDef;
		memset(tex, 0, sizeof(MaterialTextureDef));
		tex->firstCharacter = materialMaps[i][0];
		tex->secondLastCharacter = materialMaps[i][strlen(materialMaps[i])];
		tex->typeHash = R_HashString(materialMaps[i]);
		tex->image = (GfxImage*)0xFFFFFFFF;
		tex->textureType = 0xE2;

		buf->write(tex, sizeof(MaterialTextureDef), 1);

		GfxImage* img = new GfxImage;
		memset(img, 0, sizeof(GfxImage));
		img->depth = 1;
		img->textureType = 3; // 2d texture
		img->textureType2 = 3;
		img->texture = (GfxImageLoadDef*)0xFFFFFFFF;
		img->name = (char*)0xFFFFFFFF;
		img->width = iwiHeaders[i].xsize;
		img->height = iwiHeaders[i].ysize;

		buf->write(img, sizeof(GfxImage), 1);
		buf->write((void*)materialTextureNames[i], strlen(materialTextureNames[i]) + 1, 1);

		GfxImageLoadDef * def = new GfxImageLoadDef;
		memset(def, 0, sizeof(GfxImageLoadDef));
		int format = 0;
		switch(iwiHeaders[i].format)
		{
		case IWI_ARGB:
			format = 21;
			break;
		case IWI_RGB8:
			format = 20;
			break;
		case IWI_DXT1:
			format = 0x31545844;
			break;
		case IWI_DXT3:
			format = 0x33545844;
			break;
		case IWI_DXT5:
			format = 0x35545844;
			break;
		}
		def->format = format;
		def->mipLevels = 1;

		buf->write(def, sizeof(GfxImageLoadDef), 1);
	}

	// unknown 8 goes here whenever we use it

	// statemap
	if(materialUsage == MATERIAL_USAGE_UI)
	{
		char statemap[] = {0x65, 0x51, 0x12, 0x18, 0x02, 0x00, 0x0E, 0xE0 };
		buf->write(statemap, 8, 1);
	}

	buf->resize(-1);

	// fix the data
	setAssetData(info, asset, buf->data(), buf->getsize());
}