--- a/hedgewars/hwengine.pas Sun Apr 14 22:57:13 2013 +0200
+++ b/hedgewars/hwengine.pas Mon Apr 15 23:06:06 2013 +0400
@@ -32,7 +32,7 @@
uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uInputHandler
, uSound, uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uAILandMarks, uLandTexture, uCollisions
, SysUtils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted
- , uPhysFSLayer, uCursor
+ , uPhysFSLayer, uCursor, uRandom
{$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF}
{$IFDEF USE_TOUCH_INTERFACE}, uTouch {$ENDIF}
{$IFDEF ANDROID}, GLUnit{$ENDIF}
@@ -79,6 +79,7 @@
DisableSomeWeapons;
AddClouds;
AddFlakes;
+ SetRandomSeed(cSeed, false);
AssignHHCoords;
AddMiscGears;
StoreLoad(false);
--- a/hedgewars/uCommandHandlers.pas Sun Apr 14 22:57:13 2013 +0200
+++ b/hedgewars/uCommandHandlers.pas Mon Apr 15 23:06:06 2013 +0400
@@ -573,7 +573,7 @@
begin
if isDeveloperMode then
begin
- SetRandomSeed(s);
+ SetRandomSeed(s, true);
cSeed:= s;
InitStepsFlags:= InitStepsFlags or cifRandomize
end
--- a/hedgewars/uRandom.pas Sun Apr 14 22:57:13 2013 +0200
+++ b/hedgewars/uRandom.pas Mon Apr 15 23:06:06 2013 +0400
@@ -30,7 +30,7 @@
interface
uses uFloat;
-procedure SetRandomSeed(Seed: shortstring); // Sets the seed that should be used for generating pseudo-random values.
+procedure SetRandomSeed(Seed: shortstring; dropAdditionalPart: boolean); // Sets the seed that should be used for generating pseudo-random values.
function GetRandomf: hwFloat; overload; // Returns a pseudo-random hwFloat.
function GetRandom(m: LongWord): LongWord; overload; inline; // Returns a positive pseudo-random integer smaller than m.
procedure AddRandomness(r: LongWord); inline;
@@ -59,18 +59,24 @@
GetNext:= cirbuf[n]
end;
-procedure SetRandomSeed(Seed: shortstring);
-var i: Longword;
+procedure SetRandomSeed(Seed: shortstring; dropAdditionalPart: boolean);
+var i, t, l: Longword;
begin
n:= 54;
if Length(Seed) > 54 then
Seed:= copy(Seed, 1, 54); // not 55 to ensure we have odd numbers in cirbuf
-for i:= 0 to Pred(Length(Seed)) do
- cirbuf[i]:= byte(Seed[i + 1]);
+t:= 0;
+l:= Length(Seed);
-for i:= Length(Seed) to 54 do
+while (t < l) and ((not dropAdditionalPart) or (Seed[t + 1] <> '|')) do
+ begin
+ cirbuf[t]:= byte(Seed[t + 1]);
+ inc(t)
+ end;
+
+for i:= t to 54 do
cirbuf[i]:= $A98765 + 68; // odd number
for i:= 0 to 1023 do