Back to the Vavoom Forum Archives


Forum

Questions about VavoomC

Thu, 14 Jan 2010 17:30:44

Firebrand

Hi! I want to draw some sprites to use as icons in a menu screen, when I draw the menu with only a single item it's working fine, but when the menu has more than one item, it crashes with the following:
- (engine.Object.R_DrawSpritePatch)
- R_DrawSpritePatch
- VObject::ExecuteFunction
- (uibase.MenuSpriteAnim.OnDraw)
- VWidget::DrawTree
- VWidget::DrawTree
- VWidget::DrawTree
- VRootWidget::DrawWidgets
- SCR_Update
- Host_Frame
Log: Doing C_Shutdown
Log: Doing CL_Shutdown
Log: firebrand left the game

Log: Doing SV_Shutdown
Log: Doing delete GNet
Log: Doing delete GInput
Log: Doing V_Shutdown
Log: Doing delete GAudio
Log: Doing T_Shutdown
Log: Doing Sys_Shutdown
Log: Doing delete GSoundManager
Log: Doing R_ShutdownTexture
Log: Doing R_ShutdownData
Log: Doing VCommand::Shutdown
Log: Doing VCvar::Shutdown
Log: Doing ShutdownMapInfo
Log: Doing FL_Shutdown
Log: Doing W_Shutdown
Log: Doing GLanguage.FreeData
Log: Doing ShutdownDecorate
Log: Doing VObject::StaticExit
Log: Doing VName::StaticExit
Uninitialised: Doing Z_Shutdown


ERROR: Segmentation Violation
Here's the code I'm using to draw:
void CreateWeaponEntries(int YPos)
{
	int i;
	MenuTaggedTextButton Btn, Btn2;
	MenuSpriteAnim		Anim;
	Inventory Item = cl.WeaponFirst;

	i = 0;
	while (Item)
	{
		if (HexenWeapon(Item).Slot == SlotCurrent)
		{
			// [FB] Make sure to add any weapon icons to be used here
			R_InstallSprite(va("%n", HexenWeapon(Item).IconName), i);

			Anim = MenuSpriteAnim(NewChild(MenuSpriteAnim));
			Anim.SetPos(ChoicesStartX + 6, YPos + 4);
			Anim.SprDef = i;
			Anim.Speed = 1;
			Anim.NumFrames = 1;
			
			Btn = MenuTaggedTextButton(NewChild(MenuTaggedTextButton));
			Btn.Tag = i++;
			Btn.SetOrigin(ChoicesStartX + 46, YPos + 2);
			if (StrStartsWith(Item.PickupMessage, "$"))
			{
				Btn.Text = GetLangString(StrToName(substr(Item.PickupMessage, 1, strlen(Item.PickupMessage) - 1)));
			}
			else
			{
				Btn.Text = Item.PickupMessage;
			}
			Btn.Width = 600;

			if (cl.WeaponsBelt[SlotCurrent] == Item)
			{
				SelectedEntry = Btn;
				Btn.TextColour = CR_YELLOW;
				Btn.TextColourFocus = CR_GOLD;
			}
			else
			{
				Btn.TextColour = CR_UNTRANSLATED;
				Btn.TextColourFocus = CR_WHITE;
			}
			Btn.Activated = WeaponSelect;
			YPos += Btn.Height;
			// [FB] Let's not forget to increase the sprite index here
			i++;
		}

		Item = Item.NextWpn();
	}
}
My guess is that the problem is with the sprites index, maybe I'm not understanding how they work, could you please explain me how this works or if the problem is in the code? Thanks!

Back to the Vavoom Forum Archives