SelectionListGameNetMessage() vs PushMission()

Putmalk

Deity
Joined
Sep 26, 2010
Messages
2,652
Location
New York
I'm not sure about this one, figure you can help me out.

When executing a ranged attack (WorldView.lua), the LUA calls Game.SelectionListGameNetMessage(). Why? It doesn't work with a custom mission that I tried to implement, meanwhile Unit:PushMission() works perfectly. I'm actually confused why they use SelectionListGameNetMessage() and not PushMission, so if someone could please enlighten me, I'd love to know.

This caused me about 3 hours of frustration before I finally got what I want working. I want answers for that 3 hours. :king: :lol:
 
It's for multiplayer. That function makes sure to send the information to all the connected computers (or more accurately, calls the exe function which does it).

I don't know why that function wouldn't work for you, because CvDllNetMessageHandler::ResponsePushMission just calls CvUnit::PushMission.

Using PushMission instead will likely make your mod not MP compatible. Which at this point doesn't matter at all. If Firaxis do make mods work in MP however your mod will most likely not work in MP unless you use SelectionListGameNetMessage.


If you have logging on you probably have an error message in net_message_debug.log stating "*** PROTOCOL ERROR *** : PushMission invoked for a human controlled player outside of a network message!" every time your stuff is used (for a human, AI stuff in general doesn't use these types of functions).
 
It's for multiplayer. That function makes sure to send the information to all the connected computers (or more accurately, calls the exe function which does it).

I don't know why that function wouldn't work for you, because CvDllNetMessageHandler::ResponsePushMission just calls CvUnit::PushMission.

Using PushMission instead will likely make your mod not MP compatible. Which at this point doesn't matter at all. If Firaxis do make mods work in MP however your mod will most likely not work in MP unless you use SelectionListGameNetMessage.


If you have logging on you probably have an error message in net_message_debug.log stating "*** PROTOCOL ERROR *** : PushMission invoked for a human controlled player outside of a network message!" every time your stuff is used (for a human, AI stuff in general doesn't use these types of functions).

You are right, those protocol errors do exist. However, I can't get SelectionListGameNetMessage to work. And I can't find out why. So this will have to be done directly.

Maybe SelectionListGameNetMessage() is working, but I don't think it's getting the right unit for the mission. So how do I get it to set the unit for the mission?
 
Call is selectionListGameNetMessage(eMessage, iData2, iData3, iData4, iFlags, bAlt, bShift)

You don't set the unit, it's automatically set to the currently selected unit.

eMessage should be GameMessageTypes.GAMEMESSAGE_PUSH_MISSION.
Missiontype is iData2. The meaning of the rest depend on what mission it is.
 
I can re-do the call but it looks identical to what I had before. So I'm not exactly sure what my error was because the function just wasn't calling.

Edit: Doesn't seem to pick up the mission correctly, which doesn't make sense because the mission is spelled correctly (and works with pushmission).

Code:
[85577.718] Net SEND (0): size=53: NetPushMission : Do Mission, who is 0, unit ID is 24578 (Removed), mission is , data1=10, data2=6, shift=false
[85577.733] Net RECV (0) :NetPushMission : Do Mission, who is 0, unit ID is 24578 (Removed), mission is , data1=10, data2=6, shift=false

Yup, my custom MissionType isn't being picked up for some reason, but it is with PushMission.
 
Anyone have any ideas why the custom mission type wouldn't be getting picked up the by the SelectionListGameNetMessage() function, but it does with PushMission()?
 
I don't have any specific ideas about why SelectionListGameNetMessage() would be behaving differently from PushMission() but I did have an alternate implementation of custom missions that didn't require calling PushMission() directly (assuming you're adding a 'custom mission,' in the sense of units being able to perform new actions, rather than in the sense of trying to execute an existing mission at a different time depending on some new condition). The link's in my sig. It hasn't been updated for BNW (still uses the pre-BNW state from G&K) but the source code's all there and the principles involved should be much the same after the update.
 
Back
Top Bottom