void display_storage_menu() { int i; /* Entropy suggested hack to determine if this is the view only "#sto" opened storage */ view_only_storage = 0; for (i = 0; i < no_storage_categories; i++) { if ((storage_categories[i].id != -1) && (strcmp(&storage_categories[i].name[1], "Quest") == 0)) { view_only_storage = 1; break; } } if(storage_win<=0){ int our_root_win = -1; if (!windows_on_top) { our_root_win = game_root_win; } storage_win=create_window(win_storage, our_root_win, 0, storage_win_x, storage_win_y, storage_win_x_len, storage_win_y_len, ELW_WIN_DEFAULT|ELW_TITLE_NAME); set_window_handler(storage_win, ELW_HANDLER_DISPLAY, &display_storage_handler); set_window_handler(storage_win, ELW_HANDLER_CLICK, &click_storage_handler); set_window_handler(storage_win, ELW_HANDLER_MOUSEOVER, &mouseover_storage_handler); set_window_handler(storage_win, ELW_HANDLER_KEYPRESS, &keypress_storage_handler ); vscrollbar_add_extended(storage_win, STORAGE_SCROLLBAR_CATEGORIES, NULL, 130, 10, 20, 192, 0, 1.0, newcol_r, newcol_g, newcol_b, 0, 1, max2i(no_storage_categories - STORAGE_CATEGORIES_DISPLAY, 0)); vscrollbar_add_extended(storage_win, STORAGE_SCROLLBAR_ITEMS, NULL, 352, 10, 20, 192, 0, 1.0, newcol_r, newcol_g, newcol_b, 0, 1, 28); cm_add(windows_list.window[storage_win].cm_id, cm_storage_menu_str, context_storage_handler); cm_add(windows_list.window[storage_win].cm_id, cm_dialog_options_str, context_storage_handler); cm_bool_line(windows_list.window[storage_win].cm_id, ELW_CM_MENU_LEN+2, &sort_storage_categories, NULL); cm_bool_line(windows_list.window[storage_win].cm_id, ELW_CM_MENU_LEN+3, &disable_storage_filter, NULL); cm_bool_line(windows_list.window[storage_win].cm_id, ELW_CM_MENU_LEN+4, &autoclose_storage_dialogue, NULL); cm_bool_line(windows_list.window[storage_win].cm_id, ELW_CM_MENU_LEN+5, &auto_select_storage_option, NULL); } else { no_storage=0; for(i = 0; i < no_storage_categories; i++) storage_categories[i].name[0] = to_color_char (c_orange1); show_window(storage_win); select_window(storage_win); vscrollbar_set_pos(storage_win, STORAGE_SCROLLBAR_CATEGORIES, 0); vscrollbar_set_pos(storage_win, STORAGE_SCROLLBAR_ITEMS, 0); } storage_text[0] = '\0'; set_window_name("", ""); }
static __inline__ void adapt_intersect_list_size(BBOX_TREE* bbox_tree, Uint32 count) { Uint32 size, idx; if (count == 0) count = 1; idx = bbox_tree->cur_intersect_type; size = bbox_tree->intersect[idx].size; if ((bbox_tree->intersect[idx].count+count) >= size) { size += max2i(count, size/2); bbox_tree->intersect[idx].items = (BBOX_ITEM*)realloc(bbox_tree->intersect[idx].items, size*sizeof(BBOX_ITEM)); bbox_tree->intersect[idx].size = size; } }
void get_old_world_x_y (short *scene_x, short *scene_y) { AABBOX box; float t, x, y, z, t1, t2, tx, ty, dx, dy, h, len; int i, j, h_max, h_min, h1, h2, h3, h4, sx, sy, zx, zy, i_min, i_max, j_min, j_max; x = click_line.center[X]; y = click_line.center[Y]; z = click_line.center[Z]; dx = click_line.direction[X]; dy = click_line.direction[Y]; t = min2f(4.0f, max2f(-2.2f, z)); if (t != z) { t = (t-z)/click_line.direction[Z]; x += t*dx; y += t*dy; } t = 6.2f / click_line.direction[Z]; len = min2f(max2f(t, -t), click_line.length); len = click_line.length; if (max2f(dx, -dx) < 0.000001f) { zx = 1; sx = 0; } else { zx = 0; if (dx < 0.0f) sx = -1; else sx = 1; } if (max2f(dy, -dy) < 0.000001f) { zy = 1; sy = 0; } else { zy = 0; if (dy < 0.0f) sy = -1; else sy = 1; } i = x*2.0f; j = y*2.0f; i_min = min2f(x, x+dx*len)*2.0f; i_max = max2f(x, x+dx*len)*2.0f; j_min = min2f(y, y+dy*len)*2.0f; j_max = max2f(y, y+dy*len)*2.0f; i_min = max2i(min2i(i_min, tile_map_size_x*6), 0); i_max = max2i(min2i(i_max, tile_map_size_x*6-1), 0); j_min = max2i(min2i(j_min, tile_map_size_y*6), 0); j_max = max2i(min2i(j_max, tile_map_size_y*6-1), 0); i = min2i(max2i(i, i_min), i_max-1); j = min2i(max2i(j, j_min), j_max-1); h = 0.0f; while ((i >= i_min) && (j >= j_min) && (i < i_max) && (j < j_max)) { h1 = height_map[j*tile_map_size_x*6+i]; h2 = height_map[j*tile_map_size_x*6+i+1]; h3 = height_map[(j+1)*tile_map_size_x*6+i]; h4 = height_map[(j+1)*tile_map_size_x*6+i+1]; h_max = max2i(max2i(h1, h2), max2i(h3, h4)); h_min = min2i(min2i(h1, h2), min2i(h3, h4)); tx = i*0.5f; ty = j*0.5f; box.bbmin[X] = tx; box.bbmin[Y] = ty; box.bbmin[Z] = h_min*0.2f-2.2f; box.bbmax[X] = tx+1.0f; box.bbmax[Y] = ty+1.0f; box.bbmax[Z] = h_max*0.2f-2.2f; if (click_line_bbox_intersection(box)) { box.bbmin[X] = tx+0.0f; box.bbmin[Y] = ty+0.0f; box.bbmin[Z] = h1*0.2f-2.2f; box.bbmax[X] = tx+0.5f; box.bbmax[Y] = ty+0.5f; box.bbmax[Z] = h1*0.2f-2.2f; if (click_line_bbox_intersection(box)) { h = h1*0.2f-2.2f; break; } box.bbmin[X] = tx+0.5f; box.bbmin[Y] = ty+0.0f; box.bbmin[Z] = h2*0.2f-2.2f; box.bbmax[X] = tx+1.0f; box.bbmax[Y] = ty+0.5f; box.bbmax[Z] = h2*0.2f-2.2f; if (click_line_bbox_intersection(box)) { h = h2*0.2f-2.2f; break; } box.bbmin[X] = tx+0.0f; box.bbmin[Y] = ty+0.5f; box.bbmin[Z] = h3*0.2f-2.2f; box.bbmax[X] = tx+0.5f; box.bbmax[Y] = ty+1.0f; box.bbmax[Z] = h3*0.2f-2.2f; if (click_line_bbox_intersection(box)) { h = h3*0.2f-2.2f; break; } box.bbmin[X] = tx+0.5f; box.bbmin[Y] = ty+0.5f; box.bbmin[Z] = h4*0.2f-2.2f; box.bbmax[X] = tx+1.0f; box.bbmax[Y] = ty+1.0f; box.bbmax[Z] = h4*0.2f-2.2f; if (click_line_bbox_intersection(box)) { h = h4*0.2f-2.2f; break; } } if ((zx == 1) && (zy == 1)) break; if (zx == 0) t1 = (tx+sx-x)/dx; else t1 = 10e30; if (zx == 0) t2 = (ty+sy-y)/dy; else t2 = -10e30; if (t1 < t2) i += 2*sx; else j += 2*sy; t = min2f(t1, t2); x += dx*t; y += dy*t; } t = (h-click_line.center[Z])/click_line.direction[Z]; *scene_x = (click_line.center[X]+click_line.direction[X]*t) / 0.5; *scene_y = (click_line.center[Y]+click_line.direction[Y]*t) / 0.5; }