-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcS_DB_reportFile.pas
770 lines (683 loc) · 23.5 KB
/
cS_DB_reportFile.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
unit cS_DB_reportFile;
{
Autor: Ulrich Hornung
Datum: 14.7.2007
}
interface
uses
SDBFile, Windows, SysUtils, OGame_Types, DateUtils, cS_DB, Dialogs;
type
TcSReportFileFormat =
(csr_none,
csr_25,
csr_36,
csr_37,
csr_38,
csr_40,
csr_41);
const
cSRFFStarT_ = 'cscan_scan_'; // don't use for new versions
cSReportFileFormatstr: array[TcSReportFileFormat] of shortstring =
('error',
cSRFFStarT_+'2.5',
cSRFFStarT_+'3.6',
cSRFFStarT_+'3.7',
cSRFFStarT_+'3.8',
'creatureScan_ScanDB_4.0',
'creatureScan_ScanDB_4.1');
new_file_ident = 'new_file';
{
Formatversionen:
...
...
...
***25 auf 36:***
keine Formatänderungen! Nur der bcru(Schlachtkreutzer) wurde neu eingeführt! (kam auch glücklicherweise ans ende der liste dazu!)
deswegen ist auch die einelseroutine kopiert und es hat sich auser der struktur nix geändert!
36, deswegen weil ich mich vertippt hab und eigentlich 26 meinte, aber hab ich erst zu zuspät gemerkt!
***36 auf 37:***
-Neue Forschung: Expeditionstechnik (nach Intergalaktisches Forschungsnetzwerk, vor Gravitonforschung)
***37 auf 38:***
-Aktivitätsanzeige eigelesen!
***39 auf 40***
einfacherer DateiHeader
***40 auf 41***
PlayerID, Ress -> int64
}
type
EcSDBUnknownReportFileFormat = class(Exception);
EcSDBFFReportUniDiffers = class(Exception)
public
file_universe_name: string;
constructor Create(const Msg: string; const uniname: string);
end;
TcSReportHeader_10 = record
V: string[14];
Uni: Byte;
end;
TcSReportHeader_20 = packed record
filetype: string[30];
domain: string[255];
dummy_buffer: string[255];
end;
TcSReportItem_25_36_37_Head = packed record
Planet: TPlanetName;
Position : packed array[0..2] of Word;
P_Mond : Boolean;
Time: TTimeStamp;
Spieler: TPlayerName;
Spionageabwehr: Smallint;
Creator: TPlayerName;
Raid: Boolean;
Raid_Von: TPlayerName;
end;
TcSReportItem_38_Head = packed record
Planet: TPlanetName;
Position : packed array[0..2] of Word;
P_Mond : Boolean;
Time: TTimeStamp;
Spieler: TPlayerName;
Spionageabwehr: Smallint;
Creator: TPlayerName;
Activity: Smallint;
end;
TcSReportItem_41_Head = packed record
Planet: TPlanetName;
Position: packed array[0..2] of Word;
P_Mond: Boolean;
Time_u: Int64;
Spieler: TPlayerName;
SpielerId: Int64; // invalid: 0 or -1
Spionageabwehr: Smallint;
Creator: TPlayerName;
Activity: Smallint;
end;
TcSReportItem_25 = packed record
Head: TcSReportItem_25_36_37_Head;
g0_resources: packed array[1..4] of Integer;
g1_fleets: packed array[1..13] of Integer;
g2_defence: packed array[1..10] of Integer;
g3_buildings: packed array[1..18] of Shortint;
g4_research: packed array[1..15] of Shortint;
end;
TcSReportItem_36 = packed record
Head: TcSReportItem_25_36_37_Head;
g0_resources: packed array[1..4] of Integer;
g1_fleets: packed array[1..14] of Integer;
g2_defence: packed array[1..10] of Integer;
g3_buildings: packed array[1..18] of Shortint;
g4_research: packed array[1..15] of Shortint;
end;
TcSReportItem_37 = packed record
Head: TcSReportItem_25_36_37_Head;
g0_resources: packed array[1..4] of Integer;
g1_fleets: packed array[1..14] of Integer;
g2_defence: packed array[1..10] of Integer;
g3_buildings: packed array[1..18] of Shortint;
g4_research: packed array[1..16] of Shortint;
end;
TcSReportItem_38 = packed record
Head: TcSReportItem_38_Head;
g0_resources: packed array[1..4] of Integer;
g1_fleets: packed array[1..14] of Integer;
g2_defence: packed array[1..10] of Integer;
g3_buildings: packed array[1..18] of Shortint;
g4_research: packed array[1..16] of Shortint;
end;
TcSReportItem_41 = packed record
Head: TcSReportItem_41_Head;
g0_resources: packed array[1..4] of Int64;
g1_fleets: packed array[1..14] of Integer;
g2_defence: packed array[1..10] of Integer;
g3_buildings: packed array[1..18] of Shortint;
g4_research: packed array[1..16] of Shortint;
end;
TcSReportItemToScan = procedure(const ItemBuf: pointer; Result: TScanBericht);
TScantocSReportItem = procedure(const Scan: TScanBericht; const ItemBuf: pointer);
TcSReportDBFile = class(TSimpleDBCachedFile)
private
FHeader: TcSReportHeader_20;
FFormat: TcSReportFileFormat;
FScanToItem: TScantocSReportItem;
FItemToScan: TcSReportItemToScan;
procedure InitFormat;
function GetUni: string;
procedure SetUni(Uni: string);
protected
function NewItemPtr: pointer; override;
procedure DisposeItemPtr(const p: pointer); override;
procedure ItemToPtr(var Buf; const p: pointer); override;
procedure PtrToItem(const p: pointer; var Buf); override;
public
function GetReport(nr: Cardinal): TScanBericht;
procedure SetReport(nr: Cardinal; Report: TScanBericht);
property Reports[nr: Cardinal]: TScanBericht read GetReport write SetReport;
property UniDomain: string read GetUni write SetUni;
constructor Create(aFilename: string);
destructor Destroy; override;
end;
TcSReportDB_for_File = class(TcSReportDB)
private
DBFile: TcSReportDBFile;
protected
function GetReport(nr: cardinal): TScanBericht; override;
procedure SetReport(nr: cardinal; Report: TScanBericht); override;
function GetCount: Integer; override;
public
constructor Create(aFilename: string; UniDomain: string);
destructor Destroy; override;
function AddReport(Report: TScanBericht): Integer; override;
//Only for compatibility to the old Code:
procedure DeleteLastScan; override;
function IsOldFormat: Boolean;
end;
implementation
constructor TcSReportDBFile.Create(aFilename: string);
var frmt: TcSReportFileFormat;
begin
FHeaderSize := SizeOf(TcSReportHeader_20);
inherited Create(aFilename,False);
if (not GetHeader(FHeader)) then
begin
FillChar(FHeader, SizeOf(FHeader), 0);
FFormat := high(cSReportFileFormatstr);
FHeader.filetype := cSReportFileFormatstr[FFormat];
FHeader.domain := new_file_ident;
FHeader.dummy_buffer := '';
SetHeader(FHeader);
end
else
begin
FFormat := csr_none;
for frmt := high(frmt) downto low(frmt) do
if cSReportFileFormatstr[frmt] = FHeader.filetype then
begin
FFormat := frmt;
break;
end;
if (FFormat = csr_none) then
raise EcSDBUnknownReportFileFormat.Create(
'TcSReportDB.Create: Unknown file format (File: "' +
aFilename + '", Format: "' + FHeader.filetype + '")');
end;
InitFormat;
LoadList;
end;
procedure cSReportItem_37_to_Scan(const ItemBuf: pointer; Result: TScanBericht);
var Item: TcSReportItem_37;
i: integer;
begin
Item := TcSReportItem_37(ItemBuf^);
Result.clear;
with Result.Head do
begin
Planet := Item.Head.Planet;
Position.P[0] := Item.Head.Position[0];
Position.P[1] := Item.Head.Position[1];
Position.P[2] := Item.Head.Position[2];
Position.Mond := Item.Head.P_Mond;
Time_u := DateTimeToUnix(TimeStampToDateTime(Item.Head.Time));
Spieler := Item.Head.Spieler;
Spionageabwehr := Item.Head.Spionageabwehr;
Creator := Item.Head.Creator;
{geraidet := Item.Head.Raid;
von := Item.Head.Raid_Von; 14.04.2008: abgeschafft!, Neu: Activity}
Activity := -1;
end;
for i := 1 to length(Item.g0_resources) do
Result.Bericht[sg_Rohstoffe,i-1] := Item.g0_resources[i];
for i := 1 to length(Item.g1_fleets) do
Result.Bericht[sg_Flotten,i-1] := Item.g1_fleets[i];
for i := 1 to length(Item.g2_defence) do
Result.Bericht[sg_Verteidigung,i-1] := Item.g2_defence[i];
for i := 1 to length(Item.g3_buildings) do
Result.Bericht[sg_Gebaeude,i-1] := Item.g3_buildings[i];
for i := 1 to length(Item.g4_research) do
Result.Bericht[sg_Forschung,i-1] := Item.g4_research[i];
end;
procedure cSReportItem_38_to_Scan(const ItemBuf: pointer; Result: TScanBericht);
var Item: TcSReportItem_38;
i: integer;
begin
Item := TcSReportItem_38(ItemBuf^);
Result.clear;
with Result.Head do
begin
Planet := Item.Head.Planet;
Position.P[0] := Item.Head.Position[0];
Position.P[1] := Item.Head.Position[1];
Position.P[2] := Item.Head.Position[2];
Position.Mond := Item.Head.P_Mond;
Time_u := DateTimeToUnix(TimeStampToDateTime(Item.Head.Time));
Spieler := Item.Head.Spieler;
Spionageabwehr := Item.Head.Spionageabwehr;
Creator := Item.Head.Creator;
Activity := Item.Head.Activity;
end;
for i := 1 to length(Item.g0_resources) do
Result.Bericht[sg_Rohstoffe,i-1] := Item.g0_resources[i];
for i := 1 to length(Item.g1_fleets) do
Result.Bericht[sg_Flotten,i-1] := Item.g1_fleets[i];
for i := 1 to length(Item.g2_defence) do
Result.Bericht[sg_Verteidigung,i-1] := Item.g2_defence[i];
for i := 1 to length(Item.g3_buildings) do
Result.Bericht[sg_Gebaeude,i-1] := Item.g3_buildings[i];
for i := 1 to length(Item.g4_research) do
Result.Bericht[sg_Forschung,i-1] := Item.g4_research[i];
end;
procedure cSReportItem_36_to_Scan(const ItemBuf: pointer; Result: TScanBericht);
var Item: TcSReportItem_36;
i: integer;
begin
Item := TcSReportItem_36(ItemBuf^);
Result.clear;
with Result.Head do
begin
Planet := Item.Head.Planet;
Position.P[0] := Item.Head.Position[0];
Position.P[1] := Item.Head.Position[1];
Position.P[2] := Item.Head.Position[2];
Position.Mond := Item.Head.P_Mond;
Time_u := DateTimeToUnix(TimeStampToDateTime(Item.Head.Time));
Spieler := Item.Head.Spieler;
Spionageabwehr := Item.Head.Spionageabwehr;
Creator := Item.Head.Creator;
{geraidet := Item.Head.Raid;
von := Item.Head.Raid_Von; 14.04.2008: abgeschafft!, Neu: Activity}
Activity := -1;
end;
for i := 1 to length(Item.g0_resources) do
Result.Bericht[sg_Rohstoffe,i-1] := Item.g0_resources[i];
for i := 1 to length(Item.g1_fleets) do
Result.Bericht[sg_Flotten,i-1] := Item.g1_fleets[i];
for i := 1 to length(Item.g2_defence) do
Result.Bericht[sg_Verteidigung,i-1] := Item.g2_defence[i];
for i := 1 to length(Item.g3_buildings) do
Result.Bericht[sg_Gebaeude,i-1] := Item.g3_buildings[i];
for i := 1 to length(Item.g4_research) do
begin
if (i-1 >= sb_Expeditionstechnik) then
Result.Bericht[sg_Forschung,i] := Item.g4_research[i]
else Result.Bericht[sg_Forschung,i-1] := Item.g4_research[i];
end;
end;
procedure Scan_to_cSReportItem_37(const Scan: TScanBericht;
const ItemBuf: pointer);
var Item: TcSReportItem_37;
i: integer;
begin
with Item.Head do
begin
Planet := Scan.Head.Planet;
Position[0] := Scan.Head.Position.P[0];
Position[1] := Scan.Head.Position.P[1];
Position[2] := Scan.Head.Position.P[2];
P_Mond := Scan.Head.Position.Mond;
Time := DateTimeToTimeStamp(UnixToDateTime(Scan.Head.Time_u));
Spieler := Scan.Head.Spieler;
Spionageabwehr := Scan.Head.Spionageabwehr;
Creator := Scan.Head.Creator;
Raid := false;
Raid_Von := '';
{ 14.04.2008: abgeschafft!, Neu: Activity }
end;
for i := 1 to length(Item.g0_resources) do
Item.g0_resources[i] := Scan.Bericht[sg_Rohstoffe,i-1];
for i := 1 to length(Item.g1_fleets) do
Item.g1_fleets[i] := Scan.Bericht[sg_Flotten,i-1];
for i := 1 to length(Item.g2_defence) do
Item.g2_defence[i] := Scan.Bericht[sg_Verteidigung,i-1];
for i := 1 to length(Item.g3_buildings) do
Item.g3_buildings[i] := Scan.Bericht[sg_Gebaeude,i-1];
for i := 1 to length(Item.g4_research) do
Item.g4_research[i] := Scan.Bericht[sg_Forschung,i-1];
TcSReportItem_37(ItemBuf^) := Item;
end;
procedure Scan_to_cSReportItem_38(const Scan: TScanBericht;
const ItemBuf: pointer);
var Item: TcSReportItem_38;
i: integer;
begin
with Item.Head do
begin
Planet := Scan.Head.Planet;
Position[0] := Scan.Head.Position.P[0];
Position[1] := Scan.Head.Position.P[1];
Position[2] := Scan.Head.Position.P[2];
P_Mond := Scan.Head.Position.Mond;
Time := DateTimeToTimeStamp(UnixToDateTime(Scan.Head.Time_u));
Spieler := Scan.Head.Spieler;
Spionageabwehr := Scan.Head.Spionageabwehr;
Creator := Scan.Head.Creator;
Activity := Scan.Head.Activity;
end;
for i := 1 to length(Item.g0_resources) do
Item.g0_resources[i] := Scan.Bericht[sg_Rohstoffe,i-1];
for i := 1 to length(Item.g1_fleets) do
Item.g1_fleets[i] := Scan.Bericht[sg_Flotten,i-1];
for i := 1 to length(Item.g2_defence) do
Item.g2_defence[i] := Scan.Bericht[sg_Verteidigung,i-1];
for i := 1 to length(Item.g3_buildings) do
Item.g3_buildings[i] := Scan.Bericht[sg_Gebaeude,i-1];
for i := 1 to length(Item.g4_research) do
Item.g4_research[i] := Scan.Bericht[sg_Forschung,i-1];
TcSReportItem_38(ItemBuf^) := Item;
end;
procedure Scan_to_cSReportItem_36(const Scan: TScanBericht;
const ItemBuf: pointer);
var Item: TcSReportItem_36;
i: integer;
begin
with Item.Head do
begin
Planet := Scan.Head.Planet;
Position[0] := Scan.Head.Position.P[0];
Position[1] := Scan.Head.Position.P[1];
Position[2] := Scan.Head.Position.P[2];
P_Mond := Scan.Head.Position.Mond;
Time := DateTimeToTimeStamp(UnixToDateTime(Scan.Head.Time_u));
Spieler := Scan.Head.Spieler;
Spionageabwehr := Scan.Head.Spionageabwehr;
Creator := Scan.Head.Creator;
Raid := false;
Raid_Von := '';
{ 14.04.2008: abgeschafft!, Neu: Activity }
end;
for i := 1 to length(Item.g0_resources) do
Item.g0_resources[i] := Scan.Bericht[sg_Rohstoffe,i-1];
for i := 1 to length(Item.g1_fleets) do
Item.g1_fleets[i] := Scan.Bericht[sg_Flotten,i-1];
for i := 1 to length(Item.g2_defence) do
Item.g2_defence[i] := Scan.Bericht[sg_Verteidigung,i-1];
for i := 1 to length(Item.g3_buildings) do
Item.g3_buildings[i] := Scan.Bericht[sg_Gebaeude,i-1];
for i := 1 to length(Item.g4_research) do
begin
if (i-1 >= sb_Expeditionstechnik) then
Item.g4_research[i] := Scan.Bericht[sg_Forschung,i]
else Item.g4_research[i] := Scan.Bericht[sg_Forschung,i-1];
end;
TcSReportItem_36(ItemBuf^) := Item;
end;
procedure cSReportItem_25_to_Scan(const ItemBuf: pointer; Result: TScanBericht);
var Item: TcSReportItem_25;
i: integer;
begin
Item := TcSReportItem_25(ItemBuf^);
Result.clear;
with Result.Head do
begin
Planet := Item.Head.Planet;
Position.P[0] := Item.Head.Position[0];
Position.P[1] := Item.Head.Position[1];
Position.P[2] := Item.Head.Position[2];
Position.Mond := Item.Head.P_Mond;
Time_u := DateTimeToUnix(TimeStampToDateTime(Item.Head.Time));
Spieler := Item.Head.Spieler;
Spionageabwehr := Item.Head.Spionageabwehr;
Creator := Item.Head.Creator;
{geraidet := Item.Head.Raid;
von := Item.Head.Raid_Von; 14.04.2008: abgeschafft!, Neu: Activity}
Activity := -1;
end;
for i := 1 to length(Item.g0_resources) do
Result.Bericht[sg_Rohstoffe,i-1] := Item.g0_resources[i];
for i := 1 to length(Item.g1_fleets) do
Result.Bericht[sg_Flotten,i-1] := Item.g1_fleets[i];
for i := 1 to length(Item.g2_defence) do
Result.Bericht[sg_Verteidigung,i-1] := Item.g2_defence[i];
for i := 1 to length(Item.g3_buildings) do
Result.Bericht[sg_Gebaeude,i-1] := Item.g3_buildings[i];
for i := 1 to length(Item.g4_research) do
Result.Bericht[sg_Forschung,i-1] := Item.g4_research[i];
end;
procedure Scan_to_cSReportItem_25(const Scan: TScanBericht;
const ItemBuf: pointer);
var Item: TcSReportItem_25;
i: integer;
begin
with Item.Head do
begin
Planet := Scan.Head.Planet;
Position[0] := Scan.Head.Position.P[0];
Position[1] := Scan.Head.Position.P[1];
Position[2] := Scan.Head.Position.P[2];
P_Mond := Scan.Head.Position.Mond;
Time := DateTimeToTimeStamp(UnixToDateTime(Scan.Head.Time_u));
Spieler := Scan.Head.Spieler;
Spionageabwehr := Scan.Head.Spionageabwehr;
Creator := Scan.Head.Creator;
Raid := false;
Raid_Von := '';
{ 14.04.2008: abgeschafft!, Neu: Activity}
end;
for i := 1 to length(Item.g0_resources) do
Item.g0_resources[i] := Scan.Bericht[sg_Rohstoffe,i-1];
for i := 1 to length(Item.g1_fleets) do
Item.g1_fleets[i] := Scan.Bericht[sg_Flotten,i-1];
for i := 1 to length(Item.g2_defence) do
Item.g2_defence[i] := Scan.Bericht[sg_Verteidigung,i-1];
for i := 1 to length(Item.g3_buildings) do
Item.g3_buildings[i] := Scan.Bericht[sg_Gebaeude,i-1];
for i := 1 to length(Item.g4_research) do
Item.g4_research[i] := Scan.Bericht[sg_Forschung,i-1];
TcSReportItem_25(ItemBuf^) := Item;
end;
procedure cSReportItem_41_to_Scan(const ItemBuf: pointer; Result: TScanBericht);
var Item: TcSReportItem_41;
i: integer;
begin
Item := TcSReportItem_41(ItemBuf^);
Result.clear;
with Result.Head do
begin
Planet := Item.Head.Planet;
Position.P[0] := Item.Head.Position[0];
Position.P[1] := Item.Head.Position[1];
Position.P[2] := Item.Head.Position[2];
Position.Mond := Item.Head.P_Mond;
Time_u := Item.Head.Time_u;
Spieler := Item.Head.Spieler;
SpielerId := Item.Head.SpielerId;
Spionageabwehr := Item.Head.Spionageabwehr;
Creator := Item.Head.Creator;
Activity := Item.Head.Activity;
end;
for i := 1 to length(Item.g0_resources) do
Result.Bericht[sg_Rohstoffe,i-1] := Item.g0_resources[i];
for i := 1 to length(Item.g1_fleets) do
Result.Bericht[sg_Flotten,i-1] := Item.g1_fleets[i];
for i := 1 to length(Item.g2_defence) do
Result.Bericht[sg_Verteidigung,i-1] := Item.g2_defence[i];
for i := 1 to length(Item.g3_buildings) do
Result.Bericht[sg_Gebaeude,i-1] := Item.g3_buildings[i];
for i := 1 to length(Item.g4_research) do
Result.Bericht[sg_Forschung,i-1] := Item.g4_research[i];
end;
procedure Scan_to_cSReportItem_41(const Scan: TScanBericht;
const ItemBuf: pointer);
var Item: TcSReportItem_41;
i: integer;
begin
with Item.Head do
begin
Planet := Scan.Head.Planet;
Position[0] := Scan.Head.Position.P[0];
Position[1] := Scan.Head.Position.P[1];
Position[2] := Scan.Head.Position.P[2];
P_Mond := Scan.Head.Position.Mond;
Time_u := Scan.Head.Time_u;
Spieler := Scan.Head.Spieler;
SpielerId := Scan.Head.SpielerId;
Spionageabwehr := Scan.Head.Spionageabwehr;
Creator := Scan.Head.Creator;
Activity := Scan.Head.Activity;
end;
for i := 1 to length(Item.g0_resources) do
Item.g0_resources[i] := Scan.Bericht[sg_Rohstoffe,i-1];
for i := 1 to length(Item.g1_fleets) do
Item.g1_fleets[i] := Scan.Bericht[sg_Flotten,i-1];
for i := 1 to length(Item.g2_defence) do
Item.g2_defence[i] := Scan.Bericht[sg_Verteidigung,i-1];
for i := 1 to length(Item.g3_buildings) do
Item.g3_buildings[i] := Scan.Bericht[sg_Gebaeude,i-1];
for i := 1 to length(Item.g4_research) do
Item.g4_research[i] := Scan.Bericht[sg_Forschung,i-1];
TcSReportItem_41(ItemBuf^) := Item;
end;
destructor TcSReportDBFile.Destroy;
begin
inherited;
end;
procedure TcSReportDBFile.DisposeItemPtr(const p: pointer);
begin
TScanBericht(p).unlock;
TScanBericht(p).Free;
end;
function TcSReportDBFile.GetReport(nr: Cardinal): TScanBericht;
begin
Result := TScanBericht(GetCachedItem(nr));
end;
function TcSReportDBFile.GetUni: string;
begin
Result := FHeader.domain;
end;
procedure TcSReportDBFile.InitFormat;
var old_h_10: TcSReportHeader_10;
begin
// import old header
case FFormat of
csr_25 .. csr_38:
begin
FHeaderSize := SizeOf(old_h_10);
GetHeader(old_h_10); // low level stream read
FHeader.domain := 'uni' + IntToStr(old_h_10.Uni);
end;
end;
// set read/write function pointer
case FFormat of
csr_25:
begin
FItemSize := SizeOf(TcSReportItem_25);
FScanToItem := Scan_to_cSReportItem_25;
FItemToScan := cSReportItem_25_to_Scan;
end;
csr_36:
begin
FItemSize := SizeOf(TcSReportItem_36);
FScanToItem := Scan_to_cSReportItem_36;
FItemToScan := cSReportItem_36_to_Scan;
end;
csr_37:
begin
FItemSize := SizeOf(TcSReportItem_37);
FScanToItem := Scan_to_cSReportItem_37;
FItemToScan := cSReportItem_37_to_Scan;
end;
csr_38:
begin
FItemSize := SizeOf(TcSReportItem_38);
FScanToItem := Scan_to_cSReportItem_38;
FItemToScan := cSReportItem_38_to_Scan;
end;
csr_40:
begin
// FHeaderSize := SizeOf(TcSReportHeader_20); -> default value
FItemSize := SizeOf(TcSReportItem_38);
FScanToItem := Scan_to_cSReportItem_38;
FItemToScan := cSReportItem_38_to_Scan;
end;
csr_41:
begin
// FHeaderSize := SizeOf(TcSReportHeader_20); -> default value
FItemSize := SizeOf(TcSReportItem_41);
FScanToItem := Scan_to_cSReportItem_41;
FItemToScan := cSReportItem_41_to_Scan;
end;
else
raise Exception.Create('TcSReportDBFile.InitFormat: Es soll eine Datei mit einem nicht definierten Format geöffnet werden!');
end;
end;
procedure TcSReportDBFile.ItemToPtr(var Buf; const p: pointer);
begin
TScanBericht(p).unlock;
FItemToScan(@Buf, TScanBericht(p));
TScanBericht(p).lock;
end;
function TcSReportDBFile.NewItemPtr: pointer;
begin
TScanBericht(Result) := TScanBericht.Create;
TScanBericht(Result).clear;
TScanBericht(Result).lock;
end;
procedure TcSReportDBFile.PtrToItem(const p: pointer; var Buf);
begin
FScanToItem(TScanBericht(p),@Buf);
end;
procedure TcSReportDBFile.SetReport(nr: Cardinal; Report: TScanBericht);
begin
SetItem(nr,Report);
end;
procedure TcSReportDBFile.SetUni(Uni: string);
begin
if FFormat < high(FFormat) then
raise Exception.Create('TcSReportDBFile.SetUni: can''t change old fileformat');
FHeader.domain := Uni;
SetHeader(FHeader);
end;
function TcSReportDB_for_File.AddReport(Report: TScanBericht): Integer;
begin
Result := DBFile.Count;
DBFile.Count := Result + 1;
DBFile.Reports[Result] := Report;
end;
constructor TcSReportDB_for_File.Create(aFilename: string;
UniDomain: string);
begin
inherited Create;
DBFile := TcSReportDBFile.Create(aFilename);
// wenn die datei gerade neu angelegt wurde,
// muss noch die domain gesetzt werden!
if (DBFile.UniDomain = new_file_ident) then
begin
DBFile.UniDomain := UniDomain;
end;
if (UniDomain <> DBFile.UniDomain) then
begin
raise EcSDBFFReportUniDiffers.Create('TcSReportDB_for_File.Create():' +
'the file is for an other universe!', DBFile.UniDomain);
end;
end;
procedure TcSReportDB_for_File.DeleteLastScan;
begin
DBFile.Count := DBFile.Count-1;
end;
destructor TcSReportDB_for_File.Destroy;
begin
DBFile.Free;
inherited;
end;
function TcSReportDB_for_File.GetCount: Integer;
begin
Result := DBFile.Count;
end;
function TcSReportDB_for_File.GetReport(nr: cardinal): TScanBericht;
begin
Result := DBFile.GetReport(nr);
end;
function TcSReportDB_for_File.IsOldFormat: Boolean;
begin
Result := DBFile.FFormat <> high(DBFile.FFormat);
end;
procedure TcSReportDB_for_File.SetReport(nr: cardinal;
Report: TScanBericht);
begin
DBFile.SetReport(nr,Report);
end;
{ EcSDBFFSysUniDiffers }
constructor EcSDBFFReportUniDiffers.Create(const Msg, uniname: string);
begin
inherited Create(Msg);
file_universe_name := uniname;
end;
end.