Update of /cvsroot/netrek/client/netrekxp/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23170/src Modified Files: cowmain.c data.c death.c defaults.c enter.c Log Message: Added "autoSetWar: (0-2)" netrekrc option that controls declare war settings with enemy races when you first join. Can now automatically declare peace on 3rd space races, for example. Fixed bug where alert border was not working right upon death with old ship bitmaps Index: enter.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/enter.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- enter.c 28 Feb 2007 07:44:00 -0000 1.7 +++ enter.c 13 Mar 2007 18:35:00 -0000 1.8 @@ -22,6 +22,7 @@ #include "defs.h" #include "struct.h" #include "data.h" +#include "packets.h" #include "proto.h" /******************************************************************************/ @@ -107,6 +108,70 @@ } } +/******************************************************************************/ +/*** do_autosetwar(int team) ***/ +/*** Set war declares on first entry into game. Passes int team as ***/ +/*** player's p_team is not set at the time this function is called ***/ +/******************************************************************************/ +void +do_autosetwar (int team) +{ + int i, newhostile; + int playercount = 0; + int largestenemy = -1; + int largestenemycount = 0; + + /* Get my current hostile settings. Should be hostile with all teams, + set earlier in cowmain() */ + newhostile = me->p_hostile; + + /* Loop through all teams, and set war as appropriate*/ + for (i = 0; i < 4; i++) + { + /* Don't change war settings with own team */ + if (team == i) + continue; + + /* If team has 0 players ... */ + if ((playercount = realNumShips(1 << i)) == 0) + { + /* Declare peace? Yes for non-zero autoSetWar */ + if (autoSetWar) + newhostile ^= (1 << i); + continue; + } + + /* Keep track of largest enemy team */ + if (playercount > largestenemycount) + { + largestenemy = i; + largestenemycount = playercount; + } + } + /* No enemy team? Don't change war settings. */ + if (largestenemy < 0) + return; + + /* If autoSetWar is 2, keep hostile with largest enemy team, but + peace with all other teams even if they have 1 or more players */ + if (autoSetWar == 2) + { + for (i = 0; i < 4; i++) + { + /* Skip own team and zero enemy teams, these were handled earlier */ + if (team == i || (realNumShips(1 << i)) == 0) + continue; + + /* Non-zero players team that isn't largest opponent? */ + if (i != largestenemy) + newhostile ^= (1 << i); + } + } + + sendWarReq (newhostile); + return; +} + #ifdef ROTATERACE /******************************************************************************/ /*** rotateTeams() ***/ @@ -138,7 +203,7 @@ nextlargestteamcount = playercount; } } - /* Server empty or only 1 team? Don't rotate. */ + /* Server empty or only 1 team? Don't rotate. */ if (largestteam < 0 || nextlargestteam < 0) return; Index: death.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/death.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- death.c 28 Feb 2007 09:35:20 -0000 1.14 +++ death.c 13 Mar 2007 18:35:00 -0000 1.15 @@ -59,7 +59,6 @@ else alertBorderColor = W_White; W_ChangeBorder (baseWin, gColor); - oldalert = PFGREEN; } if (W_IsMapped (statwin)) { Index: defaults.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/defaults.c,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- defaults.c 3 Mar 2007 10:51:33 -0000 1.53 +++ defaults.c 13 Mar 2007 18:35:00 -0000 1.54 @@ -74,6 +74,15 @@ } }, #endif + {"autoSetWar", &autoSetWar, RC_INT, + { + "Declare war with enemy races when you first join", + "0 - Don't set war", + "1 - Set war with nonzero player teams, peace w/ 0 player teams", + "2 - Set war with largest enemy team, peace w/ everyone else", + NULL + } + }, {"baseUdpLocalPort", &baseUdpLocalPort, RC_INT, { "Base UDP local port", @@ -1590,6 +1599,7 @@ planetHighlighting = booleanDefault ("planetHighlighting", planetHighlighting); rotatePlanets = booleanDefault ("rotatePlanets", rotatePlanets); autoRotate = booleanDefault ("autoRotate", autoRotate); + autoSetWar = intDefault ("autoSetWar", autoSetWar); logging = booleanDefault ("logging", logging); maxScrollLines = intDefault ("maxScrollLines", maxScrollLines); if (maxScrollLines > 500) Index: data.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- data.c 2 Mar 2007 12:57:52 -0000 1.59 +++ data.c 13 Mar 2007 18:35:00 -0000 1.60 @@ -134,6 +134,7 @@ int old_rotate_deg = 0; #endif +int autoSetWar = 1; int loginAccept = -1; unsigned localflags = 0; int tournMask = 15; Index: cowmain.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/cowmain.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- cowmain.c 3 Mar 2007 10:02:44 -0000 1.28 +++ cowmain.c 13 Mar 2007 18:35:00 -0000 1.29 @@ -1062,6 +1062,9 @@ /* Playing hockey? */ check_hockey_mode(); #endif + /* Set up autowar settings */ + do_autosetwar(team); + isFirstEntry = 0; }