int read_mercenarydb(void)
{
	FILE *fp;
	char line[1024], *p;
	char *str[26];
	int i, j = 0, k = 0, ele;
	struct s_mercenary_db *db;
	struct status_data *status;

	sprintf(line, "%s/%s", db_path, "mercenary_db.txt");
	memset(mercenary_db,0,sizeof(mercenary_db));

	fp = fopen(line, "r");
	if( !fp )
	{
		ShowError("read_mercenarydb : can't read mercenary_db.txt\n");
		return -1;
	}

	while( fgets(line, sizeof(line), fp) && j < MAX_MERCENARY_CLASS )
	{
		k++;
		if( line[0] == '/' && line[1] == '/' )
			continue;

		i = 0;
		p = strtok(line, ",");
		while( p != NULL && i < 26 )
		{
			str[i++] = p;
			p = strtok(NULL, ",");
		}
		if( i < 26 )
		{
			ShowError("read_mercenarydb : Incorrect number of columns at mercenary_db.txt line %d.\n", k);
			continue;
		}

		db = &mercenary_db[j];
		db->class_ = atoi(str[0]);
		strncpy(db->sprite, str[1], NAME_LENGTH);
		strncpy(db->name, str[2], NAME_LENGTH);
		db->lv = atoi(str[3]);

		status = &db->status;
		db->vd.class_ = db->class_;

		status->max_hp = atoi(str[4]);
		status->max_sp = atoi(str[5]);
		status->rhw.range = atoi(str[6]);
		status->rhw.atk = atoi(str[7]);
		status->rhw.atk2 = status->rhw.atk + atoi(str[8]);
		status->def = atoi(str[9]);
		status->mdef = atoi(str[10]);
		status->str = atoi(str[11]);
		status->agi = atoi(str[12]);
		status->vit = atoi(str[13]);
		status->int_ = atoi(str[14]);
		status->dex = atoi(str[15]);
		status->luk = atoi(str[16]);
		db->range2 = atoi(str[17]);
		db->range3 = atoi(str[18]);
		status->size = atoi(str[19]);
		status->race = atoi(str[20]);
	
		ele = atoi(str[21]);
		status->def_ele = ele%10;
		status->ele_lv = ele/20;
		if( status->def_ele >= ELE_MAX )
		{
			ShowWarning("Mercenary %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1);
			status->def_ele = ELE_NEUTRAL;
		}
		if( status->ele_lv < 1 || status->ele_lv > 4 )
		{
			ShowWarning("Mercenary %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv);
			status->ele_lv = 1;
		}

		status->aspd_rate = 1000;
		status->speed = atoi(str[22]);
		status->adelay = atoi(str[23]);
		status->amotion = atoi(str[24]);
		status->dmotion = atoi(str[25]);

		j++;
	}

	fclose(fp);
	ShowStatus("'"CL_WHITE"db/mercenary_db.txt"CL_RESET"' 에서 '"CL_WHITE"%d"CL_RESET"' 개의 자료를 읽었습니다.\n", j);

	return 0;
}
Exemple #2
0
  /// This virtual method really needs to be overwritten in a derived
  /// class.
  ObjectList CbirRandom::CbirRound(CbirAlgorithm::QueryData *qd,
				    const ObjectList& seen,
				    size_t maxq) const {
    string hdr = "CbirRandom::CbirRound() : ";

    bool do_debug = debug_stages || debug;

    CbirRandom::QueryData *qde = CastData(qd);

    // This is called only for CbirAlgorithm::CbirRound()'s logging ability
    // it will return an empty list which is NOT an indication of a failure
    CbirAlgorithm::CbirRound(qde, seen, maxq);

    if (do_debug)
      cout << TimeStamp()
	   << hdr << "starting with " << seen.size() << " object already seen"
	   << endl;

    const Query::algorithm_data *lower
      = GetQuery(qd)->LowerAlgorithm(qd, 0, false);

    set<size_t> lowerset;
    if (lower) {
      for (size_t i=0; i<lower->result.size(); i++)
	if (lower->result[i].Retained())
	  lowerset.insert(lower->result[i].Index());

      if (do_debug)
	cout << TimeStamp() << hdr << "lower algorithm [" << lower->fullname
	     << "] returns " << lowerset.size() << "/" << lower->result.size()
	     << " objects" << endl;
    }

    size_t nobj = qde->GetMaxQuestions(maxq), nobjeff = nobj-lowerset.size();

    if (nobj<lowerset.size()) {
      ShowError(hdr+"nobj<lowerset.size()");
      nobjeff = 0;
    }

    // This simple algorithm just returns nobj number of yet unseen
    // objects.  The objects need to be of the same target_type as
    // requested by the Query object.

    ObjectList list;
    if (lower)
      for (size_t i=0; i<lower->result.size(); i++)
	if (lower->result[i].Retained())
	  list.push_back(Object(database, lower->result[i].Index(),
				select_question));

    stringstream nobjstrss;
    nobjstrss << nobj << "-" << lowerset.size() << "=" << nobjeff;
    string nobjstr = nobjstrss.str();
      
    bool old_and_slow = database->Size()<4000000;

    if (old_and_slow) {
      vector<size_t> idx;
      for (size_t i=0; i<database->Size(); i++)
	if (database->ObjectsTargetTypeContains(i, GetQuery(qde)->Target()) &&
	    GetQuery(qde)->CanBeShownRestricted(i, true) &&
	    (lowerset.empty() || lowerset.find(i)==lowerset.end()))
	  idx.push_back(i);

      if (do_debug)
	cout << TimeStamp()
	     << hdr << "selecting " << nobjstr << " random objects of type \""
	     << TargetTypeString(GetQuery(qde)->Target()) << "\" out of "
	     << idx.size() << " unseen&unselected ones with seed "
	     << qde->seed << endl;

      RandVar rndvar(qde->seed);
      while (!idx.empty() && (nobj==0 || list.size()<nobj)) {
	size_t rnd = (size_t)rndvar.RandomInt(idx.size());
	list.push_back(Object(database, idx[rnd], select_question));
	idx.erase(idx.begin()+rnd);
      }

    } else {
      if (do_debug)
	cout << TimeStamp()
	     << hdr << "selecting " << nobjstr << " random objects of type \""
	     << TargetTypeString(GetQuery(qde)->Target()) << "\" out of "
	     << "UNKNOWN NUMBER OF" << " unseen&unselected ones with seed "
	     << qde->seed << endl;

       RandVar rndvar(qde->seed);
       while (list.size()<nobj) {
	 size_t i = (size_t)rndvar.RandomInt(database->Size());
	 if (database->ObjectsTargetTypeContains(i, GetQuery(qde)->Target()) &&
	     GetQuery(qde)->CanBeShownRestricted(i, true) &&
	     (lowerset.empty() || lowerset.find(i)==lowerset.end()))
	   list.push_back(Object(database, i, select_question));
       }
    }

    if (do_debug||debug_lists)
      cout << TimeStamp()
	   << hdr << "returning " << list.size() << " objects" << endl;

    return list;
  }
Exemple #3
0
void _mfree(void *ptr, const char *file, int line, const char *func )
{
	struct unit_head *head;

	if (ptr == NULL)
		return;

	head = (struct unit_head *)((char *)ptr - sizeof(struct unit_head) + sizeof(long));
	if(head->size == 0) {
		/* malloc() で直に確保された領域 */
		struct unit_head_large *head_large = (struct unit_head_large *)((char *)ptr - sizeof(struct unit_head_large) + sizeof(long));
		if(
			*(long*)((char*)head_large + sizeof(struct unit_head_large) - sizeof(long) + head_large->size)
			!= 0xdeadbeaf)
		{
			ShowError("Memory manager: args of aFree 0x%p is overflowed pointer %s line %d\n", ptr, file, line);
		} else {
			head->size = -1;
			if(head_large->prev) {
				head_large->prev->next = head_large->next;
			} else {
				unit_head_large_first  = head_large->next;
			}
			if(head_large->next) {
				head_large->next->prev = head_large->prev;
			}
			memmgr_usage_bytes -= head_large->size;
#ifdef DEBUG_MEMMGR
			// set freed memory to 0xfd
			memset(ptr, 0xfd, head_large->size);
#endif
			FREE(head_large,file,line,func);
		}
	} else {
		/* ユニット解放 */
		struct block *block = head->block;
		if( (char*)head - (char*)block > sizeof(struct block) ) {
			ShowError("Memory manager: args of aFree 0x%p is invalid pointer %s line %d\n", ptr, file, line);
		} else if(head->block == NULL) {
			ShowError("Memory manager: args of aFree 0x%p is freed pointer %s:%d@%s\n", ptr, file, line, func);
		} else if(*(long*)((char*)head + sizeof(struct unit_head) - sizeof(long) + head->size) != 0xdeadbeaf) {
			ShowError("Memory manager: args of aFree 0x%p is overflowed pointer %s line %d\n", ptr, file, line);
		} else {
			memmgr_usage_bytes -= head->size;
			head->block         = NULL;
#ifdef DEBUG_MEMMGR
			memset(ptr, 0xfd, block->unit_size - sizeof(struct unit_head) + sizeof(long) );
			head->file = file;
			head->line = line;
#endif
			memmgr_assert( block->unit_used > 0 );
			if(--block->unit_used == 0) {
				/* ブロックの解放 */
				block_free(block);
			} else {
				if( block->unfill_prev == NULL) {
					// unfill リストに追加
					if( hash_unfill[ block->unit_hash ] ) {
						hash_unfill[ block->unit_hash ]->unfill_prev = block;
					}
					block->unfill_prev = &block_head;
					block->unfill_next = hash_unfill[ block->unit_hash ];
					hash_unfill[ block->unit_hash ] = block;
				}
				head->size     = block->unit_unfill;
				block->unit_unfill = (unsigned short)(((uintptr_t)head - (uintptr_t)block->data) / block->unit_size);
			}
		}
	}
}
Exemple #4
0
// Wisp/page request to send
int mapif_parse_WisRequest(int fd)
{
	struct WisData* wd;
	static int wisid = 0;
	char name[NAME_LENGTH];
	char esc_name[NAME_LENGTH*2+1];// escaped name
	char* data;
	size_t len;


	if ( fd <= 0 ) {return 0;} // check if we have a valid fd

	if (RFIFOW(fd,2)-52 >= sizeof(wd->msg)) {
		ShowWarning("inter: Wis message size too long.\n");
		return 0;
	} else if (RFIFOW(fd,2)-52 <= 0) { // normaly, impossible, but who knows...
		ShowError("inter: Wis message doesn't exist.\n");
		return 0;
	}
	
	safestrncpy(name, (char*)RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex]

	Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) )
		Sql_ShowDebug(sql_handle);

	// search if character exists before to ask all map-servers
	if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
	{
		unsigned char buf[27];
		WBUFW(buf, 0) = 0x3802;
		memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
		WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
		mapif_send(fd, buf, 27);
	}
	else
	{// Character exists. So, ask all map-servers
		// to be sure of the correct name, rewrite it
		Sql_GetData(sql_handle, 0, &data, &len);
		memset(name, 0, NAME_LENGTH);
		memcpy(name, data, min(len, NAME_LENGTH));
		// if source is destination, don't ask other servers.
		if( strncmp((const char*)RFIFOP(fd,4), name, NAME_LENGTH) == 0 )
		{
			uint8 buf[27];
			WBUFW(buf, 0) = 0x3802;
			memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
			WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
			mapif_send(fd, buf, 27);
		}
		else
		{

			CREATE(wd, struct WisData, 1);

			// Whether the failure of previous wisp/page transmission (timeout)
			check_ttl_wisdata();

			wd->id = ++wisid;
			wd->fd = fd;
			wd->len= RFIFOW(fd,2)-52;
			memcpy(wd->src, RFIFOP(fd, 4), NAME_LENGTH);
			memcpy(wd->dst, RFIFOP(fd,28), NAME_LENGTH);
			memcpy(wd->msg, RFIFOP(fd,52), wd->len);
			wd->tick = gettick();
			idb_put(wis_db, wd->id, wd);
			mapif_wis_message(wd);
		}
	}

	Sql_FreeResult(sql_handle);
	return 0;
}
Exemple #5
0
	int sig_init() {
		ShowError("sig: This plugin is not supported - Enable 'exchndl' instead!\n");
		return 0;
	}
Exemple #6
0
/**
 * Loads quests from the quest db.
 * @return Number of loaded quests, or -1 if the file couldn't be read.
 */
int quest_read_db(void)
{
	const char* dbsubpath[] = {
		"",
		DBIMPORT"/",
	};
	int f;

	for (f = 0; f < ARRAYLENGTH(dbsubpath); f++) {
		FILE *fp;
		char line[1024];
		int i, count = 0;
		char *str[20], *p, *np;
		char filename[256];
		struct quest_db entry;

		sprintf(filename, "%s/%s%s", db_path, dbsubpath[f], "quest_db.txt");
		if( (fp = fopen(filename, "r")) == NULL ) {
			if (f == 0)
				ShowError("Can't read %s\n", filename);

			return -1;
		}

		while( fgets(line, sizeof(line), fp) ) {
			if( line[0] == '/' && line[1] == '/' )
				continue;

			memset(str, 0, sizeof(str));

			for( i = 0, p = line; i < 8; i++ ) {
				if( (np = strchr(p, ',')) != NULL ) {
					str[i] = p;
					*np = 0;
					p = np + 1;
				} else if( str[0] == NULL )
					break;
				else {
					ShowError("quest_read_db: Insufficient columns in line %s\n", line);
					continue;
				}
			}

			if( str[0] == NULL )
				continue;

			memset(&entry, 0, sizeof(entry));

			entry.id = atoi(str[0]);

			if( entry.id < 0 || entry.id >= MAX_QUEST_DB ) {
				ShowError("quest_read_db: Invalid quest ID '%d' in line '%s' (min: 0, max: %d.)\n", entry.id, line, MAX_QUEST_DB);
				continue;
			}

			entry.time = atoi(str[1]);

			for( i = 0; i < MAX_QUEST_OBJECTIVES; i++ ) {
				entry.mob[i] = atoi(str[2 * i + 2]);
				entry.count[i] = atoi(str[2 * i + 3]);

				if( !entry.mob[i] || !entry.count[i] )
					break;
			}

			entry.num_objectives = i;

			if( quest_db_data[entry.id] == NULL )
				quest_db_data[entry.id] = aMalloc(sizeof(struct quest_db));

			memcpy(quest_db_data[entry.id], &entry, sizeof(struct quest_db));
			count++;
		}

		fclose(fp);
		ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
	}

	return 0;
}
Exemple #7
0
int32 map_config_read(const int8* cfgName)
{
	int8 line[1024], w1[1024], w2[1024];
	FILE* fp;

	fp = fopen(cfgName,"r");
	if( fp == NULL )
	{
		ShowError("Map configuration file not found at: %s\n", cfgName);
		return 1;
	}

	while( fgets(line, sizeof(line), fp) )
	{
		int8* ptr;

        if( line[0] == '#' )
			continue;
		if( sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2 )
			continue;

		//Strip trailing spaces
		ptr = w2 + strlen(w2);
		while (--ptr >= w2 && *ptr == ' ');
		ptr++;
		*ptr = '\0';

		if(strcmpi(w1,"timestamp_format") == 0)
		{
			strncpy(timestamp_format, w2, 20);
		}
		else if(strcmpi(w1,"stdout_with_ansisequence") == 0)
		{
			stdout_with_ansisequence = config_switch(w2);
		}
		else if(strcmpi(w1,"console_silent") == 0)
		{
			ShowInfo("Console Silent Setting: %d", atoi(w2));
			msg_silent = atoi(w2);
		}
		else if (strcmpi(w1,"map_port") == 0)
		{
			map_config.usMapPort = (atoi(w2));
		}
		else if (strcmp(w1,"buff_maxsize") == 0)
		{
			map_config.buffer_size = atoi(w2);
		}
		else if (strcmp(w1,"max_time_lastupdate") == 0)
		{
			map_config.max_time_lastupdate = atoi(w2);
		}
        else if (strcmp(w1,"vanadiel_time_offset") == 0)
        {
            map_config.vanadiel_time_offset = atoi(w2);
        }
        else if (strcmp(w1,"lightluggage_block") == 0)
        {
            map_config.lightluggage_block = atoi(w2);
        }
        else if (strcmp(w1,"exp_rate") == 0)
        {
            map_config.exp_rate = atof(w2);
        }
        else if (strcmp(w1,"exp_loss_rate") == 0)
        {
            map_config.exp_loss_rate = atof(w2);
        }
		else if (strcmp(w1,"thf_in_party_for_drops") == 0)
        {
            map_config.thf_in_party_for_drops = atof(w2);
        }
		else if (strcmp(w1,"exp_party_gap_penalties") == 0)
        {
            map_config.exp_party_gap_penalties = atof(w2);
        }
		else if (strcmp(w1,"fov_party_gap_penalties") == 0)
        {
            map_config.fov_party_gap_penalties = atof(w2);
        }
		else if (strcmp(w1,"fov_allow_alliance") == 0)
        {
            map_config.fov_allow_alliance = atof(w2);
        }
		else if (strcmp(w1,"mob_tp_multiplier") == 0)
        {
            map_config.mob_tp_multiplier = atof(w2);
        }
		else if (strcmp(w1,"player_tp_multiplier") == 0)
        {
            map_config.player_tp_multiplier = atof(w2);
        }
		else if (strcmp(w1,"exp_retain") == 0)
        {
            map_config.exp_retain = dsp_cap(atof(w2), 0.0f, 1.0f);
        }
		else if (strcmp(w1,"exp_loss_level") == 0)
		{
			map_config.exp_loss_level = atoi(w2);
		}
		else if (strcmp(w1,"level_sync_enable") == 0)
		{
			map_config.level_sync_enable = atoi(w2);
        }
		else if (strcmp(w1,"speed_mod") == 0)
		{
			map_config.speed_mod = atoi(w2);
		}
		else if (strcmp(w1,"skillup_multiplier") == 0)
        {
            map_config.skillup_multiplier = atof(w2);
        }
		else if (strcmp(w1,"craft_multiplier") == 0)
        {
            map_config.craft_multiplier = atof(w2);
        }
		else if (strcmp(w1,"mysql_host") == 0)
		{
			map_config.mysql_host = aStrdup(w2);
		}
		else if (strcmp(w1,"mysql_login") == 0)
		{
			map_config.mysql_login = aStrdup(w2);
		}
		else if (strcmp(w1,"mysql_password") == 0)
		{
			map_config.mysql_password = aStrdup(w2);
		}
		else if (strcmp(w1,"mysql_port") == 0)
		{
			map_config.mysql_port = atoi(w2);
		}
		else if (strcmp(w1,"mysql_database") == 0)
		{
			map_config.mysql_database = aStrdup(w2);
		}
		else if (strcmpi(w1,"import") == 0)
		{
			map_config_read(w2);
		}
        else if(strcmpi(w1,"newstyle_skillups") == 0)
        {
            map_config.newstyle_skillups = atoi(w2);
        }
		else if (strcmp(w1,"max_merit_points") == 0)
		{
			map_config.max_merit_points = atoi(w2);
		}
		else if (strcmp(w1,"audit_chat") == 0)
		{
			map_config.audit_chat = atoi(w2);
		}
		else if (strcmp(w1,"audit_say") == 0)
		{
			map_config.audit_say = atoi(w2);
		}
		else if (strcmp(w1,"audit_shout") == 0)
		{
			map_config.audit_shout = atoi(w2);
		}
		else if (strcmp(w1,"audit_tell") == 0)
		{
			map_config.audit_tell = atoi(w2);
		}
		else if (strcmp(w1,"audit_yell") == 0)
		{
			map_config.audit_yell = atoi(w2);
		}
		else if (strcmp(w1,"audit_linkshell") == 0)
		{
			map_config.audit_linkshell = atoi(w2);
		}
		else if (strcmp(w1,"audit_party") == 0)
		{
			map_config.audit_party = atoi(w2);
		}
		else
		{
			ShowWarning(CL_YELLOW"Unknown setting '%s' in file %s\n" CL_RESET, w1, cfgName);
		}
	}

	fclose(fp);

    // Load the English server message..
    fp = fopen("./conf/server_message.conf", "rb");
    if (fp == NULL)
    {
        ShowError("Could not read English server message from: ./conf/server_message.conf\n");
        return 1;
    }

    while (fgets(line, sizeof(line), fp))
    {
        string_t sline(line);
        map_config.server_message += sline;
    }

    fclose(fp);

    // Load the French server message..
    fp = fopen("./conf/server_message_fr.conf", "rb");
    if (fp == NULL)
    {
        ShowError("Could not read English server message from: ./conf/server_message_fr.conf\n");
        return 1;
    }

    while (fgets(line, sizeof(line), fp))
    {
        string_t sline(line);
        map_config.server_message_fr += sline;
    }

    fclose(fp);

    // Ensure both messages have null terminates..
    if (map_config.server_message.at(map_config.server_message.length() - 1) != 0x00)
        map_config.server_message += (char)0x00;
    if (map_config.server_message_fr.at(map_config.server_message_fr.length() - 1) != 0x00)
        map_config.server_message_fr += (char)0x00;

	return 0;
}
Exemple #8
0
// 情報所得
int guild_recv_info(struct guild *sg)
{
	struct guild *g,before;
	int i,bm,m;
	struct eventlist *ev,*ev2;
	struct map_session_data *sd;
	bool guild_new = false;

	nullpo_ret(sg);

	if((g = (struct guild*)idb_get(guild_db,sg->guild_id))==NULL)
	{
		guild_new = true;
		g=(struct guild *)aCalloc(1,sizeof(struct guild));
		idb_put(guild_db,sg->guild_id,g);
		before=*sg;

		// 最初のロードなのでユーザーのチェックを行う
		guild_check_member(sg);
		if ((sd = map_nick2sd(sg->master)) != NULL)
		{
			//If the guild master is online the first time the guild_info is received,
			//that means he was the first to join, so apply guild skill blocking here.
			if( battle_config.guild_skill_relog_delay )
				guild_block_skill(sd, 300000);

			//Also set the guild master flag.
			sd->state.gmaster_flag = g;
			clif_charnameupdate(sd); // [LuzZza]
			clif_guild_masterormember(sd);
		}
	}else
		before=*g;
	memcpy(g,sg,sizeof(struct guild));

	if(g->max_member > MAX_GUILD)
	{
		ShowError("guild_recv_info: Received guild with %d members, but MAX_GUILD is only %d. Extra guild-members have been lost!\n", g->max_member, MAX_GUILD);
		g->max_member = MAX_GUILD;
	}
	
	for(i=bm=m=0;i<g->max_member;i++){
		if(g->member[i].account_id>0){
			sd = g->member[i].sd = guild_sd_check(g->guild_id, g->member[i].account_id, g->member[i].char_id);
			if (sd) clif_charnameupdate(sd); // [LuzZza]
			m++;
		}else
			g->member[i].sd=NULL;
		if(before.member[i].account_id>0)
			bm++;
	}

	for(i=0;i<g->max_member;i++){	// 情報の送信
		sd = g->member[i].sd;
		if( sd==NULL )
			continue;

		if(	before.guild_lv!=g->guild_lv || bm!=m ||
			before.max_member!=g->max_member ){
			clif_guild_basicinfo(sd);	// 基本情報送信
			clif_guild_emblem(sd,g);	// エンブレム送信
		}

		if(bm!=m){		// メンバー情報送信
			clif_guild_memberlist(g->member[i].sd);
		}

		if( before.skill_point!=g->skill_point)
			clif_guild_skillinfo(sd);	// スキル情報送信

		if( guild_new ){	// 未送信なら所属情報も送る
			clif_guild_belonginfo(sd,g);
			clif_guild_notice(sd,g);
			sd->guild_emblem_id=g->emblem_id;
		}
	}

	// イベントの発生
	if( (ev = (struct eventlist*)idb_remove(guild_infoevent_db,sg->guild_id))!=NULL )
	{
		while(ev){
			npc_event_do(ev->name);
			ev2=ev->next;
			aFree(ev);
			ev=ev2;
		}
	}

	return 0;
}
Exemple #9
0
void searchstore_click(struct map_session_data *sd, int account_id, int store_id, unsigned short nameid) {
	unsigned int i;
	struct map_session_data *pl_sd;
	searchstore_search_t store_search;

	if(!battle_config.feature_search_stores || !sd->searchstore.open || !sd->searchstore.count) {
		return;
	}

	searchstore->clearremote(sd);

	ARR_FIND(0, sd->searchstore.count, i,  sd->searchstore.items[i].store_id == store_id && sd->searchstore.items[i].account_id == account_id && sd->searchstore.items[i].nameid == nameid);
	if(i == sd->searchstore.count) {
		// no such result, crafted
		ShowWarning("searchstore_click: Received request with item %hu of account %d, which is not part of current result set (account_id=%d, char_id=%d).\n", nameid, account_id, sd->bl.id, sd->status.char_id);
		clif_search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
		return;
	}

	if((pl_sd = map->id2sd(account_id)) == NULL) {
		// no longer online
		clif_search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
		return;
	}

	if(!searchstore_hasstore(pl_sd, sd->searchstore.type) || searchstore_getstoreid(pl_sd, sd->searchstore.type) != store_id) {
		// no longer vending/buying or not same shop
		clif_search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
		return;
	}

	store_search = searchstore_getsearchfunc(sd->searchstore.type);

	if(!store_search(pl_sd, nameid)) {
		// item no longer being sold/bought
		clif_search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
		return;
	}

	switch(sd->searchstore.effect) {
		case EFFECTTYPE_NORMAL:
			// display coords

			if(sd->bl.m != pl_sd->bl.m) {
				// not on same map, wipe previous marker
				clif_search_store_info_click_ack(sd, -1, -1);
			} else {
				clif_search_store_info_click_ack(sd, pl_sd->bl.x, pl_sd->bl.y);
			}

			break;
		case EFFECTTYPE_CASH:
			// open remotely

			// to bypass range checks
			sd->searchstore.remote_id = account_id;

			switch(sd->searchstore.type) {
				case SEARCHTYPE_VENDING:      vending->list(sd, account_id); break;
				case SEARCHTYPE_BUYING_STORE: buyingstore->open(sd, account_id);       break;
			}

			break;
		default:
			// unknown
			ShowError("searchstore_click: Unknown search store effect %u (account_id=%d).\n", (unsigned int)sd->searchstore.effect, sd->bl.id);
	}
}
Exemple #10
0
ground_truth CbirGVT::GetGvtImagesOneByOne(size_t idx, size_t nn) {
  string msg = "CbirGVT::GetGvtImagesOneByOne("+ToStr(idx)+","+ToStr(nn)+") : ";

  ground_truth ret(GetDataBase()->Size());

  bool hit = false;
  vector<size_t> cres = FindCache(idx, nn, hit);
  if (hit) {
    cout << msg << "cache hit, returning " << ToStr(cres.size()) << " images"
	 << endl;

    for (size_t i=0; i<cres.size(); i++)
      ret[i] = 1;

    return ret;
  }

  string access_token;

  ImageCollectionServiceSoapBindingProxy *imageCollection =
    (ImageCollectionServiceSoapBindingProxy*)GetGvtImagesCommon(access_token);
  if (!imageCollection)
    return ground_truth();  

  string collection_name = "b12n";

  GetDataBase()->WriteLog(msg+"starting");

  size_t nretpos = 0;
  map<string,string> oi = GetDataBase()->ReadOriginsInfo(idx, false, false);
  string image_url = oi["url"];

  gvt__imageSimilarityUrl imageSimilarity_payload;
  imageSimilarity_payload.CollectionId = &collection_name;
  imageSimilarity_payload.maxResults = nn;
  imageSimilarity_payload.imageUrl = &image_url;
  gvt__imageSimilarityUrlResponse imageSimilarity_response;

  if (imageCollection->imageSimilarityUrl(&imageSimilarity_payload,
					  &imageSimilarity_response)
      == SOAP_OK) {
    GetDataBase()->WriteLog(msg+"ending");

    gvt__imageSimilarityResult *imageSimilarity_result
      = imageSimilarity_response.return_;
    if (debug>1)
      cout << *(imageSimilarity_result->message) << endl;
    vector<gvt__imageSimilarityId*> &similar_images
      = imageSimilarity_result->results;
    vector<gvt__imageSimilarityId*>::iterator it = similar_images.begin();

    for (;it < similar_images.end(); it++) {
      gvt__imageSimilarityId *imageSimilarityId = *it;
      if (debug>2)
	cout << *(imageSimilarityId->imageId) << "\t"
	     << imageSimilarityId->similarity << endl;
      bool ok = false;
      string uin = *imageSimilarityId->imageId, u = uin;
      size_t p = u.find("static.flickr.com");
      if (p!=string::npos) {
	p = u.find('/', p);
	if (p!=string::npos) {
	  p = u.find('/', p+1);
	  u.erase(0, p+1);
	  p = u.find('_');
	  if (p!=string::npos) {
	    u.erase(p);
	    u = string(10-u.size(), '0')+u;
	    int idxr = GetDataBase()->ToIndex(u);
	    if (idxr>=0) {
	      nretpos++;
	      ret[idxr] = 1;
	      ok = true;
	      AddCache(idx, nn, idxr);
	    }
	  }
	}
      }
      if (!ok && debug) {
	if (false)
	  ShowError(msg+"failed with <"+uin+"> -> <"+u+">");
	else
	  cerr << msg+"failed with <"+uin+"> -> <"+u+">" << endl;
      }
    }
  }
  else {
    soap_print_fault(imageCollection, stderr);
  }

  delete imageCollection;

  if (debug)
    cout << msg << "returning " << nretpos << " images" << endl;

  return ret;
}
Exemple #11
0
ground_truth CbirGVT::GetGvtImagesManyNew(const vector<size_t>& idxv,
					  const vector<size_t>& nnv,
					  size_t nobj,
					  const ground_truth& allowed) {
  string msg = "CbirGVT::GetGvtImagesMany() : ";

  if (!idxv.size())
    return ground_truth();

  if (idxv.size()!=nnv.size()) {
    ShowError(msg+"vector dimensions differ");
    return ground_truth();
  }

  GetDataBase()->WriteLog(msg+"starting with "+ToStr(idxv.size())+" samples");

  vector<size_t> idxvres;
  vector<int>    nnvres;
  vector<string> image_url_vec;
  map<size_t,size_t> idx2nn;

  multimap<size_t,size_t> retmap;

  size_t nallow = 0;
  for (size_t a=0; a<idxv.size(); a++) {
    bool hit = false;
    vector<size_t> cres = FindCache(idxv[a], nnv[a], hit);
    if (hit) {
      cout << msg << "a=" << a << " idx=" << idxv[a] << " nn=" << nnv[a]
	   << " cache hit, returning " << ToStr(cres.size()) << " images"
	   << endl;

      for (size_t i=0; i<cres.size(); i++) {
	size_t idx = cres[i];
	bool allow = allowed[idx];
	nallow += allow;
	if (debug>2)
	  cout << " i=" << i << " index=" << idx << " allow=" << allow << endl;
	if (allow)
	  retmap.insert(make_pair(i, idx));
      }

      continue;
    }
    idxvres.push_back(idxv[a]);
    nnvres.push_back(nnv[a]);
    idx2nn[idxv[a]] = nnv[a];

    map<string,string> oi = GetDataBase()->ReadOriginsInfo(idxv[a],
							   false, false);
    string image_url = oi["url"];

    if (image_url=="")
      ShowError(msg+"image URL not resolved for image #"+ToStr(idxv[a]));

    image_url_vec.push_back(image_url);
  }

  GetDataBase()->WriteLog(msg+"found "+ToStr(nallow)+" images in the cache,"
			  " continuing with "+ToStr(nnvres.size())+" samples");

  if (nnvres.size()) {
    string access_token;
    ImageCollectionServiceSoapBindingProxy *imageCollection =
      (ImageCollectionServiceSoapBindingProxy*)GetGvtImagesCommon(access_token);
    if (!imageCollection)
      return ground_truth();  

    string collection_name = "b12n";

    gvt__imageSimilarityUrls imageSimilarity_payloads;
    imageSimilarity_payloads.CollectionId = &collection_name;
    imageSimilarity_payloads.maxResults = nnvres;
    imageSimilarity_payloads.imageUrl = image_url_vec;
    gvt__imageSimilarityUrlsResponse imageSimilarity_responses;

    // imageSimilarityUrls(collectionId, string[] imageUrls, int[] numResults);
    if (imageCollection->imageSimilarityUrls(&imageSimilarity_payloads,
					     &imageSimilarity_responses)
	== SOAP_OK) {
      GetDataBase()->WriteLog(msg+"ending");

      gvt__imageSimilarityResult *imageSimilarity_result
	= imageSimilarity_responses.return_;
      if (debug>1)
	cout << *(imageSimilarity_result->message) << endl;
      vector<gvt__imageSimilarityId*> &similar_images
	= imageSimilarity_result->results;
      vector<gvt__imageSimilarityId*>::iterator it = similar_images.begin();

      float prevsim = 0.0;
      size_t idxx = 0, nnx = 0;

      size_t j = 0;
      for (;it < similar_images.end(); it++) {
	gvt__imageSimilarityId *imageSimilarityId = *it;

	bool set_idxx = false;
	if (imageSimilarityId->similarity>prevsim)
	  set_idxx = true;
	prevsim = imageSimilarityId->similarity;

	if (debug>2)
	  cout << *(imageSimilarityId->imageId) << "\t"
	       << imageSimilarityId->similarity;
	bool ok = false;
	string uin = *imageSimilarityId->imageId, u = uin;
	size_t p = u.find("static.flickr.com");
	if (p!=string::npos) {
	  p = u.find('/', p);
	  if (p!=string::npos) {
	    p = u.find('/', p+1);
	    u.erase(0, p+1);
	    p = u.find('_');
	    if (p!=string::npos) {
	      u.erase(p);
	      u = string(10-u.size(), '0')+u;
	      int idxr = GetDataBase()->ToIndex(u);
	      if (idxr>=0) {
		if (set_idxx) {
		  idxx = idxr;
		  nnx  = idx2nn[idxx];
		  j = 0;
		}

		bool allow = allowed[idxr];
		nallow  += allow;
		if (debug>2)
		  cout << " j=" << j << " index=" << idxr
		       << " allow=" << allow << endl;
		if (allow)
		  retmap.insert(make_pair(j, idxr));

		ok = true;
		AddCache(idxx, nnx, idxr);

		j++;
	      }
	    }
	  }
	}
	if (debug>2)
	  cout << endl;

	if (!ok && debug) {
	  if (false)
	    ShowError(msg+"failed with <"+uin+"> -> <"+u+">");
	  else
	    cerr << msg+"failed with <"+uin+"> -> <"+u+">" << endl;
	}
      }
    }
    else {
      soap_print_fault(imageCollection, stderr);
    }

    delete imageCollection;
  }

  ground_truth ret(GetDataBase()->Size());

  size_t nretpos = 0;
  for (multimap<size_t,size_t>::const_iterator mi=retmap.begin();
       mi!=retmap.end() && nretpos<nobj; mi++) {
    if (debug>2)
      cout << " checking " << mi->first << " " << mi->second << " "
	   << (int)ret[mi->second] << " " << nretpos << endl;
    nretpos += ret[mi->second]!=1;
    ret[mi->second] = 1;
  }

  if (debug)
    cout << msg << "returning " << nretpos << " images from total of "
	 << nallow << " found" << endl;

  return ret;
}
void MagnatuneDownloadDialog::MetadataFinished() {
  QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
  reply->deleteLater();

  // The reply isn't valid XML so we can't use QtXML to parse it :(
  QString data = QString::fromUtf8(reply->readAll());

  // Check for errors
  if (data.contains("<ERROR>")) {
    ShowError(tr("There was a problem fetching the metadata from Magnatune"));
    return;
  }

  // Work out what format we want
  QString type;
  switch (ui_->format->currentIndex()) {
    case MagnatuneService::Format_Ogg:
      type = "URL_OGGZIP";
      break;
    case MagnatuneService::Format_Flac:
      type = "URL_FLACZIP";
      break;
    case MagnatuneService::Format_Wav:
      type = "URL_WAVZIP";
      break;
    case MagnatuneService::Format_MP3_VBR:
      type = "URL_VBRZIP";
      break;
    case MagnatuneService::Format_MP3_128:
      type = "URL_128KMP3ZIP";
      break;
  }

  // Parse the XML (lol) to find the URL
  QRegExp re(QString("<%1>([^<]+)</%2>").arg(type, type));
  if (re.indexIn(data) == -1) {
    ShowError(tr("This album is not available in the requested format"));
    return;
  }

  // Munge the URL a bit
  QString url_text = Utilities::DecodeHtmlEntities(re.cap(1));

  QUrl url = QUrl(url_text);
  url.setUserName(service_->username());
  url.setPassword(service_->password());

  qLog(Debug) << "Downloading" << url;

  // Start the actual download
  current_reply_ = network_->get(QNetworkRequest(url));

  connect(current_reply_, SIGNAL(error(QNetworkReply::NetworkError)),
          SLOT(Error(QNetworkReply::NetworkError)));
  connect(current_reply_, SIGNAL(finished()), SLOT(DownloadFinished()));
  connect(current_reply_, SIGNAL(downloadProgress(qint64, qint64)),
          SLOT(DownloadProgress(qint64, qint64)));
  connect(current_reply_, SIGNAL(readyRead()), SLOT(DownloadReadyRead()));

  // Close any open file
  download_file_.reset();

  // Open the output file
  QString output_filename = GetOutputFilename();
  download_file_.reset(new QFile(output_filename));
  if (!download_file_->open(QIODevice::WriteOnly)) {
    ShowError(tr("Couldn't open output file %1").arg(output_filename));
  }
}
Exemple #13
0
/*==========================================
 * read config file
 *------------------------------------------*/
static int inter_config_read(const char* cfgName)
{
	int i;
	char line[1024], w1[1024], w2[1024];
	FILE* fp;

	fp = fopen(cfgName, "r");
	if(fp == NULL) {
		ShowError("file not found: %s\n", cfgName);
		return 1;
	}

	ShowInfo("reading file %s...\n", cfgName);

	while(fgets(line, sizeof(line), fp))
	{
		i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2);
		if(i != 2)
			continue;

		if(!strcmpi(w1,"char_server_ip")) {
			strcpy(char_server_ip,w2);
			ShowStatus ("set char_server_ip : %s\n", w2);
		} else
		if(!strcmpi(w1,"char_server_port")) {
			char_server_port = atoi(w2);
			ShowStatus ("set char_server_port : %s\n", w2);
		} else
		if(!strcmpi(w1,"char_server_id")) {
			strcpy(char_server_id,w2);
			ShowStatus ("set char_server_id : %s\n", w2);
		} else
		if(!strcmpi(w1,"char_server_pw")) {
			strcpy(char_server_pw,w2);
			ShowStatus ("set char_server_pw : %s\n", w2);
		} else
		if(!strcmpi(w1,"char_server_db")) {
			strcpy(char_server_db,w2);
			ShowStatus ("set char_server_db : %s\n", w2);
		} else
		if(!strcmpi(w1,"default_codepage")) {
			strcpy(default_codepage,w2);
			ShowStatus ("set default_codepage : %s\n", w2);
		}
#ifndef TXT_SQL_CONVERT
		else if(!strcmpi(w1,"party_share_level"))
			party_share_level = atoi(w2);
		else if(!strcmpi(w1,"log_inter"))
			log_inter = atoi(w2);
		else if(!strcmpi(w1,"main_chat_nick"))
			safestrncpy(main_chat_nick, w2, sizeof(main_chat_nick));
#endif //TXT_SQL_CONVERT
		else if(!strcmpi(w1,"import"))
			inter_config_read(w2);
	}
	fclose(fp);

	ShowInfo ("done reading %s.\n", cfgName);

	return 0;
}
int read_mercenary_skilldb(void)
{
	FILE *fp;
	char line[1024], *p;
	char *str[3];
	struct s_mercenary_db *db;
	int i, j = 0, k = 0, class_;
	int skillid, skilllv;

	sprintf(line, "%s/%s", db_path, "mercenary_skill_db.txt");
	fp = fopen(line, "r");
	if( !fp )
	{
		ShowError("read_mercenary_skilldb : can't read mercenary_skill_db.txt\n");
		return -1;
	}

	while( fgets(line, sizeof(line), fp) )
	{
		k++;
		if( line[0] == '/' && line[1] == '/' )
			continue;

		i = 0;
		p = strtok(line, ",");
		while( p != NULL && i < 3 )
		{
			str[i++] = p;
			p = strtok(NULL, ",");
		}
		if( i < 3 )
		{
			ShowError("read_mercenary_skilldb : Incorrect number of columns at mercenary_skill_db.txt line %d.\n", k);
			continue;
		}

		class_ = atoi(str[0]);
		ARR_FIND(0, MAX_MERCENARY_CLASS, i, class_ == mercenary_db[i].class_);
		if( i == MAX_MERCENARY_CLASS )
		{
			ShowError("read_mercenary_skilldb : Class not found in mercenary_db for skill entry, line %d.\n", k);
			continue;
		}
		
		skillid = atoi(str[1]);
		if( skillid < MC_SKILLBASE || skillid >= MC_SKILLBASE + MAX_MERCSKILL )
		{
			ShowError("read_mercenary_skilldb : Skill out of range, line %d.\n", k);
			continue;
		}

		db = &mercenary_db[i];
		skilllv = atoi(str[2]);

		i = skillid - MC_SKILLBASE;
		db->skill[i].id = skillid;
		db->skill[i].lv = skilllv;
		j++;
	}

	fclose(fp);
	ShowStatus("'"CL_WHITE"db/mercenary_skill_db.txt"CL_RESET"' 에서 '"CL_WHITE"%d"CL_RESET"' 개의 자료를 읽었습니다.\n", j);
	return 0;
}
Exemple #15
0
/**
 * Loads group configuration from config file into memory.
 * @private
 */
static void read_config(void)
{
	config_setting_t *groups = NULL;
	const char *config_filename = "conf/groups.conf"; // FIXME hardcoded name
	int group_count = 0;
	
	if (conf_read_file(&pc_group_config, config_filename))
		return;

	groups = config_lookup(&pc_group_config, "groups");

	if (groups != NULL) {
		GroupSettings *group_settings = NULL;
		DBIterator *iter = NULL;
		int i, loop = 0;

		group_count = config_setting_length(groups);
		for (i = 0; i < group_count; ++i) {
			int id = 0, level = 0;
			const char *groupname = NULL;
			int log_commands = 0;
			config_setting_t *group = config_setting_get_elem(groups, i);

			if (!config_setting_lookup_int(group, "id", &id)) {
				ShowConfigWarning(group, "pc_groups:read_config: \"groups\" list member #%d has undefined id, removing...", i);
				config_setting_remove_elem(groups, i);
				--i;
				--group_count;
				continue;
			}

			if (id2group(id) != NULL) {
				ShowConfigWarning(group, "pc_groups:read_config: duplicate group id %d, removing...", i);
				config_setting_remove_elem(groups, i);
				--i;
				--group_count;
				continue;
			}

			config_setting_lookup_int(group, "level", &level);
			config_setting_lookup_bool(group, "log_commands", &log_commands);

			if (!config_setting_lookup_string(group, "name", &groupname)) {
				char temp[20];
				config_setting_t *name = NULL;
				snprintf(temp, sizeof(temp), "Group %d", id);
				if ((name = config_setting_add(group, "name", CONFIG_TYPE_STRING)) == NULL ||
				    !config_setting_set_string(name, temp)) {
					ShowError("pc_groups:read_config: failed to set missing group name, id=%d, skipping... (%s:%d)\n",
					          id, config_setting_source_file(group), config_setting_source_line(group));
					continue;
				}
				config_setting_lookup_string(group, "name", &groupname); // Retrieve the pointer
			}

			if (name2group(groupname) != NULL) {
				ShowConfigWarning(group, "pc_groups:read_config: duplicate group name %s, removing...", groupname);
				config_setting_remove_elem(groups, i);
				--i;
				--group_count;
				continue;
			}

			CREATE(group_settings, GroupSettings, 1);
			group_settings->id = id;
			group_settings->level = level;
			group_settings->name = groupname;
			group_settings->log_commands = (bool)log_commands;
			group_settings->inherit = config_setting_get_member(group, "inherit");
			group_settings->commands = config_setting_get_member(group, "commands");
			group_settings->permissions = config_setting_get_member(group, "permissions");
			group_settings->inheritance_done = false;
			group_settings->root = group;
			group_settings->group_pos = i;

			strdb_put(pc_groupname_db, groupname, group_settings);
			idb_put(pc_group_db, id, group_settings);
			
		}
		group_count = config_setting_length(groups); // Save number of groups
		
		// Check if all commands and permissions exist
		iter = db_iterator(pc_group_db);
		for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
			config_setting_t *commands = group_settings->commands, *permissions = group_settings->permissions;
			int count = 0, j;

			// Make sure there is "commands" group
			if (commands == NULL)
				commands = group_settings->commands = config_setting_add(group_settings->root, "commands", CONFIG_TYPE_GROUP);
			count = config_setting_length(commands);

			for (j = 0; j < count; ++j) {
				config_setting_t *command = config_setting_get_elem(commands, j);
				const char *name = config_setting_name(command);
				if (!atcommand_exists(name)) {
					ShowConfigWarning(command, "pc_groups:read_config: non-existent command name '%s', removing...", name);
					config_setting_remove(commands, name);
					--j;
					--count;
				}
			}

			// Make sure there is "permissions" group
			if (permissions == NULL)
				permissions = group_settings->permissions = config_setting_add(group_settings->root, "permissions", CONFIG_TYPE_GROUP);
			count = config_setting_length(permissions);

			for(j = 0; j < count; ++j) {
				config_setting_t *permission = config_setting_get_elem(permissions, j);
				const char *name = config_setting_name(permission);
				int p;

				ARR_FIND(0, ARRAYLENGTH(pc_g_permission_name), p, strcmp(pc_g_permission_name[p].name, name) == 0);
				if (p == ARRAYLENGTH(pc_g_permission_name)) {
					ShowConfigWarning(permission, "pc_groups:read_config: non-existent permission name '%s', removing...", name);
					config_setting_remove(permissions, name);
					--p;
					--count;
				}
			}
		}
		dbi_destroy(iter);

		// Apply inheritance
		i = 0; // counter for processed groups
		while (i < group_count) {
			iter = db_iterator(pc_group_db);
			for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
				config_setting_t *inherit = NULL,
				                 *commands = group_settings->commands,
					             *permissions = group_settings->permissions;
				int j, inherit_count = 0, done = 0;
				
				if (group_settings->inheritance_done) // group already processed
					continue; 

				if ((inherit = group_settings->inherit) == NULL ||
				    (inherit_count = config_setting_length(inherit)) <= 0) { // this group does not inherit from others
					++i;
					group_settings->inheritance_done = true;
					continue;
				}
				
				for (j = 0; j < inherit_count; ++j) {
					GroupSettings *inherited_group = NULL;
					const char *groupname = config_setting_get_string_elem(inherit, j);

					if (groupname == NULL) {
						ShowConfigWarning(inherit, "pc_groups:read_config: \"inherit\" array member #%d is not a name, removing...", j);
						config_setting_remove_elem(inherit,j);
						continue;
					}
					if ((inherited_group = name2group(groupname)) == NULL) {
						ShowConfigWarning(inherit, "pc_groups:read_config: non-existent group name \"%s\", removing...", groupname);
						config_setting_remove_elem(inherit,j);
						continue;
					}
					if (!inherited_group->inheritance_done)
						continue; // we need to do that group first

					// Copy settings (commands/permissions) that are not defined yet
					if (inherited_group->commands != NULL) {
						int l = 0, commands_count = config_setting_length(inherited_group->commands);
						for (l = 0; l < commands_count; ++l)
							config_setting_copy(commands, config_setting_get_elem(inherited_group->commands, l));
					}

					if (inherited_group->permissions != NULL) {
						int l = 0, permissions_count = config_setting_length(inherited_group->permissions);
						for (l = 0; l < permissions_count; ++l)
							config_setting_copy(permissions, config_setting_get_elem(inherited_group->permissions, l));
					}

					++done; // copied commands and permissions from one of inherited groups
				}
				
				if (done == inherit_count) { // copied commands from all of inherited groups
					++i;
					group_settings->inheritance_done = true; // we're done with this group
				}
			}
			dbi_destroy(iter);

			if (++loop > group_count) {
				ShowWarning("pc_groups:read_config: Could not process inheritance rules, check your config '%s' for cycles...\n",
				            config_filename);
				break;
			}
		} // while(i < group_count)

		// Pack permissions into GroupSettings.e_permissions for faster checking
		iter = db_iterator(pc_group_db);
		for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
			config_setting_t *permissions = group_settings->permissions;
			int c, count = config_setting_length(permissions);

			for (c = 0; c < count; ++c) {
				config_setting_t *perm = config_setting_get_elem(permissions, c);
				const char *name = config_setting_name(perm);
				int val = config_setting_get_bool(perm);
				int j;

				if (val == 0) // does not have this permission
					continue;
				ARR_FIND(0, ARRAYLENGTH(pc_g_permission_name), j, strcmp(pc_g_permission_name[j].name, name) == 0);
				group_settings->e_permissions |= pc_g_permission_name[j].permission;
			}
		}
		dbi_destroy(iter);
	}

	ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' groups in '"CL_WHITE"%s"CL_RESET"'.\n", group_count, config_filename);

	
	if( ( pc_group_max = group_count ) ) {
		DBIterator *iter = db_iterator(pc_group_db);
		GroupSettings *group_settings = NULL;
		int* group_ids = aMalloc( pc_group_max * sizeof(int) );
		int i = 0;
		for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
			group_ids[i++] = group_settings->id;
		}
		
		atcommand_db_load_groups(group_ids);
		
		aFree(group_ids);
		
		dbi_destroy(iter);
	}
}
Exemple #16
0
void searchstore_query(struct map_session_data *sd, unsigned char type, unsigned int min_price, unsigned int max_price, const unsigned short *itemlist, unsigned int item_count, const unsigned short *cardlist, unsigned int card_count)
{
	unsigned int i;
	struct map_session_data *pl_sd;
	struct DBIterator *iter;
	struct s_search_store_search s;
	searchstore_searchall_t store_searchall;
	time_t querytime;

	if(!battle_config.feature_search_stores) {
		return;
	}

	if(!sd->searchstore.open) {
		return;
	}

	if((store_searchall = searchstore_getsearchallfunc(type)) == NULL) {
		ShowError("searchstore_query: Unknown search type %u (account_id=%d).\n", (unsigned int)type, sd->bl.id);
		return;
	}

	time(&querytime);

	if(sd->searchstore.nextquerytime > querytime) {
		clif_search_store_info_failed(sd, SSI_FAILED_LIMIT_SEARCH_TIME);
		return;
	}

	if(!sd->searchstore.uses) {
		clif_search_store_info_failed(sd, SSI_FAILED_SEARCH_CNT);
		return;
	}

	// validate lists
	for(i = 0; i < item_count; i++) {
		if(!itemdb_exists(itemlist[i])) {
			ShowWarning("searchstore_query: Client resolved item %hu is not known.\n", itemlist[i]);
			clif_search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
			return;
		}
	}
	for(i = 0; i < card_count; i++) {
		if(!itemdb_exists(cardlist[i])) {
			ShowWarning("searchstore_query: Client resolved card %hu is not known.\n", cardlist[i]);
			clif_search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
			return;
		}
	}

	if(max_price < min_price) {
		swap(min_price, max_price);
	}

	sd->searchstore.uses--;
	sd->searchstore.type = type;
	sd->searchstore.nextquerytime = querytime+battle_config.searchstore_querydelay;

	// drop previous results
	searchstore->clear(sd);

	// allocate max. amount of results
	sd->searchstore.items = (struct s_search_store_info_item *)aMalloc(sizeof(struct s_search_store_info_item)*battle_config.searchstore_maxresults);

	// search
	s.search_sd  = sd;
	s.itemlist   = itemlist;
	s.cardlist   = cardlist;
	s.item_count = item_count;
	s.card_count = card_count;
	s.min_price  = min_price;
	s.max_price  = max_price;
	iter         = db_iterator(vending->db);

	for(pl_sd = dbi_first(iter); dbi_exists(iter);  pl_sd = dbi_next(iter)) {
		if(sd == pl_sd) {// skip own shop, if any
			continue;
		}

		if(!store_searchall(pl_sd, &s)) {
			// exceeded result size
			clif_search_store_info_failed(sd, SSI_FAILED_OVER_MAXCOUNT);
			break;
		}
	}

	dbi_destroy(iter);

	if(sd->searchstore.count) {
		// reclaim unused memory
		sd->searchstore.items = (struct s_search_store_info_item *)aRealloc(sd->searchstore.items, sizeof(struct s_search_store_info_item)*sd->searchstore.count);

		// present results
		clif_search_store_info_ack(sd);

		// one page displayed
		sd->searchstore.pages++;
	} else {
		// cleanup
		searchstore->clear(sd);

		// update uses
		clif_search_store_info_ack(sd);

		// notify of failure
		clif_search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
	}
}
Exemple #17
0
/**
* Open vending for Autotrader
* @param sd Player as autotrader
*/
void vending_reopen( struct map_session_data* sd )
{
	struct s_autotrader *at = NULL;
	int8 fail = -1;

	nullpo_retv(sd);

	// Open vending for this autotrader
	if ((at = (struct s_autotrader *)uidb_get(vending_autotrader_db, sd->status.char_id)) && at->count && at->entries) {
		uint8 *data, *p;
		uint16 j, count;

		// Init vending data for autotrader
		CREATE(data, uint8, at->count * 8);

		for (j = 0, p = data, count = at->count; j < at->count; j++) {
			struct s_autotrade_entry *entry = at->entries[j];
			uint16 *index = (uint16*)(p + 0);
			uint16 *amount = (uint16*)(p + 2);
			uint32 *value = (uint32*)(p + 4);

			// Find item position in cart
			ARR_FIND(0, MAX_CART, entry->index, sd->cart.u.items_cart[entry->index].id == entry->cartinventory_id);

			if (entry->index == MAX_CART) {
				count--;
				continue;
			}

			*index = entry->index + 2;
			*amount = itemdb_isstackable(sd->cart.u.items_cart[entry->index].nameid) ? entry->amount : 1;
			*value = entry->price;

			p += 8;
		}

		sd->state.prevend = 1; // Set him into a hacked prevend state
		sd->state.autotrade = 1;

		// Make sure abort all NPCs
		npc_event_dequeue(sd);
		pc_cleareventtimer(sd);

		// Open the vending again
		if( (fail = vending_openvending(sd, at->title, data, count, at)) == 0 ) {
			// Make vendor look perfect
			pc_setdir(sd, at->dir, at->head_dir);
			clif_changed_dir(&sd->bl, AREA_WOS);
			if( at->sit ) {
				pc_setsit(sd);
				skill_sit(sd, 1);
				clif_sitting(&sd->bl);
			}

			// Immediate save
			chrif_save(sd, CSAVE_AUTOTRADE);

			ShowInfo("Vending loaded for '" CL_WHITE "%s" CL_RESET "' with '" CL_WHITE "%d" CL_RESET "' items at " CL_WHITE "%s (%d,%d)" CL_RESET "\n",
				sd->status.name, count, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
		}
		aFree(data);
	}

	if (at) {
		vending_autotrader_remove(at, true);
		if (db_size(vending_autotrader_db) == 0)
			vending_autotrader_db->clear(vending_autotrader_db, vending_autotrader_free);
	}

	if (fail != 0) {
		ShowError("vending_reopen: (Error:%d) Load failed for autotrader '" CL_WHITE "%s" CL_RESET "' (CID=%d/AID=%d)\n", fail, sd->status.name, sd->status.char_id, sd->status.account_id);
		map_quit(sd);
	}
}
Exemple #18
0
int32 login_config_read(const char *cfgName)
{
    char line[1024], w1[1024], w2[1024];
    FILE *fp;

    fp = fopen(cfgName, "r");
    if (fp == nullptr)
    {
        ShowError("login configuration file not found at: %s\n", cfgName);
        return 1;
    }

    while (fgets(line, sizeof(line), fp))
    {
        char* ptr;

        if (line[0] == '#')
            continue;
        if (sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2)
            continue;

        //Strip trailing spaces
        ptr = w2 + strlen(w2);
        while (--ptr >= w2 && *ptr == ' ');
        ptr++;
        *ptr = '\0';

        if (strcmpi(w1, "timestamp_format") == 0)
        {
            strncpy(timestamp_format, w2, 19);
        }
        else if (strcmpi(w1, "stdout_with_ansisequence") == 0)
        {
            stdout_with_ansisequence = config_switch(w2);
        }
        else if (strcmpi(w1, "console_silent") == 0)
        {
            ShowInfo("Console Silent Setting: %d\n", atoi(w2));
            msg_silent = atoi(w2);
        }
        else if (strcmp(w1, "login_data_ip") == 0)
        {
            login_config.login_data_ip = std::string(w2);
        }
        else if (strcmp(w1, "login_data_port") == 0)
        {
            login_config.login_data_port = atoi(w2);
        }
        else if (strcmp(w1, "login_view_ip") == 0)
        {   
            login_config.login_view_ip = std::string(w2);
        }
        else if (strcmp(w1, "login_view_port") == 0)
        {
            login_config.login_view_port = atoi(w2);
        }
        else if (strcmp(w1, "login_auth_ip") == 0)
        {   
            login_config.login_auth_ip = std::string(w2);
        }
        else if (strcmp(w1, "login_auth_port") == 0)
        {
            login_config.login_auth_port = atoi(w2);
        }
        else if (strcmp(w1, "mysql_host") == 0)
        {
            login_config.mysql_host = std::string(w2);
        }
        else if (strcmp(w1, "mysql_login") == 0)
        {
            login_config.mysql_login = std::string(w2);
        }
        else if (strcmp(w1, "mysql_password") == 0)
        {
            login_config.mysql_password = std::string(w2);
        }
        else if (strcmp(w1, "mysql_port") == 0)
        {
            login_config.mysql_port = atoi(w2);
        }
        else if (strcmp(w1, "mysql_database") == 0)
        {
            login_config.mysql_database = std::string(w2);
        }
        else if (strcmp(w1, "search_server_port") == 0)
        {
            login_config.search_server_port = atoi(w2);
        }
        else if (strcmp(w1, "expansions") == 0)
        {
            login_config.expansions = atoi(w2);
        }
        else if (strcmp(w1, "features") == 0)
        {
            login_config.features = atoi(w2);
        }
        else if (strcmp(w1, "servername") == 0)
        {
            login_config.servername = std::string(w2);
        }
        else if (strcmpi(w1, "import") == 0)
        {
            login_config_read(w2);
        }
        else if (strcmp(w1, "msg_server_port") == 0)
        {
            login_config.msg_server_port = atoi(w2);
        }
        else if (strcmp(w1, "msg_server_ip") == 0)
        {
            login_config.msg_server_ip = std::string(w2);
        }
        else if (strcmp(w1, "log_user_ip") == 0)
        {
            login_config.log_user_ip = config_switch(w2);
        }
        else
        {
            ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
        }
    }

    fclose(fp);
    return 0;
}
Exemple #19
0
int32 recv_parse(int8* buff, size_t* buffsize, sockaddr_in* from, map_session_data_t* map_session_data)
{
	size_t size = *buffsize;
	int32 checksumResult = -1;

#ifdef WIN32
    try 
    {
        checksumResult = checksum((uint8*)(buff + FFXI_HEADER_SIZE), size - (FFXI_HEADER_SIZE + 16), buff + size - 16);
    }
    catch (...)
    {
        ShowError(CL_RED"Possible crash attempt from: %s\n" CL_RESET, ip2str(map_session_data->client_addr, NULL));
        return -1;
    }
#else
    checksumResult = checksum((uint8*)(buff + FFXI_HEADER_SIZE), size - (FFXI_HEADER_SIZE + 16), buff + size - 16);
#endif 

	if(checksumResult == 0)
	{
		if (map_session_data->PChar == NULL)
		{
			uint32 CharID = RBUFL(buff,FFXI_HEADER_SIZE+0x0C);

			const int8* fmtQuery = "SELECT session_key FROM accounts_sessions WHERE charid = %u LIMIT 1;";

			int32 ret = Sql_Query(SqlHandle,fmtQuery,CharID);

			if (ret == SQL_ERROR ||
				Sql_NumRows(SqlHandle) == 0 ||
				Sql_NextRow(SqlHandle) != SQL_SUCCESS)
			{
				ShowError(CL_RED"recv_parse: Cannot load session_key for charid %u" CL_RESET, CharID);
			}
			else
			{
				int8* strSessionKey = NULL;
				Sql_GetData(SqlHandle,0,&strSessionKey,NULL);

				memcpy(map_session_data->blowfish.key,strSessionKey,20);
			}

			// наверное создание персонажа лучше вынести в метод charutils::LoadChar() и загрузку инвентаря туда же сунуть
			CCharEntity* PChar = new CCharEntity();
			PChar->id = CharID;
			PChar->PBattleAI = new CAICharNormal(PChar);

			charutils::LoadChar(PChar);
			charutils::LoadInventory(PChar);
            luautils::OnGameIn(PChar);

            PChar->status = STATUS_DISAPPEAR;

			map_session_data->PChar = PChar;
		}
		map_session_data->client_packet_id = 0;
		map_session_data->server_packet_id = 0;
		return 0;
	}else{
		//char packets

		if( map_decipher_packet(buff,*buffsize,from,map_session_data) == -1)
		{
			*buffsize = 0;
			return -1;
		}
		// reading data size
		uint32 PacketDataSize = RBUFL(buff,*buffsize-sizeof(int32)-16);
		// creating buffer for decompress data
		int8* PacketDataBuff = NULL;
		CREATE(PacketDataBuff,int8,map_config.buffer_size);
		// it's decompressing data and getting new size
		PacketDataSize = zlib_decompress(buff+FFXI_HEADER_SIZE,
										 PacketDataSize,
										 PacketDataBuff,
										 map_config.buffer_size,
										 zlib_decompress_table);

		// it's making result buff
		// don't need memcpy header
		memcpy(buff+FFXI_HEADER_SIZE,PacketDataBuff,PacketDataSize);
		*buffsize = FFXI_HEADER_SIZE+PacketDataSize;

		aFree(PacketDataBuff);
		return 0;
	}
	return -1;
}
Exemple #20
0
int32 do_init(int32 argc, char** argv)
{
    int32 i;
    LOGIN_CONF_FILENAME = "conf/login_darkstar.conf";
    VERSION_INFO_FILENAME = "version.info";

    const char *lan_cfgName = LAN_CONFIG_NAME;
    //srand(gettick());

    for (i = 1; i < argc; i++) {
        if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--h") == 0 || strcmp(argv[i], "--?") == 0 || strcmp(argv[i], "/?") == 0)
            login_helpscreen(1);
        else if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "--v") == 0 || strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "/v") == 0)
            login_versionscreen(1);
        else if (strcmp(argv[i], "--login_config") == 0 || strcmp(argv[i], "--login-config") == 0)
            LOGIN_CONF_FILENAME = argv[i + 1];
        else if (strcmp(argv[i], "--lan_config") == 0 || strcmp(argv[i], "--lan-config") == 0)
            lan_cfgName = argv[i + 1];
        else if (strcmp(argv[i], "--run_once") == 0)	// close the map-server as soon as its done.. for testing [Celest]
            runflag = 0;
    }

    //lan_config_default(&lan_config);
    //lan_config_read(lan_cfgName,&lan_config);

    login_config_default();
    login_config_read(LOGIN_CONF_FILENAME);

    version_info_default();
    version_info_read(VERSION_INFO_FILENAME);


    login_fd = makeListenBind_tcp(login_config.login_auth_ip.c_str(), login_config.login_auth_port, connect_client_login);
    ShowStatus("The login-server-auth is " CL_GREEN"ready" CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_auth_port);

    login_lobbydata_fd = makeListenBind_tcp(login_config.login_data_ip.c_str(), login_config.login_data_port, connect_client_lobbydata);
    ShowStatus("The login-server-lobbydata is " CL_GREEN"ready" CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_data_port);

    login_lobbyview_fd = makeListenBind_tcp(login_config.login_view_ip.c_str(), login_config.login_view_port, connect_client_lobbyview);
    ShowStatus("The login-server-lobbyview is " CL_GREEN"ready" CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_view_port);

    SqlHandle = Sql_Malloc();
    if (Sql_Connect(SqlHandle, login_config.mysql_login.c_str(),
        login_config.mysql_password.c_str(),
        login_config.mysql_host.c_str(),
        login_config.mysql_port,
        login_config.mysql_database.c_str()) == SQL_ERROR)
    {
        exit(EXIT_FAILURE);
    }
    Sql_Keepalive(SqlHandle);

    const char *fmtQuery = "OPTIMIZE TABLE `accounts`,`accounts_banned`, `accounts_sessions`, `chars`,`char_equip`, \
						   `char_inventory`, `char_jobs`,`char_look`,`char_stats`, `char_vars`, `char_bazaar_msg`, \
						   `char_skills`, `char_titles`, `char_effects`, `char_exp`;";

    if (Sql_Query(SqlHandle, fmtQuery) == SQL_ERROR)
    {
        ShowError("do_init: Impossible to optimise tables\n");
    }

    messageThread = std::thread(message_server_init);

    ShowStatus("The login-server is " CL_GREEN"ready" CL_RESET" to work...\n");
    return 0;
}
Exemple #21
0
//--------------------------------------------------------
// Save registry to sql
int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type)
{
	struct global_reg* r;
	StringBuf buf;
	int i;

	if( account_id <= 0 )
		return 0;
	reg->account_id = account_id;
	reg->char_id = char_id;

	//`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`)
	switch( type )
	{
	case 3: //Char Reg
		if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) )
			Sql_ShowDebug(sql_handle);
		account_id = 0;
		break;
	case 2: //Account Reg
		if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) )
			Sql_ShowDebug(sql_handle);
		char_id = 0;
		break;
	case 1: //Account2 Reg
		ShowError("inter_accreg_tosql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
		return 0;
	default:
		ShowError("inter_accreg_tosql: Invalid type %d\n", type);
		return 0;
	}

	if( reg->reg_num <= 0 )
		return 0;

	StringBuf_Init(&buf);
	StringBuf_Printf(&buf, "INSERT INTO `%s` (`type`,`account_id`,`char_id`,`str`,`value`) VALUES ", reg_db);
		
	for( i = 0; i < reg->reg_num; ++i ) {
		r = &reg->reg[i];
		if( r->str[0] != '\0' && r->value[0] != '\0' ) {
			char str[32];
			char val[256];

			if( i > 0 )
				StringBuf_AppendStr(&buf, ",");

			Sql_EscapeString(sql_handle, str, r->str);
			Sql_EscapeString(sql_handle, val, r->value);

			StringBuf_Printf(&buf, "('%d','%d','%d','%s','%s')", type, account_id, char_id, str, val);
		}
	}

	if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) {
		Sql_ShowDebug(sql_handle);
	}

	StringBuf_Destroy(&buf);

	return 1;
}
Exemple #22
0
/*==========================================
 * アイテムデータベースの読み込み
 *------------------------------------------*/
static int itemdb_readdb(void)
{
	const char* filename[] = {
		DBPATH"item_db.txt",
		"item_db2.txt" };

	int fi;
	DBMap* item_combo_db = idb_alloc(DB_OPT_RELEASE_DATA);
	
	itemdb_read_combos(item_combo_db);

	for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) {
		uint32 lines = 0, count = 0;
		char line[1024];

		char path[256];
		FILE* fp;

		sprintf(path, "%s/%s", db_path, filename[fi]);
		fp = fopen(path, "r");
		if( fp == NULL ) {
			ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", path);
			continue;
		}

		// process rows one by one
		while(fgets(line, sizeof(line), fp))
		{
			char *str[32], *p;
			int i;
			struct item_combo *ic = NULL;
			char *script2 = NULL;
			lines++;
			if(line[0] == '/' && line[1] == '/')
				continue;
			memset(str, 0, sizeof(str));

			p = line;
			while( ISSPACE(*p) )
				++p;
			if( *p == '\0' )
				continue;// empty line
			for( i = 0; i < 19; ++i )
			{
				str[i] = p;
				p = strchr(p,',');
				if( p == NULL )
					break;// comma not found
				*p = '\0';
				++p;
			}

			if( p == NULL )
			{
				ShowError("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}

			// Script
			if( *p != '{' )
			{
				ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}
			str[19] = p;
			p = strstr(p+1,"},");
			if( p == NULL )
			{
				ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}
			p[1] = '\0';
			p += 2;

			// OnEquip_Script
			if( *p != '{' )
			{
				ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}
			str[20] = p;
			p = strstr(p+1,"},");
			if( p == NULL )
			{
				ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}
			p[1] = '\0';
			p += 2;

			// OnUnequip_Script (last column)
			if( *p != '{' )
			{
				ShowError("itemdb_readdb: Invalid format (OnUnequip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}
			str[21] = p;

			p = strstr(p+1,"}");
			if ( strchr(p,',') != NULL )
			{
				ShowError("itemdb_readdb: Extra columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}

			if ((ic = idb_get(item_combo_db, atoi(str[0])))) {
				script2 = ic->script;
			}
			
			if (!itemdb_parse_dbrow(str, path, lines, 0, script2))
				continue;

			if( script2 != NULL )
				idb_remove(item_combo_db,atoi(str[0]));
			
			count++;
		}

		fclose(fp);

		ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename[fi]);
	}

	if( db_size(item_combo_db) ) {
		DBIterator * iter = db_iterator(item_combo_db);
		struct item_combo * ic = NULL;
		int icount = 1;
		/* non-processed entries */
		ShowWarning("item_combo_db: There are %d unused entries in the file (combo(s) with non-available item IDs)\n",db_size(item_combo_db));
		
		for( ic = dbi_first(iter); dbi_exists(iter); ic = dbi_next(iter) ) {
			ShowWarning("item_combo_db(%d): (ID:%d) \"%s\" combo unused\n",icount++,ic->nameid,ic->script);
		}

		dbi_destroy(iter);
	}
	
	db_destroy(item_combo_db);

	return 0;
}
Exemple #23
0
static bool read_homunculusdb_sub(char* str[], int columns, int current)
{
	int classid; 
	struct s_homunculus_db *db;

	//Base Class,Evo Class
	classid = atoi(str[0]);
	if (!(classid >=  HM_CLASS_BASE && classid <= HM_CLASS_MAX || classid >=  MH_CLASS_BASE && classid <= MH_CLASS_MAX))
	{
		ShowError("read_homunculusdb : Invalid class %d\n", classid);
		return false;
	}
	db = &homunculus_db[current];
	db->base_class = classid;
	classid = atoi(str[1]);
	if (!(classid >=  HM_CLASS_BASE && classid <= HM_CLASS_MAX || classid >=  MH_CLASS_BASE && classid <= MH_CLASS_MAX))
	{
		db->base_class = 0;
		ShowError("read_homunculusdb : Invalid class %d\n", classid);
		return false;
	}
	db->evo_class = classid;
	//Name, Max Level, Food, Hungry Delay, Base Size, Evo Size, Race, Element, ASPD
	strncpy(db->name,str[2],NAME_LENGTH-1);
	db->maxlevel = atoi(str[3]);
	db->foodID = atoi(str[4]);
	db->hungryDelay = atoi(str[5]);
	db->base_size = atoi(str[6]);
	db->evo_size = atoi(str[7]);
	db->race = atoi(str[8]);
	db->element = atoi(str[9]);
	db->baseASPD = atoi(str[10]);
	//base HP, SP, str, agi, vit, int, dex, luk
	db->base.HP = atoi(str[11]);
	db->base.SP = atoi(str[12]);
	db->base.str = atoi(str[13]);
	db->base.agi = atoi(str[14]);
	db->base.vit = atoi(str[15]);
	db->base.int_= atoi(str[16]);
	db->base.dex = atoi(str[17]);
	db->base.luk = atoi(str[18]);
	//Growth Min/Max HP, SP, str, agi, vit, int, dex, luk
	db->gmin.HP = atoi(str[19]);
	db->gmax.HP = atoi(str[20]);
	db->gmin.SP = atoi(str[21]);
	db->gmax.SP = atoi(str[22]);
	db->gmin.str = atoi(str[23]);
	db->gmax.str = atoi(str[24]);
	db->gmin.agi = atoi(str[25]);
	db->gmax.agi = atoi(str[26]);
	db->gmin.vit = atoi(str[27]);
	db->gmax.vit = atoi(str[28]);
	db->gmin.int_= atoi(str[29]);
	db->gmax.int_= atoi(str[30]);
	db->gmin.dex = atoi(str[31]);
	db->gmax.dex = atoi(str[32]);
	db->gmin.luk = atoi(str[33]);
	db->gmax.luk = atoi(str[34]);
	//Evolution Min/Max HP, SP, str, agi, vit, int, dex, luk
	db->emin.HP = atoi(str[35]);
	db->emax.HP = atoi(str[36]);
	db->emin.SP = atoi(str[37]);
	db->emax.SP = atoi(str[38]);
	db->emin.str = atoi(str[39]);
	db->emax.str = atoi(str[40]);
	db->emin.agi = atoi(str[41]);
	db->emax.agi = atoi(str[42]);
	db->emin.vit = atoi(str[43]);
	db->emax.vit = atoi(str[44]);
	db->emin.int_= atoi(str[45]);
	db->emax.int_= atoi(str[46]);
	db->emin.dex = atoi(str[47]);
	db->emax.dex = atoi(str[48]);
	db->emin.luk = atoi(str[49]);
	db->emax.luk = atoi(str[50]);

	//Check that the min/max values really are below the other one.
	if(db->gmin.HP > db->gmax.HP)
		db->gmin.HP = db->gmax.HP;
	if(db->gmin.SP > db->gmax.SP)
		db->gmin.SP = db->gmax.SP;
	if(db->gmin.str > db->gmax.str)
		db->gmin.str = db->gmax.str;
	if(db->gmin.agi > db->gmax.agi)
		db->gmin.agi = db->gmax.agi;
	if(db->gmin.vit > db->gmax.vit)
		db->gmin.vit = db->gmax.vit;
	if(db->gmin.int_> db->gmax.int_)
		db->gmin.int_= db->gmax.int_;
	if(db->gmin.dex > db->gmax.dex)
		db->gmin.dex = db->gmax.dex;
	if(db->gmin.luk > db->gmax.luk)
		db->gmin.luk = db->gmax.luk;

	if(db->emin.HP > db->emax.HP)
		db->emin.HP = db->emax.HP;
	if(db->emin.SP > db->emax.SP)
		db->emin.SP = db->emax.SP;
	if(db->emin.str > db->emax.str)
		db->emin.str = db->emax.str;
	if(db->emin.agi > db->emax.agi)
		db->emin.agi = db->emax.agi;
	if(db->emin.vit > db->emax.vit)
		db->emin.vit = db->emax.vit;
	if(db->emin.int_> db->emax.int_)
		db->emin.int_= db->emax.int_;
	if(db->emin.dex > db->emax.dex)
		db->emin.dex = db->emax.dex;
	if(db->emin.luk > db->emax.luk)
		db->emin.luk = db->emax.luk;

	return true;
}
Exemple #24
0
/**
 * <combo{:combo{:combo:{..}}}>,<{ script }>
 **/
void itemdb_read_combos(DBMap* item_combo_db) {
	uint32 lines = 0, count = 0;
	char line[1024];
	
	char path[256];
	FILE* fp;
	
	sprintf(path, "%s/%s", db_path, DBPATH"item_combo_db.txt");
	
	if ((fp = fopen(path, "r")) == NULL) {
		ShowError("itemdb_read_combos: File not found \"%s\".\n", path);
		return;
	}
	
	// process rows one by one
	while(fgets(line, sizeof(line), fp)) {
		char *str[2], *p;
		
		lines++;

		if (line[0] == '/' && line[1] == '/')
			continue;
		
		memset(str, 0, sizeof(str));
		
		p = line;
		
		p = trim(p);

		if (*p == '\0')
			continue;// empty line
		
		if (!strchr(p,','))
		{
			/* is there even a single column? */
			ShowError("itemdb_read_combos: Insufficient columns in line %d of \"%s\", skipping.\n", lines, path);
			continue;
		}
		
		str[0] = p;
		p = strchr(p,',');
		*p = '\0';
		p++;

		str[1] = p;
		p = strchr(p,',');		
		p++;
		
		if (str[1][0] != '{') {
			ShowError("itemdb_read_combos(#1): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, path);
			continue;
		}
		
		/* no ending key anywhere (missing \}\) */
		if ( str[1][strlen(str[1])-1] != '}' ) {
			ShowError("itemdb_read_combos(#2): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, path);
			continue;
		} else {
			int items[MAX_ITEMS_PER_COMBO];
			int v = 0, retcount = 0;
			struct item_combo * ic = NULL;
			char combo_out[2048];
			int len = 0, slen = 0;
			bool exists = false;
			
			if((retcount = itemdb_combo_split_atoi(str[0], items)) < 2) {
				ShowError("itemdb_read_combos: line %d of \"%s\" doesn't have enough items to make for a combo (min:2), skipping.\n", lines, path);
				continue;
			}
			
			if ((ic = idb_get(item_combo_db, items[0])) != NULL) {
				slen = strlen(ic->script);
				exists = true;
			} else {
				CREATE(ic, struct item_combo, 1);
			}
			
			len += sprintf(combo_out + len, "if(isequipped(");
			
			/* we skip the first for its not a required check */
			for(v = 1; v < retcount; v++) {
				len += sprintf(combo_out + len, "%d,", items[v]);
			}
			
			len += sprintf(combo_out + len - 1, "))%s", str[1]);
						
			safestrncpy(ic->script + slen, combo_out, len);
			
			if (!exists) {
				ic->nameid = items[0];
				idb_put(item_combo_db, items[0], ic);
			}
		}
		
		count++;
	}
	
	fclose(fp);
	
	ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"item_combo_db"CL_RESET"'.\n", count);
		
	return;
}
Exemple #25
0
	int sig_init() {
		ShowError("sig: This plugin is not supported!\n");
		return 0;
	}
Exemple #26
0
int merc_hom_levelup(struct homun_data *hd)
{
	struct s_homunculus *hom;
	struct h_stats *min, *max;
	int growth_str, growth_agi, growth_vit, growth_int, growth_dex, growth_luk ;
	int growth_max_hp, growth_max_sp ;
	char output[256] ;
	int m_class;

	if((m_class = hom_class2mapid(hd->homunculus.class_)) == -1) {
		ShowError("merc_hom_levelup: Invalid class %d. \n", hd->homunculus.class_);
		return 0;
	}

	if((m_class&HOM_REG) && (hd->homunculus.level >= battle_config.hom_max_level || ((m_class&HOM_S) && hd->homunculus.level >= battle_config.hom_S_max_level) || !hd->exp_next || hd->homunculus.exp < hd->exp_next))
		return 0;

	hom = &hd->homunculus;
	hom->level++ ;
	if (!(hom->level % 3))
		hom->skillpts++ ;	//1 skillpoint each 3 base level

	hom->exp -= hd->exp_next ;
	hd->exp_next = hexptbl[hom->level - 1] ;

	max  = &hd->homunculusDB->gmax;
	min  = &hd->homunculusDB->gmin;

	growth_max_hp = rnd_value(min->HP, max->HP);
	growth_max_sp = rnd_value(min->SP, max->SP);
	growth_str = rnd_value(min->str, max->str);
	growth_agi = rnd_value(min->agi, max->agi);
	growth_vit = rnd_value(min->vit, max->vit);
	growth_dex = rnd_value(min->dex, max->dex);
	growth_int = rnd_value(min->int_,max->int_);
	growth_luk = rnd_value(min->luk, max->luk);

	//Aegis discards the decimals in the stat growth values!
	growth_str-=growth_str%10;
	growth_agi-=growth_agi%10;
	growth_vit-=growth_vit%10;
	growth_dex-=growth_dex%10;
	growth_int-=growth_int%10;
	growth_luk-=growth_luk%10;

	hom->max_hp += growth_max_hp;
	hom->max_sp += growth_max_sp;
	hom->str += growth_str;
	hom->agi += growth_agi;
	hom->vit += growth_vit;
	hom->dex += growth_dex;
	hom->int_+= growth_int;
	hom->luk += growth_luk;

	if ( battle_config.homunculus_show_growth ) {
		sprintf(output,
			"Growth: hp:%d sp:%d str(%.2f) agi(%.2f) vit(%.2f) int(%.2f) dex(%.2f) luk(%.2f) ",
			growth_max_hp, growth_max_sp,
			growth_str/10.0, growth_agi/10.0, growth_vit/10.0,
			growth_int/10.0, growth_dex/10.0, growth_luk/10.0);
		clif_disp_onlyself(hd->master,output,strlen(output));
	}
	return 1 ;
}
Exemple #27
0
void* _mmalloc(size_t size, const char *file, int line, const char *func )
{
	struct block *block;
	short size_hash = size2hash( size );
	struct unit_head *head;

	if (((long) size) < 0) {
		ShowError("_mmalloc: %d\n", size);
		return 0;
	}

	if(size == 0) {
		return NULL;
	}
	memmgr_usage_bytes += size;

	/* ブロック長を超える領域の確保には、malloc() を用いる */
	/* その際、unit_head.block に NULL を代入して区別する */
	if(hash2size(size_hash) > BLOCK_DATA_SIZE - sizeof(struct unit_head)) {
		struct unit_head_large* p = (struct unit_head_large*)MALLOC(sizeof(struct unit_head_large)+size,file,line,func);
		if(p != NULL) {
			p->size            = size;
			p->unit_head.block = NULL;
			p->unit_head.size  = 0;
			p->unit_head.file  = file;
			p->unit_head.line  = line;
			p->prev = NULL;
			if (unit_head_large_first == NULL)
				p->next = NULL;
			else {
				unit_head_large_first->prev = p;
				p->next = unit_head_large_first;
			}
			unit_head_large_first = p;
			*(long*)((char*)p + sizeof(struct unit_head_large) - sizeof(long) + size) = 0xdeadbeaf;
			return (char *)p + sizeof(struct unit_head_large) - sizeof(long);
		} else {
			ShowFatalError("Memory manager::memmgr_alloc failed (allocating %d+%d bytes at %s:%d).\n", sizeof(struct unit_head_large), size, file, line);
			exit(EXIT_FAILURE);
		}
	}

	/* 同一サイズのブロックが確保されていない時、新たに確保する */
	if(hash_unfill[size_hash]) {
		block = hash_unfill[size_hash];
	} else {
		block = block_malloc(size_hash);
	}

	if( block->unit_unfill == 0xFFFF ) {
		// free済み領域が残っていない
		memmgr_assert(block->unit_used <  block->unit_count);
		memmgr_assert(block->unit_used == block->unit_maxused);
		head = block2unit(block, block->unit_maxused);
		block->unit_used++;
		block->unit_maxused++;
	} else {
		head = block2unit(block, block->unit_unfill);
		block->unit_unfill = head->size;
		block->unit_used++;
	}

	if( block->unit_unfill == 0xFFFF && block->unit_maxused >= block->unit_count) {
		// ユニットを使い果たしたので、unfillリストから削除
		if( block->unfill_prev == &block_head) {
			hash_unfill[ size_hash ] = block->unfill_next;
		} else {
			block->unfill_prev->unfill_next = block->unfill_next;
		}
		if( block->unfill_next ) {
			block->unfill_next->unfill_prev = block->unfill_prev;
		}
		block->unfill_prev = NULL;
	}

#ifdef DEBUG_MEMMGR
	{
		size_t i, sz = hash2size( size_hash );
		for( i=0; i<sz; i++ )
		{
			if( ((unsigned char*)head)[ sizeof(struct unit_head) - sizeof(long) + i] != 0xfd )
			{
				if( head->line != 0xfdfd )
				{
					ShowError("Memory manager: freed-data is changed. (freed in %s line %d)\n", head->file,head->line);
				}
				else
				{
					ShowError("Memory manager: not-allocated-data is changed.\n");
				}
				break;
			}
		}
		memset( (char *)head + sizeof(struct unit_head) - sizeof(long), 0xcd, sz );
	}
#endif

	head->block = block;
	head->file  = file;
	head->line  = line;
	head->size  = (unsigned short)size;
	*(long*)((char*)head + sizeof(struct unit_head) - sizeof(long) + size) = 0xdeadbeaf;
	return (char *)head + sizeof(struct unit_head) - sizeof(long);
};
Exemple #28
0
/*--------------------------------------
 * name : instance name
 * Return value could be
 * -4 = already exists | -3 = no free instances | -2 = owner not found | -1 = invalid type
 * On success return instance_id
 *--------------------------------------*/
int instance_create(int owner_id, const char *name, enum instance_owner_type type) {
	struct map_session_data *sd = NULL;
	unsigned short *icptr = NULL;
	struct party_data *p = NULL;
	struct guild *g = NULL;
	short *iptr = NULL;
	int i;
	
	switch ( type ) {
		case IOT_NONE:
			break;
		case IOT_CHAR:
			if( ( sd = map->id2sd(owner_id) ) == NULL ) {
				ShowError("instance_create: character %d not found for instance '%s'.\n", owner_id, name);
				return -2;
			}
			iptr = sd->instance;
			icptr = &sd->instances;
			break;
		case IOT_PARTY:
			if( ( p = party->search(owner_id) ) == NULL ) {
				ShowError("instance_create: party %d not found for instance '%s'.\n", owner_id, name);
				return -2;
			}
			iptr = p->instance;
			icptr = &p->instances;
			break;
		case IOT_GUILD:
			if( ( g = guild->search(owner_id) ) == NULL ) {
				ShowError("instance_create: guild %d not found for instance '%s'.\n", owner_id, name);
				return -2;
			}
			iptr = g->instance;
			icptr = &g->instances;
			break;
		default:
			ShowError("instance_create: unknown type %d for owner_id %d and name %s.\n", type,owner_id,name);
			return -1;
	}
	
	if( type != IOT_NONE && *icptr ) {
		ARR_FIND(0, *icptr, i, strcmp(instance->list[iptr[i]].name,name) == 0 );
		if( i != *icptr )
			return -4;/* already got this instance */
	}
		
	ARR_FIND(0, instance->instances, i, instance->list[i].state == INSTANCE_FREE);
		
	if( i == instance->instances )
		RECREATE(instance->list, struct instance_data, ++instance->instances);

	instance->list[i].state = INSTANCE_IDLE;
	instance->list[i].id = i;
	instance->list[i].idle_timer = INVALID_TIMER;
	instance->list[i].idle_timeout = instance->list[i].idle_timeoutval = 0;
	instance->list[i].progress_timer = INVALID_TIMER;
	instance->list[i].progress_timeout = 0;
	instance->list[i].users = 0;
	instance->list[i].map = NULL;
	instance->list[i].num_map = 0;
	instance->list[i].owner_id = owner_id;
	instance->list[i].owner_type = type;
	instance->list[i].regs.vars = i64db_alloc(DB_OPT_RELEASE_DATA);
	instance->list[i].regs.arrays = NULL;
	instance->list[i].respawn.map = 0;
	instance->list[i].respawn.y = 0;
	instance->list[i].respawn.x = 0;
	
	safestrncpy( instance->list[i].name, name, sizeof(instance->list[i].name) );
	
	if( type != IOT_NONE ) {
		int j;
		ARR_FIND(0, *icptr, j, iptr[j] == -1);
		if (j == *icptr) {
			switch( type ) {
				case IOT_CHAR:
					RECREATE(sd->instance, short, ++*icptr);
					sd->instance[sd->instances-1] = i;
					break;
				case IOT_PARTY:
					RECREATE(p->instance, short, ++*icptr);
					p->instance[p->instances-1] = i;
					break;
				case IOT_GUILD:
					RECREATE(g->instance, short, ++*icptr);
					g->instance[g->instances-1] = i;
					break;
			}
		} else {
Exemple #29
0
	void params(DWORD This, DWORD OutClass, char* name, DWORD index, char* handle_string)
	{
		{
			locvar::guard _tmp_guard_((0x10000 | (int)CC_GUIID_YDWETimerStartMultiple), name, handle_string);

			DWORD nItemCount, i;
			DWORD nItemClass;
			char NewName[260];
			nItemCount = *(DWORD*)(This+0xC);

			for (i = 0; i < nItemCount; i++)
			{
				nItemClass = ((DWORD*)(*(DWORD*)(This+0x10)))[i];
				if (*(DWORD*)(nItemClass+0x13C) != 0)
				{
					if ((index) == -1 || (*(DWORD*)(nItemClass+0x154) == index))
					{  
						switch (*(DWORD*)(nItemClass+0x138))
						{
						case CC_GUIID_YDWESetAnyTypeLocalVariable:
							{
								BLZSStrPrintf(NewName, 260, "%sFunc%03d", name, i+1);
								locvar::set(nItemClass, OutClass, NewName);
								break; 
							}
						case CC_GUIID_YDWETimerStartMultiple:
						case CC_GUIID_YDWERegisterTriggerMultiple:
							ShowError(OutClass, "WESTRING_ERROR_YDTRIGGER_ILLEGAL_PARAMETER");
							break;
						default:
							{
								CC_PutAction(nItemClass, OutClass, name, i, 0);
							}
							break;
						}
					}
				}
			}
		}

		for each (auto it in register_var[name])
		{
			auto uiit = trigger_data_ui.find(it.first);
			if (uiit == trigger_data_ui.end())
			{
				locvar::do_set(OutClass, it.second.c_str(), it.first.c_str()
					, state(CC_GUIID_YDWETimerStartMultiple, name, handle_string)
					, [&]()
					{
						locvar::do_get(OutClass, it.second.c_str(), it.first.c_str(), global); 
					}
				);
			}
			else
			{
				locvar::do_set(OutClass, it.second.c_str(), it.first.c_str()
					, state(CC_GUIID_YDWETimerStartMultiple, name, handle_string)
					, [&]()
					{ 
						PUT_CONST(it.first.c_str(), 0);
						PUT_CONST("()", 0);
					}
				);
			}
		}
Exemple #30
0
int log_config_read(const char* cfgName)
{
	static int count = 0;
	char line[1024], w1[1024], w2[1024];
	FILE *fp;

	if( count++ == 0 )
		log_set_defaults();

	if( ( fp = fopen(cfgName, "r") ) == NULL )
	{
		ShowError("Log configuration file not found at: %s\n", cfgName);
		return 1;
	}

	while( fgets(line, sizeof(line), fp) )
	{
		if( line[0] == '/' && line[1] == '/' )
			continue;

		if( sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2 )
		{
			if( strcmpi(w1, "enable_logs") == 0 )
				log_config.enable_logs = (e_log_pick_type)config_switch(w2);
			else if( strcmpi(w1, "sql_logs") == 0 )
				log_config.sql_logs = (bool)config_switch(w2);
//start of common filter settings
			else if( strcmpi(w1, "rare_items_log") == 0 )
				log_config.rare_items_log = atoi(w2);
			else if( strcmpi(w1, "refine_items_log") == 0 )
				log_config.refine_items_log = atoi(w2);
			else if( strcmpi(w1, "price_items_log") == 0 )
				log_config.price_items_log = atoi(w2);
			else if( strcmpi(w1, "amount_items_log") == 0 )
				log_config.amount_items_log = atoi(w2);
//end of common filter settings
			else if( strcmpi(w1, "log_branch") == 0 )
				log_config.branch = config_switch(w2);
			else if( strcmpi(w1, "log_filter") == 0 )
				log_config.filter = config_switch(w2);
			else if( strcmpi(w1, "log_zeny") == 0 )
				log_config.zeny = config_switch(w2);
			else if( strcmpi(w1, "log_commands") == 0 )
				log_config.commands = config_switch(w2);
			else if( strcmpi(w1, "log_npc") == 0 )
				log_config.npc = config_switch(w2);
			else if( strcmpi(w1, "log_chat") == 0 )
				log_config.chat = config_switch(w2);
			else if( strcmpi(w1, "log_mvpdrop") == 0 )
				log_config.mvpdrop = config_switch(w2);
			else if( strcmpi(w1, "log_chat_woe_disable") == 0 )
				log_config.log_chat_woe_disable = (bool)config_switch(w2);
			else if( strcmpi(w1, "log_branch_db") == 0 )
				safestrncpy(log_config.log_branch, w2, sizeof(log_config.log_branch));
			else if( strcmpi(w1, "log_pick_db") == 0 )
				safestrncpy(log_config.log_pick, w2, sizeof(log_config.log_pick));
			else if( strcmpi(w1, "log_zeny_db") == 0 )
				safestrncpy(log_config.log_zeny, w2, sizeof(log_config.log_zeny));
			else if( strcmpi(w1, "log_mvpdrop_db") == 0 )
				safestrncpy(log_config.log_mvpdrop, w2, sizeof(log_config.log_mvpdrop));
			else if( strcmpi(w1, "log_gm_db") == 0 )
				safestrncpy(log_config.log_gm, w2, sizeof(log_config.log_gm));
			else if( strcmpi(w1, "log_npc_db") == 0 )
				safestrncpy(log_config.log_npc, w2, sizeof(log_config.log_npc));
			else if( strcmpi(w1, "log_chat_db") == 0 )
				safestrncpy(log_config.log_chat, w2, sizeof(log_config.log_chat));
			//support the import command, just like any other config
			else if( strcmpi(w1,"import") == 0 )
				log_config_read(w2);
		}
	}

	fclose(fp);

	if( --count == 0 )
	{// report final logging state
		const char* target = log_config.sql_logs ? "table" : "file";

		if( log_config.enable_logs && log_config.filter )
		{
			ShowInfo("Logging item transactions to %s '%s'.\n", target, log_config.log_pick);
		}
		if( log_config.branch )
		{
			ShowInfo("Logging monster summon item usage to %s '%s'.\n", target, log_config.log_pick);
		}
		if( log_config.chat )
		{
			ShowInfo("Logging chat to %s '%s'.\n", target, log_config.log_chat);
		}
		if( log_config.commands )
		{
			ShowInfo("Logging commands to %s '%s'.\n", target, log_config.log_gm);
		}
		if( log_config.mvpdrop )
		{
			ShowInfo("Logging MVP monster rewards to %s '%s'.\n", target, log_config.log_mvpdrop);
		}
		if( log_config.npc )
		{
			ShowInfo("Logging 'logmes' messages to %s '%s'.\n", target, log_config.log_npc);
		}
		if( log_config.zeny )
		{
			ShowInfo("Logging Zeny transactions to %s '%s'.\n", target, log_config.log_zeny);
		}
	}

	return 0;
}