Index: cfgparser/readCfg.cs =================================================================== --- cfgparser/readCfg.cs (revision 39) +++ cfgparser/readCfg.cs (working copy) @@ -330,6 +330,7 @@ eventAllowed["OnEnterPitLane"] = new eventProperties("$userName,$reason"); eventAllowed["OnNameChange"] = new eventProperties("$userName,$oldNickName,$newNickName"); eventAllowed["OnDistDone"] = new eventProperties("$userName"); + eventAllowed["OnPracStart"] = new eventProperties("$NumP"); } Index: insimButton.cs =================================================================== --- insimButton.cs (revision 39) +++ insimButton.cs (working copy) @@ -432,6 +432,25 @@ } } + public void deleteButtonRegex(string pattern, int UCID) + { + ArrayList al = new ArrayList(); + foreach (DictionaryEntry de in hashMsgBox) + { + box currBox = (box)de.Value; + if (Regex.IsMatch(currBox.id, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase)) + { + al.Add((string) currBox.id); +// Console.WriteLine("(match for '{0}' found): {1}", pattern,currBox.id); + } + } + string[] butToClose = (string[]) al.ToArray(typeof(string)); + for (int i = 0; i < butToClose.Length; i++) + { +// Console.WriteLine("(deleting button: {0}", butToClose[i]); + this.delete(butToClose[i], UCID); + } + } } class oneButton Index: LFSClient/managePacket.cs =================================================================== --- LFSClient/managePacket.cs (revision 39) +++ LFSClient/managePacket.cs (working copy) @@ -579,34 +579,40 @@ listOfPlayers.raceRestart(); string[] par = new string[1]; + par[0] = rst.NumP.ToString(); currRace.raceLaps = 0; currRace.raceMins = 0; currRace.qualMins = 0; - if (rst.QualMins == 0) - { - par[0] = rst.NumP.ToString(); - currRace.raceLaps = rst.RaceLaps; - // Set raceLapsLeft based on LAP.RaceLaps - if (currRace.raceLaps < 100 ) { - // Short race - less than 100 laps - currRace.raceLapsLeft = currRace.raceLaps; - } else if (currRace.raceLaps < 191 ) { - // Long race - between 100 and 1000 laps - currRace.raceLapsLeft = (((currRace.raceLaps - 100) * 10) + 100); - } else { - // Timed race - 1 to 48 hours - currRace.raceMins = ((currRace.raceLaps - 190) * 60); // Use raceMins to store race time - currRace.raceLapsLeft = 99; - } - newCfg.executeFunction("OnRaceStart", null, par); - } - if (rst.RaceLaps == 0) + if (rst.QualMins == 0 && rst.RaceLaps == 0) // Is this a practice session? { - currRace.qualMins = rst.QualMins; - par[0] = rst.NumP.ToString(); - newCfg.executeFunction("OnQualSTart", null, par); - } + newCfg.executeFunction("OnPracStart", null, par); + } + else + { + if (rst.QualMins == 0) // It's a race session if QualMins is 0 + { + currRace.raceLaps = rst.RaceLaps; + // Set raceLapsLeft based on LAP.RaceLaps + if (currRace.raceLaps < 100 ) { + // Short race - less than 100 laps + currRace.raceLapsLeft = currRace.raceLaps; + } else if (currRace.raceLaps < 191 ) { + // Long race - between 100 and 1000 laps + currRace.raceLapsLeft = (((currRace.raceLaps - 100) * 10) + 100); + } else { + // Timed race - 1 to 48 hours + currRace.raceMins = ((currRace.raceLaps - 190) * 60); // Use raceMins to store race time + currRace.raceLapsLeft = 99; + } + newCfg.executeFunction("OnRaceStart", null, par); + } + else // ...okay, we're in a qualifying session + { + currRace.qualMins = rst.QualMins; + newCfg.executeFunction("OnQualSTart", null, par); + } + } } void managePacket(InSim.Decoder.FIN fin) // FINished race notification (not a final result - use IS_RES) { Index: LFSClient/scriptFunctions.cs =================================================================== --- LFSClient/scriptFunctions.cs (revision 39) +++ LFSClient/scriptFunctions.cs (working copy) @@ -47,8 +47,10 @@ newCfg.CurrApp.registerCallBackFunction("getplayerinfo", getplayerinfo); newCfg.CurrApp.registerCallBackFunction("openprivbutton", openprivbutton); newCfg.CurrApp.registerCallBackFunction("closeprivbutton", closeprivbutton); + newCfg.CurrApp.registerCallBackFunction("closeprivbuttonregex", closeprivbuttonregex); newCfg.CurrApp.registerCallBackFunction("openbutton", openbutton); newCfg.CurrApp.registerCallBackFunction("closebutton", closebutton); + newCfg.CurrApp.registerCallBackFunction("closebuttonregex", closebuttonregex); newCfg.CurrApp.registerCallBackFunction("getlistofplayers", getlistofplayers); newCfg.CurrApp.registerCallBackFunction("setplayervar", setplayervar); newCfg.CurrApp.registerCallBackFunction("getplayervar", getplayervar); @@ -286,10 +288,18 @@ val.typVal = GLScript.typVal.num; val.fval = listOfPlayers.nbPlayerOnTrack; return; + case "raceid": + val.typVal = GLScript.typVal.str; + val.sval = utils.quote(currRace.started.ToString("yyyy-MM-dd-hh-mm-ss")); + return; case "racelaps": val.typVal = GLScript.typVal.num; val.fval = currRace.raceLaps; return; + case "raceinprog": + val.typVal = GLScript.typVal.num; + val.fval = currState.RaceInProg; + return; case "racemins": val.typVal = GLScript.typVal.num; val.fval = currRace.raceMins; @@ -370,6 +380,15 @@ testArgs(ident, "S", args); currInfoPlayer.privateButtonClose(args[0].ToString()); } + public void closeprivbuttonregex(GLScript.unionVal val, ArrayList args) + { + infoPlayer currInfoPlayer = newCfg.getCurrInfoPlayer(); + string ident = val.nameFunction; + if (currInfoPlayer == null) + throw new GLScript.GLApp.GLScriptException("You can't use " + ident + " in this context, not a player event"); + testArgs(ident, "S", args); + currInfoPlayer.privateButtonCloseRegex(args[0].ToString()); + } public void openbutton(GLScript.unionVal val, ArrayList args) { @@ -449,6 +468,19 @@ testArgs(ident, "S", args); currPly.privateButtonClose(args[0].ToString()); } + public void closebuttonregex(GLScript.unionVal val, ArrayList args) + { + infoPlayer currPly; + string ident = val.nameFunction; + currPly = listOfPlayers.getPlayerByUserName((string)args[0]); + if (currPly == null) + { + throw new GLScript.GLApp.GLScriptException("Player name " + (string)args[0] + " in function " + ident + " not a player"); + } + args.RemoveAt(0); + testArgs(ident, "S", args); + currPly.privateButtonCloseRegex(args[0].ToString()); + } public void getlistoflang(GLScript.unionVal val, ArrayList args) { string ident = val.nameFunction; Index: Players/infoPlayer.cs =================================================================== --- Players/infoPlayer.cs (revision 39) +++ Players/infoPlayer.cs (working copy) @@ -261,6 +261,10 @@ } } + public void privateButtonCloseRegex(string argString) + { + this.playerBox.deleteButtonRegex(argString, this.UCID); + } public void clearSessionInfo() { for (int i = 0; i < (int)paramLapper.maxSplit; i++)