1
0
forked from 0ad/0ad

Various lobby changes and some optimizations in the lobby bot by scythetwirler.

This was SVN commit r14396.
This commit is contained in:
JoshuaJB 2013-12-26 19:45:20 +00:00
parent 0780becb8a
commit ad0d81cb8a
6 changed files with 33 additions and 46 deletions

View File

@ -84,19 +84,17 @@ function init(attribs)
error("Unexpected 'type' in gamesetup init: "+attribs.type);
}
if (attribs.serverName)
if (attribs.serverName)
g_ServerName = attribs.serverName;
// Init the Cancel Button caption and tooltip
var cancelButton = getGUIObjectByName("cancelGame");
if(!Engine.HasXmppClient())
{
cancelButton.caption = "Main menu";
cancelButton.tooltip = "Return to the main menu."
}
else
{
cancelButton.caption = "Quit";
cancelButton.tooltip = "Return to the lobby."
}

View File

@ -296,6 +296,7 @@
<!-- Cancel Button -->
<object
name="cancelGame"
caption="Back"
type="button"
style="StoneButton"
size="100%-164 100%-52 100%-24 100%-24"

View File

@ -63,15 +63,6 @@ function lobbyDisconnect()
Engine.DisconnectXmppClient();
}
////////////////////////////////////////////////////////////////////////////////////////////////
// Server requests functions
////////////////////////////////////////////////////////////////////////////////////////////////
function lobbyRefreshGameList()
{
Engine.SendGetGameList();
}
////////////////////////////////////////////////////////////////////////////////////////////////
// Update functions
////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -145,7 +145,7 @@
<action on="SelectionChange">applyFilters();</action>
</object>
<object type="text" size="15 0 35% 100%" text_align="left" textcolor="white">Show full servers</object>
<object type="text" size="15 0 35% 100%" text_align="left" textcolor="white">Show full games</object>
<object name="showFullFilter"
type="checkbox"
checked="false"

View File

@ -186,8 +186,6 @@ void XmppClient::onConnect()
{
CreateSimpleMessage("system", "connected");
m_mucRoom->join();
SendIqGetGameList();
SendIqGetBoardList();
}
if (m_registration)

View File

@ -400,10 +400,11 @@ class XpartaMuPP(sleekxmpp.ClientXMPP):
StanzaPath('iq/gamereport'),
self.iqhandler,
instream=True))
self.add_event_handler("session_start", self.start)
self.add_event_handler("session_start", self.start)
self.add_event_handler("muc::%s::got_online" % self.room, self.muc_online)
self.add_event_handler("muc::%s::got_offline" % self.room, self.muc_offline)
def start(self, event):
"""
@ -466,20 +467,28 @@ class XpartaMuPP(sleekxmpp.ClientXMPP):
"""
# Send lists/register on leaderboard; depreciated once muc_online
# can send lists/register automatically on joining the room.
try:
self.sendGameList(iq['from'])
self.leaderboard.getOrCreatePlayer(iq['from'])
self.sendBoardList(iq['from'])
except:
traceback.print_exc()
logging.error("Failed to process list request from %s" % iq['from'].bare)
if 'gamelist' in iq.plugins:
try:
self.sendGameList(iq['from'])
except:
traceback.print_exc()
logging.error("Failed to process gamelist request from %s" % iq['from'].bare)
elif 'boardlist' in iq.plugins:
try:
self.leaderboard.getOrCreatePlayer(iq['from'])
self.sendBoardList(iq['from'])
except:
traceback.print_exc()
logging.error("Failed to process boardlist request from %s" % iq['from'].bare)
else:
logging.error("Unknown 'get' type stanza request from %s" % iq['from'].bare)
elif iq['type'] == 'result':
"""
Iq successfully received
"""
pass
elif iq['type'] == 'set':
if 'gamelist' in iq.values:
if 'gamelist' in iq.plugins:
"""
Register-update / unregister a game
"""
@ -511,7 +520,7 @@ class XpartaMuPP(sleekxmpp.ClientXMPP):
logging.error("Failed to process changestate data")
else:
logging.error("Failed to process command '%s' received from %s" % command, iq['from'].bare)
elif 'gamereport' in iq.values:
elif 'gamereport' in iq.plugins:
"""
Client is reporting end of game statistics
"""
@ -536,15 +545,9 @@ class XpartaMuPP(sleekxmpp.ClientXMPP):
games = self.gameList.getAllGames()
if to == "":
for JID in self.nicks.keys():
## Check recipient exists
if str(JID) not in self.nicks:
logging.error("No player with the XmPP ID '%s' known" % str(JID))
return
stz = GameListXmppPlugin()
## Pull games and add each to the stanza
## Pull games and add each to the stanza
for JIDs in games:
g = games[JIDs]
# Only send the games that are in the 'init' state and games
@ -560,20 +563,19 @@ class XpartaMuPP(sleekxmpp.ClientXMPP):
## Try sending the stanza
try:
iq.send()
iq.send(block=False, now=True)
except:
logging.error("Failed to send game list")
else:
## Check recipient exists
if str(to) not in self.nicks:
logging.error("No player with the XmPP ID '%s' known" % str(to))
logging.error("No player with the XmPP ID '%s' known to send gamelist to." % str(to))
return
stz = GameListXmppPlugin()
## Pull games and add each to the stanza
for JID in games:
g = games[JID]
for JIDs in games:
g = games[JIDs]
# Only send the games that are in the 'init' state and games
# that are in the 'waiting' state which the receiving player is in. TODO
if g['state'] == 'init' or (g['state'] == 'waiting' and self.nicks[str(to)] in g['players-init']):
@ -587,7 +589,7 @@ class XpartaMuPP(sleekxmpp.ClientXMPP):
## Try sending the stanza
try:
iq.send()
iq.send(block=False, now=True)
except:
logging.error("Failed to send game list")
@ -607,26 +609,23 @@ class XpartaMuPP(sleekxmpp.ClientXMPP):
iq.setPayload(stz)
if to == "":
for JID in self.nicks.keys():
if str(JID) not in self.nicks:
logging.error("No player with the XmPP ID '%s' known" % str(JID))
return
## Set aditional IQ attributes
iq['to'] = JID
## Try sending the stanza
try:
iq.send()
iq.send(block=False, now=True)
except:
logging.error("Failed to send leaderboard list")
else:
## Check recipient exists
if str(to) not in self.nicks:
logging.error("No player with the XmPP ID '%s' known" % str(to))
logging.error("No player with the XmPP ID '%s' known to send boardlist to" % str(to))
return
## Set aditional IQ attributes
iq['to'] = to
## Try sending the stanza
try:
iq.send()
iq.send(block=False, now=True)
except:
logging.error("Failed to send leaderboard list")
@ -667,7 +666,7 @@ if __name__ == '__main__':
# Setup logging.
logging.basicConfig(level=opts.loglevel,
format='%(levelname)-8s %(message)s')
format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%m-%d-%y %H:%M:%S')
# XpartaMuPP
xmpp = XpartaMuPP(opts.xlogin+'@'+opts.xdomain+'/CC', opts.xpassword, opts.xroom+'@conference.'+opts.xdomain, opts.xnickname)