sync: restore source from Google Drive
Sync changed files to Google Drive / sync (push) Successful in 1h45m13s
Sync changed files to Google Drive / sync (push) Successful in 1h45m13s
This commit is contained in:
1 parent
e2d8247e91
commit
7063d1b1c9
993 files changed
+949976
No files matched your search
@@ -0,0 +1,66 @@
|
||||
unit KM_GameUIDTracker;
|
||||
interface
|
||||
uses
|
||||
KM_CommonClasses;
|
||||
|
||||
type
|
||||
// Units-Houses tracker, to issue unique IDs
|
||||
TKMGameUIDTracker = class
|
||||
private
|
||||
fUIDTracker: Integer;
|
||||
public
|
||||
constructor Create;
|
||||
|
||||
procedure Load(LoadStream: TKMemoryStream);
|
||||
procedure Save(SaveStream: TKMemoryStream);
|
||||
|
||||
function GetNewUID: Integer;
|
||||
end;
|
||||
|
||||
var
|
||||
gUIDTracker: TKMGameUIDTracker;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
{ TKMGameUIDTracker }
|
||||
constructor TKMGameUIDTracker.Create;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
fUIDTracker := 0;
|
||||
end;
|
||||
|
||||
|
||||
procedure TKMGameUIDTracker.Load(LoadStream: TKMemoryStream);
|
||||
begin
|
||||
LoadStream.CheckMarker('UIDTracker');
|
||||
LoadStream.Read(fUIDTracker);
|
||||
end;
|
||||
|
||||
|
||||
procedure TKMGameUIDTracker.Save(SaveStream: TKMemoryStream);
|
||||
begin
|
||||
SaveStream.PlaceMarker('UIDTracker');
|
||||
SaveStream.Write(fUIDTracker);
|
||||
end;
|
||||
|
||||
|
||||
function TKMGameUIDTracker.GetNewUID: Integer;
|
||||
const
|
||||
//Prime numbers let us generate sequence of non-repeating values of max_value length
|
||||
MAX_VALUE = 16777213;
|
||||
STEP = 8765423;
|
||||
begin
|
||||
//UIDs have the following properties:
|
||||
// - allow -1 to indicate no UID (const UID_NONE = -1)
|
||||
// - fit within 24bit (we can use that much for RGB colorcoding in unit picking)
|
||||
// - Start from 1, so that black colorcode can be detected in render and then re-mapped to -1
|
||||
|
||||
fUIDTracker := (fUIDTracker + STEP) mod MAX_VALUE + 1; //1..N range, 0 is nothing for colorpicker
|
||||
Result := fUIDTracker;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
Reference in new issue
Block a user