From cff3c20ee5df34f4a6ff05c0bc1fbd35baceff42 Mon Sep 17 00:00:00 2001
From: Charles Krinke
Date: Sun, 2 Mar 2008 22:36:47 +0000
Subject: Thank you very much, Ahzzmandius for: converts Parse calls to
TryParse Replaces string.empty and lluuid.zero calls on user load to use real
values from DB (related to user profile save/load work. Finer grained
patching)
---
OpenSim/Framework/Data.MySQL/MySQLManager.cs | 70 +++++++++++-----------------
OpenSim/Framework/Data/RegionProfileData.cs | 8 +---
2 files changed, 27 insertions(+), 51 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
index e8c42f3..1a90eea 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
@@ -293,10 +293,14 @@ namespace OpenSim.Framework.Data.MySQL
if (reader.Read())
{
- // Region Main
- retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString());
- retval.regionName = (string) reader["regionName"];
- retval.UUID = new LLUUID((string) reader["uuid"]);
+ // Region Main gotta-have-or-we-return-null parts
+ if (!UInt64.TryParse(reader["regionHandle"].ToString(), out retval.regionHandle))
+ return null;
+ if (!LLUUID.TryParse((string)reader["uuid"], out retval.UUID))
+ return null;
+
+ // non-critical parts
+ retval.regionName = (string)reader["regionName"];
// Secrets
retval.regionRecvKey = (string) reader["regionRecvKey"];
@@ -334,33 +338,9 @@ namespace OpenSim.Framework.Data.MySQL
retval.regionUserSendKey = (string) reader["regionUserSendKey"];
// World Map Addition
- string tempRegionMap = reader["regionMapTexture"].ToString();
- if (tempRegionMap != String.Empty)
- {
- retval.regionMapTextureID = new LLUUID(tempRegionMap);
- }
- else
- {
- retval.regionMapTextureID = LLUUID.Zero;
- }
-
- // part of an initial brutish effort to provide accurate information (as per the xml region spec)
- // wrt the ownership of a given region
- // the (very bad) assumption is that this value is being read and handled inconsistently or
- // not at all. Current strategy is to put the code in place to support the validity of this information
- // and to roll forward debugging any issues from that point
- //
- // this particular section of the mod attempts to supply a value from the region table to the caller of 'readSimRow()'
- // for the UUID of the region's owner (master avatar)
- try
- {
- retval.owner_uuid = new LLUUID((string)reader["owner_uuid"]);
- }
- catch
- {
- retval.owner_uuid = LLUUID.Zero;
- }
- }
+ LLUUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID);
+ LLUUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid);
+ }
else
{
return null;
@@ -387,7 +367,7 @@ namespace OpenSim.Framework.Data.MySQL
retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString());
retval.reservationName = (string) reader["resName"];
retval.status = Convert.ToInt32(reader["status"].ToString()) == 1;
- retval.userUUID = new LLUUID((string) reader["userUUID"]);
+ LLUUID.TryParse((string) reader["userUUID"], out retval.userUUID);
}
else
{
@@ -408,9 +388,10 @@ namespace OpenSim.Framework.Data.MySQL
if (reader.Read())
{
// Agent IDs
- retval.UUID = new LLUUID((string) reader["UUID"]);
- retval.sessionID = new LLUUID((string) reader["sessionID"]);
- retval.secureSessionID = new LLUUID((string) reader["secureSessionID"]);
+ if (!LLUUID.TryParse((string)reader["UUID"], out retval.UUID))
+ return null;
+ LLUUID.TryParse((string) reader["sessionID"], out retval.sessionID);
+ LLUUID.TryParse((string)reader["secureSessionID"], out retval.secureSessionID);
// Agent Who?
retval.agentIP = (string) reader["agentIP"];
@@ -444,7 +425,8 @@ namespace OpenSim.Framework.Data.MySQL
if (reader.Read())
{
- retval.UUID = new LLUUID((string) reader["UUID"]);
+ if (!LLUUID.TryParse((string)reader["UUID"], out retval.UUID))
+ return null;
retval.username = (string) reader["username"];
retval.surname = (string) reader["lastname"];
@@ -473,8 +455,8 @@ namespace OpenSim.Framework.Data.MySQL
retval.profileAboutText = (string) reader["profileAboutText"];
retval.profileFirstText = (string) reader["profileFirstText"];
- retval.profileImage = new LLUUID((string) reader["profileImage"]);
- retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]);
+ LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage);
+ LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage);
if( reader.IsDBNull( reader.GetOrdinal( "webLoginKey" ) ) )
{
@@ -482,7 +464,7 @@ namespace OpenSim.Framework.Data.MySQL
}
else
{
- retval.webLoginKey = new LLUUID((string)reader["webLoginKey"]);
+ LLUUID.TryParse((string)reader["webLoginKey"], out retval.webLoginKey);
}
}
else
@@ -605,11 +587,11 @@ namespace OpenSim.Framework.Data.MySQL
parameters["?userAssetURI"] = String.Empty;
parameters["?profileCanDoMask"] = "0";
parameters["?profileWantDoMask"] = "0";
- parameters["?profileAboutText"] = String.Empty;
- parameters["?profileFirstText"] = String.Empty;
- parameters["?profileImage"] = LLUUID.Zero.ToString();
- parameters["?profileFirstImage"] = LLUUID.Zero.ToString();
- parameters["?webLoginKey"] = LLUUID.Random().ToString();
+ parameters["?profileAboutText"] = aboutText;
+ parameters["?profileFirstText"] = firstText;
+ parameters["?profileImage"] = profileImage.ToString();
+ parameters["?profileFirstImage"] = firstImage.ToString();
+ parameters["?webLoginKey"] = string.Empty;
bool returnval = false;
diff --git a/OpenSim/Framework/Data/RegionProfileData.cs b/OpenSim/Framework/Data/RegionProfileData.cs
index fb53ac7..f9f4283 100644
--- a/OpenSim/Framework/Data/RegionProfileData.cs
+++ b/OpenSim/Framework/Data/RegionProfileData.cs
@@ -123,17 +123,11 @@ namespace OpenSim.Framework.Data
///
public LLUUID regionMapTextureID = new LLUUID("00000000-0000-0000-9999-000000000006");
- // part of an initial brutish effort to provide accurate information (as per the xml region spec)
- // wrt the ownership of a given region
- // the (very bad) assumption is that this value is being read and handled inconsistently or
- // not at all. Current strategy is to put the code in place to support the validity of this information
- // and to roll forward debugging any issues from that point
- //
///
/// this particular mod to the file provides support within the spec for RegionProfileData for the
/// owner_uuid for the region
///
- public LLUUID owner_uuid;
+ public LLUUID owner_uuid = LLUUID.Zero;
///
/// Get Sim profile data from grid server when in grid mode
--
cgit v1.1