Skip to content

Commit

Permalink
Port replay reading and fix checksum calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
veikkos committed Jun 10, 2020
1 parent 74627e5 commit 1fec9ae
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions SJ3REPL.PAS
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ procedure replays(start:boolean;version:string;gdetail:byte);

implementation

uses SJ3Unit, SJ3info, SJ3Help, SJ3PCX, SJ3Graph, Tuuli, Maki, Lumi, SJ3lang, sdlport;
uses SJ3Unit, SJ3info, SJ3Help, SJ3PCX, SJ3Graph, Tuuli, Maki, Lumi, SJ3lang, sdlport, SysUtils;


procedure replays;
Expand Down Expand Up @@ -380,9 +380,33 @@ end;


procedure findreplays;
var DirInfo : TSearchRec;
temp : integer;
begin

NumReplays:=0;
// TODO: Not yet ported

for temp:=0 to 100 do filenames[temp]:='';

if FindFirst ('*.SJR',faAnyFile,DirInfo)=0 then
begin
repeat
if (NumReplays < 100) then
begin
temp:=1;

inc(NumReplays);

while (DirInfo.Name[temp]<>'.') do
begin
filenames[NumReplays]:=filenames[NumReplays]+DirInfo.Name[temp];
inc(temp);
end;
end;
Until FindNext(DirInfo)<>0;

FindClose(DirInfo);
end;
end;

procedure readreplayinfo;
Expand Down Expand Up @@ -436,14 +460,14 @@ end;
temp:=0;
inc(temp,Startx*2+Starty);
inc(temp,maxturns*3);
if (nytmaki<=numwchills) then inc(temp,nytmaki*131);
inc(temp,valuestr(hillfilename,3)*3);
if (nytmaki<=numwchills) then inc(temp,word(nytmaki*131));
inc(temp,word(valuestr(hillfilename,3)*3));
inc(temp,Acthill.profile);
inc(temp,(realhp+2)*69);
inc(temp,word((realhp+2)*69));
inc(temp,flstart+flstop);
inc(temp,(HRx+HRy)*2);
inc(temp,valuestr(author,2));
inc(temp,startgate*1412);
inc(temp,word((HRx+HRy)*2));
inc(temp,word(valuestr(author,2)));
inc(temp,word(startgate*1412));

countcheck:=temp xor 3675433;
end;
Expand Down

0 comments on commit 1fec9ae

Please sign in to comment.