internal static void LoadDll(string name) { if (dll != null) { log.WriteLine("dll already loaded! be careful!", log.LogMessageType.Error); return; } if (!filesystem.Exists(name)) { log.ThrowFatal("Could not find game dll '" + name + "'."); } byte[] data; using (Stream p = filesystem.Open(name)) { data = new byte[p.Length]; p.Read(data, 0, data.Length); } Assembly tempDll = Assembly.Load(data); log.WriteLine("dll: loading " + name); dll = (dll)tempDll.CreateInstance("game.GameDLL"); if (dll.title != DEF_GAME_TITLE) { log.WriteLine( "Game module is modified. Please only continue if you are aware and trust the author. In order to maximise modularity, game modules have *full access* to your system. BE VERY CAREFUL!!", log.LogMessageType.Warning); statemanager.SetState(new securityPrompt(() => { LoadDLL(dll); }, ref tempDll, ref dll)); } else { LoadDLL(dll); } }
private static void LoadDLL(dll dll) { try { dll.Init(); } catch { log.ThrowFatal("An error occured when initializing the game dll. (" + dll.title + ", " + dll.version + ", " + dll.dev + ")"); return; } log.WriteLine("dll: loaded successfully (" + dll.title + ", " + dll.version + ", " + dll.dev + ")", log.LogMessageType.Good); engine.SetTitle(dll.title); engine.SetIcon("icon_1024.ico"); /* load default state */ statemanager.SetState(progs.dll.GetInitialState()); /* finish loading and setup */ engine.PostLoad(); }