void soundaction(W_Event * data) { #if defined(sgi) printf("sorry, not yet implemented\n"); #elif !defined(HAVE_SDL) int i, j; i = data->y; if (i == SOUND_TOGGLE) { if (sound_init) sound_toggle = (sound_toggle == 1) ? 0 : 1; soundrefresh(SOUND_TOGGLE); /* text in soundrefresh() says engine sound is not supported if (!sound_toggle) { Abort_Sound(ENGINE_SOUND); } else { Play_Sound(ENGINE_SOUND); } */ } else if (i < SOUND_OTHER) { sounds[i].flag = (sounds[i].flag == 1) ? 0 : 1; if (i + OTHER_SOUND_OFFSET <= NUM_SOUNDS) sounds[i + OTHER_SOUND_OFFSET].flag = sounds[i].flag; soundrefresh(i); Play_Sound(i); if (i == MESSAGE_SOUND) { for (j = MESSAGE1_SOUND; j <= MESSAGE9_SOUND; j++) sounds[j].flag = sounds[MESSAGE_SOUND].flag; } /* case ENGINE: st_engine = (st_engine == 1) ? 0 : 0; soundrefresh * * * (ENGINE); if (st_engine && sound_toggle) { Play_Sound * * * (ENGINE_SOUND); } else { Abort_Sound (ENGINE_SOUND); } break; */ } else if (i == SOUND_OTHER) { soundOther = !soundOther; soundrefresh(SOUND_OTHER); } else if (i == SOUND_INIT) { Exit_Sound(); sound_init = 1; Init_Sound(); soundrefresh(SOUND_INIT); soundrefresh(SOUND_TOGGLE); } else { sounddone(); } #endif /* HAVE_SDL */ }
findslot(void) { int oldcount = -1; W_Window waitWin, qwin, countWin, motdButtonWin; W_Window motdWin; extern int MaxMotdLine; int WaitMotdLine = 0; int mapMotd = booleanDefault("showMotd", 1); W_Event event; /* Wait for some kind of indication about in/not in */ while (queuePos == -1) { socketPause(); if (isServerDead()) { #if defined(SOUND) && !defined(HAVE_SDL) Exit_Sound(); #endif printf("Shit! Ghostbusted!\n"); terminate(0); } readFromServer(NULL); if (me != NULL) { /* We are in! */ ANNOUNCESOCKET; return (me->p_no); } } /* We have to wait. Make appropriate windows, etc... */ waitWin = W_MakeWindow("wait", 0, 0, WAITWIDTH, WAITHEIGHT, NULL, 2, foreColor); countWin = W_MakeWindow("count", WAITWIDTH / 3, WAITTITLE, WAITWIDTH / 3, WAITHEIGHT - WAITTITLE, waitWin, 1, foreColor); qwin = W_MakeWindow("waitquit", 0, WAITTITLE, WAITWIDTH / 3, WAITHEIGHT - WAITTITLE, waitWin, 1, foreColor); motdButtonWin = W_MakeWindow("motdbutton", 2 * WAITWIDTH / 3, WAITTITLE, WAITWIDTH / 3, WAITHEIGHT - WAITTITLE, waitWin, 1, foreColor); W_MapWindow(waitWin); W_MapWindow(countWin); W_MapWindow(motdButtonWin); W_MapWindow(qwin); if (mapMotd) { motdWin = W_MakeWindow("waitmotd", 1, WAITWIDTH + 1, TWINSIDE, TWINSIDE, 0, 2, foreColor); W_MapWindow(motdWin); showMotd(motdWin, WaitMotdLine); } for (;;) { socketPause(); readFromServer(NULL); if (isServerDead()) { #if defined(SOUND) && !defined(HAVE_SDL) Exit_Sound(); #endif printf("Damn, We've been ghostbusted!\n"); terminate(0); } while (W_EventsPending()) { W_NextEvent(&event); switch ((int) event.type) { case W_EV_BUTTON: case W_EV_KEY: if (mapMotd && event.Window == motdWin) { if (event.key == ' ' || event.key == 'q') { W_DestroyWindow(motdWin); mapMotd = !mapMotd; } else { if (event.key == 'b') { WaitMotdLine -= 28; WaitMotdLine = MAX(WaitMotdLine, 0); } else { WaitMotdLine += 28; /* scroll to start if it goes over */ if (WaitMotdLine > MaxMotdLine) WaitMotdLine = 0; } W_ClearWindow(motdWin); showMotd(motdWin, WaitMotdLine); break; } } else if (event.Window == motdButtonWin) { if (mapMotd) { W_DestroyWindow(motdWin); } else { motdWin = W_MakeWindow("waitmotd", 1, WAITWIDTH + 1, TWINSIDE, TWINSIDE, 0, 2, foreColor); W_MapWindow(motdWin); showMotd(motdWin, WaitMotdLine); } mapMotd = !mapMotd; } else if (event.Window == qwin) { #if defined(SOUND) && !defined(HAVE_SDL) Exit_Sound(); #endif printf("OK, bye!\n"); terminate(0); } break; case W_EV_EXPOSE: if (event.Window == waitWin) { mapWaitWin(waitWin); } else if (event.Window == motdWin) { showMotd(motdWin, WaitMotdLine); } else if (event.Window == qwin) { mapWaitQuit(qwin); } else if (event.Window == countWin) { mapWaitCount(waitWin, countWin, queuePos); } else if (event.Window == motdButtonWin) { mapWaitMotdButton(motdButtonWin); } break; default: break; } } if (queuePos != oldcount) { mapWaitCount(waitWin, countWin, queuePos); oldcount = queuePos; } if (me != NULL) { W_DestroyWindow(waitWin); if (mapMotd) { W_DestroyWindow(motdWin); } ANNOUNCESOCKET; W_Beep(); W_Beep(); return (me->p_no); } } }