#define ENABLE_UNUSED_CODE FALSE /* for currently unused functions */
+#define DEBUG_NO_CONFIG_FILE FALSE /* for extra-verbose debug output */
#define NUM_LEVELCLASS_DESC 8
return levelsetup_dir;
}
-static char *getCacheDir()
+static char *getCacheDir(void)
{
static char *cache_dir = NULL;
return cache_dir;
}
+static char *getNetworkDir(void)
+{
+ static char *network_dir = NULL;
+
+ if (network_dir == NULL)
+ network_dir = getPath2(getUserGameDataDir(), NETWORK_DIRECTORY);
+
+ return network_dir;
+}
+
static char *getLevelDirFromTreeInfo(TreeInfo *node)
{
static char *level_dir = NULL;
return userlevel_dir;
}
-char *getCurrentLevelDir()
+char *getNetworkLevelDir(char *level_subdir)
+{
+ static char *network_level_dir = NULL;
+ char *data_dir = getNetworkDir();
+ char *networklevel_subdir = LEVELS_DIRECTORY;
+
+ checked_free(network_level_dir);
+
+ if (level_subdir != NULL)
+ network_level_dir = getPath3(data_dir, networklevel_subdir, level_subdir);
+ else
+ network_level_dir = getPath2(data_dir, networklevel_subdir);
+
+ return network_level_dir;
+}
+
+char *getCurrentLevelDir(void)
{
return getLevelDirFromTreeInfo(leveldir_current);
}
-char *getNewUserLevelSubdir()
+char *getNewUserLevelSubdir(void)
{
static char *new_level_subdir = NULL;
char *subdir_prefix = getLoginName();
return tape_dir;
}
-static char *getSolutionTapeDir()
+static char *getSolutionTapeDir(void)
{
static char *tape_dir = NULL;
char *data_dir = getCurrentLevelDir();
getDefaultMusicDir(MUS_CLASSIC_SUBDIR) : "");
}
-static char *getUserGraphicsDir()
+static char *getUserGraphicsDir(void)
{
static char *usergraphics_dir = NULL;
return usergraphics_dir;
}
-static char *getUserSoundsDir()
+static char *getUserSoundsDir(void)
{
static char *usersounds_dir = NULL;
return usersounds_dir;
}
-static char *getUserMusicDir()
+static char *getUserMusicDir(void)
{
static char *usermusic_dir = NULL;
checked_free(filename);
sprintf(basename, "%03d.%s", nr, SCOREFILE_EXTENSION);
- filename = getPath2(getScoreDir(leveldir_current->subdir), basename);
+
+ /* used instead of "leveldir_current->subdir" (for network games) */
+ filename = getPath2(getScoreDir(levelset.identifier), basename);
return filename;
}
-char *getSetupFilename()
+char *getSetupFilename(void)
{
static char *filename = NULL;
return filename;
}
-char *getDefaultSetupFilename()
+char *getDefaultSetupFilename(void)
{
return program.config_filename;
}
-char *getEditorSetupFilename()
+char *getEditorSetupFilename(void)
{
static char *filename = NULL;
return filename;
}
-char *getHelpAnimFilename()
+char *getHelpAnimFilename(void)
{
static char *filename = NULL;
return filename;
}
-char *getHelpTextFilename()
+char *getHelpTextFilename(void)
{
static char *filename = NULL;
return filename;
}
-char *getLevelSetInfoFilename()
+char *getLevelSetInfoFilename(void)
{
static char *filename = NULL;
char *basenames[] =
return NULL;
}
-char *getLevelSetTitleMessageBasename(int nr, boolean initial)
+static char *getLevelSetTitleMessageBasename(int nr, boolean initial)
{
static char basename[32];
createDirectory(getScoreDir(level_subdir), "level score", permissions);
}
-static void SaveUserLevelInfo();
+static void SaveUserLevelInfo(void);
void InitUserLevelDirectory(char *level_subdir)
{
}
}
+void InitNetworkLevelDirectory(char *level_subdir)
+{
+ if (!directoryExists(getNetworkLevelDir(level_subdir)))
+ {
+ createDirectory(getUserGameDataDir(), "user data", PERMS_PRIVATE);
+ createDirectory(getNetworkDir(), "network data", PERMS_PRIVATE);
+ createDirectory(getNetworkLevelDir(NULL), "main network level", PERMS_PRIVATE);
+ createDirectory(getNetworkLevelDir(level_subdir), "network level", PERMS_PRIVATE);
+ }
+}
+
void InitLevelSetupDirectory(char *level_subdir)
{
createDirectory(getUserGameDataDir(), "user data", PERMS_PRIVATE);
createDirectory(getLevelSetupDir(level_subdir), "level setup", PERMS_PRIVATE);
}
-void InitCacheDirectory()
+static void InitCacheDirectory(void)
{
createDirectory(getUserGameDataDir(), "user data", PERMS_PRIVATE);
createDirectory(getCacheDir(), "cache data", PERMS_PRIVATE);
/* some functions to handle lists of level and artwork directories */
/* ------------------------------------------------------------------------- */
-TreeInfo *newTreeInfo()
+TreeInfo *newTreeInfo(void)
{
return checked_calloc(sizeof(TreeInfo));
}
return NULL;
}
-TreeInfo *cloneTreeNode(TreeInfo **node_top, TreeInfo *node_parent,
- TreeInfo *node, boolean skip_sets_without_levels)
+static TreeInfo *cloneTreeNode(TreeInfo **node_top, TreeInfo *node_parent,
+ TreeInfo *node, boolean skip_sets_without_levels)
{
TreeInfo *node_new;
return node_new;
}
-void cloneTree(TreeInfo **ti_new, TreeInfo *ti, boolean skip_empty_sets)
+static void cloneTree(TreeInfo **ti_new, TreeInfo *ti, boolean skip_empty_sets)
{
TreeInfo *ti_cloned = cloneTreeNode(ti_new, NULL, ti, skip_empty_sets);
#define FILE_PERMS_PUBLIC_ALL (MODE_R_ALL | MODE_W_ALL)
-char *getHomeDir()
+char *getHomeDir(void)
{
static char *dir = NULL;
return user_game_data_dir;
}
-char *getSetupDir()
+char *getSetupDir(void)
{
return getUserGameDataDir();
}
#endif
}
-static boolean posix_process_running_setgid()
+static boolean posix_process_running_setgid(void)
{
#if defined(PLATFORM_UNIX)
return (getgid() != getegid());
posix_umask(last_umask); /* restore previous umask */
}
-void InitUserDataDirectory()
+void InitUserDataDirectory(void)
{
createDirectory(getUserGameDataDir(), "user data", PERMS_PRIVATE);
}
sprintf(cookie, "%s_%s_FILE_VERSION_%d.%d",
program.cookie_prefix, file_type,
- program.version_major, program.version_minor);
+ program.version_super, program.version_major);
return cookie;
}
const int len_pattern1 = strlen(pattern1);
const int len_pattern2 = strlen(pattern2);
const int len_pattern = len_pattern1 + len_pattern2;
- int version_major, version_minor;
+ int version_super, version_major;
if (len_cookie <= len_pattern)
return -1;
ptr_cookie2[2] < '0' || ptr_cookie2[2] > '9')
return -1;
- version_major = ptr_cookie2[0] - '0';
- version_minor = ptr_cookie2[2] - '0';
+ version_super = ptr_cookie2[0] - '0';
+ version_major = ptr_cookie2[2] - '0';
- return VERSION_IDENT(version_major, version_minor, 0, 0);
+ return VERSION_IDENT(version_super, version_major, 0, 0);
}
boolean checkCookieString(const char *cookie, const char *template)
return (strEqual((char *)key1, (char *)key2));
}
-SetupFileHash *newSetupFileHash()
+SetupFileHash *newSetupFileHash(void)
{
SetupFileHash *new_hash =
create_hashtable(16, 0.75, get_hash_from_key, keys_are_equal);
if (!(file = openFile(filename, MODE_READ)))
{
+#if DEBUG_NO_CONFIG_FILE
Error(ERR_DEBUG, "cannot open configuration file '%s'", filename);
+#endif
return FALSE;
}
return TRUE;
}
-void saveSetupFileHash(SetupFileHash *hash, char *filename)
+static void saveSetupFileHash(SetupFileHash *hash, char *filename)
{
FILE *file;
*(char **)setup_value = getStringCopy(token_value);
break;
+ case TYPE_PLAYER:
+ *(int *)setup_value = get_player_nr_from_string(token_value);
+ break;
+
default:
break;
}
/* functions for handling level and custom artwork info cache */
/* -------------------------------------------------------------------------- */
-static void LoadArtworkInfoCache()
+static void LoadArtworkInfoCache(void)
{
InitCacheDirectory();
artworkinfo_cache_new = newSetupFileHash();
}
-static void SaveArtworkInfoCache()
+static void SaveArtworkInfoCache(void)
{
char *filename = getPath2(getCacheDir(), ARTWORKINFO_CACHE_FILE);
if (setup_file_hash == NULL)
{
+#if DEBUG_NO_CONFIG_FILE
Error(ERR_WARN, "ignoring level directory '%s'", directory_path);
+#endif
free(directory_path);
free(filename);
level_directory);
}
-boolean AdjustGraphicsForEMC()
+boolean AdjustGraphicsForEMC(void)
{
boolean settings_changed = FALSE;
return settings_changed;
}
-void LoadLevelInfo()
+void LoadLevelInfo(void)
{
InitUserLevelDirectory(getLoginName());
if (!valid_file_found)
{
+#if DEBUG_NO_CONFIG_FILE
if (!strEqual(directory_name, "."))
Error(ERR_WARN, "ignoring artwork directory '%s'", directory_path);
+#endif
free(directory_path);
free(filename);
return artwork_new;
}
-void LoadArtworkInfo()
+void LoadArtworkInfo(void)
{
LoadArtworkInfoCache();
#endif
}
-void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node,
- LevelDirTree *level_node)
+static void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node,
+ LevelDirTree *level_node)
{
int type = (*artwork_node)->type;
}
}
-void LoadLevelArtworkInfo()
+void LoadLevelArtworkInfo(void)
{
print_timestamp_init("LoadLevelArtworkInfo");
return getTreeInfoFromIdentifier(artwork_first_node, artwork_set);
}
-boolean checkIfCustomArtworkExistsForCurrentLevelSet()
+boolean checkIfCustomArtworkExistsForCurrentLevelSet(void)
{
char *graphics_set =
getArtworkIdentifierForUserLevelSet(ARTWORK_TYPE_GRAPHICS);
return TRUE;
}
-static void SaveUserLevelInfo()
+static void SaveUserLevelInfo(void)
{
CreateUserLevelSet(getLoginName(), getLoginName(), getRealName(), 100, FALSE);
}
strcpy(value_string, *(char **)value);
break;
+ case TYPE_PLAYER:
+ sprintf(value_string, "player_%d", *(int *)value + 1);
+ break;
+
default:
value_string[0] = '\0';
break;
return line;
}
-void LoadLevelSetup_LastSeries()
+void LoadLevelSetup_LastSeries(void)
{
/* ----------------------------------------------------------------------- */
/* ~/.<program>/levelsetup.conf */
free(filename);
}
-void SaveLevelSetup_LastSeries()
+void SaveLevelSetup_LastSeries(void)
{
SaveLevelSetup_LastSeries_Ext(FALSE);
}
-void SaveLevelSetup_LastSeries_Deactivate()
+void SaveLevelSetup_LastSeries_Deactivate(void)
{
SaveLevelSetup_LastSeries_Ext(TRUE);
}
-static void checkSeriesInfo()
+static void checkSeriesInfo(void)
{
static char *level_directory = NULL;
Directory *dir;
closeDirectory(dir);
}
-void LoadLevelSetup_SeriesInfo()
+void LoadLevelSetup_SeriesInfo(void)
{
char *filename;
SetupFileHash *level_setup_hash = NULL;
free(filename);
}
-void SaveLevelSetup_SeriesInfo()
+void SaveLevelSetup_SeriesInfo(void)
{
char *filename;
char *level_subdir = leveldir_current->subdir;