let scriptEvents flags represent all events we have (so change to 64bit ulong) not the need to keep duplicated definitions on main framework and each script engine, namely because Xengine app domain option

This commit is contained in:
UbitUmarov
2020-09-04 14:22:24 +01:00
parent fcc9b30c1e
commit 23de4e3a82
9 changed files with 234 additions and 98 deletions

View File

@@ -36,7 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
string[] GetApis();
void InitApi(string name, IScriptApi data);
int GetStateEventFlags(string state);
ulong GetStateEventFlags(string state);
void ExecuteEvent(string state, string FunctionName, object[] args);
Dictionary<string,Object> GetVars();
void SetVars(Dictionary<string,Object> vars);

View File

@@ -40,17 +40,117 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Contains the script to execute functions in.
/// </summary>
protected IScript m_Script;
// this is not the right place for this
// for now it must match similar enums duplicated on scritp engines
public enum ScriptEventCode : int
{
None = -1,
attach = 0,
state_exit = 1,
timer = 2,
touch = 3,
collision = 4,
collision_end = 5,
collision_start = 6,
control = 7,
dataserver = 8,
email = 9,
http_response = 10,
land_collision = 11,
land_collision_end = 12,
land_collision_start = 13,
at_target = 14,
listen = 15,
money = 16,
moving_end = 17,
moving_start = 18,
not_at_rot_target = 19,
not_at_target = 20,
touch_start = 21,
object_rez = 22,
remote_data = 23,
at_rot_target = 24,
transaction_result = 25,
//
//
run_time_permissions = 28,
touch_end = 29,
state_entry = 30,
//
//
changed = 33,
link_message = 34,
no_sensor = 35,
on_rez = 36,
sensor = 37,
http_request = 38,
path_update = 40,
// marks highest numbered event
Size = 41
}
// this is not the right place for this
// for now it must match similar enums duplicated on scritp engines
[Flags]
public enum scriptEvents : ulong
{
None = 0,
attach = 1,
state_exit = 1UL << 1,
timer = 1UL << 2,
touch = 1UL << 3,
collision = 1UL << 4,
collision_end = 1UL << 5,
collision_start = 1UL << 6,
control = 1UL << 7,
dataserver = 1UL << 8,
email = 1UL << 9,
http_response = 1UL << 10,
land_collision = 1UL << 11,
land_collision_end = 1UL << 12,
land_collision_start = 1UL << 13,
at_target = 1UL << 14,
listen = 1UL << 15,
money = 1UL << 16,
moving_end = 1UL << 17,
moving_start = 1UL << 18,
not_at_rot_target = 1UL << 19,
not_at_target = 1UL << 20,
touch_start = 1UL << 21,
object_rez = 1UL << 22,
remote_data = 1UL << 23,
at_rot_target = 1UL << 24,
transaction_result = 1UL << 25,
//
//
run_time_permissions = 1UL << 28,
touch_end = 1UL << 29,
state_entry = 1UL << 30,
//
//
changed = 1UL << 33,
link_message = 1UL << 34,
no_sensor = 1UL << 35,
on_rez = 1UL << 36,
sensor = 1UL << 37,
http_request = 1UL << 38,
path_update = 1UL << 40,
anytouch = touch | touch_end | touch_start,
anyTarget = at_target | not_at_target | at_rot_target | not_at_rot_target
}
// this is not the right place for this
// for now it must match similar enums duplicated on scritp engines
protected static readonly Dictionary<string, scriptEvents> m_eventFlagsMap = new Dictionary<string, scriptEvents>()
{
{"attach", scriptEvents.attach},
{"at_rot_target", scriptEvents.at_rot_target},
{"at_target", scriptEvents.at_target},
// {"changed",(long)scriptEvents.changed},
{"collision", scriptEvents.collision},
{"collision_end", scriptEvents.collision_end},
{"collision_start", scriptEvents.collision_start},
@@ -61,18 +161,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{"land_collision", scriptEvents.land_collision},
{"land_collision_end", scriptEvents.land_collision_end},
{"land_collision_start", scriptEvents.land_collision_start},
//{"link_message",scriptEvents.link_message},
{"listen", scriptEvents.listen},
{"money", scriptEvents.money},
{"moving_end", scriptEvents.moving_end},
{"moving_start", scriptEvents.moving_start},
{"not_at_rot_target", scriptEvents.not_at_rot_target},
{"not_at_target", scriptEvents.not_at_target},
//{"no_sensor",(long)scriptEvents.no_sensor},
//{"on_rez",(long)scriptEvents.on_rez},
{"remote_data", scriptEvents.remote_data},
{"run_time_permissions", scriptEvents.run_time_permissions},
//{"sensor",(long)scriptEvents.sensor},
{"state_entry", scriptEvents.state_entry},
{"state_exit", scriptEvents.state_exit},
{"timer", scriptEvents.timer},
@@ -80,45 +176,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{"touch_end", scriptEvents.touch_end},
{"touch_start", scriptEvents.touch_start},
{"transaction_result", scriptEvents.transaction_result},
{"object_rez", scriptEvents.object_rez}
{"object_rez", scriptEvents.object_rez},
{"changed", scriptEvents.changed},
{"link_message", scriptEvents.link_message},
{"no_sensor", scriptEvents.no_sensor},
{"on_rez", scriptEvents.on_rez},
{"sensor", scriptEvents.sensor},
{"http_request", scriptEvents.http_request},
{"path_update", scriptEvents.path_update},
};
[Flags]
public enum scriptEvents : int
{
None = 0,
attach = 1,
state_exit = 1 << 1,
timer = 1 << 2,
touch = 1 << 3,
collision = 1 << 4,
collision_end = 1 << 5,
collision_start = 1 << 6,
control = 1 << 7,
dataserver = 1 << 8,
email = 1 << 9,
http_response = 1 << 10,
land_collision = 1 << 11,
land_collision_end = 1 << 12,
land_collision_start = 1 << 13,
at_target = 1 << 14,
listen = 1 << 15,
money = 1 << 16,
moving_end = 1 << 17,
moving_start = 1 << 18,
not_at_rot_target = 1 << 19,
not_at_target = 1 << 20,
touch_start = 1 << 21,
object_rez = 1 << 22,
remote_data = 1 << 23,
at_rot_target = 1 << 24,
transaction_result = 1 << 25,
//
//
run_time_permissions = 1 << 28,
touch_end = 1 << 29,
state_entry = 1 << 30,
}
/// <summary>
/// Contains the script to execute functions in.
/// </summary>
protected IScript m_Script;
// Cache functions by keeping a reference to them in a dictionary
private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>();

View File

@@ -86,9 +86,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
private Executor m_Executor = null;
public int GetStateEventFlags(string state)
public ulong GetStateEventFlags(string state)
{
return (int)m_Executor.GetStateEventFlags(state);
return (ulong)m_Executor.GetStateEventFlags(state);
}
[DebuggerNonUserCode]

View File

@@ -394,7 +394,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
// }
try
{
Part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State));
Part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State));
}
catch
{
@@ -879,7 +879,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_StateChangeInProgress = false;
Part.RemoveScriptTargets(ItemID);
Part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State));
Part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State));
}
else
{

View File

@@ -44,10 +44,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
{
// used by XMRInstance to indicate no event being processed
None = -1,
// must be bit numbers of equivalent values in ...
// OpenSim.Region.ScriptEngine.Shared.ScriptBase.scriptEvents
// ... so they can be passed to m_Part.SetScriptEvents().
attach = 0,
state_exit = 1,
timer = 2,
@@ -77,18 +73,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine
run_time_permissions = 28,
touch_end = 29,
state_entry = 30,
// events not passed to m_Part.SetScriptEvents().
//
//
changed = 33,
link_message = 34,
no_sensor = 35,
on_rez = 36,
sensor = 37,
http_request = 38,
//
path_update = 40,
// marks highest numbered event, ie, number of columns in seht.
// marks highest numbered event
Size = 41
}
}

View File

@@ -216,21 +216,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// Verify that our ScriptEventCode's match OpenSim's scriptEvent's.
bool err = false;
for(int i = 0; i < 32; i++)
for(int i = 0; i < (int)ScriptEventCode.Size; i++)
{
string mycode = "undefined";
string oscode = "undefined";
try
{
mycode = ((ScriptEventCode)i).ToString();
Convert.ToInt32(mycode);
Convert.ToInt64(mycode);
mycode = "undefined";
}
catch { }
try
{
oscode = ((OpenSim.Region.Framework.Scenes.scriptEvents)(1 << i)).ToString();
Convert.ToInt32(oscode);
oscode = ((OpenSim.Region.Framework.Scenes.scriptEvents)(1ul << i)).ToString();
Convert.ToInt64(oscode);
oscode = "undefined";
}
catch { }
@@ -1412,7 +1412,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
instance.EmptyEventQueues();
}
// Declare which events the script's current state can handle.
int eventMask = instance.GetStateEventFlags(instance.stateCode);
ulong eventMask = instance.GetStateEventFlags(instance.stateCode);
instance.m_Part.SetScriptEvents(instance.m_ItemID, eventMask);
QueueToStart(instance);

View File

@@ -213,7 +213,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
* @brief For a given stateCode, get a mask of the low 32 event codes
* that the state has handlers defined for.
*/
public int GetStateEventFlags(int state)
public ulong GetStateEventFlags(int state)
{
if((state < 0) ||
(state >= m_ObjCode.scriptEventHandlerTable.GetLength(0)))
@@ -221,12 +221,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine
return 0;
}
int flags = 0;
for(int i = 0; i < 32; i++)
ulong flags = 0;
for(int i = 0; i <(int)ScriptEventCode.Size; i++)
{
if(m_ObjCode.scriptEventHandlerTable[state, i] != null)
{
flags |= 1 << i;
flags |= 1ul << i;
}
}
return flags;