From 71643c2f125165ac90d1042e7509467a821b9dbd Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Thu, 30 May 2024 20:13:01 -0700 Subject: [PATCH] Improve handling of partial callsign matches - Report both callsign and exchange errors in QSO log. - Add argument to IsMyCall to enable random result for lids. --- Contest.pas | 4 +++- DxOper.pas | 18 +++++++++++------- Log.pas | 11 +++++------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Contest.pas b/Contest.pas index df8b9e6..079aea9 100644 --- a/Contest.pas +++ b/Contest.pas @@ -502,7 +502,9 @@ function TContest.GetAudio: TSingleArray; for i:=Stations.Count-1 downto 0 do if Stations[i] is TDxStation then with Stations[i] as TDxStation do - if (Oper.State = osDone) and (QsoList <> nil) and (MyCall = QsoList[High(QsoList)].Call) then begin + if (Oper.State = osDone) and (QsoList <> nil) and + ((MyCall = QsoList[High(QsoList)].Call) or + (Oper.IsMyCall(QsoList[High(QsoList)].Call, False) = mcAlmost)) then begin // grab Qso's "True" data (e.g. TrueCall, TrueExch1, TrueExch2) DataToLastQso; // deletes this TDxStation from Stations[] diff --git a/DxOper.pas b/DxOper.pas index f14adb3..976f25b 100644 --- a/DxOper.pas +++ b/DxOper.pas @@ -82,9 +82,9 @@ interface TDxOperator = class private + R1: Single; // holds a Random number; used in IsMyCall procedure DecPatience; procedure MorePatience(AValue: integer = 0); - function IsMyCall: TCallCheckResult; public Call: string; Skills: integer; @@ -105,6 +105,7 @@ TDxOperator = class procedure MsgReceived(AMsg: TStationMessages); procedure SetState(AState: TOperatorState); function GetReply: TStationMessage; + function IsMyCall(const ACall: string; ARandomResult: boolean): TCallCheckResult; end; @@ -118,6 +119,7 @@ implementation constructor TDxOperator.Create(const ACall: string; AState: TOperatorState); begin + R1 := Random; // a random value assigned at creation provides consistency Call := ACall; Skills := 1 + Random(3); //1..3 Patience := 0; @@ -317,7 +319,8 @@ procedure TDxOperator.SetState(AState: TOperatorState); end; -function TDxOperator.IsMyCall: TCallCheckResult; +function TDxOperator.IsMyCall(const ACall: string; + ARandomResult: boolean): TCallCheckResult; const W_X = 1; W_Y = 1; W_D = 1; var @@ -329,7 +332,7 @@ function TDxOperator.IsMyCall: TCallCheckResult; P: integer; begin C0 := Call; - C := Tst.Me.HisCall; + C := ACall; SetLength(M, Length(C)+1, Length(C0)+1); @@ -383,10 +386,10 @@ function TDxOperator.IsMyCall: TCallCheckResult; if Length(StringReplace(C, '?', '', [rfReplaceAll])) < 2 then Result := mcNo; //accept a wrong call, or reject the correct one - if Ini.Lids and (Length(C) > 3) then + if ARandomResult and Ini.Lids and (Length(C) > 3) then case Result of - mcYes: if Random < 0.01 then Result := mcAlmost; - mcAlmost: if Random < 0.04 then Result := mcYes; + mcYes: if R1 < 0.01 then Result := mcAlmost; + mcAlmost: if R1 < 0.04 then Result := mcYes; end; end; @@ -417,7 +420,7 @@ procedure TDxOperator.MsgReceived(AMsg: TStationMessages); end; if msgHisCall in AMsg then - case IsMyCall of + case IsMyCall(Tst.Me.HisCall, True) of mcYes: if State in [osNeedPrevEnd, osNeedQso] then SetState(osNeedNr) else if State = osNeedCallNr then SetState(osNeedNr) @@ -426,6 +429,7 @@ procedure TDxOperator.MsgReceived(AMsg: TStationMessages); mcAlmost: if State in [osNeedPrevEnd, osNeedQso] then SetState(osNeedCallNr) + else if State = osNeedCallNr then MorePatience else if State = osNeedNr then SetState(osNeedCallNr) else if State = osNeedEnd then SetState(osNeedCall); diff --git a/Log.pas b/Log.pas index dbd818b..847c3cc 100644 --- a/Log.pas +++ b/Log.pas @@ -760,7 +760,7 @@ procedure SaveQso; for i:=Tst.Stations.Count-1 downto 0 do if Tst.Stations[i] is TDxStation then with Tst.Stations[i] as TDxStation do - if (MyCall = Qso.Call) then + if ((MyCall = Qso.Call) or (Oper.IsMyCall(Qso.Call, False) = mcAlmost)) then begin Qso.TrueWpm := WpmAsText(); Break; @@ -770,7 +770,8 @@ procedure SaveQso; for i:=Tst.Stations.Count-1 downto 0 do if Tst.Stations[i] is TDxStation then with Tst.Stations[i] as TDxStation do - if (Oper.State = osDone) and (MyCall = Qso.Call) then + if (Oper.State = osDone) and + ((MyCall = Qso.Call) or (Oper.IsMyCall(Qso.Call, False) = mcAlmost)) then begin DataToLastQso; //grab "True" data and delete this dx station! Break; @@ -995,12 +996,10 @@ procedure CheckErr; else if Dupe and not Log.ShowCorrections then ExchError := leDUP else - begin ExchError := leNONE; - // find exchange errors for the current Qso - Tst.FindQsoErrors(QsoList[High(QsoList)], Corrections); - end; + // find exchange errors for the current Qso + Tst.FindQsoErrors(QsoList[High(QsoList)], Corrections); CallColumnColor := clBlack; Exch1ColumnColor := clBlack;