Results 1 to 2 of 2

Thread: Details on the RWG Custom Hub NRE issue

  1. #1
    Colony Founder StompyNZ's Avatar
    Join Date
    Apr 2015
    Posts
    3,359
    Rep Power
    1

    Details on the RWG Custom Hub NRE issue

    When trying to use a custom hub in the rwgmixer it causes an NRE when attempting to provide the distant terrain to a player nearby.

    Code:
    2017-08-05T15:18:49 54.651 ERR Exception in task
    2017-08-05T15:18:49 54.652 EXC Argument cannot be null.
    Parameter name: collection
    ArgumentNullException: Argument cannot be null.
    Parameter name: collection
      at System.Collections.Generic.List`1[RWG2.HubCell+Lot].CheckCollection (IEnumerable`1 collection) [0x00000] in <filename unknown>:0 
      at System.Collections.Generic.List`1[RWG2.HubCell+Lot].AddRange (IEnumerable`1 collection) [0x00000] in <filename unknown>:0 
      at RWG2.HubCell.GetClosestLots (Vector2 point, Boolean allLots) [0x00000] in <filename unknown>:0 
      at RWG2.HubCell.AdjustDistLotTrimming (Vector2 point, System.Single& terrainHeight) [0x00000] in <filename unknown>:0 
      at RWG2.RWGTerrainGenerator.GetDistTerrainHeight (Int32 worldX, Int32 worldZ, RWG2.HubCell _hubCell) [0x00000] in <filename unknown>:0 
      at RWG2.RWGBiomeGenerator.GetPostTrimHeightAt (Single x, Single z, RWG2.HubCell _hubCell) [0x00000] in <filename unknown>:0 
      at RWG2.RWGBiomeGenerator.GetFinalWorldHeightAt (Single x, Single z) [0x00000] in <filename unknown>:0 
      at WorldEnvironment.KU (Single , Single , Single ) [0x00000] in <filename unknown>:0 
      at DistantChunk.HA (Single , Single , Single , Int32 , Single , Single , Single , Single , Single , Single , System.Single[] ) [0x00000] in <filename unknown>:0 
      at DistantChunk.ActivateObject (Boolean _bHeightAndNormalOnly) [0x00000] in <filename unknown>:0 
      at DistantTerrain.ThreadExtraWork (.DistantChunk DChunk, .DistantChunkBasicMesh BMesh, Boolean WasReset) [0x00000] in <filename unknown>:0 
      at ThreadContainer.ThreadExtraWork () [0x00000] in <filename unknown>:0 
      at ThreadProcessing.TU (.TaskInfo ) [0x00000] in <filename unknown>:0 
      at ThreadManager.HU (System.Object ) [0x00000] in <filename unknown>:0 
    UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    UnityEngine.Logger:LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    Logger:masterLogException(Exception)
    Logger:Exception(Exception)
    Log:Exception(Exception)
    ThreadManager:HU(Object)
     
    (Filename:  Line: -1)
    In csharp.dll

    Code:
    // RWG2.HubCell
    public List<HubCell.Lot> GetClosestLots(Vector2 point, bool allLots = false)
    {
    	List<HubCell.Lot> list = new List<HubCell.Lot>();
    	float num = 1E+08f;
    	List<HubCell.Lot> list2 = new List<HubCell.Lot>();
    	if (allLots)
    	{
    		list2.AddRange(this.lots);
    		if (this.HubGenerator != null)
    		{
    			if (this.HubGenerator.BoundingBox.Contains(point))
    			{
    				list2.AddRange(this.HubGenerator.GetLots());
    			}
    		}
        
        <snip>
        ....
    The highlighted call on a custom hub returns null, which then causes the NRE for AddRange.

    With some debugging help (thanks Djkrose) I was able to confirm that .GetLots() on a custom hub returns null. Also the hub generator is HGAbstract, whereas the HubGenerator on socket towns is HGSocket

  2. #2
    Colony Founder StompyNZ's Avatar
    Join Date
    Apr 2015
    Posts
    3,359
    Rep Power
    1
    Further Info:

    Looking at the HubCell.Read method, there is this section:

    Code:
      switch (_br.ReadByte())
      {
      case 1:
        this.HubGenerator = new RWG2.HubGenerators.HGCity();
        goto IL_9C;
      case 2:
        this.HubGenerator = new RWG2.HubGenerators.HGTown();
        goto IL_9C;
      case 3:
        this.HubGenerator = new RWG2.HubGenerators.HGRural();
        goto IL_9C;
      case 5:
        this.HubGenerator = new HGSockets();
        goto IL_9C;
      }
      this.HubGenerator = new RWG2.HubGenerators.HGAbstract();
      IL_9C:
      this.HubGenerator.Read(_br, num);

    HubLayout isnt in the list, and that I expect is why loaded hcd does not have the correct Class for custom hubs, instead it is being assigned to HGAbstract (as shown in the debug)

    This is likely why the lots assignment from generateLots is not being set, because the HGAbstract doesnt have the generateLots method.
    Last edited by StompyNZ; 6 Days Ago at 09:08 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •