extern int chatCount;
int chattingPartner;
char marker[BOARD_RANKS][BOARD_FILES]; /* [HGM] marks for target squares */
+char lastMsg[MSG_SIZ];
ChessSquare pieceSweep = EmptySquare;
ChessSquare promoSweep = EmptySquare, defaultPromoChoice;
int promoDefaultAltered;
{
FILE *f;
char buf[MSG_SIZ];
+ int result;
if (strcmp(filename, "-") == 0) {
return SaveGame(stdout, 0, NULL);
DisplayError(buf, errno);
return FALSE;
} else {
- return SaveGame(f, 0, NULL);
+ safeStrCpy(buf, lastMsg, MSG_SIZ);
+ DisplayMessage(_("Waiting for access to save file"), "");
+ flock(fileno(f), LOCK_EX); // [HGM] lock: lock file while we are writing
+ DisplayMessage(_("Saving game"), "");
+ if(lseek(fileno(f), 0, SEEK_END) == -1) DisplayError("Bad Seek", errno); // better safe than sorry...
+ result = SaveGame(f, 0, NULL);
+ DisplayMessage(buf, "");
+ return result;
}
}
}
DisplayError(buf, errno);
return FALSE;
} else {
+ safeStrCpy(buf, lastMsg, MSG_SIZ);
+ DisplayMessage(_("Waiting for access to save file"), "");
+ flock(fileno(f), LOCK_EX); // [HGM] lock
+ DisplayMessage(_("Saving position"), "");
+ lseek(fileno(f), 0, SEEK_END); // better safe than sorry...
SavePosition(f, 0, NULL);
+ DisplayMessage(buf, "");
return TRUE;
}
}
if (len > remain) len = remain;\r
strncat(messageText, str2, len);\r
}\r
- messageText[MESSAGE_TEXT_MAX - 1] = NULLCHAR;\r
+ messageText[MESSAGE_TEXT_MAX - 1] = NULLCHAR;
+ safeStrCpy(lastMsg, messageText, MSG_SIZ);
\r
if (hwndMain == NULL || IsIconic(hwndMain)) return;\r
\r
};
};
+ safeStrCpy(lastMsg, message, MSG_SIZ); // [HGM] make available
+
/* need to test if messageWidget already exists, since this function
can also be called during the startup, if for example a Xresource
is not set up correctly */