Пример #1
0
void		map_contents(t_env *e)
{
	int	i;
	int	j;

	i = -1;
	while (e->map->mapheight > ++i)
	{
		j = -1;
		while (e->map->mapwidth > ++j)
		{
			if (i == 0)
			{
				if (e->map->map[i][j] != 1)
					ft_error("Bad formatage");
			}
			else if (i == e->map->mapheight - 1)
			{
				if (e->map->map[i][j] != 1)
					ft_error("Bad formatage");
			}
			else if (j == 0 || j == e->map->mapwidth - 1)
				if (e->map->map[i][j] != 1)
					ft_error("Bad formatage");
		}
	}
	map_start(e);
}
Пример #2
0
Файл: app.c Проект: rzel/dim3
bool app_run_editor_launch(char *err_str)
{
		// launch directly into map
		
	server.state=gs_running;
	net_setup.mode=net_mode_none;
		
	if (!game_start(FALSE,skill_medium,0,0,err_str)) return(FALSE);
	
	if (!map_start(FALSE,TRUE,err_str)) {
		game_end();
		return(FALSE);
	}
	
	return(TRUE);
}
Пример #3
0
Файл: app.c Проект: rzel/dim3
bool app_run_dedicated_host(char *err_str)
{
	char			str[256];

		// launch directly into hosting
		// setup hosting flags and IPs
		
	host_game_setup();
	net_host_game_setup();

	net_setup.mode=net_mode_host;
	net_setup.client.latency=0;
	net_setup.client.host_addr.ip=0;
	net_setup.client.host_addr.port=0;
	
	net_create_project_hash();

		// setup map
		
	map.info.name[0]=0x0;
	strcpy(map.info.host_name,setup.network.map_list.maps[net_setup.host.current_map_idx].name);
	
		// start game
	
	if (!game_start(FALSE,skill_medium,0,0,err_str)) {
		net_host_game_end();
		return(FALSE);
	}
	
		// add any multiplayer bots
		
	if (!game_multiplayer_bots_create(err_str)) {
		game_end();
		net_host_game_end();
		return(FALSE);
	}
	
		// start the map
		
	if (!map_start(FALSE,TRUE,err_str)) {
		game_end();
		net_host_game_end();
		return(FALSE);
	}

		// start hosting

	if (!net_host_game_start(err_str)) {
		map_end();
		game_end();
		net_host_game_end();
		return(FALSE);
	}

		// dedicated hosting, no local
		// player to add, only add
		// multiplayer bots to host

	net_host_join_multiplayer_bots();

		// game is running

	sprintf(str,"Running on %s...",net_setup.host.ip_resolve);
	console_add(str);
	
	server.next_state=gs_running;

	return(TRUE);
}
Пример #4
0
bool game_file_load(char *file_name,char *err_str)
{
	char				*c,path[1024],fname[256];
	file_save_header	head;
	
		// load and expand
		
	strcpy(fname,file_name);
	c=strrchr(fname,'.');
	if (c!=NULL) *c=0x0;			// remove any extensions
	
	file_paths_documents(&setup.file_path_setup,path,"Saved Games",fname,"sav");
	if (!game_file_expand_load(path,err_str)) return(FALSE);
	
	game_file_pos=0;

	progress_initialize("Loading");

		// if game isn't running, then start
		
	if (!server.game_open) {
		if (!game_start(skill_medium,NULL,err_str)) {
			free(game_file_data);
			return(FALSE);
		}
	}

		// get header

	game_file_get_chunk(&head);

		// check version
		
	if (strcmp(head.version,dim3_version)!=0) {
		sprintf(err_str,"This saved game file is from a different version of dim3");
		free(game_file_data);
		return(FALSE);
	}
		
		// reload map

	progress_draw(10);
	
	if ((!server.map_open) || (strcmp(head.map_name,map.info.name)!=0)) {		// need to load a map?
	
		if (server.map_open) map_end();
		
		strcpy(map.info.name,head.map_name);
		map.info.player_start_name[0]=0x0;
		map.info.player_start_type[0]=0x0;
		map.info.in_load=TRUE;

		if (!map_start(TRUE,err_str)) {
			free(game_file_data);
			return(FALSE);
		}
	}
	
		// timing
		
	game_time_set(head.tick);

		// view and server objects
		
	progress_draw(20);
					
	game_file_get_chunk(&view.time);
	game_file_get_chunk(&view.fps);
	game_file_get_chunk(&camera);
	
	game_file_get_chunk(&server.time);
	game_file_get_chunk(&server.player_obj_uid);
	game_file_get_chunk(&server.skill);
	
	game_file_get_chunk(&server.uid);
	game_file_get_chunk(&server.count);
	
	progress_draw(30);

	free(server.objs);
	free(server.weapons);
	free(server.proj_setups);

	server.objs=(obj_type*)game_file_replace_chunk();
	server.weapons=(weapon_type*)game_file_replace_chunk();
	server.proj_setups=(proj_setup_type*)game_file_replace_chunk();

	if ((server.objs==NULL) || (server.weapons==NULL) || (server.proj_setups==NULL)) {
		free(game_file_data);
		return(FALSE);
	}
	
	progress_draw(40);

	game_file_get_chunk(server.projs);
	game_file_get_chunk(server.effects);
	game_file_get_chunk(server.decals);

	progress_draw(50);

	game_file_get_chunk(hud.bitmaps);
	game_file_get_chunk(hud.texts);
	game_file_get_chunk(hud.bars);
	game_file_get_chunk(&hud.radar);
	
		// map changes
		
	progress_draw(60);

	game_file_get_chunk(&map.ambient);					
	game_file_get_chunk(&map.rain);					
	game_file_get_chunk(&map.background);					
	game_file_get_chunk(&map.sky);
	game_file_get_chunk(&map.fog);

	progress_draw(70);
	
	map_group_dispose_unit_list(&map);			// need to destroy and rebuild unit lists
	game_file_get_chunk(map.groups);
	map_group_create_unit_list(&map);

	game_file_get_chunk(map.movements);

	group_moves_synch_with_load();
	
		// script objects
		
	progress_draw(80);

	game_file_get_chunk(&js.script_current_uid);
	game_file_get_chunk(&js.count);
	game_file_get_chunk(&js.time);
	
	game_file_get_chunk(js.timers);
	game_file_get_chunk(js.globals);

		// reset model UIDs

	progress_draw(90);

	models_reset_uid();
	
		// send scripts load event
		// to restore globals
		
	progress_draw(95);
	
	script_state_load();

		// free game data
		
	progress_draw(100);
	free(game_file_data);
	
		// finished

	progress_shutdown();

		// fix some necessary functions

	map.rain.reset=TRUE;
	fade_screen_cancel();
		
		 // return to old game time

	game_time_reset();
  
    return(TRUE);
}
Пример #5
0
rt_public EIF_REFERENCE edclone(EIF_CONTEXT EIF_REFERENCE source)
{
    /* Recursive Eiffel clone. This function recursively clones the source
     * object and returns a pointer to the top of the new tree.
     */
    RT_GET_CONTEXT
    EIF_GET_CONTEXT
    EIF_REFERENCE root = (EIF_REFERENCE)  0;		/* Root of the deep cloned object */
    jmp_buf exenv;					/* Environment saving */
    struct {
        union overhead discard;		/* Pseudo object header */
        EIF_REFERENCE boot;					/* Anchor point for cloning process */
    } anchor;
    struct rt_traversal_context traversal_context;
    int volatile is_locked;

#ifdef DEBUG
    int xobjs;
#endif

    if (source == NULL) {
        return NULL;			/* Void source */
    }

    /* The deep clone of the source will be attached in the 'boot' entry from
     * the anchor structure. It all happens as if we were in fact deep cloning
     * the anchor pseudo-object.
     */

    memset (&anchor, 0, sizeof(anchor));	/* Reset header */
    anchor.boot = (EIF_REFERENCE)  &root;	/* To boostrap cloning process */

    RT_GC_PROTECT(source);	/* Protect source: allocation will occur */

#ifdef DEBUG
    xobjs = nomark(source);
    printf("Source has %x %d objects\n", source, xobjs);
#endif

    /* Set up an exception trap. If any exception occurs, control will be
     * transferred back here by the run-time to give us a chance to clean-up
     * our structures.
     */

    {
        RTXDRH;							/* Save stack contexts */
        EIF_EO_STORE_LOCK;				/* Because we perform a traversal that marks
										   objects, we need to be sure we are the
										   only one doing it. */
        is_locked = 1;

        excatch(&exenv);		/* Record pseudo-execution vector */
        if (setjmp(exenv)) {
            RTXSCH;						/* Restore stack contexts */
            map_reset(1);				/* Reset in emergency situation */
            /* If we locked the EO_STORE_MUTEX, then we need to unmark objects
             * and unlock it. */
            if (is_locked) {
                /* We are only concerned abount unmarking objects, so we do not perform any
                 * accounting. */
                CHECK ("Not accounting", traversal_context.accounting == 0);
                CHECK ("Not unmarking", traversal_context.is_unmarking == 0);
                /* First we mark again all objects. */
                traversal_context.is_unmarking = 0;
                traversal(&traversal_context, source);
                /* Then we unmark them. */
                traversal_context.is_unmarking = 1;
                traversal(&traversal_context, source);
                /* Now we can unlock our mutex. */
                EIF_EO_STORE_UNLOCK;
            }
            ereturn(MTC_NOARG);					/* And propagate the exception */
        }

        /* Now start the traversal of the source, allocating all the objects as
         * needed and stuffing them into a FIFO stack for later perusal by the
         * cloning process.
         */

        memset (&traversal_context, 0, sizeof(struct rt_traversal_context));
        traversal_context.accounting = TR_MAP;
        traversal(&traversal_context, source);		/* Object traversal, mark with EO_STORE */
        hash_malloc(&hclone, traversal_context.obj_nb);	/* Hash table allocation */
        map_start();					/* Restart at bottom of FIFO stack */

#ifdef DEBUG
        printf("Computed %x %d objects\n\n", source, traversal_context.obj_nb);
#endif

        /* Throughout the deep cloning process, we need to maintain the notion of
         * enclosing object for GC aging tests. The enclosing object is defined as
         * being the object to which the currently cloned tree will be attached.
         *
         * We need to initialize the cloning process by computing a valid reference
         * into the root variable. That will be the enclosing object, and of course
         * it cannot be void, ever, or something really really weird is happening.
         *
         * To get rid of code duplication, I am initially calling rdeepclone with
         * an enclosing object address set to anchor.boot. The anchor structure
         * represents a pseudo anchor object for the object hierarchy being cloned.
         */

        rdeepclone(source, (EIF_REFERENCE) &anchor.boot, 0);	/* Recursive clone */
        hash_free(&hclone);						/* Free hash table */
        map_reset(0);							/* And eif_free maping table */
        /* Release all the hector pointers asked for during the map table
         * construction (obj_nb exactly) */
        CHECK("Has objects", traversal_context.obj_nb > 0);
        eif_ostack_npop(&hec_stack, traversal_context.obj_nb);

#ifdef DEBUG
        xobjs= nomark(source);
        printf("Source now has %d objects\n", xobjs);
        xobjs = nomark(anchor.boot);
        printf("Result has %d objects\n", xobjs);
#endif

        RT_GC_WEAN(source);			/* Release GC protection */
        expop(&eif_stack);			/* Remove pseudo execution vector */
    }

    EIF_EO_STORE_UNLOCK;		/* Free marking mutex */
    is_locked = 0;

    return anchor.boot;			/* The cloned object tree */
}