2007-01-03 03:11:53 +00:00
|
|
|
|
/*! \file levels.cpp
|
|
|
|
|
|
* \brief Reality levels stuff.
|
|
|
|
|
|
*
|
|
|
|
|
|
* See mux/REALITY.SETUP in the distribution.
|
2006-09-01 22:59:23 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
2007-01-03 03:11:53 +00:00
|
|
|
|
#ifdef REALITY_LVLS
|
|
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
#include "copyright.h"
|
|
|
|
|
|
#include "autoconf.h"
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
#include "externs.h"
|
2007-03-24 07:43:47 +00:00
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
RLEVEL RxLevel(dbref thing)
|
|
|
|
|
|
{
|
2007-03-14 07:40:08 +00:00
|
|
|
|
const UTF8 *buff = atr_get_raw(thing, A_RLEVEL);
|
2018-10-03 17:54:51 +00:00
|
|
|
|
if ( nullptr == buff
|
2026-03-03 19:38:14 -07:00
|
|
|
|
|| strlen(reinterpret_cast<const char *>(buff)) != 17)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-09-26 12:04:34 -07:00
|
|
|
|
switch (Typeof(thing))
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
case TYPE_ROOM:
|
|
|
|
|
|
return(mudconf.def_room_rx);
|
|
|
|
|
|
|
|
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
|
|
return(mudconf.def_player_rx);
|
|
|
|
|
|
|
|
|
|
|
|
case TYPE_EXIT:
|
|
|
|
|
|
return(mudconf.def_exit_rx);
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
return(mudconf.def_thing_rx);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
RLEVEL rx = 0;
|
|
|
|
|
|
for (i = 0; mux_isxdigit(buff[i]); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
rx = 16 * rx + mux_hex2dec(buff[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
return rx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RLEVEL TxLevel(dbref thing)
|
|
|
|
|
|
{
|
2007-03-14 07:40:08 +00:00
|
|
|
|
const UTF8 *buff = atr_get_raw(thing, A_RLEVEL);
|
2018-10-03 17:54:51 +00:00
|
|
|
|
if ( nullptr == buff
|
2026-03-03 19:38:14 -07:00
|
|
|
|
|| strlen(reinterpret_cast<const char *>(buff)) != 17)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-09-26 12:04:34 -07:00
|
|
|
|
switch (Typeof(thing))
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
case TYPE_ROOM:
|
|
|
|
|
|
return(mudconf.def_room_tx);
|
|
|
|
|
|
|
|
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
|
|
return(mudconf.def_player_tx);
|
|
|
|
|
|
|
|
|
|
|
|
case TYPE_EXIT:
|
|
|
|
|
|
return(mudconf.def_exit_tx);
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
return(mudconf.def_thing_tx);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Skip the first field.
|
|
|
|
|
|
//
|
|
|
|
|
|
int i;
|
|
|
|
|
|
for (i = 0; buff[i] && !mux_isspace(buff[i]); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
; // Nothing.
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RLEVEL tx = 0;
|
|
|
|
|
|
if (buff[i])
|
|
|
|
|
|
{
|
|
|
|
|
|
// Skip space found above.
|
|
|
|
|
|
//
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
|
|
// Decode second field.
|
|
|
|
|
|
//
|
|
|
|
|
|
for ( ; mux_isxdigit(buff[i]); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
tx = 16 * tx + mux_hex2dec(buff[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return tx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void notify_except_rlevel
|
|
|
|
|
|
(
|
|
|
|
|
|
dbref loc,
|
|
|
|
|
|
dbref player,
|
|
|
|
|
|
dbref exception,
|
2007-03-14 07:40:08 +00:00
|
|
|
|
const UTF8 *msg,
|
2006-09-01 22:59:23 +00:00
|
|
|
|
int xflags
|
|
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( loc != exception
|
|
|
|
|
|
&& IsReal(loc, player))
|
|
|
|
|
|
{
|
|
|
|
|
|
notify_check(loc, player, msg,
|
|
|
|
|
|
(MSG_ME_ALL | MSG_F_UP | MSG_S_INSIDE | MSG_NBR_EXITS_A| xflags));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbref first;
|
|
|
|
|
|
DOLIST(first, Contents(loc))
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( first != exception
|
2026-03-03 22:23:55 -07:00
|
|
|
|
&& IsReal(first, player)
|
|
|
|
|
|
&& !(isPlayer(first) && Alone(loc)))
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
notify_check(first, player, msg,
|
|
|
|
|
|
(MSG_ME | MSG_F_DOWN | MSG_S_OUTSIDE | xflags));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void notify_except2_rlevel
|
|
|
|
|
|
(
|
|
|
|
|
|
dbref loc,
|
|
|
|
|
|
dbref player,
|
|
|
|
|
|
dbref exc1,
|
|
|
|
|
|
dbref exc2,
|
2007-03-14 07:40:08 +00:00
|
|
|
|
const UTF8 *msg
|
2006-09-01 22:59:23 +00:00
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( loc != exc1
|
|
|
|
|
|
&& loc != exc2
|
|
|
|
|
|
&& IsReal(loc, player))
|
|
|
|
|
|
{
|
|
|
|
|
|
notify_check(loc, player, msg,
|
|
|
|
|
|
(MSG_ME_ALL | MSG_F_UP | MSG_S_INSIDE | MSG_NBR_EXITS_A));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbref first;
|
|
|
|
|
|
DOLIST(first, Contents(loc))
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( first != exc1
|
|
|
|
|
|
&& first != exc2
|
2026-03-03 22:23:55 -07:00
|
|
|
|
&& IsReal(first, player)
|
|
|
|
|
|
&& !(isPlayer(first) && Alone(loc)))
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
notify_check(first, player, msg,
|
|
|
|
|
|
(MSG_ME | MSG_F_DOWN | MSG_S_OUTSIDE));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void notify_except2_rlevel2
|
|
|
|
|
|
(
|
|
|
|
|
|
dbref loc,
|
|
|
|
|
|
dbref player,
|
|
|
|
|
|
dbref exc1,
|
|
|
|
|
|
dbref exc2,
|
2007-03-14 07:40:08 +00:00
|
|
|
|
const UTF8 *msg
|
2006-09-01 22:59:23 +00:00
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( loc != exc1
|
|
|
|
|
|
&& loc != exc2
|
|
|
|
|
|
&& IsReal(loc, player))
|
|
|
|
|
|
{
|
|
|
|
|
|
notify_check(loc, player, msg,
|
|
|
|
|
|
(MSG_ME_ALL | MSG_F_UP | MSG_S_INSIDE | MSG_NBR_EXITS_A));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dbref first;
|
|
|
|
|
|
DOLIST(first, Contents(loc))
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( first != exc1
|
|
|
|
|
|
&& first != exc2
|
|
|
|
|
|
&& IsReal(first, player)
|
2026-03-03 22:23:55 -07:00
|
|
|
|
&& IsReal(first, exc2)
|
|
|
|
|
|
&& !(isPlayer(first) && Alone(loc)))
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
notify_check(first, player, msg,
|
|
|
|
|
|
(MSG_ME | MSG_F_DOWN | MSG_S_OUTSIDE));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* ---------------------------------------------------------------------------
|
|
|
|
|
|
* * rxlevel_description: Return an mbuf containing the RxLevels of the thing.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2007-03-14 07:40:08 +00:00
|
|
|
|
UTF8 *rxlevel_description(dbref player, dbref target)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
// Allocate the return buffer.
|
|
|
|
|
|
//
|
|
|
|
|
|
int otype = Typeof(target);
|
2007-03-14 07:40:08 +00:00
|
|
|
|
UTF8 *buff = alloc_mbuf("rxlevel_description");
|
|
|
|
|
|
UTF8 *bp = buff;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
RLEVEL rl = RxLevel(target);
|
|
|
|
|
|
for (i = 0; i < mudconf.no_levels; ++i)
|
|
|
|
|
|
{
|
2007-10-09 11:41:14 -07:00
|
|
|
|
confdata::rlevel_def *rldef = &mudconf.reality_level[i];
|
|
|
|
|
|
if ((rl & rldef->value) == rldef->value)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
safe_mb_chr(' ', buff, &bp);
|
2007-10-09 11:41:14 -07:00
|
|
|
|
safe_mb_str(rldef->name, buff, &bp);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Terminate the string, and return the buffer to the caller.
|
|
|
|
|
|
//
|
|
|
|
|
|
*bp = '\0';
|
|
|
|
|
|
return buff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* ---------------------------------------------------------------------------
|
|
|
|
|
|
* * txlevel_description: Return an mbuf containing the TxLevels of the thing.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2007-03-14 07:40:08 +00:00
|
|
|
|
UTF8 *txlevel_description(dbref player, dbref target)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
// Allocate the return buffer.
|
|
|
|
|
|
//
|
|
|
|
|
|
int otype = Typeof(target);
|
2007-03-14 07:40:08 +00:00
|
|
|
|
UTF8 *buff = alloc_mbuf("txlevel_description");
|
|
|
|
|
|
UTF8 *bp = buff;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
RLEVEL tl = TxLevel(target);
|
|
|
|
|
|
for (i = 0; i < mudconf.no_levels; ++i)
|
|
|
|
|
|
{
|
2007-10-09 11:41:14 -07:00
|
|
|
|
confdata::rlevel_def *rldef = &mudconf.reality_level[i];
|
|
|
|
|
|
if ((tl & rldef->value) == rldef->value)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
safe_mb_chr(' ', buff, &bp);
|
2007-10-09 11:41:14 -07:00
|
|
|
|
safe_mb_str(rldef->name, buff, &bp);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Terminate the string, and return the buffer to the caller.
|
|
|
|
|
|
//
|
|
|
|
|
|
*bp = '\0';
|
|
|
|
|
|
return buff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat(#2136): flip fargs to const UTF8 * const — and convert every site the compiler surfaced
The flip: FUNCTION/XFUNCTION/FUN::fun/delim_check and the module
interfaces take `const UTF8 * const fargs[]`. Double-const is
load-bearing: C++ qualification conversion needs const at both pointer
levels, so builder-side `UTF8 *[]` arrays convert implicitly — the
evaluator, the JIT marshaller, and every owner site need zero casts,
and slot reassignment inside bodies becomes a compile error for free.
The conversions: the flip landed first so the compiler enumerated every
violation; this commit is that inventory worked to zero — ~250 sites
across funceval, funceval2, functions, funmath, help, mail, session,
powers, levels, predicates, conf, walkdb, stringutil, timeutil/
date_scan (regenerated, one-line diff), exp3, and mux_main, each
classified per docs/campaign-2136-const-fargs.md's four recipes.
New idioms (functions.h): trim_space_sep_n() — non-destructive trim for
(pointer, length) consumers, so trim-then-scan sites need no copy at
all; FargVec — the argv counterpart of FargCopy for CS_ARGV handlers.
countwords() and DecodeListOfIntegers() rewritten non-destructive.
The flip deleted more than it added: #2157's fun_munge list1 copy, the
engine_com help-topic copy, fun_index's in-place NUL write, and five
const_casts (process_sex x4, sha1_helper). const_cast budget: zero
added.
Trap recorded in the brief: an old-signature definition doesn't fail
the build — it becomes a C++ overload, and the new-signature symbol
stays undefined until dlopen(RTLD_NOW). delim_check, the conn_bridge
bridges, the dbt_spike stub, and exp3::Call were all silently shadowed;
muxscript was the only host that noticed, because netmux's own net.cpp
resolved the flat-namespace lookup. After any signature flip, grep the
old spelling.
Verified: make test EXPECT_CONFIG="jit=yes" (35 passed / 0 failed) and
make test-scenario, including the new tests/scenario/sidefx_fargs.py
that live-probes the class-3 wrappers smoke never touches (pemit/
trigger/link/tel/wipe/destroy).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 14:34:23 -06:00
|
|
|
|
RLEVEL find_rlevel(const UTF8 *name)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < mudconf.no_levels; i++)
|
|
|
|
|
|
{
|
2007-10-09 11:41:14 -07:00
|
|
|
|
confdata::rlevel_def *rldef = &mudconf.reality_level[i];
|
|
|
|
|
|
if (mux_stricmp(name, rldef->name) == 0)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-10-09 11:41:14 -07:00
|
|
|
|
return rldef->value;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void do_rxlevel
|
|
|
|
|
|
(
|
2007-10-06 17:55:10 +00:00
|
|
|
|
dbref executor,
|
|
|
|
|
|
dbref caller,
|
2006-09-01 22:59:23 +00:00
|
|
|
|
dbref enactor,
|
2007-10-06 17:55:10 +00:00
|
|
|
|
int eval,
|
2006-09-01 22:59:23 +00:00
|
|
|
|
int key,
|
2007-10-06 17:55:10 +00:00
|
|
|
|
int nargs,
|
2007-03-14 07:40:08 +00:00
|
|
|
|
UTF8 *object,
|
2007-10-06 17:55:10 +00:00
|
|
|
|
UTF8 *arg,
|
|
|
|
|
|
const UTF8 *cargs[],
|
|
|
|
|
|
int ncargs
|
2006-09-01 22:59:23 +00:00
|
|
|
|
)
|
|
|
|
|
|
{
|
2007-10-06 17:55:10 +00:00
|
|
|
|
UNUSED_PARAMETER(caller);
|
|
|
|
|
|
UNUSED_PARAMETER(enactor);
|
|
|
|
|
|
UNUSED_PARAMETER(eval);
|
|
|
|
|
|
UNUSED_PARAMETER(cargs);
|
|
|
|
|
|
UNUSED_PARAMETER(ncargs);
|
|
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (!arg || !*arg)
|
|
|
|
|
|
{
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify_quiet(executor, M_("I don’t know what you want to set!"));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Find thing.
|
|
|
|
|
|
//
|
2007-10-06 17:55:10 +00:00
|
|
|
|
dbref thing = match_controlled(executor, object);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (NOTHING == thing)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-03-14 07:40:08 +00:00
|
|
|
|
UTF8 lname[9];
|
2006-09-01 22:59:23 +00:00
|
|
|
|
RLEVEL ormask = 0;
|
|
|
|
|
|
RLEVEL andmask = ~ormask;
|
|
|
|
|
|
while (*arg)
|
|
|
|
|
|
{
|
|
|
|
|
|
int negate = 0;
|
|
|
|
|
|
while ( *arg != '\0'
|
|
|
|
|
|
&& mux_isspace(*arg))
|
|
|
|
|
|
{
|
|
|
|
|
|
arg++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (*arg == '!')
|
|
|
|
|
|
{
|
|
|
|
|
|
negate = 1;
|
|
|
|
|
|
++arg;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
for (i = 0; *arg && !mux_isspace(*arg); arg++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (i < 8)
|
|
|
|
|
|
{
|
|
|
|
|
|
lname[i++] = *arg;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lname[i] = '\0';
|
|
|
|
|
|
if (!lname[0])
|
|
|
|
|
|
{
|
|
|
|
|
|
if (negate)
|
|
|
|
|
|
{
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("You must specify a reality level to clear."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("You must specify a reality level to set."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RLEVEL result = find_rlevel(lname);
|
|
|
|
|
|
if (!result)
|
|
|
|
|
|
{
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("No such reality level."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (negate)
|
|
|
|
|
|
{
|
|
|
|
|
|
andmask &= ~result;
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("Cleared."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ormask |= result;
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("Set."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set the Rx Level.
|
|
|
|
|
|
//
|
Migrate 47 more alloc_lbuf/free_lbuf sites to LBuf RAII
Second wave: convert manual alloc/free pairs in cque (1), db_rw (4),
conf (5), db (2), engine_com (6), help (7), levels (2), predicates (5),
player (7), funmath (8). Eliminates ~80 explicit free_lbuf calls
including multi-exit error paths in getboolexp1 (5 frees → 0),
get_list, AnnounceConnect/Disconnect, and the eight NOEVAL function
variants (cand/cor/firstof/allof and bool variants).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 17:55:40 -06:00
|
|
|
|
LBuf buff = LBuf_Src("do_rxlevel");
|
|
|
|
|
|
mux_sprintf(buff.get(), LBUF_SIZE, T("%08X %08X"), RxLevel(thing) & andmask | ormask, TxLevel(thing));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
atr_add_raw(thing, A_RLEVEL, buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-10-06 17:55:10 +00:00
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
void do_txlevel
|
|
|
|
|
|
(
|
2007-10-06 17:55:10 +00:00
|
|
|
|
dbref executor,
|
|
|
|
|
|
dbref caller,
|
2006-09-01 22:59:23 +00:00
|
|
|
|
dbref enactor,
|
2007-10-06 17:55:10 +00:00
|
|
|
|
int eval,
|
|
|
|
|
|
int key,
|
|
|
|
|
|
int nargs,
|
2007-03-14 07:40:08 +00:00
|
|
|
|
UTF8 *object,
|
2007-10-06 17:55:10 +00:00
|
|
|
|
UTF8 *arg,
|
|
|
|
|
|
const UTF8 *cargs[],
|
|
|
|
|
|
int ncargs
|
2006-09-01 22:59:23 +00:00
|
|
|
|
)
|
|
|
|
|
|
{
|
2007-10-06 17:55:10 +00:00
|
|
|
|
UNUSED_PARAMETER(caller);
|
|
|
|
|
|
UNUSED_PARAMETER(enactor);
|
|
|
|
|
|
UNUSED_PARAMETER(eval);
|
|
|
|
|
|
UNUSED_PARAMETER(cargs);
|
|
|
|
|
|
UNUSED_PARAMETER(ncargs);
|
|
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (!arg || !*arg)
|
|
|
|
|
|
{
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify_quiet(executor, M_("I don’t know what you want to set!"));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Find thing.
|
|
|
|
|
|
//
|
2007-10-06 17:55:10 +00:00
|
|
|
|
dbref thing = match_controlled(executor, object);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (NOTHING == thing)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-03-14 07:40:08 +00:00
|
|
|
|
UTF8 lname[9];
|
2006-09-01 22:59:23 +00:00
|
|
|
|
RLEVEL ormask = 0;
|
|
|
|
|
|
RLEVEL andmask = ~ormask;
|
|
|
|
|
|
while (*arg)
|
|
|
|
|
|
{
|
|
|
|
|
|
int negate = 0;
|
|
|
|
|
|
while ( *arg
|
|
|
|
|
|
&& mux_isspace(*arg))
|
|
|
|
|
|
{
|
|
|
|
|
|
arg++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (*arg == '!')
|
|
|
|
|
|
{
|
|
|
|
|
|
negate = 1;
|
|
|
|
|
|
++arg;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
for (i = 0; *arg && !mux_isspace(*arg); arg++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (i < 8)
|
|
|
|
|
|
{
|
|
|
|
|
|
lname[i++] = *arg;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lname[i] = '\0';
|
|
|
|
|
|
if (!lname[0])
|
|
|
|
|
|
{
|
|
|
|
|
|
if (negate)
|
|
|
|
|
|
{
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("You must specify a reality level to clear."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("You must specify a reality level to set."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RLEVEL result = find_rlevel(lname);
|
|
|
|
|
|
if (!result)
|
|
|
|
|
|
{
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("No such reality level."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (negate)
|
|
|
|
|
|
{
|
|
|
|
|
|
andmask &= ~result;
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("Cleared."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ormask |= result;
|
2026-07-27 11:50:11 +00:00
|
|
|
|
notify(executor, M_("Set."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set the Tx Level.
|
|
|
|
|
|
//
|
Migrate 47 more alloc_lbuf/free_lbuf sites to LBuf RAII
Second wave: convert manual alloc/free pairs in cque (1), db_rw (4),
conf (5), db (2), engine_com (6), help (7), levels (2), predicates (5),
player (7), funmath (8). Eliminates ~80 explicit free_lbuf calls
including multi-exit error paths in getboolexp1 (5 frees → 0),
get_list, AnnounceConnect/Disconnect, and the eight NOEVAL function
variants (cand/cor/firstof/allof and bool variants).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 17:55:40 -06:00
|
|
|
|
LBuf buff = LBuf_Src("do_rxlevel");
|
|
|
|
|
|
mux_sprintf(buff.get(), LBUF_SIZE, T("%08X %08X"), RxLevel(thing), TxLevel(thing) & andmask | ormask);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
atr_add_raw(thing, A_RLEVEL, buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* ---------------------------------------------------------------------------
|
|
|
|
|
|
* * decompile_rlevels: Produce commands to set reality levels on target.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2007-03-14 07:40:08 +00:00
|
|
|
|
void decompile_rlevels(dbref player, dbref thing, UTF8 *thingname)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-03-14 07:40:08 +00:00
|
|
|
|
UTF8 *buf = rxlevel_description(player, thing);
|
2008-12-27 18:37:01 -08:00
|
|
|
|
notify(player, tprintf(T("@rxlevel %s=%s"), thingname, buf));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
free_mbuf(buf);
|
|
|
|
|
|
|
|
|
|
|
|
buf = txlevel_description(player, thing);
|
2008-12-27 18:37:01 -08:00
|
|
|
|
notify(player, tprintf(T("@txlevel %s=%s"), thingname, buf));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
free_mbuf(buf);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-10-09 10:41:18 -07:00
|
|
|
|
#define NUM_DESC 33
|
|
|
|
|
|
typedef struct DESC_INFO
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-10-09 10:41:18 -07:00
|
|
|
|
int n;
|
|
|
|
|
|
int descs[NUM_DESC];
|
|
|
|
|
|
} DESC_INFO;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
2007-10-09 10:41:18 -07:00
|
|
|
|
DESC_INFO *desclist_match(dbref player, dbref thing)
|
|
|
|
|
|
{
|
|
|
|
|
|
static DESC_INFO descbuffer;
|
|
|
|
|
|
|
|
|
|
|
|
descbuffer.n = 0;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
RLEVEL match = RxLevel(player) & TxLevel(thing);
|
|
|
|
|
|
for (int i = 0; i < mudconf.no_levels; i++)
|
|
|
|
|
|
{
|
2007-10-09 10:41:18 -07:00
|
|
|
|
confdata::rlevel_def *rldef = &mudconf.reality_level[i];
|
|
|
|
|
|
if ((match & rldef->value) == rldef->value)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-10-09 10:41:18 -07:00
|
|
|
|
ATTR *at = atr_str(rldef->attr);
|
2018-10-03 17:54:51 +00:00
|
|
|
|
if (nullptr != at)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-10-09 10:41:18 -07:00
|
|
|
|
bool bFound = false;
|
|
|
|
|
|
for (int j = 0; j < descbuffer.n; j++)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-10-09 10:41:18 -07:00
|
|
|
|
if (at->number == descbuffer.descs[j])
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-10-09 10:41:18 -07:00
|
|
|
|
bFound = true;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2007-10-09 10:41:18 -07:00
|
|
|
|
|
|
|
|
|
|
if ( !bFound
|
|
|
|
|
|
&& descbuffer.n < NUM_DESC-1)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-10-09 10:41:18 -07:00
|
|
|
|
descbuffer.descs[descbuffer.n] = at->number;
|
|
|
|
|
|
descbuffer.n++;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2007-10-09 10:41:18 -07:00
|
|
|
|
return &descbuffer;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2007-10-09 11:41:14 -07:00
|
|
|
|
UTF8 *get_rlevel_desc
|
|
|
|
|
|
(
|
|
|
|
|
|
dbref player,
|
2007-10-09 12:04:34 -07:00
|
|
|
|
dbref thing,
|
|
|
|
|
|
int *piDescUsed
|
2007-10-09 11:41:14 -07:00
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
dbref aowner;
|
|
|
|
|
|
int aflags;
|
|
|
|
|
|
UTF8 *buff = alloc_lbuf("get_rlevel_desc.");
|
|
|
|
|
|
UTF8 *bp = buff;;
|
2018-10-03 17:54:51 +00:00
|
|
|
|
reg_ref **preserve = nullptr;
|
2007-10-09 11:41:14 -07:00
|
|
|
|
bool need_pres = false;
|
|
|
|
|
|
bool bFirst = true;
|
|
|
|
|
|
|
|
|
|
|
|
// Get description list.
|
|
|
|
|
|
//
|
|
|
|
|
|
DESC_INFO *desclist = desclist_match(player, thing);
|
|
|
|
|
|
bool found_a_desc = false;
|
|
|
|
|
|
for (int i = 0; i < desclist->n; i++)
|
|
|
|
|
|
{
|
2026-04-05 18:34:51 -06:00
|
|
|
|
LBuf d = LBuf_Adopt(atr_pget(thing, desclist->descs[i], &aowner, &aflags));
|
2007-10-09 11:41:14 -07:00
|
|
|
|
if ('\0' != d[0])
|
|
|
|
|
|
{
|
|
|
|
|
|
found_a_desc = true;
|
|
|
|
|
|
if (!need_pres)
|
|
|
|
|
|
{
|
|
|
|
|
|
need_pres = true;
|
|
|
|
|
|
preserve = PushRegisters(MAX_GLOBAL_REGS);
|
|
|
|
|
|
save_global_regs(preserve);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!bFirst)
|
|
|
|
|
|
{
|
|
|
|
|
|
safe_str(T("\r\n"), buff, &bp);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
bFirst = false;
|
2007-10-09 12:04:34 -07:00
|
|
|
|
*piDescUsed = desclist->descs[i];
|
2007-10-09 11:41:14 -07:00
|
|
|
|
}
|
2026-03-03 21:08:57 -07:00
|
|
|
|
|
2026-03-07 19:57:24 -07:00
|
|
|
|
mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player,
|
2026-03-03 21:08:57 -07:00
|
|
|
|
AttrTrace(aflags, EV_FCHECK|EV_EVAL|EV_TOP),
|
|
|
|
|
|
nullptr, 0);
|
2007-10-09 11:41:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!found_a_desc)
|
|
|
|
|
|
{
|
2026-04-05 18:34:51 -06:00
|
|
|
|
LBuf d = LBuf_Adopt(atr_pget(thing, A_DESC, &aowner, &aflags));
|
2007-10-09 11:41:14 -07:00
|
|
|
|
if ('\0' != d[0])
|
|
|
|
|
|
{
|
|
|
|
|
|
found_a_desc = true;
|
|
|
|
|
|
if (!need_pres)
|
|
|
|
|
|
{
|
|
|
|
|
|
need_pres = true;
|
|
|
|
|
|
preserve = PushRegisters(MAX_GLOBAL_REGS);
|
|
|
|
|
|
save_global_regs(preserve);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-07 19:57:24 -07:00
|
|
|
|
mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player,
|
2026-03-03 21:08:57 -07:00
|
|
|
|
AttrTrace(aflags, EV_FCHECK|EV_EVAL|EV_TOP),
|
2018-10-03 17:54:51 +00:00
|
|
|
|
nullptr, 0);
|
2007-10-09 11:41:14 -07:00
|
|
|
|
*bp = '\0';
|
2007-10-09 12:04:34 -07:00
|
|
|
|
|
|
|
|
|
|
*piDescUsed = A_DESC;
|
2007-10-09 11:41:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If we preserved the state of the global registers, restore them.
|
|
|
|
|
|
//
|
|
|
|
|
|
if (need_pres)
|
|
|
|
|
|
{
|
|
|
|
|
|
restore_global_regs(preserve);
|
|
|
|
|
|
PopRegisters(preserve, MAX_GLOBAL_REGS);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
*bp = '\0';
|
|
|
|
|
|
return buff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
|
|
|
|
* did_it_rlevel: Have player do something to/with thing, watching the
|
|
|
|
|
|
* attributes. 'what' is actually ignored, the desclist match being used
|
|
|
|
|
|
* instead.
|
|
|
|
|
|
*/
|
|
|
|
|
|
void did_it_rlevel
|
|
|
|
|
|
(
|
|
|
|
|
|
dbref player,
|
|
|
|
|
|
dbref thing,
|
2006-11-27 05:50:23 +00:00
|
|
|
|
int what,
|
2007-03-14 07:40:08 +00:00
|
|
|
|
const UTF8 *def,
|
2006-11-27 05:50:23 +00:00
|
|
|
|
int owhat,
|
2007-03-14 07:40:08 +00:00
|
|
|
|
const UTF8 *odef,
|
2006-11-27 05:50:23 +00:00
|
|
|
|
int awhat,
|
|
|
|
|
|
int ctrl_flags,
|
2007-06-18 13:50:35 -07:00
|
|
|
|
const UTF8 *args[],
|
2006-11-27 05:50:23 +00:00
|
|
|
|
int nargs
|
2006-09-01 22:59:23 +00:00
|
|
|
|
)
|
|
|
|
|
|
{
|
2018-06-03 09:31:21 +00:00
|
|
|
|
if (alarm_clock.alarmed)
|
2007-10-09 11:41:14 -07:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UTF8 *d, *buff, *act, *charges, *bp;
|
|
|
|
|
|
dbref aowner;
|
2026-07-28 19:34:54 -06:00
|
|
|
|
int64_t num;
|
|
|
|
|
|
int aflags;
|
2007-10-09 10:41:18 -07:00
|
|
|
|
int i;
|
|
|
|
|
|
bool found_a_desc;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
2018-10-03 17:54:51 +00:00
|
|
|
|
reg_ref **preserve = nullptr;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
bool need_pres = false;
|
|
|
|
|
|
|
|
|
|
|
|
// Message to player.
|
|
|
|
|
|
//
|
2007-10-09 10:41:18 -07:00
|
|
|
|
if (0 < what)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
// Get description list.
|
|
|
|
|
|
//
|
2007-10-09 10:41:18 -07:00
|
|
|
|
DESC_INFO *desclist = desclist_match(player, thing);
|
|
|
|
|
|
found_a_desc = false;
|
|
|
|
|
|
for (i = 0; i < desclist->n; i++)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
// Ok, if it's A_DESC, we need to check against A_IDESC.
|
|
|
|
|
|
//
|
|
|
|
|
|
if ( A_IDESC == what
|
2007-10-09 10:41:18 -07:00
|
|
|
|
&& A_DESC == desclist->descs[i])
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
d = atr_pget(thing, A_IDESC, &aowner, &aflags);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2007-10-09 10:41:18 -07:00
|
|
|
|
d = atr_pget(thing, desclist->descs[i], &aowner, &aflags);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
2006-11-27 05:50:23 +00:00
|
|
|
|
|
2007-10-09 11:41:14 -07:00
|
|
|
|
if ('\0' != d[0])
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
// No need for the 'def' message.
|
|
|
|
|
|
//
|
2007-10-09 10:41:18 -07:00
|
|
|
|
found_a_desc = true;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (!need_pres)
|
|
|
|
|
|
{
|
|
|
|
|
|
need_pres = true;
|
2006-11-05 13:43:16 +00:00
|
|
|
|
preserve = PushRegisters(MAX_GLOBAL_REGS);
|
|
|
|
|
|
save_global_regs(preserve);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
buff = bp = alloc_lbuf("did_it.1");
|
2026-03-07 19:57:24 -07:00
|
|
|
|
mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player,
|
2007-01-28 02:08:08 +00:00
|
|
|
|
AttrTrace(aflags, EV_EVAL|EV_FIGNORE|EV_TOP),
|
2006-09-06 04:52:56 +00:00
|
|
|
|
args, nargs);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
*bp = '\0';
|
|
|
|
|
|
|
2007-10-09 10:41:18 -07:00
|
|
|
|
if ( A_HTDESC == desclist->descs[i]
|
2006-09-01 22:59:23 +00:00
|
|
|
|
&& Html(player))
|
|
|
|
|
|
{
|
2007-03-14 22:33:04 +00:00
|
|
|
|
safe_str(T("\r\n"), buff, &bp);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
*bp = '\0';
|
|
|
|
|
|
notify_html(player, buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
notify(player, buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
free_lbuf(buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
free_lbuf(d);
|
|
|
|
|
|
}
|
2006-11-27 05:50:23 +00:00
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (!found_a_desc)
|
|
|
|
|
|
{
|
|
|
|
|
|
// No desc found... try the default desc (again).
|
|
|
|
|
|
// A_DESC or A_HTDESC... the worst case we look for it twice.
|
|
|
|
|
|
//
|
|
|
|
|
|
d = atr_pget(thing, what, &aowner, &aflags);
|
2007-10-09 11:41:14 -07:00
|
|
|
|
if ('\0' != d[0])
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
// No need for the 'def' message
|
|
|
|
|
|
//
|
2007-10-09 10:41:18 -07:00
|
|
|
|
found_a_desc = true;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (!need_pres)
|
|
|
|
|
|
{
|
|
|
|
|
|
need_pres = true;
|
2006-11-05 13:43:16 +00:00
|
|
|
|
preserve = PushRegisters(MAX_GLOBAL_REGS);
|
|
|
|
|
|
save_global_regs(preserve);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
buff = bp = alloc_lbuf("did_it.1");
|
2026-03-07 19:57:24 -07:00
|
|
|
|
mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player,
|
2007-01-28 02:08:08 +00:00
|
|
|
|
AttrTrace(aflags, EV_EVAL|EV_FIGNORE|EV_TOP),
|
2006-09-06 04:52:56 +00:00
|
|
|
|
args, nargs);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
*bp = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
if ( A_HTDESC == what
|
|
|
|
|
|
&& Html(player))
|
|
|
|
|
|
{
|
2007-03-14 22:33:04 +00:00
|
|
|
|
safe_str(T("\r\n"), buff, &bp);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
*bp = '\0';
|
|
|
|
|
|
notify_html(player, buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
notify(player, buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
free_lbuf(buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (def)
|
|
|
|
|
|
{
|
|
|
|
|
|
notify(player, def);
|
|
|
|
|
|
}
|
|
|
|
|
|
free_lbuf(d);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ( what < 0
|
|
|
|
|
|
&& def)
|
|
|
|
|
|
{
|
|
|
|
|
|
notify(player, def);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isPlayer(thing))
|
|
|
|
|
|
{
|
2007-03-14 22:33:04 +00:00
|
|
|
|
d = atr_pget(mudconf.master_room, get_atr(T("ASSET_DESC")), &aowner, &aflags);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (*d)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!need_pres)
|
|
|
|
|
|
{
|
|
|
|
|
|
need_pres = true;
|
2006-11-05 13:43:16 +00:00
|
|
|
|
preserve = PushRegisters(MAX_GLOBAL_REGS);
|
|
|
|
|
|
save_global_regs(preserve);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
buff = bp = alloc_lbuf("did_it.1");
|
2026-03-07 19:57:24 -07:00
|
|
|
|
mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player,
|
2007-01-28 02:08:08 +00:00
|
|
|
|
AttrTrace(aflags, EV_EVAL|EV_FIGNORE|EV_TOP),
|
2006-09-06 04:52:56 +00:00
|
|
|
|
args, nargs);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
*bp = '\0';
|
|
|
|
|
|
notify(player, buff);
|
|
|
|
|
|
free_lbuf(buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
free_lbuf(d);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Message to neighbors.
|
|
|
|
|
|
//
|
2007-10-09 11:41:14 -07:00
|
|
|
|
dbref loc;
|
2006-11-27 04:06:15 +00:00
|
|
|
|
if ( 0 < owhat
|
2006-09-01 22:59:23 +00:00
|
|
|
|
&& Has_location(player)
|
|
|
|
|
|
&& Good_obj(loc = Location(player)))
|
|
|
|
|
|
{
|
|
|
|
|
|
d = atr_pget(thing, owhat, &aowner, &aflags);
|
|
|
|
|
|
if (*d)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!need_pres)
|
|
|
|
|
|
{
|
|
|
|
|
|
need_pres = true;
|
2006-11-05 13:43:16 +00:00
|
|
|
|
preserve = PushRegisters(MAX_GLOBAL_REGS);
|
|
|
|
|
|
save_global_regs(preserve);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
buff = bp = alloc_lbuf("did_it.2");
|
2026-03-07 19:57:24 -07:00
|
|
|
|
mux_exec(d, LBUF_SIZE-1, buff, &bp, thing, thing, player,
|
2007-01-28 02:08:08 +00:00
|
|
|
|
AttrTrace(aflags, EV_EVAL|EV_FIGNORE|EV_TOP),
|
2006-09-06 04:52:56 +00:00
|
|
|
|
args, nargs);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
*bp = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
if (*buff)
|
|
|
|
|
|
{
|
2006-11-27 05:50:23 +00:00
|
|
|
|
if (aflags & AF_NONAME)
|
|
|
|
|
|
{
|
|
|
|
|
|
notify_except2_rlevel2(loc, player, player, thing, buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
notify_except2_rlevel2(loc, player, player, thing,
|
2008-12-27 18:37:01 -08:00
|
|
|
|
tprintf(T("%s %s"), Name(player), buff));
|
2006-11-27 05:50:23 +00:00
|
|
|
|
}
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
free_lbuf(buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (odef)
|
|
|
|
|
|
{
|
2006-11-27 05:50:23 +00:00
|
|
|
|
if (ctrl_flags & VERB_NONAME)
|
|
|
|
|
|
{
|
|
|
|
|
|
notify_except2_rlevel2(loc, player, player, thing, odef);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
notify_except2_rlevel2(loc, player, player, thing,
|
2008-12-27 18:37:01 -08:00
|
|
|
|
tprintf(T("%s %s"), Name(player), odef));
|
2006-11-27 05:50:23 +00:00
|
|
|
|
}
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
free_lbuf(d);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ( owhat < 0
|
|
|
|
|
|
&& odef
|
|
|
|
|
|
&& Has_location(player)
|
|
|
|
|
|
&& Good_obj(loc = Location(player)))
|
|
|
|
|
|
{
|
2006-11-27 05:50:23 +00:00
|
|
|
|
if (ctrl_flags & VERB_NONAME)
|
|
|
|
|
|
{
|
|
|
|
|
|
notify_except2_rlevel2(loc, player, player, thing, odef);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
notify_except2_rlevel2(loc, player, player, thing,
|
2008-12-27 18:37:01 -08:00
|
|
|
|
tprintf(T("%s %s"), Name(player), odef));
|
2006-11-27 05:50:23 +00:00
|
|
|
|
}
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If we preserved the state of the global registers, restore them.
|
|
|
|
|
|
//
|
|
|
|
|
|
if (need_pres)
|
|
|
|
|
|
{
|
2006-11-05 13:43:16 +00:00
|
|
|
|
restore_global_regs(preserve);
|
|
|
|
|
|
PopRegisters(preserve, MAX_GLOBAL_REGS);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Do the action attribute.
|
|
|
|
|
|
//
|
|
|
|
|
|
if ( awhat > 0
|
|
|
|
|
|
&& IsReal(thing, player))
|
|
|
|
|
|
{
|
|
|
|
|
|
act = atr_pget(thing, awhat, &aowner, &aflags);
|
|
|
|
|
|
if (*act != '\0')
|
|
|
|
|
|
{
|
|
|
|
|
|
charges = atr_pget(thing, A_CHARGES, &aowner, &aflags);
|
|
|
|
|
|
if (*charges)
|
|
|
|
|
|
{
|
2026-07-28 19:34:54 -06:00
|
|
|
|
// int64_t, not int (#1402).
|
|
|
|
|
|
//
|
fix(win32): migrate the remaining mux_atol callers to mux_atoi64 (#1373)
Completes the sweep the issue called for. mux_atol returns long, which
is 32-bit on LLP64, so every caller silently truncated on Windows. Two
of those were real defects (the truthiness family and cf_size, fixed in
the preceding commits); the rest were latent, waiting for a value large
enough to matter.
Rather than audit 290 sites for whether each can reach 2^31 today, use
the 64-bit parser everywhere and remove the class. A dbref cannot
overflow now, but nothing stops a later caller passing that same site a
timestamp or a byte count.
Pure 1:1 substitution: 285 lines changed, and every removed line
contained mux_atol while every added line contains mux_atoi64. No
control flow, no types, no behaviour beyond the wider parse.
This is a NO-OP on LP64 -- long is already 64-bit on Linux and macOS, so
the generated code there is unchanged. It only widens the parse on
Windows. Narrowing destinations are unaffected either way: `int x =
mux_atoi64(s)` truncates exactly as `int x = mux_atol(s)` did, on both
models.
Left alone: mux_atol itself in mathutil, its declaration, and three
comments that name it. Callers that genuinely want 32-bit semantics can
still ask for them; none appear to.
Verified on Windows: full solution builds clean with no new warnings,
smoke is 1418 passed / 16 failed / 0 crashes / 306 of 306 dispatched --
identical to before the sweep, with the same 16 build-configuration
failures (exp3 module not loaded, hmac/digest behind UNIX_DIGEST).
Spot checks after the change: the boolean family returns 1 for multiples
of 2^32, cf_size round-trips 3000000000 and still reads -1 as unlimited,
and arithmetic, string and list functions are unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-26 10:03:45 -06:00
|
|
|
|
num = mux_atoi64(charges);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (num > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
buff = alloc_sbuf("did_it.charges");
|
2026-07-28 19:34:54 -06:00
|
|
|
|
mux_i64toa(num - 1, buff);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
atr_add_raw(thing, A_CHARGES, buff);
|
|
|
|
|
|
free_sbuf(buff);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
buff = atr_pget(thing, A_RUNOUT, &aowner, &aflags);
|
|
|
|
|
|
if (*buff != '\0')
|
|
|
|
|
|
{
|
|
|
|
|
|
free_lbuf(act);
|
|
|
|
|
|
act = buff;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
free_lbuf(act);
|
|
|
|
|
|
free_lbuf(buff);
|
|
|
|
|
|
free_lbuf(charges);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
free_lbuf(charges);
|
|
|
|
|
|
|
|
|
|
|
|
CLinearTimeAbsolute lta;
|
2006-09-06 05:46:01 +00:00
|
|
|
|
wait_que(thing, player, player, AttrTrace(aflags, 0), false, lta,
|
2006-11-05 13:43:16 +00:00
|
|
|
|
NOTHING, 0,
|
|
|
|
|
|
act,
|
|
|
|
|
|
nargs, args,
|
|
|
|
|
|
mudstate.global_regs);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
free_lbuf(act);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2006-11-27 05:25:42 +00:00
|
|
|
|
#endif // REALITY_LVLS
|