示例#1
0
        public static void WriteResult(CommandContext Context, GridImportResult result)
        {
            switch (result)
            {
            case GridImportResult.FILE_NOT_FOUND:
                Context.Respond("The requested File was not found!");
                break;

            case GridImportResult.NO_GRIDS_IN_FILE:
                Context.Respond("There arent any Grids in your file to import!");
                break;

            case GridImportResult.UNKNOWN_ERROR:
                Context.Respond("An unknown error occured while importing the file. Check your logs for more information!");
                break;

            case GridImportResult.NO_GRIDS_IN_BLUEPRINT:
                Context.Respond("No grids in blueprint!");
                break;

            case GridImportResult.NO_FREE_SPACE_AVAILABLE:
                Context.Respond("No free space available!");
                break;

            case GridImportResult.NOT_COMPATIBLE:
                Context.Respond("The File to be imported does not seem to be compatible with the server!");
                break;

            case GridImportResult.POTENTIAL_BLOCKED_SPACE:
                Context.Respond("There are potentially other grids in the way. If you are certain is free you can set 'force' to true!");
                break;
            }
        }
示例#2
0
        public static GridImportResult LoadGrid(string path, BoundingSphereD position, double cutout, bool keepOriginalLocation, long playerid, bool KeepOriginalOwner, bool PlayerRespawn, string ThisIp, bool force = false)
        {
            if (!File.Exists(path))
            {
                return(GridImportResult.FILE_NOT_FOUND);
            }

            if (MyObjectBuilderSerializer.DeserializeXML(path, out MyObjectBuilder_Definitions myObjectBuilder_Definitions))
            {
                var shipBlueprints = myObjectBuilder_Definitions.ShipBlueprints;

                if (shipBlueprints == null)
                {
                    Log.Warn("No ShipBlueprints in File '" + path + "'");
                    return(GridImportResult.NO_GRIDS_IN_FILE);
                }

                foreach (var shipBlueprint in shipBlueprints)
                {
                    GridImportResult result = LoadShipBlueprint(shipBlueprint, position, cutout, keepOriginalLocation, playerid, KeepOriginalOwner, PlayerRespawn, ThisIp, force);

                    if (result != GridImportResult.OK)
                    {
                        Log.Warn("Error Loading ShipBlueprints from File '" + path + "'");
                        return(result);
                    }
                }
                return(GridImportResult.OK);
            }

            Log.Warn("Error Loading File '" + path + "' check Keen Logs.");

            return(GridImportResult.UNKNOWN_ERROR);
        }