# HG changeset patch # User unc0rr # Date 1244796751 0 # Node ID a2fa7f594842309cb8dd07d220c1ccff3b4c42b8 # Parent 3f1a19802d10144cb69a1d117a20eb89798a3fa5 Endian aware Land digest diff -r 3f1a19802d10 -r a2fa7f594842 hedgewars/uLand.pas --- a/hedgewars/uLand.pas Fri Jun 12 08:50:20 2009 +0000 +++ b/hedgewars/uLand.pas Fri Jun 12 08:52:31 2009 +0000 @@ -57,7 +57,7 @@ s: shortstring; begin SHA1Init(ctx); -SHA1Update(ctx, @Land, sizeof(Land)); +SHA1UpdateLongwords(ctx, @Land, sizeof(Land) div 4); dig:= SHA1Final(ctx); s:='M{'+inttostr(dig[0])+':' +inttostr(dig[1])+':' @@ -77,11 +77,7 @@ if digest = '' then digest:= s else -{$IFDEF IPHONEOS} - //TryDo(s = digest, 'Different maps generated, sorry', false) FIXME - digest calc needs endian handling -{$ELSE} TryDo(s = digest, 'Different maps generated, sorry', true) -{$ENDIF} end; procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword); diff -r 3f1a19802d10 -r a2fa7f594842 hedgewars/uSHA.pas --- a/hedgewars/uSHA.pas Fri Jun 12 08:50:20 2009 +0000 +++ b/hedgewars/uSHA.pas Fri Jun 12 08:52:31 2009 +0000 @@ -29,6 +29,7 @@ procedure SHA1Init(var Context: TSHA1Context); procedure SHA1Update(var Context: TSHA1Context; Buf: PByteArray; Length: LongWord); +procedure SHA1UpdateLongwords(var Context: TSHA1Context; Buf: PLongwordArray; Length: LongWord); function SHA1Final(Context: TSHA1Context): TSHA1Digest; implementation @@ -116,6 +117,22 @@ end end; +procedure SHA1UpdateLongwords(var Context: TSHA1Context; Buf: PLongwordArray; Length: LongWord); +var i: Longword; +begin +for i:= 0 to Pred(Length div 4) do + begin + SDLNet_Write32(Buf^[i], @Context.Buf[Context.CurrLength]); + inc(Context.CurrLength, 4); + if Context.CurrLength = 64 then + begin + SHA1Hash(Context); + inc(Context.Length, 512); + Context.CurrLength:= 0 + end + end +end; + function SHA1Final(Context: TSHA1Context): TSHA1Digest; var i: LongWord; begin