Opened 10 years ago

Last modified 3 years ago

#2459 new enhancement

Add a cooperative mode — at Version 8

Reported by: Antoine cezar Owned by:
Priority: Nice to Have Milestone: Backlog
Component: Simulation Keywords:
Cc: Patch:

Description (last modified by elexis)

I've sucessfully made it work with a dirty hack:

Index: source/network/NetServer.cpp
===================================================================
--- source/network/NetServer.cpp	(révision 14856)
+++ source/network/NetServer.cpp	(copie de travail)
@@ -645,7 +645,7 @@
 	PlayerAssignment assignment;
 	assignment.m_Enabled = true;
 	assignment.m_Name = name;
-	assignment.m_PlayerID = playerID;
+	assignment.m_PlayerID = 1;
 	m_PlayerAssignments[guid] = assignment;
 
 	// Send the new assignments to all currently active players

It worked with a modified host and an unmodified client, but you must not touch to the human player placement.

Since seemed to be just a mater of playerID I thougth that tweaking the gamesetup.js should do the trick. But whatever attempt I've made ended in "nothing happened" or "coredump".

I've spotted a potential reason in CNetServerWorker::AssignPlayer which "Remove anyone who's already assigned to this player" before assigning the new playerID and introduced my own method which just set on gui playerID to the other:

void CNetServerWorker::SetCooperation(const CStr& firstGuid, const CStr& secondGuid)
{
	if (m_PlayerAssignments.find(firstGuid) != m_PlayerAssignments.end()
	&&  m_PlayerAssignments.find(secondGuid) != m_PlayerAssignments.end())
	{
		
		m_PlayerAssignments[secondGuid].m_PlayerID = m_PlayerAssignments[firstGuid].m_PlayerID;
		SendPlayerAssignments();
	}
}

And tweaked gamesetup again, but nothing works for now.

Change History (8)

comment:1 by Stan, 9 years ago

Could you submit a patch ?

comment:2 by Antoine cezar, 9 years ago

Sorry didn't see your message.

I did not succeded to make a usable version of this hack. I've given up for the moment. I'll give it another if you find the feature interresting

comment:3 by elexis, 9 years ago

Component: Core engineUI & Simulation
Priority: If Time PermitsNice to Have

So the idea behind this is to have multiple clients control the same player? Would be cool.

In that case you would need to change the "Player X" entries in gamesetup to dropdowns, so that multiple clients can be assigned to the same player ID.

Introducing that might have unwanted consequences, maybe the chat messages might be updated too.

You are correct that CNetServerWorker::AssignPlayer needs to be changed.

comment:4 by elexis, 7 years ago

Refs #4435

comment:5 by wraitii, 7 years ago

Would be nice to distinguish this from a campaign co-op mode (from a ticket POV).

comment:6 by Antoine cezar, 7 years ago

In fact #4435 was exactly what I had in mind in the first place. But given my knowledge of the the code base at the time (and still today) the the best I figured out was to control the same faction. Controlling the same faction seems to me easier to achieve but I wonder in it's relevant if #4435 get implemented. Maybe both could coexists?

comment:7 by elexis, 7 years ago

Your patch also assigns two clients to the same player slot, hence same color, independent of the chosen civilization.

comment:8 by elexis, 7 years ago

Description: modified (diff)

Wouldn't be surprised if we don't have to change the network code at all. See also comments in the duplicate.

Note: See TracTickets for help on using tickets.