示例#1
0
MapgenV5::MapgenV5(int mapgenid, MapgenParams *params, EmergeManager *emerge)
    : MapgenBasic(mapgenid, params, emerge)
    , Mapgen_features(mapgenid, params, emerge)
{
    MapgenV5Params *sp = (MapgenV5Params *)params->sparams;

    this->spflags    = sp->spflags;
    this->cave_width = sp->cave_width;

    // Terrain noise
    noise_filler_depth = new Noise(&sp->np_filler_depth, seed, csize.X, csize.Z);
    noise_factor       = new Noise(&sp->np_factor,       seed, csize.X, csize.Z);
    noise_height       = new Noise(&sp->np_height,       seed, csize.X, csize.Z);

    // 3D terrain noise
    // 1-up 1-down overgeneration
    noise_ground = new Noise(&sp->np_ground, seed, csize.X, csize.Y + 2, csize.Z);

    MapgenBasic::np_cave1 = sp->np_cave1;
    MapgenBasic::np_cave2 = sp->np_cave2;

    //freeminer:
    y_offset = 1;
    float_islands = sp->float_islands;
    noise_float_islands1  = new Noise(&sp->np_float_islands1, seed, csize.X, csize.Y + y_offset * 2, csize.Z);
    noise_float_islands2  = new Noise(&sp->np_float_islands2, seed, csize.X, csize.Y + y_offset * 2, csize.Z);
    noise_float_islands3  = new Noise(&sp->np_float_islands3, seed, csize.X, csize.Z);

    noise_layers          = new Noise(&sp->np_layers,         seed, csize.X, csize.Y + y_offset * 2, csize.Z);
    layers_init(emerge, sp->paramsj);

    //noise_cave_indev      = new Noise(&sp->np_cave_indev,     seed, csize.X, csize.Y + y_offset * 2, csize.Z);
    //=========
}
示例#2
0
void GAMECLIENT::on_connected()
{
	layers_init();
	col_init();
	render_tilemap_generate_skip();

	for(int i = 0; i < all.num; i++)
	{
		all.components[i]->on_mapload();
		all.components[i]->on_reset();
	}
	
	SERVER_INFO current_server_info;
	client_serverinfo(&current_server_info);
	
	servermode = SERVERMODE_PURE;
	
	// send the inital info
	send_info(true);

	freeview = true;
	spectate_cid = -1;
	last_game_over = false;
	last_warmup = false;
	last_flag_carrier[0] = -1;
	last_flag_carrier[1] = -1;
}
void mods_init()
{
	//if(!data) /* only load once */
		//data = load_data_from_memory(internal_data);
		
	for(int i = 0; i < NUM_NETOBJTYPES; i++)
		snap_set_staticsize(i, netobj_get_size(i));

	layers_init();
	col_init();
	game.controller = new GAMECONTROLLER_BALL;
	MAPITEM_LAYER_TILEMAP *tmap = layers_game_layer();
	TILE *tiles = (TILE *)map_get_data(tmap->data);
	
	for(int y = 0; y < tmap->height; y++)
	{
		for(int x = 0; x < tmap->width; x++)
		{
			int index = tiles[y*tmap->width+x].index;
			
			if(index >= ENTITY_OFFSET)
			{
				vec2 pos(x*32.0f+16.0f, y*32.0f+16.0f);
				game.controller->on_entity(index-ENTITY_OFFSET, pos);
			}
		}
	}

	//game.world.insert_entity(game.controller);

#ifdef CONF_DEBUG
	if(config.dbg_dummies)
	{
		for(int i = 0; i < config.dbg_dummies ; i++)
		{
			mods_connected(MAX_CLIENTS-i-1);
			mods_client_enter(MAX_CLIENTS-i-1);
			if(game.controller->is_teamplay())
				game.players[MAX_CLIENTS-i-1]->team = i&1;
		}
	}
#endif
}
示例#4
0
MapgenIndev::MapgenIndev(int mapgenid, MapgenIndevParams *params, EmergeManager *emerge)
    : MapgenV6(mapgenid, params, emerge)
    , Mapgen_features(mapgenid, params, emerge)
{
    //sp = (MapgenIndevParams *)params->sparams;
    sp = params;

    xstride = 1;
    ystride = csize.X * xstride;
    zstride = csize.Y * ystride;

    noise_float_islands1  = new Noise(&sp->np_float_islands1, seed, csize.X, csize.Y + y_offset * 2, csize.Z);
    noise_float_islands2  = new Noise(&sp->np_float_islands2, seed, csize.X, csize.Y + y_offset * 2, csize.Z);
    noise_float_islands3  = new Noise(&sp->np_float_islands3, seed, csize.X, csize.Z);

    noise_layers          = new Noise(&sp->np_layers,         seed, csize.X, csize.Y + y_offset * 2, csize.Z);
    layers_init(emerge, sp->paramsj);

    noise_cave_indev      = new Noise(&sp->np_cave_indev,     seed, csize.X, csize.Y + y_offset * 2, csize.Z);
}
示例#5
0
void GAMECLIENT::on_connected()
{
	layers_init();
	col_init();
	render_tilemap_generate_skip();

	for(int i = 0; i < all.num; i++)
	{
		all.components[i]->on_mapload();
		all.components[i]->on_reset();
	}
	
	SERVER_INFO current_server_info;
	client_serverinfo(&current_server_info);
	
	servermode = SERVERMODE_PURE;
	
	// send the inital info
	send_info(true);
}
示例#6
0
文件: main.c 项目: elcerdo/avr
int main(void) {
    uint8_t i;

    keypad_init();
    led_init();
    status_init();
    layers_init();

    for (i=0; i<8; i++) led_send_command(i+1,0x00);

    wdt_enable(WDTO_1S);
    /* Even if you don't use the watchdog, turn it off here. On newer devices,
     * the status of the watchdog (on/off, period) is PRESERVED OVER RESET!
     */
    /* RESET status: all port bits are inputs without pull-up.
     * That's the way we need D+ and D-. Therefore we don't need any
     * additional hardware initialization.
     */
    odDebugInit();
    usbInit();
    usbDeviceDisconnect();  /* enforce re-enumeration, do this while interrupts are disabled! */
    i = 0;
    while(--i){             /* fake USB disconnect for > 250 ms */
        wdt_reset();
        _delay_ms(1);
    }
    usbDeviceConnect();

    sei();
    DBG1(0x01, 0, 0);       /* debug output: main loop starts */
    for(;;){                /* main event loop */
        wdt_reset();
        usbPoll();
    }

    keypad_free();
    layers_free();

    return 0;
}
示例#7
0
MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge)
	: Mapgen(mapgenid, params, emerge)
	, Mapgen_features(mapgenid, params, emerge)
{
	this->m_emerge = emerge;
	this->bmgr     = emerge->biomemgr;

	//// amount of elements to skip for the next index
	//// for noise/height/biome maps (not vmanip)
	this->ystride = csize.X;
	this->zstride = csize.X * (csize.Y + 2);

	this->biomemap        = new u8[csize.X * csize.Z];
	this->heightmap       = new s16[csize.X * csize.Z];
	this->heatmap         = NULL;
	this->humidmap        = NULL;
	this->ridge_heightmap = new s16[csize.X * csize.Z];

	MapgenV7Params *sp = (MapgenV7Params *)params->sparams;
	this->spflags = sp->spflags;

	//// Terrain noise
	noise_terrain_base    = new Noise(&sp->np_terrain_base,    seed, csize.X, csize.Z);
	noise_terrain_alt     = new Noise(&sp->np_terrain_alt,     seed, csize.X, csize.Z);
	noise_terrain_persist = new Noise(&sp->np_terrain_persist, seed, csize.X, csize.Z);
	noise_height_select   = new Noise(&sp->np_height_select,   seed, csize.X, csize.Z);
	noise_filler_depth    = new Noise(&sp->np_filler_depth,    seed, csize.X, csize.Z);
	noise_mount_height    = new Noise(&sp->np_mount_height,    seed, csize.X, csize.Z);
	noise_ridge_uwater    = new Noise(&sp->np_ridge_uwater,    seed, csize.X, csize.Z);

	//// 3d terrain noise
	noise_mountain = new Noise(&sp->np_mountain, seed, csize.X, csize.Y + 2, csize.Z);
	noise_ridge    = new Noise(&sp->np_ridge,    seed, csize.X, csize.Y + 2, csize.Z);
	noise_cave1    = new Noise(&sp->np_cave1,    seed, csize.X, csize.Y + 2, csize.Z);
	noise_cave2    = new Noise(&sp->np_cave2,    seed, csize.X, csize.Y + 2, csize.Z);

	//// Biome noise
	noise_heat           = new Noise(&params->np_biome_heat,           seed, csize.X, csize.Z);
	noise_humidity       = new Noise(&params->np_biome_humidity,       seed, csize.X, csize.Z);
	noise_heat_blend     = new Noise(&params->np_biome_heat_blend,     seed, csize.X, csize.Z);
	noise_humidity_blend = new Noise(&params->np_biome_humidity_blend, seed, csize.X, csize.Z);

	//// Resolve nodes to be used
	INodeDefManager *ndef = emerge->ndef;

	c_stone                = ndef->getId("mapgen_stone");
	c_water_source         = ndef->getId("mapgen_water_source");
	c_lava_source          = ndef->getId("mapgen_lava_source");
	c_desert_stone         = ndef->getId("mapgen_desert_stone");
	c_ice                  = ndef->getId("mapgen_ice");
	c_sandstone            = ndef->getId("mapgen_sandstone");

	c_cobble               = ndef->getId("mapgen_cobble");
	c_stair_cobble         = ndef->getId("mapgen_stair_cobble");
	c_mossycobble          = ndef->getId("mapgen_mossycobble");
	c_sandstonebrick       = ndef->getId("mapgen_sandstonebrick");
	c_stair_sandstonebrick = ndef->getId("mapgen_stair_sandstonebrick");

	if (c_ice == CONTENT_IGNORE)
		c_ice = c_water_source;

	//freeminer:
	float_islands = sp->float_islands;
	noise_float_islands1  = new Noise(&sp->np_float_islands1, seed, csize.X, csize.Y + 2, csize.Z);
	noise_float_islands2  = new Noise(&sp->np_float_islands2, seed, csize.X, csize.Y + 2, csize.Z);
	noise_float_islands3  = new Noise(&sp->np_float_islands3, seed, csize.X, csize.Z);

	noise_layers          = new Noise(&sp->np_layers,         seed, csize.X, csize.Y + 2, csize.Z);
	layers_init(emerge, sp->paramsj);

	if (c_mossycobble == CONTENT_IGNORE)
		c_mossycobble = c_cobble;
	if (c_stair_cobble == CONTENT_IGNORE)
		c_stair_cobble = c_cobble;
	if (c_sandstonebrick == CONTENT_IGNORE)
		c_sandstonebrick = c_sandstone;
	if (c_stair_sandstonebrick == CONTENT_IGNORE)
		c_stair_sandstonebrick = c_sandstone;
}
示例#8
0
int main( int argc, char *argv[] )
{
	glob_t globdata;
	int i, j, l, file_arg_start, new_empty = TRUE, get_screenshot = FALSE;

	if (argc > 1)
	{
		if ( strcmp(argv[1], "--version") == 0 )
		{
			printf("%s\n\n", MT_VERSION);
			exit(0);
		}
		if ( strcmp(argv[1], "--help") == 0 )
		{
			printf("%s\n\n"
				"Usage: mtpaint [option] [imagefile ... ]\n\n"
				"Options:\n"
				"  --help          Output this help\n"
				"  --version       Output version information\n"
				"  -s              Grab screenshot\n"
				"  -v              Start in viewer mode\n\n"
			, MT_VERSION);
			exit(0);
		}
	}

	putenv( "G_BROKEN_FILENAMES=1" );	// Needed to read non ASCII filenames in GTK+2

#if GTK2VERSION >= 4
	/* Tablet handling in GTK+ 2.18+ is broken beyond repair if this mode
	 * is set; so unset it, if g_unsetenv() is present */
	g_unsetenv("GDK_NATIVE_WINDOWS");
#endif

#ifdef U_THREADS
	/* Enable threading for GLib, but NOT for GTK+ (at least, not yet) */
	g_thread_init(NULL);
#endif
	inifile_init("/etc/mtpaint/mtpaintrc", "~/.mtpaint");

#ifdef U_NLS
#if GTK_MAJOR_VERSION == 1
	/* !!! GTK+1 needs locale set up before gtk_init(); GTK+2, *QUITE*
	 * the opposite - WJ */
	setup_language();
#endif
#endif

#ifdef U_THREADS
	/* !!! Uncomment to allow GTK+ calls from other threads */
	/* gdk_threads_init(); */
#endif
	gtk_init( &argc, &argv );
	gtk_init_bugfixes();
#if GTK_MAJOR_VERSION == 2
	{
		char *theme = inifile_get(DEFAULT_THEME_INI, "");
		if (theme[0]) gtk_rc_parse(theme);
	}
#endif

#ifdef U_NLS
#if GTK_MAJOR_VERSION == 2
	/* !!! GTK+2 starts acting up if this is before gtk_init() - WJ */
	setup_language();
#endif
	bindtextdomain("mtpaint", MT_LANG_DEST);
	textdomain("mtpaint");
#if GTK_MAJOR_VERSION == 2
	bind_textdomain_codeset("mtpaint", "UTF-8");
#endif
#endif

	file_arg_start = 1;
	if (argc > 1)		// Argument received, so assume user is trying to load a file
	{
		if ( strcmp(argv[1], "-g") == 0 )	// Loading GIF animation frames
		{
			file_arg_start+=2;
			sscanf(argv[2], "%i", &preserved_gif_delay);
		}
		if ( strcmp(argv[1], "-v") == 0 )	// Viewer mode
		{
			file_arg_start++;
			viewer_mode = TRUE;
		}
		if ( strcmp(argv[1], "-s") == 0 )	// Screenshot
		{
			file_arg_start++;
			get_screenshot = TRUE;
		}
		if ( strstr(argv[0], "mtv") != NULL ) viewer_mode = TRUE;
	}

	/* Something else got passed in */
	l = argc - file_arg_start;
	while (l)
	{
		/* First, process wildcarded args */
		memset(&globdata, 0, sizeof(globdata));
/* !!! I avoid GLOB_DOOFFS here, because glibc before version 2.2 mishandled it,
 * and quite a few copycats had cloned those buggy versions, some libc
 * implementors among them. So it is possible to encounter a broken function
 * in the wild, and playing it safe doesn't cost all that much - WJ */
		for (i = file_arg_start , j = 0; i < argc; i++)
		{
			if (strcmp(argv[i], "-w")) continue; j++;
			if (++i >= argc) break; j++;
			// Ignore errors - be glad for whatever gets returned
			glob(argv[i], (j > 2 ? GLOB_APPEND : 0), NULL, &globdata);
		}
		files_passed = l - j + globdata.gl_pathc;

		/* If no wildcarded args */
		file_args = argv + file_arg_start;
		if (!j) break;
		/* If no normal args */
		file_args = globdata.gl_pathv;
		if (l <= j) break;

		/* Allocate space for both kinds of args together */
		file_args = calloc(files_passed + 1, sizeof(char *));
		// !!! Die by SIGSEGV if this allocation fails

		/* Copy normal args if any */
		for (i = file_arg_start , j = 0; i < argc; i++)
		{
			if (!strcmp(argv[i], "-w")) i++; // Skip the pair
			else file_args[j++] = argv[i];
		}

		/* Copy globbed args after them */
		if (globdata.gl_pathc) memcpy(file_args + j, globdata.gl_pathv,
			globdata.gl_pathc * sizeof(char *));
		break;
	}

	string_init();				// Translate static strings
	var_init();				// Load INI variables
	mem_init();				// Set up memory & back end
	layers_init();
	init_cols();

	if ( get_screenshot )
	{
		if (load_image(NULL, FS_PNG_LOAD, FT_PIXMAP) == 1)
			new_empty = FALSE;	// Successfully grabbed so no new empty
		else get_screenshot = FALSE;	// Screenshot failed
	}
	main_init();					// Create main window

	if ( get_screenshot )
	{
		do_new_chores(FALSE);
		notify_changed();
	}
	else
	{
		if ((files_passed > 0) && !do_a_load(file_args[0], FALSE))
			new_empty = FALSE;
	}

	if ( new_empty )		// If no file was loaded, start with a blank canvas
	{
		create_default_image();
	}

	update_menus();

	THREADS_ENTER();
	gtk_main();
	THREADS_LEAVE();

	spawn_quit();
	inifile_quit();

	return 0;
}
示例#9
0
void mods_init()
{
	//if(!data) /* only load once */
		//data = load_data_from_memory(internal_data);
		
	for(int i = 0; i < NUM_NETOBJTYPES; i++)
		snap_set_staticsize(i, netobj_get_size(i));

	layers_init();
	col_init();

	// reset everything here
	//world = new GAMEWORLD;
	//players = new PLAYER[MAX_CLIENTS];

	// select gametype
	if(strcmp(config.sv_gametype, "mod") == 0)
		game.controller = new GAMECONTROLLER_MOD;
	else if(strcmp(config.sv_gametype, "ctf") == 0)
		game.controller = new GAMECONTROLLER_CTF;
	else if(strcmp(config.sv_gametype, "tdm") == 0)
		game.controller = new GAMECONTROLLER_TDM;
	else if(strcmp(config.sv_gametype, "race") == 0)
		game.controller = new GAMECONTROLLER_RACE;
	else
		game.controller = new GAMECONTROLLER_DM;

	// setup core world
	//for(int i = 0; i < MAX_CLIENTS; i++)
	//	game.players[i].core.world = &game.world.core;

	// create all entities from the game layer
	MAPITEM_LAYER_TILEMAP *tmap = layers_game_layer();
	TILE *tiles = (TILE *)map_get_data(tmap->data);
	
	/*
	num_spawn_points[0] = 0;
	num_spawn_points[1] = 0;
	num_spawn_points[2] = 0;
	*/
	
	for(int y = 0; y < tmap->height; y++)
	{
		for(int x = 0; x < tmap->width; x++)
		{
			int index = tiles[y*tmap->width+x].index;
			
			if(index >= ENTITY_OFFSET)
			{
				game.controller->on_entity(index-ENTITY_OFFSET, x, y);
			}
		}
	}

	//game.world.insert_entity(game.controller);

#ifdef CONF_DEBUG
	if(config.dbg_dummies)
	{
		for(int i = 0; i < config.dbg_dummies ; i++)
		{
			mods_connected(MAX_CLIENTS-i-1);
			mods_client_enter(MAX_CLIENTS-i-1);
			if(game.controller->is_teamplay())
				game.players[MAX_CLIENTS-i-1]->team = i&1;
		}
	}
#endif
}