[Freeciv-Dev] patch: myusleep
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
This patch wraps up the HAVE_USLEEP/usleep/select stuff into a
function myusleep() in shared.c
-- David
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-gtk/mapview.c
fc-adv/client/gui-gtk/mapview.c
--- freeciv-cvs/client/gui-gtk/mapview.c Sat Jun 12 17:40:05 1999
+++ fc-adv/client/gui-gtk/mapview.c Sun Jun 13 23:00:00 1999
@@ -21,6 +21,7 @@
#include "game.h"
#include "map.h"
+#include "shared.h" /* myusleep() */
#include "civclient.h"
#include "colors.h"
@@ -126,25 +127,13 @@
void decrease_unit_hp_smooth(struct unit *punit0, int hp0,
struct unit *punit1, int hp1)
{
-#ifndef HAVE_USLEEP
- struct timeval tv;
-
- tv.tv_sec=0;
- tv.tv_usec=100;
-#endif
-
set_unit_focus_no_center(punit0);
set_unit_focus_no_center(punit1);
do {
refresh_tile_mapcanvas(punit0->x, punit0->y, 1);
refresh_tile_mapcanvas(punit1->x, punit1->y, 1);
-
-#ifndef HAVE_USLEEP
- select(0, NULL, NULL, NULL, &tv);
-#else
- usleep(100);
-#endif
+ myusleep(100);
if(punit0->hp>hp0)
punit0->hp--;
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-xaw/mapview.c
fc-adv/client/gui-xaw/mapview.c
--- freeciv-cvs/client/gui-xaw/mapview.c Sat Jun 12 17:40:08 1999
+++ fc-adv/client/gui-xaw/mapview.c Sun Jun 13 23:00:03 1999
@@ -25,6 +25,7 @@
#include "game.h"
#include "map.h"
+#include "shared.h" /* myusleep() */
#include "unit.h"
#include "civclient.h"
@@ -103,25 +104,13 @@
void decrease_unit_hp_smooth(struct unit *punit0, int hp0,
struct unit *punit1, int hp1)
{
-#ifndef HAVE_USLEEP
- struct timeval tv;
-
- tv.tv_sec=0;
- tv.tv_usec=100;
-#endif
-
set_unit_focus_no_center(punit0);
set_unit_focus_no_center(punit1);
do {
refresh_tile_mapcanvas(punit0->x, punit0->y, 1);
refresh_tile_mapcanvas(punit1->x, punit1->y, 1);
-
-#ifndef HAVE_USLEEP
- select(0, NULL, NULL, NULL, &tv);
-#else
- usleep(100);
-#endif
+ myusleep(100);
if(punit0->hp>hp0)
punit0->hp--;
diff -u -r --exclude-from exclude freeciv-cvs/common/shared.c
fc-adv/common/shared.c
--- freeciv-cvs/common/shared.c Sat Jun 12 17:40:10 1999
+++ fc-adv/common/shared.c Sun Jun 13 23:00:14 1999
@@ -16,6 +16,10 @@
#include <ctype.h>
#include <assert.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
#include "log.h"
#include "mem.h"
@@ -266,6 +270,22 @@
static char buf[64];
sprintf(buf, "error %d (compiled without strerror)", errnum);
return buf;
+#endif
+}
+
+/***************************************************************
+...
+***************************************************************/
+void myusleep(unsigned long usec)
+{
+#ifndef HAVE_USLEEP
+ struct timeval tv;
+
+ tv.tv_sec=0;
+ tv.tv_usec=100;
+ select(0, NULL, NULL, NULL, &tv);
+#else
+ usleep(usec);
#endif
}
diff -u -r --exclude-from exclude freeciv-cvs/common/shared.h
fc-adv/common/shared.h
--- freeciv-cvs/common/shared.h Thu Jun 10 22:20:18 1999
+++ fc-adv/common/shared.h Sun Jun 13 22:56:07 1999
@@ -68,8 +68,10 @@
char *textyear(int year);
char *get_dot_separated_int(unsigned val);
int mystrcasecmp(char *str0, char *str1);
-char *mystrerror(int errnum);
int string_ptr_compare(const void *first, const void *second);
+
+char *mystrerror(int errnum);
+void myusleep(unsigned long usec);
RANDOM_TYPE myrand(int size);
void mysrand(RANDOM_TYPE seed);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] patch: myusleep,
David Pfitzner <=
|
|