internal static int GetMap() { if (GetMapFunction == null) { GetMapFunction = Memory.Reader.RegisterDelegate <GetMapDelegate>((IntPtr)Constants.Offsets.Functions.ClntObjMgrGetMapId); } return(GetMapFunction()); }
public void DrawMap() { var PBI = new PBInvalidateDelegate(PBInvalidate); var gmd = new GetMapDelegate(GetMap); var sbd = new SetBitmapDelegate(SetBitmap); var getPBWidth = new GetPBWidthDelegate(GetPBWidth); var getPBheight = new GetPBHeightDelegate(GetPBHeight); var getMutex = new GetMutexDelegate(GetMutex); var width = (int)Invoke(getPBWidth); var height = (int)Invoke(getPBheight); while (true) { var bitmap = new Bitmap(width, height); var curMap = Invoke(gmd) as List <List <Elem> >; var mutex = Invoke(getMutex) as Mutex; //lock (curMap) if (mutex.WaitOne(5000)) { try { for (int i = 0; i < curMap.Count; i++) { var list = curMap[i]; for (int j = 0; j < list.Count; j++) { var red = list[j].Vector[0]; var green = list[j].Vector[1]; var blue = list[j].Vector[2]; var color = Color.FromArgb(red, green, blue); bitmap.SetPixel(j, i, color); } } } finally { mutex.ReleaseMutex(); } Invoke(sbd, bitmap); Invoke(PBI); } //Thread.Sleep(0); } }