Chat garbled for drunk characters.

This commit is contained in:
joligario 2013-02-17 23:38:51 -05:00 committed by JJ
parent a41874b6a7
commit 3feeced884
4 changed files with 40 additions and 40 deletions

View File

@ -10,6 +10,7 @@ OPTIONAL SQL: Re-run utils/sql/svn/merc.sql for latest spell lists.
Derision: Added optional guildid and minstatus parameters to quest::gmsay(<messsage>, [color], [toworld], [guildid], [minstatus]) Derision: Added optional guildid and minstatus parameters to quest::gmsay(<messsage>, [color], [toworld], [guildid], [minstatus])
Derision: Client version is now returned by the stream proxy as a number. Derision: Client version is now returned by the stream proxy as a number.
Derision: Fixed bug where BecomeTrader packets were only being sent to the Trader, not all other clients in the bazaar. Derision: Fixed bug where BecomeTrader packets were only being sent to the Trader, not all other clients in the bazaar.
JJ: Chat garbled for drunk characters.
== 02/16/2013 == == 02/16/2013 ==
demonstar55: Fix AA reuse timer calc demonstar55: Fix AA reuse timer calc

View File

@ -758,7 +758,11 @@ void Client::FastQueuePacket(EQApplicationPacket** app, bool ack_req, CLIENT_CON
return; return;
} }
void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_skill, const char* message, const char* targetname) { void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_skill, const char* orig_message, const char* targetname) {
char message[4096];
strcpy(message, orig_message);
#if EQDEBUG >= 11 #if EQDEBUG >= 11
LogFile->write(EQEMuLog::Debug,"Client::ChannelMessageReceived() Channel:%i message:'%s'", chan_num, message); LogFile->write(EQEMuLog::Debug,"Client::ChannelMessageReceived() Channel:%i message:'%s'", chan_num, message);
#endif #endif
@ -813,8 +817,8 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
} }
if(RuleB(QueryServ, PlayerChatLogging)){ if(RuleB(QueryServ, PlayerChatLogging)) {
ServerPacket* pack = new ServerPacket(ServerOP_Speech, sizeof(Server_Speech_Struct)+strlen(message)+1); ServerPacket* pack = new ServerPacket(ServerOP_Speech, sizeof(Server_Speech_Struct) + strlen(message) + 1);
Server_Speech_Struct* sem = (Server_Speech_Struct*) pack->pBuffer; Server_Speech_Struct* sem = (Server_Speech_Struct*) pack->pBuffer;
if(chan_num == 0) if(chan_num == 0)
@ -826,17 +830,23 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
sem->minstatus = this->Admin(); sem->minstatus = this->Admin();
sem->type = chan_num; sem->type = chan_num;
if(targetname != 0) if(targetname != 0)
strcpy(sem->to,targetname); strcpy(sem->to, targetname);
if(GetName() != 0) if(GetName() != 0)
strcpy(sem->from,GetName()); strcpy(sem->from, GetName());
pack->Deflate(); pack->Deflate();
if(worldserver.Connected()) if(worldserver.Connected())
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);
} }
// Garble the message based on drunkness
if (m_pp.intoxication > 0) {
GarbleMessage(message, (int)(m_pp.intoxication / 3));
language = 0; // No need for language when drunk
}
switch(chan_num) switch(chan_num)
{ {
case 0: { // GuildChat case 0: { // GuildChat
@ -850,7 +860,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
} }
case 2: { // GroupChat case 2: { // GroupChat
Raid* raid = entity_list.GetRaidByClient(this); Raid* raid = entity_list.GetRaidByClient(this);
if(raid){ if(raid) {
raid->RaidGroupSay((const char*) message, this); raid->RaidGroupSay((const char*) message, this);
break; break;
} }
@ -881,7 +891,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
{ {
if(!global_channel_timer.Check()) if(!global_channel_timer.Check())
{ {
if(strlen(targetname)==0) if(strlen(targetname) == 0)
ChannelMessageReceived(5, language, lang_skill, message, "discard"); //Fast typer or spammer?? ChannelMessageReceived(5, language, lang_skill, message, "discard"); //Fast typer or spammer??
else else
return; return;
@ -905,7 +915,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
if (!worldserver.SendChannelMessage(this, 0, 4, 0, language, message)) if (!worldserver.SendChannelMessage(this, 0, 4, 0, language, message))
Message(0, "Error: World server disconnected"); Message(0, "Error: World server disconnected");
} }
else if(!RuleB(Chat, ServerWideAuction)){ else if(!RuleB(Chat, ServerWideAuction)) {
Mob *sender = this; Mob *sender = this;
if (GetPet() && GetPet()->FindType(SE_VoiceGraft)) if (GetPet() && GetPet()->FindType(SE_VoiceGraft))
@ -920,8 +930,8 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
{ {
if(!global_channel_timer.Check()) if(!global_channel_timer.Check())
{ {
if(strlen(targetname)==0) if(strlen(targetname) == 0)
ChannelMessageReceived(5, language, lang_skill, message,"discard"); //Fast typer or spammer?? ChannelMessageReceived(5, language, lang_skill, message, "discard"); //Fast typer or spammer??
else else
return; return;
} }
@ -973,7 +983,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
case 7: { // Tell case 7: { // Tell
if(!global_channel_timer.Check()) if(!global_channel_timer.Check())
{ {
if(strlen(targetname)==0) if(strlen(targetname) == 0)
ChannelMessageReceived(7, language, lang_skill, message, "discard"); //Fast typer or spammer?? ChannelMessageReceived(7, language, lang_skill, message, "discard"); //Fast typer or spammer??
else else
return; return;
@ -1020,12 +1030,12 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
} }
case 8: { // /say case 8: { // /say
if(message[0] == COMMAND_CHAR) { if(message[0] == COMMAND_CHAR) {
if(command_dispatch(this, message) == -2){ if(command_dispatch(this, message) == -2) {
if(RuleB(Chat, FlowCommandstoPerl_EVENT_SAY)){ if(RuleB(Chat, FlowCommandstoPerl_EVENT_SAY)) {
if(parse->PlayerHasQuestSub("EVENT_SAY")) { if(parse->PlayerHasQuestSub("EVENT_SAY")) {
parse->EventPlayer(EVENT_SAY, this, message, language); parse->EventPlayer(EVENT_SAY, this, message, language);
} }
}else{ } else {
this->Message(13, "Command '%s' not recognized.", message); this->Message(13, "Command '%s' not recognized.", message);
} }
} }
@ -1051,9 +1061,9 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
if (GetTarget() != 0 && GetTarget()->IsNPC()) { if (GetTarget() != 0 && GetTarget()->IsNPC()) {
if(!GetTarget()->CastToNPC()->IsEngaged()) { if(!GetTarget()->CastToNPC()->IsEngaged()) {
CheckLDoNHail(GetTarget()); CheckLDoNHail(GetTarget());
CheckEmoteHail(GetTarget(),message); CheckEmoteHail(GetTarget(), message);
if(parse->HasQuestSub(GetTarget()->GetNPCTypeID(),"EVENT_SAY")){ if(parse->HasQuestSub(GetTarget()->GetNPCTypeID(), "EVENT_SAY")){
if (DistNoRootNoZ(*GetTarget()) <= 200) { if (DistNoRootNoZ(*GetTarget()) <= 200) {
if(GetTarget()->CastToNPC()->IsMoving() && !GetTarget()->CastToNPC()->IsOnHatelist(GetTarget())) if(GetTarget()->CastToNPC()->IsMoving() && !GetTarget()->CastToNPC()->IsOnHatelist(GetTarget()))
GetTarget()->CastToNPC()->PauseWandering(RuleI(NPC, SayPauseTimeInSec)); GetTarget()->CastToNPC()->PauseWandering(RuleI(NPC, SayPauseTimeInSec));
@ -1075,7 +1085,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
} }
} }
else { else {
if(parse->HasQuestSub(GetTarget()->GetNPCTypeID(),"EVENT_AGGRO_SAY")) { if(parse->HasQuestSub(GetTarget()->GetNPCTypeID(), "EVENT_AGGRO_SAY")) {
if (DistNoRootNoZ(*GetTarget()) <= 200) { if (DistNoRootNoZ(*GetTarget()) <= 200) {
parse->EventNPC(EVENT_AGGRO_SAY, GetTarget()->CastToNPC(), this, message, language); parse->EventNPC(EVENT_AGGRO_SAY, GetTarget()->CastToNPC(), this, message, language);
} }
@ -1100,13 +1110,12 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
char *Buffer = (char *)es; char *Buffer = (char *)es;
Buffer += 4; Buffer += 4;
snprintf(Buffer, sizeof(Emote_Struct) - 4, "%s %s", GetName(), message); snprintf(Buffer, sizeof(Emote_Struct) - 4, "%s %s", GetName(), message);
entity_list.QueueCloseClients(this, outapp, true, 100,0,true,FilterSocials); entity_list.QueueCloseClients(this, outapp, true, 100, 0, true, FilterSocials);
safe_delete(outapp); safe_delete(outapp);
break; break;
} }
default: { default: {
Message(0, "Channel (%i) not implemented",(uint16)chan_num); Message(0, "Channel (%i) not implemented", (uint16)chan_num);
} }
} }
} }
@ -7274,6 +7283,7 @@ void Client::DuplicateLoreMessage(uint32 ItemID)
void Client::GarbleMessage(char *message, uint8 variance) void Client::GarbleMessage(char *message, uint8 variance)
{ {
// Garble message by variance%
const char alpha_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // only change alpha characters for now const char alpha_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // only change alpha characters for now
for (size_t i = 0; i < strlen(message); i++) { for (size_t i = 0; i < strlen(message); i++) {

View File

@ -256,7 +256,7 @@ public:
void SendPacketQueue(bool Block = true); void SendPacketQueue(bool Block = true);
void QueuePacket(const EQApplicationPacket* app, bool ack_req = true, CLIENT_CONN_STATUS = CLIENT_CONNECTINGALL, eqFilterType filter=FilterNone); void QueuePacket(const EQApplicationPacket* app, bool ack_req = true, CLIENT_CONN_STATUS = CLIENT_CONNECTINGALL, eqFilterType filter=FilterNone);
void FastQueuePacket(EQApplicationPacket** app, bool ack_req = true, CLIENT_CONN_STATUS = CLIENT_CONNECTINGALL); void FastQueuePacket(EQApplicationPacket** app, bool ack_req = true, CLIENT_CONN_STATUS = CLIENT_CONNECTINGALL);
void ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_skill, const char* message, const char* targetname=NULL); void ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_skill, const char* orig_message, const char* targetname=NULL);
void ChannelMessageSend(const char* from, const char* to, uint8 chan_num, uint8 language, const char* message, ...); void ChannelMessageSend(const char* from, const char* to, uint8 chan_num, uint8 language, const char* message, ...);
void ChannelMessageSend(const char* from, const char* to, uint8 chan_num, uint8 language, uint8 lang_skill, const char* message, ...); void ChannelMessageSend(const char* from, const char* to, uint8 chan_num, uint8 language, uint8 lang_skill, const char* message, ...);
void Message(uint32 type, const char* message, ...); void Message(uint32 type, const char* message, ...);

View File

@ -717,7 +717,7 @@ bool Client::Process() {
#ifdef REVERSE_AGGRO #ifdef REVERSE_AGGRO
//At this point, we are still connected, everything important has taken //At this point, we are still connected, everything important has taken
//place, now check to see if anybody wants to aggro us. //place, now check to see if anybody wants to aggro us.
// Everhood 6/15/06 - only if client is not feigned // only if client is not feigned
if(ret && !GetFeigned() && scanarea_timer.Check()) { if(ret && !GetFeigned() && scanarea_timer.Check()) {
entity_list.CheckClientAggro(this); entity_list.CheckClientAggro(this);
} }
@ -775,7 +775,7 @@ bool Client::Process() {
} }
OnDisconnect(true); OnDisconnect(true);
} }
// EverHood Feign Death 2 minutes and zone forgets you // Feign Death 2 minutes and zone forgets you
if (forget_timer.Check()) { if (forget_timer.Check()) {
forget_timer.Disable(); forget_timer.Disable();
entity_list.ClearZoneFeignAggro(this); entity_list.ClearZoneFeignAggro(this);
@ -1339,7 +1339,7 @@ void Client::OPMoveCoin(const EQApplicationPacket* app)
{ {
case -1: // destroy case -1: // destroy
{ {
// solar: I don't think you can move coin from the void, // I don't think you can move coin from the void,
// but need to check this // but need to check this
break; break;
} }
@ -1532,7 +1532,7 @@ void Client::OPMoveCoin(const EQApplicationPacket* app)
// don't allow them to go into negatives (from our point of view) // don't allow them to go into negatives (from our point of view)
amount_to_take = *from_bucket < mc->amount ? *from_bucket : mc->amount; amount_to_take = *from_bucket < mc->amount ? *from_bucket : mc->amount;
// solar: if you move 11 gold into a bank platinum location, the packet // if you move 11 gold into a bank platinum location, the packet
// will say 11, but the client will have 1 left on their cursor, so we have // will say 11, but the client will have 1 left on their cursor, so we have
// to figure out the conversion ourselves // to figure out the conversion ourselves
@ -1542,14 +1542,10 @@ void Client::OPMoveCoin(const EQApplicationPacket* app)
// we have to adjust the amount we take as well // we have to adjust the amount we take as well
amount_to_take = amount_to_add * ((float)CoinTypeCoppers(mc->cointype2) / (float)CoinTypeCoppers(mc->cointype1)); amount_to_take = amount_to_add * ((float)CoinTypeCoppers(mc->cointype2) / (float)CoinTypeCoppers(mc->cointype1));
// solar: now we should have a from_bucket, a to_bucket, an amount_to_take // now we should have a from_bucket, a to_bucket, an amount_to_take
// and an amount_to_add // and an amount_to_add
#ifdef SOLAR // now we actually take it from the from bucket. if there's an error
printf("taking %d coins, adding %d coins\n", amount_to_take, amount_to_add);
#endif
// solar: now we actually take it from the from bucket. if there's an error
// with the destination slot, they lose their money // with the destination slot, they lose their money
*from_bucket -= amount_to_take; *from_bucket -= amount_to_take;
// why are intentionally inducing a crash here rather than letting the code attempt to stumble on? // why are intentionally inducing a crash here rather than letting the code attempt to stumble on?
@ -1573,13 +1569,6 @@ void Client::OPMoveCoin(const EQApplicationPacket* app)
} }
} }
#ifdef SOLAR
printf("from bucket = %d ", *from_bucket);
if(to_bucket)
printf("to bucket = %d", *to_bucket);
printf("\n");
#endif
// if this is a trade move, inform the person being traded with // if this is a trade move, inform the person being traded with
if(mc->to_slot == 3 && trader && trader->IsClient()) if(mc->to_slot == 3 && trader && trader->IsClient())
{ {