private void SetBoolean(string command, Boolean value) { UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Set"); UODLL.PushStrVal(UOHandle, command); UODLL.PushBoolean(UOHandle, value); UODLL.Execute(UOHandle); }
private void SetString(string command, string value) { UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Set"); UODLL.PushStrVal(UOHandle, command); UODLL.PushStrVal(UOHandle, value); UODLL.Execute(UOHandle); }
private void SetInt(string command, int value) { UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Set"); UODLL.PushStrVal(UOHandle, command); UODLL.PushInteger(UOHandle, value); UODLL.Execute(UOHandle); }
//Executes a GameDLL command, Idea taken from jultima http://code.google.com/p/jultima/ public List <object> _executeCommand(bool ReturnResults, string CommandName, object[] args) { // Maybe return bool and results as an Out? List <object> Results = new List <object>(); UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Call"); UODLL.PushStrVal(UOHandle, CommandName); foreach (var o in args) { if (o is Int32) // (o.GetType() == typeof(int)) { UODLL.PushInteger(UOHandle, (int)o); } else if (o is string) { UODLL.PushStrVal(UOHandle, (string)o); } else if (o is bool) { UODLL.PushBoolean(UOHandle, (bool)o); } } if (UODLL.Execute(UOHandle) != 0) { return(null); } if (!ReturnResults) { return(null); } int objectcnt = UODLL.GetTop(UOHandle); for (int i = 1; i <= objectcnt; i++) { int gettype = UODLL.GetType(UOHandle, 1); switch (gettype) { case 1: Results.Add(UODLL.GetBoolean(UOHandle, i).ToString()); break; case 3: Results.Add(UODLL.GetInteger(UOHandle, i).ToString()); break; case 4: Results.Add(Marshal.PtrToStringAnsi(UODLL.GetString(UOHandle, i))); break; default: throw new NotImplementedException(); break; } } return(Results); }
public int ScanItems(bool VisibleOnly) { UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Call"); UODLL.PushStrVal(UOHandle, "ScanItems"); UODLL.PushBoolean(UOHandle, VisibleOnly); if (UODLL.Execute(UOHandle) != 0) { return(0); } return(UODLL.GetInteger(UOHandle, 1)); }
private string GetString(string command) { UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Get"); UODLL.PushStrVal(UOHandle, command); var result = UODLL.Execute(UOHandle); if (result == 0) { return(Marshal.PtrToStringAnsi(UODLL.GetString(UOHandle, 1))); } else { return(null);//Return Blank string instead? } }
private int GetInt(string command) { UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Get"); UODLL.PushStrVal(UOHandle, command); var result = UODLL.Execute(UOHandle); if (result == 0) { return(UODLL.GetInteger(UOHandle, 1)); } else { return(0); } }
//Get and Set Handlers #region GetterSetterHelpers private bool GetBoolean(string command) { UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Get"); UODLL.PushStrVal(UOHandle, command); var result = UODLL.Execute(UOHandle); if (result == 0) { return(UODLL.GetBoolean(UOHandle, 1)); } else { return(false); } }
/// <summary> /// Opens UO.dll and attaches to specified Client instance. /// </summary> /// <returns>true if Open, false if wrong version or failure</returns> public bool Open(int CliNr) { UOHandle = UODLL.Open(); var ver = UODLL.Version(); if (ver != 3) { Console.WriteLine("Warning Unsupported DLL!"); } UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Set"); UODLL.PushStrVal(UOHandle, "CliNr"); UODLL.PushInteger(UOHandle, CliNr); if (UODLL.Execute(UOHandle) != 0) { return(false); } ; return(true); }
/// <summary> /// Opens UO.dll and attaches to first Client instance. /// </summary> /// <returns>true if Open, false if wrong version or failure</returns> public bool Open() { UOHandle = UODLL.Open(); var ver = UODLL.Version(); if (ver != 3) { return(false); } UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Set"); UODLL.PushStrVal(UOHandle, "CliNr"); UODLL.PushInteger(UOHandle, 1); if (UODLL.Execute(UOHandle) != 0) { return(false); } ; return(true); }
public FoundItem GetItem(int index) { UODLL.SetTop(UOHandle, 0); UODLL.PushStrVal(UOHandle, "Call"); UODLL.PushStrVal(UOHandle, "GetItem"); UODLL.PushInteger(UOHandle, index); if (UODLL.Execute(UOHandle) != 0) { return(null); } FoundItem item = new FoundItem(); item.ID = UODLL.GetInteger(UOHandle, 1); item.Type = UODLL.GetInteger(UOHandle, 2); item.Kind = UODLL.GetInteger(UOHandle, 3); item.ContID = UODLL.GetInteger(UOHandle, 4); item.X = UODLL.GetInteger(UOHandle, 5); item.Y = UODLL.GetInteger(UOHandle, 6); item.Z = UODLL.GetInteger(UOHandle, 7); item.Stack = UODLL.GetInteger(UOHandle, 8); item.Rep = UODLL.GetInteger(UOHandle, 9); item.Col = UODLL.GetInteger(UOHandle, 10); return(item); }
// Handles opening UO.dll and mapping to correct client. You must ALWAYS call Open before anything else. #region OpenClose /// <summary> /// Closes UO.dll /// </summary> public void Close() { UODLL.Close(UOHandle); }