410 Message:= Message or (gmSwitch and InputMask); |
410 Message:= Message or (gmSwitch and InputMask); |
411 ScriptCall('onSwitch'); |
411 ScriptCall('onSwitch'); |
412 end; |
412 end; |
413 |
413 |
414 procedure chNextTurn(var s: shortstring); |
414 procedure chNextTurn(var s: shortstring); |
415 var checksum: Longword; |
415 var i: Longword; |
416 gi: PGear; |
416 gi: PGear; |
417 begin |
417 begin |
418 s:= s; // avoid compiler hint |
418 s:= s; // avoid compiler hint |
419 |
419 |
420 TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
420 TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
421 |
421 |
422 checksum:= GameTicks; |
422 CheckSum:= CheckSum xor GameTicks; |
423 gi := GearsList; |
423 gi := GearsList; |
424 while gi <> nil do |
424 while gi <> nil do |
425 begin |
425 begin |
426 with gi^ do checksum:= checksum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac; |
426 with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac; |
|
427 AddRandomness(CheckSum); |
427 gi := gi^.NextGear |
428 gi := gi^.NextGear |
428 end; |
429 end; |
429 |
430 |
430 if not CurrentTeam^.ExtDriven then |
431 if not CurrentTeam^.ExtDriven then |
431 begin |
432 begin |
432 s[0]:= #5; |
433 s[0]:= #5; |
433 s[1]:= 'N'; |
434 s[1]:= 'N'; |
434 SDLNet_Write32(checksum, @s[2]); |
435 SDLNet_Write32(CheckSum, @s[2]); |
435 SendIPC(s) |
436 SendIPC(s) |
436 end |
437 end |
437 else |
438 else |
438 TryDo(checksum = lastTurnChecksum, 'Desync detected', true); |
439 TryDo(CheckSum = lastTurnChecksum, 'Desync detected', true); |
439 AddFileLog('Next turn: time '+inttostr(GameTicks)); |
440 AddFileLog('Next turn: time '+inttostr(GameTicks)); |
440 end; |
441 end; |
441 |
442 |
442 procedure chTimer(var s: shortstring); |
443 procedure chTimer(var s: shortstring); |
443 begin |
444 begin |