Commits

drbrain committed 6bdd4e2

Update to flagprivs to prevent the last player from switching off a flagging team. Still needs testing.

Comments (0)

Files changed (1)

hs_pubarena/hs_flagprivs.c

 	pdata *pdata = PPDATA(p, pdkey);
 	adata *ad = P_ARENA_DATA(p->arena, adkey);
 
-	if (!pdata->is_flagging && new_freq >= ad->priv_freq_start)
+	if (new_freq >= ad->priv_freq_start)
 	{
-		if (err_buf)
+		if (!pdata->is_flagging)
 		{
-			snprintf(err_buf, buf_len, "Please use ?flag to change to a flagging frequency.");
+			if (err_buf)
+			{
+				snprintf(err_buf, buf_len, "Please use ?flag to change to a flagging frequency.");
+			}
+			return 0;
 		}
-		return 0;
+		else
+		{
+			int found = 0;
+			Player *i;
+			Link *link;
+			
+			pd->Lock();
+			FOR_EACH_PLAYER(i)
+				if (i != p && i->arena == p->arena && i->p_freq == p->p_freq && IS_HUMAN(i))
+				{
+					found = 1;
+					break;
+				}
+			pd->Unlock();
+
+			if (!found)
+			{
+				if (err_buf)
+				{
+					snprintf(err_buf, buf_len, "Your team needs at least one player.");
+				}
+				return 0;
+			}
+		}
 	}
 	return 1;
 }