Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Yesterday, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Sogou, Yandex

Members: 0
Guests: 7
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SWFOTE FUSS » Likely bug in do_tell and do_...
Forum Rules | Mark all | Recent Posts

Likely bug in do_tell and do_reply
< Newer Topic :: Older Topic > Lets make a language barrier!

Pages:<< prev 1 next >>
Post is unread #1 Nov 3, 2011, 11:35 pm
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

So, it seems that the do_tell and do_reply have been rewrote a few times by looking at the code (note the do_oldtell). Anyhow, it seems that the original people working on it were going to have languages work in tells much like they do in general 'room says' (function do_say), at least judging by parts that are looking for knows_language.

Anyhow, I don't know if this is 100% correct, but it seems to work with out issues, likely could be cleaned up and I bet there is some extra junk in there...Anyhow, with out further ado I'll give you the original code and my modified version.
in act_comm.c function do_tell replace:
/* New tell - utilizing comfreq (Still in the works) */
void do_tell( CHAR_DATA * ch, const char *argument )
{
	char arg[MAX_INPUT_LENGTH];
	char buf[MAX_INPUT_LENGTH];
	CHAR_DATA *victim;
	int position;
	CHAR_DATA *switched_victim;
	bool ch_comlink;
	bool victim_comlink;
	OBJ_DATA *obj;
	CHAR_DATA *vict2;

	switched_victim = NULL;

	if( IS_SET( ch->deaf, CHANNEL_TELLS ) && !IS_IMMORTAL( ch ) )
	{
		act( AT_PLAIN, "You have tells turned off... try chan +tells first", ch, NULL, NULL, TO_CHAR );
		return;
	}

	if( IS_SET( ch->in_room->room_flags, ROOM_SILENCE ) )
	{
		send_to_char( "You can't do that here.\r\n", ch );
		return;
	}

	if( !IS_NPC( ch ) && ( IS_SET( ch->act, PLR_SILENCE ) || IS_SET( ch->act, PLR_NO_TELL ) ) )
	{
		send_to_char( "You can't do that.\r\n", ch );
		return;
	}

	if( !IS_NPC( ch ) && IS_SET( ch->pcdata->act2, ACT_GAGGED ) )
	{
		send_to_char( "You can't say anything! You're gagged!\r\n", ch );
		return;
	}

	argument = one_argument( argument, arg );

	if( arg[0] == '\0' || argument[0] == '\0' )
	{
		send_to_char( "Usage: tell <frequency> <message>.\r\n", ch );
		return;
	}

	if( ( victim = get_char_from_comfreq( ch, arg ) ) == NULL
			|| ( IS_NPC( victim ) && victim->in_room != ch->in_room )
			|| ( !NOT_AUTHED( ch ) && NOT_AUTHED( victim ) && !IS_IMMORTAL( ch ) )
			|| ( IS_IMMORTAL( victim ) && !can_see( ch, victim ) ) )
	{
		send_to_char( "There is no response.\r\n", ch );
		return;
	}

	if( ch == victim )
	{
		send_to_char( "You have a nice little chat with yourself.\r\n", ch );
		return;
	}

	if( victim->in_room != ch->in_room && !IS_IMMORTAL( ch ) )
	{
		ch_comlink = FALSE;
		victim_comlink = FALSE;

		for( obj = ch->last_carrying; obj; obj = obj->prev_content )
		{
			if( obj->pIndexData->item_type == ITEM_COMLINK )
				ch_comlink = TRUE;
		}

		if( IS_IMMORTAL( victim ) )
			ch_comlink = TRUE;
		victim_comlink = TRUE;

		if( !ch_comlink )
		{
			send_to_char( "You need a comlink to do that.\r\n", ch );
			return;
		}

		for( obj = victim->last_carrying; obj; obj = obj->prev_content )
		{
			if( obj->pIndexData->item_type == ITEM_COMLINK )
				victim_comlink = TRUE;
		}

		if( !victim_comlink )
		{
			send_to_char( "There is no response.\r\n", ch );
			return;
		}

	}

	if( NOT_AUTHED( ch ) && !NOT_AUTHED( victim ) && !IS_IMMORTAL( victim ) )
	{
		send_to_char( "They can't hear you because you are not authorized.\r\n", ch );
		return;
	}

	if( !IS_NPC( victim ) && ( victim->switched )
			&& ( get_trust( ch ) > LEVEL_AVATAR )
			&& !IS_SET( victim->switched->act, ACT_POLYMORPHED ) && !IS_AFFECTED( victim->switched, AFF_POSSESS ) )
	{
		send_to_char( "That player is switched.\r\n", ch );
		return;
	}

	else if( !IS_NPC( victim ) && ( victim->switched )
			&& ( IS_SET( victim->switched->act, ACT_POLYMORPHED ) || IS_AFFECTED( victim->switched, AFF_POSSESS ) ) )
		switched_victim = victim->switched;

	else if( !IS_NPC( victim ) && ( !victim->desc ) )
	{
		send_to_char( "That player is link-dead.\r\n", ch );
		return;
	}

	if( !IS_NPC( victim ) && ( IS_SET( victim->act, PLR_AFK ) ) )
	{
		send_to_char( "That player is afk.\r\n", ch );
		return;
	}

	if( IS_SET( victim->deaf, CHANNEL_TELLS ) && ( !IS_IMMORTAL( ch ) || ( get_trust( ch ) < get_trust( victim ) ) ) )
	{
		act( AT_PLAIN, "$E has $S tells turned off.", ch, NULL, victim, TO_CHAR );
		return;
	}

	if( !IS_NPC( victim ) && ( IS_SET( victim->act, PLR_SILENCE ) ) )
	{
		send_to_char( "That player is silenced.  They will receive your message but can not respond.\r\n", ch );
	}

	if( ( !IS_IMMORTAL( ch ) && !IS_AWAKE( victim ) )
			|| ( !IS_NPC( victim ) && IS_SET( victim->in_room->room_flags, ROOM_SILENCE ) ) )
	{
		act( AT_PLAIN, "There is no response.", ch, 0, victim, TO_CHAR );
		return;
	}

	if( victim->desc && victim->desc->connected == CON_EDITING && get_trust( ch ) < LEVEL_GOD )
	{
		act( AT_PLAIN, "$E is currently in a writing buffer.  Please try again in a few minutes.", ch, 0, victim, TO_CHAR );
		return;
	}


	if( switched_victim )
		victim = switched_victim;

	show_spys( ch, victim, argument );

	if( !IS_IMMORTAL( victim ) && !IS_IMMORTAL( ch ) )
	{
		for( vict2 = first_char; vict2; vict2 = vict2->next )
		{
			if( !str_cmp( arg, vict2->comfreq ) )
			{
				if( knows_language( vict2, ch->speaking, ch ) || ( IS_NPC( ch ) && !ch->speaking ) )
					ch_printf( vict2, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n",
							IS_IMMORTAL( ch ) ? ch->name : IS_IMMORTAL( vict2 ) ? ch->name : ch->comfreq, argument );
				else
					ch_printf( vict2, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n",
							IS_IMMORTAL( ch ) ? ch->name : IS_IMMORTAL( vict2 ) ? ch->name : ch->comfreq, argument );

			}
		}
	}
	else
		ch_printf( victim, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n", ch->name, argument );

	if( IS_IMMORTAL( ch ) || IS_IMMORTAL( victim ) )
		ch_printf( ch, "&W&G[&WSent Message to: &w%s&G]&W: %s\r\n", victim->name, argument );
	else
		ch_printf( ch, "&W&G[&WSent Message to: &w%s&G]&W: %s\r\n", arg, argument );

	position = victim->position;
	victim->position = POS_STANDING;
	victim->position = position;
	victim->reply = ch;
	if( IS_SET( ch->in_room->room_flags, ROOM_LOGSPEECH ) )
	{
		sprintf( buf, "%s: %s (tell to) %s.",
				IS_NPC( ch ) ? ch->short_descr : ch->name, argument, IS_NPC( victim ) ? victim->short_descr : victim->name );
		append_to_file( LOG_FILE, buf );
	}
	mprog_speech_trigger( argument, ch );
	return;
}

With:
/* New tell - utilizing comfreq (Still in the works) */
void do_tell( CHAR_DATA * ch, const char *argument )
{
	char arg[MAX_INPUT_LENGTH];
	char buf[MAX_INPUT_LENGTH];
	char buf2[MAX_INPUT_LENGTH];
	char sbuf[MAX_INPUT_LENGTH];
	CHAR_DATA *victim;
	int position;
	CHAR_DATA *switched_victim;
	bool ch_comlink;
	bool victim_comlink;
	OBJ_DATA *obj;
	CHAR_DATA *vict2;

	switched_victim = NULL;

	if( IS_SET( ch->deaf, CHANNEL_TELLS ) && !IS_IMMORTAL( ch ) )
	{
		act( AT_PLAIN, "You have tells turned off... try chan +tells first", ch, NULL, NULL, TO_CHAR );
		return;
	}

	if( IS_SET( ch->in_room->room_flags, ROOM_SILENCE ) )
	{
		send_to_char( "You can't do that here.\r\n", ch );
		return;
	}

	if( !IS_NPC( ch ) && ( IS_SET( ch->act, PLR_SILENCE ) || IS_SET( ch->act, PLR_NO_TELL ) ) )
	{
		send_to_char( "You can't do that.\r\n", ch );
		return;
	}

	if( !IS_NPC( ch ) && IS_SET( ch->pcdata->act2, ACT_GAGGED ) )
	{
		send_to_char( "You can't say anything! You're gagged!\r\n", ch );
		return;
	}

	argument = one_argument( argument, arg );

	if( arg[0] == '\0' || argument[0] == '\0' )
	{
		send_to_char( "Usage: tell <frequency> <message>.\r\n", ch );
		return;
	}

	if( ( victim = get_char_from_comfreq( ch, arg ) ) == NULL
			|| ( IS_NPC( victim ) && victim->in_room != ch->in_room )
			|| ( !NOT_AUTHED( ch ) && NOT_AUTHED( victim ) && !IS_IMMORTAL( ch ) )
			|| ( IS_IMMORTAL( victim ) && !can_see( ch, victim ) ) )
	{
		send_to_char( "There is no response.\r\n", ch );
		return;
	}

	if( ch == victim )
	{
		send_to_char( "You have a nice little chat with yourself.\r\n", ch );
		return;
	}

	if( victim->in_room != ch->in_room && !IS_IMMORTAL( ch ) )
	{
		ch_comlink = FALSE;
		victim_comlink = FALSE;

		for( obj = ch->last_carrying; obj; obj = obj->prev_content )
		{
			if( obj->pIndexData->item_type == ITEM_COMLINK )
				ch_comlink = TRUE;
		}

		if( IS_IMMORTAL( victim ) )
			ch_comlink = TRUE;
		victim_comlink = TRUE;

		if( !ch_comlink )
		{
			send_to_char( "You need a comlink to do that.\r\n", ch );
			return;
		}

		for( obj = victim->last_carrying; obj; obj = obj->prev_content )
		{
			if( obj->pIndexData->item_type == ITEM_COMLINK )
				victim_comlink = TRUE;
		}

		if( !victim_comlink )
		{
			send_to_char( "There is no response.\r\n", ch );
			return;
		}

	}

	if( NOT_AUTHED( ch ) && !NOT_AUTHED( victim ) && !IS_IMMORTAL( victim ) )
	{
		send_to_char( "They can't hear you because you are not authorized.\r\n", ch );
		return;
	}

	if( !IS_NPC( victim ) && ( victim->switched )
			&& ( get_trust( ch ) > LEVEL_AVATAR )
			&& !IS_SET( victim->switched->act, ACT_POLYMORPHED ) && !IS_AFFECTED( victim->switched, AFF_POSSESS ) )
	{
		send_to_char( "That player is switched.\r\n", ch );
		return;
	}

	else if( !IS_NPC( victim ) && ( victim->switched )
			&& ( IS_SET( victim->switched->act, ACT_POLYMORPHED ) || IS_AFFECTED( victim->switched, AFF_POSSESS ) ) )
		switched_victim = victim->switched;

	else if( !IS_NPC( victim ) && ( !victim->desc ) )
	{
		send_to_char( "That player is link-dead.\r\n", ch );
		return;
	}

	if( !IS_NPC( victim ) && ( IS_SET( victim->act, PLR_AFK ) ) )
	{
		send_to_char( "That player is afk.\r\n", ch );
		return;
	}

	if( IS_SET( victim->deaf, CHANNEL_TELLS ) && ( !IS_IMMORTAL( ch ) || ( get_trust( ch ) < get_trust( victim ) ) ) )
	{
		act( AT_PLAIN, "$E has $S tells turned off.", ch, NULL, victim, TO_CHAR );
		return;
	}

	if( !IS_NPC( victim ) && ( IS_SET( victim->act, PLR_SILENCE ) ) )
	{
		send_to_char( "That player is silenced.  They will receive your message but can not respond.\r\n", ch );
	}

	if( ( !IS_IMMORTAL( ch ) && !IS_AWAKE( victim ) )
			|| ( !IS_NPC( victim ) && IS_SET( victim->in_room->room_flags, ROOM_SILENCE ) ) )
	{
		act( AT_PLAIN, "There is no response.", ch, 0, victim, TO_CHAR );
		return;
	}

	if( victim->desc && victim->desc->connected == CON_EDITING && get_trust( ch ) < LEVEL_GOD )
	{
		act( AT_PLAIN, "$E is currently in a writing buffer.  Please try again in a few minutes.", ch, 0, victim, TO_CHAR );
		return;
	}


	if( switched_victim )
		victim = switched_victim;

		if( !IS_IMMORTAL( victim ) && !IS_IMMORTAL( ch ) )
	{
		for( vict2 = first_char; vict2; vict2 = vict2->next )
		{
			if( !str_cmp( arg, vict2->comfreq ) )
			{
				
				if( knows_language( vict2, ch->speaking, ch ) || ( IS_NPC( ch ) && !ch->speaking ) )
				{
					ch_printf( vict2, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n",
							IS_IMMORTAL( ch ) ? ch->name : IS_IMMORTAL( vict2 ) ? ch->name : ch->comfreq, argument );
					
					show_spys( ch, vict2, argument );
				}
				if( !knows_language( vict2, ch->speaking, ch ) || ( IS_NPC( ch ) && !ch->speaking ) )
				{
					strcpy( buf2, argument);
					snprintf(sbuf, MIL, "%s", scramble (buf2, ch->speaking));
					ch_printf( vict2, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n",
							IS_IMMORTAL( ch ) ? ch->name : IS_IMMORTAL( vict2 ) ? ch->name : ch->comfreq, sbuf);		
					
					show_spys( ch, vict2, sbuf);
				}

			}
		}
	}
	else
		ch_printf( victim, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n", ch->name, argument );

	if( IS_IMMORTAL( ch ) || IS_IMMORTAL( victim ) )
		ch_printf( ch, "&W&G[&WSent Message to: &w%s&G]&W: %s\r\n", victim->name, argument );
	else
		ch_printf( ch, "&W&G[&WSent Message to: &w%s&G]&W: %s\r\n", arg, argument );

	position = victim->position;
	victim->position = POS_STANDING;
	victim->position = position;
	victim->reply = ch;
	if( IS_SET( ch->in_room->room_flags, ROOM_LOGSPEECH ) )
	{
		sprintf( buf, "%s: %s (tell to) %s.",
				IS_NPC( ch ) ? ch->short_descr : ch->name, argument, IS_NPC( victim ) ? victim->short_descr : victim->name );
		append_to_file( LOG_FILE, buf );
	}
	mprog_speech_trigger( argument, ch );
	return;
}

What the above is doing is now making the person on the other end know the language being spoken. This is also effecting the function show_spy, so the person doing the spying also needs to know the language as well. See the new show_spy function later on.

act_comm.c function do_reply replace:
void do_reply( CHAR_DATA * ch, const char *argument )
{
	char buf[MAX_STRING_LENGTH];
	CHAR_DATA *victim;
	int position;
	bool ch_comlink;
	bool victim_comlink;
	OBJ_DATA *obj;

	if( argument[0] == '\0' )
	{
		send_to_char( "Reply with what?\r\n", ch );
		return;
	}

	REMOVE_BIT( ch->deaf, CHANNEL_TELLS );
	if( IS_SET( ch->in_room->room_flags, ROOM_SILENCE ) )
	{
		send_to_char( "You can't do that here.\r\n", ch );
		return;
	}

	if( !IS_NPC( ch ) && IS_SET( ch->act, PLR_SILENCE ) )
	{
		send_to_char( "Your message didn't get through.\r\n", ch );
		return;
	}

	if( !IS_NPC( ch ) && IS_SET( ch->pcdata->act2, ACT_GAGGED ) )
	{
		send_to_char( "You can't say anything! You're gagged!\r\n", ch );
		return;
	}

	if( ( victim = ch->reply ) == NULL )
	{
		send_to_char( "There is no response.\r\n", ch );
		return;
	}

	if( !IS_NPC( victim ) && ( victim->switched ) && can_see( ch, victim ) && ( get_trust( ch ) > LEVEL_AVATAR ) )
	{
		send_to_char( "That player is switched.\r\n", ch );
		return;
	}
	else if( !IS_NPC( victim ) && ( !victim->desc ) )
	{
		send_to_char( "That player is link-dead.\r\n", ch );
		return;
	}

	if( !IS_NPC( victim ) && ( IS_SET( victim->act, PLR_AFK ) ) )
	{
		send_to_char( "That player is afk.\r\n", ch );
		return;
	}

	if( IS_SET( victim->deaf, CHANNEL_TELLS ) && ( !IS_IMMORTAL( ch ) || ( get_trust( ch ) < get_trust( victim ) ) ) )
	{
		act( AT_PLAIN, "$E has $S tells turned off.", ch, NULL, victim, TO_CHAR );
		return;
	}

	if( victim->in_room != ch->in_room && !IS_IMMORTAL( ch ) )
	{
		ch_comlink = FALSE;
		victim_comlink = FALSE;

		for( obj = ch->last_carrying; obj; obj = obj->prev_content )
		{
			if( obj->pIndexData->item_type == ITEM_COMLINK )
				ch_comlink = TRUE;
		}

		if( IS_IMMORTAL( victim ) )
			ch_comlink = TRUE;
		victim_comlink = TRUE;

		if( !ch_comlink )
		{
			send_to_char( "You need a comlink to do that.\r\n", ch );
			return;
		}

		for( obj = victim->last_carrying; obj; obj = obj->prev_content )
		{
			if( obj->pIndexData->item_type == ITEM_COMLINK )
				victim_comlink = TRUE;
		}

		if( !victim_comlink )
		{
			send_to_char( "There is no response.\r\n", ch );
			return;
		}

	}

	if( ( !IS_IMMORTAL( ch ) && !IS_AWAKE( victim ) )
			|| ( !IS_NPC( victim ) && IS_SET( victim->in_room->room_flags, ROOM_SILENCE ) ) )
	{
		send_to_char( "There is no response.\r\n", ch );
		return;
	}

	show_spys( ch, victim, argument );

	if( knows_language( victim, ch->speaking, ch ) || ( IS_NPC( ch ) && !ch->speaking ) )
		ch_printf( victim, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n",
				IS_IMMORTAL( ch ) ? ch->name : IS_IMMORTAL( victim ) ? ch->name : ch->comfreq, argument );
	else
		ch_printf( victim, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n",
				IS_IMMORTAL( ch ) ? ch->name : IS_IMMORTAL( victim ) ? ch->name : ch->comfreq, argument );

	ch_printf( ch, "&W&G[&WSent Message to: &w%s&G]&W: %s\r\n",
			IS_IMMORTAL( ch ) ? victim->name : IS_IMMORTAL( victim ) ? victim->name : victim->comfreq, argument );


	position = victim->position;
	victim->position = POS_STANDING;
	victim->position = position;
	victim->reply = ch;
	if( IS_SET( ch->in_room->room_flags, ROOM_LOGSPEECH ) )
	{
		sprintf( buf, "%s: %s (reply to) %s.",
				IS_NPC( ch ) ? ch->short_descr : ch->name, argument, IS_NPC( victim ) ? victim->short_descr : victim->name );
		append_to_file( LOG_FILE, buf );
	}

	return;
}

Replace with:
void do_reply( CHAR_DATA * ch, const char *argument )
{
	char buf[MAX_STRING_LENGTH];
	char buf2[MAX_STRING_LENGTH];
	char sbuf[MAX_STRING_LENGTH];
	CHAR_DATA *victim;
	int position;
	bool ch_comlink;
	bool victim_comlink;
	OBJ_DATA *obj;

	if( argument[0] == '\0' )
	{
		send_to_char( "Reply with what?\r\n", ch );
		return;
	}

	REMOVE_BIT( ch->deaf, CHANNEL_TELLS );
	if( IS_SET( ch->in_room->room_flags, ROOM_SILENCE ) )
	{
		send_to_char( "You can't do that here.\r\n", ch );
		return;
	}

	if( !IS_NPC( ch ) && IS_SET( ch->act, PLR_SILENCE ) )
	{
		send_to_char( "Your message didn't get through.\r\n", ch );
		return;
	}

	if( !IS_NPC( ch ) && IS_SET( ch->pcdata->act2, ACT_GAGGED ) )
	{
		send_to_char( "You can't say anything! You're gagged!\r\n", ch );
		return;
	}

	if( ( victim = ch->reply ) == NULL )
	{
		send_to_char( "There is no response.\r\n", ch );
		return;
	}

	if( !IS_NPC( victim ) && ( victim->switched ) && can_see( ch, victim ) && ( get_trust( ch ) > LEVEL_AVATAR ) )
	{
		send_to_char( "That player is switched.\r\n", ch );
		return;
	}
	else if( !IS_NPC( victim ) && ( !victim->desc ) )
	{
		send_to_char( "That player is link-dead.\r\n", ch );
		return;
	}

	if( !IS_NPC( victim ) && ( IS_SET( victim->act, PLR_AFK ) ) )
	{
		send_to_char( "That player is afk.\r\n", ch );
		return;
	}

	if( IS_SET( victim->deaf, CHANNEL_TELLS ) && ( !IS_IMMORTAL( ch ) || ( get_trust( ch ) < get_trust( victim ) ) ) )
	{
		act( AT_PLAIN, "$E has $S tells turned off.", ch, NULL, victim, TO_CHAR );
		return;
	}

	if( victim->in_room != ch->in_room && !IS_IMMORTAL( ch ) )
	{
		ch_comlink = FALSE;
		victim_comlink = FALSE;

		for( obj = ch->last_carrying; obj; obj = obj->prev_content )
		{
			if( obj->pIndexData->item_type == ITEM_COMLINK )
				ch_comlink = TRUE;
		}

		if( IS_IMMORTAL( victim ) )
			ch_comlink = TRUE;
		victim_comlink = TRUE;

		if( !ch_comlink )
		{
			send_to_char( "You need a comlink to do that.\r\n", ch );
			return;
		}

		for( obj = victim->last_carrying; obj; obj = obj->prev_content )
		{
			if( obj->pIndexData->item_type == ITEM_COMLINK )
				victim_comlink = TRUE;
		}

		if( !victim_comlink )
		{
			send_to_char( "There is no response.\r\n", ch );
			return;
		}

	}

	if( ( !IS_IMMORTAL( ch ) && !IS_AWAKE( victim ) )
			|| ( !IS_NPC( victim ) && IS_SET( victim->in_room->room_flags, ROOM_SILENCE ) ) )
	{
		send_to_char( "There is no response.\r\n", ch );
		return;
	}

	//	show_spys( ch, victim, argument );

	if( knows_language( victim, ch->speaking, ch ) || ( IS_NPC( ch ) && !ch->speaking ) )
	{
		ch_printf( victim, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n", IS_IMMORTAL( ch ) ? ch->name : IS_IMMORTAL( victim ) ? ch->name : ch->comfreq, argument );
		show_spys( ch, victim, argument );
	}
	if( !knows_language( victim, ch->speaking, ch ) || ( IS_NPC( ch ) && !ch->speaking ) )
	{
		strcpy( buf2, argument);
		snprintf(sbuf, MIL, "%s", scramble (buf2, ch->speaking));
		ch_printf( victim, "&W&G[&WIncoming Message from: &w%s&G]&W: %s\r\n",
				IS_IMMORTAL( ch ) ? ch->name : IS_IMMORTAL( victim ) ? ch->name : ch->comfreq, sbuf);
		show_spys( ch, victim, sbuf);
	}


	ch_printf( ch, "&W&G[&WSent Message to: &w%s&G]&W: %s\r\n",
			IS_IMMORTAL( ch ) ? victim->name : IS_IMMORTAL( victim ) ? victim->name : victim->comfreq, argument );


	position = victim->position;
	victim->position = POS_STANDING;
	victim->position = position;
	victim->reply = ch;
	if( IS_SET( ch->in_room->room_flags, ROOM_LOGSPEECH ) )
	{
		sprintf( buf, "%s: %s (reply to) %s.",
				IS_NPC( ch ) ? ch->short_descr : ch->name, argument, IS_NPC( victim ) ? victim->short_descr : victim->name );
		append_to_file( LOG_FILE, buf );
	}

	return;
}

Once again, what the above is doing is now making the person on the other end know the language being spoken. This is also effecting the function show_spy, so the person doing the spying also needs to know the language as well. See the new show_spy function later on.

Lastly, lets modify our show_spy() function to take advantage of the new language barrier.
act_comm.c function show_spy replace:
void show_spys( CHAR_DATA * ch, CHAR_DATA * victim, const char *tell )
{
        CHAR_DATA *och;

        if( IS_NPC( ch ) || IS_NPC( victim ) || IS_IMMORTAL( ch ) || IS_IMMORTAL( victim ) )
                return;

        for( och = first_char; och; och = och->next )
        {
                if( IS_NPC( och ) || !och->comfreq )
                        continue;
                if( knows_language(och, ch->speaking, ch) )
                {
                        if( !str_cmp( och->pcdata->tell_snoop, ch->comfreq ) || !str_cmp( och->pcdata->tell_snoop, victim->comfreq ) )
                                ch_printf( och, "&B[&cINTERCEPTED MESSAGE&b]\r\n&B(&YSent: &G&W%s&B) (&Yto: &G&W%s&B) (&Ymessage&B) &G&W %s\r\n",
                                                ch->comfreq, victim->comfreq, tell );
                }
                if( !knows_language(och, ch->speaking, ch) )
                        ch_printf(och,  "&B[&cINTERCEPTED MESSAGE&b]\r\n&B(&YSent: &G&W%s&B) (&Yto: &G&W%s&B) &WYou can't make out what language is being spoken\n\r", ch->comfreq, victim->comfreq);
//The above line is a bit of an easy way out, however gets the point to the player. Still shows their comfreq to and from.

        }
}


Ok as I stated in the start of this post, I'm not going to say its perfect. I think I've accounted for everything I can think of, however I'm more than welcome to suggestions to clean it up. It all seems to compile clean (gcc 4.6) and works for my game in testing. This is mostly for the 'clan' language support as its trivially easy to learn all the other languages in the game in matter of seconds, so that might be something that you'll have to deal with on your own.

ayuri
       
Post is unread #2 Nov 4, 2011, 8:55 am
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

I'm sorry, I goofed. In my haste to get some sleep last night, I didn't post the original show_spy.
The last code block is actually the replacement. This is the original:
void show_spys( CHAR_DATA * ch, CHAR_DATA * victim, const char *tell )
{
        CHAR_DATA *och;

        if( IS_NPC( ch ) || IS_NPC( victim ) || IS_IMMORTAL( ch ) || IS_IMMORTAL( victim ) )
                return;

        for( och = first_char; och; och = och->next )
        {
                if( IS_NPC( och ) || !och->comfreq )
                        continue;

                if( !str_cmp( och->pcdata->tell_snoop, ch->comfreq ) || !str_cmp( och->pcdata->tell_snoop, victim->comfreq ) )
                        ch_printf( och, "&B[&cINTERCEPTED MESSAGE&b]\r\n&B(&YSent: &G&W%s&B) (&Yto: &G&W%s&B) (&Ymessage&B) &G&W %s\r\n",
                                        ch->comfreq, victim->comfreq, tell );

        }
}


Replace that with
void show_spys( CHAR_DATA * ch, CHAR_DATA * victim, const char *tell )
{
        CHAR_DATA *och;

        if( IS_NPC( ch ) || IS_NPC( victim ) || IS_IMMORTAL( ch ) || IS_IMMORTAL( victim ) )
                return;

        for( och = first_char; och; och = och->next )
        {
                if( IS_NPC( och ) || !och->comfreq )
                        continue;
                if( knows_language(och, ch->speaking, ch) )
                {
                        if( !str_cmp( och->pcdata->tell_snoop, ch->comfreq ) || !str_cmp( och->pcdata->tell_snoop, victim->comfreq ) )
                                ch_printf( och, "&B[&cINTERCEPTED MESSAGE&b]\r\n&B(&YSent: &G&W%s&B) (&Yto: &G&W%s&B) (&Ymessage&B) &G&W %s\r\n",
                                                ch->comfreq, victim->comfreq, tell );
                }
                if( !knows_language(och, ch->speaking, ch) )
                        ch_printf(och,  "&B[&cINTERCEPTED MESSAGE&b]\r\n&B(&YSent: &G&W%s&B) (&Yto: &G&W%s&B) &WYou can't make out what language is being spoken\n\r", ch->comfreq, victim->comfreq);
//The above line is a bit of an easy way out, however gets the point to the player. Still shows their comfreq to and from.

        }
}


ayuri
       
Pages:<< prev 1 next >>