about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/game/game_variables.h5
-rw-r--r--src/game/server/game_server.cpp3
-rw-r--r--src/game/server/srv_common.cpp13
-rw-r--r--src/game/server/srv_common.h4
4 files changed, 22 insertions, 3 deletions
diff --git a/src/game/game_variables.h b/src/game/game_variables.h
index 71297d69..9840192d 100644
--- a/src/game/game_variables.h
+++ b/src/game/game_variables.h
@@ -31,8 +31,8 @@ MACRO_CONFIG_STR(gametype, 32, "dm")
 MACRO_CONFIG_INT(restart, 0, 0, 120)
 
 MACRO_CONFIG_INT(dbg_bots, 0, 0, 7)
-MACRO_CONFIG_INT(cl_predict, 1, 0, 1)
 
+MACRO_CONFIG_INT(cl_predict, 1, 0, 1)
 MACRO_CONFIG_INT(cl_nameplates, 0, 0, 1)
 MACRO_CONFIG_INT(cl_nameplates_always, 0, 0, 1)
 
@@ -55,6 +55,7 @@ MACRO_CONFIG_INT(ui_page, 1, 0, 5)
 MACRO_CONFIG_STR(ui_server_address, 128, "localhost:8303")
 MACRO_CONFIG_INT(ui_scale, 100, 1, 100000)
 
-
 MACRO_CONFIG_STR(sv_msg, 512, "")
+MACRO_CONFIG_INT(sv_teamdamage, 0, 0, 1)
+
 
diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp
index 96183457..c146d5c4 100644
--- a/src/game/server/game_server.cpp
+++ b/src/game/server/game_server.cpp
@@ -1064,6 +1064,9 @@ void player::die(int killer, int weapon)
 bool player::take_damage(vec2 force, int dmg, int from, int weapon)
 {
 	core.vel += force;
+	
+	if(gameobj->is_friendly_fire(client_id, from) && !config.sv_teamdamage)
+		return false;
 
 	// player only inflicts half damage on self
 	if(from == client_id)
diff --git a/src/game/server/srv_common.cpp b/src/game/server/srv_common.cpp
index 1c338897..21400d63 100644
--- a/src/game/server/srv_common.cpp
+++ b/src/game/server/srv_common.cpp
@@ -145,6 +145,19 @@ void gameobject::do_warmup(int seconds)
 	warmup = seconds*SERVER_TICK_SPEED;
 }
 
+bool gameobject::is_friendly_fire(int cid1, int cid2)
+{
+	if(cid1 == cid2)
+		return false;
+	
+	if(is_teamplay)
+	{
+		if(players[cid1].team == players[cid2].team)
+			return true;
+	}
+	
+	return false;
+}
 
 void gameobject::tick()
 {
diff --git a/src/game/server/srv_common.h b/src/game/server/srv_common.h
index 82375d25..209d99e0 100644
--- a/src/game/server/srv_common.h
+++ b/src/game/server/srv_common.h
@@ -141,7 +141,9 @@ public:
 	
 	void startround();
 	void endround();
-
+	
+	bool is_friendly_fire(int cid1, int cid2);
+	
 	virtual void post_reset();
 	virtual void tick();