1
0
Fork 0
mirror of git://git.psyced.org/git/psyced synced 2024-08-15 03:25:10 +00:00

valid degree?

This commit is contained in:
psyc://psyced.org/~lynX 2009-11-09 12:47:06 +01:00
parent cc46edb253
commit d6498a188a
2 changed files with 26 additions and 15 deletions

View file

@ -57,7 +57,7 @@ volatile string lastvar, mod, origin_unl;
volatile array(mixed) list; volatile array(mixed) list;
volatile mapping hash; volatile mapping hash;
volatile int l = 0; volatile int l = 0;
volatile int pongtime, routing = 1; volatile int reject = 0, pongtime; //, routing;
#ifndef PSYC_TCP #ifndef PSYC_TCP
// resolved UNL of remote server (psyc://hostname or psyc://hostname:port) // resolved UNL of remote server (psyc://hostname or psyc://hostname:port)
@ -129,7 +129,7 @@ int restart() {
// delete other stuff too // delete other stuff too
buffer = ""; buffer = "";
mc = 0; mc = 0;
routing = 1; // unused as yet // routing = 1; // unused as yet
#ifdef SYSTEM_SECRET #ifdef SYSTEM_SECRET
checkpack = vcheck = 0; checkpack = vcheck = 0;
ctrust = trustworthy; ctrust = trustworthy;
@ -193,13 +193,17 @@ private int conclude() {
// a later day.. TODO // a later day.. TODO
// hooray, we get to check some variable families for sanity // hooray, we get to check some variable families for sanity
} else if (abbrev("_degree", lastvar)) { } else if (abbrev("_degree", lastvar)) {
mixed t = cvars[lastvar];
// allow for unset degree '-' // allow for unset degree '-'
if (!stringp(cvars[lastvar]) || (cvars[lastvar] != "-" && if (!(intp(t) && t>=0) || (t != "-" &&
!sscanf(cvars[lastvar], "%1d", cvars[lastvar]))) { !sscanf(t, "%1d", cvars[lastvar]))) {
P1(("%O failed to parse %O: %O\n", ME, reject++;
lastvar, cvars[lastvar])) P1(("%O failed to parse %O: %O\n", ME, lastvar, t))
croak("_error_type_degree",
"Your value for variable [_variable] does not qualify for a degree.",
([ "_variable": lastvar ]));
m_delete(cvars, lastvar); m_delete(cvars, lastvar);
if (mod != ":") m_delete(pvars, lastvar); //if (mod != ":") m_delete(pvars, lastvar);
} }
else if (mod != ":") pvars[lastvar] = cvars[lastvar]; else if (mod != ":") pvars[lastvar] = cvars[lastvar];
} else if (abbrev("_list", lastvar)) { // _tab } else if (abbrev("_list", lastvar)) { // _tab
@ -293,7 +297,7 @@ vamixed parse(string a) {
// to put the mmp variable state away somewhere // to put the mmp variable state away somewhere
// and go fetch the psyc variable state for the current // and go fetch the psyc variable state for the current
// source/target pair from somewhere else. TODO // source/target pair from somewhere else. TODO
routing = 0; // unused as yet // routing = 0; // unused as yet
} else switch(a[0]) { } else switch(a[0]) {
case ':': case ':':
unless (SCANFIT) { unless (SCANFIT) {
@ -576,6 +580,12 @@ vamixed getdata(string a) {
// a runtime error (but it's still better to fix it!) // a runtime error (but it's still better to fix it!)
next_input_to(#'parse); next_input_to(#'parse);
# endif # endif
if (reject) {
// packet has been rejected by parser for semantic reasons
reject = 0;
restart();
return 1;
}
if (!t || trustworthy > 5) { if (!t || trustworthy > 5) {
deliver(0, 0, mc, buffer, cvars); deliver(0, 0, mc, buffer, cvars);
} else unless (u = parse_uniform(t)) { } else unless (u = parse_uniform(t)) {

View file

@ -1763,17 +1763,18 @@ case "_friend": // tmp
return 1; return 1;
#ifndef _flag_disable_module_presence #ifndef _flag_disable_module_presence
case "_presence": case "_presence":
// parser takes care of checking _degree type
if (t = vars["_degree_mood"]) { if (t = vars["_degree_mood"]) {
if (! sscanf(t, "%1d", t)) { // if (! sscanf(t, "%1d", t)) {
w("_warning_usage_mood"); // w("_warning_usage_mood");
return 1; // return 1;
} // }
vSet("mood", mood = t); vSet("mood", mood = t);
} }
if (t = vars["_degree_availability"]) { if (t = vars["_degree_availability"]) {
if (! sscanf(t, "%1d", t)) // if (! sscanf(t, "%1d", t))
w("_warning_usage_availability"); // w("_warning_usage_availability");
else // else
announce(t, !vars["_degree_automation"], announce(t, !vars["_degree_automation"],
1, vars["_description_presence"]); 1, vars["_description_presence"]);
return 1; return 1;