Hi,
I'm writing a game that uses JPCT and it's virtually impossible to run it in legacy/rapid debug mode without it erroring, due to threads, so I'm having to test in release mode.
I am getting a null pointer exception somewhere in the following code. I've put toast messages in to try to track where it is happening, but something is causing it to jump to the Catch method. The key to the BoardCellList is a string in the format of number dash number, the value is a structure of type CellInfo. When Ci is assigned I test the field Vanished which is a boolean.
Can anybody give me a lead as to why it could be giving a null pointer exception? It gets most of the way through the list of 225 items in BoardCellList before erroring. For each indexed item in the list I get the key to the item, I test if it's null, it's not else I'd see the "key is null" toast. Then using the key I get the actual value of type CellInfo. I test the value that is returned for null, and don't do anything if it's null, but if it's not null I test Vanished flag, and then add to a string variable.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Thanks,
Richard
			
			I'm writing a game that uses JPCT and it's virtually impossible to run it in legacy/rapid debug mode without it erroring, due to threads, so I'm having to test in release mode.
I am getting a null pointer exception somewhere in the following code. I've put toast messages in to try to track where it is happening, but something is causing it to jump to the Catch method. The key to the BoardCellList is a string in the format of number dash number, the value is a structure of type CellInfo. When Ci is assigned I test the field Vanished which is a boolean.
Can anybody give me a lead as to why it could be giving a null pointer exception? It gets most of the way through the list of 225 items in BoardCellList before erroring. For each indexed item in the list I get the key to the item, I test if it's null, it's not else I'd see the "key is null" toast. Then using the key I get the actual value of type CellInfo. I test the value that is returned for null, and don't do anything if it's null, but if it's not null I test Vanished flag, and then add to a string variable.
			
				B4X:
			
		
		
		            Try
                Dim vanished2 As String = ""
                Dim key As Object = Null
                For loop1 = 0 To GameState.BoardCellList.Size - 1
                    last = loop1
                    key = GameState.BoardCellList.GetKeyAt(loop1)
                    If key <> Null Then
                        Dim ci As CellInfo = GameState.BoardCellList.get(key)
                        If ci <> Null Then
                            If ci.vanished Then 
                                If vanished2.length > 0 Then vanished2 = vanished2 & ","
                                vanished2 = vanished2 & key
                            End If
                        End If
                    Else
                        ToastMessageShow("key is null", False)
                    End If
                Next
            Catch
                ToastMessageShow("debug: vanished ... " & LastException.Message & " @ " & last & "/" & (GameState.BoardCellList.Size-1), True)
            End TryThanks,
Richard
 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		