I am having problems installing the designship snippet found at MUD Magic's download directory diku-merc-smaug-star wars-snippets. I did everything instructions said, but I get these errors in Cygwin:
USA
#1
USA
#2
USA
#3
Australia
#4
USA
#5
USA
#6
designship.c: In function 'do_design':
designship.c:207: error: structure has no member named 'resource'
designship.c:213: error: structure has no member named 'resource'
designship.c:219: error: subscripted value is neither array not pointer
/*line 113*/void do_designship( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
char arg1[MAX_INPUT_LENGTH];
char filename[MAX_STRING_LENGTH];
int chance, numrooms, class;
bool checktool, checkdura, checkcir, checksuper;
ROOM_INDEX_DATA *room;
OBJ_DATA *obj;
SHIP_DATA *ship;
PLANET_DATA *planet;
int vnum, steel, lommite, cost,fee;
argument = one_argument( argument, arg );
strcpy (arg1, argument);
switch( ch->substate )
{
default:
if ( !is_number(arg) || arg1[0] == '\0' )
{
send_to_char("&RUsage: &Gdesignship &C<&cnumber of rooms&C> <&cname of ship&C>&w\r\n",ch);
return;
}
numrooms = atoi(arg);
if (numrooms > 100 || numrooms < 1)
{
send_to_char("&RNumber of rooms MUST be between 1 and 100&C&w",ch);
return;
}
for ( ship = first_ship; ship; ship = ship->next )
{
if(!str_cmp(ship->name,argument))
{
send_to_char("&CThat ship name is already in use. Choose another.\r\n",ch);
return;
}
}
checktool = FALSE;
checkdura = FALSE;
checkcir = FALSE;
checksuper = FALSE;
/*used import flag to avoid adding an extra shipyard flg.
it can be changed if you don't have my cargo snippet - Ortluk
Also if you're installing in swfote you can uncomment the first if statement
and comment the second one out to use the shipyard flag instead*/
/* if( !IS_SET(ch->in_room->room_flags2, ROOM_SHIPYARD))*/
if ( !IS_SET(ch->in_room->room_flags, ROOM_IMPORT))
{
send_to_char("You can't build that here!! Try a spaceport\r\n",ch);
return;
}
/* uncomment these lines if swfote
if (numrooms > 100)
class = SHIP_DESTROYER;
else if(numrooms > 75)
class = SHIP_DREADNAUGHT;
else if(numrooms > 50)
class = SHIP_CRUISER;
else if(numrooms > 25)
class = SHIP_CORVETTE;
else if(numrooms > 15)
class = SHIP_FRIGATE;
else if(numrooms > 5)
class = SHIP_FREIGHTER;
else if (numrooms > 1)
class = SHIP_SHUTTLE;
else
class = SHIP_FIGHTER; */
/* comment these for swfote */
if(numrooms > 25)
class = CAPITAL_SHIP;
else if (numrooms > 5)
class = MIDSIZE_SHIP;
else
class = FIGHTER_SHIP;
/* these values come from cargo v2 */
lommite = class * 50 + 10;
steel = class * 100 + 100;
planet = ch->in_room->area->planet;
if ( !planet )
{
send_to_char("&RAnd where do you think you're going to get the resources to build your ship?&C&w",ch);
return;
}
/* make sure the planet has the resources to build the ship */
if ( planet->resource[CARGO_LOMMITE] < lommite)
{
send_to_char("&RYou'll Have to wait till they either import or produce more lommite&C&w\r\n",ch);
return;
}
if (planet->resource[CARGO_STEEL] < steel )
{
send_to_char("&RYou'll Have to wait till they either import or produce more steel&C&w\r\n",ch);
return;
}
cost = 10;
if (planet->import[CARGO_STEEL] > 0)
cost += planet->import[CARGO_STEEL] + planet->import[CARGO_STEEL] / 2;
else if (planet->export[CARGO_STEEL] > 0)
cost += planet->export[CARGO_STEEL];
else
cost += 10;
if (planet->import[CARGO_LOMMITE] > 0)
cost += planet->import[CARGO_LOMMITE] + planet->import[CARGO_LOMMITE] / 2;
else if (planet->export[CARGO_LOMMITE] > 0)
cost += planet->export[CARGO_LOMMITE];
else
cost += 10;
cost *= lommite + steel;
fee = cost * ((class +1) * 10);
cost += fee;
if (ch->gold < cost)
{
send_to_char("&RYou can't afford the materials to build that.\r\n", ch);
return;
}
for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
{
if (obj->item_type == ITEM_TOOLKIT)
checktool = TRUE;
if (obj->item_type == ITEM_CIRCUIT)
checkcir = TRUE;
if (obj->item_type == ITEM_SUPERCONDUCTOR)
checksuper = TRUE;
}
if (!checktool)
{
send_to_char("&RI'd like to see you build a ship with no tools.\r\n",ch);
return;
}
if (!checkcir)
{
send_to_char("&RYou could really use a circuit to for the control systems.\r\n",ch);
return;
}
if (!checksuper)
{
send_to_char("&RSuch advanced circuitry requires a superconducter to work properly.\r\n",ch);
return;
}
chance = IS_NPC(ch) ? ch->top_level
: (int) (ch->pcdata->learned[gsn_shipdesign]);
if ( number_percent( ) < chance )
{
send_to_char( "&GYou begin the LONG process of building a ship.\n\r", ch);
act( AT_PLAIN, "$n takes $s tools and starts constructing a ship.\r\n",ch,
NULL, argument , TO_ROOM );
add_timer ( ch , TIMER_DO_FUN , 25 , do_designship , 1 );
ch->dest_buf = str_dup(arg);
ch->dest_buf_2 = str_dup(arg1);
return;
}
send_to_char("&RYou can't figure out how to fit the parts together.\n\r",ch);
learn_from_failure( ch, gsn_shipdesign );
return;
case 1:
if ( !ch->dest_buf )
{
bug("null ch->dest_buf", 0);
return;
}
if ( !ch->dest_buf_2 )
{
bug("null ch->dest_buf2",0);
return;
}
strcpy(arg, ch->dest_buf);
DISPOSE( ch->dest_buf);
strcpy(arg1, ch->dest_buf_2);
DISPOSE( ch->dest_buf_2);
break;
case SUB_TIMER_DO_ABORT:
DISPOSE( ch->dest_buf );
DISPOSE( ch->dest_buf_2 );
ch->substate = SUB_NONE;
send_to_char("&RYou are interupted and fail to finish your work.\n\r", ch);
return;
}
ch->substate = SUB_NONE;
numrooms = atoi(arg);
if(numrooms > 25)
class = CAPITAL_SHIP;
else if (numrooms > 5)
class = MIDSIZE_SHIP;
else
class = FIGHTER_SHIP;
/* these values come from cargo v2 */
lommite = class * 50 + 10;
steel = class * 100 + 100;
planet = ch->in_room->area->planet;
if ( !planet )
{
send_to_char("&RYou must have been moved...I'd complain.&C&w",ch);
return;
}
cost = 10;
if (planet->import[CARGO_STEEL] > 0)
cost += planet->import[CARGO_STEEL] + planet->import[CARGO_STEEL] / 2;
else if (planet->export[CARGO_STEEL] > 0)
cost += planet->export[CARGO_STEEL];
else
cost += 10;
if (planet->import[CARGO_LOMMITE] > 0)
cost += planet->import[CARGO_LOMMITE] + planet->import[CARGO_LOMMITE] / 2;
else if (planet->export[CARGO_LOMMITE] > 0)
cost += planet->export[CARGO_LOMMITE];
else
cost += 10;
cost *= lommite + steel;
fee = cost * ((class +1) * 10);
cost += fee;
if (ch->gold < cost)
{
send_to_char("&RYou can't afford the materials....Stop that THIEF!!!\r\n", ch);
return;
}
ch->gold -= cost;
planet->resource[CARGO_STEEL] -= steel;
planet->resource[CARGO_LOMMITE] -= lommite;
checktool = FALSE;
checkdura = FALSE;
checkcir = FALSE;
checksuper = FALSE;
for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
{
if (obj->item_type == ITEM_TOOLKIT)
checktool = TRUE;
if (obj->item_type == ITEM_DURASTEEL && checkdura == FALSE)
{
checkdura = TRUE;
separate_obj( obj );
obj_from_char( obj );
}
if (obj->item_type == ITEM_CIRCUIT && checkcir == FALSE)
{
checkcir = TRUE;
separate_obj( obj );
obj_from_char( obj );
}
if (obj->item_type == ITEM_SUPERCONDUCTOR && checksuper == FALSE)
{
checksuper = TRUE;
separate_obj( obj );
obj_from_char( obj );
}
}
/* ok so far so good...everything is cool...try to build the ship */
vnum = find_pvnum_block(numrooms);
if (vnum < 0)
{
bug ( "player ship area out of vnums",0);
send_to_char("Not enough vnums report to a coder.\r\n",ch);
return;
}
if (reserve_rooms(vnum, numrooms) < 0)
{
bug("do_designship: reserve_rooms failed",0);
send_to_char("Couldn't build your rooms report to coder.\r\n",ch);
return;
}
sprintf( filename, "%d.pship",vnum);
CREATE( ship, SHIP_DATA, 1 );
LINK( ship, first_ship, last_ship, next, prev );
ship->filename = STRALLOC( filename );
ship->name = STRALLOC ( arg1 );
ship->owner = STRALLOC (ch->name);
ship->copilot = STRALLOC( "" );
ship->pilot = STRALLOC( "" );
ship->home = STRALLOC( "" );
ship->type = PLAYER_SHIP;
/* you may want to adjust these to balance ships with your imm built ones
I use an array of maximum ship stats for the different classes of ships
that's another project though */
ship->maxenergy = (class + 1) * 50 * ch->pcdata->learned[gsn_shipdesign] ;
ship->energy = ship->maxenergy;
ship->maxhull = (class + 1) * 10 * ch->pcdata->learned[gsn_shipdesign] ;
ship->maxshield = (class + 1) * 5 * ch->pcdata->learned[gsn_shipdesign];
ship->realspeed = 2 * ch->pcdata->learned[gsn_shipdesign] / (class + 1);
ship->hyperspeed = ch->pcdata->learned[gsn_shipdesign] + (class +1) * 20;
ship->lasers = (class + 1) * (ch->pcdata->learned[gsn_shipdesign] / 20);
ship->manuever = ch->pcdata->learned[gsn_shipdesign] * 2 / (class + 1);
ship->comm = ch->pcdata->learned[gsn_shipdesign] * 2 / (class + 1);
ship->sensor = ch->pcdata->learned[gsn_shipdesign] * 2 / (class + 1);
ship->maxcargo = ch->pcdata->learned[gsn_shipdesign];
ship->upgrades = 0;
ship->upgradeslots = ch->pcdata->learned[gsn_shipdesign]/5;
ship->hull = ship->maxhull;
ship->in_room=NULL;
ship->currjump=NULL;
ship->target0=NULL;
ship->target1=NULL;
ship->target2=NULL;
ship->class=class;
ship->firstroom = vnum;
ship->lastroom = vnum + numrooms -1;
ship->entrance = vnum;
ship->lastbuilt = vnum;
if (numrooms == 1)
{
ship->cockpit = vnum;
ship->navseat = vnum;
ship->gunseat = vnum;
ship->pilotseat = vnum;
ship->engineroom = vnum;
ship->coseat = vnum;
}
gain_exp(ch, 10000, ENGINEERING_ABILITY);
/* I added this fee to balance the cost of building ships with that of selling them so as to
keep engis from making too much money too fast from just building and selling ships
*/
ch_printf( ch, "The planet's Government has assesed a Licence Fee of %d credits.\r\n", fee);
ch_printf( ch , "&WYou gain 10000 engineering experience.\r\n" );
learn_from_success(ch, gsn_shipdesign);
transship(ship, ch->in_room->vnum);
act( AT_PLAIN, "$n finishes building new ship, and climbs inside.", ch,
NULL, argument , TO_ROOM );
room = get_room_index(vnum);
if (!room)
{
bug ("designship..no such room",0);
return;
}
if (room->name)
STRFREE( room->name );
if (numrooms > 1)
room->name = STRALLOC( "Entrance Ramp" );
else
room->name = STRALLOC( "Cockpit" );
fold_area (room->area, room->area->filename, TRUE);
save_ship(ship);
write_ship_list();
char_from_room( ch );
char_to_room(ch, get_room_index(vnum));
}
The error your getting should help you determine what you missed, or what the snippet instructions have missing.
designship.c:207: error: structure has no member named 'resource'
designship.c:213: error: structure has no member named 'resource'
resource is a member of a structure and its missing, looking at the code you can find out what structure its missing from,
if (planet->resource[CARGO_STEEL] < steel )
plant is the structure and resource is a member of that structure. Im not sure as to what type resource is as im not familure with that snippet or with swr, but i would be inclined to look in mud.h for plant_data?? and add resource in to it most likly as an int.
designship.c:207: error: structure has no member named 'resource'
designship.c:213: error: structure has no member named 'resource'
resource is a member of a structure and its missing, looking at the code you can find out what structure its missing from,
if (planet->resource[CARGO_STEEL] < steel )
plant is the structure and resource is a member of that structure. Im not sure as to what type resource is as im not familure with that snippet or with swr, but i would be inclined to look in mud.h for plant_data?? and add resource in to it most likly as an int.
That really helps, thanks. Now I need to figured the other out:
BTW, I noted edited the post to show what line the function started on. Hope it helps.
designship.c:219: error: subscripted value is neither array not pointerBTW, I noted edited the post to show what line the function started on. Hope it helps.
AH!! I figured it out, I installed the wrong cargo snippet! This uses cargo V2, I have cargo V1!