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!

(Nujel'm) Battle Chess

Kamron

Knight
Thanks Arya alot :D Great additions. I will test out the crashing soon. And also I see that you added SolidHueOverride better than me, I forgot about the base CreatePeice method. Nice :D


As a note *yes I am that maticulous* :p

Code:
			if ( m_Chessboard.OverrideMinorHue )
				m_Piece.Hue = Hue;
			else
				m_Piece.Hue = m_Chessboard.SkinHue;

Would make no difference since the character and everyone on it and their backpack would be the hue of the SolidHueOverride property ;)

Code:
if ( e.Mobile != m_Black && e.Mobile != m_White )

That statement in the OnPlayerDisconnected method, will still result in a crash if m_Black or m_White are null because you didn't check that first. I think that was the underlying reason for a crash.


So the code for OnPlayerDisconnected, would in turn have to look like -

Code:
		private void OnPlayerDisconnected(DisconnectedEventArgs e)
		{
			if ( (m_Black != null && e.Mobile != m_Black) && (m_White != null && e.Mobile != m_White) )
				return;

			if ( m_Status == GameStatus.Setup )
			{
				Cleanup(); // No game to loose, just end.
				return;
			}

			if ( m_Status == GameStatus.Over )
			{
				// If game is over, logging out = confirming game over through the gump
				NotifyGameOver( e.Mobile );
				return;
			}

			// Game in progress

			m_Pending = true;

			if ( m_Black != null && m_Black.NetState != null )
			{
				m_Black.CloseGump( typeof( GameGump ) );
				m_Black.SendGump( new EndGameGump( m_Black, this, false,
					"Your partner has been disconnected", ChessConfig.DisconnectTimeOut.Minutes ) );
			}

			if ( m_White != null && m_White.NetState != null )
			{
				m_White.CloseGump( typeof( GameGump ) );
				m_White.SendGump( new EndGameGump( m_White, this, false,
					"Your partner has been disconnected", ChessConfig.DisconnectTimeOut.Minutes ) );
			}

			if ( m_Timer != null )
				m_Timer.OnPlayerDisconnected();
		}

Also there is no reason (as you can see from the change) to have multiple if statements when you can use an &&. You would be redirecting code twice, when in a single if statement, there is short curcuit, so that the NetState would never be checked if the initial object was null. Optimization is all ;)
 

Arya

Wanderer
Actually I'm pretty sure you can compare against a null value without a NullReferenceException because you aren't really using the null object, you just compare the two references in the two variables. Will double check it later on though.

And yep, I forgot about the skin/hair hue (I just find/replaced m_SkinHue with m_Chessboard.SkinHue *lazy*) ;)
 

Arya

Wanderer
Yes, but a NRE comes when you *use* an object that's null ( m_Mobile.NetState will throw if m_Mobile is null ) not when you compare it to another. Comparing two objects using the = operator compares only the memory address held by the reference. It's like comparing an IntPtr.Zero to another pointer. Using the Equals function on the other hand would lead to the exception.
 

Kamron

Knight
Right, although in that if statement, m_Mobile.NetState would never hit because if m_Mobile is null and that was the previous check unioned by an &&, then it will short circuit and not crash. Although yes, you are correct about null reference exception *still needs his morning coffee...*
 

Arya

Wanderer
Yep I noticed you edited your post while I was replying, but I'll leave that for someone who might learn from it. And yes you are correct about the nested if statement, I was first doing something different then realized it wasn't necessary and finally forgot to merge.
 

Kamron

Knight
Also I forgot to mention, that the script needs to eject NPCs (Even pets) from the board. Some boards are near spawns.. and its a pain in the ass to play when animals or town folk are running around. As well as people who have hoards of bonded dragons. ;)
 

Kamron

Knight
You have double If Statements for the same thing? LOL

Code:
			if ( m_Game != null && ! m_AllowSpectators )
			{
				if ( m_Game != null && ! m_AllowSpectators )
				{

Thats at the bottom of ChessRegion.cs
 

Khaz

Knight
Code:
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Arya.Chess.ChessGame.OnMoveOver(Move move, String whiteMsg, String blackMsg)
   at Arya.Chess.Chessboard.PushGame(ChessColor nextMoveColor, Move move)
   at Arya.Chess.Chessboard.OnPawnPromoted(BaseChessPiece pawn, PawnPromotion to)
   at Arya.Chess.PawnPromotionGump.OnResponse(NetState sender, RelayInfo info)
   at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)
This was a shard crash log that occurred at the near-end of some of my players' chess game. After talking to the players, it turns out that this seems to be the scenario:
Player A wanted to leave, but Player B was about to win. Player B had just moved a pawn to the edge of the board, and was still at the pawn-trade-in gump when the crash occurred. Player B reports that she received the message about a staff termination of the game. Myself and only one other staff member on at the time, I checked the logs of the staff member. The result: I found that the last entry before the shard crash in his log was that of a deleted Black pawn. My guess - the pawn at the end of the board.
So, simply, this crash was caused by the deletion of a pawn in the middle of a promotion stage. I don't know if you can put in a fix for this, but I thought I'd let you know of it, anyway.

Oh, and Arya...thank you.
 

Khaz

Knight
She talked directly to me!
*faints*

Thank you! There's no hurry. I killed the staff member...
on accident...
of course... :D
 

steamin

Wanderer
Exception:
System.Exception: Bad type: Arya.Chess.Chessboard ---> System.MissingMethodException: No parameterless constructor defined for this object.
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at Server.Scripts.Commands.DecorationList.Construct()
--- End of inner exception stack trace ---
at Server.Scripts.Commands.DecorationList.Construct()
at Server.Scripts.Commands.DecorationList.Generate(Map[] maps)
at Server.Scripts.Commands.Decorate.Generate(String folder, Map[] maps)
at Server.Scripts.Commands.Decorate.Decorate_OnCommand(CommandEventArgs e)
at Server.Commands.Handle(Mobile from, String text)
at Server.Gumps.AdminGump.OnResponse(NetState sender, RelayInfo info)
at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)


by using the [decorate command
 

Arya

Wanderer
Who added a chessboard to the decoration command anyway? It's not supposed to be there, not to mention that the Chessboard class is NOT an item, therefore it cannot be used for decoration.

Edit: I see where the problem comes from. Possibly the decorate command looks for the Chessboard type without using the full name (Server.Items.Chessboard - the regular chessboard). For now you must uninstall the chess script before doing the decoration. I'll see into changing the class name later on.
 
Top