Package net.sf.colossus.server
Class GameLoading
java.lang.Object
net.sf.colossus.server.GameLoading
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.jdom.Element
getRoot()
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)Try to load a game from saveDirName/filename.loadGameFromFile
(File file) Load contents of the file, get variant name, load the right variant and get the root element.private long
numberValue
(String filename) Extract and return the numeric part of a filename.private File
resolveFileNameToFile
(String filename) For a given filename, open the file with that name from save game directory.
-
Field Details
-
LOGGER
-
variant
-
root
private org.jdom.Element root
-
-
Constructor Details
-
GameLoading
public GameLoading()
-
-
Method Details
-
getVariant
-
getRoot
public org.jdom.Element getRoot() -
loadGame
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
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
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
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
Extract and return the numeric part of a filename.
-