Changeset 363
- Timestamp:
- Apr 12, 2021, 3:01:58 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GameServer.pas
r355 r363 8 8 uses 9 9 Protocol, Database, dynlibs, Platform, dateutils, fgl, LazFileUtils, 10 Graphics ;10 Graphics, UBrain; 11 11 12 12 const … … 14 14 FirstAICompatibleVersion = $000D00; 15 15 FirstBookCompatibleVersion = $010103; 16 17 // module flags18 fMultiple = $10000000;19 fDotNet = $20000000;20 fUsed = $40000000;21 16 22 17 maxBrain = 255; … … 52 47 TNotifyFunction = procedure(ID: TNotify; Index: Integer = 0); 53 48 54 TBrainType = (btNoTerm, btSuperVirtual, btTerm, btRandom, btAI);55 56 { TBrain }57 58 TBrain = class59 FileName: string;60 DLLName: string;61 Name: string;62 Credits: string; { filename and full name }63 hm: TLibHandle; { module handle }64 Flags: Integer;65 ServerVersion: Integer;66 DataVersion: Integer;67 DataSize: Integer;68 Client: TClientCall; { client function address }69 Initialized: Boolean;70 Kind: TBrainType;71 Picture: TBitmap;72 procedure LoadFromFile(AIFileName: string);73 constructor Create;74 destructor Destroy; override;75 end;76 77 { TBrains }78 79 TBrains = class(TFPGObjectList<TBrain>)80 function AddNew: TBrain;81 function GetKindCount(Kind: TBrainType): Integer;82 procedure GetByKind(Kind: TBrainType; Brains: TBrains);83 end;84 85 49 var 86 50 // PARAMETERS … … 98 62 BrainTerm: TBrain; 99 63 BrainRandom: TBrain; 100 BrainBeginner: TBrain; // AI to use for beginner level101 64 102 65 procedure Init(NotifyFunction: TNotifyFunction); … … 254 217 BrainRandom.Initialized := false; 255 218 BrainRandom.Kind := btRandom; 256 257 BrainBeginner := nil;258 219 259 220 if FindFirst(GetAiDir + DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then … … 4522 4483 end; 4523 4484 4524 { TBrain }4525 4526 procedure TBrain.LoadFromFile(AIFileName: string);4527 var4528 T: Text;4529 Key: string;4530 Value: string;4531 S: string;4532 BasePath: string;4533 I: Integer;4534 begin4535 BasePath := ExtractFileDir(AIFileName);4536 FileName := ExtractFileName(ExtractFileNameWithoutExt(ExtractFileNameWithoutExt(AIFileName)));4537 Name := FileName;4538 DLLName := BasePath + DirectorySeparator + Name + '.dll';4539 Credits := '';4540 Flags := fMultiple;4541 Client := nil;4542 Initialized := false;4543 ServerVersion := 0;4544 if not FileExists(AIFileName) then4545 raise Exception.Create(Format('AI specification file %s not found', [AIFileName]));4546 AssignFile(T, AIFileName);4547 Reset(T);4548 while not EOF(T) do4549 begin4550 ReadLn(T, s);4551 s := trim(s);4552 if Pos(' ', S) > 0 then begin4553 Key := Copy(S, 1, Pos(' ', S) - 1);4554 Value := Trim(Copy(S, Pos(' ', S) + 1, Length(S)));4555 end else begin4556 Key := S;4557 Value := '';4558 end;4559 if Key = '#NAME' then4560 Name := Value4561 else if Key = '#.NET' then4562 Flags := Flags or fDotNet4563 else if Key = '#BEGINNER' then4564 BrainBeginner := Self4565 else if Key = '#PATH' then4566 DLLName := BasePath + DirectorySeparator + Value4567 {$IFDEF WINDOWS}{$IFDEF CPU32}4568 else if Key = '#PATH_WIN32' then4569 DLLName := BasePath + DirectorySeparator + Value4570 {$ENDIF}{$ENDIF}4571 {$IFDEF WINDOWS}{$IFDEF CPU64}4572 else if Key = '#PATH_WIN64' then4573 DLLName := BasePath + DirectorySeparator + Value4574 {$ENDIF}{$ENDIF}4575 {$IFDEF LINUX}{$IFDEF CPU32}4576 else if Key = '#PATH_LINUX32' then4577 DLLName := BasePath + DirectorySeparator + Value4578 {$ENDIF}{$ENDIF}4579 {$IFDEF LINUX}{$IFDEF CPU64}4580 else if Key = '#PATH_LINUX64' then4581 DLLName := BasePath + DirectorySeparator + Value4582 {$ENDIF}{$ENDIF}4583 else if Key = '#GAMEVERSION' then4584 for i := 1 to Length(Value) do4585 case Value[i] of4586 '0' .. '9':4587 ServerVersion := ServerVersion and $FFFF00 + ServerVersion and4588 $FF * 10 + ord(Value[i]) - 48;4589 '.':4590 ServerVersion := ServerVersion shl 8;4591 end4592 else if Key = '#CREDITS' then4593 Credits := Value;4594 end;4595 CloseFile(T);4596 end;4597 4598 constructor TBrain.Create;4599 begin4600 Picture := TBitmap.Create;4601 Picture.SetSize(64, 64);4602 end;4603 4604 destructor TBrain.Destroy;4605 begin4606 FreeAndNil(Picture);4607 inherited;4608 end;4609 4610 { TBrains }4611 4612 function TBrains.AddNew: TBrain;4613 begin4614 Result := TBrain.Create;4615 Add(Result);4616 end;4617 4618 function TBrains.GetKindCount(Kind: TBrainType): Integer;4619 var4620 I: Integer;4621 begin4622 Result := 0;4623 for I := 0 to Count - 1 do4624 if Items[I].Kind = Kind then Inc(Result);4625 end;4626 4627 procedure TBrains.GetByKind(Kind: TBrainType; Brains: TBrains);4628 var4629 I: Integer;4630 begin4631 Brains.Clear;4632 for I := 0 to Count - 1 do4633 if Items[I].Kind = Kind then Brains.Add(Items[I]);4634 end;4635 4485 4636 4486 initialization -
trunk/Integrated.lpi
r320 r363 95 95 </Item2> 96 96 </RequiredPackages> 97 <Units Count="4 3">97 <Units Count="44"> 98 98 <Unit0> 99 99 <Filename Value="Integrated.lpr"/> … … 340 340 <IsPartOfProject Value="True"/> 341 341 </Unit42> 342 <Unit43> 343 <Filename Value="UBrain.pas"/> 344 <IsPartOfProject Value="True"/> 345 </Unit43> 342 346 </Units> 343 347 </ProjectOptions> -
trunk/LocalPlayer/Select.pas
r360 r363 1568 1568 DispLines := MaxLines; 1569 1569 InnerHeight := LineDistance * (DispLines + 1) + 24; 1570 ClientHeight := InnerHeight + TitleHeight + WideFrame 1570 ClientHeight := InnerHeight + TitleHeight + WideFrame; 1571 1571 end 1572 1572 else -
trunk/Start.pas
r359 r363 7 7 GameServer, Messg, ButtonBase, ButtonA, ButtonC, ButtonB, Area, Types, 8 8 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls, 9 Menus, Registry, DrawDlg, fgl, Protocol, UMiniMap ;9 Menus, Registry, DrawDlg, fgl, Protocol, UMiniMap, UBrain; 10 10 11 11 type … … 750 750 yMain + 164 { y0Mini-77 } , Phrases.Lookup('STARTCONTROLS', 16)); 751 751 if AutoDiff = 1 then 752 FrameImage(Canvas, Brain Beginner.Picture, xDefault, yDefault, 64,752 FrameImage(Canvas, Brains.GetBeginner.Picture, xDefault, yDefault, 64, 753 753 64, 0, 0, false) 754 754 else … … 977 977 if (Page = pgStartRandom) and (I <= AutoEnemies) or 978 978 (Page = pgStartMap) and (I < nMapStartPositions) then begin 979 if AutoDiff = 1 then PlayersBrain[I] := Brain Beginner979 if AutoDiff = 1 then PlayersBrain[I] := Brains.GetBeginner 980 980 else PlayersBrain[I] := BrainDefault; 981 981 Difficulty[I] := EnemyAutoDiff[AutoDiff];
Note:
See TracChangeset
for help on using the changeset viewer.