RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

2.1 R605 Point3D operator Ambiguity

Vorspire

Knight
Reported as active bug from 605 -> SVN 665 (Current)

The error(s):
Code:
The call is ambiguous between the following methods or properties:
'Server.Point3D.operator ==(Server.Point3D, Server.Point3D)' and 'Server.Point3D.operator ==(Server.Point3D, Server.IPoint3D)'

The call is ambiguous between the following methods or properties:
'Server.Point3D.operator !=(Server.Point3D, Server.Point3D)' and 'Server.Point3D.operator !=(Server.Point3D, Server.IPoint3D)'

How to provoke the error (example):
Rich (BB code):
Point3D p1 = Point3D.Zero;
Point3D p2 = Point3D.Zero;

if( p1 != null && p1 == p2 )
{ return; }

Using either the == or != operator on a Point3D will cause the errors.

Geometry.cs / Lines 327 to 351:
Rich (BB code):
public static bool operator ==( Point3D l, Point3D r )
{
	return l.m_X == r.m_X && l.m_Y == r.m_Y && l.m_Z == r.m_Z;
}

public static bool operator !=( Point3D l, Point3D r )
{
	return l.m_X != r.m_X || l.m_Y != r.m_Y || l.m_Z != r.m_Z;
}

public static bool operator ==( Point3D l, IPoint3D r )
{
	if ( Object.ReferenceEquals( r, null ) )
		return false;

	return l.m_X == r.X && l.m_Y == r.Y && l.m_Z == r.Z;
}

public static bool operator !=( Point3D l, IPoint3D r )
{
	if ( Object.ReferenceEquals( r, null ) )
		return false;

	return l.m_X != r.X || l.m_Y != r.Y || l.m_Z != r.Z;
}
Remove/comment the code in red to fix this issue.

Same again for Point2D...

Geometry.cs / Lines 123 to 147:
Rich (BB code):
public static bool operator == ( Point2D l, Point2D r )
{
	return l.m_X == r.m_X && l.m_Y == r.m_Y;
}

public static bool operator != ( Point2D l, Point2D r )
{
	return l.m_X != r.m_X || l.m_Y != r.m_Y;
}

public static bool operator == ( Point2D l, IPoint2D r )
{
	if ( Object.ReferenceEquals( r, null ) )
		return false;

	return l.m_X == r.X && l.m_Y == r.Y;
}

public static bool operator != ( Point2D l, IPoint2D r )
{
	if ( Object.ReferenceEquals( r, null ) )
		return false;

	return l.m_X !=r.X || l.m_Y != r.Y;
}

From what I assume, the old operator overloads were not removed.
I think there's a dev somewhere using notepad ;)
 
Top