Class GameLoading

java.lang.Object
net.sf.colossus.server.GameLoading

public class GameLoading extends Object
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • variant

      private Variant variant
    • root

      private org.jdom.Element root
  • Constructor Details

    • GameLoading

      public GameLoading()
  • Method Details

    • getVariant

      public Variant getVariant()
    • getRoot

      public org.jdom.Element getRoot()
    • loadGame

      public String loadGame(String filename)
      Try to load a game from saveDirName/filename. If the filename is "--latest" then load the latest savegame that can be found in saveDirName.
      Returns:
      String telling reason for failure, or null if all ok
    • resolveFileNameToFile

      private File resolveFileNameToFile(String filename)
      For a given filename, open the file with that name from save game directory. If no such file, try also whether with adding ".xml" it would become a valid/existing file. If the filename is "--latest" then load the latest savegame that can be found in saveDirName.
      Parameters:
      filename - The name of the file to load, or "--latest" for looking for latest save game (snapshot) file.
      Returns:
      The File object for that filename, or null if no such file can't be found
    • loadGameFromFile

      public String loadGameFromFile(File file)
      Load contents of the file, get variant name, load the right variant and get the root element. Currently also gets all variant data files and puts them to file cache but that is going to be removed one day. Soon ;-)
      Parameters:
      file - The file from which to load the game
      Returns:
      True if load was successful, otherwise false
    • latestSaveFilename

      private String latestSaveFilename(String[] filenames)
      Find from the list of savegame filenames the one with the highest numerical value (1000000000_xxx.xml comes after 999999999_xxx.xml)
      Parameters:
      filenames - An array of strings which represent filenames
      Returns:
      Latest savegame from the list
    • numberValue

      private long numberValue(String filename)
      Extract and return the numeric part of a filename.