コード例 #1
0
void noegnud_render_map_tile () {
    int x, y;
    int xs,xe,xd;
    int ys,ye,yd;
    GLfloat current_alpha;
    float nx, ny;
    float realangle;
    GLfloat light_position[4];

    ys=0;
    ye=MAX_MAP_Y;
    yd=1;

    xs=0;
    xe=MAX_MAP_X;
    xd=1;

    realangle=(noegnud_options_render_opengl_view_angle_x_current->value+(noegnud_activetileset->iso?0:noegnud_render_bullettime_angle));
    while (realangle>=360) realangle-=360;
    while (realangle<0) realangle+=360;

    if ((realangle>=90)&&(realangle<270)) {
	ys=MAX_MAP_Y-1;
	ye=-1;
	yd=-1;
    }

    if ((realangle<=180)) {
	xs=MAX_MAP_X-1;
	xe=-1;
	xd=-1;
    }

    if (noegnud_render_selection_busy) {
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_LIGHTING);
 	glDisable(GL_DEPTH_TEST);
	glDisable(GL_BLEND);
    }

    if (noegnud_activetileset->iso) {
	glEnable (GL_BLEND);
	glDisable (GL_DEPTH_TEST);
    } else {
	glDisable (GL_BLEND);
	if (noegnud_options_render_features_cardboardcutout->value&&noegnud_activetileset->isalphatileset) {
	    glEnable (GL_DEPTH_TEST);
	} else glDisable (GL_DEPTH_TEST);
    }


    if (noegnud_options_render_opengl_lighting_method->value==NOEGNUD_RENDER_LIGHTING_METHOD_CHEAP) {
	glEnable(GL_LIGHTING);
	glEnable(GL_COLOR_MATERIAL);
	glEnable(GL_LIGHT0);
	if ((noegnud_options_input_mouse_3d_light->value)&&noegnud_render_mouse_map_x!=-1) {
	    glEnable(GL_LIGHT1);
	} else {
	    glDisable(GL_LIGHT1);
	}
    }


    x=noegnud_clip_x;
    y=noegnud_clip_y;
    ny = -(y - (noegnud_render_middle_y));
    nx = x - (noegnud_render_middle_x);

    light_position[0]=noegnud_activetileset->glwidth/2;
    light_position[1]=noegnud_activetileset->glheight*3/2;
    light_position[2]=noegnud_activetileset->glheight;
    light_position[3]=1;

    glTranslatef (
		  (noegnud_activetileset->xdeltax) * (nx) +
		  (noegnud_activetileset->ydeltax) * (ny) +
		  noegnud_render_offset_x, 0,
		  -((noegnud_activetileset->xdeltay) * (nx) +
		    (noegnud_activetileset->ydeltay) * (ny)) +
		  noegnud_render_offset_y);

    glLightfv(GL_LIGHT0,GL_POSITION,light_position);

    if (noegnud_options_input_mouse_3d_light->value) {
	ny = -(noegnud_render_mouse_map_y - (noegnud_render_middle_y));
	nx = (noegnud_render_mouse_map_x-1) - (noegnud_render_middle_x);
	light_position[0]+=(noegnud_activetileset->xdeltax) * (nx) +
			  (noegnud_activetileset->ydeltax) * (ny) +
	    noegnud_render_offset_x;
	light_position[2]+=-((noegnud_activetileset->xdeltay) * (nx) +
			    (noegnud_activetileset->ydeltay) * (ny)) +
	    noegnud_render_offset_y;
	glLightfv(GL_LIGHT1,GL_POSITION,light_position);
    }

    for (y = 0; y < MAX_MAP_Y; y++) {
	ny = -(y - (noegnud_render_middle_y));
	for (x = 0; x < MAX_MAP_X; x++) {
	    nx = x - (noegnud_render_middle_x);

	    glPopMatrix ();
	    glPushMatrix ();
	    glTranslatef (
			  (noegnud_activetileset->xdeltax) * (nx) +
			  (noegnud_activetileset->ydeltax) * (ny) +
			  noegnud_render_offset_x, 0,
			  -((noegnud_activetileset->xdeltay) * (nx) +
			    (noegnud_activetileset->ydeltay) * (ny)) +
			  noegnud_render_offset_y);

	    glLoadName(y*256+x);
	    glBegin(GL_LINES); glEnd();

	    /*
	    if (noegnud_options_input_mouse_3d_light->value&&((noegnud_render_mouse_map_x-1)==x)&&(noegnud_render_mouse_map_y==y)) {
		glLightfv(GL_LIGHT1,GL_POSITION,light_position);
	    }
	    */

	    if (((noegnud_render_mouse_map_x-1)==x)&&(noegnud_render_mouse_map_y==y)) {
		glColor4f(0.25,1.0,0.25,1.0);
	    }
	    else if ((x == noegnud_clip_x) && (y == noegnud_clip_y)) {

		glColor4f(noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,1.0);
	    } else if ((!noegnud_activetileset->isalphatileset)&&iflags.hilite_pet&&(noegnud_map[x][y].glyph_primary!=MAX_GLYPH)&&(noegnud_map[x][y].special_primary & MG_PET)) {
		glColor4f(noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,1.0);
	    } else	glColor4f(1.0,1.0,1.0,1.0);

	    if (noegnud_render_selection_busy) {
		noegnud_render_map_single_selection_tile (noegnud_map[x][y].tile_primary,1);
	    } else
		if (noegnud_options_mode_tileset_caverns->value&&(!noegnud_activetileset->iso)&&noegnud_image_dungeon&&(noegnud_map[x][y].glyph_primary==MAX_GLYPH||(glyph_to_cmap(noegnud_map[x][y].glyph_primary)==S_stone&&levl[x+1][y].lit))) {

		    if (levl[x+1][y].seenv) {
			if (noegnud_options_render_features_cardboardcutout->value &&
			    noegnud_options_mode_tileset_caverns_cutout->value &&
			    noegnud_options_render_features_cardboardcutout_raise_walls->value&&(!IS_ROOM(levl[x+1][y].typ))) {

			    glPushMatrix ();

			    noegnud_render_map_single_tile_raised_walls_texture(
										noegnud_image_dungeon->block[0][0]->image,
										noegnud_options_render_features_cardboardcutout_wall_height->value,
										current_alpha,
										!((y>0)&&noegnud_map[x][y-1].high),
										!((y<MAX_MAP_Y-1)&&noegnud_map[x][y+1].high),
										!((x>0)&&noegnud_map[x-1][y].high),
										!((x<MAX_MAP_X-1)&&noegnud_map[x+1][y].high));


			    glTranslatef(0,noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_wall_height->value,0);

			}
			    if (((noegnud_render_mouse_map_x-1)==x)&&(noegnud_render_mouse_map_y==y)) {
				glColor4f(0.25,1.0,0.25,1.0);
			    } else {
				glColor4f(1.0,1.0,1.0,current_alpha);
			    }
		    } else {
			if (noegnud_options_render_features_cardboardcutout->value &&
			    noegnud_options_mode_tileset_caverns_cutout->value &&
			    noegnud_options_render_features_cardboardcutout_raise_walls->value) {
			    glTranslatef(0,noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_wall_height->value,0);
			}
			if (((noegnud_render_mouse_map_x-1)==x)&&(noegnud_render_mouse_map_y==y)) {
			    glColor4f(0.125,0.5,0.125,1.0);
			} else
			    glColor4f(0.5,0.5,0.5,current_alpha);
		    }
		    if (levl[x+1][y].seenv) {
			if (IS_ROOM(levl[x+1][y].typ)) {
			} else {

			    glBindTexture (GL_TEXTURE_2D, noegnud_image_dungeon->block[0][0]->image);
			    glBegin (GL_QUADS);

			    glNormal3f(0,1,0);
			    glTexCoord2f (noegnud_image_dungeon->block[0][0]->fx1, noegnud_image_dungeon->block[0][0]->fy2);
			    glVertex3f (0, 0, noegnud_activetileset->glheight);

			    glTexCoord2f (noegnud_image_dungeon->block[0][0]->fx2, noegnud_image_dungeon->block[0][0]->fy2);
			    glVertex3f (noegnud_activetileset->glwidth, 0, noegnud_activetileset->glheight);

			    glTexCoord2f (noegnud_image_dungeon->block[0][0]->fx2, noegnud_image_dungeon->block[0][0]->fy1);
			    glVertex3f (noegnud_activetileset->glwidth, 0, 0);

			    glTexCoord2f (noegnud_image_dungeon->block[0][0]->fx1, noegnud_image_dungeon->block[0][0]->fy1);
			    glVertex3f (0, 0, 0);

			    glEnd ();
			}
		    } else {
			if (noegnud_options_mode_tileset_caverns_unexplored->value) {
			    glBindTexture (GL_TEXTURE_2D, noegnud_image_dungeon->block[0][0]->image);
			    glBegin (GL_QUADS);

			    glNormal3f(0,1,0);
			    glTexCoord2f (noegnud_image_dungeon->block[0][0]->fx1, noegnud_image_dungeon->block[0][0]->fy2);
			    glVertex3f (0, 0, noegnud_activetileset->glheight);

			    glTexCoord2f (noegnud_image_dungeon->block[0][0]->fx2, noegnud_image_dungeon->block[0][0]->fy2);
			    glVertex3f (noegnud_activetileset->glwidth, 0, noegnud_activetileset->glheight);

			    glTexCoord2f (noegnud_image_dungeon->block[0][0]->fx2, noegnud_image_dungeon->block[0][0]->fy1);
			    glVertex3f (noegnud_activetileset->glwidth, 0, 0);

			    glTexCoord2f (noegnud_image_dungeon->block[0][0]->fx1, noegnud_image_dungeon->block[0][0]->fy1);
			    glVertex3f (0, 0, 0);

			    glEnd ();
			}
		    }
		    if (levl[x+1][y].seenv) {

			if (noegnud_options_render_features_cardboardcutout->value &&
			    noegnud_options_mode_tileset_caverns_cutout->value &&
			    noegnud_options_render_features_cardboardcutout_raise_walls->value&&(!IS_ROOM(levl[x+1][y].typ))) {
			    glPopMatrix ();
			}
		    }

		}
		if ( ((!noegnud_activetileset->isalphatileset) && (noegnud_map[x][y].glyph_primary!=MAX_GLYPH))) {
		    noegnud_render_map_single_tile (noegnud_map[x][y].tile_primary,1);
		    if ((((x == noegnud_clip_x) && (y == noegnud_clip_y))||(((noegnud_render_mouse_map_x-1)==x)&&(noegnud_render_mouse_map_y==y))) ||
			//				if (((x == noegnud_clip_x) && (y == noegnud_clip_y)) ||
			(noegnud_map[x][y].glyph_primary!=MAX_GLYPH&&iflags.hilite_pet&&(noegnud_map[x][y].special_primary & MG_PET))) {

			glEnable (GL_BLEND);
			noegnud_render_map_tile_highlight_block ();
			glDisable (GL_BLEND);
		    }
		} else if (noegnud_activetileset->isalphatileset) {
		    if ( noegnud_options_render_features_cardboardcutout->value &&
			 noegnud_options_render_features_cardboardcutout_raise_walls->value &&
			 noegnud_map[x][y].low &&
			 (!noegnud_activetileset->iso)) {
			if ((noegnud_map[x][y].glyph_primary!=MAX_GLYPH)||(noegnud_map[x][y].glyph_primary==MAX_GLYPH&&noegnud_options_mode_tileset_caverns_cutout->value))
			glTranslatef(0,-noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_hole_depth->value,0);
		    }
		    if ( noegnud_map[x][y].glyph_back != MAX_GLYPH &&
			 (!noegnud_map[x][y].high)) noegnud_render_map_single_tile (noegnud_map[x][y].tile_back,1);
		    if ((!noegnud_render_selection_busy)&&noegnud_options_render_features_cardboardcutout->value&&noegnud_options_render_features_cardboardcutout_raise_walls->value&&(!noegnud_activetileset->iso)&&noegnud_map[x][y].low) {
			//glTranslatef(0,-noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_hole_depth->value,0);
			noegnud_render_map_single_tile_sunken_walls (
								     noegnud_map[x][y].tile_back,
								     noegnud_options_render_features_cardboardcutout_hole_depth->value,
								     current_alpha,
								     !((y>0)&&noegnud_map[x][y-1].low),
								     !((y<MAX_MAP_Y-1)&&noegnud_map[x][y+1].low),
								     !((x>0)&&noegnud_map[x-1][y].low),
								     !((x<MAX_MAP_X-1)&&noegnud_map[x][y].low));
		    }

		}

	}
    }

    if (noegnud_render_selection_busy) return;

    glEnable (GL_BLEND);
    if (noegnud_activetileset->isalphatileset)
	for (y = 0; y < MAX_MAP_Y; y++)
	    {
		ny = -(y - (noegnud_render_middle_y));
		for (x = 0; x < MAX_MAP_X; x++)
		    {
			nx = x - (noegnud_render_middle_x);

			if (	(	((noegnud_activetileset->iso)) /*||
									 (noegnud_options_render_features_cardboardcutout->value&&noegnud_activetileset->isalphatileset&&(!noegnud_activetileset->iso))
								       */			)&&
				(y >= noegnud_clip_y)&&
				(!((x == noegnud_clip_x) && (y == noegnud_clip_y)))&&
				(!glyph_is_object(noegnud_map[x][y].glyph_primary))&&
				(!glyph_is_monster(noegnud_map[x][y].glyph_primary))&&
				(!glyph_is_trap(noegnud_map[x][y].glyph_primary))&&
				(sqrt((noegnud_clip_y-y)*(noegnud_clip_y-y)+(noegnud_clip_x-x)*(noegnud_clip_x-x))<3)
				) {
			    current_alpha=noegnud_options_mode_tileset_iso_opacity->value;
			} else {
			    current_alpha=1.0;
			}



			glPopMatrix ();
			glPushMatrix ();
			glTranslatef ((noegnud_activetileset->xdeltax) * (nx) +
				      (noegnud_activetileset->ydeltax) * (ny) +
				      noegnud_render_offset_x, 0,
				      -((noegnud_activetileset->xdeltay) * (nx) +
					(noegnud_activetileset->ydeltay) * (ny)) +
				      noegnud_render_offset_y);

			glBegin(GL_LINES); glEnd();

			if (noegnud_image_dungeon&&(noegnud_map[x][y].glyph_primary==MAX_GLYPH||(glyph_to_cmap(noegnud_map[x][y].glyph_primary)==S_stone&&levl[x+1][y].lit))) {

			    if (levl[x+1][y].seenv) {
				if (noegnud_options_render_features_cardboardcutout->value &&
				    noegnud_options_mode_tileset_caverns_cutout->value &&
				    noegnud_options_render_features_cardboardcutout_raise_walls->value&&(!IS_ROOM(levl[x+1][y].typ))) {
				    glTranslatef(0,noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_wall_height->value,0);
				}
			    } else {
				if (noegnud_options_render_features_cardboardcutout->value &&
				    noegnud_options_mode_tileset_caverns_cutout->value &&
				    noegnud_options_render_features_cardboardcutout_raise_walls->value) {
				    glTranslatef(0,noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_wall_height->value,0);}
			    }
} else
				    if (noegnud_map[x][y].glyph_primary!=MAX_GLYPH&&noegnud_options_render_features_cardboardcutout->value&&noegnud_options_render_features_cardboardcutout_raise_walls->value&&noegnud_activetileset->isalphatileset&&(!noegnud_activetileset->iso)) {
					if (noegnud_map[x][y].high) {

				if (IS_DOOR(level.locations[x+1][y].typ)) {
				    noegnud_render_map_single_tile_raised_walls (
										 noegnud_map[x][y].tile_middle,
										 noegnud_options_render_features_cardboardcutout_wall_height->value,
										 current_alpha,
										 !((y>0)&&noegnud_map[x][y-1].high),
										 !((y<MAX_MAP_Y-1)&&noegnud_map[x][y+1].high),
										 !((x>0)&&noegnud_map[x-1][y].high),
										 !((x<MAX_MAP_X-1)&&noegnud_map[x+1][y].high));

				} else {
				    noegnud_render_map_single_tile_raised_walls (
										 noegnud_map[x][y].tile_back,
										 noegnud_options_render_features_cardboardcutout_wall_height->value,
										 current_alpha,
										 !((y>0)&&noegnud_map[x][y-1].high),
										 !((y<MAX_MAP_Y-1)&&noegnud_map[x][y+1].high),
										 !((x>0)&&noegnud_map[x-1][y].high),
										 !((x<MAX_MAP_X-1)&&noegnud_map[x+1][y].high));
				}
				glTranslatef(0,noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_wall_height->value,0);
			    } else


				if (noegnud_map[x][y].low) {
				    glTranslatef(0,-noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_hole_depth->value,0);

				    if (noegnud_map[x][y].translucent) {
					glTranslatef(0,noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_hole_depth->value*noegnud_options_render_features_cardboardcutout_liquid_depth->value,0);
					current_alpha=0.5;
				    }

				}
			}

			if (((noegnud_render_mouse_map_x-1)==x)&&(noegnud_render_mouse_map_y==y)) {
			    glColor4f(0.25,1.0,0.25,1.0);
			}
			else if ((x == noegnud_clip_x) && (y == noegnud_clip_y)) {
			    glColor4f(noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,current_alpha);
			} else if (iflags.hilite_pet&&(noegnud_map[x][y].glyph_primary!=MAX_GLYPH)&&(noegnud_map[x][y].special_primary & MG_PET)) {
			    glColor4f(noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,current_alpha);
			} else {
			    glColor4f(1.0,1.0,1.0,current_alpha);
			}

			if (noegnud_activetileset->isalphatileset) {
			    if (noegnud_map[x][y].glyph_middle != MAX_GLYPH) {
				noegnud_render_map_single_tile (noegnud_map[x][y].tile_middle,1);
			    }
			    if (noegnud_activetileset->iso&&noegnud_map[x][y].glyph_fore != MAX_GLYPH) {
				noegnud_render_map_single_tile (noegnud_map[x][y].tile_fore,1);

			    }
			    if (((x == noegnud_clip_x) && (y == noegnud_clip_y)) ||
				(((noegnud_render_mouse_map_x-1)==x)&&(noegnud_render_mouse_map_y==y)) ||
				(noegnud_map[x][y].glyph_primary!=MAX_GLYPH&&iflags.hilite_pet&&(noegnud_map[x][y].special_primary & MG_PET))) {
				if (noegnud_options_render_features_cardboardcutout->value) glTranslatef(0,0.02,0);
				noegnud_render_map_tile_highlight_block ();
			    }

			}


		    }

	    }


    if ((noegnud_activetileset->isalphatileset)&&(!noegnud_activetileset->iso)) {

	if (noegnud_options_render_features_cardboardcutout->value) glDisable(GL_CULL_FACE);

	if (noegnud_options_render_features_cardboardcutout->value&&noegnud_options_render_features_cardboardcutout_wall_translucency_current->value>0) {

	    glDisable(GL_DEPTH_TEST);

	    for (y = ys; y != ye; y+=yd)
		{
		    ny = -(y - (noegnud_render_middle_y));
		    for (x = xs; x != xe; x+=xd)
			{
			    nx = x - (noegnud_render_middle_x);

			    glPopMatrix ();
			    glPushMatrix ();

			    if (((noegnud_render_mouse_map_x-1)==x)&&(noegnud_render_mouse_map_y==y)) {
				glColor4f(0.25,1.0,0.25,noegnud_options_render_features_cardboardcutout_wall_translucency_current->value);
			    } else {
				glColor4f(1.0,1.0,1.0,noegnud_options_render_features_cardboardcutout_wall_translucency_current->value);
			    }


			    glTranslatef ((noegnud_activetileset->xdeltax) * (nx) +
					  (noegnud_activetileset->ydeltax) * (ny) +
					  noegnud_render_offset_x, 0,
					  -((noegnud_activetileset->xdeltay) * (nx) +
					    (noegnud_activetileset->ydeltay) * (ny)) +
					  noegnud_render_offset_y);

			    glBegin(GL_LINES); glEnd();

			    if (!(noegnud_map[x][y].high||noegnud_map[x][y].low)) {

				if (noegnud_map[x][y].glyph_back!=MAX_GLYPH) {
				    if (noegnud_options_render_opengl_lighting_method->value==NOEGNUD_RENDER_LIGHTING_METHOD_CHEAP) {
					glEnable(GL_LIGHTING);
				    }

				    noegnud_render_map_single_tile (noegnud_map[x][y].tile_back,1);

				    if (noegnud_options_render_opengl_lighting_method->value==NOEGNUD_RENDER_LIGHTING_METHOD_CHEAP) {
					glDisable(GL_LIGHTING);
				    }

				}

				if (noegnud_map[x][y].glyph_middle!=MAX_GLYPH) {
				    noegnud_render_map_single_tile (noegnud_map[x][y].tile_middle,1);
				}
			    }

			    if (noegnud_map[x][y].glyph_fore != MAX_GLYPH) {
				if ((x==(u.ux-1)&&y==u.uy)&&Levitation) {
				    if (noegnud_map[x][y].low) {
					glTranslatef(0,noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_hole_depth->value,0);
				    }
				    glTranslatef(0,noegnud_activetileset->glheight/2,0);
				}
				if (noegnud_map[x][y].low) glTranslatef(0,-noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_hole_depth->value,0);
				if (((glyph_is_monster(noegnud_map[x][y].glyph_fore)&&noegnud_options_render_features_cardboardcutout_raise_monsters->value)||(glyph_is_object(noegnud_map[x][y].glyph_fore)&&noegnud_options_render_features_cardboardcutout_raise_objects->value))) {
				    glTranslatef (0,noegnud_activetileset->glheight,noegnud_activetileset->glheight/2);
				    glRotatef (90, 1, 0, 0);
				    if (noegnud_options_render_features_autoface->value) {
					glTranslatef (
						      noegnud_activetileset->glwidth/2,
						      0,0);
					glRotatef ((noegnud_options_render_opengl_view_angle_x_current->value+noegnud_render_bullettime_angle), 0, 0, 1);
					glTranslatef (
						      -noegnud_activetileset->glwidth/2,
						      0,0);
				    }
				    glRotatef (-20, 1, 0, 0);
				}
				noegnud_render_map_single_tile (noegnud_map[x][y].tile_fore,1);
			    }

			}

		}
 	    glEnable(GL_DEPTH_TEST);
	}

    if (noegnud_options_render_opengl_lighting_method->value==NOEGNUD_RENDER_LIGHTING_METHOD_CHEAP) {
	glDisable(GL_LIGHTING);
    }

	for (y = ys; y != ye; y+=yd)
	    {
		ny = -(y - (noegnud_render_middle_y));
		for (x = xs; x != xe; x+=xd)
		    {
			nx = x - (noegnud_render_middle_x);



			if ((noegnud_activetileset->iso)&&(y >= noegnud_clip_y)&&(!((x == noegnud_clip_x) && (y == noegnud_clip_y)))&&(!glyph_is_object(noegnud_map[x][y].glyph_primary))&&(!glyph_is_monster(noegnud_map[x][y].glyph_primary))&&(sqrt((noegnud_clip_y-y)*(noegnud_clip_y-y)+(noegnud_clip_x-x)*(noegnud_clip_x-x))<3)) {
			    current_alpha=0.3;
			} else {
			    current_alpha=1.0;
			}



			glPopMatrix ();
			glPushMatrix ();

			glTranslatef ((noegnud_activetileset->xdeltax) * (nx) +
				      (noegnud_activetileset->ydeltax) * (ny) +
				      noegnud_render_offset_x, 0,
				      -((noegnud_activetileset->xdeltay) * (nx) +
					(noegnud_activetileset->ydeltay) * (ny)) +
				      noegnud_render_offset_y);

			glBegin(GL_LINES); glEnd();

			if (((noegnud_render_mouse_map_x-1)==x)&&(noegnud_render_mouse_map_y==y)) {
			    glColor4f(0.25,1.0,0.25,1.0);
			}
			else if ((x == noegnud_clip_x) && (y == noegnud_clip_y)) {
			    glColor4f(noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,current_alpha);

			} else if (iflags.hilite_pet&&(noegnud_map[x][y].glyph_primary!=MAX_GLYPH)&&(noegnud_map[x][y].special_primary & MG_PET)) {
			    glColor4f(noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,noegnud_render_highlight_strobe/2+0.5,current_alpha);
			} else {
			    glColor4f(1.0,1.0,1.0,current_alpha);
			}


			if (noegnud_map[x][y].glyph_fore != MAX_GLYPH) {
			    if ((x==(u.ux-1)&&y==u.uy)&&(!noegnud_activetileset->iso)&&Levitation) {
				if (noegnud_map[x][y].low) {
				    glTranslatef(0,noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_hole_depth->value,0);
				}
				glTranslatef(0,noegnud_activetileset->glheight/2,0);
			    }
			    if (noegnud_map[x][y].low&&(!noegnud_activetileset->iso)) glTranslatef(0,-noegnud_activetileset->glheight*noegnud_options_render_features_cardboardcutout_hole_depth->value,0);
			    if (noegnud_options_render_features_cardboardcutout->value&&((glyph_is_monster(noegnud_map[x][y].glyph_fore)&&noegnud_options_render_features_cardboardcutout_raise_monsters->value)||(glyph_is_object(noegnud_map[x][y].glyph_fore)&&noegnud_options_render_features_cardboardcutout_raise_objects->value))) {
				glTranslatef (0,noegnud_activetileset->glheight,noegnud_activetileset->glheight/2);
				glRotatef (90, 1, 0, 0);
				if (noegnud_options_render_features_autoface->value) {
				    glTranslatef (
						  noegnud_activetileset->glwidth/2,
						  0,0);
				    glRotatef ((noegnud_options_render_opengl_view_angle_x_current->value+noegnud_render_bullettime_angle), 0, 0, 1);
				    glTranslatef (
						  -noegnud_activetileset->glwidth/2,
						  0,0);
				}
				glRotatef (-20, 1, 0, 0);
			    }
			    noegnud_render_map_single_tile (noegnud_map[x][y].tile_fore,1);
			}

		    }

	    }
	if (noegnud_options_render_features_cardboardcutout->value) glEnable(GL_CULL_FACE);
    } else {
	if (noegnud_options_render_opengl_lighting_method->value==NOEGNUD_RENDER_LIGHTING_METHOD_CHEAP) {
	    glDisable(GL_LIGHTING);
	}
    }
}
コード例 #2
0
ファイル: pager.c プロジェクト: thejoshwolfe/nethack
/* quick: use cursor && don't search for "more info" */
static int do_look (bool quick) {
    char    out_str[BUFSZ], look_buf[BUFSZ];
    const char *x_str, *firstmatch = 0;
    struct permonst *pm = 0;
    int     i, ans = 0;
    int     sym;                /* typed symbol or converted glyph */
    int     found;              /* count of matching syms found */
    coord   cc;                 /* screen pos of unknown glyph */
    bool save_verbose;       /* saved value of flags.verbose */
    bool from_screen;        /* question from the screen */
    bool need_to_look;       /* need to get explan. from glyph */
    bool hit_trap;           /* true if found trap explanation */
    int skipped_venom;          /* non-zero if we ignored "splash of venom" */
    static const char *mon_interior = "the interior of a monster";

    if (quick) {
        from_screen = true;     /* yes, we want to use the cursor */
    } else {
        i = ynq("Specify unknown object by cursor?");
        if (i == 'q') return 0;
        from_screen = (i == 'y');
    }

    if (from_screen) {
        cc.x = u.ux;
        cc.y = u.uy;
        sym = 0;                /* gcc -Wall lint */
    } else {
        getlin("Specify what? (type the word)", out_str);
        if (out_str[0] == '\0' || out_str[0] == '\033')
            return 0;

        if (out_str[1]) {       /* user typed in a complete string */
            checkfile(out_str, pm, true, true);
            return 0;
        }
        sym = out_str[0];
    }

    /* Save the verbose flag, we change it later. */
    save_verbose = flags.verbose;
    flags.verbose = flags.verbose && !quick;
    /*
     * The user typed one letter, or we're identifying from the screen.
     */
    do {
        /* Reset some variables. */
        need_to_look = false;
        pm = (struct permonst *)0;
        skipped_venom = 0;
        found = 0;
        out_str[0] = '\0';

        if (from_screen) {
            int glyph;  /* glyph at selected position */

            if (flags.verbose)
                pline("Please move the cursor to %s.",
                       what_is_an_unknown_object);
            else
                pline("Pick an object.");

            ans = getpos(&cc, quick, what_is_an_unknown_object);
            if (ans < 0 || cc.x < 0) {
                flags.verbose = save_verbose;
                return 0;       /* done */
            }
            flags.verbose = false;      /* only print long question once */

            /* Convert the glyph at the selected position to a symbol. */
            glyph = glyph_at(cc.x,cc.y);
            if (glyph_is_cmap(glyph)) {
                sym = showsyms[glyph_to_cmap(glyph)];
            } else if (glyph_is_trap(glyph)) {
                sym = showsyms[trap_to_defsym(glyph_to_trap(glyph))];
            } else if (glyph_is_object(glyph)) {
                sym = oc_syms[(int)objects[glyph_to_obj(glyph)].oc_class];
                if (sym == '`' && iflags.bouldersym && (int)glyph_to_obj(glyph) == BOULDER)
                        sym = iflags.bouldersym;
            } else if (glyph_is_monster(glyph)) {
                /* takes care of pets, detected, ridden, and regular mons */
                sym = monsyms[(int)mons[glyph_to_mon(glyph)].mlet];
            } else if (glyph_is_swallow(glyph)) {
                sym = showsyms[glyph_to_swallow(glyph)+S_sw_tl];
            } else if (glyph_is_invisible(glyph)) {
                sym = DEF_INVISIBLE;
            } else if (glyph_is_warning(glyph)) {
                sym = glyph_to_warning(glyph);
                sym = warnsyms[sym];
            } else {
                impossible("do_look:  bad glyph %d at (%d,%d)",
                                                glyph, (int)cc.x, (int)cc.y);
                sym = ' ';
            }
        }

        /*
         * Check all the possibilities, saving all explanations in a buffer.
         * When all have been checked then the string is printed.
         */

        /* Check for monsters */
        for (i = 0; i < MAXMCLASSES; i++) {
            if (sym == (from_screen ? monsyms[i] : def_monsyms[i]) &&
                monexplain[i]) {
                need_to_look = true;
                if (!found) {
                    sprintf(out_str, "%c       %s", sym, an(monexplain[i]));
                    firstmatch = monexplain[i];
                    found++;
                } else {
                    found += append_str(out_str, an(monexplain[i]));
                }
            }
        }
        /* handle '@' as a special case if it refers to you and you're
           playing a character which isn't normally displayed by that
           symbol; firstmatch is assumed to already be set for '@' */
        if ((from_screen ?
                (sym == monsyms[S_HUMAN] && cc.x == u.ux && cc.y == u.uy) :
                (sym == def_monsyms[S_HUMAN] && !iflags.showrace)) &&
            !(Race_if(PM_HUMAN) || Race_if(PM_ELF)) && !Upolyd)
            found += append_str(out_str, "you");        /* tack on "or you" */

        /*
         * Special case: if identifying from the screen, and we're swallowed,
         * and looking at something other than our own symbol, then just say
         * "the interior of a monster".
         */
        if (u.uswallow && from_screen && is_swallow_sym(sym)) {
            if (!found) {
                sprintf(out_str, "%c       %s", sym, mon_interior);
                firstmatch = mon_interior;
            } else {
                found += append_str(out_str, mon_interior);
            }
            need_to_look = true;
        }

        /* Now check for objects */
        for (i = 1; i < MAXOCLASSES; i++) {
            if (sym == (from_screen ? oc_syms[i] : def_oc_syms[i])) {
                need_to_look = true;
                if (from_screen && i == VENOM_CLASS) {
                    skipped_venom++;
                    continue;
                }
                if (!found) {
                    sprintf(out_str, "%c       %s", sym, an(objexplain[i]));
                    firstmatch = objexplain[i];
                    found++;
                } else {
                    found += append_str(out_str, an(objexplain[i]));
                }
            }
        }

        if (sym == DEF_INVISIBLE) {
            if (!found) {
                sprintf(out_str, "%c       %s", sym, an(invisexplain));
                firstmatch = invisexplain;
                found++;
            } else {
                found += append_str(out_str, an(invisexplain));
            }
        }

#define is_cmap_trap(i) ((i) >= S_arrow_trap && (i) <= S_polymorph_trap)
#define is_cmap_drawbridge(i) ((i) >= S_vodbridge && (i) <= S_hcdbridge)

        /* Now check for graphics symbols */
        for (hit_trap = false, i = 0; i < MAXPCHARS; i++) {
            x_str = defsyms[i].explanation;
            if (sym == (from_screen ? showsyms[i] : defsyms[i].sym) && *x_str) {
                /* avoid "an air", "a water", or "a floor of a room" */
                int article = (i == S_room) ? 2 :               /* 2=>"the" */
                              !(strcmp(x_str, "air") == 0 ||    /* 1=>"an"  */
                                strcmp(x_str, "water") == 0);   /* 0=>(none)*/

                if (!found) {
                    if (is_cmap_trap(i)) {
                        sprintf(out_str, "%c       a trap", sym);
                        hit_trap = true;
                    } else {
                        sprintf(out_str, "%c       %s", sym,
                                article == 2 ? the(x_str) :
                                article == 1 ? an(x_str) : x_str);
                    }
                    firstmatch = x_str;
                    found++;
                } else if (!u.uswallow && !(hit_trap && is_cmap_trap(i)) &&
                           !(found >= 3 && is_cmap_drawbridge(i))) {
                    found += append_str(out_str,
                                        article == 2 ? the(x_str) :
                                        article == 1 ? an(x_str) : x_str);
                    if (is_cmap_trap(i)) hit_trap = true;
                }

                if (i == S_altar || is_cmap_trap(i))
                    need_to_look = true;
            }
        }

        /* Now check for warning symbols */
        for (i = 1; i < WARNCOUNT; i++) {
            x_str = def_warnsyms[i].explanation;
            if (sym == (from_screen ? warnsyms[i] : def_warnsyms[i].sym)) {
                if (!found) {
                        sprintf(out_str, "%c       %s",
                                sym, def_warnsyms[i].explanation);
                        firstmatch = def_warnsyms[i].explanation;
                        found++;
                } else {
                        found += append_str(out_str, def_warnsyms[i].explanation);
                }
                /* Kludge: warning trumps boulders on the display.
                   Reveal the boulder too or player can get confused */
                if (from_screen && sobj_at(BOULDER, cc.x, cc.y))
                        strcat(out_str, " co-located with a boulder");
                break;  /* out of for loop*/
            }
        }

        /* if we ignored venom and list turned out to be short, put it back */
        if (skipped_venom && found < 2) {
            x_str = objexplain[VENOM_CLASS];
            if (!found) {
                sprintf(out_str, "%c       %s", sym, an(x_str));
                firstmatch = x_str;
                found++;
            } else {
                found += append_str(out_str, an(x_str));
            }
        }

        /* handle optional boulder symbol as a special case */
        if (iflags.bouldersym && sym == iflags.bouldersym) {
            if (!found) {
                firstmatch = "boulder";
                sprintf(out_str, "%c       %s", sym, an(firstmatch));
                found++;
            } else {
                found += append_str(out_str, "boulder");
            }
        }

        /*
         * If we are looking at the screen, follow multiple possibilities or
         * an ambiguous explanation by something more detailed.
         */
        if (from_screen) {
            if (found > 1 || need_to_look) {
                char monbuf[BUFSZ];
                char temp_buf[BUFSZ];

                pm = lookat(cc.x, cc.y, look_buf, monbuf);
                firstmatch = look_buf;
                if (*firstmatch) {
                    sprintf(temp_buf, " (%s)", firstmatch);
                    (void)strncat(out_str, temp_buf, BUFSZ-strlen(out_str)-1);
                    found = 1;  /* we have something to look up */
                }
                if (monbuf[0]) {
                    sprintf(temp_buf, " [seen: %s]", monbuf);
                    (void)strncat(out_str, temp_buf, BUFSZ-strlen(out_str)-1);
                }
            }
        }

        /* Finally, print out our explanation. */
        if (found) {
            pline("%s", out_str);
            /* check the data file for information about this thing */
            if (found == 1 && ans != LOOK_QUICK && ans != LOOK_ONCE &&
                        (ans == LOOK_VERBOSE || (flags.help && !quick))) {
                char temp_buf[BUFSZ];
                strcpy(temp_buf, firstmatch);
                checkfile(temp_buf, pm, false, (bool)(ans == LOOK_VERBOSE));
            }
        } else {
            pline("I've never heard of such things.");
        }

    } while (from_screen && !quick && ans != LOOK_ONCE);

    flags.verbose = save_verbose;
    return 0;
}