2007-01-03 03:11:53 +00:00
|
|
|
|
/*! \file help.cpp
|
|
|
|
|
|
* \brief In-game help system.
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
|
|
|
|
|
#include "copyright.h"
|
|
|
|
|
|
#include "autoconf.h"
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
#include "externs.h"
|
|
|
|
|
|
|
|
|
|
|
|
// Pointers to this struct is what gets stored in the help_htab's.
|
|
|
|
|
|
//
|
|
|
|
|
|
struct help_entry
|
|
|
|
|
|
{
|
2006-12-28 07:48:05 +00:00
|
|
|
|
size_t pos; // Position in file.
|
2018-10-03 17:54:51 +00:00
|
|
|
|
UTF8 *key; // The key this is stored under. nullptr if this is an
|
2006-12-28 07:48:05 +00:00
|
|
|
|
// automatically generated initial substring alias.
|
2006-09-01 22:59:23 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void helpindex_clean(int iHelpfile)
|
|
|
|
|
|
{
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
StringPtrMap *htab = mudstate.aHelpDesc[iHelpfile].ht;
|
2018-10-03 17:54:51 +00:00
|
|
|
|
if (nullptr == htab)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2006-12-29 00:11:46 +00:00
|
|
|
|
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
for (auto &[key, val] : *htab)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
struct help_entry *htab_entry = static_cast<struct help_entry *>(val);
|
2006-12-28 07:48:05 +00:00
|
|
|
|
if (htab_entry->key)
|
|
|
|
|
|
{
|
|
|
|
|
|
MEMFREE(htab_entry->key);
|
2018-10-03 17:54:51 +00:00
|
|
|
|
htab_entry->key = nullptr;
|
2006-12-28 07:48:05 +00:00
|
|
|
|
}
|
2006-10-02 12:21:20 +00:00
|
|
|
|
delete htab_entry;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
delete mudstate.aHelpDesc[iHelpfile].ht;
|
2018-10-03 17:54:51 +00:00
|
|
|
|
mudstate.aHelpDesc[iHelpfile].ht = nullptr;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int lineno;
|
|
|
|
|
|
static int ntopics;
|
|
|
|
|
|
static FILE *rfp;
|
|
|
|
|
|
|
Convert all static scratch buffers to thread_local
43 static scratch-buffer arrays across 21 files (5 in mux/src, 38 in
mux/modules/) changed from `static` to `thread_local`. Under the
current single-threaded evaluator this is a zero-behavior-change swap
— `thread_local` storage has the same lifetime and zero-allocation
properties as `static` — but each thread gets its own copy, which
makes these functions safe for a future multi-threaded evaluator
without any locking.
Read-only constant tables (`aRadix64`, `aRadixPenn36`,
`aRadixPenn64`, `Empty`) left as `static` because they are immutable
shared data.
Affected areas:
net.cpp — queue_string co_buf, trimmed_site, dump_users NameField
signals.cpp — signal_desc
stubslave.cpp — Stub_PipePump
attrcache.cpp — sqlite_attr_buf
boolexp.cpp — parsestore
command.cpp — preserve_cmd, SpaceCompressCommand, LowerCaseCommand
comsys.cpp — NewTitle, Buffer, temp
db.cpp — tbuff, Buffer (x2)
flags.cpp — buff
funceval.cpp — textbuff
functions.cpp — TimeBuffer64, TimeBuffer80, Buffer
help.cpp — Line, Buffer
mail.cpp — aFolders, Buffer, res, szFittedMailAliasDesc
match.cpp — buffer
player.cpp — szSalt, buf (x2), buff
plusemail.cpp — buf
predicates.cpp — Buf (x2), pName
session.cpp — szFittedDoing
set.cpp — pRestrictedKeyText
unparse.cpp — buf, boolexp_buf
mail_mod.cpp — result, res, buf
All 21 files verified with g++ -std=c++17 -fsyntax-only.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 17:21:14 -06:00
|
|
|
|
thread_local UTF8 Line[LBUF_SIZE];
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
|
|
|
|
|
static void HelpIndex_Start(FILE *fp)
|
|
|
|
|
|
{
|
|
|
|
|
|
lineno = 0;
|
|
|
|
|
|
ntopics = 0;
|
|
|
|
|
|
rfp = fp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-03-14 00:55:08 +00:00
|
|
|
|
static bool HelpIndex_Read(size_t *pPos, size_t *nTopic, UTF8 pTopic[TOPIC_NAME_LEN+1])
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2006-12-28 08:55:44 +00:00
|
|
|
|
size_t nLine = 0;
|
2006-12-28 08:14:58 +00:00
|
|
|
|
|
2006-12-29 00:11:46 +00:00
|
|
|
|
while ( 0 == nLine
|
|
|
|
|
|
|| '&' != Line[0])
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2026-03-03 18:39:35 -07:00
|
|
|
|
if (fgets(reinterpret_cast<char *>(Line), LBUF_SIZE-2, rfp) == nullptr)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2006-12-29 05:07:50 +00:00
|
|
|
|
*pPos = 0L;
|
|
|
|
|
|
*nTopic = 0;
|
2006-12-28 08:55:44 +00:00
|
|
|
|
return false;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
2006-12-28 08:55:44 +00:00
|
|
|
|
++lineno;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
2026-03-03 18:39:35 -07:00
|
|
|
|
nLine = strlen(reinterpret_cast<char *>(Line));
|
2007-01-14 07:48:44 +00:00
|
|
|
|
*pPos += nLine;
|
2006-12-29 00:11:46 +00:00
|
|
|
|
if ( 0 < nLine
|
|
|
|
|
|
&& '\n' != Line[nLine - 1])
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2008-12-27 18:37:01 -08:00
|
|
|
|
Log.tinyprintf(T("HelpIndex_Read, line %d: line too long" ENDLINE), lineno);
|
2006-12-28 08:55:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
2006-12-28 08:55:44 +00:00
|
|
|
|
++ntopics;
|
2007-03-14 00:55:08 +00:00
|
|
|
|
UTF8 *topic = Line + 1;
|
2006-12-29 00:11:46 +00:00
|
|
|
|
while ( ' ' == *topic
|
|
|
|
|
|
|| '\t' == *topic
|
|
|
|
|
|
|| '\r' == *topic)
|
2006-12-28 08:55:44 +00:00
|
|
|
|
{
|
|
|
|
|
|
topic++;
|
|
|
|
|
|
}
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
2007-03-14 00:55:08 +00:00
|
|
|
|
UTF8 *s = topic;
|
2006-12-28 08:55:44 +00:00
|
|
|
|
size_t i = 0;
|
2006-12-29 00:11:46 +00:00
|
|
|
|
while ( '\n' != *s
|
|
|
|
|
|
&& '\r' != *s
|
|
|
|
|
|
&& '\0' != *s
|
2006-12-28 08:55:44 +00:00
|
|
|
|
&& i < TOPIC_NAME_LEN)
|
|
|
|
|
|
{
|
2006-12-29 00:11:46 +00:00
|
|
|
|
if ( ' ' != *s
|
2006-12-28 08:55:44 +00:00
|
|
|
|
|| ( 0 < i
|
2006-12-29 05:07:50 +00:00
|
|
|
|
&& ' ' != pTopic[i-1]))
|
2006-12-28 08:55:44 +00:00
|
|
|
|
{
|
2006-12-29 05:07:50 +00:00
|
|
|
|
pTopic[i++] = *s;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
2006-12-28 08:55:44 +00:00
|
|
|
|
s++;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
2006-12-29 05:07:50 +00:00
|
|
|
|
*nTopic = i;
|
|
|
|
|
|
pTopic[i] = '\0';
|
2006-12-28 08:55:44 +00:00
|
|
|
|
return true;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void HelpIndex_End(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
lineno = 0;
|
|
|
|
|
|
ntopics = 0;
|
2018-10-03 17:54:51 +00:00
|
|
|
|
rfp = nullptr;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2006-12-29 05:07:50 +00:00
|
|
|
|
static void helpindex_read(int iHelpfile)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
helpindex_clean(iHelpfile);
|
|
|
|
|
|
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
mudstate.aHelpDesc[iHelpfile].ht = new StringPtrMap;
|
|
|
|
|
|
StringPtrMap *htab = mudstate.aHelpDesc[iHelpfile].ht;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
2007-03-14 00:55:08 +00:00
|
|
|
|
UTF8 szTextFilename[SBUF_SIZE+8];
|
2008-12-27 18:37:01 -08:00
|
|
|
|
mux_sprintf(szTextFilename, sizeof(szTextFilename), T("%s.txt"),
|
2006-12-29 00:11:46 +00:00
|
|
|
|
mudstate.aHelpDesc[iHelpfile].pBaseFilename);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
|
|
|
|
|
FILE *fp;
|
2007-03-14 22:33:04 +00:00
|
|
|
|
if (!mux_fopen(&fp, szTextFilename, T("rb")))
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
STARTLOG(LOG_PROBLEMS, "HLP", "RINDX");
|
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 p = LBuf_Src("helpindex_read.LOG");
|
nls: mark move/walk/help/guest/quota/power notify prose with M_() (#1670)
Phase 3 coverage slice. Player and staff notify paths that still used
T() (cast-only) now use M_() so they extract into the catalogue:
move arrive/leave, get/drop, teleport failures, home
walk destination, blocked, patrol
help missing topic, match list, file errors
guest busy/create errors, listing total
quota Quota/Used display templates
powers Power not found, @power echo, Powers: header
session Poll / Doing
Attribute names, flag/power registry keys, logs, HTML, and softcode
machine tokens stay T()/S_(). Regenerates pot (670 -> 704) and xx.po.
2026-07-27 23:30:41 -06:00
|
|
|
|
mux_sprintf(p.get(), LBUF_SIZE, M_("Can’t open %s for reading."), szTextFilename);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
log_text(p);
|
|
|
|
|
|
ENDLOG;
|
2006-12-29 05:07:50 +00:00
|
|
|
|
return;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
2006-12-29 05:07:50 +00:00
|
|
|
|
size_t pos = 0;
|
|
|
|
|
|
size_t nTopicOriginal = 0;
|
2007-03-14 00:55:08 +00:00
|
|
|
|
UTF8 topic[TOPIC_NAME_LEN+1];
|
2006-12-29 05:07:50 +00:00
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
HelpIndex_Start(fp);
|
2006-12-29 05:07:50 +00:00
|
|
|
|
while (HelpIndex_Read(&pos, &nTopicOriginal, topic))
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
// Convert the entry to all lowercase letters and add all leftmost
|
|
|
|
|
|
// substrings.
|
|
|
|
|
|
//
|
|
|
|
|
|
// Topic names which appear earlier in the help file have priority
|
|
|
|
|
|
// over topics names which appear later in the help file. That is,
|
|
|
|
|
|
// we do not associate prefixes with this topic if they have already
|
|
|
|
|
|
// been used on a previous topic.
|
|
|
|
|
|
//
|
2007-03-25 17:01:06 +00:00
|
|
|
|
size_t nCased;
|
|
|
|
|
|
UTF8 *pCased = mux_strlwr(topic, nCased);
|
|
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
bool bOriginal = true; // First is the longest.
|
|
|
|
|
|
|
2007-03-25 17:01:06 +00:00
|
|
|
|
for (size_t nTopic = nCased; 0 < nTopic; nTopic--)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2006-12-29 05:07:50 +00:00
|
|
|
|
// Avoid adding any entries with a trailing space.
|
|
|
|
|
|
//
|
2007-03-25 17:01:06 +00:00
|
|
|
|
if (mux_isspace(pCased[nTopic-1]))
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2006-10-02 12:21:20 +00:00
|
|
|
|
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
std::vector<UTF8> vkey(pCased, pCased + nTopic);
|
|
|
|
|
|
auto it = htab->find(vkey);
|
|
|
|
|
|
struct help_entry *htab_entry = (it != htab->end())
|
|
|
|
|
|
? static_cast<struct help_entry *>(it->second) : nullptr;
|
2006-12-28 07:48:05 +00:00
|
|
|
|
|
|
|
|
|
|
if (htab_entry)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!bOriginal)
|
|
|
|
|
|
{
|
2006-12-28 07:51:01 +00:00
|
|
|
|
continue;
|
2006-12-28 07:48:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
htab->erase(it);
|
2006-12-28 08:14:58 +00:00
|
|
|
|
|
2006-12-28 07:48:05 +00:00
|
|
|
|
if (htab_entry->key)
|
|
|
|
|
|
{
|
|
|
|
|
|
MEMFREE(htab_entry->key);
|
2018-10-03 17:54:51 +00:00
|
|
|
|
htab_entry->key = nullptr;
|
2008-12-27 18:37:01 -08:00
|
|
|
|
Log.tinyprintf(T("helpindex_read: duplicate %s entries for %s" ENDLINE),
|
2007-03-25 17:01:06 +00:00
|
|
|
|
szTextFilename, pCased);
|
2006-12-28 07:51:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
delete htab_entry;
|
2018-10-03 17:54:51 +00:00
|
|
|
|
htab_entry = nullptr;
|
2006-12-28 07:51:01 +00:00
|
|
|
|
}
|
2006-12-28 07:48:05 +00:00
|
|
|
|
|
2006-10-02 12:21:20 +00:00
|
|
|
|
try
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2006-10-02 12:21:20 +00:00
|
|
|
|
htab_entry = new struct help_entry;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
2006-10-02 12:21:20 +00:00
|
|
|
|
catch (...)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2006-10-02 12:21:20 +00:00
|
|
|
|
; // Nothing.
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-12-28 07:48:05 +00:00
|
|
|
|
if (htab_entry)
|
2006-10-02 12:21:20 +00:00
|
|
|
|
{
|
2006-12-28 07:48:05 +00:00
|
|
|
|
htab_entry->pos = pos;
|
2018-10-03 17:54:51 +00:00
|
|
|
|
htab_entry->key = bOriginal ? StringCloneLen(pCased, nTopic) : nullptr;
|
2006-10-02 12:21:20 +00:00
|
|
|
|
bOriginal = false;
|
|
|
|
|
|
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
htab->emplace(vkey, htab_entry);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
HelpIndex_End();
|
2006-12-29 05:07:50 +00:00
|
|
|
|
|
2026-03-20 06:07:24 -06:00
|
|
|
|
mux_fclose(fp);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void helpindex_load(dbref player)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < mudstate.nHelpDesc; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
helpindex_read(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
if ( player != NOTHING
|
|
|
|
|
|
&& !Quiet(player))
|
|
|
|
|
|
{
|
2026-07-27 11:50:31 +00:00
|
|
|
|
notify(player, M_("Cache for help indexes refreshed."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void helpindex_init(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
helpindex_load(NOTHING);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
static const UTF8 *MakeCanonicalTopicName(const UTF8 *topic_arg, size_t &nTopic)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
Convert all static scratch buffers to thread_local
43 static scratch-buffer arrays across 21 files (5 in mux/src, 38 in
mux/modules/) changed from `static` to `thread_local`. Under the
current single-threaded evaluator this is a zero-behavior-change swap
— `thread_local` storage has the same lifetime and zero-allocation
properties as `static` — but each thread gets its own copy, which
makes these functions safe for a future multi-threaded evaluator
without any locking.
Read-only constant tables (`aRadix64`, `aRadixPenn36`,
`aRadixPenn64`, `Empty`) left as `static` because they are immutable
shared data.
Affected areas:
net.cpp — queue_string co_buf, trimmed_site, dump_users NameField
signals.cpp — signal_desc
stubslave.cpp — Stub_PipePump
attrcache.cpp — sqlite_attr_buf
boolexp.cpp — parsestore
command.cpp — preserve_cmd, SpaceCompressCommand, LowerCaseCommand
comsys.cpp — NewTitle, Buffer, temp
db.cpp — tbuff, Buffer (x2)
flags.cpp — buff
funceval.cpp — textbuff
functions.cpp — TimeBuffer64, TimeBuffer80, Buffer
help.cpp — Line, Buffer
mail.cpp — aFolders, Buffer, res, szFittedMailAliasDesc
match.cpp — buffer
player.cpp — szSalt, buf (x2), buff
plusemail.cpp — buf
predicates.cpp — Buf (x2), pName
session.cpp — szFittedDoing
set.cpp — pRestrictedKeyText
unparse.cpp — buf, boolexp_buf
mail_mod.cpp — result, res, buf
All 21 files verified with g++ -std=c++17 -fsyntax-only.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 17:21:14 -06:00
|
|
|
|
thread_local UTF8 Buffer[LBUF_SIZE];
|
2007-03-25 17:01:06 +00:00
|
|
|
|
|
2007-03-14 00:55:08 +00:00
|
|
|
|
const UTF8 *topic;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (topic_arg[0] == '\0')
|
|
|
|
|
|
{
|
2007-03-14 22:33:04 +00:00
|
|
|
|
topic = T("help");
|
2007-03-25 17:01:06 +00:00
|
|
|
|
nTopic = 4;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2007-03-25 17:01:06 +00:00
|
|
|
|
topic = mux_strlwr(topic_arg, nTopic);
|
|
|
|
|
|
memcpy(Buffer, topic, nTopic+1);
|
|
|
|
|
|
topic = Buffer;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
return topic;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
static void ReportMatchedTopics(dbref executor, const UTF8 *topic, StringPtrMap *htab)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
bool matched = false;
|
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 topic_list = LBuf_Src("help_write");
|
|
|
|
|
|
UTF8 *buffp = topic_list.get();
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
for (auto &[key, val] : *htab)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
struct help_entry *htab_entry = static_cast<struct help_entry *>(val);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
mudstate.wild_invk_ctr = 0;
|
2006-12-28 07:48:05 +00:00
|
|
|
|
if ( htab_entry->key
|
2006-09-01 22:59:23 +00:00
|
|
|
|
&& quick_wild(topic, htab_entry->key))
|
|
|
|
|
|
{
|
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
|
|
|
|
matched = true;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
safe_str(htab_entry->key, topic_list, &buffp);
|
|
|
|
|
|
safe_chr(' ', topic_list, &buffp);
|
|
|
|
|
|
safe_chr(' ', topic_list, &buffp);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2006-12-29 05:07:50 +00:00
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (!matched)
|
|
|
|
|
|
{
|
nls: mark move/walk/help/guest/quota/power notify prose with M_() (#1670)
Phase 3 coverage slice. Player and staff notify paths that still used
T() (cast-only) now use M_() so they extract into the catalogue:
move arrive/leave, get/drop, teleport failures, home
walk destination, blocked, patrol
help missing topic, match list, file errors
guest busy/create errors, listing total
quota Quota/Used display templates
powers Power not found, @power echo, Powers: header
session Poll / Doing
Attribute names, flag/power registry keys, logs, HTML, and softcode
machine tokens stay T()/S_(). Regenerates pot (670 -> 704) and xx.po.
2026-07-27 23:30:41 -06:00
|
|
|
|
notify(executor, tprintf(M_("No entry for ‘%s’."), topic));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
nls: mark move/walk/help/guest/quota/power notify prose with M_() (#1670)
Phase 3 coverage slice. Player and staff notify paths that still used
T() (cast-only) now use M_() so they extract into the catalogue:
move arrive/leave, get/drop, teleport failures, home
walk destination, blocked, patrol
help missing topic, match list, file errors
guest busy/create errors, listing total
quota Quota/Used display templates
powers Power not found, @power echo, Powers: header
session Poll / Doing
Attribute names, flag/power registry keys, logs, HTML, and softcode
machine tokens stay T()/S_(). Regenerates pot (670 -> 704) and xx.po.
2026-07-27 23:30:41 -06:00
|
|
|
|
notify(executor, tprintf(M_("Here are the entries which match ‘%s’:"), topic));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
*buffp = '\0';
|
|
|
|
|
|
notify(executor, topic_list);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool ReportTopic(dbref executor, struct help_entry *htab_entry, int iHelpfile,
|
2007-03-14 00:55:08 +00:00
|
|
|
|
UTF8 *result)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-03-14 00:55:08 +00:00
|
|
|
|
UTF8 szTextFilename[SBUF_SIZE+8];
|
2008-12-27 18:37:01 -08:00
|
|
|
|
mux_sprintf(szTextFilename, sizeof(szTextFilename), T("%s.txt"),
|
2006-12-29 05:07:50 +00:00
|
|
|
|
mudstate.aHelpDesc[iHelpfile].pBaseFilename);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
|
|
|
|
|
size_t offset = htab_entry->pos;
|
|
|
|
|
|
FILE *fp;
|
2007-03-14 22:33:04 +00:00
|
|
|
|
if (!mux_fopen(&fp, szTextFilename, T("rb")))
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
STARTLOG(LOG_PROBLEMS, "HLP", "OPEN");
|
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 line = LBuf_Src("ReportTopic.open");
|
nls: mark move/walk/help/guest/quota/power notify prose with M_() (#1670)
Phase 3 coverage slice. Player and staff notify paths that still used
T() (cast-only) now use M_() so they extract into the catalogue:
move arrive/leave, get/drop, teleport failures, home
walk destination, blocked, patrol
help missing topic, match list, file errors
guest busy/create errors, listing total
quota Quota/Used display templates
powers Power not found, @power echo, Powers: header
session Poll / Doing
Attribute names, flag/power registry keys, logs, HTML, and softcode
machine tokens stay T()/S_(). Regenerates pot (670 -> 704) and xx.po.
2026-07-27 23:30:41 -06:00
|
|
|
|
mux_sprintf(line.get(), LBUF_SIZE, M_("Can’t open %s for reading."), szTextFilename);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
log_text(line);
|
|
|
|
|
|
ENDLOG;
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (fseek(fp, static_cast<long>(offset), 0) < 0L)
|
|
|
|
|
|
{
|
|
|
|
|
|
STARTLOG(LOG_PROBLEMS, "HLP", "SEEK");
|
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 line = LBuf_Src("ReportTopic.seek");
|
nls: mark move/walk/help/guest/quota/power notify prose with M_() (#1670)
Phase 3 coverage slice. Player and staff notify paths that still used
T() (cast-only) now use M_() so they extract into the catalogue:
move arrive/leave, get/drop, teleport failures, home
walk destination, blocked, patrol
help missing topic, match list, file errors
guest busy/create errors, listing total
quota Quota/Used display templates
powers Power not found, @power echo, Powers: header
session Poll / Doing
Attribute names, flag/power registry keys, logs, HTML, and softcode
machine tokens stay T()/S_(). Regenerates pot (670 -> 704) and xx.po.
2026-07-27 23:30:41 -06:00
|
|
|
|
mux_sprintf(line.get(), LBUF_SIZE, M_("Seek error in file %s."), szTextFilename);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
log_text(line);
|
|
|
|
|
|
ENDLOG;
|
2026-03-20 06:07:24 -06:00
|
|
|
|
mux_fclose(fp);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
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 line = LBuf_Src("ReportTopic");
|
2007-03-14 00:55:08 +00:00
|
|
|
|
UTF8 *bp = result;
|
2006-12-28 08:55:44 +00:00
|
|
|
|
bool bInTopicAliases = true;
|
2006-09-01 22:59:23 +00:00
|
|
|
|
for (;;)
|
|
|
|
|
|
{
|
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
|
|
|
|
if ( fgets(reinterpret_cast<char *>(line.get()), LBUF_SIZE - 2, fp) == nullptr
|
2006-12-29 00:11:46 +00:00
|
|
|
|
|| '\0' == line[0])
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-12-29 00:11:46 +00:00
|
|
|
|
if ('&' == line[0])
|
2006-12-28 08:55:44 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (bInTopicAliases)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bInTopicAliases = false;
|
|
|
|
|
|
|
2006-09-07 23:21:15 +00:00
|
|
|
|
// Transform LF into CRLF to be telnet-friendly.
|
|
|
|
|
|
//
|
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
|
|
|
|
size_t len = strlen(reinterpret_cast<char *>(line.get()));
|
2006-09-07 23:21:15 +00:00
|
|
|
|
if ( 0 < len
|
|
|
|
|
|
&& '\n' == line[len-1]
|
|
|
|
|
|
&& ( 1 == len
|
|
|
|
|
|
|| '\r' != line[len-2]))
|
|
|
|
|
|
{
|
|
|
|
|
|
line[len-1] = '\r';
|
|
|
|
|
|
line[len ] = '\n';
|
2007-04-09 21:55:57 +00:00
|
|
|
|
line[++len] = '\0';
|
2006-09-07 23:21:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
bool bEval = mudstate.aHelpDesc[iHelpfile].bEval;
|
|
|
|
|
|
if (bEval)
|
|
|
|
|
|
{
|
2007-09-25 13:47:09 -07:00
|
|
|
|
dbref executor_for_help = executor;
|
|
|
|
|
|
if (Good_obj(mudconf.help_executor))
|
2007-09-21 21:44:13 +00:00
|
|
|
|
{
|
2007-09-25 13:47:09 -07:00
|
|
|
|
executor_for_help = mudconf.help_executor;
|
2007-09-21 21:44:13 +00:00
|
|
|
|
}
|
2026-03-07 19:57:24 -07:00
|
|
|
|
mux_exec(line, len, result, &bp, executor_for_help, executor, executor,
|
2018-10-03 17:54:51 +00:00
|
|
|
|
EV_NO_COMPRESS | EV_FIGNORE | EV_EVAL, nullptr, 0);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
safe_str(line, result, &bp);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2006-09-07 23:01:24 +00:00
|
|
|
|
|
|
|
|
|
|
// Zap trailing CRLF if present.
|
|
|
|
|
|
//
|
2006-09-07 23:21:15 +00:00
|
|
|
|
if ( result < bp - 1
|
|
|
|
|
|
&& '\r' == bp[-2]
|
2006-09-07 23:01:24 +00:00
|
|
|
|
&& '\n' == bp[-1])
|
|
|
|
|
|
{
|
2006-09-07 23:21:15 +00:00
|
|
|
|
bp -= 2;
|
2006-09-07 23:01:24 +00:00
|
|
|
|
}
|
2006-09-01 22:59:23 +00:00
|
|
|
|
*bp = '\0';
|
2006-09-07 23:01:24 +00:00
|
|
|
|
|
2026-03-20 06:07:24 -06:00
|
|
|
|
mux_fclose(fp);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-03-14 00:55:08 +00:00
|
|
|
|
static void help_write(dbref executor, UTF8 *topic_arg, int iHelpfile)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
2007-03-25 17:01:06 +00:00
|
|
|
|
size_t nTopic;
|
|
|
|
|
|
const UTF8 *topic = MakeCanonicalTopicName(topic_arg, nTopic);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
StringPtrMap *htab = mudstate.aHelpDesc[iHelpfile].ht;
|
|
|
|
|
|
auto it = htab->find(std::vector<UTF8>(topic, topic + nTopic));
|
|
|
|
|
|
struct help_entry *htab_entry = (it != htab->end())
|
|
|
|
|
|
? static_cast<struct help_entry *>(it->second) : nullptr;
|
2007-03-25 17:01:06 +00:00
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (htab_entry)
|
|
|
|
|
|
{
|
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 result = LBuf_Src("help_write");
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (ReportTopic(executor, htab_entry, iHelpfile, result))
|
|
|
|
|
|
{
|
|
|
|
|
|
notify(executor, result);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2026-07-27 11:50:31 +00:00
|
|
|
|
notify(executor, M_("Sorry, that function is temporarily unavailable."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ReportMatchedTopics(executor, topic, htab);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool ValidateHelpFileIndex(int iHelpfile)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( iHelpfile < 0
|
|
|
|
|
|
|| mudstate.mHelpDesc <= iHelpfile)
|
|
|
|
|
|
{
|
2007-03-14 00:55:08 +00:00
|
|
|
|
UTF8 *buf = alloc_mbuf("do_help.LOG");
|
2006-09-01 22:59:23 +00:00
|
|
|
|
STARTLOG(LOG_BUGS, "BUG", "HELP");
|
nls: mark move/walk/help/guest/quota/power notify prose with M_() (#1670)
Phase 3 coverage slice. Player and staff notify paths that still used
T() (cast-only) now use M_() so they extract into the catalogue:
move arrive/leave, get/drop, teleport failures, home
walk destination, blocked, patrol
help missing topic, match list, file errors
guest busy/create errors, listing total
quota Quota/Used display templates
powers Power not found, @power echo, Powers: header
session Poll / Doing
Attribute names, flag/power registry keys, logs, HTML, and softcode
machine tokens stay T()/S_(). Regenerates pot (670 -> 704) and xx.po.
2026-07-27 23:30:41 -06:00
|
|
|
|
mux_sprintf(buf, MBUF_SIZE, M_("Unknown help file number: %d"), iHelpfile);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
log_text(buf);
|
|
|
|
|
|
ENDLOG;
|
|
|
|
|
|
free_mbuf(buf);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* ---------------------------------------------------------------------------
|
|
|
|
|
|
* * do_help: display information from new-format news and help files
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2007-09-02 13:48:10 -07:00
|
|
|
|
void do_help(dbref executor, dbref caller, dbref enactor, int eval, int key, UTF8 *message, const UTF8 *cargs[], int ncargs)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
UNUSED_PARAMETER(caller);
|
|
|
|
|
|
UNUSED_PARAMETER(enactor);
|
2006-09-06 06:17:46 +00:00
|
|
|
|
UNUSED_PARAMETER(eval);
|
2007-09-02 13:48:10 -07:00
|
|
|
|
UNUSED_PARAMETER(cargs);
|
|
|
|
|
|
UNUSED_PARAMETER(ncargs);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
|
|
|
|
|
int iHelpfile = key;
|
|
|
|
|
|
|
|
|
|
|
|
if (!ValidateHelpFileIndex(iHelpfile))
|
|
|
|
|
|
{
|
2026-07-27 11:50:31 +00:00
|
|
|
|
notify(executor, M_("No such indexed file found."));
|
2006-09-01 22:59:23 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
help_write(executor, message, iHelpfile);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
void help_helper(dbref executor, int iHelpfile, const UTF8 *topic_arg,
|
2007-03-14 00:55:08 +00:00
|
|
|
|
UTF8 *buff, UTF8 **bufc)
|
2006-09-01 22:59:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (!ValidateHelpFileIndex(iHelpfile))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-03-25 17:01:06 +00:00
|
|
|
|
size_t nTopic;
|
|
|
|
|
|
const UTF8 *topic = MakeCanonicalTopicName(topic_arg, nTopic);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
|
Replace 8 CHashTable instances with std::unordered_map (Phase 1).
Migrate command_htab, logout_cmd_htab, player_htab, powers_htab,
reference_htab, ufunc_htab to StringPtrMap and mail_htab, parent_htab,
pcache_htab to DbrefPtrMap. Eliminate the htab wrapper layer
(hashfindLEN, hashaddLEN, hashdeleteLEN, hashreplLEN, hashreplall,
hashflush, hashreset, hash_firstentry/nextentry/firstkey/nextkey)
and convert all 132 call sites to direct STL map operations.
Help system tables (HELP_DESC.ht) also migrated. vattr_name_htab
remains CHashTable for Phase 2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:37 -07:00
|
|
|
|
StringPtrMap *htab = mudstate.aHelpDesc[iHelpfile].ht;
|
|
|
|
|
|
auto it = htab->find(std::vector<UTF8>(topic, topic + nTopic));
|
|
|
|
|
|
struct help_entry *htab_entry = (it != htab->end())
|
|
|
|
|
|
? static_cast<struct help_entry *>(it->second) : nullptr;
|
2007-03-25 17:01:06 +00:00
|
|
|
|
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (htab_entry)
|
|
|
|
|
|
{
|
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 result = LBuf_Src("help_helper");
|
2006-09-01 22:59:23 +00:00
|
|
|
|
if (ReportTopic(executor, htab_entry, iHelpfile, result))
|
|
|
|
|
|
{
|
|
|
|
|
|
safe_str(result, buff, bufc);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2026-07-27 00:47:44 +00:00
|
|
|
|
safe_str(S_("#-1 ERROR"), buff, bufc);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2026-07-27 00:47:44 +00:00
|
|
|
|
safe_str(S_("#-1 TOPIC DOES NOT EXIST"), buff, bufc);
|
2006-09-01 22:59:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|