From c312a89e02262b5cb3d2c55b8ac17e521aee82ac Mon Sep 17 00:00:00 2001
From: terminx <terminx@1a8010ca-5511-0410-912e-c29ae57300e0>
Date: Sat, 19 Aug 2006 01:30:40 +0000
Subject: [PATCH] A couple more TDM things, including making the built in bots
 not attack players on the same team.  However, this can leave them in a
 rather hilarious state in which they twitch in place in the middle of a room.
  It's almost as funny as watching them spin around kicking the walls.

git-svn-id: https://svn.eduke32.com/eduke32@270 1a8010ca-5511-0410-912e-c29ae57300e0
---
 polymer/eduke32/source/game.c   | 24 +++++++++++++-----------
 polymer/eduke32/source/player.c |  2 +-
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c
index f88c40704..9b419b59b 100644
--- a/polymer/eduke32/source/game.c
+++ b/polymer/eduke32/source/game.c
@@ -8169,16 +8169,6 @@ void checkcommandline(int argc,char **argv)
                     ud.m_respawn_monsters = ud.respawn_monsters = 1;
                     ud.m_respawn_items = ud.respawn_items = 1;
                     ud.m_respawn_inventory = ud.respawn_inventory = 1;
-                    {
-                        char k = 1;
-                        for(j=numplayers;j<ud.multimode;j++)
-                        {
-                            Bsprintf(ud.user_name[j],"PLAYER %d",j+1);
-                            ps[j].team = ud.pteam[j] = k;
-                            initprintf("p %d t %d\n",j,ps[j].team);
-                            k = 1-k;
-                        }
-                    }
                     break;
                 case 'r':
                 case 'R':
@@ -8912,7 +8902,7 @@ int load_script(char *szScript)
 
 void app_main(int argc,char **argv)
 {
-    long i, j;
+    int i, j;
 #ifdef RENDERTYPEWIN
     if (win_checkinstance()) {
         if (!wm_ynbox("EDuke32","Another Build game is currently running. "
@@ -9086,6 +9076,18 @@ void app_main(int argc,char **argv)
     }
 
     Startup(); // a bunch of stuff including compiling cons
+
+    {
+        i = 1;
+        for(j=numplayers;j<ud.multimode;j++)
+        {
+            Bsprintf(ud.user_name[j],"PLAYER %d",j+1);
+            ps[j].team = ud.pteam[j] = i;
+            initprintf("p %d t %d\n",j,ps[j].team);
+            i = 1-i;
+        }
+    }
+
     if (quitevent) return;
     if (!loaddefinitionsfile(duke3ddef)) initprintf("Definitions file loaded.\n");
 
diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c
index 7c7dd5606..1caabad62 100644
--- a/polymer/eduke32/source/player.c
+++ b/polymer/eduke32/source/player.c
@@ -5127,7 +5127,7 @@ void computergetinput(long snum, input *syn)
     {
         j = 0x7fffffff;
         for(i=connecthead;i>=0;i=connectpoint2[i])
-            if (i != snum)
+            if (i != snum && !((gametype_flags[ud.coop] & GAMETYPE_FLAG_TDM) && ps[snum].team == ps[i].team))
             {
                 dist = ksqrt((sprite[ps[i].i].x-x1)*(sprite[ps[i].i].x-x1)+(sprite[ps[i].i].y-y1)*(sprite[ps[i].i].y-y1));