From 8eaac8cfda6d1e291731c27c09c74baea542b0c0 Mon Sep 17 00:00:00 2001 From: joligario Date: Sun, 17 Feb 2013 23:38:51 -0500 Subject: [PATCH] Chat garbled for drunk characters. --- changelog.txt | 1 + zone/client.cpp | 54 ++++++++++++++++++++++++----------------- zone/client.h | 2 +- zone/client_process.cpp | 23 +++++------------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/changelog.txt b/changelog.txt index 203909266..f1478c9b0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) Derision: Added optional guildid and minstatus parameters to quest::gmsay(, [color], [toworld], [guildid], [minstatus]) 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. +JJ: Chat garbled for drunk characters. == 02/16/2013 == demonstar55: Fix AA reuse timer calc diff --git a/zone/client.cpp b/zone/client.cpp index aae1ae4cb..5d13a3d37 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -751,7 +751,11 @@ void Client::FastQueuePacket(EQApplicationPacket** app, bool ack_req, CLIENT_CON 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 LogFile->write(EQEMuLog::Debug,"Client::ChannelMessageReceived() Channel:%i message:'%s'", chan_num, message); #endif @@ -806,8 +810,8 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s } - if(RuleB(QueryServ, PlayerChatLogging)){ - ServerPacket* pack = new ServerPacket(ServerOP_Speech, sizeof(Server_Speech_Struct)+strlen(message)+1); + if(RuleB(QueryServ, PlayerChatLogging)) { + ServerPacket* pack = new ServerPacket(ServerOP_Speech, sizeof(Server_Speech_Struct) + strlen(message) + 1); Server_Speech_Struct* sem = (Server_Speech_Struct*) pack->pBuffer; if(chan_num == 0) @@ -819,17 +823,23 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s sem->minstatus = this->Admin(); sem->type = chan_num; if(targetname != 0) - strcpy(sem->to,targetname); + strcpy(sem->to, targetname); if(GetName() != 0) - strcpy(sem->from,GetName()); - + strcpy(sem->from, GetName()); + pack->Deflate(); if(worldserver.Connected()) worldserver.SendPacket(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) { case 0: { // GuildChat @@ -843,7 +853,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s } case 2: { // GroupChat Raid* raid = entity_list.GetRaidByClient(this); - if(raid){ + if(raid) { raid->RaidGroupSay((const char*) message, this); break; } @@ -874,7 +884,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s { if(!global_channel_timer.Check()) { - if(strlen(targetname)==0) + if(strlen(targetname) == 0) ChannelMessageReceived(5, language, lang_skill, message, "discard"); //Fast typer or spammer?? else return; @@ -898,7 +908,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s if (!worldserver.SendChannelMessage(this, 0, 4, 0, language, message)) Message(0, "Error: World server disconnected"); } - else if(!RuleB(Chat, ServerWideAuction)){ + else if(!RuleB(Chat, ServerWideAuction)) { Mob *sender = this; if (GetPet() && GetPet()->FindType(SE_VoiceGraft)) @@ -913,8 +923,8 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s { if(!global_channel_timer.Check()) { - if(strlen(targetname)==0) - ChannelMessageReceived(5, language, lang_skill, message,"discard"); //Fast typer or spammer?? + if(strlen(targetname) == 0) + ChannelMessageReceived(5, language, lang_skill, message, "discard"); //Fast typer or spammer?? else return; } @@ -966,7 +976,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s case 7: { // Tell if(!global_channel_timer.Check()) { - if(strlen(targetname)==0) + if(strlen(targetname) == 0) ChannelMessageReceived(7, language, lang_skill, message, "discard"); //Fast typer or spammer?? else return; @@ -1013,12 +1023,12 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s } case 8: { // /say if(message[0] == COMMAND_CHAR) { - if(command_dispatch(this, message) == -2){ - if(RuleB(Chat, FlowCommandstoPerl_EVENT_SAY)){ - if(parse->PlayerHasQuestSub("EVENT_SAY")) { + if(command_dispatch(this, message) == -2) { + if(RuleB(Chat, FlowCommandstoPerl_EVENT_SAY)) { + if(parse->PlayerHasQuestSub("EVENT_SAY")) { parse->EventPlayer(EVENT_SAY, this, message, language); } - }else{ + } else { this->Message(13, "Command '%s' not recognized.", message); } } @@ -1044,9 +1054,9 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s if (GetTarget() != 0 && GetTarget()->IsNPC()) { if(!GetTarget()->CastToNPC()->IsEngaged()) { 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(GetTarget()->CastToNPC()->IsMoving() && !GetTarget()->CastToNPC()->IsOnHatelist(GetTarget())) GetTarget()->CastToNPC()->PauseWandering(RuleI(NPC, SayPauseTimeInSec)); @@ -1068,7 +1078,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s } } else { - if(parse->HasQuestSub(GetTarget()->GetNPCTypeID(),"EVENT_AGGRO_SAY")) { + if(parse->HasQuestSub(GetTarget()->GetNPCTypeID(), "EVENT_AGGRO_SAY")) { if (DistNoRootNoZ(*GetTarget()) <= 200) { parse->EventNPC(EVENT_AGGRO_SAY, GetTarget()->CastToNPC(), this, message, language); } @@ -1093,13 +1103,12 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s char *Buffer = (char *)es; Buffer += 4; 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); - break; } default: { - Message(0, "Channel (%i) not implemented",(uint16)chan_num); + Message(0, "Channel (%i) not implemented", (uint16)chan_num); } } } @@ -7267,6 +7276,7 @@ void Client::DuplicateLoreMessage(uint32 ItemID) void Client::GarbleMessage(char *message, uint8 variance) { + // Garble message by variance% const char alpha_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // only change alpha characters for now for (size_t i = 0; i < strlen(message); i++) { diff --git a/zone/client.h b/zone/client.h index 1cc8f4e42..a96b36e0a 100644 --- a/zone/client.h +++ b/zone/client.h @@ -256,7 +256,7 @@ public: void SendPacketQueue(bool Block = true); 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 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, uint8 lang_skill, const char* message, ...); void Message(uint32 type, const char* message, ...); diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 7b884309a..4a215a0f0 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -714,7 +714,7 @@ bool Client::Process() { #ifdef REVERSE_AGGRO //At this point, we are still connected, everything important has taken //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()) { entity_list.CheckClientAggro(this); } @@ -772,7 +772,7 @@ bool Client::Process() { } OnDisconnect(true); } - // EverHood Feign Death 2 minutes and zone forgets you + // Feign Death 2 minutes and zone forgets you if (forget_timer.Check()) { forget_timer.Disable(); entity_list.ClearZoneFeignAggro(this); @@ -1336,7 +1336,7 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) { 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 break; } @@ -1529,7 +1529,7 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) // don't allow them to go into negatives (from our point of view) 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 // to figure out the conversion ourselves @@ -1539,14 +1539,10 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) // we have to adjust the amount we take as well 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 -#ifdef SOLAR - 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 + // now we actually take it from the from bucket. if there's an error // with the destination slot, they lose their money *from_bucket -= amount_to_take; // why are intentionally inducing a crash here rather than letting the code attempt to stumble on? @@ -1570,13 +1566,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(mc->to_slot == 3 && trader && trader->IsClient()) {