mirror of
https://github.com/opensim/opensim.git
synced 2026-05-16 19:56:04 +08:00
To use, see the appearance section in opensim.ini.example, set "persist = true", then add the correct connection string for your database.(see mysql-AvatarAppearance.sql in share folder for a example of the table mysql table structure). This could possible be used in a very small grid, but would mean each region server would need to connect to the same mysql database. But the work to move the code to one of the grid servers shouldn't be too much.
77 lines
2.5 KiB
C#
77 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Text;
|
|
using libsecondlife;
|
|
|
|
using TribalMedia.Framework.Data;
|
|
|
|
namespace OpenSim.Framework.Data
|
|
{
|
|
public class OpenSimObjectFieldMapper<TObject, TField> : ObjectField<TObject, TField>
|
|
{
|
|
public OpenSimObjectFieldMapper(BaseTableMapper tableMapper, string fieldName,
|
|
ObjectGetAccessor<TObject, TField> rowMapperGetAccessor,
|
|
ObjectSetAccessor<TObject, TField> rowMapperSetAccessor)
|
|
: base(tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor)
|
|
{
|
|
}
|
|
|
|
public override void ExpandField<TObj>(TObj obj, DbCommand command, List<string> fieldNames)
|
|
{
|
|
string fieldName = FieldName;
|
|
object value = GetParamValue(obj);
|
|
|
|
if (ValueType == typeof(LLVector3))
|
|
{
|
|
LLVector3 vector = (LLVector3)value;
|
|
|
|
RawAddParam(command, fieldNames, fieldName + "X", vector.X);
|
|
RawAddParam(command, fieldNames, fieldName + "Y", vector.Y);
|
|
RawAddParam(command, fieldNames, fieldName + "Z", vector.Z);
|
|
}
|
|
else if (ValueType == typeof(LLQuaternion))
|
|
{
|
|
LLQuaternion quaternion = (LLQuaternion)value;
|
|
|
|
RawAddParam(command, fieldNames, fieldName + "X", quaternion.X);
|
|
RawAddParam(command, fieldNames, fieldName + "Y", quaternion.Y);
|
|
RawAddParam(command, fieldNames, fieldName + "Z", quaternion.Z);
|
|
RawAddParam(command, fieldNames, fieldName + "W", quaternion.W);
|
|
}
|
|
else
|
|
{
|
|
base.ExpandField(obj, command, fieldNames);
|
|
}
|
|
}
|
|
|
|
protected override object GetValue(BaseDataReader reader)
|
|
{
|
|
object value;
|
|
|
|
OpenSimDataReader osreader = (OpenSimDataReader) reader;
|
|
|
|
if (ValueType == typeof(LLVector3))
|
|
{
|
|
value = osreader.GetVector(FieldName);
|
|
}
|
|
else if (ValueType == typeof(LLQuaternion))
|
|
{
|
|
value = osreader.GetQuaternion(FieldName);
|
|
}
|
|
else if (ValueType == typeof(LLUUID))
|
|
{
|
|
Guid guid = reader.GetGuid(FieldName);
|
|
value = new LLUUID(guid);
|
|
}
|
|
else
|
|
{
|
|
value = base.GetValue(reader);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
}
|
|
}
|
|
|