OOS problem: local context vs global context

kipkuhmi

Warlord
Joined
Aug 8, 2007
Messages
131
I have a problem concerning multiplayer.

In my MOD one player is shown a popup where he can choose between option A and B, similar to UN votes.

Internally, "1" means the player has voted YES, "-1" means NO, whereas "0" means he hasn't voted yet.

Now my problem is that when the player clicks the option YES or NO, on his local machine that variable is set to 1 or -1, but this information is not sent to the other computers, so on those machines the variable will still have value 0. They will still be waiting for his vote to come in, and the game will go OOS (out of synch).

So my question is:

Is there a C++ command to force a game instance on one computer to send a certain variable value to all the other computers?

Thanks for any help!
 
Most of the other ButtonPopups use a command like this:

gDLL->sendDiploVote(info.getData1(), (PlayerVoteTypes)pPopupReturn->getButtonClicked());

I don't have a clue what this "sendDiploVote" (or similiar commands like "sendLaunch", "sendKillDeal") does or where it comes from ... I don't find it anywhere else in the SDK, in Python or in XML, except for one spot in CvDLLUtilityIFaceBase.h:

virtual void sendDiploVote(int iVoteId, PlayerVoteTypes eChoice) = 0;

According to the file header commands like "sendDiploVote" would be part of an "abstract interface for utility functions used by DLL" ... does anyone know what that means? What exactly are DLL and gDLL?
 
Although I have done nothing multiplayer-related myself, there is a mechanism to send data to the other connected players via Python using CyMessageControl.sendModNetMessage. Quoting the API:

VOID sendModNetMessage (INT iData1, INT iData2, INT iData3, INT iData4, INT iData5)
This is a NetMessage designed specifically for modders to use to make their mods Multiplayer friendly, eliminating Out-of-Sync errors. Check out 'onModNetMessage()' in CvEventManager for the callback

I strangely couldn't find a similar function in the SDK but perhaps you can either implement that functionality purely in Python and/or use gDLL->getPythonIFace()->callFunction() to interface with the python and handle it in the SDK.
 
Is there a "RecieveModNetMessage" command anywhere? Just wondering how precisely you accomplish much of anything worthwhile with just 5 integers being sent out.

EDIT: Nevermind, I get it now. That is what they meant about looking at "onModNetMessage"... der....
 
Sorry, I still don't get it.

As far as I understand, practically everything in Python is about reading out certain values from the SDK in order to print some messages or statistics to the screen. Python doesn't write values back to the C++ SDK, right?



Let's take the case I have in the SDK an int variable "myVar". I want to make sure that myVar has the same value on all computers to prevent the game from going OOS.

Now what do I do?

Do I have to write a function to export myVar to Python, and afterward process it within Python?

And how do I tell Python to send MyVar to the SDK on all computers?

Sorry for being a bit dim on this ... I've done almost everything in C++ so far and very little in Python.
 
Python does do some things, but it always has to do it through C++ to make it worthwhile of course.


What you would have to do is expose the controls for myVar to python (getMyVar, setMyVar) and then when you are trying to sync MyVar, you'll call Python to run this sendModNetMessage command, passing out 2 integers, the first one informs the onModNetMessage command that you are trying to sync MyVar (so just any indicator you want to use, since you aren't doing anything else yet, we'll say you use 1 for this), and the second INT would be getMyVar. Then it will setMyVar using the second INT.

PseudoCode example:

In SDK where you want to sync:
sendModNetMessage(1, getMyVar) command called from SDK

In Python, under onModNetMessage, you have:

if iValue1 == 1:
setMyVar(iValue2)
 
But how do I use "sendModNetMessage" in C++? The SDK doesn't know that command. Do I have to declare it myself in a header file first? Or did you mean I have to use "sendModNetMessage" within Python also?
 
It seems I'm getting some results with this:

CyArgsList pyArgs;

pyArgs.add(1);
pyArgs.add(GC.getGameINLINE().getOlympicInvitationResponse(GC.getGameINLINE().getActiveTeam()));
pyArgs.add(GC.getGameINLINE().getActiveTeam());

gDLL->getEventReporterIFace()->genericEvent("ModNetMessage", pyArgs.makeFunctionArgs());

But I first have to verify if it works ...
 
No, this didn't work either ...

I don't know what I'm missing out here ... I don't even manage to send the data out to Python. What command do you have to use for that? I tried to use "genericEvent" or "callFunction", but nothing of this works.
 
Hah! I retried the "genericEvent" command, and now it worked. I still get a different error message, but at least I'm now able to communicate between C++ and Python.

Thanks Xienwolf and Dresden (I saw Dresden's hint in another thread with a similiar problem).
 
Top Bottom