--- a/hedgewars/uLand.pas Sun Nov 21 09:37:48 2010 -0500
+++ b/hedgewars/uLand.pas Sun Nov 21 17:48:58 2010 +0300
@@ -35,7 +35,7 @@
implementation
uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils,
- uVariables, uUtils;
+ uVariables, uUtils, uCommands, Adler32;
operator=(const a, b: direction) c: Boolean;
begin
@@ -1294,8 +1294,35 @@
GenPreview:= Preview
end;
+
+procedure chLandCheck(var s: shortstring);
+begin
+{$IFDEF DEBUGFILE}
+ AddFileLog('CheckLandDigest: ' + s + ' digest : ' + digest);
+{$ENDIF}
+ if digest = '' then
+ digest:= s
+ else
+ TryDo(s = digest, 'Different maps generated, sorry', true);
+end;
+
+procedure chSendLandDigest(var s: shortstring);
+var adler, i: LongInt;
+begin
+ adler:= 1;
+ for i:= 0 to LAND_HEIGHT-1 do
+ Adler32Update(adler, @Land[i,0], LAND_WIDTH);
+ s:= 'M' + IntToStr(adler);
+
+ chLandCheck(s);
+ SendIPCRaw(@s[0], Length(s) + 1)
+end;
+
procedure initModule;
begin
+ RegisterVariable('landcheck', vtCommand, @chLandCheck, false);
+ RegisterVariable('sendlanddigest', vtCommand, @chSendLandDigest, false);
+
LandBackSurface:= nil;
digest:= '';