Example #1
0
void
show_chars_below(int who, int n)
{
  int i;

  assert(valid_box(who));

  indent += 3;
  loop_char_here(n, i) {
    assert(valid_box(who));
    wiout(who, 3, "%s", liner_desc(i));
  }
Example #2
0
int main(void)
{
	int max = 1000;
	for(long b=1; b < max; b++)
	for(long r=1; r < max; r++)
	{
		if(valid_box(b,r))
		{
			double bb = b, rr = r;
			printf("box: b= %ld r= %ld\n",b,r);
			printf("ratio: r/b= %.5f b/t= %.5f r/t= %.5f\n",
						rr/bb, bb/(bb+rr), rr/(bb+rr));
		}
	}
	printf("\n");
	
	printf("1/sqrt(2) = %.18Lf\n",invsqrt2);
	
	printf("1e12/sqrt(2) = %Lf\n",1.1123e12*invsqrt2);
	printf("1e12/sqrt(2) = %ld\n", (u64) (1.1123e12*invsqrt2));
	
	u64 am2 = 1;
	u64 am1 = 3;
	u64 a = 6*am1 - am2 - 2;
	
	while( a < 1e12)
	{
		am2 = am1;
		am1 = a;
		a = 6*am1 - am2 - 2;
		printf("a = %ld\n", a);
	}
	
	
	u64 t = 1;
	while(1)
	{
		u64 blue = t*invsqrt2;
		for(int i=-2; i<=2; i++)
		{
			//printf("t = %ld b = %ld\n", t, blue);
			if(valid_box(blue+i, t))
			{
				printf("blue = %ld total = %ld\n", blue+i, t);
				//exit(0);
			}
		}
		t++;
	}
}
void
set_name(int n, char *s)
{

	assert(valid_box(n));

	if (bx[n]->name)
		my_free(bx[n]->name);

	bx[n]->name = str_save(s);

	{
		char *t;

		for (t = bx[n]->name; *t; t++)
		{
			switch (*t)
			{
			case '[':
				*t = '{';
				break;

			case ']':
				*t = '}';
				break;
			}
		}
	}
}
char *
display_name(int n)
{
	char *s;
	int i;

	if (!valid_box(n))
		return "";

	s = name(n);

	if (s && *s)
		return s;

	switch (kind(n))
	{
	case T_player:		return "Player";
	case T_gate:		return "Gate";
	case T_post:		return "Sign";
	}

	if (i = noble_item(n))
		return cap(plural_item_name(i, 1));

	return cap(subkind_s[subkind(n)]);
}
char *
display_kind(int n)
{
	char *s;

	switch (subkind(n))
	{
	case sub_city:
		if (is_port_city(n))
			s = "port city";
		else
			s = "city";
		break;

	case sub_fog:
	case sub_rain:
	case sub_wind:
	case sub_mist:
		s = "storm";
		break;

	case sub_guild:
	  if (rp_subloc(n) && rp_subloc(n)->guild &&
	      valid_box(rp_subloc(n)->guild)) 
	    s = sout("%s Guild",bx[rp_subloc(n)->guild]->name);
	  else
	    s = "";
	  break;

	default:
		s = subkind_s[subkind(n)];
	}

	return s;
}
Example #6
0
char *
loc_inside_string(int where)
{
  char *name = NULL;
  char *trail = NULL;

  if (loc_depth(where) > LOC_region) {
    trail = loc_inside_string(loc(where));
  };

  switch (loc_depth(where)) {
  case LOC_region:
    name = just_name(region(where));
    break;
  case LOC_province:
    if (!valid_box(where))
      name = sout("adrift in the Cosmos");
    else
      name = box_name(where);
    break;
  default:
    name = box_name(where);
  };

  if (trail != NULL)
    return sout(", in %s%s", name, trail);

  return sout(", in %s", name);
};
Example #7
0
int
v_lore(struct command *c)
{

  if (valid_box(c->a))
    deliver_lore(c->who, c->a);

  return TRUE;
}
char *
name(int n)
{

	assert(valid_box(n));

	if (bx[n]->name)
		return bx[n]->name;

	return "";
}
Example #9
0
int
v_dump(struct command *c)
{

  if (valid_box(c->a)) {
    bx[c->a]->temp = 0;
    save_box(stdout, c->a);
    return TRUE;
  }

  return FALSE;
}
Example #10
0
int
v_be(struct command *c)
{

  if (valid_box(c->a)) {
    immediate = c->a;
    out(immediate, "You are now %s.", box_name(c->a));
    return TRUE;
  }

  out(c->who, "'%s' not a valid box.", c->parse[1]);
  return FALSE;
}
static void
add_here(int who, ilist *l)
{
	int i;
	struct loc_info *p;

	assert(valid_box(who));

	ilist_append(l, who);

	p = rp_loc_info(who);
	assert(p != NULL);

	for (i = 0; i < ilist_len(p->here_list); i++)
		add_here(p->here_list[i], l);
}
char *
just_name(int n)
{
	char *s;

	if (n == garrison_magic)
		return "Garrison";

	if (valid_box(n))
	{
		s = display_name(n);
		if (s && *s)
			return s;
	}

	return box_code(n);
}
void
all_here(int who, ilist *l)
{
	int i;
	struct loc_info *p;

	assert(valid_box(who));

	ilist_clear(l);

	p = rp_loc_info(who);

	if (p == NULL)
		return;

	for (i = 0; i < ilist_len(p->here_list); i++)
		add_here(p->here_list[i], l);
}
Example #14
0
static int
get_command(int who, char *s)
{
  int fact;                     /* who controls us now? */
  char *order;

  if (!valid_box(who) || kind(who) == T_deadchar)
    return FALSE;

  fact = player(who);

  if (fact == 0)
    return FALSE;

  order = top_order(fact, who);

/*
 *  If we don't have any orders, then fail.
 */

  if (order == NULL)
    return FALSE;

/*
 *  Update the player's last turn field so we know if he's been
 *  playing or not.
 */

  {
    struct entity_player *p;

    p = p_player(fact);
    p->last_order_turn = sysclock.turn;
  }

  assert(strlen(order) < LEN);  /* maybe not a valid assert */

  strncpy(s, order, LEN - 1);
  s[LEN - 1] = '\0';

  pop_order(fact, who);

  return TRUE;
}
Example #15
0
int
v_relore(struct command *c)
{
  int i;
  int skill = c->a;

  if (!valid_box(skill) || kind(skill) != T_skill) {
    wout(c->who, "%s is not a skill.", c->parse[1]);
    return FALSE;
  }

  loop_char(i) {
    if (has_skill(i, skill))
      queue_lore(i, skill, TRUE);
  }
  next_char;

  return TRUE;
}
void
all_stack(int who, ilist *l)
{
	int i;
	struct loc_info *p;

	assert(valid_box(who));

	ilist_clear(l);
	ilist_append(l, who);

	p = rp_loc_info(who);

	if (p == NULL)
		return;

	for (i = 0; i < ilist_len(p->here_list); i++)
		if (kind(p->here_list[i]) == T_char)
			add_char_here(p->here_list[i], l);
}
Example #17
0
int
v_eat_dead(struct command *c)
{
  int body = c->a;

  /*
   *  Sun Jun  1 10:31:40 1997 -- Scott Turner
   *
   *  Might have a lost soul as a prisoner...
   *
   */
  if (!valid_box(body)) {
    wout(c->who, "Don't have %s.", box_code(body));
    return FALSE;
  }

  if (kind(body) == T_item) {
    if (subkind(body) != sub_dead_body) {
      wout(c->who, "%s is not a dead body.", box_code(body));
      return FALSE;
    };
    if (!has_item(c->who, body)) {
      wout(c->who, "You do not possess that body.");
      return FALSE;
    };
  }
  else if (kind(body) == T_char) {
    if (subkind(body) != sub_lost_soul) {
      wout(c->who, "%s is not a lost soul.", box_code(body));
      return FALSE;
    };
    if (!has_prisoner(c->who, body)) {
      wout(c->who, "You have not captured that lost soul.");
      return FALSE;
    };
  };

  return TRUE;
}
Example #18
0
char *
loc_inside_string(int where)
{
  char *reg_name;

  if (loc_depth(where) == LOC_build) {
    if (subkind(loc(where)) == sub_ocean)
      return sout(", in %s", box_name(province(where)));

    if (loc_depth(loc(where)) == LOC_province)
      return sout(", in province %s", box_name(province(where)));

    return sout(", in %s", box_name(province(where)));
  }
  else if (loc_depth(where) == LOC_subloc) {
    if (subkind(province(where)) == sub_ocean)
      return sout(", in %s", box_name(province(where)));
    else if (!valid_box(province(where)))
      return sout(", adrift in the Cosmos");
    else
      return sout(", in province %s", box_name(province(where)));
  }
  else if (subkind(where) == sub_ocean) {
    reg_name = name(region(where));

    if (reg_name && *reg_name)
      return sout(", in %s", reg_name);
    return "";
  }
  else {
    reg_name = name(region(where));

    if (reg_name && *reg_name)
      return sout(", in %s", reg_name);

    return "";
  }
}
char *
box_name(int n)
{
	char *s;

	if (n == garrison_magic)
		return "Garrison";

	if (valid_box(n))
	{
		s = display_name(n);
		if (s && *s)
		{
		  if (options.output_tags > 0)
		    return sout("<tag type=box id=%d>%s~%s</tag type=box id=%d>",
				n,
				s, box_code(n),n);
		  else
		    return sout("%s~%s", s, box_code(n));
		}
	}

	return box_code(n);
}
int
d_reveal_mage(struct command *c)
{
	int target = c->a;
	int category = c->b;
	int aura = c->c;
	int has_detect;
	char *source;

	if (!charge_aura(c->who, aura))
		return FALSE;

	assert(valid_box(category));
	assert(skill_school(category) == category && magic_skill(category));

	has_detect = has_skill(target, sk_detect_abil);

	if (has_detect > exp_novice)
		source = box_name(c->who);
	else
		source = "Someone";

	if (aura <= char_abil_shroud(target))
	{
		wout(c->who, "The abilities of %s are shrouded from "
				"your scry.", box_name(target));

		if (has_detect)
			wout(target, "%s cast %s on us, but failed to learn "
				"anything.", source, box_name(sk_reveal_mage));

		if (has_detect > exp_teacher)
			wout(target, "They sought to learn what we "
					"know of %s.", box_name(category));

		return FALSE;
	}

	{
		int first = TRUE;
		struct skill_ent *e;

		loop_char_skill_known(target, e)
		{
			if (skill_school(e->skill) != category ||
			    e->skill == category)
				continue;

			if (first)
			{
				wout(c->who, "%s knows the following "
						"%s spells:",
						box_name(target),
						box_name(category));
				indent += 3;
				first = FALSE;
			}

			if (c->use_exp > exp_journeyman)
				list_skill_sup(c->who, e);
			else
				wout(c->who, "%s", box_name(e->skill));
		}
		next_char_skill_known;

		if (first)
			wout(c->who, "%s knowns no %s spells.",
					box_name(target), box_name(category));
		else
			indent -= 3;

	}

	if (has_detect)
	{
		wout(target, "%s successfully cast %s on us.",
			source, box_name(sk_reveal_mage));

		if (has_detect > exp_teacher)
			wout(target, "Our knowledge of %s was revealed.",
					box_name(category));
	}

	return TRUE;
}