Ejemplo n.º 1
0
/* static int remove_tkline_match(const char *host, const char *user)
 *
 * Inputs:      gecos
 * Output:      returns YES on success, NO if no tkline removed.
 * Side effects: Any matching tklines are removed.
 */
static void
xline_remove(struct Client *source_p, const struct aline_ctx *aline)
{
  struct GecosItem *gecos;

  if ((gecos = gecos_find(aline->mask, irccmp)) == NULL)
  {
    if (IsClient(source_p))
      sendto_one_notice(source_p, &me, ":No X-Line for %s", aline->mask);

    return;
  }

  if (gecos->in_database == false)
  {
    if (IsClient(source_p))
      sendto_one_notice(source_p, &me, ":The X-Line for %s is in the configuration file and must be removed by hand",
                        gecos->mask);
    return;
  }

  if (IsClient(source_p))
    sendto_one_notice(source_p, &me, ":X-Line for [%s] is removed", gecos->mask);

  sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
                       "%s has removed the X-Line for: [%s]",
                       get_oper_name(source_p), gecos->mask);
  ilog(LOG_TYPE_RESV, "%s removed X-Line for [%s]",
       get_oper_name(source_p), gecos->mask);

  gecos_delete(gecos, false);
}
Ejemplo n.º 2
0
static void
mo_chgident(struct Client *client_p, struct Client *source_p,
            int parc, char *parv[])
{
  struct Client *target_p = NULL;

  if (MyClient(source_p) && !IsOperAdmin(source_p))
  {
    sendto_one(source_p, form_str(ERR_NOPRIVS),
               me.name, source_p->name, "CHGIDENT");
    return;
  }

  if (EmptyString(parv[2]))
  {
    parv[2] = parv[1];
    target_p = source_p;

    if (!IsClient(target_p))
      return;
  }
  else {
    target_p = find_client(parv[1]);

    if (target_p == NULL || !IsClient(target_p))
    {
      sendto_one(source_p, form_str(ERR_NOSUCHNICK),
                 me.name, source_p->name, parv[1]);
      return;
    }
  }

  if (strlen(parv[2]) > USERLEN || !*parv[2] || !valid_username(parv[2]))
  {
    sendto_one(source_p, ":%s NOTICE %s :Invalid username",
               me.name, source_p->name);
    return;
  }

  if (IsUserHostIp(target_p))
    delete_user_host(target_p->username, target_p->host, !MyConnect(target_p));

  strlcpy(target_p->username, parv[2], sizeof(target_p->username));

  add_user_host(target_p->username, target_p->host, !MyConnect(target_p));
  SetUserHost(target_p);

  if (MyClient(source_p))
  {
    sendto_server(client_p, NULL, NOCAPS, NOCAPS, ":%s ENCAP * CHGIDENT %s %s",
                  source_p->name, target_p->name, parv[2]);
    sendto_one(source_p, ":%s NOTICE %s :%s changed to %s@%s",
               me.name, source_p->name, target_p->name, target_p->username,
               target_p->host);
  }

  if (MyConnect(target_p) && IsClient(source_p))
    sendto_one(target_p, ":%s NOTICE %s :You are now %s@%s",
               me.name, target_p->name, target_p->username, target_p->host);
}
Ejemplo n.º 3
0
Archivo: aa.cpp Proyecto: af4t/Server
void Mob::ExpendAlternateAdvancementCharge(uint32 aa_id) {
	for(auto &iter : aa_ranks) {
		AA::Ability *ability = zone->GetAlternateAdvancementAbility(iter.first);
		if(ability && aa_id == ability->id) {
			if(iter.second.second > 0) {
				iter.second.second -= 1;

				if(iter.second.second == 0) {
					if(IsClient()) {
						AA::Rank *r = ability->GetRankByPointsSpent(iter.second.first);
						if(r) {
							CastToClient()->GetEPP().expended_aa += r->cost;
						}
					}
					if (IsClient()) {
						auto c = CastToClient();
						c->RemoveExpendedAA(ability->first_rank_id);
					}
					aa_ranks.erase(iter.first);
				}

				if(IsClient()) {
					Client *c = CastToClient();
					c->SaveAA();
					c->SendAlternateAdvancementPoints();
				}
			}

			return;
		}
	}
}
Ejemplo n.º 4
0
static void
ms_topic(struct Client *client_p, struct Client *source_p,
         int parc, char *parv[])
{
  struct Channel *chptr = NULL;
  const char *from, *to;
  char topic_info[USERHOST_REPLYLEN];

  if (IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
  {
    from = me.id;
    to = source_p->id;
  }
  else
  {
    from = me.name;
    to = source_p->name;
  }

  if (EmptyString(parv[1]))
  {
    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
               from, to, "TOPIC");
    return;
  }

  if ((chptr = hash_find_channel(parv[1])) == NULL)
  {
    sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
               from, to, parv[1]);
    return;
  }

  if (!IsClient(source_p))
    strlcpy(topic_info, source_p->name, sizeof(topic_info));
  else
    snprintf(topic_info, sizeof(topic_info), "%s!%s@%s", source_p->name,
             source_p->username, source_p->host);
  set_channel_topic(chptr, parv[2], topic_info, CurrentTime, 0);

  sendto_server(client_p, CAP_TS6, NOCAPS, ":%s TOPIC %s :%s",
                ID(source_p), chptr->chname,
                chptr->topic);
  sendto_server(client_p, NOCAPS, CAP_TS6, ":%s TOPIC %s :%s",
                source_p->name, chptr->chname,
                chptr->topic);

  if (!IsClient(source_p))
    sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s TOPIC %s :%s",
                         source_p->name,
                         chptr->chname, chptr->topic);

  else
    sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s TOPIC %s :%s",
                         source_p->name,
                         source_p->username,
                         source_p->host,
                         chptr->chname, chptr->topic);
}
Ejemplo n.º 5
0
Archivo: aa.cpp Proyecto: af4t/Server
bool Mob::CanUseAlternateAdvancementRank(AA::Rank *rank) {
	AA::Ability *ability = rank->base_ability;

	if(!ability)
		return false;

	if(!(ability->classes & (1 << GetClass()))) {
		return false;
	}

	// Passive and Active Shroud AAs
	// For now we skip them
	if(ability->category == 3 || ability->category == 4) {
		return false;
	}

	//the one titanium hack i will allow
	//just to make sure we dont crash the client with newer aas
	//we'll exclude any expendable ones
	if(IsClient() && CastToClient()->ClientVersionBit() & EQEmu::versions::maskTitaniumAndEarlier) {
		if(ability->charges > 0) {
			return false;
		}
	}

	if(IsClient()) {
		if(rank->expansion && !(CastToClient()->GetPP().expansions & (1 << (rank->expansion - 1)))) {
			return false;
		}
	} else {
		if(rank->expansion && !(RuleI(World, ExpansionSettings) & (1 << (rank->expansion - 1)))) {
			return false;
		}
	}

	auto race = GetPlayerRaceValue(GetBaseRace());
	race = race > 16 ? 1 : race;
	if(!(ability->races & (1 << (race - 1)))) {
		return false;
	}

	auto deity = GetDeityBit();
	if(!(ability->deities & deity)) {
		return false;
	}

	if(IsClient() && CastToClient()->Admin() < ability->status) {
		return false;
	}

	if(GetBaseRace() == 522) {
		//drakkin_heritage
		if(!(ability->drakkin_heritage & (1 << GetDrakkinHeritage()))) {
			return false;
		}
	}

	return true;
}
Ejemplo n.º 6
0
void Mob::RemoveAura(int spawn_id, bool skip_strip, bool expired)
{
	for (int i = 0; i < aura_mgr.count; ++i) {
		auto &aura = aura_mgr.auras[i];
		if (aura.spawn_id == spawn_id) {
			if (aura.aura)
				aura.aura->Depop(skip_strip);
			if (expired && IsClient()) {
				CastToClient()->SendColoredText(
				    CC_Yellow, StringFormat("%s has expired.", aura.name)); // TODO: verify color
				// need to update client UI too
				auto app = new EQApplicationPacket(OP_UpdateAura, sizeof(AuraDestory_Struct));
				auto ads = (AuraDestory_Struct *)app->pBuffer;
				ads->action = 1; // delete
				ads->entity_id = spawn_id;
				CastToClient()->QueuePacket(app);
				safe_delete(app);
			}
			while (aura_mgr.count - 1 > i) {
				i++;
				aura.spawn_id = aura_mgr.auras[i].spawn_id;
				aura.icon = aura_mgr.auras[i].icon;
				aura.aura = aura_mgr.auras[i].aura;
				aura_mgr.auras[i].aura = nullptr;
				strn0cpy(aura.name, aura_mgr.auras[i].name, 64);
			}
			aura_mgr.count--;
			return;
		}
	}

	for (int i = 0; i < trap_mgr.count; ++i) {
		auto &aura = trap_mgr.auras[i];
		if (aura.spawn_id == spawn_id) {
			if (aura.aura)
				aura.aura->Depop(skip_strip);
			if (expired && IsClient())
				CastToClient()->SendColoredText(
				    CC_Yellow, StringFormat("%s has expired.", aura.name)); // TODO: verify color
			while (trap_mgr.count - 1 > i) {
				i++;
				aura.spawn_id = trap_mgr.auras[i].spawn_id;
				aura.icon = trap_mgr.auras[i].icon;
				aura.aura = trap_mgr.auras[i].aura;
				trap_mgr.auras[i].aura = nullptr;
				strn0cpy(aura.name, trap_mgr.auras[i].name, 64);
			}
			trap_mgr.count--;
			return;
		}
	}

	return;
}
Ejemplo n.º 7
0
void Mob::RemoveAllAuras()
{
	if (IsClient()) {
		database.SaveAuras(CastToClient());
		EQApplicationPacket outapp(OP_UpdateAura, 4);
		outapp.WriteUInt32(2);
		CastToClient()->QueuePacket(&outapp);
	}

	// this is sent on camp/zone, so it just despawns?
	if (aura_mgr.count) {
		for (auto &e : aura_mgr.auras) {
			if (e.aura)
				e.aura->Depop();
		}
	}

	aura_mgr.count = 0;

	if (trap_mgr.count) {
		for (auto &e : trap_mgr.auras) {
			if (e.aura)
				e.aura->Depop();
		}
	}

	trap_mgr.count = 0;

	return;
}
Ejemplo n.º 8
0
//------------------------------------------------------------------------
void CGunTurret::OnTargetLocked(IEntity *pTarget)
{
	if(pTarget)
		PlayAction(g_pItemStrings->lock);

	if(IsServer())
	{
		// if this turret has others linked, notify them about acquired target
		for(IEntityLink *pLink = GetEntity()->GetEntityLinks(); pLink; pLink = pLink->next)
		{
			if(0 != strcmp(pLink->name, "TargetInfo"))
				continue;

			IItem *pItem = g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(pLink->entityId);

			if(pItem)
			{
				SGameObjectEvent event(pTarget?eCGE_Turret_LockedTarget:eCGE_Turret_LostTarget, eGOEF_ToExtensions);
				event.ptr = pTarget;
				pItem->GetGameObject()->SendEvent(event);
			}
		}
	}

	if(IsClient())
	{
		m_pGameFramework->GetMusicLogic()->SetEvent(eMUSICLOGICEVENT_PLAYER_TURRET_ATTACK);
	}
}
Ejemplo n.º 9
0
static void
me_chghost(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
{
	struct Client *target_p = NULL;

	if(parc < 3)
		return;

	if(!IsServer(source_p))
		return;

	if((target_p = find_client(parv[1])) == NULL)
		return;

	if(!IsClient(target_p))
		return;

	if(strlen(parv[2]) > HOSTLEN || !*parv[2] || !valid_hostname(parv[2]))
		return;

	if(!strcmp(target_p->host, parv[2]))
		return;

	if(ConfigChannel.cycle_on_hostchange)
		do_hostchange_quits(target_p);

	strlcpy(target_p->host, parv[2], sizeof(target_p->host));

	if(ConfigChannel.cycle_on_hostchange)
		do_hostchange_joins(target_p);
}
Ejemplo n.º 10
0
/*
** m_away
**      parv[1] = away message
*/
static int
m_away(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    if(MyClient(source_p) && source_p->localClient->next_away &&
       !IsFloodDone(source_p))
        flood_endgrace(source_p);

    if(!IsClient(source_p))
        return 0;

    if(parc < 2 || EmptyString(parv[1])) {
        /* Marking as not away */
        if(source_p->user->away != NULL) {
            /* we now send this only if they were away before --is */
            sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
                          ":%s AWAY", use_id(source_p));
            free_away(source_p);

            sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, NOCAPS, ":%s!%s@%s AWAY",
                                                source_p->name, source_p->username, source_p->host);
        }
        if(MyConnect(source_p))
            sendto_one_numeric(source_p, RPL_UNAWAY, form_str(RPL_UNAWAY));
        return 0;
    }

    /* Rate limit this because it is sent to common channels. */
    if (MyClient(source_p)) {
        if(!IsOper(source_p) &&
           source_p->localClient->next_away > rb_current_time()) {
            sendto_one(source_p, form_str(RPL_LOAD2HI),
                       me.name, source_p->name, "AWAY");
            return 0;
        }
        if(source_p->localClient->next_away < rb_current_time() -
           ConfigFileEntry.away_interval)
            source_p->localClient->next_away = rb_current_time();
        else
            source_p->localClient->next_away = rb_current_time() +
                                               ConfigFileEntry.away_interval;
    }


    if(source_p->user->away == NULL)
        allocate_away(source_p);
    if(strncmp(source_p->user->away, parv[1], AWAYLEN - 1)) {
        rb_strlcpy(source_p->user->away, parv[1], AWAYLEN);
        sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
                      ":%s AWAY :%s", use_id(source_p), source_p->user->away);
    }

    if(MyConnect(source_p))
        sendto_one_numeric(source_p, RPL_NOWAWAY, form_str(RPL_NOWAWAY));

    sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, NOCAPS, ":%s!%s@%s AWAY :%s",
                                        source_p->name, source_p->username, source_p->host,
                                        source_p->user->away);

    return 0;
}
Ejemplo n.º 11
0
/* check_clean_nick()
 *
 * input        - pointer to source
 *              -
 *              - nickname
 *              - truncated nickname
 *              - origin of client
 *              - pointer to server nick is coming from
 * output       - none
 * side effects - if nickname is erroneous, or a different length to
 *                truncated nickname, return 1
 */
static int
check_clean_nick(struct Client *source_p, char *nick, struct Client *server_p)
{
  /*
   * The old code did some wacky stuff here, if the nick is invalid, kill it
   * and don't bother messing at all
   */
  if (!valid_nickname(nick, 0))
  {
    ++ServerStats.is_kill;
    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
                         "Bad/long Nick: %s From: %s(via %s)",
                         nick, server_p->name, source_p->from->name);

    sendto_one(source_p, ":%s KILL %s :%s (Bad Nickname)",
               me.name, nick, me.name);

    /* Bad nick change */
    if (IsClient(source_p) && !MyConnect(source_p))
    {
      sendto_server(source_p, 0, 0, ":%s KILL %s :%s (Bad Nickname)",
                    me.id, source_p->id, me.name);
      AddFlag(source_p, FLAGS_KILLED);
      exit_client(source_p, "Bad Nickname");
    }

    return 1;
  }

  return 0;
}
Ejemplo n.º 12
0
static void
ms_away(struct Client *client_p, struct Client *source_p,
        int parc, char *parv[])
{
  if (!IsClient(source_p))
    return;

  if (parc < 2 || EmptyString(parv[1]))
  {
    /* Marking as not away */
    if (source_p->away[0])
    {
      /* we now send this only if they were away before --is */
      sendto_server(client_p, CAP_TS6, NOCAPS,
                    ":%s AWAY", ID(source_p));
      sendto_server(client_p, NOCAPS, CAP_TS6,
                    ":%s AWAY", source_p->name);
      source_p->away[0] = '\0';
    }

    return;
  }

  strlcpy(source_p->away, parv[1], sizeof(source_p->away));

  sendto_server(client_p, CAP_TS6, NOCAPS,
                ":%s AWAY :%s", ID(source_p), source_p->away);
  sendto_server(client_p, NOCAPS, CAP_TS6,
                ":%s AWAY :%s", source_p->name, source_p->away);
}
Ejemplo n.º 13
0
static void
me_undline(struct Client *client_p, struct Client *source_p,
           int parc, char *parv[])
{
  const char *addr = NULL;

  if (parc != 3 || EmptyString(parv[2]))
    return;

  addr = parv[2];

  if (!IsClient(source_p) || match(parv[1], me.name))
    return;

  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE,
                                   source_p->servptr->name,
                                   source_p->username, source_p->host,
                                   SHARED_UNDLINE))
  {
    if (remove_dline_match(addr))
    {
      sendto_one(source_p,
                 ":%s NOTICE %s :D-Line for [%s] is removed",
                 me.name, source_p->name, addr);
      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
                           "%s has removed the D-Line for: [%s]",
                           get_oper_name(source_p), addr);
      ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]",
           get_oper_name(source_p), addr);
    }
    else
      sendto_one(source_p, ":%s NOTICE %s :No D-Line for [%s] found",
                 me.name, source_p->name, addr);
  }
}
Ejemplo n.º 14
0
//------------------------------------------------------------------------
void CItem::UpdateFPCharacter(float frameTime)
{
	if (IsClient())
	{
		ICharacterInstance *pCharacter = GetEntity()->GetCharacter(eIGS_FirstPerson);

		if (pCharacter && !m_idleAnimation[eIGS_FirstPerson].empty() && pCharacter->GetISkeletonAnim()->GetNumAnimsInFIFO(0)<1)
			PlayAction(m_idleAnimation[eIGS_FirstPerson], 0, true);
	}

	// need to explicitly update characters at this point
	// cause the entity system update occered earlier, with the last position
	for (int i=0; i<eIGS_Last; i++)
	{
		if (GetEntity()->GetSlotFlags(i)&ENTITY_SLOT_RENDER)
		{
			ICharacterInstance *pCharacter = GetEntity()->GetCharacter(i);
			if (pCharacter)
			{
				Matrix34 mloc = GetEntity()->GetSlotLocalTM(i,false);
				Matrix34 m34=GetEntity()->GetWorldTM()*mloc;
				QuatT renderLocation = QuatT(m34);
				pCharacter->GetISkeletonPose()->SetForceSkeletonUpdate(8);
				pCharacter->SkeletonPreProcess(renderLocation, renderLocation, GetISystem()->GetViewCamera(),0x55 );
				pCharacter->SetPostProcessParameter(renderLocation, renderLocation, 0, 1.0f, 0x55 ); 
			}
		}
	}

	IEntityRenderProxy *pProxy=GetRenderProxy();
	if (pProxy)
		pProxy->InvalidateLocalBounds();
}
Ejemplo n.º 15
0
/*!
 *
 * \param source_p Pointer to allocated Client struct from which the message
 *                 originally comes from.  This can be a local or remote client.
 * \param parc     Integer holding the number of supplied arguments.
 * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
 *                 pointers.
 * \note Valid arguments for this command are:
 *
 *      - parv[0] = command
 *      - parv[1] = nickname
 *      - parv[2] = timestamp
 */
static void
change_remote_nick(struct Client *source_p, char *parv[])
{
  int samenick = !irccmp(source_p->name, parv[1]);

  assert(!EmptyString(parv[1]));
  assert(IsClient(source_p));
  assert(source_p->name[0]);

  /* Client changing their nick */
  if (!samenick)
  {
    DelUMode(source_p, UMODE_REGISTERED);
    watch_check_hash(source_p, RPL_LOGOFF);
    source_p->tsinfo = atol(parv[2]);
    assert(source_p->tsinfo > 0);
  }

  sendto_common_channels_local(source_p, 1, 0, ":%s!%s@%s NICK :%s",
                               source_p->name, source_p->username,
                               source_p->host, parv[1]);

  whowas_add_history(source_p, 1);
  sendto_server(source_p, 0, 0, ":%s NICK %s :%lu",
                source_p->id, parv[1], (unsigned long)source_p->tsinfo);

  /* Set the new nick name */
  hash_del_client(source_p);
  strlcpy(source_p->name, parv[1], sizeof(source_p->name));
  hash_add_client(source_p);

  if (!samenick)
    watch_check_hash(source_p, RPL_LOGON);
}
 int stripcodes_packet(aClient *from, aClient *to, char **msg, int length)
 {
 	static char buf[512];

 	if((from != &me && (!IsClient(from) && IsRegistered(from))) || (to != &me && !IsClient(to)))
 		return HOOK_CONTINUE;

 	if (to != &me && IsColorBlind(to)) {
 		strcpy(buf, StripControlCodes(*msg));

 		length = strlen(buf);
 		*msg = buf;
 	}

 	return HOOK_CONTINUE;
 }
Ejemplo n.º 17
0
bool Mob::CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ) {
	if(IsNPC() || IsClient() || IsPet()) {
		pRunAnimSpeed = (int8)(speed*NPC_RUNANIM_RATIO);
		speed *= NPC_SPEED_MULTIPLIER;
	}

	return MakeNewPositionAndSendUpdate(x, y, z, speed, checkZ);
}
Ejemplo n.º 18
0
/* me_resv()
 *
 * inputs	- server
 *		- client (oper)
 *		- parc number of arguments
 *		- parv list of arguments
 * via parv[]
 * parv[0] = client name applying resv
 * parv[1] = tkline_time
 * parv[2] = name
 * parv[3] = 0
 * parv[4] = reason
 * parc should be 5
 *
 * outputs	- NONE
 * side effects -
 */
static void
me_resv(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
{
	if(parc != 5 || !IsClient(source_p))
		return;

	parse_resv(source_p, parv[2], atoi(parv[1]), parv[4]);
}
Ejemplo n.º 19
0
/* msg_client()
 *
 * inputs	- flag 0 if PRIVMSG 1 if NOTICE. RFC
 *		  say NOTICE must not auto reply
 * 		- pointer to source_p source (struct Client *)
 *		- pointer to target_p target (struct Client *)
 *		- pointer to text
 * output	- NONE
 * side effects	- message given channel either chanop or voice
 */
static void
msg_client(int p_or_n, struct Client *source_p, struct Client *target_p,
           const char *text)
{
  if (MyClient(source_p))
  {
    if (target_p->away[0] && p_or_n != NOTICE)
      sendto_one_numeric(source_p, &me, RPL_AWAY, target_p->name, target_p->away);

    if (HasUMode(target_p, UMODE_REGONLY) && target_p != source_p)
    {
      if (!HasUMode(source_p, UMODE_REGISTERED | UMODE_OPER))
      {
        if (p_or_n != NOTICE)
          sendto_one_numeric(source_p, &me, ERR_NONONREG, target_p->name);
        return;
      }
    }
  }

  if (MyClient(target_p) && IsClient(source_p))
  {
    if (HasUMode(target_p, UMODE_CALLERID | UMODE_SOFTCALLERID) &&
        !accept_message(source_p, target_p))
    {
      const int callerid = !!HasUMode(target_p, UMODE_CALLERID);

      /* check for accept, flag recipient incoming message */
      if (p_or_n != NOTICE)
        sendto_one_numeric(source_p, &me, RPL_TARGUMODEG,
                           target_p->name,
                           callerid ? "+g" : "+G",
                           callerid ? "server side ignore" :
                                      "server side ignore with the exception of common channels");

      if ((target_p->connection->last_caller_id_time +
           ConfigGeneral.caller_id_wait) < CurrentTime)
      {
        if (p_or_n != NOTICE)
          sendto_one_numeric(source_p, &me, RPL_TARGNOTIFY, target_p->name);

        sendto_one_numeric(target_p, &me, RPL_UMODEGMSG,
                           source_p->name, source_p->username, source_p->host,
                           callerid ? "+g" : "+G");
        target_p->connection->last_caller_id_time = CurrentTime;
      }

      /* Only so opers can watch for floods */
      flood_attack_client(NOTICE, source_p, target_p);
      return;
    }

    if (flood_attack_client(p_or_n, source_p, target_p))
      return;
  }

  sendto_anywhere(target_p, source_p, command[p_or_n], ":%s", text);
}
Ejemplo n.º 20
0
//healing and buffing aggro
int32 Mob::CheckHealAggroAmount(uint16 spellid, uint32 heal_possible) {
	uint16 spell_id = spellid;
	int32 AggroAmount = 0;

	for (int o = 0; o < EFFECT_COUNT; o++) {
		switch(spells[spell_id].effectid[o]) {
			case SE_CurrentHP: {
				AggroAmount += spells[spell_id].mana;
				break;
			}
			case SE_Rune: {
				AggroAmount += CalcSpellEffectValue_formula(spells[spell_id].formula[0], spells[spell_id].base[0], spells[spell_id].max[o], this->GetLevel(), spellid) * 2;
				break;
			}
			case SE_HealOverTime:{
				AggroAmount += CalcSpellEffectValue_formula(spells[spell_id].formula[o], spells[spell_id].base[o], spells[spell_id].max[o], this->GetLevel(), spell_id);
				break;
			}
			default:{
				break;
			}
		}
	}
	if (IsBardSong(spell_id))
		AggroAmount = AggroAmount * RuleI(Aggro, SongAggroMod) / 100;
	if (GetOwner() && IsPet())
		AggroAmount = AggroAmount * RuleI(Aggro, PetSpellAggroMod) / 100;

	if(AggroAmount > 0)
	{
		int HateMod = RuleI(Aggro, SpellAggroMod);

		if(IsClient())
		{
			HateMod += CastToClient()->GetFocusEffect(focusSpellHateMod, spell_id);
		}

		//Live AA - Spell casting subtlety
		HateMod += aabonuses.hatemod + spellbonuses.hatemod + itembonuses.hatemod;

		AggroAmount = (AggroAmount * HateMod) / 100;

		//made up number probably scales a bit differently on live but it seems like it will be close enough
		//every time you cast on live you get a certain amount of "this is a spell" aggro
		//confirmed by EQ devs to be 100 exactly at level 85. From their wording it doesn't seem like it's affected
		//by hate modifiers either.
		//AggroAmount += (slevel*slevel/72); // Moved Below


	}


	if(AggroAmount < 0)
		return 0;
	else
		return AggroAmount;
}
Ejemplo n.º 21
0
static void
ms_away(struct Client *client_p, struct Client *source_p,
        int parc, char *parv[])
{
  char *cur_away_msg;
  char *new_away_msg;
  size_t nbytes = 0;

  if (!IsClient(source_p))
    return;

  cur_away_msg = source_p->user->away;

  if (parc < 2 || EmptyString(parv[1]))
  {
    /* Marking as not away */
    if (cur_away_msg)
    {
      /* we now send this only if they were away before --is */
      sendto_server(client_p, source_p, NULL, CAP_TS6, NOCAPS,
                    NOFLAGS, ":%s AWAY", ID(source_p));
      sendto_server(client_p, source_p, NULL, NOCAPS, CAP_TS6,
                    NOFLAGS, ":%s AWAY", source_p->name);

      MyFree(cur_away_msg);
      source_p->user->away = NULL;
    }

    return;
  }

  source_p->user->last_away = CurrentTime;
  new_away_msg              = parv[1];

  nbytes = strlen(new_away_msg);
  if (nbytes > (size_t)TOPICLEN) {
    new_away_msg[TOPICLEN] = '\0';
    nbytes = TOPICLEN;
  }

  /* we now send this only if they
   * weren't away already --is */
  if (!cur_away_msg)
  {
    sendto_server(client_p, source_p, NULL, CAP_TS6, NOCAPS,
                  NOFLAGS, ":%s AWAY :%s", ID(source_p), new_away_msg);
    sendto_server(client_p, source_p, NULL, NOCAPS, CAP_TS6,
                  NOFLAGS, ":%s AWAY :%s", source_p->name, new_away_msg);
  }
  else
    MyFree(cur_away_msg);

  cur_away_msg = MyMalloc(nbytes + 1);
  strcpy(cur_away_msg, new_away_msg);
  source_p->user->away = cur_away_msg;
}
Ejemplo n.º 22
0
/*
 * * get_client_name *      Return the name of the client for various
 * tracking and *      admin purposes. The main purpose of this
 * function is to *      return the "socket host" name of the client,
 * if that *    differs from the advertised name (other than case). *
 * But, this can be used to any client structure. *
 * 
 *      Returns: *        "name[user@ip#.port]" if 'showip' is true; *
 * "name[sockethost]", if name and sockhost are different and *
 * showip is false; else *        "name". *
 * 
 * NOTE 1: *    Watch out the allocation of "nbuf", if either
 * sptr->name * or sptr->sockhost gets changed into pointers instead of *
 * directly allocated within the structure... *
 * 
 * NOTE 2: *    Function return either a pointer to the structure
 * (sptr) or *  to internal buffer (nbuf). *NEVER* use the returned
 * pointer *    to modify what it points!!!
 */
char *
get_client_name(aClient *sptr, int showip)
{
    static char nbuf[HOSTLEN * 2 + USERLEN + 7];
    char *s = nbuf;

    if (MyConnect(sptr)) 
    {
        if (sptr->name[0])
            s += ircsprintf(s, "%s", sptr->name);
        else
            s += ircsprintf(s, "%s", "<unnamed>");

        if (IsServer(sptr))
        {
            if (showip == TRUE)
                s += ircsprintf(s, "[%s]", cipntoa(sptr));
            else if (showip != HIDEME)
                s += ircsprintf(s, "[%s]", sptr->sockhost);
        }
        else if (IsClient(sptr))
        {
            if (showip == TRUE)
                s += ircsprintf(s, "!%s@%s", sptr->user->username,
                                cipntoa(sptr));
            else if (showip != HIDEME)
                s += ircsprintf(s, "!%s@%s", sptr->user->username,
                                sptr->user->host);
        }
        else
        {
            if (showip != HIDEME)
            {
                s += ircsprintf(s, "([");

                if (DoingAuth(sptr))
                    *s++ = '?';
                else if (sptr->flags & FLAGS_GOTID)
                    *s++ = '+';
                else
                    *s++ = '-';

                if (showip == TRUE)
                    s += ircsprintf(s, "]%s@%s)", sptr->username,
                                    cipntoa(sptr));
                else
                    s += ircsprintf(s, "]%s@%s)", sptr->username,
                                    sptr->sockhost);
            }
        }

        return nbuf;
    }

    return sptr->name;
}
Ejemplo n.º 23
0
bool CChar::Use_Obj( CObjBase * pObj, bool fTestTouch, bool fScript  )
{
	ADDTOCALLSTACK("CChar::Use_Obj");
	if ( !pObj )
		return false;
	if ( IsClient() )
		return GetClient()->Event_DoubleClick(pObj->GetUID(), false, fTestTouch, fScript);
	else
		return Use_Item(dynamic_cast<CItem*>(pObj), fTestTouch);
}
Ejemplo n.º 24
0
/*
 * ms_admin - ADMIN command handler, used for OPERS as well
 *      parv[0] = sender prefix
 *      parv[1] = servername
 */
static void
ms_admin(struct Client *client_p, struct Client *source_p,
         int parc, char *parv[])
{
  if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
    return;

  if (IsClient(source_p))
    do_admin(source_p);
}
Ejemplo n.º 25
0
/*! \brief TOPIC command handler
 *
 * \param source_p Pointer to allocated Client struct from which the message
 *                 originally comes from.  This can be a local or remote client.
 * \param parc     Integer holding the number of supplied arguments.
 * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
 *                 pointers.
 * \note Valid arguments for this command are:
 *      - parv[0] = command
 *      - parv[1] = channel name
 *      - parv[2] = topic text
 */
static int
ms_topic(struct Client *source_p, int parc, char *parv[])
{
  struct Channel *chptr = NULL;
  char topic_info[USERHOST_REPLYLEN];

  if (EmptyString(parv[1]))
  {
    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "TOPIC");
    return 0;
  }

  if ((chptr = hash_find_channel(parv[1])) == NULL)
  {
    sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]);
    return 0;
  }

  if (!IsClient(source_p))
    strlcpy(topic_info, source_p->name, sizeof(topic_info));
  else
    snprintf(topic_info, sizeof(topic_info), "%s!%s@%s", source_p->name,
             source_p->username, source_p->host);
  channel_set_topic(chptr, parv[2], topic_info, CurrentTime, 0);

  sendto_server(source_p, 0, 0, ":%s TOPIC %s :%s",
                source_p->id, chptr->name,
                chptr->topic);

  if (!IsClient(source_p))
    sendto_channel_local(0, chptr, ":%s TOPIC %s :%s",
                        (IsHidden(source_p) || ConfigServerHide.hide_servers) ? me.name : source_p->name,
                         chptr->name, chptr->topic);

  else
    sendto_channel_local(0, chptr, ":%s!%s@%s TOPIC %s :%s",
                         source_p->name,
                         source_p->username,
                         source_p->host,
                         chptr->name, chptr->topic);
  return 0;
}
Ejemplo n.º 26
0
static void
m_privmsg(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
{
	/* servers have no reason to send privmsgs, yet sometimes there is cause
	 * for a notice.. (for example remote kline replies) --fl_
	 */
	if(!IsClient(source_p))
		return;

	m_message(PRIVMSG, "PRIVMSG", client_p, source_p, parc, parv);
}
Ejemplo n.º 27
0
static int
me_locops(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	if(!IsClient(source_p))
		return 0;

	if(find_shared_conf("*", "*", source_p->servptr->name, SHARED_LOCOPS))
		sendto_wallops_flags(UMODE_LOCOPS, source_p, "SLOCOPS - %s", parv[1]);

	return 0;
}
Ejemplo n.º 28
0
void Mob::SetPetID(uint16 NewPetID) {
	if (NewPetID == GetID() && NewPetID != 0)
		return;
	petid = NewPetID;

	if(IsClient())
	{
		Mob* NewPet = entity_list.GetMob(NewPetID);
		CastToClient()->UpdateXTargetType(MyPet, NewPet);
	}
}
Ejemplo n.º 29
0
bool Aura::ShouldISpawnFor(Client *c)
{
	if (spawn_type == AuraSpawns::Noone)
		return false;

	if (spawn_type == AuraSpawns::Everyone)
		return true;

	// hey, it's our owner!
	if (c->GetID() == m_owner)
		return true;

	// so this one is a bit trickier
	auto owner = GetOwner();
	if (owner == nullptr)
		return false; // hmm

	owner = owner->GetOwnerOrSelf(); // pet auras we need the pet's owner
	if (owner == nullptr) // shouldn't really be needed
		return false;

	// gotta check again for pet aura case -.-
	if (owner == c)
		return true;

	if (owner->IsRaidGrouped() && owner->IsClient()) {
		auto raid = owner->GetRaid();
		if (raid == nullptr)
			return false; // hmm
		auto group_id = raid->GetGroup(owner->CastToClient());
		if (group_id == 0xFFFFFFFF) // owner handled above, and they're in a raid and groupless
			return false;

		auto idx = raid->GetPlayerIndex(c);
		if (idx == 0xFFFFFFFF) // they're not in our raid!
			return false;

		if (raid->members[idx].GroupNumber != group_id) // in our raid, but not our group
			return false;

		return true; // we got here so we know that 1 they're in our raid and 2 they're in our group!
	} else if (owner->IsGrouped()) {
		auto group = owner->GetGroup();
		if (group == nullptr)
			return false; // hmm

		// easy, in our group
		return group->IsGroupMember(c);
	}

	// our owner is not raided or grouped, and they're handled above so we don't spawn!
	return false;
}
Ejemplo n.º 30
0
/* send_linebuf()
 *
 * inputs	- client to send to, linebuf to attach
 * outputs	-
 * side effects - linebuf is attached to client
 */
static int
_send_linebuf(struct Client *to, buf_head_t *linebuf)
{
    if(IsMe(to))
    {
        sendto_realops_snomask(SNO_GENERAL, L_ALL, "Trying to send message to myself!");
        return 0;
    }

    if(!MyConnect(to) || IsIOError(to))
        return 0;

    if(linebuf_len(&to->localClient->buf_sendq) > get_sendq(to))
    {
        if(IsServer(to))
        {
            sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                   "Max SendQ limit exceeded for %s: %u > %lu",
                                   get_server_name(to, HIDE_IP),
                                   linebuf_len(&to->localClient->buf_sendq),
                                   get_sendq(to));

            ilog(L_SERVER, "Max SendQ limit exceeded for %s: %u > %lu",
                 log_client_name(to, SHOW_IP),
                 linebuf_len(&to->localClient->buf_sendq),
                 get_sendq(to));
        }

        if(IsClient(to))
            to->flags |= FLAGS_SENDQEX;

        dead_link(to);
        return -1;
    }
    else
    {
        /* just attach the linebuf to the sendq instead of
         * generating a new one
         */
        linebuf_attach(&to->localClient->buf_sendq, linebuf);
    }

    /*
     ** Update statistics. The following is slightly incorrect
     ** because it counts messages even if queued, but bytes
     ** only really sent. Queued bytes get updated in SendQueued.
     */
    to->localClient->sendM += 1;
    me.localClient->sendM += 1;
    if(linebuf_len(&to->localClient->buf_sendq) > 0)
        send_queued_write(to->localClient->fd, to);
    return 0;
}