Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
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
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
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
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Bing, Yahoo!, DotBot, Sogou

Members: 0
Guests: 4
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SWFOTE FUSS » Ship data not freed when it's...
Forum Rules | Mark all | Recent Posts

Ship data not freed when it's destroyed
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 8, 2006, 6:25 am   Last edited Sep 10, 2006, 7:31 am by Keberus
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

This is a copy of my message on the fote fourms I figured I would post here too because it applies to 1.3FUSS as well..

I was messing around with trying to make sure everything is getting cleaned up in my code and realized that none of the ship data is being freed like it should be. Instead all they do with the ship is put in room vnum 46, the file for it is deleted, and the listing on ships.lst is deleted, so when you copyover it won't show up, or load, and will indeed be gone. I decided to go ahead and write a free_ship function that properly free's the ship data instantly and there's no need to copyover, at least not for ship reasons.

In ships.c or space.c add this function..
/*free up ship data by Keberus */
void free_ship( SHIP_DATA *ship )
{
  MODULE_DATA *mod, *mod_next;
  TURRET_DATA *turret, *tnext;

   STRFREE( ship->clanowner );
   STRFREE( ship->copilot );
   STRFREE( ship->description );
   STRFREE( ship->home );
   STRFREE( ship->name );
   STRFREE( ship->owner );
   STRFREE( ship->pilot );
   DISPOSE( ship->filename );
   STRFREE( ship->protoname );
   STRFREE( ship->pbeacon );
   STRFREE( ship->dest );

  /*dispose of ship module data*/
  for( mod = ship->first_module; mod; mod = mod_next )
  {
     mod_next = mod->next;
     UNLINK( mod, ship->first_module, ship->last_module, next, prev );
     DISPOSE(mod);
  }

  /*dispose of ship turret data*/
  for( turret = ship->first_turret; turret; turret = tnext )
  {
     tnext = turret->next;
     UNLINK( turret, ship->first_turret, ship->last_turret, next, prev );
     DISPOSE(turret);
  }

  DISPOSE( ship );
  return;
}


at the top of space.c after:
char *secondary_beam_name args( ( SHIP_DATA * ship ) );


add:
void free_ship( SHIP_DATA *ship );


in the function destroy_ship find:
      sprintf( buf, "%s%s", SHIP_DIR, ship->filename );
      remove( buf );

      UNLINK( ship, first_ship, last_ship, next, prev );
      DISPOSE( ship );


and change to:
      sprintf( buf, "%s%s", SHIP_DIR, ship->filename );
      remove( buf );

      UNLINK( ship, first_ship, last_ship, next, prev );
      free_ship( ship );


And that should be it.

PS- If anyone catches any chars or structs I forgot...let me know.

Edited:Deleted all the excess ifchecks

Later,
KeB
       
Post is unread #2 Sep 8, 2006, 6:46 am
Go to the top of the page
Go to the bottom of the page

kiasyn
Magician
GroupMembers
Posts121
JoinedJun 30, 2006

if( ship->pbeacon )
STRFREE( ship->pbeacon );

etc

you dont need the if ( ship->pbeacon )... pretty sure STRFREE checks for it. (at least mine does)
       
Post is unread #3 Sep 8, 2006, 8:08 am   Last edited Sep 8, 2006, 8:14 am by Keberus
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Thanks, I was wondering if the ifchecks were necessary.

I went ahead and updated my posts and took out the excess ifchecks.

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