From cd97bf706239cd5faa3dd5c5c570f699adbbf1df Mon Sep 17 00:00:00 2001 From: Ari Johnson Date: Sat, 12 Jul 2008 15:44:23 +0000 Subject: [PATCH] General OOREF cleanup (cherry picked from commit 32b4959101bc39f634468c10a7de87118a399f48) --- game/txt/changes/0.73p1 | 3 +++ hdrs/conf.h | 18 ++++++++++----- src/funstr.c | 28 +++++++++++------------ src/funufun.c | 49 +++++++++++++++++++++++++---------------- 4 files changed, 59 insertions(+), 39 deletions(-) diff --git a/game/txt/changes/0.73p1 b/game/txt/changes/0.73p1 index d1b3643..2b12b72 100644 --- a/game/txt/changes/0.73p1 +++ b/game/txt/changes/0.73p1 @@ -7,6 +7,9 @@ CobraMUSH Version 0.73p1 Version 0.73p1 is a maintenance release of version 0.73. It is the first maintenance release in that series. + Minor changes: + * General OOREF cleanup [AEJ] + Fixes: * Fixed cstatus() [AEJ] * Fixed bug that caused some lock types to incorrectly count diff --git a/hdrs/conf.h b/hdrs/conf.h index 7792de5..d8f0963 100644 --- a/hdrs/conf.h +++ b/hdrs/conf.h @@ -15,12 +15,18 @@ /* TwinCheck Ooref define */ #define OOREF(x,y,z) ((ooref == NOTHING || x == ooref) ? (y) : (z && y)) -#define BEGINOOREF_L char l = 0; \ - if(options.twinchecks && ooref == NOTHING ) { \ - ooref = executor; \ - l = 1; \ - } -#define ENDOOREF_L if(l == 1) { ooref = NOTHING; } + +#define OOREF_DECL char __ooref_set = 0 + +#define ENTER_OOREF if(options.twinchecks && ooref == NOTHING) { \ + ooref = executor; \ + __ooref_set = 1; \ + } + +#define LEAVE_OOREF if(__ooref_set) { \ + ooref = NOTHING; \ + __ooref_set = 0; \ + } /* New Guest Setup Configuration */ #define GUEST_KEYWORD "GUEST" diff --git a/src/funstr.c b/src/funstr.c index e4aacf4..3d0f616 100644 --- a/src/funstr.c +++ b/src/funstr.c @@ -2131,21 +2131,18 @@ FUNCTION(fun_speak) char *say_string; char *string; char rbuff[BUFFER_LEN]; - - BEGINOOREF_L + OOREF_DECL; speaker = match_thing(executor, args[0]); if (speaker == NOTHING || speaker == AMBIGUOUS) { safe_str(T(e_match), buff, bp); - ENDOOREF_L return; } + speaker_str = unparse_dbref(speaker); - if (!args[1] || !*args[1]) { - ENDOOREF_L + if (!args[1] || !*args[1]) return; - } string = args[1]; @@ -2154,13 +2151,15 @@ FUNCTION(fun_speak) else say_string = (char *) "says,"; + ENTER_OOREF; + if (nargs > 3) { if (args[3] != '\0') { /* we have a transform attr */ transform = 1; if (!fetch_ufun_attrib(args[3], executor, &transufun, 1)) { - ENDOOREF_L safe_str(T(e_atrperm), buff, bp); + LEAVE_OOREF; return; } if (nargs > 4) { @@ -2168,8 +2167,8 @@ FUNCTION(fun_speak) /* we have an attr to use when transform returns an empty string */ null = 1; if (!fetch_ufun_attrib(args[4], executor, &nullufun, 1)) { - ENDOOREF_L safe_str(T(e_atrperm), buff, bp); + LEAVE_OOREF; return; } } @@ -2224,7 +2223,7 @@ FUNCTION(fun_speak) safe_format(buff, bp, "%s %s \"%s\"", Name(speaker), say_string, string); else safe_str(string, buff, bp); - ENDOOREF_L + LEAVE_OOREF; return; } @@ -2235,22 +2234,22 @@ FUNCTION(fun_speak) wenv[1] = speaker_str; wenv[2] = unparse_integer(fragment); if (call_ufun(&transufun, wenv, 3, rbuff, executor, enactor, pe_info)) { - ENDOOREF_L + LEAVE_OOREF; return; } if (strlen(rbuff) > 0) { safe_format(buff, bp, "%s %s %s", Name(speaker), say_string, rbuff); - ENDOOREF_L + LEAVE_OOREF; return; } else if (null == 1) { wenv[0] = speaker_str; wenv[1] = unparse_integer(fragment); if (call_ufun(&nullufun, wenv, 2, rbuff, executor, enactor, pe_info)) { - ENDOOREF_L + LEAVE_OOREF; return; } safe_str(rbuff, buff, bp); - ENDOOREF_L + LEAVE_OOREF; return; } } else { @@ -2312,5 +2311,6 @@ FUNCTION(fun_speak) safe_str(string, buff, bp); /* remaining string (not speech, so not t) */ } } - ENDOOREF_L + + LEAVE_OOREF; } diff --git a/src/funufun.c b/src/funufun.c index e88be2c..23f38ff 100644 --- a/src/funufun.c +++ b/src/funufun.c @@ -56,8 +56,9 @@ FUNCTION(fun_objeval) char *s; char const *p; dbref obj; + OOREF_DECL; - BEGINOOREF_L + ENTER_OOREF; /* First, we evaluate our first argument so people can use * functions on it. @@ -88,7 +89,8 @@ FUNCTION(fun_objeval) p = args[1]; process_expression(buff, bp, &p, obj, executor, enactor, PE_DEFAULT, PT_DEFAULT, pe_info); - ENDOOREF_L + + LEAVE_OOREF; } /** Helper function for ufun and family. @@ -150,11 +152,13 @@ FUNCTION(fun_ufun) { char rbuff[BUFFER_LEN]; ufun_attrib ufun; + OOREF_DECL; - BEGINOOREF_L + ENTER_OOREF; if (!fetch_ufun_attrib(args[0], executor, &ufun, 0)) { safe_str(T(ufun.errmess), buff, bp); + LEAVE_OOREF; return; } @@ -162,7 +166,7 @@ FUNCTION(fun_ufun) safe_str(rbuff, buff, bp); - ENDOOREF_L + LEAVE_OOREF; return; } @@ -172,12 +176,13 @@ FUNCTION(fun_ulambda) { char rbuff[BUFFER_LEN]; ufun_attrib ufun; + OOREF_DECL; - BEGINOOREF_L + ENTER_OOREF; if (!fetch_ufun_attrib(args[0], executor, &ufun, 1)) { safe_str(T(ufun.errmess), buff, bp); - ENDOOREF_L + LEAVE_OOREF; return; } @@ -185,7 +190,8 @@ FUNCTION(fun_ulambda) safe_str(rbuff, buff, bp); - ENDOOREF_L + LEAVE_OOREF; + return; } @@ -199,12 +205,13 @@ FUNCTION(fun_ulocal) char *preserve[NUMQ]; char rbuff[BUFFER_LEN]; ufun_attrib ufun; + OOREF_DECL; - BEGINOOREF_L + ENTER_OOREF; if (!fetch_ufun_attrib(args[0], executor, &ufun, 0)) { safe_str(T(ufun.errmess), buff, bp); - ENDOOREF_L + LEAVE_OOREF; return; } @@ -216,7 +223,7 @@ FUNCTION(fun_ulocal) restore_global_regs("ulocal.save", preserve); - ENDOOREF_L + LEAVE_OOREF; return; } @@ -236,8 +243,9 @@ FUNCTION(fun_uldefault) char **xargs; int i; char *preserve[NUMQ]; + OOREF_DECL; - BEGINOOREF_L + ENTER_OOREF; /* find our object and attribute */ dp = mstr; @@ -277,7 +285,7 @@ FUNCTION(fun_uldefault) mush_free(xargs[i], "udefault"); mush_free(xargs, "udefault.xargs"); } - ENDOOREF_L + LEAVE_OOREF; return; } /* We couldn't get it. Evaluate args[1] and return it */ @@ -289,7 +297,9 @@ FUNCTION(fun_uldefault) PE_DEFAULT, PT_DEFAULT, pe_info); if (called_as[1] == 'L') restore_global_regs("uldefault.save", preserve); - ENDOOREF_L + + LEAVE_OOREF; + return; } @@ -299,14 +309,15 @@ FUNCTION(fun_zfun) { ATTR *attrib; dbref zone; + OOREF_DECL; - BEGINOOREF_L + ENTER_OOREF; zone = Zone(executor); if (zone == NOTHING) { safe_str(T("#-1 INVALID ZONE"), buff, bp); - ENDOOREF_L + LEAVE_OOREF; return; } /* find the user function attribute */ @@ -314,19 +325,19 @@ FUNCTION(fun_zfun) if (attrib && Can_Read_Attr(executor, zone, attrib)) { if (!CanEvalAttr(executor, zone, attrib)) { safe_str(T(e_perm), buff, bp); - ENDOOREF_L + LEAVE_OOREF; return; } do_userfn(buff, bp, zone, attrib, nargs - 1, args + 1, executor, caller, enactor, pe_info); - ENDOOREF_L + LEAVE_OOREF; return; } else if (attrib || !Can_Examine(executor, zone)) { safe_str(T(e_atrperm), buff, bp); - ENDOOREF_L + LEAVE_OOREF; return; } safe_str(T("#-1 NO SUCH USER FUNCTION"), buff, bp); - ENDOOREF_L + LEAVE_OOREF; return; } -- 2.30.2