return (unsigned int) seed;
}
+#if 1
unsigned int get_random_number(int nr, unsigned int max)
{
return (max > 0 ? random_linux_libc(nr) % max : 0);
}
+#else
+unsigned int get_random_number(int nr, unsigned int max)
+{
+ unsigned int rnd = (max > 0 ? random_linux_libc(nr) % max : 0);
+
+ if (nr == 0 && FrameCounter < 2)
+ printf("::: %d [%d]\n", rnd, FrameCounter);
+
+#if 0
+ if (nr == 0 && FrameCounter < 2 && rnd == 8)
+ rnd /= 0;
+#endif
+
+ return rnd;
+}
+#endif
/* ------------------------------------------------------------------------- */
int getFileVersion(FILE *file)
{
- int version_major, version_minor, version_patch, version_release;
-
- version_major = fgetc(file);
- version_minor = fgetc(file);
- version_patch = fgetc(file);
- version_release = fgetc(file);
+ int version_major = fgetc(file);
+ int version_minor = fgetc(file);
+ int version_patch = fgetc(file);
+ int version_build = fgetc(file);
- return RELEASE_IDENT(version_major, version_minor, version_patch,
- version_release);
+ return VERSION_IDENT(version_major, version_minor, version_patch,
+ version_build);
}
void putFileVersion(FILE *file, int version)
{
- int version_major = VERSION_MAJOR(version);
- int version_minor = VERSION_MINOR(version);
- int version_patch = VERSION_PATCH(version);
- int version_release = VERSION_RELEASE(version);
+ int version_major = VERSION_MAJOR(version);
+ int version_minor = VERSION_MINOR(version);
+ int version_patch = VERSION_PATCH(version);
+ int version_build = VERSION_BUILD(version);
- fputc(version_major, file);
- fputc(version_minor, file);
- fputc(version_patch, file);
- fputc(version_release, file);
+ fputc(version_major, file);
+ fputc(version_minor, file);
+ fputc(version_patch, file);
+ fputc(version_build, file);
}
void ReadUnusedBytesFromFile(FILE *file, unsigned long bytes)
{
static char *number_text[][3] =
{
- { "0", "zero", "null", },
- { "1", "one", "first" },
- { "2", "two", "second" },
- { "3", "three", "third" },
- { "4", "four", "fourth" },
- { "5", "five", "fifth" },
- { "6", "six", "sixth" },
- { "7", "seven", "seventh" },
- { "8", "eight", "eighth" },
- { "9", "nine", "ninth" },
- { "10", "ten", "tenth" },
- { "11", "eleven", "eleventh" },
- { "12", "twelve", "twelfth" },
+ { "0", "zero", "null", },
+ { "1", "one", "first" },
+ { "2", "two", "second" },
+ { "3", "three", "third" },
+ { "4", "four", "fourth" },
+ { "5", "five", "fifth" },
+ { "6", "six", "sixth" },
+ { "7", "seven", "seventh" },
+ { "8", "eight", "eighth" },
+ { "9", "nine", "ninth" },
+ { "10", "ten", "tenth" },
+ { "11", "eleven", "eleventh" },
+ { "12", "twelve", "twelfth" },
+
+ { NULL, NULL, NULL },
};
int i, j;
char *s_lower = getStringToLower(s);
int result = -1;
- for (i=0; i<13; i++)
- for (j=0; j<3; j++)
+ for (i=0; number_text[i][0] != NULL; i++)
+ for (j=0; j < 3; j++)
if (strcmp(s_lower, number_text[i][j]) == 0)
result = i;
if (result == -1)
- result = atoi(s);
+ {
+ if (strcmp(s_lower, "false") == 0)
+ result = 0;
+ else if (strcmp(s_lower, "true") == 0)
+ result = 1;
+ else
+ result = atoi(s);
+ }
free(s_lower);
return string_has_parameter(substring, s_contained);
}
-int get_parameter_value(char *token, char *value_raw, int type)
+int get_parameter_value(char *suffix, char *value_raw, int type)
{
char *value = getStringToLower(value_raw);
int result = 0; /* probably a save default value */
- if (strcmp(token, ".direction") == 0)
+ if (strcmp(suffix, ".direction") == 0)
{
result = (strcmp(value, "left") == 0 ? MV_LEFT :
strcmp(value, "right") == 0 ? MV_RIGHT :
strcmp(value, "up") == 0 ? MV_UP :
strcmp(value, "down") == 0 ? MV_DOWN : MV_NO_MOVING);
}
- else if (strcmp(token, ".anim_mode") == 0)
- {
- result = (string_has_parameter(value, "loop") ? ANIM_LOOP :
- string_has_parameter(value, "linear") ? ANIM_LINEAR :
- string_has_parameter(value, "pingpong") ? ANIM_PINGPONG :
- string_has_parameter(value, "pingpong2") ? ANIM_PINGPONG2 :
- string_has_parameter(value, "random") ? ANIM_RANDOM :
- string_has_parameter(value, "none") ? ANIM_NONE :
- ANIM_LOOP);
+ else if (strcmp(suffix, ".anim_mode") == 0)
+ {
+ result = (string_has_parameter(value, "none") ? ANIM_NONE :
+ string_has_parameter(value, "loop") ? ANIM_LOOP :
+ string_has_parameter(value, "linear") ? ANIM_LINEAR :
+ string_has_parameter(value, "pingpong") ? ANIM_PINGPONG :
+ string_has_parameter(value, "pingpong2") ? ANIM_PINGPONG2 :
+ string_has_parameter(value, "random") ? ANIM_RANDOM :
+ string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL :
+ string_has_parameter(value, "vertical") ? ANIM_VERTICAL :
+ ANIM_DEFAULT);
if (string_has_parameter(value, "reverse"))
result |= ANIM_REVERSE;
return result;
}
+int get_auto_parameter_value(char *token, char *value_raw)
+{
+ char *suffix;
+
+ if (token == NULL || value_raw == NULL)
+ return ARG_UNDEFINED_VALUE;
+
+ suffix = strrchr(token, '.');
+ if (suffix == NULL)
+ suffix = token;
+
+ return get_parameter_value(suffix, value_raw, TYPE_INTEGER);
+}
+
static void FreeCustomArtworkList(struct ArtworkListInfo *,
struct ListNodeInfo ***, int *);
/* ---------- step 0: search for matching base prefix ---------- */
start_pos = 0;
- for (i=0; i<num_base_prefixes && !base_prefix_found; i++)
+ for (i=0; i < num_base_prefixes && !base_prefix_found; i++)
{
char *base_prefix = base_prefixes[i];
int len_base_prefix = strlen(base_prefix);
/* ---------- step 1: search for matching first suffix ---------- */
start_pos += len_base_prefix;
- for (j=0; j<num_ext1_suffixes && !ext1_suffix_found; j++)
+ for (j=0; j < num_ext1_suffixes && !ext1_suffix_found; j++)
{
char *ext1_suffix = ext1_suffixes[j];
int len_ext1_suffix = strlen(ext1_suffix);
/* ---------- step 2: search for matching second suffix ---------- */
- for (k=0; k<num_ext2_suffixes && !ext2_suffix_found; k++)
+ for (k=0; k < num_ext2_suffixes && !ext2_suffix_found; k++)
{
char *ext2_suffix = ext2_suffixes[k];
int len_ext2_suffix = strlen(ext2_suffix);
- ext2_suffix_found = token_suffix_match(token, ext2_suffix,start_pos);
+ ext2_suffix_found = token_suffix_match(token, ext2_suffix, start_pos);
if (!ext2_suffix_found)
continue;
/* ---------- step 3: search for matching third suffix ---------- */
- for (l=0; l<num_ext3_suffixes && !ext3_suffix_found; l++)
+ for (l=0; l < num_ext3_suffixes && !ext3_suffix_found; l++)
{
char *ext3_suffix = ext3_suffixes[l];
int len_ext3_suffix = strlen(ext3_suffix);
- ext3_suffix_found =token_suffix_match(token,ext3_suffix,start_pos);
+ ext3_suffix_found = token_suffix_match(token, ext3_suffix, start_pos);
if (!ext3_suffix_found)
continue;
printf("GOT CUSTOM ARTWORK CONFIG FILE '%s'\n", filename);
#endif
+ DrawInitText("Loading artwork config:", 120, FC_GREEN);
+ DrawInitText(ARTWORKINFO_FILENAME(artwork_info->type), 150, FC_YELLOW);
+
/* always start with reliable default values */
for (i=0; i<num_file_list_entries; i++)
{