Index: src/common/cli.c =================================================================== --- src/common/cli.c (revision 17257) +++ src/common/cli.c (working copy) @@ -2,7 +2,9 @@ #include #include #ifdef WIN32 - #include + #include + #include + #include #else #include #endif @@ -156,20 +158,92 @@ return 1; } +#ifdef WIN32 +int poll(struct pollfd *fds, int nfds, int timeout) +{ + int i = 0, nCntOfEvent = 0, nMaxFD = -1; + fd_set R, W, E; + struct timeval tout = {0, 0}; + struct pollfd *pCur = NULL; + + FD_ZERO(&R); + FD_ZERO(&W); + FD_ZERO(&E); + + assert(fds != (struct pollfd *) NULL); + + for (i = 0, pCur = fds; i < nfds; i++, pCur++) + { + if (pCur->fd < 0) // skip bad file descriptor + continue; + + if ( (pCur->events & POLLIN) == POLLIN || (pCur->events & POLLRDNORM) == POLLRDNORM ) + FD_SET((unsigned int)pCur->fd, &R); + + if ( (pCur->events & POLLOUT) == POLLOUT || (pCur->events & POLLWRNORM) == POLLWRNORM ) + FD_SET((unsigned int)pCur->fd, &W); + + FD_SET((unsigned int)pCur->fd, &E); + nMaxFD = max (nMaxFD, pCur->fd); + } + + if ( nMaxFD < 0 ) + { + return -1; // Ooops nMaxFD is a bad file descriptor. + } + + if ( timeout > 0 ) + { + tout.tv_sec = timeout / 1000; + tout.tv_usec = (timeout % 1000) * 1000; + } + + // On success, select() and pselect() return the number of file descriptors contained + // in the three returned descriptor sets (that is, the total number of bits that are + // set in readfds, writefds, exceptfds) which may be zero if the timeout expires before + // anything interesting happens. On error, -1 is returned, and errno is set appropriately + if ( (nCntOfEvent = select (nMaxFD + 1, &R, &W, &E, &tout)) == 0 ) + { + return 0; // timout !!! + } + + if ( nCntOfEvent > 0 ) + { + for (i = 0, pCur = fds; i < nfds; i++, pCur++) + { + if (pCur->fd < 0) + continue; // skip bad file descriptor + + pCur->revents = 0; + + if ( FD_ISSET (pCur->fd, &E) ) + { + pCur->revents |= POLLERR; + continue; + } + else if ( FD_ISSET(pCur->fd, &R) ) + pCur->revents |= (POLLIN | POLLRDNORM); + + if ( FD_ISSET(pCur->fd, &W) ) + pCur->revents |= (POLLOUT | POLLWRNORM); + } + } + + return nCntOfEvent; +} +#endif + + + int cli_hasevent(){ -#ifdef WIN32 - return _kbhit(); -#else struct pollfd fds; fds.fd = 0; /* this is STDIN */ fds.events = POLLIN; return poll(&fds, 1, 0); -#endif } int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data) { char buf[MAX_CONSOLE_IN]; //max cmd atm is 63+63+63+3+3 - memset(buf,0,MAX_CONSOLE_IN); //clear out buf if(cli_hasevent()){ @@ -177,7 +251,7 @@ return -1; else if(strlen(buf)>MIN_CONSOLE_IN) parse_console(buf); - } + } return 0; } Index: src/common/cli.h =================================================================== --- src/common/cli.h (revision 17257) +++ src/common/cli.h (working copy) @@ -36,6 +36,28 @@ int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data); extern int parse_console(const char* buf); //particular for each serv +#ifdef WIN32 + #ifndef POLL_H + #define POLL_H + #define POLLIN 0x001 // There is data to read. + #define POLLPRI 0x002 // There is urgent data to read + #define POLLOUT 0x004 // Writing now will not block. + #define POLLERR 0x008 // Error condition (output only). + #define POLLHUP 0x010 // Stream socket peer closed connection, or shut down writing half of connection. + #define POLLNVAL 0x020 // Invalid request: fd not open (output only). + #define POLLRDNORM 0x040 // Equivalent to POLLIN. + #define POLLRDBAND 0x080 // Priority band data can be read (generally unused on Linux). + #define POLLWRNORM 0x100 // Equivalent to POLLOUT. + + struct pollfd { + int fd; // file descriptor + short events; // requested events + short revents; // returned events + }; + int poll (struct pollfd *fds, int nfds, int timeout); + #endif +#endif + #ifdef __cplusplus } #endif Index: conf/msg_conf/map_msg.conf =================================================================== --- conf/msg_conf/map_msg.conf (revision 17257) +++ conf/msg_conf/map_msg.conf (working copy) @@ -449,6 +449,7 @@ 462: This language is currently disabled. 463: Message configuration has been reloaded. 464: ---- Available languages: +464: Available langage // Messages of others (not for GM commands) // ---------------------------------------- Index: conf/login_athena.conf =================================================================== --- conf/login_athena.conf (revision 17257) +++ conf/login_athena.conf (working copy) @@ -38,7 +38,7 @@ // Console Commands // Allow for console commands to be used on/off // This prevents usage of >& log.file -console: off +console: yes // Can you use _M/_F to make new accounts on the server? new_account: yes Index: conf/map_athena.conf =================================================================== --- conf/map_athena.conf (revision 17257) +++ conf/map_athena.conf (working copy) @@ -79,7 +79,7 @@ // Console Commands // Allow for console commands to be used on/off // This prevents usage of >& log.file -console: off +console: on // Database autosave time // All characters are saved on this time in seconds (example: Index: conf/char_athena.conf =================================================================== --- conf/char_athena.conf (revision 17257) +++ conf/char_athena.conf (working copy) @@ -64,7 +64,7 @@ // Console Commands // Allow for console commands to be used on/off // This prevents usage of >& log.file -console: off +console: on // Type of server. // No functional side effects at the moment.