-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged PR 488: Merge 393_in_game_defect_logging to master
Related work items: #393, #446
- Loading branch information
Allen B. Cummings
committed
Apr 19, 2019
1 parent
fcd9bfe
commit 8703072
Showing
10 changed files
with
474 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.