secondcircle
Chieftain
- Joined
- Aug 4, 2013
- Messages
- 10
Am I going crazy, or is the multiplayer lit up in mod'ed games now? This is huge.. When did this change happen?
Uh wait what? Really?
-------------------------------------------------------------------------------------------
function PWRand()
if not Game:IsNetworkMultiPlayer() then
return math.random()
else
return ((Map.Rand(65535,"") * 65536) + Map.Rand(65535,""))/4294967295 --32 bit floating point precision random for multiplayer.
end
end
-------------------------------------------------------------------------------------------
function PWRandSeed(fixedseed)
if not Game:IsNetworkMultiPlayer() then
local seed
if fixedseed == nil then
seed = (Map.Rand(32767,"") * 65536) + Map.Rand(65535,"")
else
seed = fixedseed
end
math.randomseed(seed) --This function caps at 2,147,483,647, if you set it any higher, or try to trick it with multiple RNGs that can end up with a value above this, it will break randomization.
print("Random seed for this map is " .. seed)
PWRand() --Trash the first random to avoid issues on non-Windows systems.
else
print("Multiplayer game detected, using Map.Rand instead of a seeded lua random.")
end
end
-------------------------------------------------------------------------------------------
--range is inclusive, low and high are possible results
function PWRandint(low, high)
if not Game:IsNetworkMultiPlayer() then
return math.random(low, high)
else
return Map.Rand(high-low,"")+low --the maximum difference between high and low is 65,535 as Map.Rand is limited to returning a 16 bit integer.
end
end
I just tried it out, the game still resynced after 1 turn. My non-host computers Cultural Borders and Warrior was moved about 3 spaces right and 3 spaces up, though the map itself seemed unchanged. I tried a couple of more games after that. It seems the map is unchanged on the client and host computer, although I don't know if they are the same since I never start close enough, but it always seem to resync 1 or 2 turns after start and move the clients cultural borders somewhere else.
"Multiplayer game detected, using Map.Rand instead of a seeded lua random."
"Random seed for this map is ##########"
Holy crap, yup... just confirmed.
However it only works with mods that have been identified in the ModInfo as 'WorksInMultiplayer' = 1
I started a couple of more games, I recopied all the code from the comment, edited the Communitas.lua file and started the firetuner and civ. Firetuner does not seem to work in LAN multiplayer games unfortunately, or I am doing something wrong.
The game did not resync for about 25 turns and the maps seemed to match. Earlier I never got past 2 turns until it resynced. I'm not sure why it worked this time, it might've been I chose the wrong map or something... I then shut down firetuner and enabled logging instead. I restarted the game. Recopied the mod file for both computers so they matched and started another map. This time it resynced at the first turn and I saved the LUA.log files from both computers.
"Multiplayer game detected, using Map.Rand instead of a seeded lua random." shows up in both files.
I've been looking through them and they should be identical but I can see differences here and there... First thing I notice is differing Double values, all whole numbers are identical but double values seem to differ at about the 7th decimal. What is probably more relevant though is that values below row 494 in the log differs more, after "INFO Turn 0 RestoreLakes" where there starts to be larger differences. Different number of lakes target number, different flowing rivers, different placement tries for natural wonders.
Logs pasted to pastebin:
Client Log: http://pastebin.com/a6LS2xwK
Host Log: http://pastebin.com/MMMPL8nQ
Where in the modinfo would one add this?
<Properties>
<Name>blah</Name>
<Teaser>mooo</Teaser>
<Description>blah moo blah</Description>
<Authors>aliens</Authors>
<SpecialThanks>cows</SpecialThanks>
<HideSetupGame>0</HideSetupGame>
<AffectsSavedGames>0</AffectsSavedGames>
<SupportsSinglePlayer>1</SupportsSinglePlayer>
[COLOR="SeaGreen"]<SupportsMultiplayer>1</SupportsMultiplayer>[/COLOR]
<SupportsHotSeat>1</SupportsHotSeat>
<SupportsMac>1</SupportsMac>
<ReloadLandmarkSystem>0</ReloadLandmarkSystem>
<ReloadStrategicViewSystem>0</ReloadStrategicViewSystem>
<ReloadUnitSystem>0</ReloadUnitSystem>
</Properties>