extra additional paranoia (trunk only)
When requiring "no" to reject in addition to "yes" to confirm one of the paranoid_confirmation prompts, only loop a handful of times before giving up and rejecting (in case there's some hangup-like situation that isn't hangup enough to switch over to using ESC for further input). There's no "that's enough tries" feedback; after 6 tries it just stops asking for a yes or no answer and behaves as if it had gotten no.
This commit is contained in:
@@ -3650,20 +3650,22 @@ paranoid_query(be_paranoid, prompt)
|
|||||||
boolean be_paranoid;
|
boolean be_paranoid;
|
||||||
const char *prompt;
|
const char *prompt;
|
||||||
{
|
{
|
||||||
char qbuf[QBUFSZ], ans[BUFSZ];
|
|
||||||
const char *responsetype, *promptprefix = "";
|
|
||||||
boolean confirmed_ok;
|
boolean confirmed_ok;
|
||||||
|
|
||||||
/* when paranoid, player must respond with "yes" rather than just 'y'
|
/* when paranoid, player must respond with "yes" rather than just 'y'
|
||||||
to give the go-ahead for this query; default is "no" unless the
|
to give the go-ahead for this query; default is "no" unless the
|
||||||
ParanoidConfirm flag is set in which case there's no default */
|
ParanoidConfirm flag is set in which case there's no default */
|
||||||
if (be_paranoid) {
|
if (be_paranoid) {
|
||||||
|
char qbuf[QBUFSZ], ans[BUFSZ];
|
||||||
|
const char *promptprefix = "",
|
||||||
|
*responsetype = ParanoidConfirm ? "(yes|no)" : "(yes) [no]";
|
||||||
|
int trylimit = 6; /* 1 normal, 5 more with "Yes or No:" prefix */
|
||||||
|
|
||||||
/* in addition to being paranoid about this particular
|
/* in addition to being paranoid about this particular
|
||||||
query, we might be even more paranoid about all paranoia
|
query, we might be even more paranoid about all paranoia
|
||||||
responses (ie, ParanoidConfirm is set) in which case we
|
responses (ie, ParanoidConfirm is set) in which case we
|
||||||
require "no" to reject in addition to "yes" to confirm
|
require "no" to reject in addition to "yes" to confirm
|
||||||
(except we won't loop if respose is ESC; it means no) */
|
(except we won't loop if respose is ESC; it means no) */
|
||||||
responsetype = ParanoidConfirm ? "(yes|no)" : "(yes) [no]";
|
|
||||||
do {
|
do {
|
||||||
Sprintf(qbuf, "%s%s %s", promptprefix, prompt, responsetype);
|
Sprintf(qbuf, "%s%s %s", promptprefix, prompt, responsetype);
|
||||||
getlin(qbuf, ans);
|
getlin(qbuf, ans);
|
||||||
@@ -3671,7 +3673,7 @@ const char *prompt;
|
|||||||
confirmed_ok = !strcmpi(ans, "yes");
|
confirmed_ok = !strcmpi(ans, "yes");
|
||||||
if (confirmed_ok || *ans == '\033') break;
|
if (confirmed_ok || *ans == '\033') break;
|
||||||
promptprefix = "\"Yes\" or \"No\": ";
|
promptprefix = "\"Yes\" or \"No\": ";
|
||||||
} while (ParanoidConfirm && strcmpi(ans, "no"));
|
} while (ParanoidConfirm && strcmpi(ans, "no") && --trylimit);
|
||||||
} else
|
} else
|
||||||
confirmed_ok = (yn(prompt) == 'y');
|
confirmed_ok = (yn(prompt) == 'y');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user