Esempio n. 1
0
/**
 * @brief Allocate an sprite to the UI static memory
 * @note Its not a dynamic memory allocation. Please only use it at the loading time
 * @param[in] name Name of the sprite
 * @todo Assert out when we are not in parsing/loading stage
 */
uiSprite_t* UI_AllocStaticSprite (const char* name)
{
	uiSprite_t* result;

	if (UI_SpriteExists(name))
		Com_Error(ERR_FATAL, "UI_AllocStaticSprite: \"%s\" sprite already allocated. Check your scripts.", name);

	if (ui_global.numSprites >= UI_MAX_SPRITES)
		Com_Error(ERR_FATAL, "UI_AllocStaticSprite: UI_MAX_SPRITES hit");

	result = &ui_global.sprites[ui_global.numSprites];
	ui_global.numSprites++;

	OBJZERO(*result);
	Q_strncpyz(result->name, name, sizeof(result->name));
	return result;
}
Esempio n. 2
0
/**
 * @brief Allocate an sprite to the UI static memory
 * @note Its not a dynamic memory allocation. Please only use it at the loading time
 * @param[in] name Name of the sprite
 * @todo Assert out when we are not in parsing/loading stage
 */
uiSprite_t* UI_AllocStaticSprite (const char* name)
{
	uiSprite_t* result;
	/** @todo understand why we must hide this assert in release build with mingw */
#ifdef DEBUG
	assert(!UI_SpriteExists(name));
#endif
	if (ui_global.numSprites >= UI_MAX_SPRITES)
		Com_Error(ERR_FATAL, "UI_AllocStaticSprite: UI_MAX_SPRITES hit");

	result = &ui_global.sprites[ui_global.numSprites];
	ui_global.numSprites++;

	OBJZERO(*result);
	Q_strncpyz(result->name, name, sizeof(result->name));
	return result;
}