Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Today, 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, Google, Remcon

Members: 1
Guests: 14
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 » SWR FUSS » Conversion to FUSS area forma...
Forum Rules | Mark all | Recent Posts

Conversion to FUSS area format problem
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 27, 2009, 1:38 am
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

Well, I did the conversion and after a few mix ups got almost everything working. Unfortunately languages are acting screwy now. Only the first five languages are showing up anywhere as known. I can still set a mob as knowing any valid language with mset mob speaks language but only basic, wookiee, twi'lek, rodian and hutt show up as known languages. This includes characters. I can go to a mob set to teach languages and type language learn basic, and it says I'm fluent in it, which I am. But if I try anything other than one of the five it's showing that it's not a language.

Does anyone have any idea what might be going on here? I've double checked that all of the various arrays and things for languages are complete and in the correct order but other than that I don't know what else to do.
       
Post is unread #2 Sep 27, 2009, 6:25 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

If you get a chance post what you have for the languages code in saving and loading etc... as well as what it saves to the file on one of the ones that is loosing some of the languages it should know etc... as well as what you have setup to be valid langauges etc...
       
Post is unread #3 Sep 27, 2009, 7:58 am
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

You asked for it!

Saving
if( pMobIndex->speaks )
   fprintf( fpout, "Speaks     %s~\n", flag_string( pMobIndex->speaks, lang_names ) );
if( pMobIndex->speaking )
   fprintf( fpout, "Speaking   %s~\n", flag_string( pMobIndex->speaking, lang_names ) );

Loading
if( !str_cmp( word, "Speaks" ) )
{
   char *speaks = fread_flagstring( fp );

   while( speaks[0] != '\0' )
   {
      speaks = one_argument( speaks, flag );
      value = get_langflag( flag );
      if( value < 0 || value >= LANG_UNKNOWN )
         bug( "Unknown speaks language: %s", flag );
      else
         SET_BIT( pMobIndex->speaks, 1 << value );
   }

   if( !pMobIndex->speaks )
      pMobIndex->speaks = LANG_BASIC;
   break;
}

if( !str_cmp( word, "Speaking" ) )
{
   char *speaking = fread_flagstring( fp );

   while( speaking[0] != '\0' )
   {
      speaking = one_argument( speaking, flag );
      value = get_langflag( flag );
      if( value < 0 || value >= LANG_UNKNOWN )
         bug( "Unknown speaking language: %s", flag );
      else
         SET_BIT( pMobIndex->speaking, 1 << value );
   }

   if( !pMobIndex->speaking )
      pMobIndex->speaking = LANG_BASIC;
   break;
}

Here's Puff's language entry stuff in limbo.are
Speaks     basic wookiee twilek hutt gamorrean adarian~
Speaking   basic~

Also used during loading.
int get_langflag( char *flag )
{
   int x;

   for( x = 0; x != LANG_UNKNOWN; x++ )
      if( !str_cmp( flag, lang_names[x] ) )
         return x;
   return LANG_UNKNOWN;
}

And the language stuff from mud.h
#define LANG_BASIC        BV00  /* Human base language */
#define LANG_WOOKIEE      BV01
#define LANG_TWI_LEK      BV02
#define LANG_RODIAN       BV03
#define LANG_HUTT         BV04
#define LANG_MON_CALAMARI BV05
#define LANG_NOGHRI       BV06
#define LANG_EWOK         BV07
#define LANG_ITHORIAN     BV08
#define LANG_GOTAL        BV09
#define LANG_DEVARONIAN   BV10
#define LANG_BINARY       BV11
#define LANG_BARABEL      BV12
#define LANG_GEONOSIAN    BV13
#define LANG_GAMORREAN    BV14
#define LANG_YEVETHAN     BV15
#define LANG_GUNGAN       BV16
#define LANG_JAWA         BV17
#define LANG_ADARIAN      BV18
#define LANG_VERPINE      BV19
#define LANG_DEFEL        BV20
#define LANG_TRANDOSHAN   BV21
#define LANG_CHADRA_FAN   BV22
#define LANG_QUARREN      BV23
#define LANG_DUINUOGWUIN  BV24
#define LANG_ZABRAK       BV25
#define LANG_DATHOMIRI    BV26
#define LANG_BIMM         BV27
#define LANG_BOTHAN       BV28
#define LANG_CHISS        BV29
#define LANG_KUBAZ        BV30
#define LANG_CLAN         BV31
#define LANG_UNKNOWN      32 /* Anything that doesnt fit a category */

#define VALID_LANGS (  LANG_BASIC       | LANG_WOOKIEE      | LANG_TWI_LEK    | LANG_RODIAN   \
                     | LANG_HUTT        | LANG_MON_CALAMARI | LANG_NOGHRI     | LANG_EWOK     \
                     | LANG_ITHORIAN    | LANG_GOTAL        | LANG_DEVARONIAN | LANG_BINARY   \
                     | LANG_BARABEL     | LANG_GEONOSIAN    | LANG_GAMORREAN  | LANG_YEVETHAN \
                     | LANG_GUNGAN      | LANG_JAWA         | LANG_ADARIAN    | LANG_VERPINE  \
                     | LANG_DEFEL       | LANG_TRANDOSHAN   | LANG_CHADRA_FAN | LANG_QUARREN  \
                     | LANG_DUINUOGWUIN | LANG_ZABRAK       | LANG_DATHOMIRI  | LANG_BIMM     \
                     | LANG_BOTHAN      | LANG_CHISS        | LANG_KUBAZ )

From act_comm.c
int const lang_array[] = {
   LANG_BASIC, LANG_WOOKIEE, LANG_TWI_LEK, LANG_RODIAN,
   LANG_HUTT, LANG_MON_CALAMARI, LANG_NOGHRI, LANG_EWOK,
   LANG_ITHORIAN, LANG_GOTAL, LANG_DEVARONIAN, LANG_BINARY,
   LANG_BARABEL, LANG_GEONOSIAN, LANG_GAMORREAN, LANG_YEVETHAN,
   LANG_GUNGAN, LANG_JAWA, LANG_ADARIAN, LANG_VERPINE,
   LANG_DEFEL, LANG_TRANDOSHAN, LANG_CHADRA_FAN, LANG_QUARREN,
   LANG_DUINUOGWUIN, LANG_ZABRAK, LANG_DATHOMIRI, LANG_BIMM,
   LANG_BOTHAN, LANG_CHISS, LANG_KUBAZ, LANG_CLAN,
   LANG_UNKNOWN
};

char *const lang_names[] = {
   "basic", "wookiee", "twilek", "rodian",
   "hutt", "mon_calamari", "noghri", "ewok",
   "ithorian", "gotal", "devaronian", "binary",
   "barabel", "geonosian", "gamorrean", "yevethan",
   "gungan", "jawa", "adarian", "verpine",
   "defel", "trandoshan", "chadra-fan", "quarren",
   "duinuogwuin", "zabrak", "dathomiri", "bimm",
   "bothan", "chiss", "kubaz", "clan"
};

/* Language support functions. -- Altrag 07/01/96 */
bool knows_language( CHAR_DATA * ch, int language, CHAR_DATA * cch )
{
   short sn;

   if( !IS_NPC( ch ) && IS_IMMORTAL( ch ) )
      return true;
   if( !IS_NPC( cch ) && IS_IMMORTAL( cch ) )
      return true;
   if( IS_NPC( ch ) && !ch->speaks )   /* No langs = knows all for npcs */
      return true;
   if( IS_NPC( ch ) && IS_SET( ch->speaks, ( language & ~LANG_CLAN ) ) )
      return true;
   if( !IS_NPC( ch ) && IS_SET( ch->pcdata->cyber, CYBER_TRANSLATE ) )
      return true;

   if( language & LANG_CLAN )
   {
      /*
       * Clan = common for mobs.. snicker.. -- Altrag 
       */
      if( IS_NPC( ch ) || IS_NPC( cch ) )
         return true;
      if( ch->pcdata->clan == cch->pcdata->clan && ch->pcdata->clan != NULL )
         return true;
   }
   if( !IS_NPC( ch ) )
   {
      int lang;

      /*
       * Racial languages for PCs 
       */
      if( IS_SET( race_table[ch->race].language, language ) )
         return true;

      for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
         if( IS_SET( language, lang_array[lang] ) && IS_SET( ch->speaks, lang_array[lang] ) )
         {
            if( ( sn = skill_lookup( lang_names[lang] ) ) != -1 && ch->pcdata->learned[sn] >= 60 )
               return true;
         }
   }
   return false;
}

bool can_learn_lang( CHAR_DATA * ch, int language )
{
   if( language & LANG_CLAN )
      return false;
   if( IS_NPC( ch ) || IS_IMMORTAL( ch ) )
      return false;
   if( race_table[ch->race].language & language )
      return false;
   if( ch->speaks & language )
   {
      int lang;

      for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
         if( language & lang_array[lang] )
         {
            int sn;

            if( !( VALID_LANGS & lang_array[lang] ) )
               return false;
            if( ( sn = skill_lookup( lang_names[lang] ) ) < 0 )
            {
               bug( "Can_learn_lang: valid language without sn: %d", lang );
               continue;
            }
            if( ch->pcdata->learned[sn] >= 99 )
               return false;
         }
   }
   if( VALID_LANGS & language )
      return true;
   return false;
}

void do_languages( CHAR_DATA * ch, char *argument )
{
   char arg[MAX_INPUT_LENGTH];
   int lang;
   int sn;

   argument = one_argument( argument, arg );

   if( arg[0] != '\0' && !str_cmp( arg, "learn" ) && !IS_NPC( ch ) )
   {
      CHAR_DATA *sch;
      char arg2[MAX_INPUT_LENGTH];
      int prct;

      argument = one_argument( argument, arg2 );
      if( arg2[0] == '\0' )
      {
         send_to_char( "Learn which language?\n\r", ch );
         return;
      }
      for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      {
         if( lang_array[lang] == LANG_CLAN )
            continue;
         if( !str_cmp( arg2, lang_names[lang] ) )
            break;
      }
      if( lang_array[lang] == LANG_UNKNOWN )
      {
         send_to_char( "That is not a language.\n\r", ch );
         return;
      }
      if( !( VALID_LANGS & lang_array[lang] ) )
      {
         send_to_char( "You may not learn that language.\n\r", ch );
         return;
      }
      if( ( sn = skill_lookup( lang_names[lang] ) ) < 0 )
      {
         send_to_char( "That is not a language.\n\r", ch );
         return;
      }
      if( race_table[ch->race].language & lang_array[lang] || ch->pcdata->learned[sn] >= 99 )
      {
         act( AT_PLAIN, "You are already fluent in $t.", ch, lang_names[lang], NULL, TO_CHAR );
         return;
      }
      for( sch = ch->in_room->first_person; sch; sch = sch->next )
         if( IS_NPC( sch ) && sch->pcdata->flags.test( ACT_SCHOLAR ) &&
             knows_language( sch, ch->speaking, ch ) &&
             knows_language( sch, lang_array[lang], sch ) && ( !sch->speaking || knows_language( ch, sch->speaking, sch ) ) )
            break;
      if( !sch )
      {
         send_to_char( "There is no one who can teach that language here.\n\r", ch );
         return;
      }
      if( ch->gold < 25 )
      {
         send_to_char( "language lessons cost 25 credits... you don't have enough.\n\r", ch );
         return;
      }
      ch->gold -= 25;
      /*
       * Max 12% (5 + 4 + 3) at 24+ int and 21+ wis. -- Altrag 
       */
      prct = 5 + ( get_curr_int( ch ) / 6 ) + ( get_curr_wis( ch ) / 7 );
      ch->pcdata->learned[sn] += prct;
      ch->pcdata->learned[sn] = UMIN( ch->pcdata->learned[sn], 99 );
      SET_BIT( ch->speaks, lang_array[lang] );
      if( ch->pcdata->learned[sn] == prct )
         act( AT_PLAIN, "You begin lessons in $t.", ch, lang_names[lang], NULL, TO_CHAR );
      else if( ch->pcdata->learned[sn] < 60 )
         act( AT_PLAIN, "You continue lessons in $t.", ch, lang_names[lang], NULL, TO_CHAR );
      else if( ch->pcdata->learned[sn] < 60 + prct )
         act( AT_PLAIN, "You feel you can start communicating in $t.", ch, lang_names[lang], NULL, TO_CHAR );
      else if( ch->pcdata->learned[sn] < 99 )
         act( AT_PLAIN, "You become more fluent in $t.", ch, lang_names[lang], NULL, TO_CHAR );
      else
         act( AT_PLAIN, "You now speak perfect $t.", ch, lang_names[lang], NULL, TO_CHAR );
      return;
   }
   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
   {
      if( !( VALID_LANGS & lang_array[lang] ) )
         continue;
      if( ch->speaking & lang_array[lang] || ( IS_NPC( ch ) && !ch->speaking ) )
         set_char_color( AT_RED, ch );
      else
         set_char_color( AT_SAY, ch );
      if( ( sn = skill_lookup( lang_names[lang] ) ) < 0 )
         send_to_char( "(  0) ", ch );
      else
         ch_printf( ch, "(%3d) ", ch->pcdata->learned[sn] );
      if( ch->speaking & lang_array[lang] )
         ch_printf( ch, "%-12.12s [Speaking]", lang_names[lang] );
      else
         send_to_char( lang_names[lang], ch );
      send_to_char( "\n\r", ch );
   }
   send_to_char( "\n\r", ch );
   return;
}

And I'm spent. :)

That should be everything relating to languages as far as I know.
       
Post is unread #4 Sep 27, 2009, 8:30 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

Does it give bug messages on loading etc...? What are the exact lines it gives when you try to learn it etc... Yea its a fairly massive deal to get all the code rounded up lol.
       
Post is unread #5 Sep 27, 2009, 10:04 am
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

The log shows a clean startup.

Trying to learn a new language, "That is not a language." is the message I get. I put in some messages and determined that I was receiving the first instance of that, where lang_array[lang] == LANG_UNKNOWN. So I put a couple more messages into the for loop above it that looks for whatever language you're searching for.
      for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      {
         ch_printf( ch, "lang is %d, name is %s.\r\n", lang, lang_names[lang] );
         if( lang_array[lang] == LANG_CLAN )
            continue;
         if( !str_cmp( arg2, lang_names[lang] ) )
         {
            ch_printf( ch, "lang is %d, name is %s.\r\n", lang, lang_names[lang] );
            break;
         }
      }
      if( lang_array[lang] == LANG_UNKNOWN )
      {
         send_to_char( "That is not a language.\n\r", ch );
         ch_printf( ch, "%s", arg2 );
         return;
      }

And here's the output I get in-game when I try to learn a language.
lang learn zabrak
lang is 0, name is basic.
lang is 1, name is wookiee.
lang is 2, name is twilek.
lang is 3, name is rodian.
lang is 4, name is hutt.
That is not a language.
zabrak

It appears to be breaking out of the for loop prematurely after 5 iterations and somehow setting lang to 32. Even though the loop is only being run through 5 times...
       
Post is unread #6 Sep 27, 2009, 10:20 am   Last edited Sep 27, 2009, 10:28 am by Andril
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

Okay, I changed all the for loops from for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ ) to for( lang = 0; lang != LANG_UNKNOWN; lang++ ) and everything seems to be working properly now. I think what was happening was, because LANG_UNKNOWN is defined as 32, it was automatically stopping on LANG_MON_CALAMARI, which is equal to 32. Odd that it never happened before.

Now to figure out what's going on with mon_calamari not being a learnable language.

Meh, already answered my own question. LANG_MON_CALAMARI is 32..

BAH! I know what happened. LANG_UNKNOWN was originally 33 and I changed it to 32. Wasn't thinking that time was I? :)
       
Post is unread #7 Sep 27, 2009, 10:29 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

hmm try changing it to look like this
      for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      {
         ch_printf( ch, "1st: lang is %d, name is %s.\r\n", lang, lang_names[lang] );
         if( lang_array[lang] == LANG_CLAN )
            continue;
         if( !str_cmp( arg2, lang_names[lang] ) )
         {
            ch_printf( ch, "2nd: lang is %d, name is %s.\r\n", lang, lang_names[lang] );
            break;
         }
      }

Having them both show the same thing makes it kind of hard to know which one it is showing and since it is breaking out early need to make sure its not saying that arg2 is lang_names[lang]
       
Post is unread #8 Sep 27, 2009, 10:33 am
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

Heh you must've been writing that reply while I was editing my last one. I broke it in the first place and fixed it. Thanks for the help.
       
Post is unread #9 Sep 27, 2009, 10:39 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

Lol, np at least you figured it out :)
       
Post is unread #10 Sep 27, 2009, 11:04 am
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

It might be better to assign LANG_UNKNOWN as 0 rather than anything > 0. The reason being is that you can't have a valid BV that's equal to 0.
       
Post is unread #11 Oct 3, 2009, 7:34 am
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

What I'd like to do is convert languages over to std::bitset, then I can just change LANG_UNKNOWN to MAX_LANG and be happy, but I'm not 100% sure on what all the various bit specific operators do yet and I don't want to break stuff any more than I absolutely have to. I seem to do that regardless, but that's not the point. :)
       
Pages:<< prev 1 next >>