Allow estate config files to specify a specific EstateID. Defaults to 0 if not specified which uses auto increment id as current behaviour.

This commit is contained in:
Alicia Raven
2020-12-15 17:05:30 +00:00
parent 73d33aee32
commit a969797512
10 changed files with 81 additions and 38 deletions

View File

@@ -177,10 +177,12 @@ namespace OpenSim.Data.PGSQL
return es;
}
public EstateSettings CreateNewEstate()
public EstateSettings CreateNewEstate(int estateID)
{
EstateSettings es = new EstateSettings();
es.OnSave += StoreEstateSettings;
es.EstateID = Convert.ToUInt32(estateID);
DoCreate(es);
@@ -197,7 +199,9 @@ namespace OpenSim.Data.PGSQL
{
List<string> names = new List<string>(FieldList);
names.Remove("EstateID");
// Remove EstateID and use AutoIncrement
if (es.EstateID < 100)
names.Remove("EstateID");
string sql = string.Format("insert into estate_settings (\"{0}\") values ( :{1} )", String.Join("\",\"", names.ToArray()), String.Join(", :", names.ToArray()));
@@ -215,10 +219,9 @@ namespace OpenSim.Data.PGSQL
//insertCommand.Parameters.Add(idParameter);
conn.Open();
es.EstateID = 100;
if (insertCommand.ExecuteNonQuery() > 0)
if (insertCommand.ExecuteNonQuery() > 0 && es.EstateID < 100)
{
// Only get Auto ID if we actually used it
insertCommand.CommandText = "Select cast(lastval() as int) as ID ;";
using (NpgsqlDataReader result = insertCommand.ExecuteReader())