about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-11-26 19:32:02 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-11-26 19:32:02 +0000
commit7715ab0059fbfb44af8a448ba3605e1d6a8b58f3 (patch)
tree4efd85b5cada4e15e55fdbddbdeb78dda740d17d
parent73789b0b0a04b6d3e12da70429ce1da16402ce3d (diff)
downloadzcatch-7715ab0059fbfb44af8a448ba3605e1d6a8b58f3.tar.gz
zcatch-7715ab0059fbfb44af8a448ba3605e1d6a8b58f3.zip
fixed so that the flag returns when in the field for 30 seconds
-rw-r--r--src/game/server/srv_ctf.cpp14
-rw-r--r--src/game/server/srv_ctf.h2
2 files changed, 9 insertions, 7 deletions
diff --git a/src/game/server/srv_ctf.cpp b/src/game/server/srv_ctf.cpp
index 6e779297..abdb0efe 100644
--- a/src/game/server/srv_ctf.cpp
+++ b/src/game/server/srv_ctf.cpp
@@ -43,6 +43,7 @@ int gameobject_ctf::on_player_death(class player *victim, class player *killer,
 			had_flag |= 2;
 		if(f && f->carrying_player == victim)
 		{
+			f->drop_tick = server_tick();
 			f->carrying_player = 0;
 			had_flag |= 1;
 		}
@@ -101,8 +102,13 @@ void gameobject_ctf::tick()
 			
 			if(!f->carrying_player)
 			{
-				f->vel.y += gravity;
-				move_box(&f->pos, &f->vel, vec2(f->phys_size, f->phys_size), 0.5f);
+				if(server_tick() > f->drop_tick + SERVER_TICK_SPEED*30)
+					f->reset();
+				else
+				{
+					f->vel.y += gravity;
+					move_box(&f->pos, &f->vel, vec2(f->phys_size, f->phys_size), 0.5f);
+				}
 			}
 		}
 	}
@@ -127,14 +133,10 @@ void flag::reset()
 	carrying_player = 0;
 	at_stand = 1;
 	pos = stand_pos;
-	spawntick = -1;
 }
 
 void flag::snap(int snapping_client)
 {
-	if(spawntick != -1)
-		return;
-
 	obj_flag *flag = (obj_flag *)snap_new_item(OBJTYPE_FLAG, team, sizeof(obj_flag));
 	flag->x = (int)pos.x;
 	flag->y = (int)pos.y;
diff --git a/src/game/server/srv_ctf.h b/src/game/server/srv_ctf.h
index 677940c5..02acef37 100644
--- a/src/game/server/srv_ctf.h
+++ b/src/game/server/srv_ctf.h
@@ -23,8 +23,8 @@ public:
 	vec2 stand_pos;
 	
 	int team;
-	int spawntick;
 	int at_stand;
+	int drop_tick;
 	
 	flag(int _team);