Skip to content

Commit

Permalink
Merge pull request #119 from GenieClient/Dev-4-0-2-5
Browse files Browse the repository at this point in the history
This has been running stable for 2 weeks with heavy use (>100 hours) by Briarleigh and others. There is a known issue with the Volatile Highlights not applying correctly to the Room Objects in the Game window in some instances. I am not considering this a no-go issue. Version 4.0.2.5 appears stable and resolves a number of issues as above
  • Loading branch information
mj-colonel-panic authored Sep 17, 2022
2 parents 3812e13 + a3d3d42 commit bf94183
Show file tree
Hide file tree
Showing 15 changed files with 329 additions and 166 deletions.
41 changes: 30 additions & 11 deletions Core/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1890,8 +1890,13 @@ public string ParseCommand(string sText, bool bSendToGame = false, bool bUserInp
if (oArgs.Count > 3)
{
string argsKey = oGlobals.ParseGlobalVars(Utility.ArrayToString(oArgs, 3));
bool argbHighlightWholeRow = true;
oGlobals.HighlightList.Add(argsKey, argbHighlightWholeRow, oGlobals.ParseGlobalVars(oArgs[2].ToString()));
bool highlightWholeRow = true;
string color = oGlobals.ParseGlobalVars(oArgs[2].ToString());
bool caseSensitive = oArgs.Count > 4 ? oArgs[4].ToString().ToUpper() == "TRUE" : false;
string soundFile = oArgs.Count > 5 ? oArgs[5].ToString() : string.Empty;
string className = oArgs.Count > 6 ? oArgs[6].ToString() : string.Empty;
bool isActive = oArgs.Count > 7 ? oArgs[7].ToString().ToUpper() == "TRUE" : true;
oGlobals.HighlightList.Add(argsKey, highlightWholeRow, color, caseSensitive, soundFile, className, isActive);
oGlobals.HighlightList.RebuildLineIndex();
}

Expand All @@ -1903,9 +1908,14 @@ public string ParseCommand(string sText, bool bSendToGame = false, bool bUserInp
{
if (oArgs.Count > 3)
{
string argsKey1 = oGlobals.ParseGlobalVars(Utility.ArrayToString(oArgs, 3));
bool argbHighlightWholeRow1 = false;
oGlobals.HighlightList.Add(argsKey1, argbHighlightWholeRow1, oGlobals.ParseGlobalVars(oArgs[2].ToString()));
string highlightText = oGlobals.ParseGlobalVars(Utility.ArrayToString(oArgs, 3));
bool highlightWholeRow = false;
string color = oGlobals.ParseGlobalVars(oArgs[2].ToString());
bool caseSensitive = oArgs.Count > 4 ? oArgs[4].ToString().ToUpper() == "TRUE" : false;
string soundFile = oArgs.Count > 5 ? oArgs[5].ToString() : string.Empty;
string className = oArgs.Count > 6 ? oArgs[6].ToString() : string.Empty;
bool isActive = oArgs.Count > 7 ? oArgs[7].ToString().ToUpper() == "TRUE" : true;
oGlobals.HighlightList.Add(highlightText, highlightWholeRow, color , caseSensitive, soundFile, className, isActive);
oGlobals.HighlightList.RebuildStringIndex();
}

Expand All @@ -1916,9 +1926,13 @@ public string ParseCommand(string sText, bool bSendToGame = false, bool bUserInp
{
if (oArgs.Count > 3)
{
string argsKey2 = oGlobals.ParseGlobalVars(Utility.ArrayToString(oArgs, 3));
string argsColorName = oGlobals.ParseGlobalVars(oArgs[2].ToString());
oGlobals.HighlightBeginsWithList.Add(argsKey2, argsColorName);
string beginsWithText = oGlobals.ParseGlobalVars(Utility.ArrayToString(oArgs, 3));
string color = oGlobals.ParseGlobalVars(oArgs[2].ToString());
bool caseSensitive = oArgs.Count > 4 ? oArgs[4].ToString().ToUpper() == "TRUE" : false;
string soundFile = oArgs.Count > 5 ? oArgs[5].ToString() : string.Empty;
string className = oArgs.Count > 6 ? oArgs[6].ToString() : string.Empty;
bool isActive = oArgs.Count > 7 ? oArgs[7].ToString().ToUpper() == "TRUE" : true;
oGlobals.HighlightBeginsWithList.Add(beginsWithText, color, caseSensitive, soundFile, className, isActive);
}

break;
Expand All @@ -1932,9 +1946,13 @@ public string ParseCommand(string sText, bool bSendToGame = false, bool bUserInp
string argsRegExp = oGlobals.ParseGlobalVars(Utility.ArrayToString(oArgs, 3));
if (Utility.ValidateRegExp(argsRegExp) == true)
{
string argsKey3 = oGlobals.ParseGlobalVars(Utility.ArrayToString(oArgs, 3));
string argsColorName1 = oGlobals.ParseGlobalVars(oArgs[2].ToString());
oGlobals.HighlightRegExpList.Add(argsKey3, argsColorName1);
string regexPattern = oGlobals.ParseGlobalVars(Utility.ArrayToString(oArgs, 3));
string color = oGlobals.ParseGlobalVars(oArgs[2].ToString());
bool caseSensitive = oArgs.Count > 4 ? oArgs[4].ToString().ToUpper() == "TRUE" : false;
string soundFile = oArgs.Count > 5 ? oArgs[5].ToString() : string.Empty;
string className = oArgs.Count > 6 ? oArgs[6].ToString() : string.Empty;
bool isActive = oArgs.Count > 7 ? oArgs[7].ToString().ToUpper() == "TRUE" : true;
oGlobals.HighlightRegExpList.Add(regexPattern, color, caseSensitive, soundFile, className, isActive);
}
else
{
Expand Down Expand Up @@ -2859,6 +2877,7 @@ private void ListSettings()
EchoText("mapdir=" + oGlobals.Config.sMapDir + System.Environment.NewLine);
EchoText("scriptdir=" + oGlobals.Config.sScriptDir + System.Environment.NewLine);
EchoText("scriptchar=" + oGlobals.Config.ScriptChar.ToString() + System.Environment.NewLine);
EchoText("scriptrepo=" + oGlobals.Config.ScriptRepo + System.Environment.NewLine);
EchoText("scriptextension=" + oGlobals.Config.ScriptExtension + System.Environment.NewLine);
EchoText("scripttimeout=" + oGlobals.Config.iScriptTimeout.ToString() + System.Environment.NewLine);
EchoText("separatorchar=" + oGlobals.Config.cSeparatorChar.ToString() + System.Environment.NewLine);
Expand Down
38 changes: 23 additions & 15 deletions Core/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,14 @@ public void SendRaw(string text)
public void ParseGameRow(string sText)
{
var oXMLBuffer = new StringBuilder();
bool hasXML = false;
int iInsideXML = 0;
bool bEndTagFound = false;
bool bInsideHTMLTag = false;
string sHTMLBuffer = string.Empty;
string sTextBuffer = string.Empty;
string sBoldBuffer = string.Empty;
int iBoldIndex = 0;
char cPreviousChar = Conversions.ToChar("");
bool bCombatRow = false;
bool bPromptRow = false;
Expand Down Expand Up @@ -548,6 +550,7 @@ public void ParseGameRow(string sText)
case '<':
{
iInsideXML += 1;
hasXML = true;
oXMLBuffer.Append(c);
break;
}
Expand Down Expand Up @@ -589,8 +592,7 @@ public void ParseGameRow(string sText)
default:
break;
}
sTmp = ParseSubstitutions(sTmp);
m_oGlobals.VolatileHighlights.Add(new System.Collections.Generic.KeyValuePair<string, string>(presetLabel, sTmp));
m_oGlobals.VolatileHighlights.Add(new VolatileHighlight(sTmp, presetLabel, 0));
if(presetLabel == "roomdesc")
{
PrintTextWithParse(sTmp, bIsPrompt: false, oWindowTarget: 0);
Expand All @@ -600,16 +602,17 @@ public void ParseGameRow(string sText)
if (buffer.EndsWith(@"<pushBold/>"))
{
sBoldBuffer = string.Empty;
iBoldIndex = sTextBuffer.Length; //do not subtract 1 because our start index isn't added yet
}
if (buffer.EndsWith(@"<popBold/>"))
{
if (!string.IsNullOrWhiteSpace(sBoldBuffer))
{
sBoldBuffer = ParseSubstitutions(sBoldBuffer);
m_oGlobals.VolatileHighlights.Add(new System.Collections.Generic.KeyValuePair<string, string>("creatures", sBoldBuffer));
m_oGlobals.VolatileHighlights.Add(new VolatileHighlight(sBoldBuffer, "creatures", iBoldIndex));
}
}
if (m_bBold)
if (m_bBold & !m_oGlobals.Config.Condensed)
{
if (sTextBuffer.StartsWith("< ") | sTextBuffer.StartsWith("> ") | sTextBuffer.StartsWith("* "))
{
Expand All @@ -620,6 +623,7 @@ public void ParseGameRow(string sText)
PrintTextWithParse(argsText, bIsPrompt: argbIsPrompt, oWindowTarget: argoWindowTarget);
m_bBold = true;
sTextBuffer = string.Empty;
iBoldIndex = sTextBuffer.Length;
bCombatRow = true;
}
}
Expand Down Expand Up @@ -763,7 +767,7 @@ public void ParseGameRow(string sText)
else if (!string.IsNullOrWhiteSpace(sBoldBuffer))
{
sBoldBuffer = ParseSubstitutions(sBoldBuffer);
m_oGlobals.VolatileHighlights.Add(new System.Collections.Generic.KeyValuePair<string, string>("creatures", sBoldBuffer.Trim())); //trim because excessive whitespace seems to be breaking this
m_oGlobals.VolatileHighlights.Add(new VolatileHighlight(sBoldBuffer.Trim(), "creatures", iBoldIndex)); //trim because excessive whitespace seems to be breaking this
sBoldBuffer = string.Empty;
}

Expand All @@ -785,10 +789,12 @@ public void ParseGameRow(string sText)
}
}

if (!(sTextBuffer == "\r\n" && hasXML))
{
bool isRoomOutput = sText.Contains(@"<preset id='roomDesc'>");
PrintTextWithParse(sTextBuffer, default, default, default, default, isRoomOutput);
}

bool argbIsPrompt1 = false;
WindowTarget argoWindowTarget1 = 0;
PrintTextWithParse(sTextBuffer, bIsPrompt: argbIsPrompt1, oWindowTarget: argoWindowTarget1);

if (bCombatRow == true)
{
Expand Down Expand Up @@ -2491,13 +2497,15 @@ public void ResetIndicators()

private Regex m_MonsterRegex = new Regex("<pushBold />([^<]*)<popBold />([^,.]*)", MyRegexOptions.options);
private Regex m_RoomObjectsRegex = new Regex("<pushBold />([^<]*)<popBold />");

private static int tagOffset = "<pushBold /><popBold />".Length;
private void SetRoomObjects(XmlNode oXmlNode)
{
m_oGlobals.RoomObjects.Clear();
foreach (Match roomObject in m_RoomObjectsRegex.Matches(oXmlNode.InnerXml.Replace(" and ", ", ").Replace(" and <pushBold />", ", <pushBold />")))
foreach (Match roomObject in m_RoomObjectsRegex.Matches(oXmlNode.InnerXml))
{
m_oGlobals.RoomObjects.Add(new KeyValuePair<string, string>("creatures", ParseSubstitutions(roomObject.Groups[1].Value)));
int position = roomObject.Index - (tagOffset * m_oGlobals.RoomObjects.Count);
VolatileHighlight highlight = new VolatileHighlight(ParseSubstitutions(roomObject.Groups[1].Value), "creatures", position);
m_oGlobals.RoomObjects.Add(highlight);
}
}
private int CountMonsters(XmlNode oXmlNode)
Expand Down Expand Up @@ -2641,7 +2649,7 @@ public void PrintTextWithParse(string sText, Color color, Color bgcolor, bool bI
{
if (sText.StartsWith(" You also see"))
{
PrintTextToWindow(Environment.NewLine, color, bgcolor);
PrintTextToWindow(Environment.NewLine, color, bgcolor, oWindowTarget, bIsPrompt, true);
sText = sText.TrimStart();
}

Expand Down Expand Up @@ -2748,7 +2756,7 @@ public void PrintTextWithParse(string sText, Color color, Color bgcolor, bool bI

private void PrintTextToWindow(string text, Color color, Color bgcolor, WindowTarget targetwindow = WindowTarget.Main, bool isprompt = false, bool isroomoutput = false)
{
if (text.Length == 0 || (m_oGlobals.Config.Condensed && text.Trim().Length == 0))
if (text.Length == 0 || (!isroomoutput && m_oGlobals.Config.Condensed && text.Trim().Length == 0))
{
return;
}
Expand Down Expand Up @@ -3010,7 +3018,7 @@ private String ParseSubstitutions(string text)
{
bool bNewLineStart = text.StartsWith(System.Environment.NewLine);
bool bNewLineEnd = text.EndsWith(System.Environment.NewLine);
text = sl.SubstituteRegex.Replace(Utility.Trim(text), sl.sReplaceBy.ToString());
text = sl.SubstituteRegex.Replace(Utility.Trim(text), m_oGlobals.ParseGlobalVars(sl.sReplaceBy).ToString());
if (bNewLineStart == true)
{
text = System.Environment.NewLine + text;
Expand Down Expand Up @@ -3134,7 +3142,7 @@ private void GameSocket_EventConnected()
m_iConnectAttempts = 0;
m_bManualDisconnect = false;
m_oReconnectTime = default;
m_oSocket.Send(m_sConnectKey + Constants.vbLf + "/FE:GENIE /VERSION:" + My.MyProject.Application.Info.Version.ToString() + " / P:WIN_UNKNOWN /XML" + Constants.vbLf); // TEMP
m_oSocket.Send(m_sConnectKey + Constants.vbLf + "FE:WRAYTH /VERSION:1.0.1.22 /P:WIN_UNKNOWN /XML" + Constants.vbLf); // TEMP
string argkey = "connected";
string argvalue = m_oSocket.IsConnected ? "1" : "0";
m_oGlobals.VariableList.Add(argkey, argvalue, Globals.Variables.VariableType.Reserved);
Expand Down
3 changes: 2 additions & 1 deletion Core/LegacyPluginHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public bool get_IsPremium(string key)
return false;
string argsText = Utility.GenerateAccountHash(key);
string premKey = Utility.EncryptString(m_oGlobals.GenieKey, argsText);
return m_oGlobals.PluginPremiumKeyList.ContainsKey(premKey);
return true;
//return m_oGlobals.PluginPremiumKeyList.ContainsKey(premKey); #Was checking Hash and returning true/false. Now always true.
}

public LegacyPluginHost(Form Form, ref Genie.Globals Globals)
Expand Down
Loading

0 comments on commit bf94183

Please sign in to comment.