Skip to content

Commit

Permalink
updated backend with sse support
Browse files Browse the repository at this point in the history
  • Loading branch information
matortheeternal committed Dec 29, 2016
1 parent a1b5bb9 commit c02170a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 49 deletions.
Empty file added backend/SSEDictionary.txt
Empty file.
81 changes: 37 additions & 44 deletions backend/mpBackend.pas
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ TmpStatus = class(TObject)
fnvHash: string;
fo3Hash: string;
fo4Hash: string;
sseHash: string;
procedure Refresh;
end;
TReport = class(TObject)
Expand Down Expand Up @@ -165,11 +166,13 @@ TServerStatistics = class(TObject)
fnvReports: integer;
fo3Reports: integer;
fo4Reports: integer;
sseReports: integer;
tes5Logins: integer;
tes4Logins: integer;
fnvLogins: integer;
fo3Logins: integer;
fo4Logins: integer;
sseLogins: integer;
end;

{ MySQL methods }
Expand Down Expand Up @@ -269,16 +272,16 @@ TServerStatistics = class(TObject)

var
TES5Dictionary, TES4Dictionary, FO3Dictionary, FNVDictionary, FO4Dictionary,
ApprovedReports, UnapprovedReports, Users, Blacklist, BaseLog, Log,
LabelFilters, GroupFilters: TList;
SSEDictionary, ApprovedReports, UnapprovedReports, Users, Blacklist, BaseLog,
Log, LabelFilters, GroupFilters: TList;
slTES5Dictionary, slTES4Dictionary, slFO3Dictionary, slFNVDictionary,
slFO4Dictionary, slConnectedIPs: TStringList;
slFO4Dictionary, slSSEDictionary, slConnectedIPs: TStringList;
statistics: TServerStatistics;
settings: TSettings;
status: TmpStatus;
LogPath, ProgramPath, ProgramVersion: string;
bLoginSuccess, bRebuildTES5, bRebuildTES4, bRebuildFNV,
bRebuildFO3, bRebuildFO4, bApprovedAscending, bUnapprovedAscending: boolean;
bLoginSuccess, bRebuildTES5, bRebuildTES4, bRebuildFNV, bRebuildFO3,
bRebuildFO4, bRebuildSSE, bApprovedAscending, bUnapprovedAscending: boolean;
wbStartTime: TDateTime;
sessionBandwidth: Int64;
Connection: TZConnection;
Expand Down Expand Up @@ -306,8 +309,9 @@ class procedure TTaskProcedures.RebuildDictionaries;
if bRebuildFNV then RebuildDictionary('FNV', FNVDictionary);
if bRebuildFO3 then RebuildDictionary('FO3', FO3Dictionary);
if bRebuildFO4 then RebuildDictionary('FO4', FO4Dictionary);
if bRebuildSSE then RebuildDictionary('SSE', SSEDictionary);
if not (bRebuildTES5 or bRebuildTES4 or bRebuildFNV or bRebuildFO3
or bRebuildFO4) then
or bRebuildFO4 or bRebuildSSE) then
Logger.Write('DATA', 'Dictionary', 'No dictionaries need to be updated');
end;

Expand Down Expand Up @@ -944,6 +948,7 @@ procedure UpdateRebuildBooleans(report: TReport);
if report.game = 'FNV' then bRebuildFNV := true;
if report.game = 'FO3' then bRebuildFO3 := true;
if report.game = 'FO4' then bRebuildFO4 := true;
if report.game = 'SSE' then bRebuildSSE := true;
end;

function GetDictionary(name: string): string;
Expand All @@ -957,7 +962,9 @@ function GetDictionary(name: string): string;
else if name = 'FO3Dictionary.txt' then
Result := slFO3Dictionary.Text
else if name = 'FO4Dictionary.txt' then
Result := slFO4Dictionary.Text;
Result := slFO4Dictionary.Text
else if name = 'SSEDictionary.txt' then
Result := slSSEDictionary.Text;
end;

function GetDictionaryHash(name: string): string;
Expand All @@ -971,7 +978,9 @@ function GetDictionaryHash(name: string): string;
else if name = 'FO3Dictionary.txt' then
Result := status.fo3hash
else if name = 'FO4Dictionary.txt' then
Result := status.fo4hash;
Result := status.fo4hash
else if name = 'SSEDictionary.txt' then
Result := status.ssehash;
end;

procedure LoadDictionary(var lst: TList; var sl: TStringList; filename: string);
Expand Down Expand Up @@ -1518,9 +1527,22 @@ constructor TmpMessage.Create(id: integer; username, auth, data: string);
end;

{ TmpStatus }
procedure TmpStatus.Refresh;
procedure RefreshDictionary(game: String; var hash: String);
var
NewVersion: string;
begin
if FileExists(game + 'Dictionary.txt') then begin
NewVersion := GetCRC32(game + 'Dictionary.txt');
if (hash <> NewVersion) then begin
hash := NewVersion;
Logger.Write('INIT', 'Status', game + 'Dictionary Hash: '+hash);
end;
end;
end;

procedure TmpStatus.Refresh;
var
NewVersion: String;
Zipper: TAbZipper;
begin
if FileExists('MergePlugins.exe') then begin
Expand All @@ -1538,41 +1560,12 @@ procedure TmpStatus.Refresh;
Zipper.Free;
end;
end;
if FileExists('TES5Dictionary.txt') then begin
NewVersion := GetCRC32('TES5Dictionary.txt');
if (TES5Hash <> NewVersion) then begin
TES5Hash := NewVersion;
Logger.Write('INIT', 'Status', 'TES5Dictionary Hash: '+TES5Hash);
end;
end;
if FileExists('TES4Dictionary.txt') then begin
NewVersion := GetCRC32('TES4Dictionary.txt');
if (TES4Hash <> NewVersion) then begin
TES4Hash := NewVersion;
Logger.Write('INIT', 'Status', 'TES4Dictionary Hash: '+TES4Hash);
end;
end;
if FileExists('FNVDictionary.txt') then begin
NewVersion := GetCRC32('FNVDictionary.txt');
if (FNVHash <> NewVersion) then begin
FNVHash := NewVersion;
Logger.Write('INIT', 'Status', 'FNVDictionary Hash: '+FNVHash);
end;
end;
if FileExists('FO3Dictionary.txt') then begin
NewVersion := GetCRC32('FO3Dictionary.txt');
if (FO3Hash <> NewVersion) then begin
FO3Hash := NewVersion;
Logger.Write('INIT', 'Status', 'FO3Dictionary Hash: '+FO3Hash);
end;
end;
if FileExists('FO4Dictionary.txt') then begin
NewVersion := GetCRC32('FO4Dictionary.txt');
if (FO4Hash <> NewVersion) then begin
FO4Hash := NewVersion;
Logger.Write('INIT', 'Status', 'FO4Dictionary Hash: '+FO4Hash);
end;
end;
RefreshDictionary('TES5', TES5Hash);
RefreshDictionary('TES4', TES4Hash);
RefreshDictionary('FNV', FNVHash);
RefreshDictionary('FO3', FO3Hash);
RefreshDictionary('FO4', FO4Hash);
RefreshDictionary('SSE', SSEHash);
end;

{ TReport }
Expand Down
13 changes: 11 additions & 2 deletions backend/mpBackendForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,13 @@ procedure TBackendForm.FormCreate(Sender: TObject);
FO3Dictionary := TList.Create;
FNVDictionary := TList.Create;
FO4Dictionary := TList.Create;
SSEDictionary := TList.Create;
LoadDictionary(TES5Dictionary, slTES5Dictionary, 'TES5Dictionary.txt');
LoadDictionary(TES4Dictionary, slTES4Dictionary, 'TES4Dictionary.txt');
LoadDictionary(FO3Dictionary, slFO3Dictionary, 'FO3Dictionary.txt');
LoadDictionary(FNVDictionary, slFNVDictionary, 'FNVDictionary.txt');
LoadDictionary(FO4Dictionary, slFO4Dictionary, 'FO4Dictionary.txt');
LoadDictionary(SSEDictionary, slSSEDictionary, 'SSEDictionary.txt');

// QUERY DATA FROM MYSQL
DBQueryReports;
Expand Down Expand Up @@ -500,11 +502,13 @@ procedure TBackendForm.UpdateApplicationDetails;
AddDetailsItem('FNV logins', IntToStr(statistics.fnvLogins));
AddDetailsItem('FO3 logins', IntToStr(statistics.fo3Logins));
AddDetailsItem('FO4 logins', IntToStr(statistics.fo4Logins));
AddDetailsItem('SSE logins', IntToStr(statistics.sseLogins));
AddDetailsItem('TES5 reports recieved', IntToStr(statistics.tes5Reports));
AddDetailsItem('TES4 reports recieved', IntToStr(statistics.tes4Reports));
AddDetailsItem('FNV reports recieved', IntToStr(statistics.fnvReports));
AddDetailsItem('FO3 reports recieved', IntToStr(statistics.fo3Reports));
AddDetailsItem('FO4 reports recieved', IntToStr(statistics.fo4Reports));
AddDetailsItem('SSE reports recieved', IntToStr(statistics.sseReports));
AddDetailsItem(' ', ' ');
AddDetailsItem('Session bandwidth', FormatByteSize(sessionBandwidth));
AddDetailsItem('Session uptime', TimeStr(sessionUptime));
Expand Down Expand Up @@ -757,6 +761,7 @@ procedure TBackendForm.ForceRebuildItemClick(Sender: TObject);
bRebuildFO3 := true;
bRebuildFNV := true;
bRebuildFO4 := true;
bRebuildSSE := true;
TTaskProcedures.RebuildDictionaries;
end;

Expand Down Expand Up @@ -1258,7 +1263,9 @@ procedure TBackendForm.HandleMessage(msg: TmpMessage; size: integer;
else if msg.data = 'FO3' then
Inc(statistics.fo3Logins)
else if msg.data = 'FO4' then
Inc(statistics.fo4Logins);
Inc(statistics.fo4Logins)
else if msg.data = 'SSE' then
Inc(statistics.sseLogins);
end;

MSG_REGISTER: begin
Expand Down Expand Up @@ -1381,7 +1388,9 @@ procedure TBackendForm.HandleMessage(msg: TmpMessage; size: integer;
else if report.game = 'FO3' then
Inc(statistics.fo3Reports)
else if report.game = 'FO4' then
Inc(statistics.fo4Reports);
Inc(statistics.fo4Reports)
else if report.game = 'SSE' then
Inc(statistics.sseReports);
except
on x : Exception do begin
QueueLogMessage('ERROR', 'Server', 'Failed to load report '+x.Message);
Expand Down
6 changes: 3 additions & 3 deletions backend/mpDictionaryForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,15 @@ object DictionaryForm: TDictionaryForm
Align = alCustom
Style = csDropDownList
Anchors = [akTop, akRight]
ItemIndex = 0
TabOrder = 0
Text = 'TES5'
OnChange = cbGameChange
Items.Strings = (
'TES5'
'TES4'
'FNV'
'FO3')
'FO3'
'FO4'#11
'SSE')
end
end
object pnlDictionaryInfo: TPanel
Expand Down

0 comments on commit c02170a

Please sign in to comment.