411 Message:= Message or (gmSwitch and InputMask); |
411 Message:= Message or (gmSwitch and InputMask); |
412 ScriptCall('onSwitch'); |
412 ScriptCall('onSwitch'); |
413 end; |
413 end; |
414 |
414 |
415 procedure chNextTurn(var s: shortstring); |
415 procedure chNextTurn(var s: shortstring); |
416 var checksum: Longword; |
416 var i: Longword; |
417 gi: PGear; |
417 gi: PGear; |
418 begin |
418 begin |
419 s:= s; // avoid compiler hint |
419 s:= s; // avoid compiler hint |
420 |
420 |
421 TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
421 TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
422 |
422 |
423 checksum:= GameTicks; |
423 CheckSum:= CheckSum xor GameTicks; |
424 gi := GearsList; |
424 gi := GearsList; |
425 while gi <> nil do |
425 while gi <> nil do |
426 begin |
426 begin |
427 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 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; |
|
428 AddRandomness(CheckSum); |
428 gi := gi^.NextGear |
429 gi := gi^.NextGear |
429 end; |
430 end; |
430 |
431 |
431 if not CurrentTeam^.ExtDriven then |
432 if not CurrentTeam^.ExtDriven then |
432 begin |
433 begin |
433 s[0]:= #5; |
434 s[0]:= #5; |
434 s[1]:= 'N'; |
435 s[1]:= 'N'; |
435 SDLNet_Write32(checksum, @s[2]); |
436 SDLNet_Write32(CheckSum, @s[2]); |
436 SendIPC(s) |
437 SendIPC(s) |
437 end |
438 end |
438 else |
439 else |
439 TryDo(checksum = lastTurnChecksum, 'Desync detected', true); |
440 TryDo(CheckSum = lastTurnChecksum, 'Desync detected', true); |
440 AddFileLog('Next turn: time '+inttostr(GameTicks)); |
441 AddFileLog('Next turn: time '+inttostr(GameTicks)); |
441 end; |
442 end; |
442 |
443 |
443 procedure chTimer(var s: shortstring); |
444 procedure chTimer(var s: shortstring); |
444 begin |
445 begin |
795 end; |
797 end; |
796 |
798 |
797 procedure initModule; |
799 procedure initModule; |
798 begin |
800 begin |
799 //////// Begin top sorted by freq analysis not including chatmsg |
801 //////// Begin top sorted by freq analysis not including chatmsg |
800 RegisterVariable('+right' , @chRight_p , false); |
802 RegisterVariable('+right' , @chRight_p , false, true); |
801 RegisterVariable('-right' , @chRight_m , false); |
803 RegisterVariable('-right' , @chRight_m , false, true); |
802 RegisterVariable('+up' , @chUp_p , false); |
804 RegisterVariable('+up' , @chUp_p , false, true); |
803 RegisterVariable('-up' , @chUp_m , false); |
805 RegisterVariable('-up' , @chUp_m , false, true); |
804 RegisterVariable('+left' , @chLeft_p , false); |
806 RegisterVariable('+left' , @chLeft_p , false, true); |
805 RegisterVariable('-left' , @chLeft_m , false); |
807 RegisterVariable('-left' , @chLeft_m , false, true); |
806 RegisterVariable('+attack' , @chAttack_p , false); |
808 RegisterVariable('+attack' , @chAttack_p , false); |
807 RegisterVariable('+down' , @chDown_p , false); |
809 RegisterVariable('+down' , @chDown_p , false, true); |
808 RegisterVariable('-down' , @chDown_m , false); |
810 RegisterVariable('-down' , @chDown_m , false, true); |
809 RegisterVariable('hjump' , @chHJump , false); |
811 RegisterVariable('hjump' , @chHJump , false, true); |
810 RegisterVariable('ljump' , @chLJump , false); |
812 RegisterVariable('ljump' , @chLJump , false, true); |
811 RegisterVariable('nextturn', @chNextTurn , false); |
813 RegisterVariable('nextturn', @chNextTurn , false); |
812 RegisterVariable('-attack' , @chAttack_m , false); |
814 RegisterVariable('-attack' , @chAttack_m , false); |
813 RegisterVariable('slot' , @chSlot , false); |
815 RegisterVariable('slot' , @chSlot , false); |
814 RegisterVariable('setweap' , @chSetWeapon , false); |
816 RegisterVariable('setweap' , @chSetWeapon , false, true); |
815 //////// End top by freq analysis |
817 //////// End top by freq analysis |
816 RegisterVariable('gencmd' , @chGenCmd , false); |
818 RegisterVariable('gencmd' , @chGenCmd , false); |
817 RegisterVariable('flag' , @chFlag , false); |
819 RegisterVariable('flag' , @chFlag , false); |
818 RegisterVariable('script' , @chScript , false); |
820 RegisterVariable('script' , @chScript , false); |
819 RegisterVariable('proto' , @chCheckProto , true ); |
821 RegisterVariable('proto' , @chCheckProto , true ); |
855 RegisterVariable('-speedup', @chSpeedup_m , true ); |
857 RegisterVariable('-speedup', @chSpeedup_m , true ); |
856 RegisterVariable('zoomin' , @chZoomIn , true ); |
858 RegisterVariable('zoomin' , @chZoomIn , true ); |
857 RegisterVariable('zoomout' , @chZoomOut , true ); |
859 RegisterVariable('zoomout' , @chZoomOut , true ); |
858 RegisterVariable('zoomreset',@chZoomReset , true ); |
860 RegisterVariable('zoomreset',@chZoomReset , true ); |
859 RegisterVariable('ammomenu', @chAmmoMenu , true); |
861 RegisterVariable('ammomenu', @chAmmoMenu , true); |
860 RegisterVariable('+precise', @chPrecise_p , false); |
862 RegisterVariable('+precise', @chPrecise_p , false, true); |
861 RegisterVariable('-precise', @chPrecise_m , false); |
863 RegisterVariable('-precise', @chPrecise_m , false, true); |
862 RegisterVariable('switch' , @chSwitch , false); |
864 RegisterVariable('switch' , @chSwitch , false); |
863 RegisterVariable('timer' , @chTimer , false); |
865 RegisterVariable('timer' , @chTimer , false, true); |
864 RegisterVariable('taunt' , @chTaunt , false); |
866 RegisterVariable('taunt' , @chTaunt , false); |
865 RegisterVariable('put' , @chPut , false); |
867 RegisterVariable('put' , @chPut , false); |
866 RegisterVariable('+volup' , @chVol_p , true ); |
868 RegisterVariable('+volup' , @chVol_p , true ); |
867 RegisterVariable('-volup' , @chVol_m , true ); |
869 RegisterVariable('-volup' , @chVol_m , true ); |
868 RegisterVariable('+voldown', @chVol_m , true ); |
870 RegisterVariable('+voldown', @chVol_m , true ); |