Skip to content
Permalink
Browse files

Merged PR 488: Merge 393_in_game_defect_logging to master

Related work items: #393, #446
  • Loading branch information...
realms-mud committed Apr 19, 2019
1 parent fcd9bfe commit 8703072ce18263d096e5fab5a0034c9469834289
@@ -0,0 +1,160 @@
//*****************************************************************************
// Copyright (c) 2019 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//*****************************************************************************
inherit "/lib/commands/baseCommand.c";
#include "/lib/modules/secure/logging.h"

/////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg)
{
if (!arg)
{
CommandType = "General";
addCommandTemplate("issue [-teleport] [-t ##Target##] [-c ##Value##]");
}
}

/////////////////////////////////////////////////////////////////////////////
private object getIssueTarget(string command, object initiator)
{
object target = 0;
if (sizeof(regexp(({ command }), "-t [^-]+")))
{
string targetString = regreplace(command, ".*-t ([^-]+)( .*|$)", "\\1", 1);

target = present(targetString, initiator) ||
present(targetString, environment(initiator)) ||
find_object(targetString);
}

if (!target)
{
target = environment(initiator);
}
return target;
}

/////////////////////////////////////////////////////////////////////////////
public nomask int execute(string command, object initiator)
{
int ret = 0;

if (canExecuteCommand(command))
{
ret = 1;
object target = getIssueTarget(command, initiator);

if (objectp(target))
{
string longDesc = "???";
catch (longDesc = target->long());

int teleportUser = sizeof(regexp(({ command }), "-teleport"));

mapping data = ([
"status": 0,
"logged by": initiator->RealName(),
"affected object": program_name(target),
"location": program_name(environment(initiator)),
"data": regreplace(command, ".*-c (.*$)", "\\1", 1) +
(teleportUser ? sprintf("\n\n*** NOTE: %s used teleport to "
"safety.\n", capitalize(initiator->RealName())) : "") +
"\n\nItem Description:\n" + longDesc +
"\n\nCurrent trace data:\n" +
(driver_info(-44) || "No errors found.\n")
]);

saveIssue(data);

object channels = load_object("/lib/dictionaries/channelDictionary.c");
if (channels)
{
channels->broadcastMessage("issue logged by",
sprintf("A new issue has been logged:\n"
"Affected Object: %s\nLocation: %s\nDetails: %s\n",
data["affected object"], data["location"], data["data"]),
initiator);
}
if (teleportUser)
{
move_object(initiator, "/room/city/central_park.c");
command("look", initiator);
}

tell_object(initiator, configuration->decorate(
"Your issue details have been logged.\n", "issue", "help",
initiator->colorConfiguration()));
}
}
return ret;
}

/////////////////////////////////////////////////////////////////////////////
protected string synopsis(string displayCommand, string colorConfiguration)
{
return "Log a defect/issue/typo/idea with/for a MUD object, quest, "
"area, or item";
}

/////////////////////////////////////////////////////////////////////////////
protected string description(string displayCommand, string colorConfiguration)
{
return format("The issue command will report any problems or other "
"feedback that a player might have with respect to a room, item, "
"monster, quest, or any other thing they might interact with in "
"the MUD. Given that the living mud can have serious issues that "
"place users in an untenable situation, there is also a -teleport "
"flag that will send the player to a safe location.", 78);
}

/////////////////////////////////////////////////////////////////////////////
protected string notes(string displayCommand, string colorConfiguration)
{
return "See also: set";
}

/////////////////////////////////////////////////////////////////////////////
protected string flagInformation(string flag, string colorConfiguration)
{
string ret = "";
string parsedFlag = regreplace(flag, "[^-]*(-[a-zA-Z]+).*", "\\1");

switch (parsedFlag)
{
case "-t":
{
ret = "This flag allows a user to specify a target item that has "
"an issue.";
break;
}
case "-c":
{
ret = "This option allows the player to add additional "
"free-form commentary about the issue/idea they are logging";
break;
}
case "-teleport":
{
ret = "This flag can be used to teleport the user to a safe, "
"theoretically error-free location in the event that you have "
"been placed in an untenable situation. It is important to "
"note that this action is logged and feeds directly in to "
"the defect tracking system of the MUD, so inappropriate use of "
"it will both be extremely obvious (imagine all wizzes seeing "
"100 new issues logged with '<your name> used the teleport to "
"safety mechanism') and will result in disciplinary action. "
"However, you are strongly encouraged to use this flag when "
"you are placed in a situation where you are unable to react. "
"This includes rooms that throw errors that result in you not "
"being able to leave, situations where your character will "
"die or be otherwise adversely affected, and so on. In short, "
"use common sense. If you use this as a means of quickly "
"getting to town, a means of escape from imminent death or "
"'sucker punching' during player-killing, this is most "
"definitely inappropriate.";
break;
}
}
return format(ret, 72);
}
@@ -51,7 +51,7 @@ private nomask void compileOneItem(string path, object initiator,
{
result = configuration->decorate(result,
"error message", "wizard commands", colorConfiguration) +
configuration->decorate((read_file(logFile) || driver_info(-42)),
configuration->decorate((read_file(logFile) || driver_info(-44)),
"error message", "wizard commands", colorConfiguration);

tell_object(initiator, result);
@@ -74,7 +74,7 @@ private nomask string *getWizardChannels(object user)
string *ret = ({});
if (member(inherit_list(user), "lib/realizations/wizard.c") > -1)
{
ret += ({ "wiz", "status" });
ret += ({ "wiz", "status", "issue logged by" });

if (member(({ "owner", "god", "demigod", "archwizard", "sage", "elder" }),
user->wizardLevel()) > -1)
@@ -265,7 +265,12 @@ private nosave mapping decorators = ([
"3-bit": "\x1b[0;31;1m",
"8-bit": "\x1b[0;38;5;20m",
"24-bit": "\x1b[0;38;2;50;50;150m"
]),
]),
"issue":([
"3-bit": "\x1b[0;32;1m",
"8-bit": "\x1b[0;38;5;149;1m",
"24-bit": "\x1b[0;38;2;210;220;40;1m"
]),
]),
"shout":([
"message":([
@@ -0,0 +1,85 @@
//*****************************************************************************
// Copyright (c) 2019 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//*****************************************************************************
virtual inherit "/lib/modules/secure/dataServices/dataService.c";

/////////////////////////////////////////////////////////////////////////////
private nomask mapping *getIssues(string whereClause)
{
mapping *ret = 0;
string query = sprintf("select * from issues %s "
"order by firstLoggedTime desc;", whereClause);

int dbHandle = connect();
db_exec(dbHandle, query);
mixed result;

do
{
result = db_fetch(dbHandle);
if (sizeof(result))
{
mapping entry = ([]);
entry["id"] = to_int(result[0]);
entry["status"] = to_int(result[1]);
entry["logged by"] = convertString(result[2]);
entry["assigned to"] = convertString(result[3]);
entry["first logged time"] = convertString(result[4]);
entry["affected object"] = convertString(result[5]);
entry["location"] = convertString(result[6]);
entry["data"] = convertString(result[7]);

ret += ({ entry });
}
} while (result);
disconnect(dbHandle);

return ret;
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping *getNewlySubmittedIssues()
{
return getIssues("where status = 0");
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping *getIssuesByPlayerName(string playerName)
{
return getIssues(sprintf("where loggedBy = '%s'", playerName));
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping *getIssuesByWizard(string wizard)
{
return getIssues(sprintf("where assignedTo = '%s'", wizard));
}

/////////////////////////////////////////////////////////////////////////////
private nomask int validateIssueData(mapping data)
{
return member(data, "status") &&
member(data, "logged by") &&
member(data, "affected object") &&
member(data, "location") &&
member(data, "data");
}

/////////////////////////////////////////////////////////////////////////////
public nomask void saveIssue(mapping data)
{
string query = sprintf("call saveIssue(%d, %d, '%s', '%s', '%s', '%s', '%s');",
data["id"],
data["status"],
sanitizeString(data["logged by"]),
sanitizeString(data["assigned to"]),
sanitizeString(data["affected object"]),
sanitizeString(data["location"]),
sanitizeString(data["data"]));

int dbHandle = connect();
db_exec(dbHandle, query);
mixed result = db_fetch(dbHandle);
disconnect(dbHandle);
}
@@ -75,7 +75,7 @@ public nomask void saveSettings(int dbHandle, mapping playerData)

string *keys = filter(m_indices(playerData),
(: (member(({ "blocks", "busy", "earmuffs", "page size",
"color setting", "character set" }), $1) > -1) :));
"color setting", "character set", "safety teleport" }), $1) > -1) :));

if (sizeof(keys))
{
@@ -99,3 +99,17 @@ public nomask void saveSettings(int dbHandle, mapping playerData)
}
}
}

/*
/////////////////////////////////////////////////////////////////////////////
public nomask int canSafetyTeleport()
{
return lastSafetyTeleport <= time();
}
/////////////////////////////////////////////////////////////////////////////
public nomask void setLastSafetyTeleport()
{
lastSafetyTeleport = time() + 3600;
}
*/
@@ -0,0 +1,37 @@
//*****************************************************************************
// Copyright (c) 2019 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//*****************************************************************************

private int Submitted = 0;
private int Scheduled = 1;
private int Active = 2;
private int Completed = 3;
private int Rejected = 4;

private object service =
load_object("/lib/modules/secure/dataServices/loggingDataService.c");

/////////////////////////////////////////////////////////////////////////////
private nomask mapping *getNewlySubmittedIssues()
{
return service->getNewlySubmittedIssues();
}

/////////////////////////////////////////////////////////////////////////////
private nomask mapping *getIssuesByPlayerName(string playerName)
{
return service->getIssuesByPlayerName(playerName);
}

/////////////////////////////////////////////////////////////////////////////
private nomask mapping *getIssuesByWizard(string wizard)
{
return service->getIssuesByWizard(wizard);
}

/////////////////////////////////////////////////////////////////////////////
private nomask void saveIssue(mapping data)
{
service->saveIssue(data);
}
@@ -10,7 +10,7 @@ private string PrimaryGuild = 0;
private mapping blocks = ([ ]);
private string colorSetting = "3-bit";
private string characterSet = "ascii";

private int lastSafetyTeleport = 0;
private nosave object ReplyTo;

/////////////////////////////////////////////////////////////////////////////
@@ -24,6 +24,7 @@ static nomask void loadSettings(mapping data, object persistence)
colorSetting = persistence->extractSaveData("color setting", data);
characterSet = persistence->extractSaveData("character set", data);
PrimaryGuild = persistence->extractSaveData("primary guild", data);
lastSafetyTeleport = persistence->extractSaveData("safety teleport", data);
blocks = persistence->extractSaveData("blocks", data);
}

@@ -53,6 +54,7 @@ static nomask mapping sendSettings()
"page size": to_string(PageSize),
"color setting": colorSetting,
"character set": characterSet,
"primary guild": PrimaryGuild
"primary guild": PrimaryGuild,
"safety teleport": lastSafetyTeleport
]);
}
Oops, something went wrong.

0 comments on commit 8703072

Please sign in to comment.
You can’t perform that action at this time.