Example #1
0
void map_convert_liquid(map_type *map,portal_type *portal,segment_type *seg)
{
	int				liq_idx,sz;
	map_liquid_type	*liquid;

	liq_idx=map_liquid_add(map);
	if (liq_idx==-1) return;

	liquid=&map->liquid.liquids[liq_idx];

	liquid->y=(seg->data.liquid.y+1)*map_enlarge;
	liquid->lft=(seg->data.liquid.lft*map_enlarge)+portal->x;
	liquid->rgt=(seg->data.liquid.rgt*map_enlarge)+portal->x;
	liquid->top=(seg->data.liquid.top*map_enlarge)+portal->z;
	liquid->bot=(seg->data.liquid.bot*map_enlarge)+portal->z;
	
	liquid->depth=5000;

	liquid->alpha=seg->alpha;
	liquid->speed_alter=seg->data.liquid.speed_alter;
	liquid->tint_alpha=seg->data.liquid.tint_alpha;
	
	liquid->x_txtfact=seg->x_txtfact;
	liquid->y_txtfact=seg->y_txtfact;
	liquid->x_txtoff=seg->x_txtoff;
	liquid->y_txtoff=seg->y_txtoff;
	liquid->x_shift=seg->x_shift;
	liquid->y_shift=seg->y_shift;
	
	liquid->txt_idx=seg->fill;
	liquid->group_idx=seg->group_idx;

	memmove(&liquid->col,&seg->data.liquid.col,sizeof(d3col));

	liquid->harm.in_harm=seg->data.liquid.harm;
	liquid->harm.drown_harm=seg->data.liquid.drown_harm;
	liquid->harm.drown_tick=seg->data.liquid.drown_tick;

	sz=liquid->rgt-liquid->lft;
	if ((liquid->bot-liquid->top)>sz) sz=liquid->bot-liquid->top;
	liquid->tide.division=sz/seg->data.liquid.wavesize;
	liquid->tide.rate=seg->data.liquid.tiderate;
	liquid->tide.high=seg->data.liquid.tidesize;
	liquid->tide.direction=seg->data.liquid.tidedirection;
}
Example #2
0
File: map_undo.c Project: rzel/dim3
void map_undo_pull(void)
{
	int				n,idx,nmesh,old_nmesh,
					nliquid,old_nliquid;
	map_undo_type	*undo;
	map_mesh_type	*old_meshes,*org_mesh,*mesh;
	map_liquid_type	*old_liquids,*org_liq,*liq;
	
	if (map_undo_level==0) return;
	
	undo=&map_undos[0];

		// free VBOs

	view_vbo_map_free();
	
		// backup old meshes
		// and clear mesh list
		
	old_nmesh=map.mesh.nmesh;
	old_meshes=map.mesh.meshes;
	
	free(map.mesh.meshes);
	
	map.mesh.nmesh=0;
	map.mesh.meshes=NULL;
	
		// restore all meshes
		
	nmesh=undo->mesh.count;
		
	if (nmesh!=0) {
	
		org_mesh=(map_mesh_type*)undo->mesh.data;
		
		for (n=0;n!=nmesh;n++) {
		
				// new mesh
				// if it fails, put everything back
				// and return
				
			idx=map_mesh_add(&map);
			if (idx==-1) {
				free(map.mesh.meshes);
				
				map.mesh.nmesh=old_nmesh;
				map.mesh.meshes=old_meshes;
				return;
			}
			
			mesh=&map.mesh.meshes[idx];
			
				// just copy over from backup mesh
				// and then null out the pointers
				// so close doesn't erase them
				
			if (mesh->vertexes!=NULL) free(mesh->vertexes);
			if (mesh->polys!=NULL) free(mesh->polys);
				
			memmove(mesh,org_mesh,sizeof(map_mesh_type));

			org_mesh->vertexes=NULL;
			org_mesh->polys=NULL;
						
			org_mesh++;
		}
	}
		
	map.mesh.nmesh=nmesh;
	
		// backup old liquids
		// and clear liquid list
		
	old_nliquid=map.liquid.nliquid;
	old_liquids=map.liquid.liquids;
	
	free(map.liquid.liquids);
	
	map.liquid.nliquid=0;
	map.liquid.liquids=NULL;
	
		// restore all meshes
		
	nliquid=undo->liquid.count;
		
	if (nliquid!=0) {
	
		org_liq=(map_liquid_type*)undo->liquid.data;
		
		for (n=0;n!=nliquid;n++) {
		
				// new liquid
				// if it fails, put everything back
				// and return
				
			idx=map_liquid_add(&map);
			if (idx==-1) {
				free(map.liquid.liquids);
				
				map.liquid.nliquid=old_nliquid;
				map.liquid.liquids=old_liquids;
				return;
			}
			
			liq=&map.liquid.liquids[idx];
			memmove(liq,org_liq,sizeof(map_liquid_type));
						
			org_liq++;
		}
	}
		
	map.liquid.nliquid=nliquid;
	
		// restore other chunks
	
	map.nspot=map_undo_pull_chunk(sizeof(spot_type),(unsigned char*)map.spots,&undo->spot);
	map.nscenery=map_undo_pull_chunk(sizeof(map_scenery_type),(unsigned char*)map.sceneries,&undo->scenery);
	map.nnode=map_undo_pull_chunk(sizeof(node_type),(unsigned char*)map.nodes,&undo->node);
	map.nlight=map_undo_pull_chunk(sizeof(map_light_type),(unsigned char*)map.lights,&undo->light);
	map.nsound=map_undo_pull_chunk(sizeof(map_sound_type),(unsigned char*)map.sounds,&undo->sound);
	map.nparticle=map_undo_pull_chunk(sizeof(map_particle_type),(unsigned char*)map.particles,&undo->particle);
	nselect_item=map_undo_pull_chunk(sizeof(select_item_type),(unsigned char*)select_items,&undo->selection);
	
		// clear level
		// and move stack up
		
	map_undo_clear_single(&map_undos[0]);
	
	for (n=1;n!=max_map_undo_level;n++) {
		undo_copy(&map_undos[n-1],&map_undos[n]);
	}
	
	if (max_map_undo_level>1) map_undo_initialize_single(&map_undos[max_map_undo_level-1]);
	
		// move down undo level
		
	map_undo_level--;
	if (map_undo_level==0) os_menu_enable_item(map_menu_edit,1,FALSE);

		// rebuild VBOs

	view_vbo_map_initialize();
	
		// redraw windows
		
	map_palette_reset();

	main_wind_draw();
}