示例#1
0
void Initialize() {
	std::cout << "Starting Initialization" << std::endl;
	/* Variable Initialization */
	modelChosen = THIRTEENBOX;
    spotLightChosen = NOSPOTLIGHT;
	planeEnabled = true;

	/* Model Initialization */
    camera = viewglut_create(1.0, 100.0);
    p = plane_create(20);
	box = obj_create("thirteen-box.obj");
	troll = obj_create("trolluvd1.obj");
	
	//glEnable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LESS);
	createMenuItems();

	boxloader = new ShaderLoader("thirteenBoxVertexShader2.glsl", "thirteenBoxFragmentShader2.glsl");
	boxloader->initializeTextures("thirteen-diffuse.png");
	boxloader->initializeTextures("thirteen-normal.png");
	//boxloader->initializeTextures("thirteen-specular.png");

	spotlight1loader = new ShaderLoader("spotlightVertexShader.glsl", "spotlightFragmentShader.glsl");
	spotlight1loader->initializeTextures("spotlight2.png");

	std::cout << "Initialization Finished" << std::endl;
}
示例#2
0
文件: pal_custdlg.c 项目: juddy/edcde
static void
custdlg_create_area(
    ABObj		obj,
    AB_CONTAINER_TYPE	area_type
)
{
    ABObj	pwobj;
    ABObj	label, area;
    ABObj       workobj;
    Dimension   height;

    pwobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_PW_OBJ);
    workobj = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);

    area = obj_create(AB_TYPE_CONTAINER, pwobj);
    obj_set_subtype(area, area_type);
    pal_initialize_obj(area);

    if (area_type == AB_CONT_FOOTER)
    {
	label = obj_create(AB_TYPE_LABEL, area);
        obj_set_x(label, 1);
        obj_set_y(label, 1);
	pal_initialize_obj(label);
	obj_set_label(label, catgets(Dtb_project_catd, 100, 264, "footer message"));
	obj_set_label_alignment(label, AB_ALIGN_LEFT);
	obj_set_unique_name(label,
		ab_ident_from_name_and_label(obj_get_name(obj), "label"));

	/*
	 * Workaround part1: MainWindow bug that causes MainWindow to shrink
	 * when a MessageWindow area is added
	 */
	XtVaGetValues(objxm_get_widget(workobj),
		XmNheight,	&height,
		NULL);
    }
    else if (area_type == AB_CONT_BUTTON_PANEL)
	custdlg_create_buttons(obj, area);

    abobj_show_tree(area, True);

    /* Workaround part2 */
    if (area_type == AB_CONT_FOOTER)
	XtVaSetValues(objxm_get_widget(workobj),
		XmNheight,	height,
		NULL);

    abobj_set_save_needed(obj_get_module(obj), True);

}
static int load_state(
    const struct RTOp_obj_type_vtbl_t* vtbl
    ,const void *            instance_data
    ,int                     num_values
    ,const RTOp_value_type   value_data[]
    ,int                     num_indexes
    ,const RTOp_index_type   index_data[]
    ,int                     num_chars
    ,const RTOp_char_type    char_data[]
    ,void **                 obj
)
{
    struct RTOp_value_value_type* vi_obj;
#ifdef RTOp_DEBUG
    assert( obj );
    assert( num_values  == 2 );
    assert( num_indexes == 0 );
    assert( num_chars   == 0 );
#endif
    if(*obj == NULL)
        obj_create(vtbl,instance_data,obj);
    vi_obj = (struct RTOp_value_value_type*)*obj;
    vi_obj->value1 = value_data[0];
    vi_obj->value2 = value_data[1];
    return 0;
}
示例#4
0
文件: pal_custdlg.c 项目: juddy/edcde
static void
custdlg_create_buttons(
    ABObj	obj,
    ABObj	area
)
{
    ABObj	bobj;
    char    *button_names[] = {"button1","button2","button3"};
    char    *button_labels[3];
    int     startpos, endpos;
    int		i;

    button_labels[0] = catgets(Dtb_project_catd, 100, 265, "Button1");
    button_labels[1] = catgets(Dtb_project_catd, 100, 266, "Button2");
    button_labels[2] = catgets(Dtb_project_catd, 100, 267, "Button3");

    endpos = 0;
    for(i=0; i < XtNumber(button_names); i++)
    {
        bobj = obj_create(AB_TYPE_BUTTON, area);
        obj_set_subtype(bobj, AB_BUT_PUSH);
        obj_set_unique_name(bobj,
            ab_ident_from_name_and_label(obj_get_name(obj),button_names[i]));
        obj_set_label(bobj, button_labels[i]);
        obj_set_is_initially_visible(bobj, True);
        obj_set_is_initially_active(bobj, True);
        startpos = endpos + 10;
        obj_set_attachment(bobj, AB_CP_WEST, AB_ATTACH_GRIDLINE, (void*)startpos, 0);
        endpos = startpos + 20;
        obj_set_attachment(bobj, AB_CP_EAST, AB_ATTACH_GRIDLINE, (void*)endpos, 0);
	obj_set_attachment(bobj, AB_CP_NORTH, AB_ATTACH_POINT, (void*)0, 5);
    }

}
示例#5
0
文件: gil_loadact.c 项目: juddy/edcde
static int
add_user_handler(ABObj obj, ABObj module,
                 ISTRING handler, AB_WHEN when)
{
    int                 retval = 0;
    ABObj               project = NULL;
    ABObj               action = NULL;

    if (handler == NULL)
    {
        return 0;
    }
    project = obj_get_project(module);

    /*
     * With "callbacks," the to field is irrelevant.  The target is generally
     * whatever widget calls the callback, so we set the "to" field to NULL,
     * so that this action may be used by multiple widgets.  I.e., if the
     * function type, name and to fields match, an action will be shared.
     */
    action = obj_create(AB_TYPE_ACTION, NULL);
    obj_set_func_type(action, AB_FUNC_USER_DEF);
    obj_set_func_name(action, istr_string(handler));
    obj_set_arg_type(action, AB_ARG_VOID_PTR);
    action->info.action.to = NULL;

    obj_set_from(action, obj);
    obj_set_when(action, when);

    install_action(obj, module, action);
    return 0;
}
void waypoint_create_game_object(waypoint *wpt, int list_index, int wpt_index)
{
	Assert(wpt != NULL);
	Assert(list_index >= 0);
	Assert(wpt_index >= 0);
	wpt->objnum = obj_create(OBJ_WAYPOINT, -1, calc_waypoint_instance(list_index, wpt_index), NULL, wpt->get_pos(), 0.0f, OF_RENDERS);
}
示例#7
0
文件: gil_loadact.c 项目: juddy/edcde
/*
 * Load the actions attributes
 */
int
gilP_load_att_actions(FILE * inFile, ABObj obj, ABObj module)
{
    int                 return_value = 0;
    int                 rc = 0; /* r turn code */
    ABObj               action = NULL;

    if (!abio_get_list_begin(inFile))
        return (abil_print_load_err(ERR_WANT_LIST), -1);

    while (!abio_get_list_end(inFile))
    {
        action = obj_create(AB_TYPE_ACTION, NULL);

        if ((rc = get_action(inFile, obj, module, action)) < 0)
        {
            obj_destroy(action);
            return rc;
        }
        else
        {
	    if (obj_get_when(action) == AB_WHEN_UNDEF)
	    {
		/* unsupported :when value - ignore it and continue */
		obj_destroy(action);
	    }
	    else
	    {
                install_action(obj, module, action);
	    }
        }
    }
    return return_value;
}
示例#8
0
文件: world.c 项目: fjolnir/Dynamo
World_t *world_create(void)
{
    World_t *out = obj_create_autoreleased(&Class_World);
    out->cpSpace = cpSpaceNew();
    out->cpSpace->data = out;
    cpSpaceAddCollisionHandler(out->cpSpace, 0, 0,
                               collisionWillBegin,
                               NULL,
                               collisionDidBegin,
                               collisionDidEnd, NULL);
    out->entities = obj_retain(llist_create((InsertionCallback_t)&obj_retain, &obj_release));

    // Create the static entity
    out->staticEntity = obj_create(&Class_WorldEntity);
    out->staticEntity->world = out;
    out->staticEntity->owner = out;
    out->staticEntity->cpBody = out->cpSpace->staticBody;
    out->staticEntity->luaUpdateHandler = -1;
    out->staticEntity->luaPreCollisionHandler = -1;
    out->staticEntity->luaCollisionHandler = -1;
    out->staticEntity->luaPostCollisionHandler = -1;
    out->cpSpace->staticBody->data = out->staticEntity;
    out->staticEntity->shapes = obj_retain(llist_create((InsertionCallback_t)&obj_retain, &obj_release));

    return out;
}
示例#9
0
文件: fops.c 项目: Asamaha/mongo
/*
 * fop --
 *	File operation function.
 */
static void *
fop(void *arg)
{
	STATS *s;
	uintptr_t id;
	WT_RAND_STATE rnd;
	u_int i;

	id = (uintptr_t)arg;
	__wt_yield();		/* Get all the threads created. */

	s = &run_stats[id];
	__wt_random_init(&rnd);

	for (i = 0; i < nops; ++i, __wt_yield())
		switch (__wt_random(&rnd) % 10) {
		case 0:
			++s->bulk;
			obj_bulk();
			break;
		case 1:
			++s->create;
			obj_create();
			break;
		case 2:
			++s->cursor;
			obj_cursor();
			break;
		case 3:
			++s->drop;
			obj_drop(__wt_random(&rnd) & 1);
			break;
		case 4:
			++s->ckpt;
			obj_checkpoint();
			break;
		case 5:
			++s->upgrade;
			obj_upgrade();
			break;
		case 6:
			++s->rebalance;
			obj_rebalance();
			break;
		case 7:
			++s->verify;
			obj_verify();
			break;
		case 8:
			++s->bulk_unique;
			obj_bulk_unique(__wt_random(&rnd) & 1);
			break;
		case 9:
			++s->create_unique;
			obj_create_unique(__wt_random(&rnd) & 1);
			break;
		}

	return (NULL);
}
示例#10
0
void waypoint_create_game_object(waypoint *wpt, int list_index, int wpt_index)
{
	Assert(wpt != NULL);
	Assert(list_index >= 0);
	Assert(wpt_index >= 0);
    flagset<Object::Object_Flags> default_flags;
    default_flags.set(Object::Object_Flags::Renders);
	wpt->objnum = obj_create(OBJ_WAYPOINT, -1, calc_waypoint_instance(list_index, wpt_index), NULL, wpt->get_pos(), 0.0f, default_flags);
}
示例#11
0
文件: edb.c 项目: Knio/everdb-native
int
edb_array_create(edb *db, obj_handle **hp, const u8 item_size) {
  LOG_HERE;
  int err = 0;
  CHECK(obj_create(db, hp));
  CHECK(array_init(db, (*hp)->root, item_size));

  err:
  return err;
}
示例#12
0
static int do_work(struct kid_t *kid)
{
        int rc = 0, err, iter = 0;

        if (!(kid->k_cmd.c_flags & C_CREATE_EVERY))
                rc = obj_create(kid);

        for (iter = 0; iter < kid->k_cmd.c_rpt; iter++) {
                if (rc || sig_received)
                        break;

                if (kid->k_cmd.c_flags & C_CREATE_EVERY) {
                        rc = obj_create(kid);
                        if (rc)
                                break;
                }

                if (kid->k_cmd.c_flags & C_WRITE) {
                        rc = obj_write(kid);
                        grant_estimate(kid->k_id);
                }

                if (kid->k_cmd.c_flags & C_CREATE_EVERY) {
                        err = obj_delete(kid);
                        if (!rc) rc = err;
                }

                if ((o_verbose > 3) && (iter % 10 == 0))
                        printf("%d: i%d\n", kid->k_id, iter);
                if (!rc)
                        sleep(kid->k_cmd.c_delay);
        }

        if (!(kid->k_cmd.c_flags & C_CREATE_EVERY)) {
                err = obj_delete(kid);
                if (!rc) rc = err;
        }

        if (o_verbose > 2)
                printf("%d: done (%d)\n", kid->k_id, rc);

        return rc;
}
示例#13
0
int observer_create(matrix *orient, vec3d *pos)
{
	int objnum,idx;	
	physics_info *pi;

	// try and find the first free observer slot
	for(idx=0;idx<MAX_OBSERVER_OBS;idx++){
		if(!(Observers[idx].flags & OBS_FLAG_USED))
			break;
	}
	// if we couldn't find an open slot
	if(idx == MAX_OBSERVER_OBS){
		mprintf(("Ran out of observer slots!\n"));
		return -1;
	}
	
	// attempt to create the object
    flagset<Object::Object_Flags> default_flagset;
	objnum = obj_create(OBJ_OBSERVER,-1,idx,orient,pos,1.0f, default_flagset);

	// fail situation
	if(objnum == -1)
		return -1;

	// give the observer Descent style physics
    Objects[objnum].flags.set(Object::Object_Flags::Physics);
	physics_init(&Objects[objnum].phys_info);
	pi = &Objects[objnum].phys_info;
	pi->flags |= PF_ACCELERATES | PF_SLIDE_ENABLED;
	
	
	// setup some physics parameters
	pi->max_vel.xyz.x = OBS_MAX_VEL_X;
	pi->max_vel.xyz.y = OBS_MAX_VEL_Y;
	pi->max_vel.xyz.z = OBS_MAX_VEL_Z;	
	vm_vec_zero(&pi->prev_ramp_vel);
	vm_vec_zero(&pi->desired_vel);
	vm_vec_zero(&pi->desired_rotvel);
	vm_vec_zero(&pi->vel);
	vm_vec_zero(&pi->rotvel);
	vm_vec_zero(&pi->prev_fvec);
	vm_set_identity(&pi->last_rotmat);
	pi->forward_thrust = 0.0f;
	pi->speed = 0.0f;
	pi->fspeed = 0.0f;
	pi->heading = 0.0f;
		
	// set up the observer data
	Observers[idx].flags |= OBS_FLAG_USED;
	Observers[idx].objnum = objnum;
	Observers[idx].target_objnum = -1;

	return objnum;
}
示例#14
0
int cgmgr_create_cg(xid_t xid, struct mlu_ioctl_create_cg_args *argp)
{
	int rc = 0;
	obj_id_t cg_oid;
	obj_t cg_obj = NULL;
	obj_t vu_obj = NULL;
	unsigned int i;

	/* Create group object first */
	rc = obj_create(xid, OBJ_TYPE_CG, argp, &cg_oid);
	if (rc != 0) {
		MLU_TRACE(TL_ERR, "xid:0x%x failed to create CG, rc:0x%x\n",
			  xid, rc);
		goto create_cg_exit;
	}

	cg_obj = objmgr_access_obj(xid, cg_oid);
	if (cg_obj == NULL) {
		rc = MLU_STATUS_NOENT;
		MLU_TRACE(TL_ERR, "xid:0x%x failed to access CG "
			  OID_FMT"\n", xid, OBJ_ID(cg_oid));
		goto create_cg_exit;
	}

	for (i = 0; i < argp->nr_members; i++) {
		vu_obj = objmgr_access_obj(xid, argp->members[i]);
		if (vu_obj == NULL) {
			rc = MLU_STATUS_NOENT;
			MLU_TRACE(TL_ERR, "xid:0x%x failed to access member "
				  OID_FMT"\n", xid, OBJ_ID(argp->members[i]));
			break;
		}

		rc = grpmgr_add_member(xid, cg_obj, vu_obj);
		if (rc != 0) {
			MLU_TRACE(TL_ERR, "xid:0x%x failed to add member "
				  OID_FMT", rc:0x%x\n",
				  xid, OBJ_ID(argp->members[i]), rc);
			break;
		}
	}

	argp->cg_oid = cg_oid;

 create_cg_exit:

	if (rc != 0) {
		// TODO: Do the clean up work
		;
	}

	return rc;
}
示例#15
0
object *object_create_debris(object *parent, int subobj_num)
{
	int objnum;
	object *obj;
	polymodel *po;

	Assert((parent->type == OBJ_ROBOT) || (parent->type == OBJ_PLAYER)  );

	objnum = obj_create(OBJ_DEBRIS,0,parent->segnum,&parent->pos,
				&parent->orient,Polygon_models[parent->rtype.pobj_info.model_num].submodel_rads[subobj_num],
				CT_DEBRIS,MT_PHYSICS,RT_POLYOBJ);

	if ((objnum < 0 ) && (Highest_object_index >= MAX_OBJECTS-1)) {
		mprintf((1, "Can't create object in object_create_debris.\n"));
		Int3();
		return NULL;
	}
	if ( objnum < 0 )
		return NULL;				// Not enough debris slots!
	obj = &Objects[objnum];

	Assert(subobj_num < 32);

	//Set polygon-object-specific data 

	obj->rtype.pobj_info.model_num = parent->rtype.pobj_info.model_num;
	obj->rtype.pobj_info.subobj_flags = 1<<subobj_num;
	obj->rtype.pobj_info.tmap_override = parent->rtype.pobj_info.tmap_override;

	//Set physics data for this object

	po = &Polygon_models[obj->rtype.pobj_info.model_num];

	obj->mtype.phys_info.velocity.x = RAND_MAX/2 - rand();
	obj->mtype.phys_info.velocity.y = RAND_MAX/2 - rand();
	obj->mtype.phys_info.velocity.z = RAND_MAX/2 - rand();
	vm_vec_normalize_quick(&obj->mtype.phys_info.velocity);
	vm_vec_scale(&obj->mtype.phys_info.velocity,i2f(10 + (30 * rand() / RAND_MAX)));

	vm_vec_add2(&obj->mtype.phys_info.velocity,&parent->mtype.phys_info.velocity);

	vm_vec_make(&obj->mtype.phys_info.rotvel,10*0x2000/3,10*0x4000/3,10*0x7000/3);
	vm_vec_zero(&obj->mtype.phys_info.rotthrust);

	obj->lifeleft = DEBRIS_LIFE;

	obj->mtype.phys_info.mass = fixmuldiv(parent->mtype.phys_info.mass,obj->size,parent->size);
	obj->mtype.phys_info.drag = 0; //fl2f(0.2);		//parent->mtype.phys_info.drag;

	return obj;

}
示例#16
0
文件: vector.c 项目: qyqx/wisp
object_t *c_vec (size_t len, object_t * init)
{
  object_t *o = obj_create (VECTOR);
  vector_t *v = OVAL (o);
  v->len = len;
  if (len == 0)
    len = 1;
  v->v = xmalloc (sizeof (object_t **) * len);
  size_t i;
  for (i = 0; i < v->len; i++)
    v->v[i] = UPREF (init);
  return o;
}
示例#17
0
文件: proj.c 项目: juddy/edcde
int
proj_init(
)
{
    obj_add_rename_callback(projP_obj_renameOCB, "PROJ");
    obj_add_destroy_callback(projP_obj_destroyOCB, "PROJ");
    obj_add_update_callback(projP_obj_updateOCB, "PROJ");

    AB_project = obj_create(AB_TYPE_PROJECT, NULL);
    obj_set_name(AB_project, "project");
    abobj_show_tree(AB_project, TRUE);

    return 0;
}
示例#18
0
END_TEST

START_TEST (test_video_initialize) {
    Object * ev = obj_create ("video", NULL, NULL, NULL);
    VIDEO * v = obj_getClassData (ev, "video");

    obj_message (ev, OM_START, NULL, NULL);
    fail_unless (
        v->screen != NULL,
        "Video start must create a SDL screen.");

    // ... other stuff

    obj_message (ev, OM_DESTROY, NULL, NULL);
}
示例#19
0
END_TEST

START_TEST (test_video_resize) {
    Object * ev = obj_create ("video", NULL, NULL, NULL);
    VIDEO * v = obj_getClassData (ev, "video");
    float x = 0, y = 0;
    obj_message (ev, OM_START, NULL, NULL);

    x = video_getXResolution ();
    y = video_getYResolution ();
    fail_unless (
        fcmp (x, 67.2)
        && fcmp (y, 37.8),
        "Video default resolution should be 960x540 with a scale of 0.07"
    );
    video_setScaling (v, 1.0);
    video_setResolution (v, 500.0, 500.0);
    x = video_getXResolution ();
    y = video_getYResolution ();
    fail_unless (
        fcmp (x, 500.0)
        && fcmp (y, 500.0),
        "Video dimensions should be resizable on the fly (got %.2f, %.2f; expecting %.2f,%2.f)",
        x, y, 500.0, 500.0
    );
    video_setScaling (v, 2.0);
    x = video_getXResolution ();
    y = video_getYResolution ();
    fail_unless (
        fcmp (x, 1000.0)
        && fcmp (y, 1000.0),
        "Video resolution should be resizable on the fly (got %.2f,%.2f; expecting %.2f,%.2f)",
        x, y, 1000.0, 1000.0
    );
    video_setScaling (v, 0.5);
    x = video_getXResolution ();
    y = video_getYResolution ();
    fail_unless (
        fcmp (x, 250.0)
        && fcmp (y, 250.0),
        "Video resolution should be resizable on the fly (got %.2f,%.2f; expecting %.2f,%.2f)",
        x, y, 250.0, 250.0
    );

    obj_message (ev, OM_DESTROY, NULL, NULL);
}
示例#20
0
//------------------------------------------------------------
//	Trigger (enable) the materialization center in segment segnum
void trigger_matcen(int segnum)
{
	// -- segment		*segp = &Segments[segnum];
	segment2		*seg2p = &Segment2s[segnum];
	vms_vector	pos, delta;
	FuelCenter	*robotcen;
	int			objnum;

	mprintf((0, "Trigger matcen, segment %i\n", segnum));

	Assert(seg2p->special == SEGMENT_IS_ROBOTMAKER);
	Assert(seg2p->matcen_num < Num_fuelcenters);
	Assert((seg2p->matcen_num >= 0) && (seg2p->matcen_num <= Highest_segment_index));

	robotcen = &Station[RobotCenters[seg2p->matcen_num].fuelcen_num];

	if (robotcen->Enabled == 1)
		return;

	if (!robotcen->Lives)
		return;

	//	MK: 11/18/95, At insane, matcens work forever!
	if (Difficulty_level+1 < NDL)
		robotcen->Lives--;

	robotcen->Timer = F1_0*1000;	//	Make sure the first robot gets emitted right away.
	robotcen->Enabled = 1;			//	Say this center is enabled, it can create robots.
	robotcen->Capacity = i2f(Difficulty_level + 3);
	robotcen->Disable_time = MATCEN_LIFE;

	//	Create a bright object in the segment.
	pos = robotcen->Center;
	vm_vec_sub(&delta, &Vertices[Segments[segnum].verts[0]], &robotcen->Center);
	vm_vec_scale_add2(&pos, &delta, F1_0/2);
	objnum = obj_create( OBJ_LIGHT, 0, segnum, &pos, NULL, 0, CT_LIGHT, MT_NONE, RT_NONE );
	if (objnum != -1) {
		Objects[objnum].lifeleft = MATCEN_LIFE;
		Objects[objnum].ctype.light_info.intensity = i2f(8);	//	Light cast by a fuelcen.
	} else {
		mprintf((1, "Can't create invisible flare for matcen.\n"));
		Int3();
	}
//	mprintf((0, "Created invisibile flare, object=%i, segment=%i, pos=%7.3f %7.3f%7.3f\n", objnum, segnum, f2fl(pos.x), f2fl(pos.y), f2fl(pos.z)));
}
示例#21
0
object * create_morph_robot( segment *segp, vms_vector *object_pos, int object_id)
{
	short		objnum;
	object	*obj;
	int		default_behavior;

	Players[Player_num].num_robots_level++;
	Players[Player_num].num_robots_total++;

	objnum = obj_create(OBJ_ROBOT, object_id, segp-Segments, object_pos,
				&vmd_identity_matrix, Polygon_models[Robot_info[object_id].model_num].rad,
				CT_AI, MT_PHYSICS, RT_POLYOBJ);

	if ( objnum < 0 ) {
		mprintf((1, "Can't create morph robot.  Aborting morph.\n"));
		Int3();
		return NULL;
	}

	obj = &Objects[objnum];

	//Set polygon-object-specific data 

	obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num;
	obj->rtype.pobj_info.subobj_flags = 0;

	//set Physics info

	obj->mtype.phys_info.mass = Robot_info[obj->id].mass;
	obj->mtype.phys_info.drag = Robot_info[obj->id].drag;

	obj->mtype.phys_info.flags |= (PF_LEVELLING);

	obj->shields = Robot_info[obj->id].strength;
	
	default_behavior = Robot_info[obj->id].behavior;

	init_ai_object(obj-Objects, default_behavior, -1 );		//	Note, -1 = segment this robot goes to to hide, should probably be something useful

	create_n_segment_path(obj, 6, -1);		//	Create a 6 segment path from creation point.

	Ai_local_info[objnum].mode = ai_behavior_to_mode(default_behavior);

	return obj;
}
示例#22
0
文件: pal_custdlg.c 项目: juddy/edcde
/*************************************************************************
**                                                                      **
**       Function Definitions                                           **
**                                                                      **
**************************************************************************/
static int
custdlg_initialize(
    ABObj     obj
)
{
    ABObj	module = obj_get_module(obj);
    ABObj	win;
    ABObj	apobj;
    int		num_wins;
    int		i;

    /* Find MainWindow to be Custom Dialog's Motif parent.
     * If none exist, window-parent will remain NULL
     */
    num_wins = obj_get_num_children(module);
    for (i = 0; i < num_wins; i++)
    {
	win = obj_get_child(module, i);
	if (obj_is_base_win(win))
	{
	    obj_set_win_parent(obj, win);
	    break;
	}
    }
    obj_set_unique_name(obj, "dialog");

    obj_set_label(obj, catgets(Dtb_project_catd, 100, 256, "Custom Dialog"));
    obj_set_bg_color(obj, "white");
    obj_set_is_initially_visible(obj, False);
    obj_set_is_initially_active(obj, True);
    obj_set_width(obj, custdlg_init_width);
    obj_set_height(obj, custdlg_init_height);

    /* Create Default Button Panel */
    apobj = obj_create(AB_TYPE_CONTAINER, obj);
    obj_set_subtype(apobj, AB_CONT_BUTTON_PANEL);
    pal_initialize_obj(apobj);

    /* Create Default Buttons for Button Panel */
    custdlg_create_buttons(obj, apobj);

    return OK;

}
示例#23
0
static int load_state(
  const struct RTOp_obj_type_vtbl_t* vtbl
  ,const void *            instance_data
  ,int                     num_values
  ,const RTOp_value_type   value_data[]
  ,int                     num_indexes
  ,const RTOp_index_type   index_data[]
  ,int                     num_chars
  ,const RTOp_char_type    char_data[]
  ,void **                 obj
  )
{
  assert(obj);
  assert( num_values  == 0 );
  assert( num_indexes == 1 );
  assert( num_chars   == 0 );
  if(*obj == NULL)
    obj_create(NULL,NULL,obj);
  *((RTOp_index_type*)*obj) = index_data[0];
  return 0;
}
示例#24
0
//------------------------------------------------------------
//	Trigger (enable) the materialization center in segment segnum
void trigger_matcen(const vsegptridx_t segnum)
{
	const auto &segp = segnum;
	FuelCenter	*robotcen;

	Assert(segp->special == SEGMENT_IS_ROBOTMAKER);
	Assert(segp->matcen_num < Num_fuelcenters);
	Assert((segp->matcen_num >= 0) && (segp->matcen_num <= Highest_segment_index));

	robotcen = &Station[RobotCenters[segp->matcen_num].fuelcen_num];

	if (robotcen->Enabled == 1)
		return;

	if (!robotcen->Lives)
		return;

#if defined(DXX_BUILD_DESCENT_II)
	//	MK: 11/18/95, At insane, matcens work forever!
	if (Difficulty_level+1 < NDL)
#endif
		robotcen->Lives--;

	robotcen->Timer = F1_0*1000;	//	Make sure the first robot gets emitted right away.
	robotcen->Enabled = 1;			//	Say this center is enabled, it can create robots.
	robotcen->Capacity = i2f(Difficulty_level + 3);
	robotcen->Disable_time = MATCEN_LIFE;

	//	Create a bright object in the segment.
	auto pos = compute_segment_center(segp);
	const auto delta = vm_vec_sub(Vertices[segnum->verts[0]], pos);
	vm_vec_scale_add2(pos, delta, F1_0/2);
	auto objnum = obj_create( OBJ_LIGHT, 0, segnum, pos, NULL, 0, CT_LIGHT, MT_NONE, RT_NONE );
	if (objnum != object_none) {
		objnum->lifeleft = MATCEN_LIFE;
		objnum->ctype.light_info.intensity = i2f(8);	//	Light cast by a fuelcen.
	} else {
		Int3();
	}
}
示例#25
0
/**
 * Constructor for CJumpNode class, with world position argument
 */
CJumpNode::CJumpNode(vec3d *position) : m_radius(0.0f), m_modelnum(-1), m_objnum(-1), m_flags(0)
{	
	Assert(position != NULL);
	
	gr_init_alphacolor(&m_display_color, 0, 255, 0, 255);
	
	// Set m_name
	sprintf(m_name, XSTR( "Jump Node %d", 632), Jump_nodes.size());
	
	// Set m_modelnum and m_radius
	m_modelnum = model_load(NOX("subspacenode.pof"), 0, NULL, 0);
	if (m_modelnum == -1)
		Warning(LOCATION, "Could not load default model for %s", m_name);
	else
		m_radius = model_get_radius(m_modelnum);
	
    m_pos.xyz.x = position->xyz.x;
    m_pos.xyz.y = position->xyz.y;
    m_pos.xyz.z = position->xyz.z;
    
	// Create the object
    m_objnum = obj_create(OBJ_JUMP_NODE, -1, -1, NULL, &m_pos, m_radius, OF_RENDERS);
}
示例#26
0
// ------------------------------------------------------------------------------------
// shockwave_create()
//
// Call to create a shockwave
//
//	input:	parent_objnum	=> object number of object spawning the shockwave
//				pos				=>	vector specifing global position of shockwave center
//				speed				=>	speed at which shockwave expands (m/s)
//				inner_radius	=>	radius at which damage applied is at maximum
//				outer_radius	=> damage decreases linearly to zero from inner_radius to
//										outer_radius.  Outside outer_radius, damage is 0.
//				damage			=>	the maximum damage (ie within inner_radius)
//				blast				=> the maximux blast (within inner_radius)
//				sw_flag			=> indicates whether shockwave is from weapon or ship explosion
//				delay          => delay in ms before the shockwave actually starts
//
//	return:	success			=>	object number of shockwave
//				failure			=>	-1
//
// Goober5000 - now parent_objnum can be allowed to be -1
int shockwave_create(int parent_objnum, vec3d *pos, shockwave_create_info *sci, int flag, int delay)
{
	int				i, objnum, real_parent;
	int				info_index = -1, model_id = -1;
	shockwave		*sw;
//	shockwave_info	*si;
	matrix			orient;

 	for (i = 0; i < MAX_SHOCKWAVES; i++) {
		if ( !(Shockwaves[i].flags & SW_USED) )
			break;
	}

	if (i == MAX_SHOCKWAVES)
		return -1;

	// try 2D shockwave first, then fall back to 3D, then fall back to default of either
	// this should be pretty fool-proof and allow quick change between 2D and 3D effects
	if ( strlen(sci->name) )
		info_index = shockwave_load(sci->name, false);

	if ( (info_index < 0) && strlen(sci->pof_name) )
		info_index = shockwave_load(sci->pof_name, true);

	if (info_index < 0) {
		if ( (Shockwave_info[0].bitmap_id >= 0) || (Shockwave_info[0].model_id >= 0) ) {
			info_index = 0;
			model_id = Shockwave_info[0].model_id;
		} else {
			// crap, just bail
			return -1;
		}
	} else {
		model_id = Shockwave_info[info_index].model_id;
	}

	// real_parent is the guy who caused this shockwave to happen
	if (parent_objnum == -1) {	// Goober5000
		real_parent = -1;
	} else if ( Objects[parent_objnum].type == OBJ_WEAPON ){
		real_parent = Objects[parent_objnum].parent;
	} else {
		real_parent = parent_objnum;
	}

	sw = &Shockwaves[i];

	sw->model_id = model_id;
	sw->flags = (SW_USED | flag);
	sw->speed = sci->speed;
	sw->inner_radius = sci->inner_rad;
	sw->outer_radius = sci->outer_rad;
	sw->damage = sci->damage;
	sw->blast = sci->blast;
	sw->radius = 1.0f;
	sw->pos = *pos;
	sw->num_objs_hit = 0;
	sw->shockwave_info_index = info_index;		// only one type for now... type could be passed is as a parameter
	sw->current_bitmap = -1;

	sw->time_elapsed=0.0f;
	sw->delay_stamp = delay;

	sw->rot_angles = sci->rot_angles;
	sw->damage_type_idx = sci->damage_type_idx;

//	si = &Shockwave_info[sw->shockwave_info_index];
//	sw->total_time = i2fl(si->num_frames) / si->fps;	// in seconds
	sw->total_time = sw->outer_radius / sw->speed;

	if ( (parent_objnum != -1) && Objects[parent_objnum].type == OBJ_WEAPON ) {		// Goober5000: allow -1
		sw->weapon_info_index = Weapons[Objects[parent_objnum].instance].weapon_info_index;
	}
	else {		
		sw->weapon_info_index = -1;
	}

	orient = vmd_identity_matrix;
	vm_angles_2_matrix(&orient, &sw->rot_angles);
//	angles a;
//	a.p = sw->rot_angle*(PI/180);
//	a.b = frand_range(0.0f, PI2);
//	a.h = frand_range(0.0f, PI2);
//	vm_angles_2_matrix(&orient, &a);
	objnum = obj_create( OBJ_SHOCKWAVE, real_parent, i, &orient, &sw->pos, sw->outer_radius, OF_RENDERS );

	if ( objnum == -1 ){
		Int3();
	}

	sw->objnum = objnum;

	list_append(&Shockwave_list, sw);

	return objnum;
}
示例#27
0
do_endlevel_frame()
{
	static fix timer;
	vms_vector save_last_pos;
	static fix explosion_wait1=0;
	static fix explosion_wait2=0;
	static fix bank_rate;
	static fix ext_expl_halflife;

	save_last_pos = ConsoleObject->last_pos;	//don't let move code change this
	object_move_all();
	ConsoleObject->last_pos = save_last_pos;

	if (ext_expl_playing) {

		external_explosion.lifeleft -= FrameTime;
		do_explosion_sequence(&external_explosion);

		if (external_explosion.lifeleft < ext_expl_halflife)
			mine_destroyed = 1;

		if (external_explosion.flags & OF_SHOULD_BE_DEAD)
			ext_expl_playing = 0;
	}

	if (cur_fly_speed != desired_fly_speed) {
		fix delta = desired_fly_speed - cur_fly_speed;
		fix frame_accel = fixmul(FrameTime,FLY_ACCEL);

		if (abs(delta) < frame_accel)
			cur_fly_speed = desired_fly_speed;
		else
			if (delta > 0)
				cur_fly_speed += frame_accel;
			else
				cur_fly_speed -= frame_accel;
	}

	//do big explosions
	if (!outside_mine) {

		if (Endlevel_sequence==EL_OUTSIDE) {
			vms_vector tvec;

			vm_vec_sub(&tvec,&ConsoleObject->pos,&mine_side_exit_point);

			if (vm_vec_dot(&tvec,&mine_exit_orient.fvec) > 0) {
				object *tobj;

				outside_mine = 1;

				tobj = object_create_explosion(exit_segnum,&mine_side_exit_point,i2f(50),VCLIP_BIG_PLAYER_EXPLOSION);

				if (tobj) {
					external_explosion = *tobj;

					tobj->flags |= OF_SHOULD_BE_DEAD;

					flash_scale = 0;	//kill lights in mine

					ext_expl_halflife = tobj->lifeleft;

					ext_expl_playing = 1;
				}
	
				digi_link_sound_to_pos( SOUND_BIG_ENDLEVEL_EXPLOSION, exit_segnum, 0, &mine_side_exit_point, 0, i2f(3)/4 );
			}
		}

		//do explosions chasing player
		if ((explosion_wait1-=FrameTime) < 0) {
			vms_vector tpnt;
			int segnum;
			object *expl;
			static int sound_count;

			vm_vec_scale_add(&tpnt,&ConsoleObject->pos,&ConsoleObject->orient.fvec,-ConsoleObject->size*5);
			vm_vec_scale_add2(&tpnt,&ConsoleObject->orient.rvec,(rand()-RAND_MAX/2)*15);
			vm_vec_scale_add2(&tpnt,&ConsoleObject->orient.uvec,(rand()-RAND_MAX/2)*15);

			segnum = find_point_seg(&tpnt,ConsoleObject->segnum);

			if (segnum != -1) {
				expl = object_create_explosion(segnum,&tpnt,i2f(20),VCLIP_BIG_PLAYER_EXPLOSION);
				if (rand()<10000 || ++sound_count==7) {		//pseudo-random
					digi_link_sound_to_pos( SOUND_TUNNEL_EXPLOSION, segnum, 0, &tpnt, 0, F1_0 );
					sound_count=0;
				}
			}

			explosion_wait1 = 0x2000 + rand()/4;

		}
	}

	//do little explosions on walls
	if (Endlevel_sequence >= EL_FLYTHROUGH && Endlevel_sequence < EL_OUTSIDE)
		if ((explosion_wait2-=FrameTime) < 0) {
			vms_vector tpnt;
			fvi_query fq;
			fvi_info hit_data;

			//create little explosion on wall

			vm_vec_copy_scale(&tpnt,&ConsoleObject->orient.rvec,(rand()-RAND_MAX/2)*100);
			vm_vec_scale_add2(&tpnt,&ConsoleObject->orient.uvec,(rand()-RAND_MAX/2)*100);
			vm_vec_add2(&tpnt,&ConsoleObject->pos);

			if (Endlevel_sequence == EL_FLYTHROUGH)
				vm_vec_scale_add2(&tpnt,&ConsoleObject->orient.fvec,rand()*200);
			else
				vm_vec_scale_add2(&tpnt,&ConsoleObject->orient.fvec,rand()*60);

			//find hit point on wall

			fq.p0 = &ConsoleObject->pos;
			fq.p1 = &tpnt;
			fq.startseg = ConsoleObject->segnum;
			fq.rad = 0;
			fq.thisobjnum = 0;
			fq.ignore_obj_list = NULL;
			fq.flags = 0;

			find_vector_intersection(&fq,&hit_data);

			if (hit_data.hit_type==HIT_WALL && hit_data.hit_seg!=-1)
				object_create_explosion(hit_data.hit_seg,&hit_data.hit_pnt,i2f(3)+rand()*6,VCLIP_SMALL_EXPLOSION);

			explosion_wait2 = (0xa00 + rand()/8)/2;
		}

	switch (Endlevel_sequence) {

		case EL_OFF: return;

		case EL_FLYTHROUGH: {

			do_endlevel_flythrough(0);

			if (ConsoleObject->segnum == transition_segnum) {
				int objnum;

				Endlevel_sequence = EL_LOOKBACK;

				objnum = obj_create(OBJ_CAMERA, 0, 
					ConsoleObject->segnum,&ConsoleObject->pos,&ConsoleObject->orient,0,
					CT_NONE,MT_NONE,RT_NONE);

				if (objnum == -1) {				//can't get object, so abort
					mprintf((1, "Can't get object for endlevel sequence.  Aborting endlevel sequence.\n"));
					stop_endlevel_sequence();
					return;
				}

				Viewer = endlevel_camera = &Objects[objnum];

				select_cockpit(CM_LETTERBOX);

				fly_objects[1] = fly_objects[0];
				fly_objects[1].obj = endlevel_camera;
				fly_objects[1].speed = (5*cur_fly_speed)/4;
				fly_objects[1].offset_frac = 0x4000;

				vm_vec_scale_add2(&endlevel_camera->pos,&endlevel_camera->orient.fvec,i2f(7));

				timer=0x20000;
			}

			break;
		}


		case EL_LOOKBACK: {

			do_endlevel_flythrough(0);
			do_endlevel_flythrough(1);

			if (timer>0) {

				timer -= FrameTime;

				if (timer < 0)		//reduce speed
					fly_objects[1].speed = fly_objects[0].speed;
			}

			if (endlevel_camera->segnum == exit_segnum) {
				vms_angvec cam_angles,exit_seg_angles;

				Endlevel_sequence = EL_OUTSIDE;

				timer = i2f(2);

				vm_vec_negate(&endlevel_camera->orient.fvec);
				vm_vec_negate(&endlevel_camera->orient.rvec);

				vm_extract_angles_matrix(&cam_angles,&endlevel_camera->orient);
				vm_extract_angles_matrix(&exit_seg_angles,&mine_exit_orient);
				bank_rate = (-exit_seg_angles.b - cam_angles.b)/2;

				ConsoleObject->control_type = endlevel_camera->control_type = CT_NONE;

				//_MARK_("Starting outside");//Commented out by KRB

#ifdef SLEW_ON
 slew_obj = endlevel_camera;
#endif
			}
				
			break;
		}

		case EL_OUTSIDE: {
			#ifndef SLEW_ON
			vms_angvec cam_angles;
			#endif

			vm_vec_scale_add2(&ConsoleObject->pos,&ConsoleObject->orient.fvec,fixmul(FrameTime,cur_fly_speed));
#ifndef SLEW_ON
			vm_vec_scale_add2(&endlevel_camera->pos,&endlevel_camera->orient.fvec,fixmul(FrameTime,-2*cur_fly_speed));
			vm_vec_scale_add2(&endlevel_camera->pos,&endlevel_camera->orient.uvec,fixmul(FrameTime,-cur_fly_speed/10));

			vm_extract_angles_matrix(&cam_angles,&endlevel_camera->orient);
			cam_angles.b += fixmul(bank_rate,FrameTime);
			vm_angles_2_matrix(&endlevel_camera->orient,&cam_angles);
#endif

			timer -= FrameTime;

			if (timer < 0) {

				Endlevel_sequence = EL_STOPPED;

				vm_extract_angles_matrix(&player_angles,&ConsoleObject->orient);

				timer = i2f(3);

			}

			break;
		}

		case EL_STOPPED: {

			get_angs_to_object(&player_dest_angles,&station_pos,&ConsoleObject->pos);
			chase_angles(&player_angles,&player_dest_angles);
			vm_angles_2_matrix(&ConsoleObject->orient,&player_angles);

			vm_vec_scale_add2(&ConsoleObject->pos,&ConsoleObject->orient.fvec,fixmul(FrameTime,cur_fly_speed));

			timer -= FrameTime;

			if (timer < 0) {

				#ifdef SLEW_ON
				slew_obj = endlevel_camera;
				_do_slew_movement(endlevel_camera,1,1);
				timer += FrameTime;		//make time stop
				break;
				#else

				#ifdef SHORT_SEQUENCE

				stop_endlevel_sequence();

				#else
				Endlevel_sequence = EL_PANNING;

				vm_extract_angles_matrix(&camera_cur_angles,&endlevel_camera->orient);


				timer = i2f(3);

				if (Game_mode & GM_MULTI) { // try to skip part of the seq if multiplayer
					stop_endlevel_sequence();
					return;
				}

				//mprintf((0,"Switching to pan...\n"));
				#endif		//SHORT_SEQUENCE
				#endif		//SLEW_ON

			}
			break;
		}

		#ifndef SHORT_SEQUENCE
		case EL_PANNING: {
			#ifndef SLEW_ON
			int mask;
			#endif

			get_angs_to_object(&player_dest_angles,&station_pos,&ConsoleObject->pos);
			chase_angles(&player_angles,&player_dest_angles);
			vm_angles_2_matrix(&ConsoleObject->orient,&player_angles);
			vm_vec_scale_add2(&ConsoleObject->pos,&ConsoleObject->orient.fvec,fixmul(FrameTime,cur_fly_speed));

			#ifdef SLEW_ON
			_do_slew_movement(endlevel_camera,1,1);
			#else

			get_angs_to_object(&camera_desired_angles,&ConsoleObject->pos,&endlevel_camera->pos);
			mask = chase_angles(&camera_cur_angles,&camera_desired_angles);
			vm_angles_2_matrix(&endlevel_camera->orient,&camera_cur_angles);

			if ((mask&5) == 5) {

				vms_vector tvec;

				Endlevel_sequence = EL_CHASING;

				//_MARK_("Done outside");//Commented out -KRB

				vm_vec_normalized_dir_quick(&tvec,&station_pos,&ConsoleObject->pos);
				vm_vector_2_matrix(&ConsoleObject->orient,&tvec,&surface_orient.uvec,NULL);

				desired_fly_speed *= 2;

				//mprintf((0,"Switching to chase...\n"));

			}
			#endif

			break;
		}

		case EL_CHASING: {
			fix d,speed_scale;

			#ifdef SLEW_ON
			_do_slew_movement(endlevel_camera,1,1);
			#endif

			get_angs_to_object(&camera_desired_angles,&ConsoleObject->pos,&endlevel_camera->pos);
			chase_angles(&camera_cur_angles,&camera_desired_angles);

			#ifndef SLEW_ON
			vm_angles_2_matrix(&endlevel_camera->orient,&camera_cur_angles);
			#endif

			d = vm_vec_dist_quick(&ConsoleObject->pos,&endlevel_camera->pos);

			speed_scale = fixdiv(d,i2f(0x20));
			if (d<f1_0) d=f1_0;

			get_angs_to_object(&player_dest_angles,&station_pos,&ConsoleObject->pos);
			chase_angles(&player_angles,&player_dest_angles);
			vm_angles_2_matrix(&ConsoleObject->orient,&player_angles);

			vm_vec_scale_add2(&ConsoleObject->pos,&ConsoleObject->orient.fvec,fixmul(FrameTime,cur_fly_speed));
			#ifndef SLEW_ON
			vm_vec_scale_add2(&endlevel_camera->pos,&endlevel_camera->orient.fvec,fixmul(FrameTime,fixmul(speed_scale,cur_fly_speed)));

			if (vm_vec_dist(&ConsoleObject->pos,&station_pos) < i2f(10))
				stop_endlevel_sequence();
			#endif

			break;

		}
		#endif		//ifdef SHORT_SEQUENCE
	}
}
示例#28
0
文件: pal_choice.c 项目: juddy/edcde
/*************************************************************************
**                                                                      **
**       Function Definitions                                           **
**                                                                      **
**************************************************************************/
static int
choice_initialize(
    ABObj    obj
)
{
    AB_CHOICE_TYPE choice_type;
    ABObj	module = obj_get_module(obj);
    ABObj	iobj;
    String  items[2];
    int		i;

    choice_type = obj->info.choice.type;

    switch(choice_type)
    {
    case AB_CHOICE_NONEXCLUSIVE:
        obj_set_unique_name(obj, "checkbox");
        obj_set_label(obj, catgets(Dtb_project_catd, 100, 253, "Choice:"));
        break;
    case AB_CHOICE_OPTION_MENU:
        obj_set_unique_name(obj, "optionmenu");
        obj_set_label(obj, catgets(Dtb_project_catd, 100, 254, "Options:"));
        break;
    case AB_CHOICE_EXCLUSIVE:
    default:
        obj_set_unique_name(obj, "radiobox");
        obj_set_label(obj, catgets(Dtb_project_catd, 100, 253, "Choice:"));
        break;
    }

    obj_set_is_initially_visible(obj, True);
    obj_set_is_initially_active(obj, True);

    if (choice_type == AB_CHOICE_EXCLUSIVE)
        obj_set_orientation(obj, AB_ORIENT_HORIZONTAL);
    else
        obj_set_orientation(obj, AB_ORIENT_VERTICAL);

    obj_set_num_columns(obj, 1);

    /* Add initial items to Choice */
    items[0] = catgets(Dtb_project_catd, 6, 70, "itemA");
    items[1] = catgets(Dtb_project_catd, 6, 71, "itemB");
    for (i=0; i < XtNumber(items); i++)
    {
        iobj = obj_create(AB_TYPE_ITEM, NULL);
        obj_append_child(obj, iobj);
        obj_set_subtype(iobj, AB_ITEM_FOR_CHOICE);
        iobj->label_type = AB_LABEL_STRING;

        if (i == 0)
            obj_set_is_initially_selected(iobj, True);
        else
            obj_set_is_initially_selected(iobj, False);

        obj_set_is_initially_active(iobj, True);
        abobj_set_item_name(iobj, obj_get_module(obj), obj_get_name(obj), items[i]);
        obj_set_label(iobj, items[i]);
    }

    obj_set_attachment(obj, AB_CP_NORTH, AB_ATTACH_POINT, NULL, obj->y);
    obj_set_attachment(obj, AB_CP_WEST,  AB_ATTACH_POINT, NULL, obj->x);

    return OK;

}
示例#29
0
// read in a new mission file from disk
int CFREDDoc::load_mission(char *pathname)
{
	char name[512], *old_name;
	int i, j, k, ob;
	int used_pool[MAX_WEAPON_TYPES];
	waypoint_list *wptr;
	object *objp;

	Parse_viewer_pos = view_pos;
	Parse_viewer_orient = view_orient;

	// activate the localizer hash table
	fhash_flush();	

	clear_mission();
	Fred_found_unknown_ship_during_parsing = 0;
	if (parse_main(pathname)) {
		sprintf(name, "Unable to load the file \"%s\"", pathname);
		Fred_view_wnd->MessageBox(name);
		create_new_mission();		
		return -1;
	}

	if(Fred_found_unknown_ship_during_parsing){
		Fred_view_wnd->MessageBox("Fred encountered unknown ship/weapon classes when parsing the mission file. This may be due to mission disk data you do not have");
	}
	Fred_found_unknown_ship_during_parsing = 0;

	for (i=0; i<Num_waypoint_lists; i++) {
		wptr = &Waypoint_lists[i];
		for (j=0; j<wptr->count; j++){
			ob = obj_create(OBJ_WAYPOINT, -1, i * 65536 + j, NULL, &wptr->waypoints[j], 0.0f, OF_RENDERS);
		}
	}

	obj_merge_created_list();
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		if (objp->flags & OF_PLAYER_SHIP) {
			Assert(objp->type == OBJ_SHIP);
			objp->type = OBJ_START;
//			Player_starts++;
		}

		objp = GET_NEXT(objp);
	}

	for (i=0; i<num_wings; i++) {
		for (j=0; j<Wings[i].wave_count; j++) {
			ob = Ships[Wings[i].ship_index[j]].objnum;
			wing_objects[i][j] = ob;
			Ships[Wings[i].ship_index[j]].wingnum = i;
			Ships[Wings[i].ship_index[j]].arrival_cue = Locked_sexp_false;
		}

		// fix old ship names for ships in wings if needed
		while (j--) {
			if ( (Objects[wing_objects[i][j]].type == OBJ_SHIP) || (Objects[wing_objects[i][j]].type == OBJ_START) ) {  // don't change player ship names
				sprintf(name, "%s %d", Wings[i].name, j + 1);
				old_name = Ships[Wings[i].ship_index[j]].ship_name;
				if (stricmp(name, old_name)) {  // need to fix name
					update_sexp_references(old_name, name);
					ai_update_goal_references(REF_TYPE_SHIP, old_name, name);
					for (k=0; k<Num_reinforcements; k++)
						if (!stricmp(old_name, Reinforcements[k].name)) {
							Assert(strlen(name) < NAME_LENGTH);
							strcpy(Reinforcements[k].name, name);
						}

					strcpy(Ships[Wings[i].ship_index[j]].ship_name, name);
				}
			}
		}
	}

	generate_weaponry_usage_list(used_pool);
	for ( j = 0; j < Num_teams; j++ ) {
		for (i=0; i<Num_weapon_types; i++) {
			Team_data[j].weaponry_pool[i] -= used_pool[i];  // convert weaponry_pool to be extras available beyond the current ships weapons
			if (Team_data[j].weaponry_pool[i] < 0)
				Team_data[j].weaponry_pool[i] = 0;
		}
	}

	Assert(Mission_palette >= 0);
	Assert(Mission_palette <= 98);

	if (The_mission.flags & MISSION_FLAG_SUBSPACE) {
		strcpy(name, NOX("gamepalette-subspace"));
	} else {
		strcpy(name, "gamepalette1-01");
		// sprintf(name, NOX("gamepalette1-%02d"), Mission_palette + 1);
	}

	palette_load_table(name);

	// go through all ships and translate their alternate name indices	
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		// if this is a ship, check it, and mark its possible alternate name down in the auxiliary array
		if(((objp->type == OBJ_SHIP) || (objp->type == OBJ_START)) && (objp->instance >= 0) && (Ships[objp->instance].alt_type_index >= 0)){
			mission_parse_lookup_alt_index(Ships[objp->instance].alt_type_index, Fred_alt_names[objp->instance]);

			// also zero it
			Ships[objp->instance].alt_type_index = -1;
		}

		objp = GET_NEXT(objp);
	}


	view_pos = Parse_viewer_pos;
	view_orient = Parse_viewer_orient;
	set_modified(0);	

	return 0;
}
示例#30
0
文件: object.c 项目: fjolnir/Dynamo
Obj_t *obj_create_autoreleased(Class_t *aClass)
{
    Obj_t *self = obj_create(aClass);
    return obj_autorelease(self);
}