-
Notifications
You must be signed in to change notification settings - Fork 0
/
cS_DB.pas
106 lines (89 loc) · 3.03 KB
/
cS_DB.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
unit cS_DB;
{
Autor: Ulrich Hornung
Datum: 14.7.2007
23.5.2008: Neu: TcSActivityStatDB
}
interface
uses
OGame_Types;
type
TcSReportDB = class
protected
function GetReport(nr: cardinal): TScanBericht; virtual; abstract;
procedure SetReport(nr: cardinal; Report: TScanBericht); virtual; abstract;
function GetCount: Integer; virtual; abstract;
public
property Reports[nr: cardinal]: TScanBericht read GetReport write SetReport; default;
property Count: Integer read GetCount;
function FindLatestReport(pos: TPlanetPosition): Integer; virtual;
function AddReport(Report: TScanBericht): Integer; virtual; abstract;
//Only for compatibility to the old Code:
property ScanCount: Integer read GetCount;
procedure DeleteLastScan; virtual; abstract;
end;
TcSSolSysDB = class
protected
function GetSolSys(nr: Cardinal): TSystemCopy; virtual; abstract;
procedure SetSolSys(nr: Cardinal; SolSys: TSystemCopy); virtual; abstract;
function GetCount: Integer; virtual; abstract;
public
property SolSys[nr: cardinal]: TSystemCopy read GetSolSys write SetSolSys; default;
property Count: Integer read GetCount;
function FindLatestSolSys(pos: TSolSysPosition): Integer; //WithoutUse
function AddSolSys(Sys: TSystemCopy): Integer; virtual; abstract;
//Only for compatibility to the old Code:
property SysCount: Integer read GetCount;
procedure DeleteLastSys; virtual; abstract;
end;
TcSFleetDB = class
protected
function GetFleet(nr: Cardinal): TFleetEvent; virtual; abstract;
procedure SetFleet(nr: Cardinal; Fleet: TFleetEvent); virtual; abstract;
function GetCount: Integer; virtual; abstract;
public
property Fleets[nr: cardinal]: TFleetEvent read GetFleet write SetFleet; default;
property Count: Integer read GetCount;
function AddFleet(Fleet: TFleetEvent): Integer; virtual; abstract;
//Only for compatibility to the old Code:
procedure DeleteLastFleet; virtual; abstract;
end;
TcSActivityStatDB = class
protected
function Get(nr: Cardinal): TFleetEvent; virtual; abstract;
procedure SetFleet(nr: Cardinal; Fleet: TFleetEvent); virtual; abstract;
function GetCount: Integer; virtual; abstract;
public
//blablabla
end;
implementation
function TcSReportDB.FindLatestReport(pos: TPlanetPosition): Integer;
var i: Integer;
t: Int64;
begin
Result := -1;
t := low(t);
for i := 0 to Count-1 do
if SamePlanet(pos,Reports[i].Head.Position)and
(Reports[i].Head.Time_u > t) then
begin
Result := i;
t := Reports[i].Head.Time_u;
end;
end;
function TcSSolSysDB.FindLatestSolSys(pos: TSolSysPosition): Integer;
var i: Integer;
t: Int64;
begin
Result := -1;
t := low(t);
for i := 0 to Count-1 do
if (pos[0] = SolSys[i].System.P[0])and
(pos[1] = SolSys[i].System.P[1])and
(SolSys[i].Time_u > t) then
begin
Result := i;
t := SolSys[i].Time_u;
end;
end;
end.