projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20070123-1-src
[rocksndiamonds.git]
/
src
/
libgame
/
misc.c
diff --git
a/src/libgame/misc.c
b/src/libgame/misc.c
index f9ec87fe5b15cf9c1206f7f6b83bade9c302e0df..f01ce132a3155b7e7349e110415ceb26145855f5 100644
(file)
--- a/
src/libgame/misc.c
+++ b/
src/libgame/misc.c
@@
-498,36
+498,45
@@
char *getBasePath(char *filename)
/* various string functions */
/* ------------------------------------------------------------------------- */
/* various string functions */
/* ------------------------------------------------------------------------- */
-char *get
Path2(char *path1, char *path2
)
+char *get
StringCat2WithSeparator(char *s1, char *s2, char *sep
)
{
{
- char *sep = STRING_PATH_SEPARATOR;
- char *complete_path = checked_malloc(strlen(path1) + 1 +
- strlen(path2) + 1);
+ char *complete_string = checked_malloc(strlen(s1) + strlen(sep) +
+ strlen(s2) + 1);
- sprintf(complete_
path, "%s%s%s", path1, sep, path
2);
+ sprintf(complete_
string, "%s%s%s", s1, sep, s
2);
- return complete_
path
;
+ return complete_
string
;
}
}
-char *get
Path3(char *path1, char *path2, char *path3
)
+char *get
StringCat3WithSeparator(char *s1, char *s2, char *s3, char *sep
)
{
{
- char *sep = STRING_PATH_SEPARATOR;
- char *complete_path = checked_malloc(strlen(path1) + 1 +
- strlen(path2) + 1 +
- strlen(path3) + 1);
+ char *complete_string = checked_malloc(strlen(s1) + strlen(sep) +
+ strlen(s2) + strlen(sep) +
+ strlen(s3) + 1);
- sprintf(complete_
path, "%s%s%s%s%s", path1, sep, path2, sep, path
3);
+ sprintf(complete_
string, "%s%s%s%s%s", s1, sep, s2, sep, s
3);
- return complete_
path
;
+ return complete_
string
;
}
char *getStringCat2(char *s1, char *s2)
{
}
char *getStringCat2(char *s1, char *s2)
{
- char *complete_string = checked_malloc(strlen(s1) + strlen(s2) + 1);
+ return getStringCat2WithSeparator(s1, s2, "");
+}
+
+char *getStringCat3(char *s1, char *s2, char *s3)
+{
+ return getStringCat3WithSeparator(s1, s2, s3, "");
+}
- sprintf(complete_string, "%s%s", s1, s2);
+char *getPath2(char *path1, char *path2)
+{
+ return getStringCat2WithSeparator(path1, path2, STRING_PATH_SEPARATOR);
+}
- return complete_string;
+char *getPath3(char *path1, char *path2, char *path3)
+{
+ return getStringCat3WithSeparator(path1, path2, path3, STRING_PATH_SEPARATOR);
}
char *getStringCopy(char *s)
}
char *getStringCopy(char *s)
@@
-1544,7
+1553,7
@@
void deleteNodeFromList(ListNode **node_first, char *key,
if (strEqual((*node_first)->key, key))
{
if (strEqual((*node_first)->key, key))
{
- free((*node_first)->key);
+
checked_
free((*node_first)->key);
if (destructor_function)
destructor_function((*node_first)->content);
*node_first = (*node_first)->next;
if (destructor_function)
destructor_function((*node_first)->content);
*node_first = (*node_first)->next;
@@
-1761,6
+1770,12
@@
int get_parameter_value(char *value_raw, char *suffix, int type)
strEqual(value, "up") ? MV_UP :
strEqual(value, "down") ? MV_DOWN : MV_NONE);
}
strEqual(value, "up") ? MV_UP :
strEqual(value, "down") ? MV_DOWN : MV_NONE);
}
+ else if (strEqual(suffix, ".align"))
+ {
+ result = (strEqual(value, "left") ? ALIGN_LEFT :
+ strEqual(value, "right") ? ALIGN_RIGHT :
+ strEqual(value, "center") ? ALIGN_CENTER : ALIGN_DEFAULT);
+ }
else if (strEqual(suffix, ".anim_mode"))
{
result = (string_has_parameter(value, "none") ? ANIM_NONE :
else if (strEqual(suffix, ".anim_mode"))
{
result = (string_has_parameter(value, "none") ? ANIM_NONE :
@@
-1774,6
+1789,9
@@
int get_parameter_value(char *value_raw, char *suffix, int type)
string_has_parameter(value, "ce_delay") ? ANIM_CE_DELAY :
string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL :
string_has_parameter(value, "vertical") ? ANIM_VERTICAL :
string_has_parameter(value, "ce_delay") ? ANIM_CE_DELAY :
string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL :
string_has_parameter(value, "vertical") ? ANIM_VERTICAL :
+ string_has_parameter(value, "centered") ? ANIM_CENTERED :
+ string_has_parameter(value, "fade") ? ANIM_FADE :
+ string_has_parameter(value, "crossfade") ? ANIM_CROSSFADE :
ANIM_DEFAULT);
if (string_has_parameter(value, "reverse"))
ANIM_DEFAULT);
if (string_has_parameter(value, "reverse"))
@@
-1947,6
+1965,10
@@
struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list,
file_list[list_pos].token = config_list[i].token;
file_list[list_pos].default_filename = config_list[i].value;
file_list[list_pos].token = config_list[i].token;
file_list[list_pos].default_filename = config_list[i].value;
+
+#if 0
+ printf("::: '%s' => '%s'\n", config_list[i].token, config_list[i].value);
+#endif
}
}
}
}
@@
-1955,13
+1977,17
@@
struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list,
{
Error(ERR_RETURN_LINE, "-");
Error(ERR_RETURN, "inconsistant config list information:");
{
Error(ERR_RETURN_LINE, "-");
Error(ERR_RETURN, "inconsistant config list information:");
- Error(ERR_RETURN, "- should be: %d (according to 'src/conf_
gf
x.h')",
+ Error(ERR_RETURN, "- should be: %d (according to 'src/conf_
xx
x.h')",
num_file_list_entries);
num_file_list_entries);
- Error(ERR_RETURN, "- found to be: %d (according to 'src/conf_
gf
x.c')",
+ Error(ERR_RETURN, "- found to be: %d (according to 'src/conf_
xx
x.c')",
num_file_list_entries_found);
Error(ERR_EXIT, "please fix");
}
num_file_list_entries_found);
Error(ERR_EXIT, "please fix");
}
+#if 0
+ printf("::: ---------- DONE ----------\n");
+#endif
+
return file_list;
}
return file_list;
}
@@
-2472,7
+2498,7
@@
void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
char *filename_base = UNDEFINED_FILENAME, *filename_local;
int i, j;
char *filename_base = UNDEFINED_FILENAME, *filename_local;
int i, j;
- DrawInitText("Loading artwork config
:
", 120, FC_GREEN);
+ DrawInitText("Loading artwork config", 120, FC_GREEN);
DrawInitText(ARTWORKINFO_FILENAME(artwork_info->type), 150, FC_YELLOW);
/* always start with reliable default values */
DrawInitText(ARTWORKINFO_FILENAME(artwork_info->type), 150, FC_YELLOW);
/* always start with reliable default values */
@@
-2549,9
+2575,9
@@
static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info,
{
char *init_text[] =
{
{
char *init_text[] =
{
- "Loading graphics
:
",
- "Loading sounds
:
",
- "Loading music
:
"
+ "Loading graphics",
+ "Loading sounds",
+ "Loading music"
};
ListNode *node;
};
ListNode *node;
@@
-2769,6
+2795,8
@@
void NotifyUserAboutErrorFile()
/* the following is only for debugging purpose and normally not used */
/* ------------------------------------------------------------------------- */
/* the following is only for debugging purpose and normally not used */
/* ------------------------------------------------------------------------- */
+#if DEBUG
+
#define DEBUG_NUM_TIMESTAMPS 3
void debug_print_timestamp(int counter_nr, char *message)
#define DEBUG_NUM_TIMESTAMPS 3
void debug_print_timestamp(int counter_nr, char *message)
@@
-2781,10
+2809,10
@@
void debug_print_timestamp(int counter_nr, char *message)
counter[counter_nr][0] = Counter();
if (message)
counter[counter_nr][0] = Counter();
if (message)
- printf("%s %.
2
f seconds\n", message,
+ printf("%s %.
3
f seconds\n", message,
(float)(counter[counter_nr][0] - counter[counter_nr][1]) / 1000);
(float)(counter[counter_nr][0] - counter[counter_nr][1]) / 1000);
- counter[counter_nr][1] =
Counter()
;
+ counter[counter_nr][1] =
counter[counter_nr][0]
;
}
void debug_print_parent_only(char *format, ...)
}
void debug_print_parent_only(char *format, ...)
@@
-2803,3
+2831,4
@@
void debug_print_parent_only(char *format, ...)
printf("\n");
}
}
printf("\n");
}
}
+#endif