Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Development
Nov 28, 2018, 10:10 am
By Keirath
First Immortal
Oct 12, 2018, 12:02 pm
By GatewaySysop
Bug in do_climb( )
Jun 5, 2018, 5:31 pm
By joeyfogas
question on overland code
May 31, 2018, 10:03 am
By joeyfogas
KaVir's Protocol Snip
May 15, 2018, 7:57 pm
By joeyfogas
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Bing, DotBot

Members: 0
Guests: 13
Stats
Files
Topics
Posts
Members
Newest Member
481
3,740
19,397
640
KieraZajac
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SWFOTE FUSS Bugfix List » [Bug] Numerous problems with ...
Forum Rules | Mark all | Recent Posts

[Bug] Numerous problems with droptroops command
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Oct 29, 2006, 1:50 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,644
JoinedJan 1, 2002

Bug: Numerous problems with droptroops command
Danger: Medium - Some crashers and other security problems
Found by: Phoneix Dracul
Fixed by: Keberus

---

misc.c, do_droptroops

Replace the function with:
#define MAX_DROP_TROOPS 20

//do_droptroops fixed by KeB 10/24/06
void do_droptroops( CHAR_DATA *ch, char *argument )
{
   int num, vnum, i;
   SHIP_DATA *ship;
   CHAR_DATA *mob;
   MOB_INDEX_DATA  * pMobIndex;
   OBJ_DATA        * blaster;
   OBJ_INDEX_DATA  * pObjIndex;
   ROOM_INDEX_DATA *room, *rtest;
   char tmpbuf[MAX_STRING_LENGTH];

   if( ch->pcdata->clan == NULL )
   {
      send_to_char( "You must be in a clan to drop troops.\r\n", ch );
      return;
   }

   if( ch->pcdata->clan->troops < 1 )
   {
      send_to_char( "Your clan has no ground assault troops.\r\n", ch );
      return;
   }

   num = atoi(argument);
   if( num > ch->pcdata->clan->troops )
   {
      send_to_char( "Your clan doesn't have that many ground assault troops.\r\n", ch );
      return;
   }

   if( ( ship = ship_from_cockpit(ch->in_room->vnum) ) == NULL )
   {
      send_to_char( "You must be in the cockpit of the dropship to do this.\r\n", ch );
      return;
   }

   vnum = ship->location;
   if( ( room = get_room_index(vnum) ) == NULL )
   {
      send_to_char( "This ship is not in a room.\r\n", ch );
      return;
   }

   if( num > MAX_DROP_TROOPS )
   {
      ch_printf( ch, "You can only drop %d troops at once!\r\n", MAX_DROP_TROOPS );
      return;
   }
   if( num > ch->pcdata->clan->troops )
      num = ch->pcdata->clan->troops;

   if( ( pMobIndex = get_mob_index( 82 ) ) == NULL )
      return;

   if( room->area == NULL )
      return;

   for( i = 1; i <= num; i++ )
   {
      /* Can be any room but the hi_room and low_room */
      vnum = number_range( room->area->low_r_vnum + 1, room->area->hi_r_vnum - 1 );

      if( ( rtest = get_room_index(vnum) ) == NULL )
         continue;

      /* Now lets make sure the room isn't safe and isn't a player home */
      if( IS_SET( rtest->room_flags, ROOM_SAFE ) || IS_SET( rtest->room_flags, ROOM_PLR_HOME ) )
      {
         --i;
         continue;
      }
      mob = create_mobile( pMobIndex );
      char_to_room( mob, rtest );
      if( ch->pcdata && ch->pcdata->clan )
         sprintf( tmpbuf , "(%s) %s" , ch->pcdata->clan->name  , mob->long_descr );
      STRFREE( mob->long_descr );
      mob->mob_clan = QUICKLINK( ch->pcdata->clan->name );
      mob->long_descr = STRALLOC( tmpbuf );
      if( ( pObjIndex = get_obj_index( OBJ_VNUM_BLASTECH_E11 ) ) != NULL )
      {
         blaster = create_object( pObjIndex, mob->top_level );
         obj_to_char( blaster, mob );
         equip_char( mob, blaster, WEAR_WIELD );
      }
   }
   sprintf( tmpbuf, "&RYelling and the thunder of feet is heard from the troop hold as %d troops exit the ship and fan out.\r\n", num );
   ch->pcdata->clan->troops -= num;
   echo_to_cockpit( AT_RED, ship, tmpbuf );
}


Keberus said:


Basically, it would be easiest if you replace your do_droptroops with this one. The problem with the old code is that it used room for everthing even after it got set to NULL, then continued in the loop it would try accessing room->area->low_r_vnum ...which crashed the mud. Also I put in a global variable for max # of droptroops, and put in checks to make sure the room wasn't a player home, safe, or floating in a void.


Also of note, in this fix, I also corrected the line:
mob->mob_clan = ch->pcdata->clan->name;

The result of this, while unlikely, could lead to string memory corruption down the road.
       
Pages:<< prev 1 next >>