Example #1
0
int command_unmark_special(char *text, int len, int do_log)
{
	int i;

	while (isspace(*text))
		text++;

	if(*text) {
		for (i = 0; i < max_mark; i ++)
		{
			if (my_strcompare(marks[i].text, text) && (marks[i].x != -1) && !marks[i].server_side)
			{
				char str[512];
				marks[i].x = marks[i].y = -1;
				if (do_log)
				{
					safe_snprintf(str, sizeof(str), unmarked_str, marks[i].text);
					LOG_TO_CONSOLE(c_orange1, str);
				}
				save_markings();
				load_map_marks(); // simply to compact the array and make room for new marks
				break;
			}
		}
	}
	return 1;
}
Example #2
0
//returns 1 if ignored, 0 if not ignored
int check_if_ignored (const char *name)
{
	int i;

	for (i = 0; i < MAX_IGNORES; i++)
	{
		if (ignore_list[i].used && my_strcompare(ignore_list[i].name, name))
			return 1;	// yep, ignored
	}
	return 0;	// nope
}
Example #3
0
File: parser.c Project: fave-r/RT
int	is_in_tab(char *str, t_flag tab[])
{
  int	i;

  i = 0;
  while (i < 6)
    {
      if (my_strcompare(tab[i].type, str))
	return (1);
      i++;
    }
  return (0);
}
Example #4
0
void fill_help_win ()
{
    int i;
    for(i=0; i<=numpage; i++)
    {
        if(my_strcompare(Page[i].Name,"HelpPage"))
            break;
    }
    helppage=i;
    set_window_handler (help_win, ELW_HANDLER_DISPLAY, &display_help_handler);
    set_window_handler (help_win, ELW_HANDLER_CLICK, &click_help_handler);

    help_menu_scroll_id = vscrollbar_add_extended(help_win, help_menu_scroll_id, NULL, help_menu_x_len-20, 0, 20, help_menu_y_len, 0, 1.0, newcol_r, newcol_g, newcol_b, 0, 30, Page[helppage].max_y);
}
Example #5
0
//returns -1 if the name is already ignored, 1 on sucess, -2 if no more ignore slots
int add_to_ignore_list(char *name, char save_name)
{
	int i;
	
	// never ignore uobeyuok, the rule bot
	if(!strcasecmp(name, "uobeyuok")){
		return(-1);
	}
	//see if this name is already on the list
	for(i=0;i<MAX_IGNORES;i++)
		{
			if(ignore_list[i].used)
				if(my_strcompare(ignore_list[i].name,name))return -1;//already in the list
		}

	//ok, find a free spot
	for(i=0;i<MAX_IGNORES;i++)
		{
			if(!ignore_list[i].used)
				{
					//excellent, a free spot
					my_strcp(ignore_list[i].name,name);
					//add to the global ignore file, if the case
					if(save_name)
						{
							FILE * f=open_file_config("local_ignores.txt", "a");
							if (f == NULL){
								LOG_ERROR("%s: %s \"local_ignores.txt\": %s\n", reg_error_str, cant_open_file, strerror(errno));
							} else {
								fwrite(name, strlen(name), 1, f);
								fwrite("\n", 1, 1, f);
								fclose(f);
							}
						}
					ignore_list[i].used=1;//mark as used
					ignored_so_far++;
					return 1;
				}
		}

	return -2;//if we are here, it means the ignores list is full
}
Example #6
0
File: parser.c Project: fave-r/RT
void		fill_list(char **tmp, t_flag tab[], t_obj *obj, t_spot *spot)
{
  static int	i = 0;

  i++;
  if (is_in_tab(tmp[0], tab) == 1)
    {
      check_obj(tmp, i);
      new_obj(tmp, obj);
    }
  else if (my_strcompare("SPOT", tmp[0]))
    {
      check_spot(tmp, i);
      new_spot(tmp, spot);
    }
  else
    {
      fprintf(stderr, "Unknown object line %d\n", i);
      exit(EXIT_FAILURE);
    }
}
Example #7
0
//returns -1 if the name is not filtered, 1 on sucess
int remove_from_filter_list (const char *name)
{
	int i;
	int local = 0;
	FILE *f = NULL;
	
	//see if this name is on the list
	for (i = 0; i < MAX_FILTERS; i++)
	{
		if (filter_list[i].len > 0)
		{
			if (my_strcompare (filter_list[i].name, name))
			{
				local = filter_list[i].local;
				filter_list[i].len = 0;
				filtered_so_far--;
				break;
			}
		}
	}
	
	if (local)
	{
		f = open_file_config ("local_filters.txt", "w");
		if (f == NULL){
			LOG_ERROR("%s: %s \"local_filters.txt\": %s\n", reg_error_str, cant_open_file, strerror(errno));
		} else {
			for (i = 0; i < MAX_FILTERS; i++)
			{
				if (filter_list[i].len > 0 && filter_list[i].local)
					fprintf (f, "%s = %s\n", filter_list[i].name, filter_list[i].replacement);
			}
			fclose(f);
		}
		return 1;
	}

	return -1;
}
Example #8
0
int command_unmark(char *text, int len)
{
	int i;

	while (isspace(*text))
		text++;

	if(*text) {
		for (i = 0; i < max_mark; i ++)
		{
			if (my_strcompare(marks[i].text, text) && (marks[i].x != -1) && !marks[i].server_side)
			{
				char str[512];
				marks[i].x = marks[i].y = -1;
				save_markings();
				safe_snprintf(str, sizeof(str), unmarked_str, marks[i].text);
				LOG_TO_CONSOLE(c_orange1, str);
				break;
			}
		}
	}
	return 1;
}
Example #9
0
//returns -1 if the name is already ignored, 1 on sucess
int remove_from_ignore_list(char *name)
{
	int i;
	int found = 0;
	FILE *f = NULL;
	//see if this name is on the list
	for(i=0;i<MAX_IGNORES;i++)
		{
			if(!found && ignore_list[i].used)
				if(my_strcompare(ignore_list[i].name,name))
					{
						ignore_list[i].used=0;
						found = 1;
						ignored_so_far--;
					}
		}
	if(found)
		{
			f=open_file_config("local_ignores.txt", "w");
			if (f == NULL){
				LOG_ERROR("%s: %s \"local_ignores.txt\": %s\n", reg_error_str, cant_open_file, strerror(errno));
			} else {
				for(i=0;i<MAX_IGNORES;i++)
				{
					if(ignore_list[i].used)
						{
							fwrite(ignore_list[i].name, strlen(ignore_list[i].name), 1, f);
							fwrite("\n", 1, 1, f);
						}
				}
				fclose(f);
			}
			return 1;
		}
	else
		return -1;
}
Example #10
0
/* display or test the md5sum of the current map or the specified file */
int command_ckdata(char *text, int len)
{
	const int DIGEST_LEN = 16;
	Uint8 digest[DIGEST_LEN];
	char digest_str[DIGEST_LEN*2+1];
	char expected_digest_str[DIGEST_LEN*2+1];
	char result_str[256];
	char filename[256];

	/* paramters are optional, first is expected checksum value, second is filename */
	/* if only a filename is specfied, we display checksum rather than do match */
	filename[0] = digest_str[0] = expected_digest_str[0] = '\0';
	text = getparams(text);
	if (*text)
	{
		/* if we have at least one space and the first string is of digest length, assume we matching */
		char *tempstr = safe_strcasestr(text, strlen(text), " ", 1);
		if ((tempstr != NULL) && (strlen(text) - strlen(tempstr) == DIGEST_LEN*2))
		{
			safe_strncpy2(expected_digest_str, text, DIGEST_LEN*2+1, DIGEST_LEN*2 );
			/* trim leading space from filename */
			while (*tempstr == ' ')
				tempstr++;
			if (*tempstr)
				safe_strncpy(filename, tempstr, 256);
		}
		/* else we only have a filename */
		else
			safe_strncpy(filename, text, 256 );
	}
	/* if no parameters default to current map elm file */
	else
		safe_strncpy(filename, continent_maps[cur_map].name, 256 );

	/* calculate, display checksum if we're not matching */
	if (*filename && el_file_exists(filename) && get_file_digest(filename, digest))
	{
		int i;	
		for(i=0; i<DIGEST_LEN; i++)
			sprintf(&digest_str[2*i], "%02x", (int)digest[i]);
		digest_str[DIGEST_LEN*2] = 0;
		if (! *expected_digest_str)
		{
			safe_snprintf(result_str, sizeof(result_str), "#ckdata %s %s", digest_str, filename );
			LOG_TO_CONSOLE(c_grey1,result_str);
		}
	}
	/* show help if something fails */
	else
	{
		LOG_TO_CONSOLE(c_red2, "ckdata: invalid file or command syntax.");
		LOG_TO_CONSOLE(c_red1, "Show current map (elm): #ckdata");
		LOG_TO_CONSOLE(c_red1, "Show specified file:    #ckdata file_name");
		LOG_TO_CONSOLE(c_red1, "Check specified file:   #ckdata expected_checksum file_name");
		return 1;
	}

	/* if we have an expected value, compare then display an appropriate message */
	if (*expected_digest_str)
	{
		if (my_strcompare(digest_str, expected_digest_str))
			LOG_TO_CONSOLE(c_green2,"ckdata: File matches expected checksum");
		else
			LOG_TO_CONSOLE(c_red2,"ckdata: File does not match expected checksum");
	}
	
	return 1;
	
} /* end command_ckdata() */
Example #11
0
void add_enhanced_actor_from_server(char * in_data)
{
	short actor_id;
	short x_pos;
	short y_pos;
	short z_pos;
	short z_rot;
	short max_health;
	short cur_health;
	Uint8 actor_type;
	Uint8 skin;
	Uint8 hair;
	Uint8 shirt;
	Uint8 pants;
	Uint8 boots;
	Uint8 frame;
	Uint8 cape;
	Uint8 head;
	Uint8 shield;
	Uint8 weapon;
	Uint8 helmet;
	int i;
	int dead=0;
	int kind_of_actor;
	enhanced_actor *this_actor;

	char cur_frame[20];
	double f_x_pos,f_y_pos,f_z_pos,f_z_rot;

	actor_id=*((short *)(in_data));
	x_pos=*((short *)(in_data+2));
	y_pos=*((short *)(in_data+4));
	z_pos=*((short *)(in_data+6));
	z_rot=*((short *)(in_data+8));
	actor_type=*(in_data+10);
	skin=*(in_data+12);
	hair=*(in_data+13);
	shirt=*(in_data+14);
	pants=*(in_data+15);
	boots=*(in_data+16);
	head=*(in_data+17);
	shield=*(in_data+18);
	weapon=*(in_data+19);
	cape=*(in_data+20);
	helmet=*(in_data+21);

	frame=*(in_data+22);
	max_health=*((short *)(in_data+23));
	cur_health=*((short *)(in_data+25));
	kind_of_actor=*(in_data+27);

	//translate from tile to world
	f_x_pos=x_pos*0.5;
	f_y_pos=y_pos*0.5;
	f_z_pos=z_pos;
	f_z_rot=z_rot;

	//get the current frame
	switch(frame) {
	case frame_walk:
		my_strcp(cur_frame,actors_defs[actor_type].walk_frame);break;
	case frame_run:
		my_strcp(cur_frame,actors_defs[actor_type].run_frame);break;
	case frame_die1:
		my_strcp(cur_frame,actors_defs[actor_type].die1_frame);
		dead=1;
		break;
	case frame_die2:
		my_strcp(cur_frame,actors_defs[actor_type].die2_frame);
		dead=1;
		break;
	case frame_pain1:
		my_strcp(cur_frame,actors_defs[actor_type].pain1_frame);break;
	case frame_pain2:
		my_strcp(cur_frame,actors_defs[actor_type].pain2_frame);break;
	case frame_pick:
		my_strcp(cur_frame,actors_defs[actor_type].pick_frame);break;
	case frame_drop:
		my_strcp(cur_frame,actors_defs[actor_type].drop_frame);break;
	case frame_idle:
		my_strcp(cur_frame,actors_defs[actor_type].idle_frame);break;
	case frame_sit_idle:
		my_strcp(cur_frame,actors_defs[actor_type].idle_sit_frame);break;
	case frame_harvest:
		my_strcp(cur_frame,actors_defs[actor_type].harvest_frame);break;
	case frame_cast:
		my_strcp(cur_frame,actors_defs[actor_type].attack_cast_frame);break;
	case frame_attack_up_1:
		my_strcp(cur_frame,actors_defs[actor_type].attack_up_1_frame);break;
	case frame_attack_up_2:
		my_strcp(cur_frame,actors_defs[actor_type].attack_up_2_frame);break;
	case frame_attack_up_3:
		my_strcp(cur_frame,actors_defs[actor_type].attack_up_3_frame);break;
	case frame_attack_up_4:
		my_strcp(cur_frame,actors_defs[actor_type].attack_up_4_frame);break;
	case frame_attack_down_1:
		my_strcp(cur_frame,actors_defs[actor_type].attack_down_1_frame);break;
	case frame_attack_down_2:
		my_strcp(cur_frame,actors_defs[actor_type].attack_down_2_frame);break;
	case frame_combat_idle:
		my_strcp(cur_frame,actors_defs[actor_type].combat_idle_frame);break;
	default:
		{
		}
	}

	//find out if there is another actor with that ID
	//ideally this shouldn't happen, but just in case
	for(i=0;i<max_actors;i++)
		{
			if(actors_list[i])
				{
					if(actors_list[i]->actor_id==actor_id)
						{
							char str[256];
							sprintf(str,"%s %d = %s => %s\n",duplicate_actors_str,actor_id, actors_list[i]->actor_name ,&in_data[28]);
							log_error(str);
							destroy_actor(actors_list[i]->actor_id);//we don't want two actors with the same ID
							i--;// last actor was put here, he needs to be checked too
						}
					else if(kind_of_actor==COMPUTER_CONTROLLED_HUMAN && (actors_list[i]->kind_of_actor==COMPUTER_CONTROLLED_HUMAN || actors_list[i]->kind_of_actor==PKABLE_COMPUTER_CONTROLLED) && !my_strcompare(&in_data[28], actors_list[i]->actor_name))
						{
							char str[256];
							sprintf(str,"%s(%d) = %s => %s\n",duplicate_npc_actor,actor_id, actors_list[i]->actor_name ,&in_data[28]);
							log_error(str);
							destroy_actor(actors_list[i]->actor_id);//we don't want two actors with the same ID
							i--;// last actor was put here, he needs to be checked too
						}
				}
		}

	this_actor=calloc(1,sizeof(enhanced_actor));

	//get the torso
	my_strcp(this_actor->arms_tex,actors_defs[actor_type].shirt[shirt].arms_name);
	my_strcp(this_actor->torso_tex,actors_defs[actor_type].shirt[shirt].torso_name);
	my_strcp(this_actor->torso_fn,actors_defs[actor_type].shirt[shirt].model_name);
	//skin
	my_strcp(this_actor->hands_tex,actors_defs[actor_type].skin[skin].hands_name);
	my_strcp(this_actor->hands_tex_save,actors_defs[actor_type].skin[skin].hands_name);
	my_strcp(this_actor->head_tex,actors_defs[actor_type].skin[skin].head_name);
	//hair
	my_strcp(this_actor->hair_tex,actors_defs[actor_type].hair[hair].hair_name);
	//boots
	my_strcp(this_actor->boots_tex,actors_defs[actor_type].boots[boots].boots_name);
	//legs
	my_strcp(this_actor->pants_tex,actors_defs[actor_type].legs[pants].legs_name);
	my_strcp(this_actor->legs_fn,actors_defs[actor_type].legs[pants].model_name);
	//cape
	if(cape!=CAPE_NONE)
		{
			my_strcp(this_actor->cape_tex,actors_defs[actor_type].cape[cape].skin_name);
			my_strcp(this_actor->cape_fn,actors_defs[actor_type].cape[cape].model_name);
		}
	else
		{
			my_strcp(this_actor->cape_tex,"");
			my_strcp(this_actor->cape_fn,"");
		}
	//head
	my_strcp(this_actor->head_fn,actors_defs[actor_type].head[head].model_name);

	//shield
	if(shield!=SHIELD_NONE)
		{
			my_strcp(this_actor->shield_tex,actors_defs[actor_type].shield[shield].skin_name);
			my_strcp(this_actor->shield_fn,actors_defs[actor_type].shield[shield].model_name);
		}
	else
		{
			my_strcp(this_actor->shield_tex,"");
			my_strcp(this_actor->shield_fn,"");
		}

	my_strcp(this_actor->weapon_tex,actors_defs[actor_type].weapon[weapon].skin_name);
	my_strcp(this_actor->weapon_fn,actors_defs[actor_type].weapon[weapon].model_name);
	this_actor->weapon_glow=actors_defs[actor_type].weapon[weapon].glow;
	if(weapon == GLOVE_FUR || weapon == GLOVE_LEATHER){
		my_strcp(this_actor->hands_tex, actors_defs[actor_type].weapon[weapon].skin_name);
	}

	//helmet
	if(helmet!=HELMET_NONE)
		{
			my_strcp(this_actor->helmet_tex,actors_defs[actor_type].helmet[helmet].skin_name);
			my_strcp(this_actor->helmet_fn,actors_defs[actor_type].helmet[helmet].model_name);
		}
	else
		{
			my_strcp(this_actor->helmet_tex,"");
			my_strcp(this_actor->helmet_fn,"");
		}

	i=add_enhanced_actor(this_actor,cur_frame,f_x_pos,f_y_pos,f_z_pos,f_z_rot,actor_id);

	actors_list[i]->x_tile_pos=x_pos;
	actors_list[i]->y_tile_pos=y_pos;
	actors_list[i]->actor_type=actor_type;
	actors_list[i]->damage=0;
	actors_list[i]->damage_ms=0;
	actors_list[i]->sitting=0;
	actors_list[i]->fighting=0;
	//test only
	actors_list[i]->max_health=max_health;
	actors_list[i]->cur_health=cur_health;
	if(frame==frame_sit_idle)
		{
			if(actors_list[i]->actor_id==yourself)you_sit_down();
			actors_list[i]->sitting=1;
		}
	else if(frame==frame_combat_idle)
		actors_list[i]->fighting=1;

	//ghost or not?
	actors_list[i]->ghost=0;

	actors_list[i]->dead=dead;
	actors_list[i]->stop_animation=1;//helps when the actor is dead...
	actors_list[i]->cur_weapon=weapon;
	actors_list[i]->kind_of_actor=kind_of_actor;
	if(strlen(&in_data[28]) >= 30)
		{
			char str[120];
			snprintf(str, 120, "%s (%d): %s/%d\n", bad_actor_name_length, actors_list[i]->actor_type,&in_data[28], (int)strlen(&in_data[28]));
			log_error(str);
			return;
		}

	my_strncp(actors_list[i]->actor_name,&in_data[28],30);
	if(caps_filter && my_isupper(actors_list[i]->actor_name, -1)) my_tolower(actors_list[i]->actor_name);
	unlock_actors_lists();  //unlock it

}
Example #12
0
//returns -1 if the name is already filtered, 1 on sucess, -2 if no more filter slots
int add_to_filter_list (const char *name, char local, char save_name)
{
	int i, j;
	char left[256];
	char right[256];
	int t, tp;
	int l=0;

	//ok, find a free spot
	for (i = 0; i < MAX_FILTERS; i++)
	{
		if (filter_list[i].len <= 0)
		{
			// excellent, a free spot
			safe_strncpy (left, name, sizeof(left));
			for (t = 0; ; t++)
			{
				if (left[t] == '\0')
				{
					safe_strncpy (right, "smeg", sizeof(right));
					break;
				}
				if(left[t]=='=')
				{
					left[t] = '\0';
					tp = t - 1;
					for (tp = t-1; tp >= 0 && isspace (left[tp]); tp--)
					{
						left[tp] = '\0';
					}
					for (tp = t + 1; left[tp] != '\0' && !(left[tp]&0x80) && isspace(left[tp]); tp++) ;
					safe_strncpy (right, &left[tp], sizeof(right));
					break;
				}
			}
			// See if this name is already on the list
			for (j = 0; j < MAX_FILTERS; j++)
			{
				if (filter_list[j].len > 0)
				{
					if (my_strcompare (filter_list[j].name, left))
						return -1; // Already in the list
				}
			}
			// add to the local filter file, if the case
			if (save_name)
			{
				FILE *f = open_file_config("local_filters.txt", "a");
				if (f == NULL){
					LOG_ERROR("%s: %s \"local_filters.txt\": %s\n", reg_error_str, cant_open_file, strerror(errno));
				} else {
					fprintf (f, "%s = %s\n", left, right);
					fclose(f);
				}
			}
			left[sizeof(filter_list[i].name)-1] = '\0';
			right[sizeof(filter_list[i].replacement)-1] = '\0';
			filter_list[i].wildcard_type = 0;
			l = strlen (left) - 1;
			if (left[0] == '*' && left[l] != '*') filter_list[i].wildcard_type = 1;
			if (left[0] != '*' && left[l] == '*') filter_list[i].wildcard_type = 2;
			if (left[0] == '*' && left[l] == '*') filter_list[i].wildcard_type = 3;
			my_strcp (filter_list[i].name, left);
			my_strcp (filter_list[i].replacement, right);
			filter_list[i].len = strlen(filter_list[i].name);//memorize the length
			filter_list[i].rlen = strlen(filter_list[i].replacement);//memorize the length
			filter_list[i].local = local;

			filtered_so_far++;
			return 1;
		}
	}

	return -2;//if we are here, it means the filters list is full
}