Prevent changing time control during game (XB)
[xboard.git] / dialogs.c
index 0377031..ea0ece7 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -1,7 +1,7 @@
 /*
  * dialogs.c -- platform-independent code for dialogs of XBoard
  *
- * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+ * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
  * ------------------------------------------------------------------------
  *
  * GNU XBoard is free software: you can redistribute it and/or modify
@@ -331,8 +331,10 @@ UpgradeParticipant ()
 static void
 PseudoOK ()
 {
+    if(matchMode) return;
     GenericReadout(matchOptions, -2); // read all, but suppress calling of MatchOK
     ASSIGN(appData.participants, engineName);
+    ASSIGN(appData.tourneyFile, tfName);
     PopDown(MasterDlg); // early popdown to prevent FreezeUI called through MatchEvent from causing XtGrab warning
 }
 
@@ -1669,6 +1671,10 @@ SetTcType (int n)
 void
 TimeControlProc ()
 {
+   if(gameMode != BeginningOfGame) {
+       DisplayError(_("Changing time control during a game is not implemented"), 0);
+       return;
+   }
    tmpMoves = appData.movesPerSession;
    tmpInc = appData.timeIncrement; if(tmpInc < 0) tmpInc = 0;
    tmpOdds1 = tmpOdds2 = 1; tcType = 0;
@@ -1771,7 +1777,7 @@ PromotionPopUp (char choice)
 { // choice depends on variant: prepare dialog acordingly
   count = 8;
   SetPromo(_("Cancel"), --count, -1); // Beware: GenericPopUp cannot handle user buttons named "cancel" (lowe case)!
-  if(choice != '+') {
+  if(choice != '+' && !IS_SHOGI(gameInfo.variant)) {
     if (!appData.testLegality || gameInfo.variant == VariantSuicide ||
         gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove) ||
         gameInfo.variant == VariantGiveaway) {
@@ -1923,7 +1929,7 @@ IcsHist (int n, Option *opt, DialogClass dlg)
         while(!dirty[chat = (chat + 1)%MAX_CHAT]) if(chat == start) break;
        if(!dirty[chat])
         while(!chatPartner[chat = (chat + 1)%MAX_CHAT][0]) if(chat == start) break;
-       if(chat == start && hidden) chat = 0; // if all unused, start left
+       if(!chatPartner[chat][0]) break; // if all unused, ignore
         ChatSwitch(chat + 1);
        break;
       case 1:
@@ -1944,6 +1950,7 @@ OutputChatMessage (int partner, char *mess)
     char *p = texts[partner];
     int len = strlen(mess) + 1;
 
+    if(!DialogExists(ChatDlg)) return;
     if(p) len += strlen(p);
     texts[partner] = (char*) malloc(len);
     snprintf(texts[partner], len, "%s%s", p ? p : "", mess);
@@ -1962,11 +1969,12 @@ ChatOK (int n)
 {   // can only be called through <Enter> in chat-partner text-edit, as there is no OK button
     char buf[MSG_SIZ];
 
-    if(!hidden && (!partner || strcmp(partner, chatPartner[activePartner]))) {
+    if(!hidden && (!partner || strcmp(partner, chatPartner[activePartner]) || !*partner)) {
        safeStrCpy(chatPartner[activePartner], partner, MSG_SIZ);
        SetWidgetText(&chatOptions[CHAT_OUT], "", -1); // clear text if we alter partner
        SetWidgetText(&chatOptions[CHAT_IN], "", ChatDlg); // clear text if we alter partner
        SetWidgetLabel(&chatOptions[activePartner+1], chatPartner[activePartner][0] ? chatPartner[activePartner] : _("New Chat"));
+       if(!*partner) PaneSwitch();
        HardSetFocus(&chatOptions[CHAT_IN], 0);
     }
     if(line[0] || hidden) { // something was typed (for ICS commands we also allow empty line!)
@@ -1979,6 +1987,10 @@ ChatOK (int n)
              snprintf(buf, MSG_SIZ, "whisper %s\n", line); // WHISPER box uses "whisper" to send
        else if(!strcmp("shouts", chatPartner[activePartner]))
              snprintf(buf, MSG_SIZ, "shout %s\n", line); // SHOUT box uses "shout" to send
+       else if(!strcmp("c-shouts", chatPartner[activePartner]))
+             snprintf(buf, MSG_SIZ, "cshout %s\n", line); // C-SHOUT box uses "cshout" to send
+       else if(!strcmp("kibitzes", chatPartner[activePartner]))
+             snprintf(buf, MSG_SIZ, "kibitz %s\n", line); // KIBITZ box uses "kibitz" to send
        else {
            if(!atoi(chatPartner[activePartner])) {
                snprintf(buf, MSG_SIZ, "> %s\n", line); // echo only tells to handle, not channel
@@ -2256,8 +2268,8 @@ ErrorPopUp (char *title, char *label, int modal)
 {
     errorUp = True;
     errorOptions[1].name = label;
-    if(dialogError = shellUp[TransientDlg])
-       GenericPopUp(errorOptions+1, title, FatalDlg, TransientDlg, MODAL, 0); // pop up as daughter of the transient dialog
+    if(dialogError = shellUp[MasterDlg])
+       GenericPopUp(errorOptions+1, title, FatalDlg, MasterDlg, MODAL, 0); // pop up as daughter of the transient dialog
     else
        GenericPopUp(errorOptions+modal, title, modal ? FatalDlg: ErrorDlg, BoardWindow, modal, 0); // kludge: option start address indicates modality
 }