Ejemplo n.º 1
0
GLOBAL void TP_Msg_Need_f (void)
{
    MSGPART powerup = "";
    MSGPART need = "";
 
	if (DEAD())
		return; // if you're dead, you need better aim :E

	TP_GetNeed();
	
	if (NEED(health) || NEED(armor) || NEED_WEAPON() || NEED(rockets) || NEED(cells) || NEED(shells) || NEED(nails))
	{
		need = "need %u $[{%l}$]";
	}

	if (HAVE_POWERUP())
	{
		powerup = tp_ib_name_team " $colored_powerups ";
	}

	if (need[0] == 0 && powerup[0] == 0)
		return;
	
	TP_Send_TeamSay("%s%s", powerup, need);
}
Ejemplo n.º 2
0
GLOBAL void TP_Msg_Took_f (void)
{
	extern cvar_t tp_name_lg, tp_name_rl, tp_name_gl, tp_name_sng, tp_name_backpack, tp_name_cells, tp_name_rockets, tp_name_mh,
		tp_name_ra, tp_name_ya, tp_name_ga, tp_name_flag, tp_name_rune1, tp_name_rune2, tp_name_rune3, tp_name_rune4;
	MSGPART took = "";
	MSGPART at_location = " $[{%Y}$]"; // %Y is took location, remembers for 15 secs
	MSGPART powerup = "";
	MSGPART took_msg = "";
 
	if (TOOK_EMPTY())
		return;
	
	if (TOOK(quad) || TOOK(pent) || TOOK(ring)) {
		TP_GetNeed();
		
		if (DEAD())	{
			TP_Msg_QuadDead_f();
			return;
		}
		
		// Note that we check if you are holding powerup. This is because TOOK remembers for 15 seconds.
		// So a case could arise where you took quad then died less than 15 seconds later, and you'd be reporting "team need %u" (because $colored_powerups would be empty)
		else if ((NEED(health) || NEED(armor) || NEED_WEAPON() || NEED(rockets) || NEED(cells)) && HAVE_POWERUP())
			took = "{&c0b0team&cfff} $colored_powerups need %u";
		else if (HAVE_QUAD() || HAVE_RING()) // notice we can't send this check to tp_msgenemypwr, because if enemy with powerup is in your view, tp_enemypwr reports enemypwr first, but in this function you want to report TEAM powerup.
			took = "{&c0b0team&cfff} $colored_powerups";
		else { // In this case, you took quad or ring and died before 15 secs later. So just report what you need, nothing about powerups.
			took = "need %u"; //notice we don't say quad over, because it could be that you held ring. No way to distinguish
		}
	}
	else {
		if		(TOOK(rl))			took = tp_name_rl.string;
		else if (TOOK(lg))			took = tp_name_lg.string;
		else if (TOOK(gl))			took = tp_name_gl.string;
		else if (TOOK(sng))			took = tp_name_sng.string;
		else if (TOOK(pack))    	took = tp_name_backpack.string;
		else if (TOOK(cells))		took = tp_name_cells.string;
		else if (TOOK(rockets))		took = tp_name_rockets.string;
		else if (TOOK(mh))			took = tp_name_mh.string;
		else if (TOOK(ra))			took = tp_name_ra.string;
		else if (TOOK(ya))			took = tp_name_ya.string;
		else if (TOOK(ga))			took = tp_name_ga.string;
		else if (TOOK(flag))		took = tp_name_flag.string;
		else if (TOOK(rune1))		took = tp_name_rune1.string;
		else if (TOOK(rune2))		took = tp_name_rune2.string;
		else if (TOOK(rune3))		took = tp_name_rune3.string;
		else if (TOOK(rune4))		took = tp_name_rune4.string;
		else 						took = "{$took}"; // This should never happen
		
		took_msg = "took ";
		
		if (HAVE_POWERUP())
			powerup = "$colored_powerups ";
		else
			powerup = "";	
	}
	TP_Send_TeamSay("%s%s%s%s", powerup, took_msg, took, at_location);
}
Ejemplo n.º 3
0
GLOBAL void TP_Msg_Took_f (void)
{
	MSGPART took = "";
	MSGPART at_location = "";
	MSGPART powerup = "";
	MSGPART took_msg = "";
 
	if (TOOK_EMPTY())
		return;
	else if (TOOK(quad) || TOOK(pent) || TOOK(ring))
	{
		TP_GetNeed();
		if (NEED(health) || NEED(armor) || NEED_WEAPON() || NEED(rockets) || NEED(cells))
		{
			took = tp_ib_name_team " $colored_powerups need %u";
		}
		else
		{ // notice we can't send this check to tp_msgenemypwr, that's because if enemy with powerup is in your view, tp_enemypwr reports enemypwr first, but in this function you want to report TEAM powerup.
			took = tp_ib_name_team " $colored_powerups";
		}
	}
	else
	{
		if	(TOOK(rl))									took = tp_ib_name_rl;
		else if (TOOK(lg))								took = tp_ib_name_lg;
		else if (TOOK(gl))								took = tp_ib_name_gl;
		else if (TOOK(sng))								took = tp_ib_name_sng;
		else if (TOOK(pack))    						took = tp_ib_name_backpack;
		else if (TOOK(rockets) || TOOK(cells))			took = "{$took}";
		else if (TOOK(mh))								took = tp_ib_name_mh;
		else if (TOOK(ra))								took = tp_ib_name_ra;
		else if (TOOK(ya))								took = tp_ib_name_ya;
		else if (TOOK(ga))								took = tp_ib_name_ga;
		else if (TOOK(flag))							took = tp_ib_name_flag;
		else if (TOOK(rune1))							took = "$tp_name_rune1";
		else if (TOOK(rune2))							took = "$tp_name_rune2";
		else if (TOOK(rune3))							took = "$tp_name_rune3";
		else if (TOOK(rune4))							took = "$tp_name_rune4";
		else 											took = "{$took}"; // This should never happen
		
		if (HAVE_POWERUP())
		{
			powerup = "$colored_short_powerups ";
		}
		else
		{
			powerup = "";
		}
		
		at_location = " $[{%Y}$]"; // %Y is "forgotten" macro - location of item you took
		took_msg = "took ";
	}
	TP_Send_TeamSay("%s%s%s%s", powerup, took_msg, took, at_location);
}
Ejemplo n.º 4
0
GLOBAL void TP_Msg_Need_f (void)
{
	MSGPART team_powerup = "";
    MSGPART need = "";
 
	if (DEAD())
		return;

	TP_GetNeed();

	if (NEED(health) || NEED(armor) || NEED_WEAPON() || NEED(rockets) || NEED(cells) || NEED(shells) || NEED(nails)) {
		need = "need %u $[{%l}$]";
		
		if (HAVE_POWERUP())
			team_powerup = "{&c0b0team&cfff} $colored_powerups ";
		
		if (need[0] == 0 && team_powerup[0] == 0)
			return;

		TP_Send_TeamSay("%s%s", team_powerup, need);
	}
}
Ejemplo n.º 5
0
/*
 * configuration of pipes, schedulers, flowsets.
 * When we configure a new scheduler, an empty pipe is created, so:
 * 
 * do_pipe = 1 -> "pipe N config ..." only for backward compatibility
 *	sched N+Delta type fifo sched_mask ...
 *	pipe N+Delta <parameters>
 *	flowset N+Delta pipe N+Delta (no parameters)
 *	sched N type wf2q+ sched_mask ...
 *	pipe N <parameters>
 *
 * do_pipe = 2 -> flowset N config
 *	flowset N parameters
 *
 * do_pipe = 3 -> sched N config
 *	sched N parameters (default no pipe)
 *	optional Pipe N config ...
 * pipe ==>
 */
int
ipfw_config_pipe(int ac, char **av, int do_pipe)
{
	int i, j;
	char *end;
	void *par = NULL;
	struct dn_id *buf, *base;
	struct dn_sch *sch = NULL;
	struct dn_link *p = NULL;
	struct dn_fs *fs = NULL;
	struct ipfw_flow_id *mask = NULL;
	int lmax;
	uint32_t _foo = 0, *flags = &_foo , *buckets = &_foo;

	/*
	 * allocate space for 1 header,
	 * 1 scheduler, 1 link, 1 flowset, 1 profile
	 */
	lmax = sizeof(struct dn_id);	/* command header */
	lmax += sizeof(struct dn_sch) + sizeof(struct dn_link) +
		sizeof(struct dn_fs) + sizeof(struct dn_profile);

	av++; ac--;
	/* Pipe number */
	if (ac && isdigit(**av)) {
		i = atoi(*av); av++; ac--;
	} else
		i = -1;
	if (i <= 0) {
		php_printf("need a pipe/flowset/sched number");
		return (-1);
	}
	base = buf = calloc(1, lmax);
	if (base == NULL)
		return (-1);
	/* all commands start with a 'CONFIGURE' and a version */
	o_next(&buf, sizeof(struct dn_id), DN_CMD_CONFIG);
	base->id = DN_API_VERSION;

	switch (do_pipe) {
	case 1: /* "pipe N config ..." */
		/* Allocate space for the WF2Q+ scheduler, its link
		 * and the FIFO flowset. Set the number, but leave
		 * the scheduler subtype and other parameters to 0
		 * so the kernel will use appropriate defaults.
		 * XXX todo: add a flag to record if a parameter
		 * is actually configured.
		 * If we do a 'pipe config' mask -> sched_mask.
		 * The FIFO scheduler and link are derived from the
		 * WF2Q+ one in the kernel.
		 */
		sch = o_next(&buf, sizeof(*sch), DN_SCH);
		p = o_next(&buf, sizeof(*p), DN_LINK);
		fs = o_next(&buf, sizeof(*fs), DN_FS);

		sch->sched_nr = i;
		sch->oid.subtype = 0;	/* defaults to WF2Q+ */
		mask = &sch->sched_mask;
		flags = &sch->flags;
		buckets = &sch->buckets;
		*flags |= DN_PIPE_CMD;

		p->link_nr = i;

		/* This flowset is only for the FIFO scheduler */
		fs->fs_nr = i + 2*DN_MAX_ID;
		fs->sched_nr = i + DN_MAX_ID;
		break;

	case 2: /* "queue N config ... " */
		fs = o_next(&buf, sizeof(*fs), DN_FS);
		fs->fs_nr = i;
		mask = &fs->flow_mask;
		flags = &fs->flags;
		buckets = &fs->buckets;
		break;

	case 3: /* "sched N config ..." */
		sch = o_next(&buf, sizeof(*sch), DN_SCH);
		fs = o_next(&buf, sizeof(*fs), DN_FS);
		sch->sched_nr = i;
		mask = &sch->sched_mask;
		flags = &sch->flags;
		buckets = &sch->buckets;
		/* fs is used only with !MULTIQUEUE schedulers */
		fs->fs_nr = i + DN_MAX_ID;
		fs->sched_nr = i;
		break;
	}
	/* set to -1 those fields for which we want to reuse existing
	 * values from the kernel.
	 * Also, *_nr and subtype = 0 mean reuse the value from the kernel.
	 * XXX todo: support reuse of the mask.
	 */
	if (p)
		p->bandwidth = -1;
	for (j = 0; j < sizeof(fs->par)/sizeof(fs->par[0]); j++)
		fs->par[j] = -1;
	while (ac > 0) {
		double d;
		int tok = match_token(dummynet_params, *av);
		ac--; av++;

		switch(tok) {
		case TOK_NOERROR:
			NEED(fs, "noerror is only for pipes");
			fs->flags |= DN_NOERROR;
			break;

		case TOK_PLR:
			NEED(fs, "plr is only for pipes");
			NEED1("plr needs argument 0..1\n");
			d = strtod(av[0], NULL);
			if (d > 1)
				d = 1;
			else if (d < 0)
				d = 0;
			fs->plr = (int)(d*0x7fffffff);
			ac--; av++;
			break;

		case TOK_QUEUE:
			NEED(fs, "queue is only for pipes or flowsets");
			NEED1("queue needs queue size\n");
			end = NULL;
			fs->qsize = strtoul(av[0], &end, 0);
			if (*end == 'K' || *end == 'k') {
				fs->flags |= DN_QSIZE_BYTES;
				fs->qsize *= 1024;
			} else if (*end == 'B' ||
			    _substrcmp2(end, "by", "bytes") == 0) {
				fs->flags |= DN_QSIZE_BYTES;
			}
			ac--; av++;
			break;

		case TOK_BUCKETS:
			NEED(fs, "buckets is only for pipes or flowsets");
			NEED1("buckets needs argument\n");
			*buckets = strtoul(av[0], NULL, 0);
			ac--; av++;
			break;

		case TOK_FLOW_MASK:
		case TOK_SCHED_MASK:
		case TOK_MASK:
			NEED(mask, "tok_mask");
			NEED1("mask needs mask specifier\n");
			/*
			 * per-flow queue, mask is dst_ip, dst_port,
			 * src_ip, src_port, proto measured in bits
			 */
			par = NULL;

			bzero(mask, sizeof(*mask));
			end = NULL;

			while (ac >= 1) {
			    uint32_t *p32 = NULL;
			    uint16_t *p16 = NULL;
			    uint32_t *p20 = NULL;
			    struct in6_addr *pa6 = NULL;
			    uint32_t a;

			    tok = match_token(dummynet_params, *av);
			    ac--; av++;
			    switch(tok) {
			    case TOK_ALL:
				    /*
				     * special case, all bits significant
				     * except 'extra' (the queue number)
				     */
				    mask->dst_ip = ~0;
				    mask->src_ip = ~0;
				    mask->dst_port = ~0;
				    mask->src_port = ~0;
				    mask->proto = ~0;
				    n2mask(&mask->dst_ip6, 128);
				    n2mask(&mask->src_ip6, 128);
				    mask->flow_id6 = ~0;
				    *flags |= DN_HAVE_MASK;
				    goto end_mask;

			    case TOK_QUEUE:
				    mask->extra = ~0;
				    *flags |= DN_HAVE_MASK;
				    goto end_mask;

			    case TOK_DSTIP:
				    mask->addr_type = 4;
				    p32 = &mask->dst_ip;
				    break;

			    case TOK_SRCIP:
				    mask->addr_type = 4;
				    p32 = &mask->src_ip;
				    break;

			    case TOK_DSTIP6:
				    mask->addr_type = 6;
				    pa6 = &mask->dst_ip6;
				    break;
			    
			    case TOK_SRCIP6:
				    mask->addr_type = 6;
				    pa6 = &mask->src_ip6;
				    break;

			    case TOK_FLOWID:
				    mask->addr_type = 6;
				    p20 = &mask->flow_id6;
				    break;

			    case TOK_DSTPORT:
				    p16 = &mask->dst_port;
				    break;

			    case TOK_SRCPORT:
				    p16 = &mask->src_port;
				    break;

			    case TOK_PROTO:
				    break;

			    default:
				    ac++; av--; /* backtrack */
				    goto end_mask;
			    }
			    if (ac < 1) {
				    php_printf("mask: value missing");
				    goto end;
			    }
			    if (*av[0] == '/') {
				    a = strtoul(av[0]+1, &end, 0);
				    if (pa6 == NULL)
					    a = (a == 32) ? ~0 : (1 << a) - 1;
			    } else
				    a = strtoul(av[0], &end, 0);
			    if (p32 != NULL)
				    *p32 = a;
			    else if (p16 != NULL) {
				    if (a > 0xFFFF) {
					php_printf("port mask must be 16 bit");
					goto end;
				    }
				    *p16 = (uint16_t)a;
			    } else if (p20 != NULL) {
				    if (a > 0xfffff) {
					 php_printf("flow_id mask must be 20 bit");
					 goto end;
				    }
				    *p20 = (uint32_t)a;
			    } else if (pa6 != NULL) {
				    if (a > 128) {
					    php_printf("in6addr invalid mask len");
					   goto end;
				    }
				    else
					n2mask(pa6, a);
			    } else {
				    if (a > 0xFF) {
					php_printf("proto mask must be 8 bit");
					goto end;
				    }
				    mask->proto = (uint8_t)a;
			    }
			    if (a != 0)
				    *flags |= DN_HAVE_MASK;
			    ac--; av++;
			} /* end while, config masks */
end_mask:
			break;

		case TOK_DROPTAIL:
			NEED(fs, "droptail is only for flowsets");
			fs->flags &= ~(DN_IS_RED|DN_IS_GENTLE_RED);
			break;

		case TOK_BW:
			NEED(p, "bw is only for links");
			NEED1("bw needs bandwidth or interface\n");
			if (read_bandwidth(av[0], &p->bandwidth, NULL, 0) < 0)
				goto end;
			ac--; av++;
			break;

		case TOK_DELAY:
			NEED(p, "delay is only for links");
			NEED1("delay needs argument 0..10000ms\n");
			p->delay = strtoul(av[0], NULL, 0);
			ac--; av++;
			break;

		case TOK_TYPE: {
			int l;
			NEED(sch, "type is only for schedulers");
			NEED1("type needs a string");
			l = strlen(av[0]);
			if (l == 0 || l > 15) {
				php_printf("type %s too long\n", av[0]);
				goto end;
			}
			strcpy(sch->name, av[0]);
			sch->oid.subtype = 0; /* use string */
			ac--; av++;
			break;
		    }

		case TOK_WEIGHT:
			NEED(fs, "weight is only for flowsets");
			NEED1("weight needs argument\n");
			fs->par[0] = strtol(av[0], &end, 0);
			ac--; av++;
			break;

		case TOK_LMAX:
			NEED(fs, "lmax is only for flowsets");
			NEED1("lmax needs argument\n");
			fs->par[1] = strtol(av[0], &end, 0);
			ac--; av++;
			break;

		case TOK_PRI:
			NEED(fs, "priority is only for flowsets");
			NEED1("priority needs argument\n");
			fs->par[2] = strtol(av[0], &end, 0);
			ac--; av++;
			break;

		case TOK_SCHED:
		case TOK_PIPE:
			NEED(fs, "pipe/sched");
			NEED1("pipe/link/sched needs number\n");
			fs->sched_nr = strtoul(av[0], &end, 0);
			ac--; av++;
			break;

		default:
			php_printf("unrecognised option ``%s''", av[-1]);
			goto end;
		}
	}

	/* check validity of parameters */
	if (p) {
		if (p->delay > 10000) {
			php_printf("delay must be < 10000");
			goto end;
		}
		if (p->bandwidth == -1)
			p->bandwidth = 0;
	}
	if (fs) {
		/* XXX accept a 0 scheduler to keep the default */
	    if (fs->flags & DN_QSIZE_BYTES) {
		size_t len;
		long limit;

		len = sizeof(limit);
		if (sysctlbyname("net.inet.ip.dummynet.pipe_byte_limit",
			&limit, &len, NULL, 0) == -1)
			limit = 1024*1024;
		if (fs->qsize > limit) {
			php_printf("queue size must be < %ldB", limit);
			goto end;
		}
	    } else {
		size_t len;
		long limit;

		len = sizeof(limit);
		if (sysctlbyname("net.inet.ip.dummynet.pipe_slot_limit",
			&limit, &len, NULL, 0) == -1)
			limit = 100;
		if (fs->qsize > limit) {
			php_printf("2 <= queue size <= %ld", limit);
			goto end;
		}
	    }

	    if (fs->flags & DN_IS_RED) {
		size_t len;
		int lookup_depth, avg_pkt_size;
		double w_q;

		if (fs->min_th >= fs->max_th) {
		    php_printf("min_th %d must be < than max_th %d",
			fs->min_th, fs->max_th);
			goto end;
		}
		if (fs->max_th == 0) {
			php_printf("max_th must be > 0");
			goto end;
		}

		len = sizeof(int);
		if (sysctlbyname("net.inet.ip.dummynet.red_lookup_depth",
			&lookup_depth, &len, NULL, 0) == -1)
			lookup_depth = 256;
		if (lookup_depth == 0) {
		    php_printf("net.inet.ip.dummynet.red_lookup_depth"
			" must be greater than zero");
			goto end;
		}

		len = sizeof(int);
		if (sysctlbyname("net.inet.ip.dummynet.red_avg_pkt_size",
			&avg_pkt_size, &len, NULL, 0) == -1)
			avg_pkt_size = 512;

		if (avg_pkt_size == 0) {
			    php_printf("net.inet.ip.dummynet.red_avg_pkt_size must"
			    " be greater than zero");
			goto end;
		}

		/*
		 * Ticks needed for sending a medium-sized packet.
		 * Unfortunately, when we are configuring a WF2Q+ queue, we
		 * do not have bandwidth information, because that is stored
		 * in the parent pipe, and also we have multiple queues
		 * competing for it. So we set s=0, which is not very
		 * correct. But on the other hand, why do we want RED with
		 * WF2Q+ ?
		 */
#if 0
		if (p.bandwidth==0) /* this is a WF2Q+ queue */
			s = 0;
		else
			s = (double)ck.hz * avg_pkt_size * 8 / p.bandwidth;
#endif
		/*
		 * max idle time (in ticks) before avg queue size becomes 0.
		 * NOTA:  (3/w_q) is approx the value x so that
		 * (1-w_q)^x < 10^-3.
		 */
		w_q = ((double)fs->w_q) / (1 << SCALE_RED);
#if 0 // go in kernel
		idle = s * 3. / w_q;
		fs->lookup_step = (int)idle / lookup_depth;
		if (!fs->lookup_step)
			fs->lookup_step = 1;
		weight = 1 - w_q;
		for (t = fs->lookup_step; t > 1; --t)
			weight *= 1 - w_q;
		fs->lookup_weight = (int)(weight * (1 << SCALE_RED));
#endif
	    }
	}

	i = do_cmd(IP_DUMMYNET3, base, (char *)buf - (char *)base);

	if (i)
		php_printf("setsockopt(%s)", "IP_DUMMYNET_CONFIGURE");

	free(base);

	return (0); /* XXX: i? */
end:
	if (base != NULL)
		free(base);
	return (-1);
}
Ejemplo n.º 6
0
void
parse_to(ipfw_insn **cmd, int *ac, char **av[])
{
	ipfw_insn_ip *p = (ipfw_insn_ip *)(*cmd);
	double port;
	int i;

	(*cmd)->module = MODULE_BASIC_ID;
	NEXT_ARG1;
	if (strcmp(**av, "table") == 0) {
		NEXT_ARG1;
		NEED(*ac, 1, "table id missing");
		(*cmd)->len = F_INSN_SIZE(ipfw_insn);
		(*cmd)->opcode = O_BASIC_IP_DST_LOOKUP;
		(*cmd)->arg1 = strtoul(**av, NULL, 10);
	} else if (strcmp(**av, "any") == 0) {
		(*cmd)->len &= ~F_LEN_MASK;
	} else if (strcmp(**av, "me") == 0) {
		(*cmd)->len |= F_INSN_SIZE(ipfw_insn);
		(*cmd)->opcode = O_BASIC_IP_DST_ME;
	} else {
		char *c = NULL, md = 0;
		c = strchr(**av, '/');
		if (!c)
			c = strchr(**av, ':');
		if (c) {
			md = *c;
			*c++ = '\0';
		}
		if (lookup_host(**av, &p->addr) != 0)
			errx(EX_NOHOST, "hostname ``%s'' unknown", **av);
		switch (md) {
			case ':':
				port = strtol(c, NULL, 0);
				if (port <= 0 || port >= 65535)
					errx(EX_NOHOST, "port `%s' invalid", c);
				(*cmd)->arg1 = port;
				(*cmd)->len |= F_INSN_SIZE(ipfw_insn_ip);
				(*cmd)->opcode = O_BASIC_IP_DST_N_PORT;
				break;
			case '/':
				i = atoi(c);
				if (i == 0)
					p->mask.s_addr = htonl(0);
				else if (i > 32)
					errx(EX_DATAERR, "bad width ``%s''", c);
				else
					p->mask.s_addr = htonl(~0 << (32 - i));
				(*cmd)->len |= F_INSN_SIZE(ipfw_insn_ip);
				(*cmd)->opcode = O_BASIC_IP_DST_MASK;
				p->addr.s_addr &= p->mask.s_addr;
				break;
			default:
				p->mask.s_addr = htonl(~0);
				(*cmd)->len |= F_INSN_SIZE(ipfw_insn_u32);
				(*cmd)->opcode = O_BASIC_IP_DST;
				break;
		}
	}
	NEXT_ARG1;

}
Ejemplo n.º 7
0
void update_stuff() {
  unsigned int i;

  info.mask = 0;

  if (no_buffers) need_mask |= 1 << INFO_BUFFERS;

  /* clear speeds and up status in case device was removed and doesn't get
   * updated */

  for (i=0; i<16; i++) {
    if (netstats[i].dev) {
      netstats[i].up = 0;
      netstats[i].recv_speed = 0.0;
      netstats[i].trans_speed = 0.0;
    }
  }

  prepare_update();

#define NEED(a) ((need_mask & (1 << a)) && ((info.mask & (1 << a)) == 0))

  if (NEED(INFO_UPTIME)) update_uptime();

  if (NEED(INFO_PROCS)) update_total_processes();

  if (NEED(INFO_RUN_PROCS)) update_running_processes();

  if (NEED(INFO_CPU)) update_cpu_usage();

  if (NEED(INFO_NET)) update_net_stats();

  if (NEED(INFO_MAIL)) update_mail_count();

#ifdef SETI
  if (NEED(INFO_SETI)) update_seti();
#endif

  if (NEED(INFO_LOADAVG)) update_load_average();

  if ((NEED(INFO_MEM) || NEED(INFO_BUFFERS)) &&
      current_update_time - last_meminfo_update > 6.9) {
    update_meminfo();
    if (no_buffers) info.mem -= info.bufmem;
    last_meminfo_update = current_update_time;
  }

  /* update_fs_stat() won't do anything if there aren't fs -things */
  if (NEED(INFO_FS) && current_update_time - last_fs_update > 12.9) {
    update_fs_stats();
    last_fs_update = current_update_time;
  }
}
Ejemplo n.º 8
0
GLOBAL void TP_Msg_EnemyPowerup_f (void) // might as well add flag to this monster. need $point and $took to see red/blue flag!
{
	/*	This is the "go-to" function!". It contains all possible scenarios for any player, teammate or enemy, with any combination of powerup.
	!!! Please note this function is grouped into four parts: player with eyes (assumed enemy), enemy with powerup, you with powerup, teammate with powerup. !!! */
	extern cvar_t tp_name_quad, tp_name_pent, tp_name_quaded, tp_name_pented, tp_name_eyes, tp_name_enemy;
	MSGPART quad = "";
	MSGPART quaded = "";
	MSGPART pent = "";
	MSGPART pented = "";
	MSGPART eyes = "";
	MSGPART team = "";
	MSGPART enemy = "";
	MSGPART location = "at $[{%y}$]";
	MSGPART space = "";
	
	if (flashed) return;
    TP_FindPoint();
	
	/* Note we don't have && INPOINT(enemy) in the below if.
	This is because $point DOES NOT TELL YOU TEAMMATE/ENEMY if they have ring (because there is no way to know).
	Therefore, we don't assume enemy when we see eyes anymore because this confuses people into thinking it's ALWAYS enemy, so we just say "eyes at location" */		
	if (INPOINT(eyes)) {
		eyes = tp_name_eyes.string;

		if (INPOINT(quaded) && INPOINT(pented))	{ // Since we can't say "enemy (or) team eyes", instead we say "quaded pented eyes"
			quaded = tp_name_quaded.string;
			pented = tp_name_pented.string;
		}
		else if (INPOINT(quaded))
			quad = tp_name_quad.string;
		else if (INPOINT(pented))
			pent = tp_name_pent.string;
	}
	else if (INPOINT(enemy)) {
		enemy = tp_name_enemy.string; // %q is last seen powerup of enemy. defaults to quad, which is nice (but it won't be colored)
		space = " ";

		if (INPOINT(quaded) && INPOINT(pented))	{
			quad = tp_name_quad.string;
			pent = tp_name_pent.string;
		}
		else if (INPOINT(quaded))
			quad = tp_name_quad.string;
		else if (INPOINT(pented))
			pent = tp_name_pent.string;
		else {// Default to "enemy powerup", because that's the purpose of this function
			quad = "%q"; //we're hi-jacking "quad" here
			location = ""; //Report only "enemy quad", not "enemy quad %l" which is confusing
		}
	}
	else if (HAVE_POWERUP()) {
		if (DEAD()) { // if you are dead with powerup, then you dont technically have it.
			TP_Msg_Lost_f(); // this function will take care of it
			return;
		}
		
		TP_GetNeed();	
		if (NEED(health) || NEED(armor) || NEED_WEAPON() || NEED(rockets) || NEED(cells)) { // Note this doesn't include shells/nails. Not as broad as tp_msgneed.
			TP_Msg_Need_f();
			return;
		}
		else
			team = "{&c0b0team&cfff} $colored_powerups";
	}
	else if (INPOINT(teammate)) {
		team = "{&c0b0team&cfff} ";

		if (INPOINT(quaded) && INPOINT(pented))	{
			quad = tp_name_quad.string;
			pent = tp_name_pent.string;
		}
		else if (INPOINT(quaded))
			quad = tp_name_quad.string;
		else if (INPOINT(pented))
			pent = tp_name_pent.string;
		else { // Default to "enemy powerup", because that's the purpose of this function
			team = tp_name_enemy.string; // We're hi-jacking "team" to mean enemy here. %q is last seen powerup of enemy. defaults to quad, which is nice (but it won't be colored)
			quad = "%q"; // we're hi-jacking "quad" here
			location = ""; //Report only "enemy quad", not "enemy quad %l" which is confusing
		}
	}
	else { // Default to "enemy powerup", because that's the purpose of this function
		enemy = tp_name_enemy.string; // %q is last seen powerup of enemy. defaults to quad, which is nice (but it won't be colored)
		location = "%q"; //we're hi-jacking "location" here
	}

	TP_Send_TeamSay("%s%s%s%s%s%s%s%s %s", team, enemy, space, quad, pent, quaded, pented, eyes, location);
}
Ejemplo n.º 9
0
GLOBAL void TP_Msg_EnemyPowerup_f (void) // might as well add flag to this monster. need $point and $took to see red/blue flag!
{
	/*
	This is the "go-to" function!". It contains all possible scenarios for any player, teammate or enemy, with any combination of powerup.
	!!! Please note this function is grouped into four parts: player with eyes (assumed enemy), enemy with powerup, you with powerup, teammate with powerup. !!!
	*/
	MSGPART message = "";
	
	if (flashed) return;
    TP_FindPoint();
	
		/*
		Note we don't have && INPOINT(enemy) in the below if.
		This is because $point DOES NOT TELL YOU TEAMMATE/ENEMY if they have ring (because there is no way to know).
		Therefore, we don't assume enemy when we see eyes anymore because this confuses people into thinking it's ALWAYS enemy, so we just say "eyes at location"
		*/
		
	if (INPOINT(eyes))
	{
		if (INPOINT(quaded) && INPOINT(pented))
		{
			message = tp_ib_name_quaded " " tp_ib_name_pented " " tp_ib_name_eyes " at $[{%y}$]";
		}
		else if (INPOINT(quaded))
		{
			message = tp_ib_name_quaded " " tp_ib_name_eyes " at $[{%y}$]";
		}
		else if (INPOINT(pented))
		{
			message = tp_ib_name_pented " " tp_ib_name_eyes " at $[{%y}$]";
		}
		else
		{
			message = tp_ib_name_eyes " at $[{%y}$]";
		}
	}
	else if (INPOINT(enemy))
	{
		if (INPOINT(quaded) && INPOINT(pented))
		{
			message = tp_ib_name_quaded " " tp_ib_name_pented " " tp_ib_name_enemy " at $[{%y}$]";
		}
		else if (INPOINT(quaded))
		{
			message = tp_ib_name_quaded " " tp_ib_name_enemy " at $[{%y}$]";
		}
		else if (INPOINT(pented))
		{
			message = tp_ib_name_pented " " tp_ib_name_enemy " at $[{%y}$]";
		}
		else
		{
			message = tp_ib_name_enemy " %q"; // %q is last seen powerup of enemy. defaults to quad, which is nice (but it won't be colored)
		}
	}
	else if (HAVE_POWERUP())
	{
		TP_GetNeed();
		if (DEAD()) // if you are dead with powerup, then you dont technically have it.
		{
			TP_Msg_Lost_f(); // this function will take care of it
			return;
		}		
		else if (NEED(health) || NEED(armor) || NEED_WEAPON() || NEED(rockets) || NEED(cells)) // all things we care for
		{
			message = tp_ib_name_team " $colored_powerups need %u $[{%l}$]";
		}
		else
		{
			message = tp_ib_name_team " $colored_powerups";
		}
	}
	else if (INPOINT(teammate))
	{
		if (INPOINT(quaded) && INPOINT(pented))
		{
			message = tp_ib_name_team " " tp_ib_name_quad " " tp_ib_name_pent;
		}
		else if (INPOINT(quaded))
		{
			message = tp_ib_name_team " " tp_ib_name_quad;
		}
		else if (INPOINT(pented))
		{
			message = tp_ib_name_team " " tp_ib_name_pent;	
		}
		else
		{
			message = tp_ib_name_enemy " %q"; // %q is last seen powerup of enemy. defaults to quad, which is nice (but it won't be colored)
		}
	}
	else
	{
		message = tp_ib_name_enemy " %q"; // %q is last seen powerup of enemy. defaults to quad, which is nice (but it won't be colored)
	}

	TP_Send_TeamSay("%s", message);
}