Пример #1
0
bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele)
{
	char *data;

	memset(ele, 0, sizeof(struct s_elemental));
	ele->elemental_id = ele_id;
	ele->char_id = char_id;

	if(SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `atk1`, `atk2`, `matk`, `aspd`,"
	                          "`def`, `mdef`, `flee`, `hit`, `life_time` FROM `elemental` WHERE `ele_id` = '%d' AND `char_id` = '%d'",
	                          ele_id, char_id)) {
		Sql_ShowDebug(sql_handle);
		return false;
	}

	if(SQL_SUCCESS != Sql_NextRow(sql_handle)) {
		Sql_FreeResult(sql_handle);
		return false;
	}

	Sql_GetData(sql_handle,  0, &data, NULL); ele->class_ = atoi(data);
	Sql_GetData(sql_handle,  1, &data, NULL); ele->mode = atoi(data);
	Sql_GetData(sql_handle,  2, &data, NULL); ele->hp = atoi(data);
	Sql_GetData(sql_handle,  3, &data, NULL); ele->sp = atoi(data);
	Sql_GetData(sql_handle,  4, &data, NULL); ele->max_hp = atoi(data);
	Sql_GetData(sql_handle,  5, &data, NULL); ele->max_sp = atoi(data);
	Sql_GetData(sql_handle,  6, &data, NULL); ele->atk = atoi(data);
	Sql_GetData(sql_handle,  7, &data, NULL); ele->atk2 = atoi(data);
	Sql_GetData(sql_handle,  8, &data, NULL); ele->matk = atoi(data);
	Sql_GetData(sql_handle,  9, &data, NULL); ele->amotion = atoi(data);
	Sql_GetData(sql_handle, 10, &data, NULL); ele->def = atoi(data);
	Sql_GetData(sql_handle, 11, &data, NULL); ele->mdef = atoi(data);
	Sql_GetData(sql_handle, 12, &data, NULL); ele->flee = atoi(data);
	Sql_GetData(sql_handle, 13, &data, NULL); ele->hit = atoi(data);
	Sql_GetData(sql_handle, 14, &data, NULL); ele->life_time = atoi(data);
	Sql_FreeResult(sql_handle);
	if(save_log)
		ShowInfo(read_message("Source.char.elemental_load"), ele->elemental_id, ele->char_id);

	return true;
}
Пример #2
0
/*--------------------------------------
 * name : instance name
 * Return value could be
 * -4 = already exists | -3 = no free instances | -2 = party not found | -1 = invalid type
 * On success return instance_id
 *--------------------------------------*/
int instance_create(int party_id, const char *name)
{
	int i;
	struct party_data* p;

	if( ( p = party_search(party_id) ) == NULL )
	{
		ShowError("instance_create: party %d not found for instance '%s'.\n", party_id, name);
		return -2;
	}

	if( p->instance_id )
		return -4; // Party already instancing

	// Searching a Free Instance
	// 0 is ignored as this mean "no instance" on maps
	ARR_FIND(1, MAX_INSTANCE, i, instance[i].state == INSTANCE_FREE);
	if( i == MAX_INSTANCE )
	{
		ShowError("instance_create: no free instances, consider increasing MAX_INSTANCE.\n");
		return -3;
	}

	instance[i].state = INSTANCE_IDLE;
	instance[i].instance_id = i;
	instance[i].idle_timer = INVALID_TIMER;
	instance[i].idle_timeout = instance[i].idle_timeoutval = 0;
	instance[i].progress_timer = INVALID_TIMER;
	instance[i].progress_timeout = 0;
	instance[i].users = 0;
	instance[i].party_id = party_id;
	instance[i].vars = idb_alloc(DB_OPT_RELEASE_DATA);

	safestrncpy( instance[i].name, name, sizeof(instance[i].name) );
	memset( instance[i].map, 0x00, sizeof(instance[i].map) );
	p->instance_id = i;

	clif_instance(i, 1, 0); // Start instancing window
	ShowInfo("[Instance] Created: %s.\n", name);
	return i;
}
Пример #3
0
static bool harmony_iterate_groups_adminlevel(int group_id, int level, const char* name) {
	int account_id;

	if (level < current_groupscan_minlevel)
		return true;

	ShowInfo("Registering group %d..\n", group_id);
	if (SQL_SUCCESS != SqlStmt_BindParam(admin_stmt, 0, SQLDT_INT, (void*)&group_id, sizeof(group_id)) ||
		SQL_SUCCESS != SqlStmt_Execute(admin_stmt))
	{
		ShowError("Fetching GM accounts from group %d failed.\n", group_id);
		Sql_ShowDebug(mmysql_handle);
		return true;
	}

	SqlStmt_BindColumn(admin_stmt, 0, SQLDT_INT, &account_id, 0, NULL, NULL);
	while (SQL_SUCCESS == SqlStmt_NextRow(admin_stmt)) {
		harm_funcs->zone_register_admin(account_id, false);
	}
	return true;
}
Пример #4
0
// Create a party whether or not
int mapif_party_created(int fd, int account_id, int char_id, struct party *p)
{
	nullpo_ret(p);
	WFIFOHEAD(fd, 39);
	WFIFOW(fd,0)=0x3820;
	WFIFOL(fd,2)=account_id;
	WFIFOL(fd,6)=char_id;
	if(p!=NULL){
		WFIFOB(fd,10)=0;
		WFIFOL(fd,11)=p->party_id;
		memcpy(WFIFOP(fd,15),p->name,NAME_LENGTH);
		ShowInfo("int_party: Party created (%d - %s)\n",p->party_id,p->name);
	}else{
		WFIFOB(fd,10)=1;
		WFIFOL(fd,11)=0;
		memset(WFIFOP(fd,15),0,NAME_LENGTH);
	}
	WFIFOSET(fd,39);

	return 0;
}
Пример #5
0
/**
 * Create a channel
 * - Will then add it in the channel_db if the type is not map or ally
 * @param name: Channel name, can't be null
 * @param pass: Channel password, can be null
 * @param color: Display color
 * @param chantype: Channel type
 * @return NULL on failure or Channel on success
 */
struct Channel* channel_create(struct Channel *tmp_chan) {
	struct Channel* channel;

	if (!tmp_chan->name[0])
		return NULL;

	CREATE(channel, struct Channel, 1); //will exit on fail allocation
	//channel->id = tmp_chan->id;
	channel->users = idb_alloc(DB_OPT_BASE);
	channel->banned = idb_alloc(static_cast<DBOptions>(DB_OPT_BASE|DB_OPT_RELEASE_DATA) );
	channel->opt = tmp_chan->opt;
	channel->type = tmp_chan->type;
	channel->color = tmp_chan->color;
	safestrncpy(channel->name, tmp_chan->name, CHAN_NAME_LENGTH); // Store channel cname without '#'
	safestrncpy(channel->alias, tmp_chan->alias[0] ? tmp_chan->alias : tmp_chan->name, CHAN_NAME_LENGTH);
	if (!tmp_chan->pass[0])
		channel->pass[0] = '\0';
	else
		safestrncpy(channel->pass, tmp_chan->pass, CHAN_NAME_LENGTH);
	channel->msg_delay = tmp_chan->msg_delay;

	switch (channel->type) {
		case CHAN_TYPE_MAP:
			channel->m = tmp_chan->m;
			break;
		case CHAN_TYPE_ALLY:
			channel->gid = tmp_chan->gid;
			break;
		case CHAN_TYPE_PRIVATE:
			channel->char_id = tmp_chan->char_id;
		default:
			strdb_put(channel_db, channel->name, channel);
			break;
	}

	if (battle_config.etc_log)
		ShowInfo("Create channel %s alias %s type=%d, owner=%d/%d/%d\n",channel->name,channel->alias,channel->type,channel->char_id,channel->m,channel->gid);

	return channel;
}
Пример #6
0
eOSState cSatipPluginSetup::ProcessKey(eKeys keyP)
{
  bool hadSubMenu = HasSubMenu();
  int oldOperatingMode = operatingModeM;
  int oldCiExtension = ciExtensionM;
  int oldNumDisabledSources = numDisabledSourcesM;
  int oldNumDisabledFilters = numDisabledFiltersM;
  eOSState state = cMenuSetupPage::ProcessKey(keyP);

  // Ugly hack with hardcoded '+/-' characters :(
  const char *p = Get(Current())->Text();
  if (!hadSubMenu && !HasSubMenu() && p && (*p == '+' || *p == '-') && (keyP == kOk))
     return DeviceInfo();
  if (hadSubMenu && !HasSubMenu())
     Setup();

  if (state == osUnknown) {
     switch (keyP) {
       case kRed:    return DeviceScan();
       case kYellow: return ShowDeviceStatus();
       case kBlue:   return ShowInfo();
       case kInfo:   if (Current() < helpM.Size())
                        return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), helpM[Current()]));
       default:      state = osContinue; break;
       }
     }

  if ((keyP == kNone) && (cSatipDiscover::GetInstance()->GetServers()->Count() != deviceCountM))
     Setup();

  if ((keyP != kNone) && ((numDisabledSourcesM != oldNumDisabledSources) || (numDisabledFiltersM != oldNumDisabledFilters) || (operatingModeM != oldOperatingMode) || (ciExtensionM != oldCiExtension) || (detachedModeM != SatipConfig.GetDetachedMode()))) {
     while ((numDisabledSourcesM < oldNumDisabledSources) && (oldNumDisabledSources > 0))
           disabledSourcesM[--oldNumDisabledSources] = cSource::stNone;
     while ((numDisabledFiltersM < oldNumDisabledFilters) && (oldNumDisabledFilters > 0))
           disabledFilterIndexesM[--oldNumDisabledFilters] = -1;
     Setup();
     }

  return state;
}
Пример #7
0
bool Lua::LoadScriptFromFile(const std::string& filename, bool useGlue)
{
    m_filename = filename;

    // TODO Use glue file if required
    int r = luaL_loadfile(m_pL, filename.c_str());

    if (r == 0)
    {
        // Need to do this before we can call any functions in the file.
        lua_call(m_pL, 0, 0);
        if (ShowInfo())
        {
            std::cout << "LUA: c++: Loaded lua file " << filename << " OK\n";
        }
    }
    else
    {
        std::string error = "LUA: c++: Loading lua file \"" + filename +
                            "\" failed: Code " + ToString(r) + ": " + lua_tostring(m_pL, -1);
        ReportError(error);
    }

    return (r == 0);


    // TODO use Amju::File
    bool NOVERSIONINFO = false;
    File f(NOVERSIONINFO, useGlue ? File::GLUE : File::STD);
    if (!f.OpenRead(filename)) // TODO binary ? use Root Dir ?
    {
        f.ReportError("Failed to open Lua script file.");
        return false;
    }
    // Load the whole file into memory if not a glue file.
    // If a glue file, it's in memory already, but we need the start and length.


    return false;
}
Пример #8
0
/* 現在の状況を表示する */
static void memmgr_info(void) {
	int i;
	struct block *p;
	ShowInfo("** Informacao da administracao de memoria **\n");
	if(block_first == NULL) {
		ShowMessage("Nao inicializado.\n");
		return;
	}
	ShowMessage(
		"Blocos: %04u , Tamanho do Bloco: %06u Byte , Usado: %08uKB\n",
		block_last->block_no+1,sizeof(struct block),
		(block_last->block_no+1) * sizeof(struct block) / 1024
	);
	p = block_first;
	for(i=0;i<=block_last->block_no;i++) {
		ShowMessage("    Bloco #%04u : ",p->block_no);
		if(p->unit_size == 0) {
			ShowMessage("nao unsado.\n");
		} else {
			ShowMessage(
				"tamanho: %05u byte. usado: %04u/%04u prev:",
				p->unit_size - sizeof(struct unit_head),p->unit_used,p->unit_count
			);
			if(p->samesize_prev == NULL) {
				ShowMessage("NULO");
			} else {
				ShowMessage("%04u",(p->samesize_prev)->block_no);
			}
			ShowMessage(" next:");
			if(p->samesize_next == NULL) {
				ShowMessage("NULO");
			} else {
				ShowMessage("%04u",(p->samesize_next)->block_no);
			}
			ShowMessage("\n");
		}
		p = p->block_next;
	}
}
Пример #9
0
/*==========================================
 * Read Message Data
 *------------------------------------------*/
int _msg_config_read(const char* cfgName,int size, char ** msg_table)
{
    int msg_number;
    char line[1024], w1[1024], w2[1024];
    FILE *fp;
    static int called = 1;

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

    if ((--called) == 0)
	memset(msg_table, 0, sizeof (msg_table[0]) * size);

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

	if (strcmpi(w1, "import") == 0)
	    _msg_config_read(w2,size,msg_table);
	else {
	    msg_number = atoi(w1);
	    if (msg_number >= 0 && msg_number < size) {
		if (msg_table[msg_number] != NULL)
		    aFree(msg_table[msg_number]);
		msg_table[msg_number] = (char *) aMalloc((strlen(w2) + 1) * sizeof (char));
		strcpy(msg_table[msg_number], w2);
	    }
	}
    }

    fclose(fp);
    ShowInfo("Finished reading %s.\n",cfgName);

    return 0;
}
Пример #10
0
  void CPVRGUIChannelNavigator::SetPlayingChannel(const CPVRChannelPtr channel)
  {
    CFileItemPtr item;

    if (channel)
    {
      CSingleLock lock(m_critSection);

      m_playingChannel = channel;
      if (m_currentChannel != m_playingChannel)
      {
        m_currentChannel = m_playingChannel;
        if (m_playingChannel)
          item.reset(new CFileItem(m_playingChannel));
      }
    }

    if (item)
      CServiceBroker::GetGUI()->GetInfoManager().SetCurrentItem(*item);

    ShowInfo(false);
  }
Пример #11
0
/**
 * Saves a pet to the SQL database.
 *
 * @remark
 *   In case of newly created pet, the pet ID is not updated to reflect the
 *   newly assigned ID.  The caller must do so.
 *
 * @param p The pet data to save.
 * @return The ID of the saved pet.
 * @retval 0 in case of errors.
 */
int inter_pet_tosql(const struct s_pet *p)
{
	//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`)
	char esc_name[NAME_LENGTH*2+1];// escaped pet name
	int pet_id = 0, hungry = 0, intimate = 0;

	nullpo_ret(p);

	SQL->EscapeStringLen(inter->sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
	hungry = cap_value(p->hungry, 0, 100);
	intimate = cap_value(p->intimate, 0, 1000);

	if (p->pet_id == 0) {
		// New pet.
		if (SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` "
				"(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`) "
				"VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
				pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
				p->equip, intimate, hungry, p->rename_flag, p->incubate)) {
			Sql_ShowDebug(inter->sql_handle);
			return 0;
		}
		pet_id = (int)SQL->LastInsertId(inter->sql_handle);
	} else {
		// Update pet.
		if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incubate`='%d' WHERE `pet_id`='%d'",
				pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
				p->equip, intimate, hungry, p->rename_flag, p->incubate, p->pet_id)) {
			Sql_ShowDebug(inter->sql_handle);
			return 0;
		}
		pet_id = p->pet_id;
	}

	if (save_log)
		ShowInfo("Pet saved %d - %s.\n", pet_id, p->name);

	return pet_id;
}
Пример #12
0
/*======================================
 *	CORE : Display title
 *--------------------------------------*/
static void display_title(void)
{
	//ClearScreen(); // clear screen and go up/left (0, 0 position in text)
	ShowMessage("\n");
	ShowMessage(""CL_WTBL"          (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BT_YELLOW"            eAthena Development Team presents            "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"       ______  __    __                                  "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"      /\\  _  \\/\\ \\__/\\ \\                                 "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"    __\\ \\ \\_\\ \\ \\ ,_\\ \\ \\___      __    ___      __      "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"  /'__`\\ \\  __ \\ \\ \\/\\ \\  _ `\\  /'__`\\/' _ `\\  /'__`\\    "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD" /\\  __/\\ \\ \\/\\ \\ \\ \\_\\ \\ \\ \\ \\/\\  __//\\ \\/\\ \\/\\ \\_\\.\\_  "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD" \\ \\____\\\\ \\_\\ \\_\\ \\__\\\\ \\_\\ \\_\\ \\____\\ \\_\\ \\_\\ \\__/.\\_\\ "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"  \\/____/ \\/_/\\/_/\\/__/ \\/_/\\/_/\\/____/\\/_/\\/_/\\/__/\\/_/ "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"   _   _   _   _   _   _   _     _   _   _   _   _   _   "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"  / \\ / \\ / \\ / \\ / \\ / \\ / \\   / \\ / \\ / \\ / \\ / \\ / \\  "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD" ( e | n | g | l | i | s | h ) ( A | t | h | e | n | a ) "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"  \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/   \\_/ \\_/ \\_/ \\_/ \\_/ \\_/  "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"                                                         "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_WTBL"          (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)"CL_CLL""CL_NORMAL"\n\n");

	ShowInfo("SVN Revision: '"CL_WHITE"%s"CL_RESET"'.\n", get_svn_revision());
}
Пример #13
0
bool mapif_elemental_load (int ele_id, int char_id, struct s_elemental *ele)
{
	char *data;
	memset (ele, 0, sizeof (struct s_elemental));
	ele->elemental_id = ele_id;
	ele->char_id = char_id;

	if (SQL_ERROR == Sql_Query (sql_handle, "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `str`, `agi`, `vit`, `int`, `dex`,"
								"`luk`, `life_time` FROM `elemental` WHERE `ele_id` = '%d' AND `char_id` = '%d'",
								ele_id, char_id)) {
		Sql_ShowDebug (sql_handle);
		return false;
	}

	if (SQL_SUCCESS != Sql_NextRow (sql_handle)) {
		Sql_FreeResult (sql_handle);
		return false;
	}

	Sql_GetData (sql_handle,  0, &data, NULL); ele->class_ = atoi (data);
	Sql_GetData (sql_handle,  1, &data, NULL); ele->mode = atoi (data);
	Sql_GetData (sql_handle,  2, &data, NULL); ele->hp = atoi (data);
	Sql_GetData (sql_handle,  3, &data, NULL); ele->sp = atoi (data);
	Sql_GetData (sql_handle,  4, &data, NULL); ele->max_hp = atoi (data);
	Sql_GetData (sql_handle,  5, &data, NULL); ele->max_sp = atoi (data);
	Sql_GetData (sql_handle,  6, &data, NULL); ele->str = atoi (data);
	Sql_GetData (sql_handle,  7, &data, NULL); ele->agi = atoi (data);
	Sql_GetData (sql_handle,  8, &data, NULL); ele->vit = atoi (data);
	Sql_GetData (sql_handle,  9, &data, NULL); ele->int_ = atoi (data);
	Sql_GetData (sql_handle, 10, &data, NULL); ele->dex = atoi (data);
	Sql_GetData (sql_handle, 11, &data, NULL); ele->luk = atoi (data);
	Sql_GetData (sql_handle, 12, &data, NULL); ele->life_time = atoi (data);
	Sql_FreeResult (sql_handle);

	if (save_log)
		ShowInfo ("Elemental carregado (%d - %d).\n", ele->elemental_id, ele->char_id);

	return true;
}
Пример #14
0
int chrif_recvfamelist(int fd) {
	int num, size;
	int total = 0, len = 8;

	memset (smith_fame_list, 0, sizeof(smith_fame_list));
	memset (chemist_fame_list, 0, sizeof(chemist_fame_list));
	memset (taekwon_fame_list, 0, sizeof(taekwon_fame_list));

	size = RFIFOW(fd, 6); //Blacksmith block size
	
	for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
		memcpy(&smith_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
 		len += sizeof(struct fame_list);
	}
	
	total += num;

	size = RFIFOW(fd, 4); //Alchemist block size
	
	for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
		memcpy(&chemist_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
 		len += sizeof(struct fame_list);
	}
	
	total += num;

	size = RFIFOW(fd, 2); //Total packet length
	
	for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
		memcpy(&taekwon_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
 		len += sizeof(struct fame_list);
	}
	
	total += num;

	ShowInfo("Received Fame List of '"CL_WHITE"%d"CL_RESET"' characters.\n", total);

	return 0;
}
Пример #15
0
/**
 * This can still happen (client times out while waiting for char to confirm auth data)
 * @see DBApply
 */
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
	struct auth_node *node = DB->data2ptr(data);
	const char* states[] = { "Login", "Logout", "Map change" };
	
	if(DIFF_TICK(gettick(),node->node_created)>60000) {
		switch (node->state) {
			case ST_LOGOUT:
				//Re-save attempt (->sd should never be null here).
				node->node_created = gettick(); //Refresh tick (avoid char-server load if connection is really bad)
				chrif_save(node->sd, 1);
				break;
			default:
				//Clear data. any connected players should have timed out by now.
				ShowInfo("auth_db: Node (state %s) timed out for %d:%d\n", states[node->state], node->account_id, node->char_id);
				chrif_char_offline_nsd(node->account_id, node->char_id);
				chrif_auth_delete(node->account_id, node->char_id, node->state);
				break;
		}
		return 1;
	}
	return 0;
}
Пример #16
0
static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data)
{
	struct auction_data *auction;
	if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL )
	{
		if( auction->buyer_id )
		{
			mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Thanks, you won the auction!.", 0, &auction->item);
			mapif_Auction_message(auction->buyer_id, 6); // You have won the auction
			mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->price, NULL);
		}
		else
			mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "No buyers have been found for your auction.", 0, &auction->item);
		
		ShowInfo("Auction End: id %u.\n", auction->auction_id);

		auction->auction_end_timer = INVALID_TIMER;
		auction_delete(auction);
	}

	return 0;
}
Пример #17
0
/* 現在の状況を表示する */
static void memmgr_info(void) {
	int i;
	struct block *p;
	ShowInfo("** Memory Manager Information **\n");
	if(block_first == NULL) {
		ShowMessage("Uninitialized.\n");
		return;
	}
	ShowMessage(
		"Blocks: %04u , BlockSize: %06u Byte , Used: %08uKB\n",
		block_last->block_no+1,sizeof(struct block),
		(block_last->block_no+1) * sizeof(struct block) / 1024
	);
	p = block_first;
	for(i=0;i<=block_last->block_no;i++) {
		ShowMessage("    Block #%04u : ",p->block_no);
		if(p->unit_size == 0) {
			ShowMessage("unused.\n");
		} else {
			ShowMessage(
				"size: %05u byte. used: %04u/%04u prev:",
				p->unit_size - sizeof(struct unit_head),p->unit_used,p->unit_count
			);
			if(p->samesize_prev == NULL) {
				ShowMessage("NULL");
			} else {
				ShowMessage("%04u",(p->samesize_prev)->block_no);
			}
			ShowMessage(" next:");
			if(p->samesize_next == NULL) {
				ShowMessage("NULL");
			} else {
				ShowMessage("%04u",(p->samesize_next)->block_no);
			}
			ShowMessage("\n");
		}
		p = p->block_next;
	}
}
Пример #18
0
static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data)
{
	struct auction_data *auction;
	if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL )
	{
		if( auction->buyer_id )
		{
			mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(202), 0, &auction->item);
			mapif_Auction_message(auction->buyer_id, 6); // You have won the auction
			mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(203), auction->price, NULL);
		}
		else
			mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(204), 0, &auction->item);

		ShowInfo("Auction End: id %u.\n", auction->auction_id);

		auction->auction_end_timer = INVALID_TIMER;
		auction_delete(auction);
	}

	return 0;
}
Пример #19
0
/**
 * Delete a channel
 * - Checks if there is any user in channel and make them quit
 * @param channel: Channel data
 * @param force: Forcefully remove channel
 * @return
 *   0: Success
 *  -1: Invalid channel
 *  -2: Can't delete now
 */
int channel_delete(struct Channel *channel, bool force) {
	if(!channel)
		return -1;
	if(!force && channel->type == CHAN_TYPE_PUBLIC && runflag == MAPSERVER_ST_RUNNING) //only delete those serv stop
		return -2;
	if( db_size(channel->users)) {
		struct map_session_data *sd;
		DBIterator *iter = db_iterator(channel->users);
		for( sd = (struct map_session_data *)dbi_first(iter); dbi_exists(iter); sd = (struct map_session_data *)dbi_next(iter) ) { //for all users
			channel_clean(channel,sd,1); //make all quit
		}
		dbi_destroy(iter);
	}
	if (battle_config.etc_log)
		ShowInfo("Deleting channel %s alias %s type %d\n",channel->name,channel->alias,channel->type);
	db_destroy(channel->users);
	db_destroy(channel->banned);
	if (channel->groups)
		aFree(channel->groups);
	channel->groups = NULL;
	channel->group_count = 0;
	switch(channel->type){
	case CHAN_TYPE_MAP:
		map_getmapdata(channel->m)->channel = NULL;
		aFree(channel);
		break;
	case CHAN_TYPE_ALLY: {
		struct guild *g = guild_search(channel->gid);
		if(g) g->channel = NULL;
		aFree(channel);
		break;
	}
	default:
		strdb_remove(channel_db, channel->name);
		break;
	}
	return 0;
}
Пример #20
0
void CDataProcess::ThreadProc()
{
	long lLastQueryTime = 0;
	string strHeader = m_strHeader;
	int iRet = -1;
	CString strRet = "";
	CString strPath = CFunction::GetAppPath().c_str();
	strPath += "xmlLog";
	CString strFilePath = "";
	if (!CFileUtil::IsDirectoryExist(strPath))
	{
		CFileUtil::CreateDirectory(strPath);
	}
	while (IsRunning())
	{
		if (::GetTickCount() - lLastQueryTime < m_lQueryInterval)
		{
			Sleep(500);
			continue;
		}
		strHeader = m_strHeader;
		if (m_bUseZipCompress)
			strHeader.append("\r\nAccept-Encoding:gzip, deflate");
		strFilePath.Format("%s\\%s.xml", strPath, CTime::GetCurrentTime().Format("%Y%m%d%H%M%S"));

		int iRet = GetPage(m_strObject, strHeader.c_str(), NULL, 0, true, strFilePath);
		if(iRet < 0)
		{
			Sleep(500);
			continue;
		}
		lLastQueryTime = ::GetTickCount();
		ReadXmlInfo(strFilePath);
		if(m_hWndShow)	ShowInfo(m_hWndShow);
		CString strShow = "最后抓取时间: ";
		if(m_hWndNotice) ::SetWindowText(m_hWndNotice,strShow + CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
	}
}
Пример #21
0
// initialize
int inter_init_sql(const char *file)
{
	inter_config_defaults();
	inter_config_read(file);

	//DB connection initialized
	sql_handle = Sql_Malloc();
	ShowInfo("Connect Character DB server.... (Character Server)\n");
	if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) )
	{
		ShowError("Couldn't connect with username = '******', password = '******', host = '%s', port = '%d', database = '%s'\n",
			char_server_id, char_server_pw, char_server_ip, char_server_port, char_server_db);
		Sql_ShowDebug(sql_handle);
		Sql_Free(sql_handle);
		exit(EXIT_FAILURE);
	}

	if( *default_codepage ) {
		if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) )
			Sql_ShowDebug(sql_handle);
	}

	wis_db = idb_alloc(DB_OPT_RELEASE_DATA);
	inter_config_readConf();
	inter_guild_sql_init();
	inter_storage_sql_init();
	inter_party_sql_init();
	inter_pet_sql_init();
	inter_homunculus_sql_init();
	inter_mercenary_sql_init();
	inter_elemental_sql_init();
	inter_mail_sql_init();
	inter_auction_sql_init();
	inter_clan_init();

	geoip_readdb();
	return 0;
}
Пример #22
0
// Console Command Parser [Wizputer]
int cnslif_parse(const char* buf)
{
	char type[64];
	char command[64];
	int n=0;

	if( ( n = sscanf(buf, "%63[^:]:%63[^\n]", type, command) ) < 2 ){
		if((n = sscanf(buf, "%63[^\n]", type))<1) return -1; //nothing to do no arg
	}
	if( n != 2 ){ //end string
		ShowNotice("Type: '%s'\n",type);
		command[0] = '\0';
	}
	else
		ShowNotice("Type of command: '%s' || Command: '%s'\n",type,command);

	if( n == 2 && strcmpi("server", type) == 0 ){
		if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 ){
			runflag = 0;
		}
		else if( strcmpi("alive", command) == 0 || strcmpi("status", command) == 0 )
			ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n");
		else if( strcmpi("reloadconf", command) == 0 ) {
			ShowInfo("Reloading config file \"%s\"\n", CHAR_CONF_NAME);
			char_config_read(CHAR_CONF_NAME, false);
		}
	}
	else if( strcmpi("ers_report", type) == 0 ){
		ers_report();
	}
	else if( strcmpi("help", type) == 0 ){
		ShowInfo("Available commands:\n");
		ShowInfo("\t server:shutdown => Stops the server.\n");
		ShowInfo("\t server:alive => Checks if the server is running.\n");
		ShowInfo("\t server:reloadconf => Reload config file: \"%s\"\n", CHAR_CONF_NAME);
		ShowInfo("\t ers_report => Displays database usage.\n");
	}

	return 0;
}
Пример #23
0
void CVolumeInfo::OnChangeNewQuota()
{
	if (m_List.m_hWnd == 0)
		return;

	CString strQuota;
	GetDlgItem(IDC_NEW_QUOTA)->GetWindowText(strQuota);

	if (strQuota.IsEmpty())
		return;

	if (!UpdateData(TRUE))
		return;

	ASSERT(m_nCurIndex >= 0);

	m_pVolInfo[m_nCurIndex].m_nNewQuota = m_nNewQuota;

	if (m_pVolInfo[m_nCurIndex].m_nNewQuota != m_pVolInfo[m_nCurIndex].m_nQuota)
		m_Ok.EnableWindow(TRUE);

	ShowInfo();
}
Пример #24
0
/*======================================
 *	CORE : Display title
 *--------------------------------------*/
static void display_title(void)
{
	//ClearScreen(); // clear screen and go up/left (0, 0 position in text)
	ShowMessage("\n");
	ShowMessage(""CL_WTBL"          (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BT_YELLOW"       Equipe Cronus de Desenvolvimento Apresenta        "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	// Não precisamos mostrar essa versão por enquanto [Keoy]
	//ShowMessage(""CL_XXBL"          ("CL_BOLD"      _________                    v%2d.%02d.%02d             "CL_XXBL")"CL_CLL""CL_NORMAL"\n", ATHENA_MAJOR_VERSION, ATHENA_MINOR_VERSION, ATHENA_REVISION);
	ShowMessage(""CL_XXBL"          ("CL_BOLD"      _________                                          "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"      \\_   ___ \\_______  ____   ____  __ __  ______      "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"      /    \\  \\/\\_  __ \\/  _ \\ /    \\|  |  \\/  ___/      "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"      \\     \\____|  | \\(  <_> )   |  \\  |  /\\___ \\       "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"       \\______  /|__|   \\____/|___|  /____//____  >      "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"              \\/                   \\/           \\/       "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BT_RED"                          Fusion                         "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"                  www.cronus-emulator.com                "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BT_YELLOW"      Baseado no eAthena (c) 2005-2010 Projeto Cronus    "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BT_GREEN"              Emulador compilado por Spike               "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_XXBL"          ("CL_BOLD"                                                         "CL_XXBL")"CL_CLL""CL_NORMAL"\n");
	ShowMessage(""CL_WTBL"          (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)"CL_CLL""CL_NORMAL"\n\n");

	ShowInfo("Revisao SVN: '"CL_WHITE"%s"CL_RESET"'.\n", get_svn_revision());
}
Пример #25
0
//This can still happen (client times out while waiting for char to confirm auth data)
int auth_db_cleanup_sub(DBKey key,void *data,va_list ap)
{
	struct auth_node *node=(struct auth_node*)data;
	const char* states[] = { "Iniciar Sessao", "Encerrar Sessao", "Mudanca de Mapa" };
	if(DIFF_TICK(gettick(),node->node_created)>60000) {
		switch (node->state)
		{
		case ST_LOGOUT:
			//Re-save attempt (->sd should never be null here).
			node->node_created = gettick(); //Refresh tick (avoid char-server load if connection is really bad)
			chrif_save(node->sd, 1);
			break;
		default:
			//Clear data. any connected players should have timed out by now.
			ShowInfo("auth_db: No (estado %s) tempo esgotado para %d:%d\n", states[node->state], node->account_id, node->char_id);
			chrif_char_offline_nsd(node->account_id, node->char_id);
			chrif_auth_delete(node->account_id, node->char_id, node->state);
			break;
		}
		return 1;
	}
	return 0;
}
Пример #26
0
void CSystemDlg::OnReceiveComplete()
{

    switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
    {
    case TOKEN_SYSTEMINFO:
        ShowInfo();
        break;
    case TOKEN_PSLIST:
        ShowProcessList();
        break;
    case TOKEN_WSLIST:
        ShowWindowsList();
        break;
    case TOKEN_DIALUPASS:
        ShowDialupassList();
        break;
    default:
        // 传输发生异常数据
        break;
    }

}
Пример #27
0
//----------------------------------------
// Function to send characters to a player
//----------------------------------------
int chclif_mmo_send006b(int fd, struct char_session_data* sd){
	int j, offset = 0;
	bool newvers = (sd->version >= date2version(20100413) );
	if(newvers) //20100413
		offset += 3;
	if (charserv_config.save_log)
		ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id);

	j = 24 + offset; // offset
	WFIFOHEAD(fd,j + MAX_CHARS*MAX_CHAR_BUF);
	WFIFOW(fd,0) = 0x6b;
	if(newvers){ //20100413
		WFIFOB(fd,4) = MAX_CHARS; // Max slots.
		WFIFOB(fd,5) = MIN_CHARS; // Available slots. (PremiumStartSlot)
		WFIFOB(fd,6) = MIN_CHARS+sd->chars_vip; // Premium slots. (Any existent chars past sd->char_slots but within MAX_CHARS will show a 'Premium Service' in red)
	}
	memset(WFIFOP(fd,4 + offset), 0, 20); // unknown bytes
	j+=char_mmo_chars_fromsql(sd, WFIFOP(fd,j));
	WFIFOW(fd,2) = j; // packet len
	WFIFOSET(fd,j);

	return 0;
}
Пример #28
0
//---------------------------------------------------------
int inter_pet_tosql(int pet_id, struct s_pet* p)
{
	//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`)
	char esc_name[NAME_LENGTH*2+1];// escaped pet name

	Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
	p->hungry = cap_value(p->hungry, 0, 100);
	p->intimate = cap_value(p->intimate, 0, 1000);

	if( pet_id == -1 )
	{// New pet.
		if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` "
			"(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`) "
			"VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
			schema_config.pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
			p->equip, p->intimate, p->hungry, p->rename_flag, p->incubate) )
		{
			Sql_ShowDebug(sql_handle);
			return 0;
		}
		p->pet_id = (int)Sql_LastInsertId(sql_handle);
	}
	else
	{// Update pet.
		if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incubate`='%d' WHERE `pet_id`='%d'",
			schema_config.pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
			p->equip, p->intimate, p->hungry, p->rename_flag, p->incubate, p->pet_id) )
		{
			Sql_ShowDebug(sql_handle);
			return 0;
		}
	}

	if (charserv_config.save_log)
		ShowInfo("Pet saved %d - %s.\n", pet_id, p->name);
	return 1;
}
Пример #29
0
static void WriteSavegameInfo(const char *name)
{
	extern uint16 _sl_version;
	uint32 last_ottd_rev = 0;
	byte ever_modified = 0;
	bool removed_newgrfs = false;

	GamelogInfo(_load_check_data.gamelog_action, _load_check_data.gamelog_actions, &last_ottd_rev, &ever_modified, &removed_newgrfs);

	char buf[8192];
	char *p = buf;
	p += seprintf(p, lastof(buf), "Name:         %s\n", name);
	p += seprintf(p, lastof(buf), "Savegame ver: %d\n", _sl_version);
	p += seprintf(p, lastof(buf), "NewGRF ver:   0x%08X\n", last_ottd_rev);
	p += seprintf(p, lastof(buf), "Modified:     %d\n", ever_modified);

	if (removed_newgrfs) {
		p += seprintf(p, lastof(buf), "NewGRFs have been removed\n");
	}

	p = strecpy(p, "NewGRFs:\n", lastof(buf));
	if (_load_check_data.HasNewGrfs()) {
		for (GRFConfig *c = _load_check_data.grfconfig; c != NULL; c = c->next) {
			char md5sum[33];
			md5sumToString(md5sum, lastof(md5sum), HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum);
			p += seprintf(p, lastof(buf), "%08X %s %s\n", c->ident.grfid, md5sum, c->filename);
		}
	}

	/* ShowInfo put output to stderr, but version information should go
	 * to stdout; this is the only exception */
#if !defined(WIN32) && !defined(WIN64)
	printf("%s\n", buf);
#else
	ShowInfo(buf);
#endif
}
void TableEntryDatarate::EditFinished()
{
    bool tApplied = false;
    unsigned int tNewDatarate = 0, tOldDatarate = 0;

    if(mSocket == NULL)
        return;

    SocketsList tSocketList = SVC_SOCKET_CONTROL.GetClientSocketsControl();

    if(SVC_SOCKET_CONTROL.IsClientSocketAvailable(mSocket))
    {
        QoSSettings tQoSSettings;
        mSocket->GetQoS(tQoSSettings);
        tOldDatarate = tQoSSettings.DataRate;
        bool tOk = false;
        tNewDatarate = mLineEdit->text().toInt(&tOk, 10);
        if (tOk)
        {
            if(tNewDatarate != tOldDatarate)
            {
                tQoSSettings.DataRate = (unsigned int)tNewDatarate;
                mSocket->SetQoS(tQoSSettings);
                tApplied = true;
            }
        }else
        {
            LOG(LOG_WARN, "Wrong user input for new data rate value, will use old value");
            mLineEdit->setText(QString("%1").arg(tQoSSettings.DataRate));
        }
    }

    SVC_SOCKET_CONTROL.ReleaseClientSocketsControl();

    if (tApplied)
        ShowInfo("New QoS settings applied", "The required data rate was set from " + QString("%1").arg(tOldDatarate) + " to " + QString("%1").arg(tNewDatarate) + " Kb/s in the socket settings");
}