[SDK] Question - Where in the src is retiring/dropping handled??

sirkris

Chieftain
Joined
Dec 16, 2005
Messages
57
I'm trying to locate where in the source code it is determined that a player has retired or dropped in a multiplayer game. I am designing an auto-reporting system. Sending the data to the server is easy-- OBTAINING that data (i.e. determining when a player has quit or dropped), that's the hard part. I know the functions for this already exist in the game (otherwise it wouldn't know when to let AI take over), I just need to find where this is done.

Any ideas? I've studied the SDK for over 2 hours now, and I'm completely stumped. Help! =)
 
I have found this in CvGame.cpp:

case CONTROL_RETIRE:
if (!isGameMultiPlayer())
{
setGameState(GAMESTATE_OVER);
}
else
{
if (isNetworkMultiPlayer())
{
gDLL->sendMPRetire();
gDLL->getInterfaceIFace()->exitingToMainMenu();
}
else
{
gDLL->handleRetirement(getActivePlayer());
}
}
break;


But this seems to apply only to the person actually retiring; i.e. this doesn't seem to be the code that determines when -another- player has retired. It does send to other players that the player has retired, but where in the code does it receive that from another player who retires? Also, it doesn't seem to account for "return to main menu" or "return to desktop" either. But so far, this is all I've been able to find.

Does anybody have any ideas where I might find what I'm looking for in this?
 
Hmm isn't there any documentation on this? It wouldn't have to be much, just something to point me in the right direction. It shouldn't be this hard to locate such a basic function....
 
Ok this doesn't make any sense!! :mad:

You know how it broadcasts the message "<playername> has retired from the game." to other players when someone retires? Well, I figured that if I could find where this is handled, then that would be a good place to put in the reporting system (for retirement at least).

But here's the hitch: I don't think I have the full source code here! I do a search for the word "retire" in the SDK, and come up with 5 files. Of those, that specific message doesn't come up. However, CvEnums.h makes reference to a "GAMEMESSAGE_MP_RETIRE" variable. But, at least as far as I can tell, it isn't actually used by any of the cpp files (except for just a definition thing).

So then I thought, it must be handled by the Python files, since the variable isn't even assigned a value in the SDK. So I did a search of my entire Civ4 directory and subdirectories (which include all the necessary Python files?), and only 1 result came up.... the "Readme.htm" file listing the patch fixes.... Obviously, that's not it....


So where else am I supposed to look?! Am I missing something?! It just seems like I don't have the complete source here. Doesn't anyone here have some clue about this?! I'm stumped!
 
Afaik the actual network code isn't included and I can only assume this was considered such since you haven't been able to find it.
 
Omfg you're kidding!! Why wouldn't they include the network code??

Bah well is there any way of obtaining the network code, or are they holding on to it for some inexplicable reason? I mean, the network code is perhaps the most buggy of all! Maybe opening it up to the community would generate some improvements that they've been unable to implement on their own.


Hmm I wonder if there's a workaround then. The problem with including auto-report code client-side only is that a savvy user could simply disconnect from the internet before quitting, deliberately crash the game, etc. On the other hand, since manual reporting is still an option, I guess it's better than nothing.... Damn.

Well at least that explains why I wasn't able to find the SendMPRetire() function....
 
I think they didn't give us the network code to prevent cheating. Atleast that's the only reason I've heard, but can't remember where or when.
 
Well if that's the case, then at least their motives are good. However, if they have good security measures in place, then knowing the source code won't make any difference. On the other hand, people could just as easily learn to cheat without ever looking at the source. To prevent the developer community from improving on the game because of some paranoid fear of cheaters taking over is, at least in my opinion, short-sighted.

But oh well. I won't be able to make a fool-proof reporting system without access to the network code. However, I CAN probably throw together a half-assed one to supplement the existing manual reporting system. If nothing else, it would at least prove that the Fire Badge concept of automated quitter report management is sound.
 
Hmmm - isn't the network code based on Gamespy code or something? I'm guessing that this is similar to the way the graphics engine is - they don't own it so they can't release it for free.
 
True, though unless it's copied line-for-line from Gamespy, then they could at least release the parts of it that aren't copyrighted by Gamespy. It would at least be enough for me to work with.
 
sirkris said:
True, though unless it's copied line-for-line from Gamespy, then they could at least release the parts of it that aren't copyrighted by Gamespy. It would at least be enough for me to work with.

Chances are, though, that they are significantly integrated with gamespy. It probably looks something like:

onPlayerDisconnects(String playerName) { //this is gamespy's method
... // whatever random gamespy code is here
printMessageToAll(playerName + " has retired from the game") //this is the civIV specific code
}

The problem being that splitting out their custom code from the gamespy code would take work, and they aren't likely to take on extra work without some significant motivation.
 
Back
Top Bottom