Changeset 120
- Timestamp:
- Feb 3, 2018, 5:03:31 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Database.pas
r45 r120 652 652 {$IFNDEF SCR} if x = 1 then 653 653 v := pi / 2 { first wave goes horizontal } 654 else {$ENDIF} v := Random * 2 * pi;654 else {$ENDIF} v := DelphiRandom * 2 * pi; 655 655 sa[x] := sin(v) / lx; 656 656 ca[x] := cos(v) / ly; … … 786 786 begin 787 787 inc(AreaCount[xBlock, yBlock]); 788 if Random(AreaCount[xBlock, yBlock]) = 0 then788 if DelphiRandom(AreaCount[xBlock, yBlock]) = 0 then 789 789 RareByArea[xBlock, yBlock] := Loc0 790 790 end … … 857 857 begin 858 858 inc(Cnt); 859 if Random(Cnt) = 0 then859 if DelphiRandom(Cnt) = 0 then 860 860 begin 861 861 xworst := x; … … 908 908 begin 909 909 inc(Cnt); 910 if Random(Cnt) = 0 then910 if DelphiRandom(Cnt) = 0 then 911 911 begin 912 912 iBest := i; … … 996 996 p := Zone[z0, i] * (1 - ZPlus) + Zone[z0 + 1, i] * ZPlus; 997 997 { weight between zones z0 and z0+1 } 998 if Random * p0 < p then998 if DelphiRandom * p0 < p then 999 999 begin 1000 1000 RndLow := i; … … 1136 1136 if plus > MapSize then 1137 1137 plus := MapSize; 1138 Loc0 := Random(MapSize);1138 Loc0 := DelphiRandom(MapSize); 1139 1139 for n := 0 to plus - 1 do 1140 1140 begin … … 1147 1147 1148 1148 for Loc0 := 0 to MapSize - 1 do 1149 if (RealMap[Loc0] = fGrass) and ( Random(100) < ShRandHills) then1149 if (RealMap[Loc0] = fGrass) and (DelphiRandom(100) < ShRandHills) then 1150 1150 RealMap[Loc0] := RealMap[Loc0] or fHills; 1151 1151 … … 1156 1156 for n := 0 to unification * MapSize div 100 do 1157 1157 begin 1158 y := Random(ly);1159 if abs(y - (ly shr 1)) > ly div 4 + Random(ly * hotunification div 100) then1158 y := DelphiRandom(ly); 1159 if abs(y - (ly shr 1)) > ly div 4 + DelphiRandom(ly * hotunification div 100) then 1160 1160 if y < ly shr 1 then 1161 1161 y := ly shr 1 - y 1162 1162 else 1163 1163 y := 3 * ly shr 1 - y; 1164 Loc0 := lx * y + Random(lx);1164 Loc0 := lx * y + DelphiRandom(lx); 1165 1165 if RealMap[Loc0] and fTerrain = fGrass then 1166 1166 begin 1167 Dir := Random(4);1167 Dir := DelphiRandom(4); 1168 1168 Loc1 := dLoc(Loc0, Dir and 1 * 2 - 1, Dir shr 1 * 2 - 1); 1169 1169 if (Loc1 >= 0) and (RealMap[Loc1] and fTerrain = fGrass) then … … 1198 1198 if RealMap[Loc0] and fTerrain = fGrass then 1199 1199 begin // change grassland to swamp 1200 if Random(100) < ShSwamp then1200 if DelphiRandom(100) < ShSwamp then 1201 1201 RealMap[Loc0] := RealMap[Loc0] and not fTerrain or fSwamp; 1202 1202 end; … … 1373 1373 end; 1374 1374 FillChar(nCityLoc, SizeOf(nCityLoc), 0); 1375 Loc := Random(MapSize);1375 Loc := DelphiRandom(MapSize); 1376 1376 for i := 0 to MapSize - 1 do 1377 1377 begin … … 1414 1414 begin // for all start continents 1415 1415 if sccount[c] = 1 then 1416 StartLoc0[p1] := CityLoc[c, Random(nCityLoc[c])]1416 StartLoc0[p1] := CityLoc[c, DelphiRandom(nCityLoc[c])] 1417 1417 else 1418 1418 begin … … 1431 1431 if nRest = 0 then 1432 1432 Break; 1433 j := Random(nRest);1433 j := DelphiRandom(nRest); 1434 1434 TestStartLoc[i] := RestLoc[j]; 1435 1435 RestLoc[j] := RestLoc[nRest - 1]; … … 1494 1494 if (Loc1 >= 0) and (Loc1 < MapSize) and 1495 1495 (RealMap[Loc1] and fDeadLands = 0) then 1496 if IsGoodTile(Loc1) and ( Random(CntGood) < MinGood - CntGoodGrass + 1)1496 if IsGoodTile(Loc1) and (DelphiRandom(CntGood) < MinGood - CntGoodGrass + 1) 1497 1497 then 1498 1498 begin … … 1504 1504 RealMap[Loc1] := RealMap[Loc1] and not fTerrain or fPrairie 1505 1505 else if (RealMap[Loc1] and fTerrain in [fPrairie, fTundra, fSwamp]) 1506 and ( Random(2) = 0) then1506 and (DelphiRandom(2) = 0) then 1507 1507 RealMap[Loc1] := RealMap[Loc1] and not fTerrain or fForest; 1508 1508 end; … … 1526 1526 while i > 0 do 1527 1527 begin 1528 j := Random(nIrrLoc);1528 j := DelphiRandom(nIrrLoc); 1529 1529 RealMap[IrrLoc[j]] := RealMap[IrrLoc[j]] or tiIrrigation; 1530 1530 IrrLoc[j] := IrrLoc[nIrrLoc - 1]; … … 1539 1539 begin 1540 1540 repeat 1541 i := Random(nAlive) + 11541 i := DelphiRandom(nAlive) + 1 1542 1542 until StartLoc0[i] >= 0; 1543 1543 StartLoc[p1] := StartLoc0[i]; … … 1580 1580 begin 1581 1581 inc(n); 1582 if Random(n) = 0 then1582 if DelphiRandom(n) = 0 then 1583 1583 StartLoc2[p1] := Loc1; 1584 1584 end; … … 1637 1637 imax := nPrefStartLoc0; 1638 1638 end; 1639 i := Random(imax + 1);1639 i := DelphiRandom(imax + 1); 1640 1640 StartLoc[p1] := StartLoc0[i]; 1641 1641 StartLoc2[p1] := StartLoc0[i]; … … 1657 1657 { !!!for Loc1:=0 to MapSize-1 do 1658 1658 if RealMap[Loc1] and fterrain>=fGrass then 1659 if random(3)=0 then RealMap[Loc1]:=RealMap[Loc1] or fRoad1660 else if random(3)=0 then RealMap[Loc1]:=RealMap[Loc1] or fRR;1659 if Delphirandom(3)=0 then RealMap[Loc1]:=RealMap[Loc1] or fRoad 1660 else if Delphirandom(3)=0 then RealMap[Loc1]:=RealMap[Loc1] or fRR; 1661 1661 {random Road and Railroad } 1662 1662 { !!!for Loc1:=0 to MapSize-1 do 1663 if (RealMap[Loc1] and fterrain>=fGrass) and ( random(20)=0) then1663 if (RealMap[Loc1] and fterrain>=fGrass) and (Delphirandom(20)=0) then 1664 1664 RealMap[Loc1]:=RealMap[Loc1] or fPoll; } 1665 1665 … … 1782 1782 procedure InitRandomGame; 1783 1783 begin 1784 RandSeed := RND;1784 DelphiRandSeed := RND; 1785 1785 CalculatePrimitive; 1786 1786 CreateElevation; … … 1792 1792 procedure InitMapGame(Human: integer); 1793 1793 begin 1794 RandSeed := RND;1794 DelphiRandSeed := RND; 1795 1795 FindContinents; 1796 1796 PredefinedStartPositions(Human); … … 2770 2770 i, dx, dy, dxMax, dyMax, Loc, NewOwner: integer; 2771 2771 begin 2772 if OriginLoc = -1 then 2773 raise Exception.Create('Location error'); 2772 2774 i := 0; 2773 2775 dyMax := 0; -
trunk/GameServer.pas
r105 r120 295 295 MapSize := lx * ly; 296 296 LandMass := lm; 297 RandSeed := PreviewRND;297 DelphiRandSeed := PreviewRND; 298 298 if not PreviewElevation then 299 299 begin … … 714 714 bix[p1] := -1 715 715 else 716 bix[p1] := bixFirstAI + random(nBrain - bixFirstAI)716 bix[p1] := bixFirstAI + Delphirandom(nBrain - bixFirstAI) 717 717 else 718 718 bix[p1] := bixView[p1]; … … 838 838 RW[p].DefaultDebugMap := nil; 839 839 840 { !!!for i:=0 to nShipPart-1 do GShip[p].Parts[i]:= random((3-i)*2);{ }840 { !!!for i:=0 to nShipPart-1 do GShip[p].Parts[i]:=Delphirandom((3-i)*2);{ } 841 841 end; 842 842 … … 1371 1371 LandMass := NewLandMass; 1372 1372 MaxTurn := NewMaxTurn; 1373 Randomize;1374 RND := RandSeed;1373 DelphiRandomize; 1374 RND := DelphiRandSeed; 1375 1375 Mode := moPlaying; 1376 1376 CL := TCmdList.Create; … … 1416 1416 InitBrain(bixTerm); 1417 1417 1418 Randomize;1418 DelphiRandomize; 1419 1419 GAlive := 0; 1420 1420 GWatching := 1; -
trunk/LocalPlayer/Diagram.pas
r113 r120 68 68 69 69 // stars 70 RandSeed := Player * 11111;70 DelphiRandSeed := Player * 11111; 71 71 for i := 1 to Width - 16 do 72 72 begin 73 x := Random((Width - 16) * 200);74 r := Random(13) + 28;73 x := DelphiRandom((Width - 16) * 200); 74 r := DelphiRandom(13) + 28; 75 75 Canvas.Pixels[x div 200 + 8, x mod 200 + Top] := 76 76 (r * r * r * r div 10001) * $10101; -
trunk/LocalPlayer/Term.pas
r118 r120 1322 1322 begin 1323 1323 inc(CountBest); 1324 if random(CountBest) = 0 then1324 if DelphiRandom(CountBest) = 0 then 1325 1325 result := j 1326 1326 end … … 3502 3502 AILogo[i] := nil; 3503 3503 Canvas.Font.Assign(UniFont[ftSmall]); 3504 InitButtons ();3504 InitButtons; 3505 3505 EOT.Template := Templates; 3506 3506 end; -
trunk/Protocol.pas
r117 r120 1283 1283 end; 1284 1284 1285 { TCity } 1286 1285 1287 TCity = packed record 1286 1288 Loc, { location } … … 1632 1634 { preLeo,preLighthouse, } preLeo); 1633 1635 1636 var 1637 DelphiRandSeed: Integer; 1638 1634 1639 procedure MakeUnitInfo(p: integer; const u: TUn; var ui: TUnitInfo); 1635 1640 procedure MakeModelInfo(p, mix: integer; const m: TModel; var mi: TModelInfo); 1636 1641 function IsSameModel(const mi1, mi2: TModelInfo): boolean; 1637 1642 function SpecialTile(Loc, TerrType, lx: integer): integer; 1643 function DelphiRandom(const pi_Max: Integer): Integer; overload; 1644 function DelphiRandom: Extended; overload; 1645 procedure DelphiRandomize; 1638 1646 1639 1647 implementation … … 1757 1765 end; 1758 1766 1767 function DelphiRandom(const pi_Max: Integer): Integer; 1768 var 1769 Temp: LongInt; 1770 begin 1771 Temp := LongInt(134775813 * DelphiRandSeed + 1); 1772 DelphiRandSeed := Temp; 1773 Result := (UInt64(Cardinal(pi_Max)) * UInt64(Cardinal(Temp))) shr 32; 1774 end; 1775 1776 function DelphiRandom: Extended; overload; 1777 begin 1778 Result := DelphiRandom(High(LongInt)) / High(LongInt); 1779 end; 1780 1781 procedure DelphiRandomize; 1782 begin 1783 Randomize; 1784 DelphiRandSeed := RandSeed; 1785 end; 1786 1759 1787 initialization 1760 1788
Note:
See TracChangeset
for help on using the changeset viewer.