projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20140515-1-src
[rocksndiamonds.git]
/
src
/
libgame
/
misc.c
diff --git
a/src/libgame/misc.c
b/src/libgame/misc.c
index ae4b5d78e797c470863e88e09313172700eeca0d..7c2f4353851cb803d8dc8bd43fd1474e65711df8 100644
(file)
--- a/
src/libgame/misc.c
+++ b/
src/libgame/misc.c
@@
-223,18
+223,6
@@
boolean getTokenValueFromString(char *string, char **token, char **value)
/* counter functions */
/* ------------------------------------------------------------------------- */
/* counter functions */
/* ------------------------------------------------------------------------- */
-#if defined(PLATFORM_MSDOS)
-volatile unsigned int counter = 0;
-
-void increment_counter()
-{
- counter++;
-}
-
-END_OF_FUNCTION(increment_counter);
-#endif
-
-
/* maximal allowed length of a command line option */
#define MAX_OPTION_LEN 256
/* maximal allowed length of a command line option */
#define MAX_OPTION_LEN 256
@@
-323,22
+311,12
@@
static unsigned int mainCounter(int mode)
void InitCounter() /* set counter back to zero */
{
void InitCounter() /* set counter back to zero */
{
-#if !defined(PLATFORM_MSDOS)
mainCounter(INIT_COUNTER);
mainCounter(INIT_COUNTER);
-#else
- LOCK_VARIABLE(counter);
- LOCK_FUNCTION(increment_counter);
- install_int_ex(increment_counter, BPS_TO_TIMER(100));
-#endif
}
unsigned int Counter() /* get milliseconds since last call of InitCounter() */
{
}
unsigned int Counter() /* get milliseconds since last call of InitCounter() */
{
-#if !defined(PLATFORM_MSDOS)
return mainCounter(READ_COUNTER);
return mainCounter(READ_COUNTER);
-#else
- return (counter * 10);
-#endif
}
static void sleep_milliseconds(unsigned int milliseconds_delay)
}
static void sleep_milliseconds(unsigned int milliseconds_delay)
@@
-474,7
+452,7
@@
unsigned int get_random_number(int nr, int max)
/* system info functions */
/* ------------------------------------------------------------------------- */
/* system info functions */
/* ------------------------------------------------------------------------- */
-#if !defined(PLATFORM_
MSDOS) && !defined(PLATFORM_
ANDROID)
+#if !defined(PLATFORM_ANDROID)
static char *get_corrected_real_name(char *real_name)
{
char *real_name_new = checked_malloc(MAX_USERNAME_LEN + 1);
static char *get_corrected_real_name(char *real_name)
{
char *real_name_new = checked_malloc(MAX_USERNAME_LEN + 1);
@@
-708,7
+686,7
@@
char *getPath3(char *path1, char *path2, char *path3)
return getStringCat3WithSeparator(path1, path2, path3, STRING_PATH_SEPARATOR);
}
return getStringCat3WithSeparator(path1, path2, path3, STRING_PATH_SEPARATOR);
}
-char *getStringCopy(char *s)
+char *getStringCopy(c
onst c
har *s)
{
char *s_copy;
{
char *s_copy;
@@
-721,7
+699,7
@@
char *getStringCopy(char *s)
return s_copy;
}
return s_copy;
}
-char *getStringCopyN(char *s, int n)
+char *getStringCopyN(c
onst c
har *s, int n)
{
char *s_copy;
int s_len = MAX(0, n);
{
char *s_copy;
int s_len = MAX(0, n);
@@
-736,7
+714,18
@@
char *getStringCopyN(char *s, int n)
return s_copy;
}
return s_copy;
}
-char *getStringToLower(char *s)
+char *getStringCopyNStatic(const char *s, int n)
+{
+ static char *s_copy = NULL;
+
+ checked_free(s_copy);
+
+ s_copy = getStringCopyN(s, n);
+
+ return s_copy;
+}
+
+char *getStringToLower(const char *s)
{
char *s_copy = checked_malloc(strlen(s) + 1);
char *s_ptr = s_copy;
{
char *s_copy = checked_malloc(strlen(s) + 1);
char *s_ptr = s_copy;
@@
-1057,15
+1046,17
@@
void GetOptions(char *argv[], void (*print_usage_function)(void))
/* error handling functions */
/* ------------------------------------------------------------------------- */
/* error handling functions */
/* ------------------------------------------------------------------------- */
+#define MAX_INTERNAL_ERROR_SIZE 1024
+
/* used by SetError() and GetError() to store internal error messages */
/* used by SetError() and GetError() to store internal error messages */
-static char internal_error[
1024]; /* this is bad */
+static char internal_error[
MAX_INTERNAL_ERROR_SIZE];
void SetError(char *format, ...)
{
va_list ap;
va_start(ap, format);
void SetError(char *format, ...)
{
va_list ap;
va_start(ap, format);
- vs
printf(internal_error
, format, ap);
+ vs
nprintf(internal_error, MAX_INTERNAL_ERROR_SIZE
, format, ap);
va_end(ap);
}
va_end(ap);
}