Wie wird PPlayer innerhalb von MakePlayer angelegt und wie ist es (und sein Basistyp) definiert? Wie ist p.Genetics definiert?
Au, das wollte ich gestern eigentlich gleich mit hinschreiben, hab's dann wohl doch vergessen.
Delphi-Quellcode:
type
PEvoState = ^TEvoState;
TEvoState = record
Action, OnTrue, OnFalse: byte;
end;
PEvoAI = ^TEvoAI;
TEvoAI = record
Name: AnsiString;
States: array[0..127] of TEvoState;
end;
PPlayer = ^TPlayer;
TPlayer = record
id: TPlayerID;
intf: IPlayer;
name: AnsiString;
end;
IPlayer = interface
procedure GrantVoice(const voice: TVoice); overload;
procedure GrantVoice(const voice: TVoice; const piece: TPiece); overload;
end;
PSafeID = ^TSafeID;
TSafeID = record
st, nd, rd: Longword;
end;
PPlayerID = PSafeID;
TPlayerID = TSafeID;
function MakePlayer(const intf: IPlayer; const pid: TPlayerID): PPlayer;
begin
New(Result);
Resptr.intf := intf;
Resptr.id := pid;
end;
procedure DismissPlayer(const p: PPlayer);
begin
Dispose(p);
end;
procedure TEvoDrive.SetAI(const ai: TEvoAI);
begin
FGenetics := ai;
// alternativ:
// FGenetics.States := ai.States;
end;