Login
User Name:

Password:



Register

Forgot your password?
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
SWRFUSS 1.4
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.4
Author: Various
Submitted by: Samson
Users Online
Bing

Members: 0
Guests: 18
Stats
Files
Topics
Posts
Members
Newest Member
487
3,788
19,630
595
Salan

Today's Birthdays
Gatz (39)
» SmaugMuds » 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 4, 2011 1:35 am   
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  .\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  .\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 10: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 >>