Example #1
0
void draw_town_boat(location center) {
	location where_draw;
	rectangle source_rect;
	short i;
	sf::Texture& vehicle_gworld = *ResMgr::get<ImageRsrc>("vehicle");
	
	for(i = 0; i < univ.party.boats.size(); i++)
		if((univ.party.boats[i].which_town == univ.town.num) &&
			((point_onscreen(center, univ.party.boats[i].loc)) &&
			 (can_see_light(center, univ.party.boats[i].loc,sight_obscurity) < 5) && (univ.party.in_boat != i)
			 && (pt_in_light(center,univ.party.boats[i].loc)))) {
				where_draw.x = univ.party.boats[i].loc.x - center.x + 4;
				where_draw.y = univ.party.boats[i].loc.y - center.y + 4;
				Draw_Some_Item(vehicle_gworld, calc_rect(1,0), terrain_screen_gworld, where_draw, 1, 0);
			}
	for(i = 0; i < univ.party.horses.size(); i++)
		if((univ.party.horses[i].which_town == univ.town.num) &&
			((point_onscreen(center, univ.party.horses[i].loc)) &&
			 (can_see_light(center, univ.party.horses[i].loc,sight_obscurity) < 5) && (univ.party.in_horse != i)
			 && (pt_in_light(center,univ.party.horses[i].loc)))) {
				where_draw.x = univ.party.horses[i].loc.x - center.x + 4;
				where_draw.y = univ.party.horses[i].loc.y - center.y + 4;
				Draw_Some_Item(vehicle_gworld, calc_rect(1,1), terrain_screen_gworld, where_draw, 1, 0);
			}
}
Example #2
0
void draw_one_terrain_spot (short i,short j,unsigned char terrain_to_draw)
{
	location where_draw;
	RECT source_rect;
	short picture_wanted;
	GWorldPtr source_gworld;
	short k;

	picture_wanted = scenario.ter_types[terrain_to_draw].picture;

	where_draw.x = (char) i;
	where_draw.y = (char) j;

	if ((picture_wanted >= 2000) && (spec_scen_g != NULL)) {
        source_gworld = spec_scen_g;
        source_rect = get_custom_rect(picture_wanted % 2000);
		source_rect.left += 28 * ((anim_ticks / 20) % 4);
		source_rect.right = source_rect.left + 28;
    }
    else if ((picture_wanted >= 1000) && (spec_scen_g != NULL)) {
		source_gworld = spec_scen_g;
		source_rect = get_custom_rect(picture_wanted % 1000);
		}
	else if (picture_wanted >= 400)	{
			source_gworld = anim_gworld;
			picture_wanted -= 400;
			source_rect.left = 112 * (picture_wanted / 5)+ 28 * ((anim_ticks / 20) % 4);
			source_rect.right = source_rect.left + 28;
			source_rect.top = 36 * (picture_wanted % 5);
			source_rect.bottom = source_rect.top + 36;
		}
		else {
			source_rect = get_template_rect(terrain_to_draw);
			source_gworld = terrain_gworld[picture_wanted / 50];
		}

	Draw_Some_Item(source_gworld, source_rect, ter_draw_gworld, where_draw, 0, 0);

    if(editing_town)
        for(k=0;k<30;k++){
            if ((cur_town == scenario.scen_horses[k].which_town) &&
							 (scenario.scen_horses[k].horse_loc.x == cen_x + i - 4) &&
							 (scenario.scen_horses[k].horse_loc.y == cen_y + j - 4)) {
							 				source_rect = horse_button_from;
											Draw_Some_Item(mixed_gworld,source_rect,ter_draw_gworld,where_draw,1,0);
                                        }
            if ((scenario.scen_boats[k].which_town == cur_town) &&
							 (scenario.scen_boats[k].boat_loc.x == cen_x + i - 4) &&
							 (scenario.scen_boats[k].boat_loc.y == cen_y + j - 4)) {
							 				source_rect = boat_button_from;
                                            Draw_Some_Item(mixed_gworld,source_rect,ter_draw_gworld,where_draw,1,0);
                                    }
                    }

}
Example #3
0
void draw_monsts(HDC hdc)
{
	short i,k,width,height,m_start_pic;
	GWorldPtr from_gworld;
	RECT source_rect;
	location where_draw,store_loc;

		for (i = 0; i < 60; i++)
		if (t_d.creatures[i].number != 0) {
				where_draw.x = t_d.creatures[i].start_loc.x - cen_x + 4;
				where_draw.y = t_d.creatures[i].start_loc.y - cen_y + 4;
				width = scenario.scen_monsters[t_d.creatures[i].number].x_width;
				height = scenario.scen_monsters[t_d.creatures[i].number].y_width;

				for (k = 0; k < width * height; k++) {
					store_loc = where_draw;
					if ((where_draw.x == minmax(0,8,where_draw.x)) &&
					(where_draw.y == minmax(0,8,where_draw.y)) &&
						(scenario.scen_monsters[t_d.creatures[i].number].picture_num >= 1000)) {
						source_rect = get_custom_rect((scenario.scen_monsters[t_d.creatures[i].number].picture_num + k) % 1000);
						store_loc.x += k % width;
						store_loc.y += k / width;
						Draw_Some_Item(spec_scen_g, source_rect, ter_draw_gworld, store_loc, 1, 0);
						}
						else if (scenario.scen_monsters[t_d.creatures[i].number].picture_num < 1000) {
							m_start_pic = m_pic_index[scenario.scen_monsters[t_d.creatures[i].number].picture_num] + k;
							from_gworld = monst_gworld[m_start_pic / 20];
							m_start_pic = m_start_pic % 20;
							source_rect = calc_rect(2 * (m_start_pic / 10), m_start_pic % 10);
							store_loc.x += k % width;
							store_loc.y += k / width;
							Draw_Some_Item(from_gworld, source_rect, ter_draw_gworld, store_loc, 1, 0);
							}
					}
			}
}
Example #4
0
void draw_party_symbol(location center) {
	rectangle source_rect;
	location target(4,4);
	short i = 0;
	
	if(!can_draw_pcs)
		return;
	if(!univ.party.is_alive())
		return;
	if((is_town()) && (univ.town.p_loc.x > 70))
		return;
	if(overall_mode == MODE_LOOK_TOWN || cartoon_happening) {
		target.x += univ.town.p_loc.x - center.x;
		target.y += univ.town.p_loc.y - center.y;
	}
	
	if((univ.party.in_boat < 0) && (univ.party.in_horse < 0)) {
		i = first_active_pc();
		sf::Texture* from_gw;
		pic_num_t pic = univ.party[i].which_graphic;
		if(pic >= 1000) {
			bool isParty = pic >= 10000;
			pic_num_t need_pic = pic % 1000;
			if(univ.party.direction >= 4)
				need_pic++;
			graf_pos_ref(from_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty);
		} else if(pic >= 100) {
			// Note that we assume it's a 1x1 graphic.
			// PCs can't be larger than that, but we leave it to the scenario designer to avoid assigning larger graphics.
			pic_num_t need_pic = pic - 100;
			int mode = 0;
			if(univ.party.direction >= 4)
				mode++;
			source_rect = get_monster_template_rect(need_pic, mode, 0);
			int which_sheet = m_pic_index[need_pic].i / 20;
			from_gw = ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)).get();
		} else {
			source_rect = calc_rect(2 * (pic / 8), pic % 8);
			if(univ.party.direction >= 4)
				source_rect.offset(28,0);
			from_gw = ResMgr::get<ImageRsrc>("pcs").get();
		}
		ter_num_t ter = 0;
		if(is_out())
			ter = univ.out[univ.party.p_loc.x][univ.party.p_loc.y];
		else if(is_town() || is_combat())
			ter = univ.town->terrain(univ.town.p_loc.x,univ.town.p_loc.y);
		// now wedge in bed graphic
		if(is_town() && univ.scenario.ter_types[ter].special == eTerSpec::BED)
			draw_one_terrain_spot((short) target.x,(short) target.y,10000 + univ.scenario.ter_types[ter].flag1);
		else Draw_Some_Item(*from_gw, source_rect, terrain_screen_gworld, target, 1, 0);
	}
	else if(univ.party.in_boat >= 0) {
		if(univ.party.direction == DIR_N) i = 2;
		else if(univ.party.direction == DIR_S) i = 3;
		else i = univ.party.direction > DIR_S;
		Draw_Some_Item(*ResMgr::get<ImageRsrc>("vehicle"), calc_rect(i,0), terrain_screen_gworld, target, 1, 0);
	}else {
		i = univ.party.direction > 3;
		Draw_Some_Item(*ResMgr::get<ImageRsrc>("vehicle"), calc_rect(i + 2, 1), terrain_screen_gworld, target, 1, 0);
	}
}
Example #5
0
void draw_fields(location where){
	if(!point_onscreen(center,where)) return;
	if(party_can_see(where) >= 6) return;
	location where_draw(4 + where.x - center.x, 4 + where.y - center.y);
	sf::Texture& fields_gworld = *ResMgr::get<ImageRsrc>("fields");
	if(is_out()){
		if(univ.out.is_spot(where.x,where.y))
			Draw_Some_Item(fields_gworld,calc_rect(4,0),terrain_screen_gworld,where_draw,1,0);
		return;
	}
	if(univ.town.is_force_wall(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(0,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_fire_wall(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(1,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_antimagic(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(2,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_scloud(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(3,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_ice_wall(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(4,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_blade_wall(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(5,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_sleep_cloud(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(6,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_block(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(3,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_spot(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(4,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_web(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(5,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_crate(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(6,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_barrel(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(7,0),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_fire_barr(where.x,where.y) || univ.town.is_force_barr(where.x,where.y))
		Draw_Some_Item(*ResMgr::get<ImageRsrc>("teranim"),calc_rect(8+(anim_ticks%4),4),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_quickfire(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(7,1),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_sm_blood(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(0,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_med_blood(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(1,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_lg_blood(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(2,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_sm_slime(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(3,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_lg_slime(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(4,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_ash(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(5,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_bones(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(6,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_rubble(where.x,where.y))
		Draw_Some_Item(fields_gworld,calc_rect(7,3),terrain_screen_gworld,where_draw,1,0);
	if(univ.town.is_force_cage(where.x,where.y)) {
		Draw_Some_Item(fields_gworld,calc_rect(1,0),terrain_screen_gworld,where_draw,1,0);
		forcecage_locs.push_back(where_draw);
	}
}
Example #6
0
//short mode; // 0 - put pcs in gworld  1 - only rectangle around active pc
void draw_pcs(location center,short mode) {
	rectangle source_rect,active_pc_rect;
	location where_draw;
	
	if(!univ.party.is_alive())
		return;
	if(!can_draw_pcs)
		return;
	
	// Draw current pc on top
	int pcs[6] = {0,1,2,3,4,5};
	if(current_pc < 6)
		std::swap(pcs[5], pcs[current_pc]);
	
	for(int j = 0; j < 6; j++) {
		int i = pcs[j];
		if(univ.party[i].main_status == eMainStatus::ALIVE)
			if(point_onscreen(center, univ.party[i].combat_pos) &&
			   (cartoon_happening || party_can_see(univ.party[i].combat_pos) < 6)){
				where_draw.x = univ.party[i].combat_pos.x - center.x + 4;
				where_draw.y = univ.party[i].combat_pos.y - center.y + 4;
				sf::Texture* from_gw;
				pic_num_t pic = univ.party[i].which_graphic;
				if(pic >= 1000) {
					bool isParty = pic >= 10000;
					pic_num_t need_pic = pic % 1000;
					if(univ.party[i].direction >= 4)
						need_pic++;
					if(combat_posing_monster == i)
						need_pic += 2;
					graf_pos_ref(from_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty);
				} else if(pic >= 100) {
					// Note that we assume it's a 1x1 graphic.
					// PCs can't be larger than that, but we leave it to the scenario designer to avoid assigning larger graphics.
					pic_num_t need_pic = pic - 100;
					int mode = 0;
					if(univ.party[current_pc].direction >= 4)
						mode++;
					if(combat_posing_monster == i)
						mode += 10;
					source_rect = get_monster_template_rect(need_pic, mode, 0);
					int which_sheet = m_pic_index[need_pic].i / 20;
					from_gw = ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)).get();
				} else {
					source_rect = calc_rect(2 * (pic / 8), pic % 8);
					if(univ.party[i].direction >= 4)
						source_rect.offset(28,0);
					if(combat_posing_monster == i)
						source_rect.offset(0,288);
					from_gw = ResMgr::get<ImageRsrc>("pcs").get();
				}
				
				if(mode == 0) {
					Draw_Some_Item(*from_gw, source_rect, terrain_screen_gworld, where_draw, 1, 0);
				}
				
				if((current_pc == i) && (mode == 1) && !monsters_going) {
					active_pc_rect.top = 18 + where_draw.y * 36;
					active_pc_rect.left = 18 + where_draw.x * 28;
					active_pc_rect.bottom = 54 + where_draw.y * 36;
					active_pc_rect.right = 46 + where_draw.x * 28;
					active_pc_rect.offset(ul);
					
					frame_roundrect(mainPtr, active_pc_rect, 8, sf::Color::Magenta);
				}
			}
	}
}
Example #7
0
void draw_monsters() {
	short i,j = 0,k;
	short width,height;
	rectangle source_rect,to_rect;
	location where_draw,store_loc;
	ter_num_t ter;
	rectangle monst_rects[4][4] = {
		{{0,0,36,28}},
		{{0,7,18,21},{18,7,36,21}},
		{{9,0,27,14},{9,14,27,28}},
		{{0,0,18,14},{0,14,18,28},{18,0,36,14},{18,14,36,28}}
	};
	
	if(is_out())
		for(i = 0; i < 10; i++)
			if(univ.party.out_c[i].exists) {
				if((point_onscreen(univ.party.p_loc, univ.party.out_c[i].m_loc)) &&
					(can_see_light(univ.party.p_loc, univ.party.out_c[i].m_loc,sight_obscurity) < 5)) {
					where_draw.x = univ.party.out_c[i].m_loc.x - univ.party.p_loc.x + 4;
					where_draw.y = univ.party.out_c[i].m_loc.y - univ.party.p_loc.y + 4;
					
					for(j = 0; univ.party.out_c[i].what_monst.monst[j] == 0 && j < 7; j++);
					
					short picture_wanted;
					if(j == 7) univ.party.out_c[i].exists = false; // begin watch out
					else {
						picture_wanted = get_monst_picnum(univ.party.out_c[i].what_monst.monst[j]);
					} // end watch out
					
					if(univ.party.out_c[i].exists) {
						get_monst_dims(univ.party.out_c[i].what_monst.monst[j],&width,&height);
						if(picture_wanted >= 1000) {
							for(k = 0; k < width * height; k++) {
								sf::Texture* src_gw;
								graf_pos_ref(src_gw, source_rect) = spec_scen_g.find_graphic(picture_wanted % 1000 +
																							 ((univ.party.out_c[i].direction < 4) ? 0 : (width * height)) + k);
								to_rect = monst_rects[(width - 1) * 2 + height - 1][k];
								to_rect.offset(13 + 28 * where_draw.x,13 + 36 * where_draw.y);
								rect_draw_some_item(*src_gw, source_rect, terrain_screen_gworld,to_rect, sf::BlendAlpha);
							}
						}
						if(picture_wanted < 1000) {
							for(k = 0; k < width * height; k++) {
								source_rect = get_monster_template_rect(picture_wanted,(univ.party.out_c[i].direction < 4) ? 0 : 1,k);
								to_rect = monst_rects[(width - 1) * 2 + height - 1][k];
								to_rect.offset(13 + 28 * where_draw.x,13 + 36 * where_draw.y);
								int which_sheet = m_pic_index[picture_wanted].i / 20;
								sf::Texture& monst_gworld = *ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet));
								rect_draw_some_item(monst_gworld, source_rect, terrain_screen_gworld,to_rect, sf::BlendAlpha);
							}
						}
					}
				}
			}
	if(is_town() || is_combat()) {
		for(i = 0; i < univ.town.monst.size(); i++)
			if(univ.town.monst[i].active != 0 && !univ.town.monst[i].invisible && univ.town.monst[i].status[eStatus::INVISIBLE] <= 0)
				if(point_onscreen(center,univ.town.monst[i].cur_loc) && party_can_see_monst(i)) {
					where_draw.x = univ.town.monst[i].cur_loc.x - center.x + 4;
					where_draw.y = univ.town.monst[i].cur_loc.y - center.y + 4;
					get_monst_dims(univ.town.monst[i].number,&width,&height);
					
					for(k = 0; k < width * height; k++) {
						store_loc = where_draw;
						store_loc.x += k % width;
						store_loc.y += k / width;
						ter = univ.town->terrain(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y);
						// in bed?
						if(store_loc.x >= 0 && store_loc.x < 9 && store_loc.y >= 0 && store_loc.y < 9 &&
						   (univ.scenario.ter_types[ter].special == eTerSpec::BED) && isHumanoid(univ.town.monst[i].m_type)
						   && (univ.town.monst[i].active == 1 || univ.town.monst[i].target == 6) &&
						   width == 1 && height == 1)
							draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + univ.scenario.ter_types[ter].flag1);
						else if(univ.town.monst[i].picture_num >= 1000) {
							bool isParty = univ.town.monst[i].picture_num >= 10000;
							sf::Texture* src_gw;
							pic_num_t need_pic = (univ.town.monst[i].picture_num % 1000) + k;
							if(univ.town.monst[i].direction >= 4) need_pic += width * height;
							if(combat_posing_monster == i + 100) need_pic += (2 * width * height);
							graf_pos_ref(src_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty);
							Draw_Some_Item(*src_gw, source_rect, terrain_screen_gworld, store_loc, 1, 0);
						} else {
							pic_num_t this_monst = univ.town.monst[i].picture_num;
							int pic_mode = (univ.town.monst[i].direction) < 4 ? 0 : 1;
							pic_mode += (combat_posing_monster == i + 100) ? 10 : 0;
							source_rect = get_monster_template_rect(this_monst, pic_mode, k);
							int which_sheet = m_pic_index[this_monst].i / 20;
							sf::Texture& monst_gworld = *ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet));
							Draw_Some_Item(monst_gworld, source_rect, terrain_screen_gworld, store_loc, 1, 0);
						}
					}
				}
	}
}
Example #8
0
void draw_terrain()
{
	short q,r,x,i,small_i;
	location which_pt,where_draw;
	RECT draw_rect,clipping_rect = {8,8,260,332};
	unsigned char t_to_draw;
	RECT tiny_to,tiny_to_base = {29,37,36,44},tiny_from,from_rect,to_rect;
	HBITMAP store_bmp;
	COLORREF gray = RGB(128,128,128);
	COLORREF red = RGB(255,0,0);
	COLORREF white = RGB(255,255,255);

	HBRUSH new_brush;
	HDC hdc;
	HPEN old_pen;

	if (overall_mode >= 60)
		return;

	if (cur_viewing_mode == 0) {
		paint_pattern(ter_draw_gworld,0,terrain_rect,1);
		}
	hdc = CreateCompatibleDC(main_dc);

	SetBkMode(hdc,TRANSPARENT);
	SelectObject(hdc,small_bold_font);
	store_bmp = (HBITMAP)SelectObject(hdc,ter_draw_gworld);


	new_brush = CreateSolidBrush(gray);
	FrameRect(hdc,&terrain_rect,new_brush);
	DeleteObject(new_brush);
	old_pen = (HPEN)SelectObject(hdc,GetStockObject(NULL_PEN));
	SelectObject(hdc,store_bmp);

	if (cur_viewing_mode == 0) {
	for (q = 0; q < 9; q++)
		for (r = 0; r < 9; r++)
			{
			where_draw.x = q; where_draw.y = r;
			if (editing_town == TRUE) {
				t_to_draw = t_d.terrain[cen_x + q - 4][cen_y + r - 4];
				}
				else {
					if (cen_x + q - 4 == -1)
						t_to_draw = borders[3][cen_y + r - 4];
					else if (cen_x + q - 4 == 48)
						t_to_draw = borders[1][cen_y + r - 4];
					else if (cen_y + r - 4 == -1)
						t_to_draw = borders[0][cen_x + q - 4];
					else if (cen_y + r - 4 == 48)
						t_to_draw = borders[2][cen_x + q - 4];
					else t_to_draw = current_terrain.terrain[cen_x + q - 4][cen_y + r - 4];
					}
			draw_one_terrain_spot(q,r,t_to_draw);
			which_pt.x = cen_x + q - 4;
			which_pt.y =cen_y + r - 4;

			tiny_to = tiny_to_base;
			OffsetRect(&tiny_to,28 * q, 36 * r);

			// draw start icon, if starting point
			if ((editing_town == TRUE) &&
				(cur_town == scenario.which_town_start) && (scenario.where_start.x == cen_x + q - 4)
				&& (scenario.where_start.y == cen_y + r - 4)) {
				from_rect = start_button_from;
				to_rect = tiny_to;
				to_rect.left -= 14;
				rect_draw_some_item(editor_mixed,from_rect,ter_draw_gworld,to_rect,0,0);
				OffsetRect(&tiny_to,0,-7);
				}
			if ((editing_town == FALSE)
				&& (scenario.out_sec_start.x == cur_out.x)
				&& (scenario.out_sec_start.y == cur_out.y)
				&& (scenario.out_start.x == cen_x + q - 4)
				&& (scenario.out_start.y == cen_y + r - 4)) {
				from_rect = start_button_from;
				to_rect = tiny_to;
				to_rect.left -= 14;
				rect_draw_some_item(editor_mixed,from_rect,ter_draw_gworld,to_rect,0,0);
				OffsetRect(&tiny_to,0,-7);
				}
			small_i = small_icons[scenario.ter_types[t_to_draw].special];
			if ((small_i == 30) && (scenario.ter_types[t_to_draw].flag2 >= 5))
				small_i = 31;
			if ((small_i == 31) && (scenario.ter_types[t_to_draw].flag2 == 10))
				small_i = 32;
			tiny_from = base_small_button_from;
			OffsetRect(&tiny_from,7 * (small_i % 10),7 * (small_i / 10));
			if (small_i > 0) {
				rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
				OffsetRect(&tiny_to,0,-7);
				}

				if (is_special(cen_x + q - 4,cen_y + r - 4) == TRUE) {
					tiny_from = base_small_button_from;
					OffsetRect(&tiny_from,7 * (7),7 * (0));
					rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
					OffsetRect(&tiny_to,0,-7);
					}
				if ((t_to_draw == 7) || (t_to_draw == 10) || (t_to_draw == 13) || (t_to_draw == 16)) {
					tiny_from = base_small_button_from;
					OffsetRect(&tiny_from,7 * (3),7 * (2));
					rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
					OffsetRect(&tiny_to,0,-7);
					}
				if (editing_town == FALSE) {
					for (i = 0; i < 4; i++)
						if ((cen_x + q - 4 == current_terrain.wandering_locs[i].x) &&
							(cen_y + r - 4 == current_terrain.wandering_locs[i].y)) {
							tiny_from = base_small_button_from;
							OffsetRect(&tiny_from,7 * (2),7 * (1));
							rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
							OffsetRect(&tiny_to,0,-7);
							i = 4;
							}

					}

				if (editing_town == TRUE) {
					for (i = 0; i < 4; i++)
						if ((cen_x + q - 4 == town.start_locs[i].x) &&
							(cen_y + r - 4 == town.start_locs[i].y)) {
							tiny_from = base_small_button_from;
							OffsetRect(&tiny_from,7 * (6 + i),7 * (1));
							rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
							OffsetRect(&tiny_to,0,-7);
							}
					for (i = 0; i < 4; i++)
						if ((cen_x + q - 4 == town.wandering_locs[i].x) &&
							(cen_y + r - 4 == town.wandering_locs[i].y)) {
							tiny_from = base_small_button_from;
							OffsetRect(&tiny_from,7 * (2),7 * (1));
							rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0);
							OffsetRect(&tiny_to,0,-7);
							i = 4;
							}
					if (is_web(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(5,0);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_crate(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(6,0);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_barrel(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(7,0);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_fire_barrier(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(0,2);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_quickfire(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(7,1);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					if (is_force_barrier(cen_x + q - 4,cen_y + r - 4) == TRUE) {
						from_rect = calc_rect(2,2);
						Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
						}
					for (i = 0; i < 8; i++)
						if (is_sfx(cen_x + q - 4,cen_y + r - 4,i)) {
							from_rect = calc_rect(i,3);
							Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0);
							}
					for (x = 0; x < 64; x++)
						if ((cen_x + q - 4 == town.preset_items[x].item_loc.x) &&
						 (cen_y + r - 4 == town.preset_items[x].item_loc.y) && (town.preset_items[x].item_code >= 0)) {
						 }
					for (x = 0; x < 60; x++)
						if ((cen_x + q - 4 == t_d.creatures[x].start_loc.x) &&
						 (cen_y + r - 4 == t_d.creatures[x].start_loc.y) && (t_d.creatures[x].number != 0)) {
						 }

					 }
				}
	if (editing_town == TRUE) {
		draw_monsts(hdc);
		draw_items(hdc);
		}

	store_bmp = (HBITMAP)SelectObject(hdc,ter_draw_gworld);
	ClipRect(hdc,&clipping_rect);

	if (editing_town == TRUE) {
		// draw info rects
		for (i = 0; i < 16; i++)
			if (t_d.room_rect[i].left > -1) {
				draw_rect.left = 22 + 28 * (t_d.room_rect[i].left - cen_x + 4);
				draw_rect.right = 22 + 28 * (t_d.room_rect[i].right - cen_x + 4);
				draw_rect.top = 24 + 36 * (t_d.room_rect[i].top - cen_y + 4);
				draw_rect.bottom = 24 + 36 * (t_d.room_rect[i].bottom - cen_y + 4);

				//c = GetNearestPaletteIndex(hpal,red);
				new_brush = CreateSolidBrush(red);
				FrameRect(hdc,&draw_rect,new_brush);
				DeleteObject(new_brush);
				}
		// draw border rect
			draw_rect.left = 21 + 28 * (town.in_town_rect.left - cen_x + 4);
			draw_rect.right = 21 + 28 * (town.in_town_rect.right - cen_x + 4);
			draw_rect.top = 25 + 36 * (town.in_town_rect.top - cen_y + 4);
			draw_rect.bottom = 25 + 36 * (town.in_town_rect.bottom - cen_y + 4);

//			c = GetNearestPaletteIndex(hpal,white);
			new_brush = CreateSolidBrush(white);
			FrameRect(hdc,&draw_rect,new_brush);
			DeleteObject(new_brush);
		}
	if (editing_town == FALSE) {
		// draw info rects
		for (i = 0; i < 8; i++)
			if (current_terrain.info_rect[i].left > -1) {
				draw_rect.left = 22 + 28 * (current_terrain.info_rect[i].left - cen_x + 4);
				draw_rect.right = 22 + 28 * (current_terrain.info_rect[i].right - cen_x + 4);
				draw_rect.top = 24 + 36 * (current_terrain.info_rect[i].top - cen_y + 4);
				draw_rect.bottom = 24 + 36 * (current_terrain.info_rect[i].bottom - cen_y + 4);
				//c = GetNearestPaletteIndex(hpal,red);
				new_brush = CreateSolidBrush(red);

				FrameRect(hdc,&draw_rect,new_brush);
				DeleteObject(new_brush);
				}
		}
	undo_clip(hdc);
	SelectObject(hdc,store_bmp);

	small_any_drawn = FALSE;
	}

	if (cur_viewing_mode == 1) {
		if (small_any_drawn == FALSE) {
			InsetRect(&terrain_rect,1,1);
			paint_pattern(ter_draw_gworld,0,terrain_rect,1);
			InsetRect(&terrain_rect,-1,-1);
			//FrameRect(&terrain_rect);
			}
		for (q = 0; q < ((editing_town == TRUE) ? max_dim[town_type] : 48); q++)
			for (r = 0; r < ((editing_town == TRUE) ? max_dim[town_type] : 48); r++) {
				t_to_draw = (editing_town == TRUE) ? t_d.terrain[q][r] :
					current_terrain.terrain[q][r];
				if ((small_what_drawn[q][r] != t_to_draw) || (small_any_drawn == FALSE)) {
					draw_one_tiny_terrain_spot(q,r,t_to_draw,hdc);
					small_what_drawn[q][r] = t_to_draw;
					}
			}
		small_any_drawn = TRUE;
		}

	SelectObject(hdc,old_pen);
	DeleteObject(hdc);
	//draw_cur_string();
	place_location();

	rect_draw_some_item(ter_draw_gworld,terrain_rect,ter_draw_gworld,world_screen,0,1);
}