diff --git a/importprimscript/importprimscript.cs b/importprimscript/importprimscript.cs index b9d6e8e0..b3407f0b 100644 --- a/importprimscript/importprimscript.cs +++ b/importprimscript/importprimscript.cs @@ -29,7 +29,7 @@ namespace importprimscript static void Main(string[] args) { - if (args.Length != 8) + if (args.Length != 8 && args.Length != 9) { Console.WriteLine("Usage: importprimscript.exe [firstname] [lastname] [password] " + "[loginuri] [Simulator] [x] [y] [z] [input.primscript]" + diff --git a/libsecondlife/FriendsManager.cs b/libsecondlife/FriendsManager.cs index 5a3f7754..28b1d6a4 100644 --- a/libsecondlife/FriendsManager.cs +++ b/libsecondlife/FriendsManager.cs @@ -692,7 +692,7 @@ namespace libsecondlife private void Network_OnLoginResponse(bool loginSuccess, bool redirect, string message, string reason, LoginResponseData replyData) { - if (loginSuccess) + if (loginSuccess && replyData.BuddyList != null) { lock (_Friends) { diff --git a/libsecondlife/InventoryManager.cs b/libsecondlife/InventoryManager.cs index 1762365d..9932e4ec 100644 --- a/libsecondlife/InventoryManager.cs +++ b/libsecondlife/InventoryManager.cs @@ -107,7 +107,7 @@ namespace libsecondlife public InventoryBase(LLUUID itemID) { if (itemID == LLUUID.Zero) - throw new ArgumentException("Inventory item ID cannot be NULL_KEY (LLUUID.Zero)"); + SecondLife.LogStatic("Initializing an InventoryBase with LLUUID.Zero", Helpers.LogLevel.Warning); UUID = itemID; } diff --git a/libsecondlife/LLSD/LLSD.cs b/libsecondlife/LLSD/LLSD.cs index 21406834..904588ef 100644 --- a/libsecondlife/LLSD/LLSD.cs +++ b/libsecondlife/LLSD/LLSD.cs @@ -148,7 +148,17 @@ namespace libsecondlife.StructuredData this.value = String.Empty; } - public override bool AsBoolean() { return !String.IsNullOrEmpty(value); } + public override bool AsBoolean() + { + if (String.IsNullOrEmpty(value)) + return false; + + if (value == "0" || value.ToLower() == "false") + return false; + + return true; + } + public override int AsInteger() { double dbl; diff --git a/libsecondlife/Login.cs b/libsecondlife/Login.cs index 233f6e21..9d4dabe6 100644 --- a/libsecondlife/Login.cs +++ b/libsecondlife/Login.cs @@ -136,15 +136,28 @@ namespace libsecondlife // Home LLSDMap home = (LLSDMap)LLSDParser.DeserializeNotation(reply["home"].AsString()); - LLSD homeRegion; - if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == LLSDType.Array) + + if (home != null) { - LLSDArray homeArray = (LLSDArray)homeRegion; - if (homeArray.Count == 2) - HomeRegion = Helpers.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger()); + LLSD homeRegion; + if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == LLSDType.Array) + { + LLSDArray homeArray = (LLSDArray)homeRegion; + if (homeArray.Count == 2) + HomeRegion = Helpers.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger()); + else + HomeRegion = 0; + } + + HomePosition = ParseLLVector3("position", home); + HomeLookAt = ParseLLVector3("look_at", home); + } + else + { + HomeRegion = 0; + HomePosition = LLVector3.Zero; + HomeLookAt = LLVector3.Zero; } - HomePosition = ParseLLVector3("position", home); - HomeLookAt = ParseLLVector3("look_at", home); CircuitCode = ParseUInt("circuit_code", reply); RegionX = ParseUInt("region_x", reply); @@ -636,26 +649,34 @@ namespace libsecondlife ulong handle = Helpers.UIntsToLong(data.RegionX, data.RegionY); - // Connect to the sim given in the login reply - if (Connect(data.SimIP, data.SimPort, handle, true, LoginSeedCapability) != null) + if (data.SimIP != null && data.SimPort != 0) { - // Request the economy data right after login - SendPacket(new EconomyDataRequestPacket()); - - // Update the login message with the MOTD returned from the server - UpdateLoginStatus(LoginStatus.Success, message); - - // Fire an event for connecting to the grid - if (OnConnected != null) + // Connect to the sim given in the login reply + if (Connect(data.SimIP, data.SimPort, handle, true, LoginSeedCapability) != null) { - try { OnConnected(this.Client); } - catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } + // Request the economy data right after login + SendPacket(new EconomyDataRequestPacket()); + + // Update the login message with the MOTD returned from the server + UpdateLoginStatus(LoginStatus.Success, message); + + // Fire an event for connecting to the grid + if (OnConnected != null) + { + try { OnConnected(this.Client); } + catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } + } + } + else + { + UpdateLoginStatus(LoginStatus.Failed, + "Unable to establish a UDP connection to the simulator"); } } else { UpdateLoginStatus(LoginStatus.Failed, - "Unable to establish a UDP connection to the simulator"); + "Login server did not return a simulator address"); } } else if (redirect)