{
char *player_name_new;
- checkSetupFileHashIdentifier(setup_file_hash, filename,getCookie("SETUP"));
decodeSetupFileHash(setup_file_hash);
freeSetupFileHash(setup_file_hash);
if (setup_file_hash)
{
- checkSetupFileHashIdentifier(setup_file_hash, filename,getCookie("SETUP"));
decodeSetupFileHash_EditorCascade(setup_file_hash);
freeSetupFileHash(setup_file_hash);
return;
}
- fprintf(file, "%s\n", getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER,
- getCookie("SETUP")));
- fprintf(file, "\n");
+ fprintFileHeader(file, SETUP_FILENAME);
/* global setup */
si = setup;
return;
}
- fprintf(file, "%s\n", getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER,
- getCookie("SETUP")));
- fprintf(file, "\n");
+ fprintFileHeader(file, EDITORCASCADE_FILENAME);
seci = setup.editor_cascade;
- fprintf(file, "\n");
for (i = 0; i < NUM_EDITOR_CASCADE_SETUP_TOKENS; i++)
fprintf(file, "%s\n", getSetupLine(editor_cascade_setup_tokens, "", i));
#include "hash.h"
-#define USE_FILE_IDENTIFIERS FALSE /* do not use identifiers anymore */
#define ENABLE_UNUSED_CODE FALSE /* for currently unused functions */
#define NUM_LEVELCLASS_DESC 8
return cookie;
}
+void fprintFileHeader(FILE *file, char *basename)
+{
+ char *prefix = "# ";
+ char *sep1 = "=";
+
+ fprintf_line_with_prefix(file, prefix, sep1, 77);
+ fprintf(file, "%s%s\n", prefix, basename);
+ fprintf_line_with_prefix(file, prefix, sep1, 77);
+ fprintf(file, "\n");
+}
+
int getFileVersionFromCookieString(const char *cookie)
{
const char *ptr_cookie1, *ptr_cookie2;
return TRUE;
}
+
/* ------------------------------------------------------------------------- */
/* setup file list and hash handling functions */
/* ------------------------------------------------------------------------- */
return setup_file_hash;
}
-void checkSetupFileHashIdentifier(SetupFileHash *setup_file_hash,
- char *filename, char *identifier)
-{
-#if USE_FILE_IDENTIFIERS
- char *value = getHashEntry(setup_file_hash, TOKEN_STR_FILE_IDENTIFIER);
-
- if (value == NULL)
- Error(ERR_WARN, "config file '%s' has no file identifier", filename);
- else if (!checkCookieString(value, identifier))
- Error(ERR_WARN, "config file '%s' has wrong file identifier", filename);
-#endif
-}
-
/* ========================================================================= */
/* setup file stuff */
leveldir_new->subdir = getStringCopy(directory_name);
- checkSetupFileHashIdentifier(setup_file_hash, filename,
- getCookie("LEVELINFO"));
-
/* set all structure fields according to the token/value pairs */
ldi = *leveldir_new;
for (i = 0; i < NUM_LEVELINFO_TOKENS; i++)
token_value_position = TOKEN_VALUE_POSITION_SHORT;
- fprintf(file, "%s\n\n", getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER,
- getCookie("LEVELINFO")));
+ fprintFileHeader(file, LEVELINFO_FILENAME);
ldi = *level_info;
for (i = 0; i < NUM_LEVELINFO_TOKENS; i++)
if (leveldir_current == NULL)
leveldir_current = getFirstValidTreeInfoEntry(leveldir_first);
- checkSetupFileHashIdentifier(level_setup_hash, filename,
- getCookie("LEVELSETUP"));
-
freeSetupFileHash(level_setup_hash);
}
else
return;
}
- fprintf(file, "%s\n\n", getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER,
- getCookie("LEVELSETUP")));
+ fprintFileHeader(file, LEVELSETUP_FILENAME);
if (deactivate_last_level_series)
fprintf(file, "# %s\n# ", "the following level set may have caused a problem and was deactivated");
}
END_HASH_ITERATION(hash, itr)
- checkSetupFileHashIdentifier(level_setup_hash, filename,
- getCookie("LEVELSETUP"));
-
freeSetupFileHash(level_setup_hash);
}
else
return;
}
- fprintf(file, "%s\n\n", getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER,
- getCookie("LEVELSETUP")));
+ fprintFileHeader(file, LEVELSETUP_FILENAME);
+
fprintf(file, "%s\n", getFormattedSetupEntry(TOKEN_STR_LAST_PLAYED_LEVEL,
level_nr_str));
fprintf(file, "%s\n\n", getFormattedSetupEntry(TOKEN_STR_HANDICAP_LEVEL,
#define TYPE_ENTER_OR_LEAVE (TYPE_ENTER | TYPE_LEAVE)
-/* cookie token for file identifier and version number */
-#define TOKEN_STR_FILE_IDENTIFIER "file_identifier"
-
struct TokenInfo
{
int type;
void SetFilePermissions(char *, int);
char *getCookie(char *);
+void fprintFileHeader(FILE *, char *);
int getFileVersionFromCookieString(const char *);
boolean checkCookieString(const char *, const char *);
void setHashEntry(SetupFileHash *, char *, char *);
char *removeHashEntry(SetupFileHash *, char *);
SetupFileHash *loadSetupFileHash(char *);
-void checkSetupFileHashIdentifier(SetupFileHash *, char *, char *);
void setSetupInfo(struct TokenInfo *, int, char *);
char *getSetupValue(int, void *);
char *getSetupLine(struct TokenInfo *, char *, int);