Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » C++ code help please. (Converting Variables)
icon5.gif  C++ code help please. [message #416861] Wed, 06 January 2010 09:02 Go to previous message
Raptor RSF is currently offline  Raptor RSF
Messages: 210
Registered: July 2007
Location: Netherlands
Karma:
Recruit
Hello everyone,

Last days i have been working on the RSF HUD and while programming a feature for this hud i encountered an error.

Feature that i am programming. ( my goal is to have it fade, the very same as the MiniAmmoHUD and MiniHealthHUD)

index.php?t=getfile&id=12326&private=0


.\reticlehealthhud.cpp(224) : error C2220: warning treated as error - no 'object' file generated
.\reticlehealthhud.cpp(224) : warning C4244: '=' : conversion from 'float' to 'unsigned int', possible loss of data



I tried many thing to convert the variable or something, But i am still a noob at coding c++.

Does anybody know a solution for this problem? Dont Get It




void ReticleHealthHUDItemClass::Render()
{
	if (!Enabled) return;


	// RETICLEHEALTHHUD_flash
	GameObject *obj = Get_Vehicle_Return((GameObject *)(*TheStar)->obj);
	float current_health = Commands->Get_Health(obj);
	unsigned int current_time = *SyncTime;

	if (current_health != LastHealth)
	{
		EndFlashTime = current_time + HealthInfoFlashDuration;
		FlashActive = true;
	}

	float flash_percentage = 1.0f;
	if (FlashActive && (current_time < EndFlashTime))
	{
		flash_percentage = float(EndFlashTime - current_time) / float(HealthInfoFlashDuration);
	}
	else if (FlashActive)
	{
		flash_percentage = 0.0f;
	}


	// RETICLEHEALTHHUD_color
	float health = 0;
	float maxhealth = 0;
	if (Get_Vehicle(obj))
	{
		health = Commands->Get_Health(Get_Vehicle(obj));
		maxhealth = Commands->Get_Max_Health(Get_Vehicle(obj));
			}
	else
	{
		health = Commands->Get_Health(obj);
		maxhealth = Commands->Get_Max_Health(obj);
	}
	float healthpercent = (health / (maxhealth / 100));
	unsigned int color = 0;
	color = ReticleHealthHUDColor;
	for (unsigned int i = 0;i < ReticleHealthHUDColorCount;i++)
	{
		if (healthpercent <= (*ReticleHealthHUDColors)[i]->Value)
		{
			color = (*ReticleHealthHUDColors)[i]->ColorValue;
			
			unsigned int alpha = color >> 24;
			alpha = flash_percentage; // <<<<<  "alpha" is an integer and "flash_percentage" is a float. This is the issue.
			color = (color & 0x00FFFFFF)| (alpha<<24);
			break;
		}
	};
	

	Render2D->Reset();
	Render2D->Shader.ShaderBits = 0x000984B3;

	Render2D->Set_Texture(BackgroundTextureFile);
	if (Render2D->Texture->Initialized == false)
	{
		Render2D->Texture->Init();
	};

	RectClass background_location;
	background_location.Top = BackgroundPosition.Y;
	background_location.Left = BackgroundPosition.X;
	background_location.Bottom = BackgroundPosition.Y + BackgroundSize.Y;
	background_location.Right = BackgroundPosition.X + BackgroundSize.X;

	Render2D->Add_Quad(background_location, BackgroundUV, color);
	Render2D->Render();

	LastHealth = current_health;
};

  • Attachment: RSF_HUD.png
    (Size: 745.64KB, Downloaded 303 times)


Rencom server Fan - Marathon#1

http://bfbc2.statsverse.com/sig/clean1/pc/Raptor_RSF.png

[Updated on: Wed, 06 January 2010 09:11]

Report message to a moderator

 
Read Message icon5.gif
Read Message
Read Message
Previous Topic: Questions (player objects, stealth vehs)
Next Topic: [preview] rotating weaponlist
Goto Forum:
  


Current Time: Fri Dec 20 19:42:48 MST 2024

Total time taken to generate the page: 0.00674 seconds