From: <z-...@us...> - 2008-01-16 10:27:25
|
Revision: 7523 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=7523&view=rev Author: z-man Date: 2008-01-16 02:27:25 -0800 (Wed, 16 Jan 2008) Log Message: ----------- Merging branch 0.2.8 from revision 7453 to 7520: ------------------------------------------------------------------------ r7520 | z-man | 2008-01-16 10:39:56 +0100 (Wed, 16 Jan 2008) | 2 lines Better ordering for the OnRender() call. ------------------------------------------------------------------------ r7519 | z-man | 2008-01-16 02:15:54 +0100 (Wed, 16 Jan 2008) | 2 lines Added OnRender() function that is called before the menuitems are rendered. ------------------------------------------------------------------------ r7504 | nemostultae | 2008-01-11 08:26:02 +0100 (Fri, 11 Jan 2008) | 2 lines Remove intermediate folder holding package files ------------------------------------------------------------------------ r7502 | nemostultae | 2008-01-11 08:06:39 +0100 (Fri, 11 Jan 2008) | 2 lines Fixed #determine_source_kind to correctly identify svn checkouts. Corrects problem of the version not showing up on the title screen. ------------------------------------------------------------------------ r7501 | nemostultae | 2008-01-11 03:13:14 +0100 (Fri, 11 Jan 2008) | 3 lines ?\226?\128?\162 Only build for native architecture in ?\226?\128?\156Debug?\226?\128?\157 builds ?\226?\128?\162?\194?\160Changed to a valid CFBundleSignature to silence a warning ------------------------------------------------------------------------ r7500 | nemostultae | 2008-01-11 02:41:32 +0100 (Fri, 11 Jan 2008) | 4 lines ?\226?\128?\162 Removed TextMate project ?\226?\128?\162 Edited some svn:ignore properties ?\226?\128?\162 Small change to project file by Xcode 3 so we stay compatible with 2.4 ------------------------------------------------------------------------ r7499 | z-man | 2008-01-11 00:19:36 +0100 (Fri, 11 Jan 2008) | 2 lines Switched continuous unblocking of stdin to only doing so when SIGCONT is received. That was easy :) ------------------------------------------------------------------------ r7498 | z-man | 2008-01-10 21:26:56 +0100 (Thu, 10 Jan 2008) | 2 lines Corrected conqueror log loop. ------------------------------------------------------------------------ r7497 | z-man | 2008-01-10 17:30:20 +0100 (Thu, 10 Jan 2008) | 2 lines Added redirection possibility for vote kicks. ------------------------------------------------------------------------ r7496 | z-man | 2008-01-10 17:08:24 +0100 (Thu, 10 Jan 2008) | 3 lines Added KICK_TO and MOVE_TO, redirecting a player to a different server. Fixed crash from one of the leak fixes. ------------------------------------------------------------------------ r7495 | z-man | 2008-01-10 11:48:46 +0100 (Thu, 10 Jan 2008) | 2 lines Unblocking stdin before every read. SIGSTOP signals cause it to get blocked, freezing the server. ------------------------------------------------------------------------ r7494 | z-man | 2008-01-10 11:46:42 +0100 (Thu, 10 Jan 2008) | 2 lines Not compensating hickups when playing back. Makes no sense. ------------------------------------------------------------------------ r7492 | z-man | 2008-01-10 10:27:21 +0100 (Thu, 10 Jan 2008) | 2 lines RINCLUDE command now actually calls the new RInclude function :) ------------------------------------------------------------------------ r7491 | z-man | 2008-01-10 03:04:27 +0100 (Thu, 10 Jan 2008) | 2 lines Fixed leak in machine decorators, forgot to delete this in Destroy(). ------------------------------------------------------------------------ r7490 | z-man | 2008-01-10 02:43:13 +0100 (Thu, 10 Jan 2008) | 6 lines Fixed memory leak caused by missing gParser destructor. The leakfinding memory manager missed it because all allocation was done through libxml2, and it passed casual code review because the corresponding delete operation did happen, just not always; a leak would occur every time a completely new game was started. (migrated to tXmlParser.cpp) ------------------------------------------------------------------------ r7489 | luke-jr | 2008-01-10 02:41:51 +0100 (Thu, 10 Jan 2008) | 1 line the rest of RInclude, since I just accidentally committed part of it; revert if you like ------------------------------------------------------------------------ r7488 | luke-jr | 2008-01-10 02:40:39 +0100 (Thu, 10 Jan 2008) | 1 line apparently I missed this a while ago ------------------------------------------------------------------------ r7487 | z-man | 2008-01-10 02:21:38 +0100 (Thu, 10 Jan 2008) | 2 lines Listening to console input while waiting for players (and only spectators are there). ------------------------------------------------------------------------ r7486 | z-man | 2008-01-07 19:51:55 +0100 (Mon, 07 Jan 2008) | 2 lines Added non-existing comment about TIME_FACTOR to non-existing documentation. ------------------------------------------------------------------------ r7461 | wrtlprnft | 2008-01-04 23:25:27 +0100 (Fri, 04 Jan 2008) | 2 lines adding PLAYER_MESSAGE (btw, I'm not the only one with commit access to NEWS IIRC) ------------------------------------------------------------------------ r7459 | wrtlprnft | 2008-01-04 21:51:54 +0100 (Fri, 04 Jan 2008) | 2 lines small fixes, thanks luke-jr ------------------------------------------------------------------------ r7458 | wrtlprnft | 2008-01-04 21:37:23 +0100 (Fri, 04 Jan 2008) | 2 lines Got rid of the spurious commit ;-) ------------------------------------------------------------------------ r7457 | wrtlprnft | 2008-01-04 21:29:28 +0100 (Fri, 04 Jan 2008) | 2 lines Added luke's new commands ------------------------------------------------------------------------ NOT MERGING, TOO MANY CONFLICTS: ------------------------------------------------------------------------ r7493 | z-man | 2008-01-10 10:30:18 +0100 (Thu, 10 Jan 2008) | 2 lines Fixed xmlGetProp memory leaks. ( There will likely be completely different leaks of this type in the trunk anyway ) ------------------------------------------------------------------------ r7503 | nemostultae | 2008-01-11 08:16:57 +0100 (Fri, 11 Jan 2008) | 13 lines ?\226?\128?\162 Only build for native architecture in dedicated ?\226?\128?\156Debug?\226?\128?\157 builds as well. ?\226?\128?\162 Remove package files build step from dedicated target ?\226?\128?\162 Pass in useful command-line arguments for dedicated target (--datadir, etc?\226?\128?\166) ?\226?\128?\162 Added ?\226?\128?\156Create Client Release?\226?\128?\157, ?\226?\128?\156Create Dedicated Release?\226?\128?\157, and ?\226?\128?\156Create Full Release?\226?\128?\157 targets. The disk images are placed in $BUILT_PRODUCTS_DIR (build/Release usually). The ?\226?\128?\156Create Client Release?\226?\128?\157 target checks to see if you have an $AA_RECORDER_APP environment variable set, and if you do the recorder app will be included in the disk image. For example I have in my .bash_profile: AA_RECORDER_APP="/Users/Shared/Applications/Games/Armagetron Advanced Recorder.app" ?\226?\128?\162 Changed a few svn:ignore properties to ignore generated files ?\226?\128?\162 dmg-convert, dmg-create ?\226?\134?\146 added ?\226?\128?\162 Updated README-Subversion with new information about targets Revision Links: -------------- http://armagetronad.svn.sourceforge.net/armagetronad/?rev=7453&view=rev Modified Paths: -------------- armagetronad/trunk/armagetronad/NEWS armagetronad/trunk/armagetronad/README-Subversion armagetronad/trunk/armagetronad/config/settings.cfg armagetronad/trunk/armagetronad/config/settings_dedicated.cfg armagetronad/trunk/armagetronad/language/english_base.txt armagetronad/trunk/armagetronad/src/engine/ePlayer.cpp armagetronad/trunk/armagetronad/src/engine/eVoter.cpp armagetronad/trunk/armagetronad/src/network/nNetwork.cpp armagetronad/trunk/armagetronad/src/network/nNetwork.h armagetronad/trunk/armagetronad/src/network/nServerInfo.cpp armagetronad/trunk/armagetronad/src/network/nServerInfo.h armagetronad/trunk/armagetronad/src/render/rConsoleCout.cpp armagetronad/trunk/armagetronad/src/tools/tConfiguration.cpp armagetronad/trunk/armagetronad/src/tools/tSysTime.cpp armagetronad/trunk/armagetronad/src/tools/tXmlParser.cpp armagetronad/trunk/armagetronad/src/tron/gCommandLineJumpStart.cpp armagetronad/trunk/armagetronad/src/tron/gCommandLineJumpStart.h armagetronad/trunk/armagetronad/src/tron/gGame.cpp armagetronad/trunk/armagetronad/src/tron/gServerFavorites.cpp armagetronad/trunk/armagetronad/src/tron/gServerFavorites.h armagetronad/trunk/armagetronad/src/ui/uMenu.cpp armagetronad/trunk/armagetronad/src/ui/uMenu.h Modified: armagetronad/trunk/armagetronad/NEWS =================================================================== --- armagetronad/trunk/armagetronad/NEWS 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/NEWS 2008-01-16 10:27:25 UTC (rev 7523) @@ -89,7 +89,11 @@ ------------ New settings and commands: +- KICK_TO and MOVE_TO: redirect a client to a different server +- DEFAULT_KICK(_TO)_MESSAGE: default reason given to players for a kick +- DEFAULT_KICK_TO_SERVER/PORT: default redirection target for KICK/MOVE_TO. - If all clients support it, PING_CHARITY_MIN/MAX can be used to constrain ping charity. +- VOTE_KICK_TO_SERVER/PORT: redirection target for vote kicks. - SILENCE and VOICE allow to control chat of annoying players. - SILENCE_ALL can be used on the server to inhibit all cross-team communication unless specifically voiced. - ENABLE_CHAT can be set to 0 to disable all chat. If it is set on the server it only disables public chat and logged in players can still speak. @@ -97,7 +101,7 @@ - FILTER_NAME_MIDDLE: collapses multiple whitespaces to one in player names. - FORTRESS_CONQEST_TIMEOUT: if an enemy contact with a zone happens longer ago than this value, it is discarded from zone memory. -- TOPOLOGY_POLICE_PARALLEL, extra topology police flag to control the checks +- TOPOLOGY_POLICE_PARALLEL, extra topology police flag to control the checks for walls getting copied into the grid in exactly the same place. - CAMERA_GLANCE_*: separate settings for the glancing camera, work like CAMERA_CUSTOM_*. Likewise, CAMERA_SERVER_GLANCE_* can replace CAMERA_SERVER_CUSTOM_* when glancing. @@ -115,9 +119,23 @@ for turns in the same direction. Can be used to limit the advantage doublebinders get while not punishing players who press both left and right at the same time. -- LAG_O_METER(TRESHOLD|BLEND|USE_OLD): Configure the minimal size of the Lag-O-Meter, its color and whether to scrap it all and stick with the old one. -- ALLOW_TEAM_CHANGE: if set to 0 players won't be able to join a team, create a new team or change to another team. -- ALLOW_TEAM_CHANGE_PLAYER/DISALLOW_TEAM_CHANGE_PLAYER: allow/disallow specific players to switch teams +- LAG_O_METER_(TRESHOLD|BLEND|USE_OLD): Configure the minimal size of the + Lag-O-Meter, its color and whether to scrap it all and stick with the old + one. +- ALLOW_TEAM_CHANGE: if set to 0 players won't be able to join a team, create + a new team or change to another team. +- ALLOW_TEAM_CHANGE_PLAYER/DISALLOW_TEAM_CHANGE_PLAYER: allow/disallow specific + players to switch teams +- INTERCEPT_COMMANDS is a space-delimited list of chat commands that shall be + intercepted by an external script. Example value: /login /admin /teamleave + /teamshuffle /shuffle /team +- INTERCEPT_UNKNOWN_COMMANDS is a boolean specifying if an external script + wishes to handle unrecognized chat commands. This would allow hooking + arbitrary things like /foobarz or /mode ctf +- CONSOLE_LADDER_LOG boolean places the ladderlog on stdout prefixed with + "[L] " +- PLAYER_MESSAGE <user ID or name> <Message>: Like /msg, but from the + console Featurelets ----------- @@ -158,8 +176,8 @@ message, <player> has been in the conquered zone - ONLINE_PLAYER <player> [<ping [<team>]]: At the beginning of the round, <player> had <ping> and was on <team>. This line is not printed for bots - - NUM_HUMANS <n>: There are <n> players that are not AIs and are part of - a team. + - NUM_HUMANS <n>: There are <n> players that are not AIs and are part of a + team. - ROUND_SCORE has the player's team's score appended. Bugfixes Modified: armagetronad/trunk/armagetronad/README-Subversion =================================================================== --- armagetronad/trunk/armagetronad/README-Subversion 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/README-Subversion 2008-01-16 10:27:25 UTC (rev 7523) @@ -66,10 +66,25 @@ Mac OS X ======== +This will only open in Xcode >= 2.1. It has these targets: +* Armagetron Advanced -- The client +* Armagetron Advanced 10.2.8 -- The client for Mac OS X 10.2.8 +* Armagetron Advanced Dedicated -- Dedicated Server +* Create Client Release -- Create a distributable disk image of the client. This target checks to see if you have an $AA_RECORDER_APP environment variable set, and if you do the recorder app will be included in the disk image. For example I have in my .bash_profile: Prerequisites ------------- + AA_RECORDER_APP="/Users/Shared/Applications/Games/Armagetron Advanced Recorder.app" +* Create Dedicated Release -- Create a distributable disk image of the dedicated server. +* Create Full Release -- Runs both "Create Client Release" and "Create Dedicated Release" + +Armagetron Advanced requires: +* SDL.framework +* SDL_mixer.framework +* SDL_image.framework +* libpng.framework + - Apple developer tools (http://developer.apple.com) - Xcode 2.4 or greater is required. - rake (http://rubyforge.org/projects/rake) Modified: armagetronad/trunk/armagetronad/config/settings.cfg =================================================================== --- armagetronad/trunk/armagetronad/config/settings.cfg 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/config/settings.cfg 2008-01-16 10:27:25 UTC (rev 7523) @@ -773,7 +773,8 @@ # cannot do anything about that, you can make ArmagetronAd multiply time measurements # with the following value. For example, if your system timer is about 10% too fast, you # can use the value 0.909 to compensate. Deviations of less than 1% are usually compensated -# by the network code. +# by the network code. NOTE: Do not change this while the program is running, this will cause +# huge hickups or freezes. TIME_FACTOR 1.0 # deprecated settings, they'll go away unless there are protests Modified: armagetronad/trunk/armagetronad/config/settings_dedicated.cfg =================================================================== --- armagetronad/trunk/armagetronad/config/settings_dedicated.cfg 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/config/settings_dedicated.cfg 2008-01-16 10:27:25 UTC (rev 7523) @@ -207,6 +207,17 @@ PING_FLOOD_TIME_100 100.0 # Minimum time for 100 ping packets to arrive. PING_FLOOD_GLOBAL .1 # The same times, multiplied by this value, count for all pings from all machines. Negative values disable global flood protection. +# default settings for MOVE/KICK(_TO) + +# default kick reason given for the KICK console command +#DEFAULT_KICK_REASON + +# default redirection kick/move reason given for the KICK/MOVE_TO console commands +#DEFAULT_KICK_TO_REASON + +DEFAULT_KICK_TO_SERVER # default server to kick/move to (IP or hostname) +DEFAULT_KICK_TO_PORT 4534 # default port of the server to kick/move to + ############################################################################################ # # Game settings Modified: armagetronad/trunk/armagetronad/language/english_base.txt =================================================================== --- armagetronad/trunk/armagetronad/language/english_base.txt 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/language/english_base.txt 2008-01-16 10:27:25 UTC (rev 7523) @@ -797,6 +797,15 @@ allow_team_change_player_help Allow a specific player to change teams even if ALLOW_TEAM_CHANGE is disabled disallow_team_change_player_help Reverse of ALLOW_TEAM_CHANGE_PLAYER kick_help Kicks the specified player from the server. +default_kick_reason_help The reason given to a player kicked by KICK if none is specified. +kick_to_help Kicks the specified player from the server and, if the client supports it, redirects him to a different server. +move_to_help Kicks the specified player from the server and, if the client supports it, redirects him to a different server. Does not imply an autoban penalty. +default_kick_to_reason_help The reason given to a player kicked by KICK_TO or MOVE_TO if none is specified. +default_kick_to_server Default server IP/name a player is redirected to by KICK_TO and MOVE_TO. +default_kick_to_port Default server port a player is redirected to by KICK_TO and MOVE_TO. +vote_kick_to_server Server IP/name a player is redirected to by vote kicks. +vote_kick_to_port Default server port a player is redirected to by vote kicks. + ban_help Bans the specified player from the server (kicks him first) for a variable time in minutes. ban_ip_help Bans the spedified IP address from the server for a variable time. ban_list_help Prints a list of currently banned IPs. @@ -2313,6 +2322,7 @@ network_login_done Done!\n network_kill_log User \1 kicked, reason given to him: \2\n +network_redirect \n\nYou will now be redirected to the server \1:\2.\n network_kill_preface Reason given by server: network_kill_maxidgrabber It ran out of IDs; your client was the one occupying most of them for himself. The reason for this can be a bug. network_kill_maxiduser It ran out of IDs; your client was the one occupying most of them. @@ -2488,6 +2498,7 @@ #******************************************** config_include_not_found Configuration file "\1" to be included not found.\n +config_rinclude_not_found Configuration resource "\1" to be included not found.\n config_command_unknown Command \1 unknown.\n config_command_other You probably want:\n config_command_more There are more commands containing your search string that were left out to avoid flooding your terminal.\n Modified: armagetronad/trunk/armagetronad/src/engine/ePlayer.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/engine/ePlayer.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/engine/ePlayer.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -4517,13 +4517,17 @@ static tConfItemFunc se_PlayerMessage_c("PLAYER_MESSAGE", &se_PlayerMessageConf); +static tString se_defaultKickReason(""); +static tConfItemLine se_defaultKickReasonConf( "DEFAULT_KICK_REASON", se_defaultKickReason ); + static void se_KickConf(std::istream &s) { // get user ID int num = se_ReadUser( s ); - tString reason; - reason.ReadLine(s); + tString reason = se_defaultKickReason; + if ( !s.eof() ) + reason.ReadLine(s); // and kick. if ( num > 0 && !s.good() ) @@ -4539,6 +4543,62 @@ static tConfItemFunc se_kickConf("KICK",&se_KickConf); +static tString se_defaultKickToServer(""); +static int se_defaultKickToPort = 4534; +static tString se_defaultKickToReason(""); + +static tSettingItem< tString > se_defaultKickToServerConf( "DEFAULT_KICK_TO_SERVER", se_defaultKickToServer ); +static tSettingItem< int > se_defaultKickToPortConf( "DEFAULT_KICK_TO_PORT", se_defaultKickToPort ); +static tConfItemLine se_defaultKickToReasonConf( "DEFAULT_KICK_TO_REASON", se_defaultKickToReason ); + +static void se_MoveToConf(std::istream &s, REAL severity ) +{ + // get user ID + int num = se_ReadUser( s ); + + // read redirection target + tString server = se_defaultKickToServer; + if ( !s.eof() ) + { + s >> server; + } + + int port = se_defaultKickToPort; + if ( !s.eof() ) + s >> port; + + nServerInfoRedirect redirect( server, port ); + + tString reason = se_defaultKickToReason; + if ( !s.eof() ) + reason.ReadLine(s); + + // and kick. + if ( num > 0 && !s.good() ) + { + sn_KickUser( num , reason.Len() > 1 ? static_cast< char const *>( reason ) : "$network_kill_kick", severity, &redirect ); + } + else + { + con << "Usage: KICK_TO <user ID or name> <server IP to kick to>:<server port to kick to> <Reason>\n"; + return; + } +} + +static void se_KickToConf(std::istream &s ) +{ + se_MoveToConf( s, 1 ); +} + +static tConfItemFunc se_kickToConf("KICK_TO",&se_KickToConf); + +static void se_MoveToConf(std::istream &s ) +{ + se_MoveToConf( s, 0 ); +} + +static tConfItemFunc se_moveToConf("MOVE_TO",&se_MoveToConf); + static void se_BanConf(std::istream &s) { // get user ID Modified: armagetronad/trunk/armagetronad/src/engine/eVoter.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/engine/eVoter.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/engine/eVoter.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -35,6 +35,7 @@ #include "uMenu.h" #include "nConfig.h" +#include "nServerInfo.h" #include "rConsole.h" @@ -731,11 +732,32 @@ virtual void OnDestroy() { machine_ = 0; + + delete this; } private: nMachine * machine_; }; +static tString se_voteKickToServer(""); +static int se_voteKickToPort = 4534; +static tSettingItem< tString > se_voteKickToServerConf( "VOTE_KICK_TO_SERVER", se_voteKickToServer ); +static tSettingItem< int > se_voteKickToPortConf( "VOTE_KICK_TO_PORT", se_voteKickToPort ); + +void se_VoteKickUser( int user ) +{ + if ( se_voteKickToServer.Len() < 2 ) + { + sn_KickUser( user, tOutput("$voted_kill_kick") ); + } + else + { + // kick player to default destination + nServerInfoRedirect redirect( se_voteKickToServer, se_voteKickToPort ); + sn_KickUser( user, tOutput("$voted_kill_kick"), 1, &redirect ); + } +} + // something to vote on class eVoteItemKick: public virtual eVoteItem { @@ -842,7 +864,7 @@ // kick the player, he is online int user = player_->Owner(); if ( user > 0 ) - sn_KickUser( user, tOutput("$voted_kill_kick") ); + se_VoteKickUser( user ); } else if ( machine_ ) { @@ -856,7 +878,7 @@ { if ( &nMachine::GetMachine( user ) == machine ) { - sn_KickUser( user, tOutput("$voted_kill_kick") ); + se_VoteKickUser( user ); kick = true; } } @@ -987,7 +1009,7 @@ if(sn_GetNetState()==nSERVER) { // kill user directly - sn_KickUser( player_->Owner(), tOutput("$voted_kill_kick") ); + se_VoteKickUser( player_->Owner() ); } { // issue kick vote Modified: armagetronad/trunk/armagetronad/src/network/nNetwork.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/network/nNetwork.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/network/nNetwork.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -30,6 +30,7 @@ #include "nSimulatePing.h" #include "nConfig.h" #include "nNetwork.h" +#include "nServerInfo.h" #include "tConsole.h" #include "tDirectories.h" #include "nSocket.h" @@ -95,7 +96,7 @@ static tConfItemLine sn_sbtip("SERVER_IP", net_hostip); -void sn_DisconnectUserNoWarn(int i, const tOutput& reason ); +void sn_DisconnectUserNoWarn(int i, const tOutput& reason, nServerInfoBase * redirectTo = 0 ); int sn_defaultDelay=10000; @@ -1315,7 +1316,18 @@ real_req_info_handler=handle; } +// the server we are redirected to +static std::auto_ptr< nServerInfoBase > sn_redirectTo; +std::auto_ptr< nServerInfoBase > sn_GetRedirectTo() +{ + return sn_redirectTo; +} +nServerInfoBase * sn_PeekRedirectTo() +{ + return sn_redirectTo.get(); +} + void login_deny_handler(nMessage &m){ if ( !m.End() ) { @@ -1329,6 +1341,21 @@ sn_DenyReason = tOutput( "$network_kill_unknown" ); } + if ( !m.End() ) + { + // read redirection data from message + tString connectionName; + m >> connectionName; + int port; + m >> port; + + if ( connectionName.Len() > 1 ) + { + // create server info and fill it with data + sn_redirectTo = std::auto_ptr< nServerInfoBase>( new nServerInfoRedirect( connectionName, port ) ); + } + } + if (!login_failed) con << tOutput("$network_login_denial"); if (sn_GetNetState()!=nSERVER){ @@ -2504,6 +2531,9 @@ nConnectError sn_Connect( nAddress const & server, nLoginType loginType, nSocket const * socket ){ sn_DenyReason = ""; + // reset redirection + sn_redirectTo.release(); + // pings in the beginning of the login are not really representative nPingAverager::SetWeight(.0001); @@ -3000,7 +3030,7 @@ */ } -void sn_KickUser(int i, const tOutput& reason, REAL severity ) +void sn_KickUser(int i, const tOutput& reason, REAL severity, nServerInfoBase * redirectTo ) { // print it con << tOutput( "$network_kill_log", i, reason ); @@ -3009,10 +3039,10 @@ nMachine::GetMachine(i).OnKick( severity ); // do it - sn_DisconnectUser( i, reason ); + sn_DisconnectUser( i, reason, redirectTo ); } -void sn_DisconnectUser(int i, const tOutput& reason ) +void sn_DisconnectUser(int i, const tOutput& reason, nServerInfoBase * redirectTo ) { // don't be daft and kill yourself, server! if ( i == 0 && sn_GetNetState() == nSERVER ) @@ -3034,10 +3064,10 @@ return; } - sn_DisconnectUserNoWarn( i, reason ); + sn_DisconnectUserNoWarn( i, reason, redirectTo ); } -void sn_DisconnectUserNoWarn(int i, const tOutput& reason ) +void sn_DisconnectUserNoWarn(int i, const tOutput& reason, nServerInfoBase * redirectTo ) { nCurrentSenderID senderID( i ); @@ -3060,6 +3090,18 @@ for(int j=2;j>=0;j--){ nMessage* mess = (new nMessage(login_deny)); *mess << tString( reason ); + + // write redirection + tString redirection; + int port; + if ( redirectTo ) + { + redirection = redirectTo->GetConnectionName(); + port = redirectTo->GetPort(); + } + *mess << redirection; + *mess << port; + mess->SendImmediately(i, false); nMessage::SendCollected(i); } Modified: armagetronad/trunk/armagetronad/src/network/nNetwork.h =================================================================== --- armagetronad/trunk/armagetronad/src/network/nNetwork.h 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/network/nNetwork.h 2008-01-16 10:27:25 UTC (rev 7523) @@ -40,6 +40,7 @@ class nSocket; class nAddress; class nBasicNetworkSystem; +class nServerInfoBase; extern nBasicNetworkSystem sn_BasicNetworkSystem; @@ -98,8 +99,8 @@ nConnectError sn_GetLastError(); nNetState sn_GetNetState(); void sn_SetNetState(nNetState x); -void sn_DisconnectUser(int i, const tOutput& reason ); //!< terminate connection with user i (peacefully) -void sn_KickUser(int i, const tOutput& reason, REAL severity = 1 ); //!< throw out user i (violently) +void sn_DisconnectUser(int i, const tOutput& reason, nServerInfoBase * redirectTo = 0 ); //!< terminate connection with user i (peacefully) +void sn_KickUser(int i, const tOutput& reason, REAL severity = 1, nServerInfoBase * redirectTo = 0 ); //!< throw out user i (violently) void sn_GetAdr(int user, tString& name); unsigned int sn_GetPort(int user); @@ -795,6 +796,13 @@ ~nSocketResetInhibitor(); }; +// on disconnection, this returns a server we should be redirected to (or NULL if we should not be redirected) +std::auto_ptr< nServerInfoBase > sn_GetRedirectTo(); + +// take a peek at the same info +nServerInfoBase * sn_PeekRedirectTo(); + + // ******************************************************************************************* // * // * GetWeight Modified: armagetronad/trunk/armagetronad/src/network/nServerInfo.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/network/nServerInfo.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/network/nServerInfo.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -844,6 +844,8 @@ { if ( warned_ ) con << "Flood protection ban of " << GetIP() << " removed because machine is discarded.\n"; + + delete this; } void Block() Modified: armagetronad/trunk/armagetronad/src/network/nServerInfo.h =================================================================== --- armagetronad/trunk/armagetronad/src/network/nServerInfo.h 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/network/nServerInfo.h 2008-01-16 10:27:25 UTC (rev 7523) @@ -95,6 +95,18 @@ inline nServerInfoBase & SetPort( unsigned int port ); //!< Sets the network port the server listens on }; +//! server information, just to redirect and for other immediate applications +class nServerInfoRedirect: public nServerInfoBase +{ +public: + // construct a server directly with connection name and port + nServerInfoRedirect( tString const & connectionName, unsigned int port ) + { + nServerInfoBase::SetConnectionName( connectionName ); + nServerInfoBase::SetPort( port ); + }; +}; + //! Full server information class nServerInfo: public tListItem<nServerInfo>, public nServerInfoBase { Modified: armagetronad/trunk/armagetronad/src/render/rConsoleCout.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/render/rConsoleCout.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/render/rConsoleCout.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -42,9 +42,10 @@ #include <windows.h> //#define fileno _fileno //#define fcntl _fcntl +#else +#include <signal.h> #endif - void rConsole::DoCenterDisplay(const tString &s,REAL timeout,REAL r,REAL g,REAL b){ std::cout << tColoredString::RemoveColors(s) << '\n'; DisplayAtNewline(); @@ -53,7 +54,20 @@ static int stdin_descriptor; static bool unblocked = false; +static void sr_HandleSigCont( int signal ) +{ + // con << "Continuing.\n"; + + // unblock stdin again + sr_Unblock_stdin(); +} + void sr_Unblock_stdin(){ + if ( !unblocked ) + { + signal( SIGCONT, &sr_HandleSigCont ); + } + unblocked = true; stdin_descriptor=fileno(stdin); #ifndef WIN32 @@ -66,6 +80,7 @@ } + #define MAXLINE 1000 static char line_in[MAXLINE+2]; static int currentIn=0; @@ -121,8 +136,9 @@ #else - while (read(stdin_descriptor,&line_in[currentIn],1)>0){ - if (line_in[currentIn]=='\n' || currentIn>=MAXLINE-1){ + while ( read(stdin_descriptor,&line_in[currentIn],1)>0){ + if (line_in[currentIn]=='\n' || currentIn>=MAXLINE-1) + { line_in[currentIn+1]='\0'; std::stringstream s(line_in); tConfItemBase::LoadAll(s); Modified: armagetronad/trunk/armagetronad/src/tools/tConfiguration.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tools/tConfiguration.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/tools/tConfiguration.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -40,6 +40,7 @@ #include "tDirectories.h" #include "tRecorder.h" #include "tCommandLine.h" +#include "tResourceManager.h" #include <vector> @@ -678,6 +679,23 @@ static tConfItemFunc s_Include("INCLUDE", &Include); static tConfItemFunc s_SInclude("SINCLUDE", &SInclude); +static void RInclude(std::istream& s) +{ + tString file; + s >> file; + + tString rclcl = tResourceManager::locateResource(NULL, file); + if ( rclcl ) { + std::ifstream rc(rclcl); + tConfItemBase::LoadAll(rc); + return; + } + + con << tOutput( "$config_rinclude_not_found", file ); +} + +static tConfItemFunc s_RInclude("RINCLUDE", &RInclude); + // obsoleted settings that still are around in some distruted configuration files static void st_Dummy(std::istream &s){tString rest; rest.ReadLine(s);} static tConfItemFunc st_DummyMpHack("MOVIEPACK_HACK",&st_Dummy); Modified: armagetronad/trunk/armagetronad/src/tools/tSysTime.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tools/tSysTime.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/tools/tSysTime.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -267,7 +267,7 @@ // detect and counter timer hickups tTime newRelative = time - start; tTime timeStep = newRelative - relative; - if ( timeStep.seconds < 0 || timeStep.seconds > 10 ) + if ( !tRecorder::IsPlayingBack() && ( timeStep.seconds < 0 || timeStep.seconds > 10 ) ) { static bool warn = true; if ( warn ) Modified: armagetronad/trunk/armagetronad/src/tools/tXmlParser.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tools/tXmlParser.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/tools/tXmlParser.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -240,7 +240,11 @@ } tXmlParser::~tXmlParser() { - // do nothing + if (m_Doc) + { + xmlFreeDoc(m_Doc); + m_Doc=0; + } } void tXmlParser::cb_endElement(const xmlChar *name) { Modified: armagetronad/trunk/armagetronad/src/tron/gCommandLineJumpStart.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gCommandLineJumpStart.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/tron/gCommandLineJumpStart.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -39,15 +39,8 @@ bool gCommandLineJumpStartAnalyzer::DoAnalyze( tCommandLineParser & parser ) { - tString raw; - tString server; - tString port; - - if ( parser.GetOption( raw, "--connect" ) ) + if ( parser.GetOption( _raw, "--connect" ) ) { - ExtractConnectionInformation( raw, server, port ); - _server.SetPort( port.ToInt() ); - _server.SetConnectionName( server ); _shouldConnect = true; return true; @@ -67,7 +60,14 @@ void gCommandLineJumpStartAnalyzer::Connect() { - ConnectToServer( &_server ); + tString server; + tString port; + + ExtractConnectionInformation( _raw, server, port ); + + nServerInfoRedirect connectTo( server, port.ToInt() ); + + ConnectToServer( &connectTo ); } // ***************************************************************************** Modified: armagetronad/trunk/armagetronad/src/tron/gCommandLineJumpStart.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gCommandLineJumpStart.h 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/tron/gCommandLineJumpStart.h 2008-01-16 10:27:25 UTC (rev 7523) @@ -54,7 +54,7 @@ void Connect(); private: bool _shouldConnect; - gServerInfoFavorite _server; + tString _raw; virtual bool DoAnalyze( tCommandLineParser & parser ); virtual void DoHelp( std::ostream & s ); }; Modified: armagetronad/trunk/armagetronad/src/tron/gGame.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gGame.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/tron/gGame.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -873,6 +873,9 @@ // wait for network messages sn_BasicNetworkSystem.Select( 0.1f ); gGame::NetSyncIdle(); + + // handle console input + sr_Read_stdin(); } } @@ -1417,19 +1420,23 @@ static void sg_NetworkError( const tOutput& title, const tOutput& message, REAL timeout ) { + tOutput message2 ( message ); + if ( sn_DenyReason.Len() > 2 ) { - tOutput message2 ( message ); message2.AddLiteral("\n\n"); message2.AddLocale("network_kill_preface"); message2.AddLiteral("\n"); message2.AddLiteral(sn_DenyReason); - tConsole::Message( title, message2, timeout ); } - else + + nServerInfoBase * redirect = sn_PeekRedirectTo(); + if ( redirect ) { - tConsole::Message( title, message, timeout ); + message2.Append( tOutput( "$network_redirect", redirect->GetConnectionName(), (int)redirect->GetPort() ) ); } + + tConsole::Message( title, message2, timeout ); } // revert settings to defaults in the current scope @@ -1462,7 +1469,7 @@ } } -void ConnectToServer(nServerInfoBase *server) +void ConnectToServerCore(nServerInfoBase *server) { tASSERT( server ); @@ -1552,7 +1559,6 @@ } } - if (!sg_RequestedDisconnection && !uMenu::quickexit) switch (sn_GetLastError()) { @@ -1578,6 +1584,46 @@ sr_textOut=to; } +void ConnectToServer(nServerInfoBase *server) +{ + ConnectToServerCore( server ); + + REAL redirections = 0; + double lastTime = tSysTimeFloat(); + + // check for redirection + while( true ) + { + std::auto_ptr< nServerInfoBase > redirectTo( sn_GetRedirectTo() ); + + // abort loop + if ( !(&(*redirectTo)) ) + { + break; + } + + ConnectToServerCore( redirectTo.get() ); + + // redirection spam chain protection, allow one redirection every 30 seconds. Should + // be short enough to allow hacky applications (server-to-server teleport), but + // long enough to allow players to escape via the menu or at least shift-esc. + static const REAL timeout = 30; + static const REAL maxRedirections = 5; + + redirections = redirections + 1; + if ( redirections > maxRedirections ) + { + break; + } + + // decay spam protection + double newTime = tSysTimeFloat(); + REAL dt = newTime - lastTime; + lastTime = newTime; + redirections *= 1/(1 + dt * maxRedirections * timeout ); + } +} + static tConfItem<int> mor("MAX_OUT_RATE",sn_maxRateOut); static tConfItem<int> mir("MAX_IN_RATE",sn_maxRateIn); Modified: armagetronad/trunk/armagetronad/src/tron/gServerFavorites.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gServerFavorites.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/tron/gServerFavorites.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -47,12 +47,17 @@ enum { NUM_FAVORITES = 10 }; +/* +//! favorite server information, just to connect gServerInfoFavorite::gServerInfoFavorite( tString const & connectionName, unsigned int port ) { nServerInfoBase::SetConnectionName( connectionName ); nServerInfoBase::SetPort( port ); } +*/ +typedef nServerInfoRedirect gServerInfoFavorite; + //******************************************************************************** //******************************************************************************** Modified: armagetronad/trunk/armagetronad/src/tron/gServerFavorites.h =================================================================== --- armagetronad/trunk/armagetronad/src/tron/gServerFavorites.h 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/tron/gServerFavorites.h 2008-01-16 10:27:25 UTC (rev 7523) @@ -33,6 +33,7 @@ class nServerInfoBase; +/* //! favorite server information, just to connect class gServerInfoFavorite: public nServerInfoBase { @@ -43,6 +44,7 @@ void SetPort( unsigned int port ) { nServerInfoBase::SetPort( port ); } void SetConnectionName( tString const connectionName ) { nServerInfoBase::SetConnectionName( connectionName ); } }; +*/ class gServerFavorites { Modified: armagetronad/trunk/armagetronad/src/ui/uMenu.cpp =================================================================== --- armagetronad/trunk/armagetronad/src/ui/uMenu.cpp 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/ui/uMenu.cpp 2008-01-16 10:27:25 UTC (rev 7523) @@ -178,9 +178,6 @@ st_DoToDo(); tAdvanceFrame(); - if (selected < 0 || selected >= items.Len()) - selected = items.Len()-1; - ts=tSysTimeFloat()-lastt; lastt=tSysTimeFloat(); if (ts>.2) ts=.2; @@ -226,6 +223,15 @@ nextrepeat = tSysTimeFloat() + repeatrate; } } + + // we're about to render, last chance to make changes to the menu + OnRender(); + + // clamp cursor + if (selected < 0 ) + selected = 0; + if ( selected >= items.Len()) + selected = items.Len()-1; #endif // quit shortcut if ( quickexit ) @@ -352,13 +358,13 @@ switch (event.key.keysym.sym){ case(SDLK_ESCAPE): - repeat = false; + repeat = false; lastkey=tSysTimeFloat(); Exit(); break; case(SDLK_UP): - lastkey=tSysTimeFloat(); + lastkey=tSysTimeFloat(); selected = GetNextSelectable(selected); break; case(SDLK_DOWN): @@ -505,6 +511,11 @@ exitFlag=1; } +//! called every frame before the menu is rendered +void uMenu::OnRender() +{ +} + // ***************************************************** // ******************************************************************************************* Modified: armagetronad/trunk/armagetronad/src/ui/uMenu.h =================================================================== --- armagetronad/trunk/armagetronad/src/ui/uMenu.h 2008-01-16 09:59:51 UTC (rev 7522) +++ armagetronad/trunk/armagetronad/src/ui/uMenu.h 2008-01-16 10:27:25 UTC (rev 7523) @@ -122,6 +122,9 @@ int GetNextSelectable(int start); int GetPrevSelectable(int start); + + //! called every frame before the menu is rendered + virtual void OnRender(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |