Exemplo n.º 1
0
/** Attempt to create a new player object.
 * \param d DESC the creation attempt is being made on (if from connect screen)
 * \param executor dbref of the object attempting to create a player (if
 * \@pcreate)
 * \param name name of player to create.
 * \param password initial password of created player.
 * \param host host from which creation is attempted.
 * \param ip ip address from which creation is attempted.
 * \return dbref of created player, NOTHING if invalid name, AMBIGUOUS if taken
 *  name, or HOME for a bad password
 *  password.
 */
dbref
create_player(DESC *d, dbref executor, const char *name, const char *password,
              const char *host, const char *ip)
{
  if (!ok_player_name(name, executor, NOTHING)) {
    do_log(LT_CONN, 0, 0, "Failed creation (bad name) from %s", host);
    if (d) {
      queue_event(SYSEVENT, "SOCKET`CREATEFAIL", "%d,%s,%d,%s,%s",
                  d->descriptor, ip, mark_failed(ip), "create: bad name", name);
    }
    return (lookup_player(name) == NOTHING ? NOTHING : AMBIGUOUS);
  }
  if (!ok_password(password)) {
    do_log(LT_CONN, 0, 0, "Failed creation (bad password) from %s", host);
    if (d) {
      queue_event(SYSEVENT, "SOCKET`CREATEFAIL", "%d,%s,%d,%s,%s",
                  d->descriptor, ip, mark_failed(ip), "create: bad password",
                  name);
    }
    return HOME;
  }
  if (DBTOP_MAX && (db_top >= DBTOP_MAX + 1) && (first_free == NOTHING)) {
    /* Oops, out of db space! */
    do_log(LT_CONN, 0, 0, "Failed creation (no db space) from %s", host);
    if (d) {
      queue_event(SYSEVENT, "SOCKET`CREATEFAIL", "%d,%s,%d,%s,%s",
                  d->descriptor, ip, mark_failed(ip),
                  "create: no db space left to create!", name);
    }
    return NOTHING;
  }
  /* else he doesn't already exist, create him */
  return make_player(name, password, host, ip);
}
Exemplo n.º 2
0
void gen_player_buffers(
    GLuint *position_buffer, GLuint *normal_buffer, GLuint *uv_buffer,
    float x, float y, float z, float rx, float ry)
{
    int faces = 6;
    glDeleteBuffers(1, position_buffer);
    glDeleteBuffers(1, normal_buffer);
    glDeleteBuffers(1, uv_buffer);
    GLfloat *position_data = malloc(sizeof(GLfloat) * faces * 18);
    GLfloat *normal_data = malloc(sizeof(GLfloat) * faces * 18);
    GLfloat *uv_data = malloc(sizeof(GLfloat) * faces * 12);
    make_player(
        position_data, normal_data, uv_data,
        x, y, z, rx, ry);
    *position_buffer = gen_buffer(
        GL_ARRAY_BUFFER,
        sizeof(GLfloat) * faces * 18,
        position_data
    );
    *normal_buffer = gen_buffer(
        GL_ARRAY_BUFFER,
        sizeof(GLfloat) * faces * 18,
        normal_data
    );
    *uv_buffer = gen_buffer(
        GL_ARRAY_BUFFER,
        sizeof(GLfloat) * faces * 12,
        uv_data
    );
    free(position_data);
    free(normal_data);
    free(uv_data);
}
Exemplo n.º 3
0
void init_outbreak(Outbreak * outbreak, SDL_Surface * screen) {
  outbreak->screen = screen;
  outbreak->player = make_player("Jeremy", INITIAL_PADDLE_X, INITIAL_PADDLE_Y, INITIAL_PADDLE_WIDTH, INITIAL_PADDLE_HEIGHT, resources.paddle_bmp);
  outbreak->ball = make_ball(INITIAL_BALL_X, INITIAL_BALL_Y, INITIAL_BALL_WIDTH, INITIAL_BALL_HEIGHT, resources.ball_bmp);
  outbreak->paused = FALSE;
  outbreak->quit = FALSE;

  magnetize_ball(outbreak->ball);

  outbreak->num_blocks = generate_level(outbreak->blocks, MAX_BLOCKS);
}
Exemplo n.º 4
0
void gen_player_buffers(
    GLuint *position_buffer, GLuint *normal_buffer, GLuint *uv_buffer,
    float x, float y, float z, float rx, float ry)
{
    GLfloat *position_data, *normal_data, *uv_data;
    malloc_buffers(3, 6, &position_data, &normal_data, &uv_data);
    make_player(
        position_data, normal_data, uv_data,
        x, y, z, rx, ry);
    gen_buffers(
        3, 6, position_data, normal_data, uv_data,
        position_buffer, normal_buffer, uv_buffer);
}
Exemplo n.º 5
0
struct game_t make_game(const int num_players, char names[][MAX_NAME_LEN], char types[],
    const int num_cards)
{
    int i;    
    struct game_t game;

    game.num_players = num_players;
    game.num_cards_each = num_cards;
    game.pile_size = 0; 
    game.deck_size = 0;
    game.burnt = 0;
    game.current_player = 0;
    game.miss_a_go = FALSE;

    for(i = 0; i<num_players; i++)
        game.players[i] = make_player(names[i], types[i]);
    
    return game;
}
Exemplo n.º 6
0
void battle_ground_make() {
	task_exec();
	objc_exec();
	obj_sync_something();
	//tilemaps_sync();
	switch (superstate.multipurpose_state_tracker) {
		case 0:
		{
			temp_vars.var_8001 = 0;
			/*// REG_DISPCNT setup
			REG_DISPCNT.mode = 2;
			REG_DISPCNT.GBC_mode = 0;
			REG_DISPCNT.frame_select = 0;
			REG_DISPCNT.hblank_oam_process = 0;
			REG_DISPCNT.sprite_tile_mapping = 0; //2d or 3d mapping
			REG_DISPCNT.screen_blank = 0;
			REG_DISPCNT.BG0_enable = 1;
			REG_DISPCNT.BG1_enable = 1;
			REG_DISPCNT.BG2_enable = 1;
			REG_DISPCNT.BG3_enable = 0;
			REG_DISPCNT.sprite_enable = 1;
			REG_DISPCNT.win0_enable = 0;
			REG_DISPCNT.win1_enable = 0;
			REG_DISPCNT.oam_win_enable = 0;
			temp_vars.var_8000 = *DISPCNT;
			
			// REG_BGCNT
				u8 i;
			for (i = 0; i < 4; i ++) {
				BG_CNT[i].priority = i;
				BG_CNT[i].char_index = i;
				BG_CNT[i].padding = 0;
				BG_CNT[i].mosiac = 0;
				BG_CNT[i].color = 0;
				BG_CNT[i].map_index = (0x1F - i);
				BG_CNT[i].screen_over = 0;
				BG_CNT[i].size = 0;
				
			}
			BG_CNT[1].color = 1;
			lcd_io_set(0x50, 0x2F00);
			lcd_io_set(0x52, 0x0F);*/
			test();
			superstate.multipurpose_state_tracker++;
			break;
		}
		case 1:
		{
			// load VRAM BG background
			u8 bg_config_data[16] = {0xF0, 0x11, 0x0, 0x0, 0xE5, 0x09, 0x0, 0x0, 0xDA, 0x21, 0x0, 0x0, 0xCF, 0x31, 0x0, 0x0};
			void bg_vram_setup(u8, u8 *, u8);
			// mode, setup, amount of bgs to config
			bg_vram_setup(0, (u8 *)&bg_config_data, 4);
			set_bg(0, (u8 *)sky_tiles, (u8 *)sky_map, (u8 *)sky_pal, 6, 32);
			set_bg(1, (u8 *)tree_tiles, (u8 *)tree_map, (u8 *)tree_pal, 0, 160);
			superstate.multipurpose_state_tracker++;
			break;
		}
		case 2:
		{
			// wtb better clouds
			task_add(sky_scroll, 0x1);
			superstate.multipurpose_state_tracker++;
			break;
		}
		case 3:
		{
			void gpu_bg_config_set_field(u8, u8, u8);
			gpu_bg_config_set_field(0, 5, 1);
			superstate.multipurpose_state_tracker++;
			break;
		}
		case 4:
		{
			make_player(0);
			make_opponent(0);
			superstate.multipurpose_state_tracker++;
			break;
		}
		case 5:
		{
			player_char_movement();
			break;
		}
		case 99:
		{
			// waitstate + next command buffer
			player_movement_buffer();
			break;
		}
		default:
			break;
	};


}
Exemplo n.º 7
0
static void test_is_not_computer(void)
{
    struct player_t human = make_player("Human", 'h');
    assert_false(human.is_computer);
}
Exemplo n.º 8
0
GLuint BufferUtils::genPlayerBuffer(float x, float y, float z, float rx, float ry)
{
    GLfloat *data = malloc_faces(10, 6);
    make_player(data, x, y, z, rx, ry);
    return gen_faces(10, 6, data);
}
Exemplo n.º 9
0
/** Attempt to register a new player at the connect screen.
 * If registration is allowed, a new player object is created with
 * a random password which is emailed to the registering player.
 * \param name name of player to register.
 * \param email email address to send registration details.
 * \param host host from which registration is being attempted.
 * \param ip ip address from which registration is being attempted.
 * \return dbref of created player or NOTHING if creation failed.
 */
dbref
email_register_player(DESC *d, const char *name, const char *email,
                      const char *host, const char *ip)
{
  char *p;
  char passwd[20];
  static char elems[] =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  int i, len;
  bool resend = 0;
  dbref player = NOTHING;
  FILE *fp;
  size_t NELEMS = sizeof(elems) - 1;
  char sbuff[260];

  if (!check_fails(ip)) {
    return NOTHING;
  }

  if (strlen(options.sendmail_prog) == 0)
    return NOTHING;

  if (!ok_player_name(name, NOTHING, NOTHING)) {
    /* Check for re-registration request */
    player = lookup_player(name);
    if (GoodObject(player)) {
      ATTR *a;
      a = atr_get(player, "LASTLOGOUT");
      if (!a) {
        a = atr_get(player, "REGISTERED_EMAIL");
        if (a && !strcasecmp(atr_value(a), email))
          resend = 1;
      }
    }
    if (!resend) {
      do_log(LT_CONN, 0, 0, "Failed registration (bad name) from %s", host);
      queue_event(SYSEVENT, "SOCKET`CREATEFAIL", "%d,%s,%d,%s,%s",
                  d->descriptor, ip, mark_failed(ip), "register: bad name",
                  name);
      return NOTHING;
    }
  }
  if (!resend) {
    /* Make sure that the email address is kind of valid. A valid
     * address must contain a @. Let the mailer sort it out beyond
     * that.  Also, to prevent someone from using the MUSH to mailbomb
     * another site, let's make sure that the site to which the user
     * wants the email sent is also allowed to use the register
     * command.  If there's an @, we check whatever's after the last @
     * (since @foo.bar:user@host is a valid email).
     */
    if ((p = strrchr(email, '@'))) {
      p++;
      if (!Site_Can_Register(p)) {
        if (!Deny_Silent_Site(p, AMBIGUOUS)) {
          do_log(LT_CONN, 0, 0,
                 "Failed registration (bad site in email: %s) from %s", email,
                 host);
          queue_event(SYSEVENT, "SOCKET`CREATEFAIL", "%d,%s,%d,%s,%s",
                      d->descriptor, ip, mark_failed(ip),
                      "register: bad site in email", name);
        }
        return NOTHING;
      }
    } else {
      if (!Deny_Silent_Site(host, AMBIGUOUS)) {
        do_log(LT_CONN, 0, 0, "Failed registration (bad email: %s) from %s",
               email, host);
        queue_event(SYSEVENT, "SOCKET`CREATEFAIL", "%d,%s,%d,%s,%s",
                    d->descriptor, ip, mark_failed(ip),
                    "register: sitelocked host", name);
      }
      return NOTHING;
    }

    if (DBTOP_MAX && (db_top >= DBTOP_MAX + 1) && (first_free == NOTHING)) {
      /* Oops, out of db space! */
      do_log(LT_CONN, 0, 0, "Failed registration (no db space) from %s", host);
      queue_event(SYSEVENT, "SOCKET`CREATEFAIL", "%d,%s,%d,%s,%s",
                  d->descriptor, ip, count_failed(ip),
                  "register: no db space left to create!", name);
      return NOTHING;
    }
  }

  /* Come up with a random password of length 7-12 chars */
  len = get_random_u32(7, 12);
  for (i = 0; i < len; i++)
    passwd[i] = elems[get_random_u32(0, NELEMS - 1)];
  passwd[len] = '\0';

  /* If we've made it here, we can send the email and create the
   * character. Email first, since that's more likely to go bad.
   * Some security precautions we'll take:
   *  1) We'll use sendmail -t, so we don't pass user-given values to a shell.
   *  2) We'll cross our fingers and hope nobody uses this to spam.
   */

  release_fd();
  snprintf(sbuff, sizeof sbuff, "%s -t", options.sendmail_prog);
  if ((fp = popen(sbuff, "w")) == NULL) {
    do_log(LT_CONN, 0, 0,
           "Failed registration of %s by %s: unable to open sendmail", name,
           email);
    queue_event(SYSEVENT, "SOCKET`CREATEFAIL", "%d,%s,%d,%s,%s,%d",
                d->descriptor, ip, count_failed(ip),
                "register: Unable to open sendmail!", name, 1);
    reserve_fd();
    return NOTHING;
  }
  fprintf(fp, "Subject: ");
  fprintf(fp, T("[%s] Registration of %s\n"), MUDNAME, name);
  fprintf(fp, "To: %s\n", email);
  fprintf(fp, "Precedence: junk\n");
  fprintf(fp, "\n");
  fprintf(fp, T("This is an automated message.\n"));
  fprintf(fp, "\n");
  fprintf(fp, T("Your requested player, %s, has been created.\n"), name);
  fprintf(fp, T("The password is %s\n"), passwd);
  fprintf(fp, "\n");
  fprintf(fp, T("To access this character, connect to %s and type:\n"),
          MUDNAME);
  fprintf(fp, "\tconnect \"%s\" %s\n", name, passwd);
  fprintf(fp, "\n");
  i = pclose(fp);
  reserve_fd();

  if (i != 0) {
    /* Mailer exited with an error code. Log it. */
    do_rawlog(
      LT_CONN,
      "When attempting to email a password to a newly registered player,\n"
      "\tthe mailer exited with error code %d.\n"
      "\t(Check /usr/include/sysexits.h if present for the meaning.)",
      i);
    queue_event(SYSEVENT, "SOCKET`CREATEFAIL", "%d,%s,%d,%s,%s,%d",
                d->descriptor, ip, count_failed(ip),
                "register: Unable to send email", name, i);
    return NOTHING;
  } else if (resend) {
    /* Reset the password */
    (void) atr_add(player, pword_attr, password_hash(passwd, NULL), GOD, 0);
    return player;
  } else {
    /* Ok, all's well, make a player */
    player = make_player(name, passwd, host, ip);
    queue_event(SYSEVENT, "PLAYER`CREATE", "%s,%s,%s,%d,%s",
                unparse_objid(player), name, "register", d->descriptor, email);
    (void) atr_add(player, "REGISTERED_EMAIL", email, GOD, 0);
    return player;
  }
}