MPMPM - Multiplayer Mod DLC-hack (Updated!)

Quick question - is that <text> bug fixed yet, i.e. can I pack CPP or is the update still pending?
 
For those of you in the know, did I rewrite the code correctly? I switched every instance of math.random to Game.Rand. Everything seems to be working in game so far, but I just want to be sure.

Reforestation.lua of the Reforestation (v 8) Mod
line 8: local random = math.random
line 36: if (random(1, 100) < 4) then
to
line 8: local random = Game.Rand
line 36: if (random(100,"") + 1 < 4) then

Plague_Main.lua of Health and Plague (v 19) Mod
line 228: local i = math.random(bestCities);
line 271: local i = math.random(#targetCities)
line 296: name = choices[math.random(#choices)]
line 357: local i = math.random(#sabotageTargets)
to
line 228: local i = Game.Rand(bestCities,"") + 1;
line 271: local i = Game.Rand(#targetCities,"") + 1
line 296: name = choices[Game.Rand(#choices,"") + 1]
line 357: local i = Game.Rand(#sabotageTargets,"") + 1

CivNames.lua of Civ Names by Policies (v 8) Mod
Line 315: pd[p] = math.min(6, math.random(0, p1))
Line 322: local way = math.random(1, 3)
Line 325: pd.FREEDOM = math.min(25, math.random(0, p5))
Line 327: pd.ORDER = math.min(25, math.random(0, p5)) * 2
Line 329: pd.AUTOCRACY = math.min(25, math.random(0, p5))
Line 333: local r = math.random()
Line 337: r = math.random()
Line 341: r = math.random()
Line 345: pd.cities = math.random(1, 2)
Line 350: pd.units = math.sqrt(1, math.random(10000)) / 15
Line 358: pd.religion = Game.GetReligionName(rels[math.random(1, n)])
Line 360: r = math.random()
Line 1015: form = math.random(1, 2)
Line 1443: vassal = math.random(1, 5) == 1
Line 1456: return math.random(1, 5) == 1
to
Line 315: pd[p] = math.min(6, Game.Rand(p1,"") + 1)
Line 322: local way = Game.Rand(3,"") + 1
Line 325: pd.FREEDOM = math.min(25, Game.Rand(p5,"") + 1)
Line 327: pd.ORDER = math.min(25, Game.Rand(p5,"") + 1) * 2
Line 329: pd.AUTOCRACY = math.min(25, Game.Rand(p5,"") + 1)
Line 333: local r = Game.Rand(1000,"") / 1000
Line 337: r = Game.Rand(1000,"") / 1000
Line 341: r = Game.Rand(1000,"") / 1000
Line 345: pd.cities = Game.Rand(2,"") + 1
Line 350: pd.units = math.sqrt(1, Game.Rand(10000,"") + 1) / 15
Line 358: pd.religion = Game.GetReligionName(rels[Game.Rand(n,"") + 1])
Line 360: r = Game.Rand(1000,"") / 1000
Line 1015: form = Game.Rand(2,"") + 1
Line 1443: vassal = Game.Rand(5,"") + 1 == 1
Line 1456: return Game.Rand(5,"") + 1 == 1

I noticed that there are some math.randoms in the last lua that call for a minimum value of 0 as opposed to 1? Is it possible for Game.Rand to return 0 as an value without losing the correction for mval-1 that comes by adding the '+ 1'?
 
@Serp

I've encountered this bug during a multiplayer game using either the normal Fortress Borders and your Vorposten Mod. If a desync occurs after the construction of a vorposten, it can revert to a different human player than the one who built it, even if original owner had a unit posted in the vorposten. The game will come back from the desync with that the original owner's unit kicked out and the vorposten borders reverted to different player. I believe that the desync is being caused by this mod as well, but I have no proof other than a hunch.

Edit for more information:
It seems like the calculation that the mod makes to determine whether the property around a vorposten belongs to a particular player or even nature is occurring at the local level - and can result in different outcomes for different players. I've noticed that the land around a vorposten can appear to belong to different players/nature for each player (I've been playing a two computer, two person local network game). When the plot reverts to nature and back has also occurred differently for the two players. I imagine this is what causes the desync. I think the fix would require the border/timer calculations to occur globally so the different instances of the game are on the same page.
 
@Serp

I've encountered this bug during a multiplayer game using either the normal Fortress Borders and your Vorposten Mod. If a desync occurs after the construction of a vorposten, it can revert to a different human player than the one who built it, even if original owner had a unit posted in the vorposten. The game will come back from the desync with that the original owner's unit kicked out and the vorposten borders reverted to different player. I believe that the desync is being caused by this mod as well, but I have no proof other than a hunch.

thanks for reporting the bug :)

I will summarize it to make sure I understand it:
You used just my modpack+EUI, no other mods, correct?
When happens a desync and what action is causing it? Can you explain how to reproduce it and/or send a savegame?
And after a desync, so loading the game, a vorposten could change owner to another human player? What do you mean by "The game will come back from desync..." ?

Ah and how does a desync look like? I think I never had a desync before, so I know nothing about it :D

edit:
okay I tested it and now I know how a desync looks like... I will try to fix this.. until then you should not build a vorposten in multiplayer =/
 
Anyone knows how to get Firetuner work in multiplayer?
If I start a singleplayer, the print statements are printed, but in multiplayer (local on two pcs with the same steam account), the firetuner does not work...
I need the print statements to figure out bugs in multiplayer...
 
Anyone knows how to get Firetuner work in multiplayer?
If I start a singleplayer, the print statements are printed, but in multiplayer (local on two pcs with the same steam account), the firetuner does not work...
I need the print statements to figure out bugs in multiplayer...

I don't know about firetuner, but with logging turned on, it does appear that statements are being written to the log files, like lua.log. Not sure if that helps.
 
I don't know about firetuner, but with logging turned on, it does appear that statements are being written to the log files, like lua.log. Not sure if that helps.

Thanks, this does work :)
The first problem I see is the function:
Events.SerialEventImprovementCreated.Add(function(hex1, hex2, continent1, continent2, iPlayer, improvementType, improvmentRRType, improvementEra, improvementState, improvmentEra2)

After building a Vorposten it prints the follwing in log from player 0:
main: 41 built on tile 12, 12 (4) by player 0.

and at the same time in the log from player 1:
main: 41 built on tile 12, 12 (4) by player 1.

So iPlayer does not work in multiplayer ...
I will try to solve this, but maybe you or cicero does now a function which gives the correct player...

Solved: (unfortunately it's not solved, see my next post..)
I uploaded the fixed main.lua under "known Bugs" in my modpack post http://forums.civfanatics.com/showpost.php?p=13779673&postcount=315 .
I solved it by getting the owner of the unit on the plot, where the vorposten is created, since the worker is standing there.

So I added the lines:
-- iPlayer is wrong in multiplayer, therefore get the player from the unit on this plot. This unit build the improvement
pUnit = pPlot:GetUnit()
Player = pUnit:GetOwner()

(and changed the iPlayer in the function into Player)
 
Thanks, this does work :)

Solved:
I uploaded the fixed main.lua under "known Bugs" in my modpack post http://forums.civfanatics.com/showpost.php?p=13779673&postcount=315 .
I solved it by getting the owner of the unit on the plot, where the vorposten is created, since the worker is standing there.

So I added the lines:
-- iPlayer is wrong in multiplayer, therefore get the player from the unit on this plot. This unit build the improvement
pUnit = pPlot:GetUnit()
Player = pUnit:GetOwner()

(and changed the iPlayer in the function into Player)

Excellent! I'll test it out. I noticed there was some other stuff that called for iPlayer in that lua file. You think that other stuff will be fine?
 
When I go to Assets/Gameplay/NewText I have German (because it is my system language) and English (I guess standard for everyone) texts there. So yes, I'm sure my mutli modpack works in english and german. But it would create blank files, if I try to add another language, cause I don't have the textfiles for these languages.

I read that you can set your language on steam for each game and then steam will download the textfiles for these languages. That way you would be able to create a real multi language modpack.

I think the best solution for MPMPM would be to create a textfile for each language that appaear in the game textfiles or in one mod textfile. *

Or/and you could add an additional download, which includes all major language textfiles for the game. And everyone who want to create a multi language version have to download this first (would make sense, if you have to select and download every single language on steam and are not able to download it in a packet...)

edit:
When I make a modpack with german textfiles only, but the mod has no german translation, ingame will be a "text missing" message for the mod textfiles.
I wonder why...
Anyway, I tested something: I deleted one german text entry in the override file (deleted the whole replace tag). Ingame this missing text was replaced by the english one automatically. So I guess, if no english text is in the override, the text is missing. But if an english text is there, it will replace the missing texts.
-> Every modpack, regardless which language it should be, needs the english texts as standard.

* from this test we know, that missing text entries will be replaced by the english ones. So I think blank override files/missing text entries will be no problem...
...but you should test this, if this is also the case for game textfiles... Because when I play with a modpack, that has english language only, my game language is still german, only the mods are english...

... I'm stucked now :D I don't know if my last sentence mean, that we don't need all gametextfiles... =/

I won't lie, I have no idea what those last two sentences say. But, regarding languages, I went ahead and uploaded a new version that handles multiple languages, but it will still require you to have multiple languages installed. I'm also not sure it's even possible to convince civ 5 to load all the language databases at once. I'll have to think about what to do in that regard...

Quick question - is that <text> bug fixed yet, i.e. can I pack CPP or is the update still pending?

I fixed it and put a pull request here, but it hasen't been merged yet.

Sorry, I missed the pull request because I was operating on my own repo without remembering to check github. I independently fixed that. I would note that the version you submitted only applies to the text database, when the fix should really apply to everything, to be most general. The version that I have now doesn't have the new messages though. Perhaps you could reconcile these?
For those of you in the know, did I rewrite the code correctly? I switched every instance of math.random to Game.Rand. Everything seems to be working in game so far, but I just want to be sure.

I noticed that there are some math.randoms in the last lua that call for a minimum value of 0 as opposed to 1? Is it possible for Game.Rand to return 0 as an value without losing the correction for mval-1 that comes by adding the '+ 1'?

I'll quote myself on this:

EDIT: Oh wait, didn't scan what you were doing. The only real issue is with the empty math.random() call vs. Game.Rand(), where there is no version of Game.Rand() that returns decimals, so you have to do some trickery.
cicero225 said:
Substitute in Game.Rand() for every math.random(). They have slightly different syntax.

Game.Rand( int mval, string log_message) returns a random integer between 0 and mval-1, and inserts the log_message into the lua log. log_message can also just be "" if you want no message.

math.random(), on the other hand, returns either a pseudorandom decimal (double precision) between 0 and 0.9999... or, if called as math.random(mval), gives a random value between 1 and mval.

It's obnoxious, but math.random(mval) need to become Game.Rand(mval,"message")+1, and math.random() needs to become Game.Rand(mval,"message")/mval , where mval is chosen sufficiently high that the change in precision won't matter (1000 is probably safe enough).

Lua stores all numeric values as double precision, so no type conversion is necessary.

Ask me if that doesn't make sense to you.

Edit: Reference links:
http://modiki.civfanatics.com/index....(Civ5_API)
(It doesn't specify the integer range, but the civ 5 source code clearly shows 0 to n-1)
http://www.lua.org/pil/18.html

Anyone knows how to get Firetuner work in multiplayer?
If I start a singleplayer, the print statements are printed, but in multiplayer (local on two pcs with the same steam account), the firetuner does not work...
I need the print statements to figure out bugs in multiplayer...

Firetuner is not compatible with multiplayer, sadly, but lua.log will still update.
 
Excellent! I'll test it out. I noticed there was some other stuff that called for iPlayer in that lua file. You think that other stuff will be fine?

Only this ImprovementCreated function is the problem. So everything else in the lua script should work.

But I did not solved the problem...
I noticed the function/Event is the dumpest function I've ever seen >.<
It is triggered when someone find a new improvement on map and gives out hte player who found it! That's why the iPlayer is wrong and that's also why my fix does not work!
Player 0 builds a Vorposten, but player 1 does not see this. After some turns player 1 find the tile with vorposten and the event is triggered for him... if no unit is stationed in the vorposten, it will have no borders from player 1 view -> desync

Cicero,
do you know a way to circumvent this problem ?
Does other functins/Events exist to solve this? Or are all Events not multiplayer compatible?

Also the mod "improvement upgrades" uses those Events... it could also have some bugs, based on the behaviour I descriped above ...
 
I made a thread here http://forums.civfanatics.com/showthread.php?p=13815777 and got good replies :)
So I think the problem is solved now (again uploaded to known bugs section).

I replaced the Events.SerialEventImprovementCreated.Add with GameEvents.BuildFinished.Add and this should work :)

Would be great if someone could test it in all variations, but I think it works.
 
I made a thread here http://forums.civfanatics.com/showthread.php?p=13815777 and got good replies :)
So I think the problem is solved now (again uploaded to known bugs section).

I replaced the Events.SerialEventImprovementCreated.Add with GameEvents.BuildFinished.Add and this should work :)

Would be great if someone could test it in all variations, but I think it works.
Currently testing civaddiction's modpack, I'll see if it causes less desyncs in there for me.

Also have to say good job from both you and civaddiction. Keep the good work guys ;)
 
@ civaddiction:
I see you updated your modpack and put in most of my improved mods, too :)

You write, that the Barbarian and improvement upgrade mod causes runtime errors.
Are you able to provide more information?
Is it only in mutliplayer or in singleplayer also? And do you now when the errors appaer ? (e.g when a barbarian general is killed or when imrpovement xy is build) ?
 
If I get 'missing xml file' and 'missing sniper.dds' errors during loading screen, what exactly does that mean?

Context: I packed v5 of the NoQuitters mod along with about 60 new civilizations, and I get them whenever I start up a game although I didn't get any error during the making of the Modpack.
 
@ civaddiction:
I see you updated your modpack and put in most of my improved mods, too :)

You write, that the Barbarian and improvement upgrade mod causes runtime errors.
Are you able to provide more information?
Is it only in mutliplayer or in singleplayer also? And do you now when the errors appaer ? (e.g when a barbarian general is killed or when imrpovement xy is build) ?

Hey so I don't remember exactly when it was happening, but if I remember correctly, these runtime errors were happening at the start of the game and almost every turn thereafter. I really didn't test it out too thoroughly because I just eliminated mods that threw errors at the onset. Whether the game could continue with these errors, I don't know. I can go back and test them again but it'll be a little while as I am in the middle good game :D
 
@Serp

This might not add much but here's what I got from the lua.log in an old modpack I made:
Code:
Runtime Error: Assets\DLC\MP_MODSPACK\Mods\(BNW) Leugi's Barbarian Inmersion Enhancements (v 1)\Lua\BarbarianEraScripts.lua:318: attempt to call global 'save' (a nil value)

Runtime Error: Assets\DLC\MP_MODSPACK\Mods\(BNW) Leugi's Barbarian Inmersion Enhancements (v 1)\Lua\BarbarianUnhappiness.lua:26: attempt to call global 'load' (a nil value)

Runtime Error: Assets\DLC\MP_MODSPACK\Mods\(BNW) Leugi's Barbarian Inmersion Enhancements (v 1)\Lua\UI\BarbarianCampPopup.lua:22: attempt to call global 'load' (a nil value)

It's basically what civaddiction got I think, however you might be able to check if there's some "funny business" going on in the code. I know nothing of Lua so I hope this helps.
 
If I get 'missing xml file' and 'missing sniper.dds' errors during loading screen, what exactly does that mean?

Context: I packed v5 of the NoQuitters mod along with about 60 new civilizations, and I get them whenever I start up a game although I didn't get any error during the making of the Modpack.

Well, the errors mean that some xml file is missing, as well as sniper.dds, despite the packing working. Does gamaeplay work?
 
@Serp

This might not add much but here's what I got from the lua.log in an old modpack I made:
Code:
Runtime Error: Assets\DLC\MP_MODSPACK\Mods\(BNW) Leugi's Barbarian Inmersion Enhancements (v 1)\Lua\BarbarianEraScripts.lua:318: attempt to call global 'save' (a nil value)

Runtime Error: Assets\DLC\MP_MODSPACK\Mods\(BNW) Leugi's Barbarian Inmersion Enhancements (v 1)\Lua\BarbarianUnhappiness.lua:26: attempt to call global 'load' (a nil value)

Runtime Error: Assets\DLC\MP_MODSPACK\Mods\(BNW) Leugi's Barbarian Inmersion Enhancements (v 1)\Lua\UI\BarbarianCampPopup.lua:22: attempt to call global 'load' (a nil value)

It's basically what civaddiction got I think, however you might be able to check if there's some "funny business" going on in the code. I know nothing of Lua so I hope this helps.

thanks.
Both, "Improved Upgrades" and "Barbarian Immersion" use the "SaveUtilis.lua". So this could causing problems.

But I just started a game with my v14 modpack in industrial age, played some turns, build some new improvements and fought against some barbarian.
But this save/load errors did not appear... (but two other errors in barbarian script that I will fix in v15).

So I would need information about when these save/load errors appear to reproduce them...

Did you played with my modpack, or do you changed something? Maybe the SaveUtilis.lua was missing?
 
thanks.
Both, "Improved Upgrades" and "Barbarian Immersion" use the "SaveUtilis.lua". So this could causing problems.

Thanks to your suggestion, I found and fixed the problem. You were right about SaveUtils.lua. Thanks to DonQuiche over in the saveUtils.lua thread, I discovered that the file has a coding error that the standard lua interpreter can live with but causes a stumble if you are using LuaJIT (like I am).

There is an error in the code. The standard lua interpreter can live with it but LuaJIT does stumble on it: on line 511 to 514 of SaveUtils.lua, the "\[" escapes are wrong and must be replaced by "["

So removing the backslash from both \[ and \] to just [ and ] in the SaveUtils.lua (lines 514-517 in my file) fixed the code, allowing these mods to properly load without error. Another thing I noticed was that the Improvement Mod was using an outdated SaveUtils.lua file. I updated it to the one the Barbarian mod was using (it is the most recent) and altered both lua files (so it didn't matter which loaded first when making the modpack).

A note on LuaJIT. It supposedly speeds up turn times if the mods you are using heavily utilizes Lua. See this thread for more info: http://forums.civfanatics.com/showthread.php?t=399635

I will include these mods in my next modpack update :)
 
Back
Top Bottom