The Dawn Of Time
The Official Forums for the Dawn Of Time Mud Codebase
 
Log in Register FAQ Memberlist Search The Dawn Of Time Forum Index Goto the Official Dawn Website

* char_position_text()

 
Post new topic   Reply to topic    The Dawn Of Time Forum Index » 1.69r typos and mobprog bugs fixed in the upcoming release
View previous topic :: View next topic  
Author Message
Daos



Joined: 29 Jan 2003
Posts: 1214
Location: United States

PostPosted: Wed Feb 22, 2006 10:22 am    Post subject: * char_position_text() Reply with quote

Hi -

Due to the 1.69r code being incomplete in handler.cpp, people will find themselves sitting on or resting on an object, and the visual output for others around them would be %s is sitting/resting in %s.

1.69R Code:

Code:
// char * char_position_text(char_data *ch )
// returns the correct position text for a characters position.
// eg " is <postion name> in <object_short>.",
//    " is <postion name> on <object_short>.",
//    " is <postion name> at <object_short>.",
//    " is <postion name> here."
char * char_position_text( char_data *ch)
{
   static char buf[MSL];
   sh_int pos = ch->position;

   if(ch->on != NULL)
   {         
      if(IS_SET(ch->on->value[2],SLEEP_AT))
      {
         sprintf(buf," is %s at %s.", position_table[pos].name
            ,ch->on->short_descr);
      }
      else
      {
         if(IS_SET(ch->on->value[2],SLEEP_ON))
         {
            sprintf(buf," is %s on %s.", position_table[pos].name
               ,ch->on->short_descr);
         }
         else
         {
            sprintf(buf," is %s in %s.", position_table[pos].name
               ,ch->on->short_descr);
         }
      }
   }
   else
   {
      sprintf(buf," is %s here.",  position_table[pos].name);
   }

   return(buf);
}


Below here is the completed code which will support character positions:

Code:
// char * char_position_text(char_data *ch )
// returns the correct position text for a characters position.
// eg " is <postion name> in <object_short>.",
//    " is <postion name> on <object_short>.",
//    " is <postion name> at <object_short>.",
//    " is <postion name> here."
char * char_position_text( char_data *ch)
{
   static char buf[MSL];
   sh_int pos = ch->position;

   if(ch->on != NULL){         
      if(IS_SET(ch->on->value[2],SLEEP_AT)){
         sprintf(buf," is %s at %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],SIT_AT)){
         sprintf(buf," is %s at %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],REST_AT)){
         sprintf(buf," is %s at %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],KNEEL_AT)){
         sprintf(buf," is %s at %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],SLEEP_ON)){
         sprintf(buf," is %s on %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2], SIT_ON)){
         sprintf(buf," is %s on %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2], REST_ON)){
         sprintf(buf," is %s on %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],KNEEL_ON)){
         sprintf(buf," is %s on %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],SLEEP_UNDER)){
         sprintf(buf," is %s under %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],SIT_UNDER)){
         sprintf(buf," is %s under %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],REST_UNDER)){
         sprintf(buf," is %s under %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],KNEEL_UNDER)){
         sprintf(buf," is %s under %s.", position_table[pos].name
            ,ch->on->short_descr);
      }else{
         sprintf(buf," is %s in %s.", position_table[pos].name
            ,ch->on->short_descr);
      }
   }else{
      sprintf(buf," is %s here.",  position_table[pos].name);
   }
   return(buf);
}


Cheers!



_________________
- Daos

http://www.dawnoftime.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website
spilinek



Joined: 17 Sep 2003
Posts: 217
Location: Massachusetts, USA

PostPosted: Wed Mar 01, 2006 4:18 am    Post subject: Reply with quote

Here's the same fix, but cleaned up to have similar cases share the same sprintf. I find this a bit easier to read.

Code:
// char * char_position_text(char_data *ch )
// returns the correct position text for a characters position.
// eg " is <postion name> in <object_short>.",
//    " is <postion name> on <object_short>.",
//    " is <postion name> at <object_short>.",
//    " is <postion name> here."
char * char_position_text( char_data *ch)
{
   static char buf[MSL];
   sh_int pos = ch->position;

   if(ch->on != NULL){         
      if(IS_SET(ch->on->value[2],SLEEP_AT)
       || IS_SET(ch->on->value[2],SIT_AT)
       || IS_SET(ch->on->value[2],REST_AT)
       || IS_SET(ch->on->value[2],KNEEL_AT))
     {
         sprintf(buf," is %s at %s.", position_table[pos].name, ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],SLEEP_ON)
            || IS_SET(ch->on->value[2],SIT_ON)
            || IS_SET(ch->on->value[2],REST_ON)
            || IS_SET(ch->on->value[2],KNEEL_ON))
     {
         sprintf(buf," is %s on %s.", position_table[pos].name, ch->on->short_descr);
      }else if(IS_SET(ch->on->value[2],SLEEP_UNDER)
            || IS_SET(ch->on->value[2],SIT_UNDER)
            || IS_SET(ch->on->value[2],REST_UNDER)
            || IS_SET(ch->on->value[2],KNEEL_UNDER))
     {
         sprintf(buf," is %s under %s.", position_table[pos].name, ch->on->short_descr);
      }else{
         sprintf(buf," is %s in %s.", position_table[pos].name, ch->on->short_descr);
      }
   }else{
      sprintf(buf," is %s here.", position_table[pos].name);
   }
   return(buf);
}



_________________
"Beer is proof that God loves us and wants us to be happy." -- Benjamin Franklin
Back to top
View user's profile Send private message MSN Messenger
Kalahn
Codebase Developer


Joined: 18 Jan 2003
Posts: 710
Location: New Zealand

PostPosted: Fri Mar 03, 2006 11:14 am    Post subject: Reply with quote

Thanks guys, well spotted.

You will have to wait to the release to see which version I used... well, you can probably guess by how much of a clean code freak I am Wink

- Kal


Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    The Dawn Of Time Forum Index » 1.69r typos and mobprog bugs fixed in the upcoming release All times are GMT + 13 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2005 phpBB Group
Theme created by Vjacheslav Trushkin