33 procedure GenMap; |
33 procedure GenMap; |
34 function GenPreview: TPreview; |
34 function GenPreview: TPreview; |
35 |
35 |
36 implementation |
36 implementation |
37 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils, |
37 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils, |
38 uVariables, uUtils; |
38 uVariables, uUtils, uCommands, Adler32; |
39 |
39 |
40 operator=(const a, b: direction) c: Boolean; |
40 operator=(const a, b: direction) c: Boolean; |
41 begin |
41 begin |
42 c := (a.x = b.x) and (a.y = b.y); |
42 c := (a.x = b.x) and (a.y = b.y); |
43 end; |
43 end; |
1292 end; |
1292 end; |
1293 |
1293 |
1294 GenPreview:= Preview |
1294 GenPreview:= Preview |
1295 end; |
1295 end; |
1296 |
1296 |
|
1297 |
|
1298 procedure chLandCheck(var s: shortstring); |
|
1299 begin |
|
1300 {$IFDEF DEBUGFILE} |
|
1301 AddFileLog('CheckLandDigest: ' + s + ' digest : ' + digest); |
|
1302 {$ENDIF} |
|
1303 if digest = '' then |
|
1304 digest:= s |
|
1305 else |
|
1306 TryDo(s = digest, 'Different maps generated, sorry', true); |
|
1307 end; |
|
1308 |
|
1309 procedure chSendLandDigest(var s: shortstring); |
|
1310 var adler, i: LongInt; |
|
1311 begin |
|
1312 adler:= 1; |
|
1313 for i:= 0 to LAND_HEIGHT-1 do |
|
1314 Adler32Update(adler, @Land[i,0], LAND_WIDTH); |
|
1315 s:= 'M' + IntToStr(adler); |
|
1316 |
|
1317 chLandCheck(s); |
|
1318 SendIPCRaw(@s[0], Length(s) + 1) |
|
1319 end; |
|
1320 |
1297 procedure initModule; |
1321 procedure initModule; |
1298 begin |
1322 begin |
|
1323 RegisterVariable('landcheck', vtCommand, @chLandCheck, false); |
|
1324 RegisterVariable('sendlanddigest', vtCommand, @chSendLandDigest, false); |
|
1325 |
1299 LandBackSurface:= nil; |
1326 LandBackSurface:= nil; |
1300 digest:= ''; |
1327 digest:= ''; |
1301 |
1328 |
1302 if (cReducedQuality and rqBlurryLand) = 0 then |
1329 if (cReducedQuality and rqBlurryLand) = 0 then |
1303 SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) |
1330 SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) |