public bool CreateAndConnectToLocalServer(string serverType, string level)
            {
            if (!CreateServer(serverType, level))

                return false;


            coGameConnection client = new Torque_Class_Helper("GameConnection", "ServerConnection").Create();


            client.setConnectArgs(sGlobal["$pref::Player::Name"]);

            client.setJoinPassword(sGlobal["$Client::Password"]);

            string result = client.connectLocal();

            if (result != "")
                {
                client.delete();
                DestroyServer();
                return false;
                }
            return true;
            }
        public bool sfxAutodetect()
            {
            // Get all the available devices.
            string devices = Util.sfxGetAvailableDevices();
            // Collect and sort the devices by preferentiality.


            int count = Util.getRecordCount(devices);


            coArrayObject deviceTrySequence = new Torque_Class_Helper("ArrayObject").Create().AsString();


            for (int i = 0; i < count; i++)
                {
                string info = Util.getRecord(devices, i);
                string provider = Util.getField(info, 0);
                deviceTrySequence.push_back(provider, info);
                }
            deviceTrySequence.sortfk("sfxCompareProvider");
            // Try the devices in order.

            count = deviceTrySequence.count();
            for (int i = 0; i < count; i++)
                {
                string provider = deviceTrySequence.getKey(i);
                string info = deviceTrySequence.getValue(i);
                sGlobal["$pref::SFX::provider"] = provider;
                sGlobal["$pref::SFX::device"] = Util.getField(info, 1);
                sGlobal["$pref::SFX::useHardware"] = Util.getField(info, 2);
                // By default we've decided to avoid hardware devices as
                // they are buggy and prone to problems.
                bGlobal["$pref::SFX::useHardware"] = false;
                if (!sfxInit())
                    continue;
                bGlobal["$pref::SFX::autoDetect"] = false;
                deviceTrySequence.delete();
                return true;
                }
            // Found no suitable device.
            console.error("sfxAutodetect - Could not initialize a valid SFX device.");
            sGlobal["$pref::SFX::provider"] = "";
            sGlobal["$pref::SFX::device"] = "";
            sGlobal["$pref::SFX::useHardware"] = "";
            deviceTrySequence.delete();
            return false;
            }
 public string loadFileText(string file)
     {
     coFileObject fo = new Torque_Class_Helper("FileObject").Create();
     fo.openForRead(file);
     string text = "";
     while (!fo.isEOF())
         {
         text += fo.readLine();
         if (!fo.isEOF())
             text += "\n";
         }
     fo.delete();
     return text;
     }