00001 /* 00002 * Copyright (C) 2000-2002 The Exult Team 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef _GUMP_UTILS_H_ 00020 #define _GUMP_UTILS_H_ 00021 00022 #ifdef XWIN /* Only needed in XWIN. */ 00023 #include <sys/time.h> 00024 #endif 00025 00026 #ifdef OPENBSD 00027 #include <sys/types.h> 00028 #endif 00029 00030 #include <unistd.h> 00031 00032 #ifndef XWIN 00033 #include "SDL_timer.h" 00034 #endif 00035 00036 /* 00037 * Delay between animations. 00038 */ 00039 00040 inline void Delay 00041 ( 00042 ) 00043 { 00044 #ifdef XWIN 00045 /* 00046 * Here's a somewhat better way to delay in X: 00047 */ 00048 extern int xfd; 00049 fd_set rfds; 00050 struct timeval timer; 00051 timer.tv_sec = 0; 00052 timer.tv_usec = 50000; // Try 1/50 second. 00053 FD_ZERO(&rfds); 00054 FD_SET(xfd, &rfds); 00055 // Wait for timeout or event. 00056 select(xfd + 1, &rfds, 0, 0, &timer); 00057 #else /* May use this for Linux too. */ 00058 SDL_Delay(10); // Try 1/100 second. 00059 #endif 00060 } 00061 00062 #endif