viewing paste Unknown #5640 | Diff

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
Index: src/common/cli.c
===================================================================
--- src/common/cli.c    (revision 17257)
+++ src/common/cli.c    (working copy)
@@ -2,7 +2,9 @@
 #include <string.h>
 #include <stdlib.h>
 #ifdef WIN32
-       #include <conio.h>
+       #include <assert.h>
+       #include <winsock2.h>
+       #include <sys/types.h>
 #else
        #include <sys/poll.h>
 #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,7 @@
 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 __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.
Viewed 605 times, submitted by lighta.