projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added optional button to restart game (door, panel and touch variants)
[rocksndiamonds.git]
/
src
/
libgame
/
misc.c
diff --git
a/src/libgame/misc.c
b/src/libgame/misc.c
index 02358aa292a3803890ca42b4526f679af0884cce..536d90b53816d3b4ab11e26f28ed0f54edd9842e 100644
(file)
--- a/
src/libgame/misc.c
+++ b/
src/libgame/misc.c
@@
-1088,7
+1088,9
@@
char *getBasePath(char *filename)
// various string functions
// ----------------------------------------------------------------------------
// various string functions
// ----------------------------------------------------------------------------
-char *getStringCat2WithSeparator(char *s1, char *s2, char *sep)
+char *getStringCat2WithSeparator(const char *s1,
+ const char *s2,
+ const char *sep)
{
if (s1 == NULL || s2 == NULL || sep == NULL)
return NULL;
{
if (s1 == NULL || s2 == NULL || sep == NULL)
return NULL;
@@
-1101,7
+1103,10
@@
char *getStringCat2WithSeparator(char *s1, char *s2, char *sep)
return complete_string;
}
return complete_string;
}
-char *getStringCat3WithSeparator(char *s1, char *s2, char *s3, char *sep)
+char *getStringCat3WithSeparator(const char *s1,
+ const char *s2,
+ const char *s3,
+ const char *sep)
{
if (s1 == NULL || s2 == NULL || s3 == NULL || sep == NULL)
return NULL;
{
if (s1 == NULL || s2 == NULL || s3 == NULL || sep == NULL)
return NULL;
@@
-1115,17
+1120,17
@@
char *getStringCat3WithSeparator(char *s1, char *s2, char *s3, char *sep)
return complete_string;
}
return complete_string;
}
-char *getStringCat2(c
har *s1,
char *s2)
+char *getStringCat2(c
onst char *s1, const
char *s2)
{
return getStringCat2WithSeparator(s1, s2, "");
}
{
return getStringCat2WithSeparator(s1, s2, "");
}
-char *getStringCat3(c
har *s1, char *s2,
char *s3)
+char *getStringCat3(c
onst char *s1, const char *s2, const
char *s3)
{
return getStringCat3WithSeparator(s1, s2, s3, "");
}
{
return getStringCat3WithSeparator(s1, s2, s3, "");
}
-char *getPath2(c
har *path1,
char *path2)
+char *getPath2(c
onst char *path1, const
char *path2)
{
#if defined(PLATFORM_ANDROID)
// workaround for reading from assets directory -- skip "." subdirs in path
{
#if defined(PLATFORM_ANDROID)
// workaround for reading from assets directory -- skip "." subdirs in path
@@
-1138,7
+1143,7
@@
char *getPath2(char *path1, char *path2)
return getStringCat2WithSeparator(path1, path2, STRING_PATH_SEPARATOR);
}
return getStringCat2WithSeparator(path1, path2, STRING_PATH_SEPARATOR);
}
-char *getPath3(c
har *path1, char *path2,
char *path3)
+char *getPath3(c
onst char *path1, const char *path2, const
char *path3)
{
#if defined(PLATFORM_ANDROID)
// workaround for reading from assets directory -- skip "." subdirs in path
{
#if defined(PLATFORM_ANDROID)
// workaround for reading from assets directory -- skip "." subdirs in path
@@
-1166,12
+1171,12
@@
static char *getPngOrPcxIfNotExists(char *filename)
return filename;
}
return filename;
}
-char *getImg2(c
har *path1,
char *path2)
+char *getImg2(c
onst char *path1, const
char *path2)
{
return getPngOrPcxIfNotExists(getPath2(path1, path2));
}
{
return getPngOrPcxIfNotExists(getPath2(path1, path2));
}
-char *getImg3(c
har *path1, char *path2,
char *path3)
+char *getImg3(c
onst char *path1, const char *path2, const
char *path3)
{
return getPngOrPcxIfNotExists(getPath3(path1, path2, path3));
}
{
return getPngOrPcxIfNotExists(getPath3(path1, path2, path3));
}
@@
-1227,14
+1232,14
@@
char *getStringToLower(const char *s)
return s_copy;
}
return s_copy;
}
-void setString(char **old_value, char *new_value)
+void setString(char **old_value, c
onst c
har *new_value)
{
checked_free(*old_value);
*old_value = getStringCopy(new_value);
}
{
checked_free(*old_value);
*old_value = getStringCopy(new_value);
}
-boolean strEqual(c
har *s1,
char *s2)
+boolean strEqual(c
onst char *s1, const
char *s2)
{
return (s1 == NULL && s2 == NULL ? TRUE :
s1 == NULL && s2 != NULL ? FALSE :
{
return (s1 == NULL && s2 == NULL ? TRUE :
s1 == NULL && s2 != NULL ? FALSE :
@@
-1242,7
+1247,7
@@
boolean strEqual(char *s1, char *s2)
strcmp(s1, s2) == 0);
}
strcmp(s1, s2) == 0);
}
-boolean strEqualN(c
har *s1,
char *s2, int n)
+boolean strEqualN(c
onst char *s1, const
char *s2, int n)
{
return (s1 == NULL && s2 == NULL ? TRUE :
s1 == NULL && s2 != NULL ? FALSE :
{
return (s1 == NULL && s2 == NULL ? TRUE :
s1 == NULL && s2 != NULL ? FALSE :
@@
-1250,7
+1255,7
@@
boolean strEqualN(char *s1, char *s2, int n)
strncmp(s1, s2, n) == 0);
}
strncmp(s1, s2, n) == 0);
}
-boolean strEqualCase(c
har *s1,
char *s2)
+boolean strEqualCase(c
onst char *s1, const
char *s2)
{
return (s1 == NULL && s2 == NULL ? TRUE :
s1 == NULL && s2 != NULL ? FALSE :
{
return (s1 == NULL && s2 == NULL ? TRUE :
s1 == NULL && s2 != NULL ? FALSE :
@@
-1258,7
+1263,7
@@
boolean strEqualCase(char *s1, char *s2)
strcasecmp(s1, s2) == 0);
}
strcasecmp(s1, s2) == 0);
}
-boolean strEqualCaseN(c
har *s1,
char *s2, int n)
+boolean strEqualCaseN(c
onst char *s1, const
char *s2, int n)
{
return (s1 == NULL && s2 == NULL ? TRUE :
s1 == NULL && s2 != NULL ? FALSE :
{
return (s1 == NULL && s2 == NULL ? TRUE :
s1 == NULL && s2 != NULL ? FALSE :
@@
-1266,7
+1271,7
@@
boolean strEqualCaseN(char *s1, char *s2, int n)
strncasecmp(s1, s2, n) == 0);
}
strncasecmp(s1, s2, n) == 0);
}
-boolean strPrefix(c
har *s,
char *prefix)
+boolean strPrefix(c
onst char *s, const
char *prefix)
{
return (s == NULL && prefix == NULL ? TRUE :
s == NULL && prefix != NULL ? FALSE :
{
return (s == NULL && prefix == NULL ? TRUE :
s == NULL && prefix != NULL ? FALSE :
@@
-1274,7
+1279,7
@@
boolean strPrefix(char *s, char *prefix)
strncmp(s, prefix, strlen(prefix)) == 0);
}
strncmp(s, prefix, strlen(prefix)) == 0);
}
-boolean strSuffix(c
har *s,
char *suffix)
+boolean strSuffix(c
onst char *s, const
char *suffix)
{
return (s == NULL && suffix == NULL ? TRUE :
s == NULL && suffix != NULL ? FALSE :
{
return (s == NULL && suffix == NULL ? TRUE :
s == NULL && suffix != NULL ? FALSE :
@@
-1283,7
+1288,7
@@
boolean strSuffix(char *s, char *suffix)
strcmp(&s[strlen(s) - strlen(suffix)], suffix) == 0);
}
strcmp(&s[strlen(s) - strlen(suffix)], suffix) == 0);
}
-boolean strPrefixLower(c
har *s,
char *prefix)
+boolean strPrefixLower(c
onst char *s, const
char *prefix)
{
char *s_lower = getStringToLower(s);
boolean match = strPrefix(s_lower, prefix);
{
char *s_lower = getStringToLower(s);
boolean match = strPrefix(s_lower, prefix);
@@
-1293,7
+1298,7
@@
boolean strPrefixLower(char *s, char *prefix)
return match;
}
return match;
}
-boolean strSuffixLower(c
har *s,
char *suffix)
+boolean strSuffixLower(c
onst char *s, const
char *suffix)
{
char *s_lower = getStringToLower(s);
boolean match = strSuffix(s_lower, suffix);
{
char *s_lower = getStringToLower(s);
boolean match = strSuffix(s_lower, suffix);
@@
-1303,7
+1308,7
@@
boolean strSuffixLower(char *s, char *suffix)
return match;
}
return match;
}
-boolean isURL(char *s)
+boolean isURL(c
onst c
har *s)
{
while (*s && *s >= 'a' && *s <= 'z')
s++;
{
while (*s && *s >= 'a' && *s <= 'z')
s++;
@@
-3072,7
+3077,7
@@
void freeDirectoryEntry(DirectoryEntry *dir_entry)
// functions for checking files and filenames
// ----------------------------------------------------------------------------
// functions for checking files and filenames
// ----------------------------------------------------------------------------
-boolean directoryExists(char *dir_name)
+boolean directoryExists(c
onst c
har *dir_name)
{
if (dir_name == NULL)
return FALSE;
{
if (dir_name == NULL)
return FALSE;
@@
-3100,7
+3105,7
@@
boolean directoryExists(char *dir_name)
return success;
}
return success;
}
-boolean fileExists(char *filename)
+boolean fileExists(c
onst c
har *filename)
{
if (filename == NULL)
return FALSE;
{
if (filename == NULL)
return FALSE;
@@
-3124,7
+3129,7
@@
boolean fileExists(char *filename)
}
#if 0
}
#if 0
-static boolean fileHasPrefix(c
har *basename,
char *prefix)
+static boolean fileHasPrefix(c
onst char *basename, const
char *prefix)
{
static char *basename_lower = NULL;
int basename_length, prefix_length;
{
static char *basename_lower = NULL;
int basename_length, prefix_length;
@@
-3147,7
+3152,7
@@
static boolean fileHasPrefix(char *basename, char *prefix)
}
#endif
}
#endif
-static boolean fileHasSuffix(c
har *basename,
char *suffix)
+static boolean fileHasSuffix(c
onst char *basename, const
char *suffix)
{
static char *basename_lower = NULL;
int basename_length, suffix_length;
{
static char *basename_lower = NULL;
int basename_length, suffix_length;