🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Implicit conversion changed sign of value

Started by
10 comments, last by _Vicious_ 10 years, 4 months ago

Hi Andreas,

here I am again with another question :)

The following code produces a warning which says "Implicit conversion changed sign of value":

       
if ( ( G_PointContents( spawn.origin ) & CONTENTS_NODROP ) != 0 )
...

G_PointContents's declaration is:

int G_PointContents( const Vec3 &in origin )

and CONTENTS_NODROP is an enum. Changing the line to read:

if ( ( G_PointContents( spawn.origin ) & uint( CONTENTS_NODROP ) ) != 0 )

fixes the warning. Why casting an enum to unsigned int fixes the warning, while G_PointContents is obviously a signed integer?

Advertisement

That's a good question. :)

I'll look into it.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

ok, thanks!

Hi Andreas,

did you have the chance to look into the problem? I know it's kinda minor but still rather annoying :)

Not yet. I haven't forgotten it though. :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Fixed in revision 1835.

Regards,

Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thank you :)

Hm, after updating to WIP Angelscript version, I get loads of the following errors:

dm.as 275:33: No conversion from 'uint' to 'uint' available.
^5ANGELSCRIPT:

legacy/quake1.as 86:1: Compiling void light_fluoro_use(Entity@, Entity@, Entity@)
^1ERROR:

legacy/quake1.as 91:23: No conversion from 'int' to 'int' available.
^3WARNING:

That's bizarre.

Can you show me the script for these funtions?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game


void item_weapon( Entity @ent )
{
	if( (ent.spawnFlags & WEAPON_ROCKET) == WEAPON_ROCKET )
	{
		if( (ent.spawnFlags & WEAPON_BIG) == WEAPON_BIG )
			GENERIC_SpawnItem( ent, AMMO_ROCKETS );
		else
			GENERIC_SpawnItem( ent, AMMO_WEAK_ROCKETS );	
	}
	else if( (ent.spawnFlags & WEAPON_SPIKES) == WEAPON_SPIKES )
	{
		if( (ent.spawnFlags & WEAPON_BIG) == WEAPON_BIG )
			GENERIC_SpawnItem( ent, AMMO_PLASMA );		
		else
			GENERIC_SpawnItem( ent, AMMO_WEAK_PLASMA );
	}	
	else if( (ent.spawnFlags & WEAPON_SHOTGUN) == WEAPON_SHOTGUN )
	{
		if( (ent.spawnFlags & WEAPON_BIG) == WEAPON_BIG )
			GENERIC_SpawnItem( ent, AMMO_SHELLS );
		else
			GENERIC_SpawnItem( ent, AMMO_WEAK_SHELLS );
	}
}

Basically, each '(ent.spawnFlags & WEAPON_ROCKET) == WEAPON_ROCKET'-style comparison throughout the source code results in compilation error.

WEAPON_ROCKET again is an enum, spawnflags is an integer property.

This topic is closed to new replies.

Advertisement