Ticket #3476: t3476_dont_even_look_at_it_wip.patch
File t3476_dont_even_look_at_it_wip.patch, 11.3 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup.js
1892 1892 var mapSize = Engine.GetGUIObjectByName("mapSize").list_data[selectedMapSize]; 1893 1893 else 1894 1894 var mapSize = "Default"; 1895 1896 var victoryCondition = Engine.GetGUIObjectByName("victoryCondition").list[selectedVictoryCondition]; 1895 1897 1896 var victoryCondition = Engine.GetGUIObjectByName("victoryCondition").list[selectedVictoryCondition]; 1898 1899 /*var object = g_GameAttributes.settings.PlayerData; 1900 var output = 'PlayerData:\n'; 1901 for (var player in object) { 1902 output += "player" + player + ":\n"; 1903 for (var property in object[player]) { 1904 output += "\t" + property + ': ' + object[player][property]+'\n'; 1905 } 1906 } 1907 error(output); 1908 1909 return; 1910 var object = g_PlayerAssignments; 1911 var output = 'PlayerAssignments:\n'; 1912 for (var guid in object) { 1913 output += "guid" + guid + "\n"; 1914 for (var property in object[guid]) { 1915 output += "\t" + property + ': ' + object[guid][property]+'\n'; 1916 } 1917 } 1918 error(output); 1919 return; 1920 1921 */ 1922 1923 // DEPRECATED 1924 // nbp = client count 1925 // tnbp = slots available 1897 1926 var numberOfPlayers = Object.keys(g_PlayerAssignments).length; 1898 1927 var players = [ assignment.name for each (assignment in g_PlayerAssignments) ].join(", "); 1899 1900 1928 var nbp = numberOfPlayers ? numberOfPlayers : 1; 1901 1929 var tnbp = g_GameAttributes.settings.PlayerData.length; 1930 var players = [ assignment.name for each (assignment in g_PlayerAssignments) ].join(", "); 1902 1931 1932 // new 1933 var teams = getTeams(g_PlayerAssignments, g_GameAttributes.settings.PlayerData); 1934 var maxPlayers = g_GameAttributes.settings.PlayerData.length; 1935 var playerCount = 0; 1936 for(var i in g_PlayerAssignments) 1937 { 1938 if (g_PlayerAssignments[i]["player"] != -1) 1939 playerCount += 1; 1940 } 1941 1942 // The player names are saved in the assignments 1943 // The team settings are saved in g_GameAttributes.settings.PlayerData 1944 1945 error("Sending stanza"); 1946 1903 1947 var gameData = { 1904 1948 "name":g_ServerName, 1905 1949 "mapName":g_GameAttributes.map, … … 1907 1951 "mapSize":mapSize, 1908 1952 "mapType":g_GameAttributes.mapType, 1909 1953 "victoryCondition":victoryCondition, 1910 "nbp":nbp, 1954 1955 // those 3 deprecated 1956 "nbp":playerCount, 1911 1957 "tnbp":tnbp, 1912 "players":players 1958 "players":players, 1959 1960 "playerCount":playerCount, 1961 "maxPlayers":maxPlayers, 1962 "teams":JSON.stringify(teams), 1963 // save turnnumber, so that we can compute lag time with real time - ingame time - pause time 1964 "pausedTime":0, 1965 "turn":0 // get m_CurrentTurn 1913 1966 }; 1914 1967 Engine.SendRegisterGame(gameData); 1915 1968 } 1916 1969 1970 function getTeams(g_PlayerAssignments, playerData) 1971 { 1972 var teams = {}; 1973 for(var i in playerData) 1974 { 1975 var team = playerData[i]["Team"] + 1; 1976 var ai = playerData[i]["AI"]; 1977 1978 // get player name 1979 var add = false; 1980 var name = "(unassigned)"; 1981 if (ai != "") 1982 { 1983 name = ai + " AI"; 1984 add = true; 1985 } else { 1986 for(var j in g_PlayerAssignments) 1987 { 1988 if (g_PlayerAssignments[j]["player"] == parseInt(i) + 1) { 1989 name = g_PlayerAssignments[j]["name"]; 1990 add = true; 1991 } 1992 } 1993 } 1994 1995 if (add) { 1996 if (!teams.hasOwnProperty(team)) { 1997 teams[team] = []; 1998 } 1999 teams[team].push(name); 2000 } 2001 } 2002 2003 // add observers 2004 teams[-1] = []; 2005 for(var i in g_PlayerAssignments) 2006 { 2007 if (g_PlayerAssignments[i]["player"] == -1) 2008 teams["-1"].push(g_PlayerAssignments[i]["name"]); 2009 } 2010 2011 return teams; 2012 } 2013 1917 2014 function getVictoryConditions() 1918 2015 { 1919 2016 var r = {}; -
binaries/data/mods/public/gui/lobby/lobby.js
113 113 // We assume index 0 means display all for any given filter. 114 114 if (mapSizeFilter.selected != 0 && game.mapSize != mapSizeFilter.list_data[mapSizeFilter.selected]) 115 115 return true; 116 if (playersNumberFilter.selected != 0 && game. tnbp!= playersNumberFilter.list_data[playersNumberFilter.selected])116 if (playersNumberFilter.selected != 0 && game.maxPlayers != playersNumberFilter.list_data[playersNumberFilter.selected]) 117 117 return true; 118 118 if (mapTypeFilter.selected != 0 && game.mapType != mapTypeFilter.list_data[mapTypeFilter.selected]) 119 119 return true; 120 if (!showFullFilter.checked && game. tnbp <= game.nbp)120 if (!showFullFilter.checked && game.playerCount >= game.maxPlayers) 121 121 return true; 122 122 123 123 return false; … … 361 361 // Store the game whole game list data so that we can access it later 362 362 // to update the game info panel. 363 363 g_GameList = gameList; 364 364 365 365 // Sort the list of games to that games 'waiting' are displayed at the top, followed by 'init', followed by 'running'. 366 366 var gameStatuses = ['waiting', 'init', 'running']; 367 367 g_GameList.sort(function (a,b) { … … 406 406 list_mapSize.push(translatedMapSize(g.mapSize)); 407 407 let idx = g_mapTypes.indexOf(g.mapType); 408 408 list_mapType.push(idx != -1 ? g_mapTypesText[idx] : ""); 409 list_nPlayers.push(g. nbp + "/" +g.tnbp);409 list_nPlayers.push(g.playerCount + "/" +g.maxPlayers); 410 410 list.push(g.name); 411 411 list_data.push(c); 412 412 } … … 528 528 529 529 // Display the map name, number of players, the names of the players, the map size and the map type. 530 530 Engine.GetGUIObjectByName("sgMapName").caption = translate(g_GameList[g].niceMapName); 531 Engine.GetGUIObjectByName("sgNbPlayers").caption = g_GameList[g]. nbp + "/" + g_GameList[g].tnbp;532 Engine.GetGUIObjectByName("sgPlayersNames").caption = g _GameList[g].players;531 Engine.GetGUIObjectByName("sgNbPlayers").caption = g_GameList[g].playerCount + "/" + g_GameList[g].maxPlayers; 532 Engine.GetGUIObjectByName("sgPlayersNames").caption = getGameText(g_GameList[g]); 533 533 Engine.GetGUIObjectByName("sgMapSize").caption = translatedMapSize(g_GameList[g].mapSize); 534 534 let idx = g_mapTypes.indexOf(g_GameList[g].mapType); 535 535 Engine.GetGUIObjectByName("sgMapType").caption = idx != -1 ? g_mapTypesText[idx] : ""; … … 550 550 Engine.GetGUIObjectByName("sgMapPreview").sprite = "cropped:(0.7812,0.5859)session/icons/mappreview/" + mapPreview; 551 551 } 552 552 553 function getGameText(game) 554 { 555 var teams = JSON.parse(game["teams"]); 556 557 // find out if free for all 558 var freeForAll = true; 559 for (var team=1; team<=4; team++) 560 { 561 if (teams.hasOwnProperty(team) && teams[team].length > 0) { 562 freeForAll = false; 563 break; 564 } 565 } 566 567 // assemble text 568 var text = ""; 569 var printOrder = [1,2,3,4,0,-1]; 570 for(var p in printOrder) 571 { 572 573 var team = printOrder[p]; 574 if (!teams.hasOwnProperty(team) || teams[team].length == 0) { 575 continue; 576 } 577 578 var names = teams[team].join(", "); 579 580 if (team > 0) 581 text += "Team: " + team + ": " + names + "\n"; 582 else if (team == -1) 583 text += "Observer: " + names + "\n"; 584 else if (team == 0) 585 { 586 if (freeForAll) 587 text += names + "\n"; 588 else 589 text += "No Team: " + names + "\n"; 590 } 591 } 592 593 if (game["state"] == "running") 594 { 595 text += "Started: \n"; 596 text += "Time: \n"; 597 text += "Lag: \n"; // show period spend lagging 598 } 599 600 return text; 601 } 602 603 553 604 /** 554 605 * Start the joining process on the currectly selected game. 555 606 */ … … 599 650 600 651 function onTick() 601 652 { 653 602 654 updateTimers(); 603 655 checkSpamMonitor(); 604 656 … … 839 891 updateSpamMonitor(msg.from); 840 892 if (isSpam(msg.text, msg.from)) 841 893 return; 842 894 843 895 // Format Text 844 896 var formatted = ircFormat(msg.text, msg.from, msg.color, msg.key, msg.datetime); 845 897 -
source/gui/scripting/ScriptFunctions.cpp
420 420 return ps_generate_guid().FromUTF8(); 421 421 } 422 422 423 u32 getCurrentTurn(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) 424 { 425 return g_Game->GetTurnManager()->m_CurrentTurn; 426 } 427 423 428 void RestartInAtlas(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) 424 429 { 425 430 restart_mainloop_in_atlas(); … … 969 974 scriptInterface.RegisterFunction<void, int, &SetPlayerID>("SetPlayerID"); 970 975 scriptInterface.RegisterFunction<void, std::string, &OpenURL>("OpenURL"); 971 976 scriptInterface.RegisterFunction<std::wstring, &GetMatchID>("GetMatchID"); 977 scriptInterface.RegisterFunction<u32, &GetCurrentTurn>("GetCurrentTurn"); 972 978 scriptInterface.RegisterFunction<void, &RestartInAtlas>("RestartInAtlas"); 973 979 scriptInterface.RegisterFunction<bool, &AtlasIsAvailable>("AtlasIsAvailable"); 974 980 scriptInterface.RegisterFunction<bool, &IsAtlasRunning>("IsAtlasRunning"); -
source/lobby/XmppClient.cpp
373 373 std::wstring value; 374 374 scriptInterface.GetProperty(data, properties[i].c_str(), value); 375 375 game->addAttribute(properties[i], utf8_from_wstring(value)); 376 377 //debug_printf("ADDING %s = %s\n", properties[i].c_str(), value.c_str()); 376 378 } 377 379 378 380 // Push the stanza onto the IQ … … 528 530 JS::RootedValue game(cx); 529 531 scriptInterface.Eval("({})", &game); 530 532 531 const char* stats[] = { "name", "ip", "state", "nbp", "tnbp", "player s", "mapName", "niceMapName", "mapSize", "mapType", "victoryCondition" };533 const char* stats[] = { "name", "ip", "state", "nbp", "tnbp", "playerCount", "maxPlayers", "teams", "pausedTime", "turn", "players", "mapName", "niceMapName", "mapSize", "mapType", "victoryCondition" }; 532 534 for (size_t i = 0; i < ARRAY_SIZE(stats); ++i) 533 535 scriptInterface.SetProperty(game, stats[i], wstring_from_utf8((*it)->findAttribute(stats[i]).to_string())); 534 536 -
source/tools/XpartaMuPP/XpartaMuPP.py
20 20 import logging, time, traceback 21 21 from optparse import OptionParser 22 22 23 import sleekxmpp 23 import sleekxmpp,sys 24 24 from sleekxmpp.stanza import Iq 25 25 from sleekxmpp.xmlstream import ElementBase, register_stanza_plugin, ET 26 26 from sleekxmpp.xmlstream.handler import Callback … … 281 281 """ 282 282 Add a game 283 283 """ 284 # DEPRECATED 284 285 data['players-init'] = data['players'] 285 286 data['nbp-init'] = data['nbp'] 287 288 data['playerCount-init'] = data['playerCount'] 289 data['teams-init'] = data['teams'] 290 291 # save when the game started so that we can compute lag time 292 data['game-started'] = time.time() 293 286 294 data['state'] = 'init' 287 295 self.gameList[str(JID)] = data 288 296 def removeGame(self, JID): … … 301 309 """ 302 310 JID = str(JID) 303 311 if JID in self.gameList: 312 self.gameList[JID]['nbp'] = data['nbp'] 304 313 if self.gameList[JID]['nbp-init'] > data['nbp']: 305 314 logging.debug("change game (%s) state from %s to %s", JID, self.gameList[JID]['state'], 'waiting') 306 self.gameList[JID]['nbp'] = data['nbp']307 315 self.gameList[JID]['state'] = 'waiting' 308 316 else: 309 317 logging.debug("change game (%s) state from %s to %s", JID, self.gameList[JID]['state'], 'running')