void metainput(void) /* Wait for actions in the meta-server window. * * This is really the meta-server window's own little input() function. It is * needed so we don't have to use all the bull in the main input(). Plus to * use it I'd have to call mapAll() first and the client would read in the * default server and then call it up before I can select a server. */ { W_Event data; (void) SIGNAL(SIGCHLD, sigchld); while (W_IsMapped(metaWin)) { while (1) { W_Flush(); if (W_EventsPending()) break; if (ReadMetasRecv(W_Socket()) || metareap_needed) { metareap(); metaHeight = num_servers + N_OVERHEAD; metawindow(); W_Flush(); } refresh_cyclic(); } W_NextEvent(&data); switch ((int) data.type) { case W_EV_KEY: if (data.Window == metaList || data.Window == metaWin) if (key(&data)) return; if (data.Window == metaHelpWin) hide_help(); break; case W_EV_BUTTON: if (data.Window == metaList) if (button(&data)) return; if (data.Window == metaHelpWin) hide_help(); if (data.Window == metaWin && data.y < 200) W_NextScreenShot(metaWin, 0, 0); break; case W_EV_EXPOSE: if (data.Window == metaHelpWin) expo_help(); if (data.Window == metaWin) { W_DrawScreenShot(metaWin, 0, 0); W_DrawImage(200, 9, logo); } break; case W_EV_CLOSED: if (data.Window == metaWin) { fprintf(stderr, "you quit, by closing the server list window\n"); terminate(0); } break; default: break; } } }
getname(char *defname, char *defpasswd) /* Let person identify themselves from w */ { register char ch; int secondsLeft = 199, laststate; char tempstr[40]; LONG lasttime; char *namptr, *passptr; register int j; struct timeval timeout; fd_set readfds; autolog = (*defpasswd && *defname) ? 1 : 0; MZERO(mystats, sizeof(struct stats)); mystats->st_tticks = 1; for (j = 0; j < 95; j++) { mystats->st_keymap[j] = j + 32; mystats->st_keymap[j + 96] = j + 32 + 96; #ifdef MOUSE_AS_SHIFT mystats->st_keymap[j + 192] = j + 32; mystats->st_keymap[j + 288] = j + 32; mystats->st_keymap[j + 384] = j + 32; #endif } mystats->st_keymap[95] = 0; mystats->st_flags = ST_MAPMODE + ST_NAMEMODE + ST_SHOWSHIELDS + ST_KEEPPEACE + ST_SHOWLOCAL * 2 + ST_SHOWGLOBAL * 2; lasttime = time(NULL); if (ghoststart) return; tempname[0] = '\0'; password1[0] = '\0'; password2[0] = '\0'; laststate = state = ST_GETNAME; displayStartup(defname); while (1) { handleWEvents(defname); if (!autolog) { #ifndef HAVE_WIN32 W_FullScreen(baseWin); timeout.tv_sec = 1; timeout.tv_usec = 0; #else /* Since we don't have a socket to check on Win32 for windowing * * system events, we set the timeout to zero and effectively poll. * * Yes, I could do the correct thing and call * * WaitForMultipleObjects() etc. but I don't feel like it */ timeout.tv_sec = 0; timeout.tv_usec = 100000; #endif FD_ZERO(&readfds); FD_SET(sock, &readfds); if (udpSock >= 0) FD_SET(udpSock, &readfds); #ifndef HAVE_WIN32 FD_SET(W_Socket(), &readfds); #endif if (SELECT(32, &readfds, 0, 0, &timeout) < 0) { perror("select"); continue; } if (FD_ISSET(sock, &readfds) || (udpSock >= 0 && FD_ISSET(udpSock, &readfds))) readFromServer(&readfds); #ifndef HAVE_WIN32 if (FD_ISSET(W_Socket(), &readfds)) #else if (W_EventsPending()) #endif handleWEvents(defname); } else { readFromServer(&readfds); } if (isServerDead()) { printf("Shit, we were ghostbusted\n"); #ifdef HAVE_XPM W_GalacticBgd(GHOST_PIX); #endif #ifdef AUTOKEY if (autoKey) W_AutoRepeatOn(); #endif terminate(0); } if (time(0) != lasttime) { lasttime++; secondsLeft--; showreadme(); if (!autolog) { sprintf(tempstr, "Seconds to go: %d ", secondsLeft); W_WriteText(w, 100, 400, textColor, tempstr, strlen(tempstr), W_RegularFont); } if (secondsLeft == 0) { me->p_status = PFREE; printf("Timed Out.\n"); #ifdef AUTOKEY if (autoKey) W_AutoRepeatOn(); #endif terminate(0); } } if (state == ST_DONE) { W_ClearWindow(w); W_ClearWindow(mapw); return; } if (autolog) { switch (state) { case ST_GETNAME: tempname[0] = '\0'; ch = 13; j = 0; break; case ST_GETPASS: case ST_MAKEPASS1: case ST_MAKEPASS2: ch = defpasswd[j++]; if (ch == '\0') { j = 0; ch = 13; } break; default: break; } loginproced(ch, defname); } laststate = state; } }
void new_entrywindow(int *team, int *s_type) { int i; int lastplayercount[4]; /* number of players on each team */ int okayMask, lastOkayMask; /* teams you're allowed to choose */ char buf[100]; /* OUTFIT timeout stuff */ long startTime = -1; long lasttime = -1; int spareTime = 0; if (fastQuit) { *team = -1; return; } lastOkayMask = okayMask = tournMask; /* erase packet lights to make Bob happy [BDyess] */ light_erase(); /* map all team selection windows, and stripe out those that are unchoosable */ for (i = 0; i < number_of_teams; i++) { W_MapWindow(teamWin[i]); lastplayercount[i] = -1; } W_MapWindow(qwin); /* no team selected yet */ *team = -1; /* set to team index (0..n-1) to choose a team. set to n if you want to quit */ /* I don't know why this restriction is in place - RF */ if (me->p_whydead != KWINNER && me->p_whydead != KGENOCIDE) { showMotd(w); W_ClearWindow(mapw); showValues(mapw); redraw_death_messages(); } do { /* set team to n if you want to quit */ while (!W_EventsPending() && (me->p_status == POUTFIT || me->p_status == PTQUEUE)) { /* no window events, just process socket stuff */ fd_set mask; light_erase(); readFromServer(); if (me->p_status == POUTFIT || me->p_status == PTQUEUE) { /* wait up to a half-second for input from the window system */ struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 500000; FD_ZERO(&mask); FD_SET(W_Socket(), &mask); select(W_Socket() + 1, &mask, 0, 0, &tv); } #if SHOW_MAP_AT_MOTD_DATA_ITEM_IMPLEMENTED if(showMapAtMotd) { map(); } #endif redraw_death_messages(); if (me->p_status == PTQUEUE) startTime = -1; if (me->p_status == POUTFIT) { /* time only elapses in OUTFIT mode */ if (startTime == -1) { /* we were on the tqueue */ /* I hate this [BDyess] */ W_Deiconify(baseWin); /* we changed status. alert the user */ startTime = time(0); spareTime = 480; /* Allow them extra time, as long */ /* as they are active */ } elapsed = time(0) - startTime; if (elapsed > autoQuit) { printf("Auto-Quit.\n"); *team = number_of_teams; break; } } if (lasttime != time(0)) { if (W_IsMapped(playerw)) playerlist2(); if (newMotdStuff) { showMotd(w); showValues(mapw); redraw_death_messages(); } if (me->p_status == POUTFIT) { showTimeLeft(elapsed, autoQuit); } lasttime = time(0); } okayMask = tournMask; /* redraw those windows whose choosable status has changed */ for (i = 0; i < number_of_teams; i++) { if ((okayMask ^ lastOkayMask) & (1 << i)) { lastplayercount[i] = -1; /* force update */ } redrawTeam(teamWin[i], i, &lastplayercount[i]); } lastOkayMask = okayMask; } if (playback) /* silly. Shouldn't even be mapping team windows. */ break; /* they quit or ran out of time */ if (*team == number_of_teams) { me->p_status = PFREE; /* exit outer while loop */ break; } /* this makes them eventually run out of time no matter how awake they are. Only affects the OUTFIT screen. */ if (me->p_status == POUTFIT && startTime != -1) { if (time(0) - startTime <= spareTime) { spareTime -= time(0) - startTime; startTime = time(0); } else { startTime += spareTime; spareTime = 0; } } if (!W_EventsPending()) continue; /* ok, there's a window event pending */ /* thiswill set p_status to PFREE if they decide to quit */ get_N_dispatch_outfit_event(team, s_type, lastplayercount); } while ((me->p_status == POUTFIT || me->p_status == PTQUEUE) && (!pb_update) ); if (*team >= 0) { strcpy(buf, "Welcome aboard "); if (paradise) strcat(buf, ranks2[me->p_stats2.st_rank].name); else strcat(buf, ranks[me->p_stats.st_rank].name); sprintf(buf, "Welcome aboard %s!", get_players_rank_name(me)); warning(buf); } if (playback) { extern int lastTeamReq; *team = me->p_teami = lastTeamReq; } else /* if they quit or ran out of time */ if (me->p_status == PFREE) *team = -1; else if (me->p_status == PALIVE || me->p_status == POBSERVE) if (*team == -1) *team = me->p_teami; else me->p_teami = *team; for (i = 0; i < number_of_teams; i++) W_UnmapWindow(teamWin[i]); W_UnmapWindow(qwin); }