projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added delay counter data type and adjusted related functions
[rocksndiamonds.git]
/
src
/
libgame
/
misc.c
diff --git
a/src/libgame/misc.c
b/src/libgame/misc.c
index 54e5bfd16b4822d7f682f3755aa6aac8e4952a66..7c3e04fca21eaa297b0a5398bfb98b1c604c2618 100644
(file)
--- a/
src/libgame/misc.c
+++ b/
src/libgame/misc.c
@@
-641,8
+641,8
@@
void Delay(unsigned int delay) // Sleep specified number of milliseconds
sleep_milliseconds(delay);
}
sleep_milliseconds(delay);
}
-boolean DelayReachedExt(unsigned int *counter_var, unsigned int delay,
- unsigned int actual_counter)
+boolean DelayReachedExt
2
(unsigned int *counter_var, unsigned int delay,
+
unsigned int actual_counter)
{
if (actual_counter >= *counter_var &&
actual_counter < *counter_var + delay)
{
if (actual_counter >= *counter_var &&
actual_counter < *counter_var + delay)
@@
-653,34
+653,40
@@
boolean DelayReachedExt(unsigned int *counter_var, unsigned int delay,
return TRUE;
}
return TRUE;
}
-boolean
FrameReached(unsigned int *frame_counter_var, unsigned int frame_delay
)
+boolean
DelayReachedExt(DelayCounter *counter, unsigned int actual_counter
)
{
{
- return DelayReachedExt
(frame_counter_var, frame_delay, FrameC
ounter);
+ return DelayReachedExt
2(&counter->count, counter->value, actual_c
ounter);
}
}
-boolean
DelayReached(unsigned int *counter_var, unsigned int delay
)
+boolean
FrameReached(DelayCounter *counter
)
{
{
- return DelayReachedExt(counter
_var, delay, Counter()
);
+ return DelayReachedExt(counter
, FrameCounter
);
}
}
-void ResetDelayCounterExt(unsigned int *counter_var,
- unsigned int actual_counter)
+boolean DelayReached(DelayCounter *counter)
{
{
-
DelayReachedExt(counter_var, 0, actual_counter
);
+
return DelayReachedExt(counter, Counter()
);
}
}
-void Reset
FrameCounter(unsigned int *frame_counter_va
r)
+void Reset
DelayCounterExt(DelayCounter *counter, unsigned int actual_counte
r)
{
{
-
FrameReached(frame_counter_var, 0
);
+
DelayReachedExt2(&counter->count, 0, actual_counter
);
}
}
-void Reset
DelayCounter(unsigned int *counter_va
r)
+void Reset
FrameCounter(DelayCounter *counte
r)
{
{
-
DelayReached(counter_var, 0
);
+
ResetDelayCounterExt(counter, FrameCounter
);
}
}
-
int WaitUntilDelayReached(unsigned int *counter_var, unsigned int delay
)
+
void ResetDelayCounter(DelayCounter *counter
)
{
{
+ ResetDelayCounterExt(counter, Counter());
+}
+
+int WaitUntilDelayReached(DelayCounter *counter)
+{
+ unsigned int *counter_var = &counter->count;
+ unsigned int delay = counter->value;
unsigned int actual_counter;
int skip_frames = 0;
unsigned int actual_counter;
int skip_frames = 0;
@@
-711,22
+717,22
@@
int WaitUntilDelayReached(unsigned int *counter_var, unsigned int delay)
return skip_frames;
}
return skip_frames;
}
-void SkipUntilDelayReached(
unsigned int *counter_var, unsigned int delay
,
+void SkipUntilDelayReached(
DelayCounter *counter
,
int *loop_var, int last_loop_value)
{
int *loop_var, int last_loop_value)
{
- int skip_frames = WaitUntilDelayReached(counter
_var, delay
);
+ int skip_frames = WaitUntilDelayReached(counter);
#if 0
#if DEBUG
if (skip_frames)
Debug("internal:SkipUntilDelayReached",
"%d: %d ms -> SKIP %d FRAME(S) [%d ms]",
#if 0
#if DEBUG
if (skip_frames)
Debug("internal:SkipUntilDelayReached",
"%d: %d ms -> SKIP %d FRAME(S) [%d ms]",
- *loop_var,
delay
,
- skip_frames, skip_frames *
delay
);
+ *loop_var,
counter->value
,
+ skip_frames, skip_frames *
counter->value
);
else
Debug("internal:SkipUntilDelayReached",
"%d: %d ms",
else
Debug("internal:SkipUntilDelayReached",
"%d: %d ms",
- *loop_var,
delay
);
+ *loop_var,
counter->value
);
#endif
#endif
#endif
#endif
@@
-763,7
+769,7
@@
static unsigned int init_random_number_ext(int nr, int seed)
// default random seed
seed = (int)time(NULL); // seconds since the epoch
// default random seed
seed = (int)time(NULL); // seconds since the epoch
-#if !defined(PLATFORM_WIN
32
)
+#if !defined(PLATFORM_WIN
DOWS
)
// add some more randomness
struct timeval current_time;
// add some more randomness
struct timeval current_time;
@@
-896,7
+902,7
@@
char *getLoginName(void)
{
static char *login_name = NULL;
{
static char *login_name = NULL;
-#if defined(PLATFORM_WIN
32
)
+#if defined(PLATFORM_WIN
DOWS
)
if (login_name == NULL)
{
unsigned long buffer_size = MAX_USERNAME_LEN + 1;
if (login_name == NULL)
{
unsigned long buffer_size = MAX_USERNAME_LEN + 1;
@@
-927,7
+933,7
@@
char *getRealName(void)
{
static char *real_name = NULL;
{
static char *real_name = NULL;
-#if defined(PLATFORM_WIN
32
)
+#if defined(PLATFORM_WIN
DOWS
)
if (real_name == NULL)
{
static char buffer[MAX_USERNAME_LEN + 1];
if (real_name == NULL)
{
static char buffer[MAX_USERNAME_LEN + 1];
@@
-1543,7
+1549,7
@@
void GetOptions(int argc, char *argv[],
if (option_arg == next_option)
options_left++;
}
if (option_arg == next_option)
options_left++;
}
-#if defined(PLATFORM_MAC
OSX
)
+#if defined(PLATFORM_MAC)
else if (strPrefix(option, "-psn"))
{
// ignore process serial number when launched via GUI on Mac OS X
else if (strPrefix(option, "-psn"))
{
// ignore process serial number when launched via GUI on Mac OS X
@@
-1617,7
+1623,7
@@
void checked_free(void *ptr)
void clear_mem(void *ptr, unsigned int size)
{
void clear_mem(void *ptr, unsigned int size)
{
-#if defined(PLATFORM_WIN
32
)
+#if defined(PLATFORM_WIN
DOWS
)
// for unknown reason, memset() sometimes crashes when compiled with MinGW
char *cptr = (char *)ptr;
// for unknown reason, memset() sometimes crashes when compiled with MinGW
char *cptr = (char *)ptr;
@@
-4201,7
+4207,7
@@
void DumpLogFile(int nr)
void NotifyUserAboutErrorFile(void)
{
void NotifyUserAboutErrorFile(void)
{
-#if defined(PLATFORM_WIN
32
)
+#if defined(PLATFORM_WIN
DOWS
)
char *title_text = getStringCat2(program.program_title, " Error Message");
char *error_text = getStringCat2("The program was aborted due to an error; "
"for details, see the following error file:"
char *title_text = getStringCat2(program.program_title, " Error Message");
char *error_text = getStringCat2("The program was aborted due to an error; "
"for details, see the following error file:"