Need help with ship resets for SWR 1.0

Posted by Jason on Thu 05 Feb 2004 06:24 AM — 3 posts, 15,385 views.

#0
Hello again,

I'm needing some help with some ship reset on my swr 1.0. Everytime they reset all my speeders end up in the middle of space the following code is the void resetships and the void do_resetships. Oh and when i reset the ship manually it goes back to where it is supposed to:

void resetship( SHIP_DATA *ship )
{
     ship->shipstate = SHIP_READY;
     ship->docking = SHIP_READY;
     ship->docked = NULL;     
     if ( ship->class <= SHIP_PLATFORM && ship->type != MOB_SHIP )
     {
           extract_ship( ship );
           ship_to_room( ship , ship->shipyard ); 
     
           ship->location = ship->shipyard;
           ship->lastdoc = ship->shipyard; 
           ship->shipstate = SHIP_LANDED;
     }

     if (ship->class == LAND_SPEEDER)
     {
	extract_ship(ship);
	ship_to_room( ship , ship->lastdoc );
	ship->location = ship->lasdoc;
     }
     if (ship->starsystem)
        ship_from_starsystem( ship, ship->starsystem );  
  
     ship->currspeed=0;
     ship->energy=ship->maxenergy;
     ship->chaff=ship->maxchaff;
     ship->hull=ship->maxhull;
     ship->shield=0;
     
     ship->statet1 = LASER_READY; 
     ship->statet2 = LASER_READY; 
     ship->statet0 = LASER_READY; 
     ship->missilestate = LASER_READY;
       
     ship->currjump=NULL;
     ship->target0=NULL;
     ship->target1=NULL;
     ship->target2=NULL;
     
     ship->hatchopen = FALSE;
	if (ship->class == SHIP_PLATFORM)
	  ship->bayopen = TRUE;
	else
     ship->bayopen = FALSE;
     
     ship->missiles = ship->maxmissiles;
     ship->torpedos = ship->maxtorpedos;
     ship->rockets = ship->maxrockets;
     ship->autorecharge = FALSE;
     ship->autotrack = FALSE;
     ship->autospeed = FALSE;
     
     if ( str_cmp("Public",ship->owner) && ship->type != MOB_SHIP )
     {
        CLAN_DATA *clan;
        
        if ( ship->type != MOB_SHIP && (clan = get_clan( ship->owner )) != NULL )
	{
          if ( ship->class <= SHIP_PLATFORM )
             clan->spacecraft--;
          else
             clan->vehicles--;
	}
        
        STRFREE( ship->owner );
        ship->owner = STRALLOC( "" );
        STRFREE( ship->pilot );
        ship->pilot = STRALLOC( "" );
        STRFREE( ship->copilot );
        ship->copilot = STRALLOC( "" );
     }
     
     if ( ship->type == SHIP_REPUBLIC || ( ship->type == MOB_SHIP && !str_cmp(ship->owner, "The Galactic Republic") ) )
     {
         STRFREE( ship->home );
         ship->home = STRALLOC( "coruscant" );
     }
     else if ( ship->type == SHIP_IMPERIAL || ( ship->type == MOB_SHIP && !str_cmp(ship->owner, "The Army of Palpatine") ))

     {
          STRFREE( ship->home );
          ship->home = STRALLOC( "byss" );
     }
     else if ( ship->type == SHIP_CIVILIAN)
     {
          STRFREE( ship->home );
          ship->home = STRALLOC( "corperate" );
     }
     
     save_ship(ship);               
}
void do_resetship( CHAR_DATA *ch, char *argument )
{    
     SHIP_DATA *ship;
     
     ship = get_ship( argument );
     if (ship == NULL)
     {
        send_to_char("&RNo such ship!",ch);
        return;
     } 
     
     resetship( ship ); 
     
     if ( ( ship->class == SHIP_PLATFORM || ship->type == MOB_SHIP || ship->class == CAPITAL_SHIP ) 
          && ship->home )
     {
          ship_to_starsystem(ship, starsystem_from_name(ship->home) );  
          ship->vx = number_range( -5000 , 5000 );
          ship->vy = number_range( -5000 , 5000 );
          ship->vz = number_range( -5000 , 5000 );
          ship->shipstate = SHIP_READY;
          ship->autopilot = TRUE;
          ship->autorecharge = TRUE;
          ship->shield = ship->maxshield;
     }
         
}

USA #1
Unless I missed it(entirely possible at 230), you havent actually initialized ship->lastdoc to anything for your speeders. My suspicion is they are going to vnum 0(or is it 1 minimum?) since that would be the logical default value for a room vnum. Granted, I dont work with the SWR codebase but unless its stored as a permanemt value in the ship_data construct, ship->lastdoc is your most likely culprit. Might be a good time to read up on Nick's gdb guide and put in a breakpoint to see whats really going on with that reset function.
Canada #2
Also, double check that it is set as a speeder for sure, because if not, then it may be sent out to space. I tried to reste a speeder manually, and it didn't go into space, so its likely a setting with the ship it self, or with a code change. Have you done anything to it recently?