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, Yandex, Sogou

Members: 0
Guests: 10
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 » Do_droptroops can crash the m...
Forum Rules | Mark all | Recent Posts

Do_droptroops can crash the mud
< Newer Topic :: Older Topic >

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

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Found by: Phoenix Dracul
Fixed by: Keberus


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.

#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.\n\r", ch);
        return;
  }

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

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

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

  if (num > MAX_DROP_TROOPS)
  {
      ch_printf(ch, "You can only drop %d troops at once!\n\r", 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 = 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.\n\r", num);
  ch->pcdata->clan->troops-=num;
  echo_to_cockpit(AT_RED, ship, tmpbuf);
}


Be sure to include the define...it allows you to modify one number to adjust the max number of troops that can be dropped at one time.


Later,
KeB
       
Pages:<< prev 1 next >>