# Some initial work on networking, fixing session setup, game startup, and command queueing.

- Fixed outdated / buggy networking code in the GUI scripts.
- Finished the API to CNetClient so that it's possible to start a CGame
from it.
- Some enhancements for debugging networking: Enabled updates while the
game is minimized/out-of-focus if it's in a network session. Also
reduced the turn length to something slightly more manageable but still
unplayable (1 sec versus 3 sec).
- Fixed a bug where IssueCommand used to access the order it creates
after queueing it, which is bad if the order gets deleted while being
queued (e.g. in CNetClient).

This was SVN commit r5139.
This commit is contained in:
Matei
2007-06-04 07:41:05 +00:00
parent db189468a9
commit 92578ae553
12 changed files with 100 additions and 85 deletions
+14 -6
View File
@@ -237,17 +237,18 @@ JSBool IssueCommand( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rv
entities.push_back( (ToNative<CEntity>(argv[0])) ->me);
else
entities = *EntityCollection::RetrieveSet(cx, JSVAL_TO_OBJECT(argv[0]));
std::map<int, CEntityList> entityStore;
bool isQueued = ToPrimitive<bool>(argv[1]);
//Destroy old notifiers if we're explicitly being reassigned
for ( size_t i=0; i < entities.size(); i++)
{
if ( entities[i]->entf_get(ENTF_DESTROY_NOTIFIERS))
entities[i]->DestroyAllNotifiers();
}
std::vector<CNetMessage*> messages;
//Generate messages for formations
@@ -281,9 +282,9 @@ JSBool IssueCommand( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rv
for ( std::vector<CNetMessage*>::iterator it=messages.begin(); it != messages.end(); it++ )
{
//g_Console->InsertMessage(L"IssueCommand: %hs", (*it)->GetString().c_str());
g_Game->GetSimulation()->QueueLocalCommand(*it);
g_Console->InsertMessage(L"IssueCommand: %hs", (*it)->GetString().c_str());
*rval = g_ScriptingHost.UCStringToValue((*it)->GetString());
g_Game->GetSimulation()->QueueLocalCommand(*it);
}
return JS_TRUE;
@@ -728,11 +729,14 @@ JSBool StartGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
// Hosted MP Game
if (g_NetServer)
if (g_NetServer)
{
*rval = BOOLEAN_TO_JSVAL(g_NetServer->StartGame() == 0);
// Joined MP Game: StartGame is invalid - do nothing
}
// Joined MP Game
else if (g_NetClient)
{
*rval = BOOLEAN_TO_JSVAL(g_NetClient->StartGame() == 0);
}
// Start an SP Game Session
else if (!g_Game)
@@ -750,6 +754,10 @@ JSBool StartGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
return( JS_TRUE );
}
}
else
{
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
}
return( JS_TRUE );
}