WINEXPORT LRESULT CALLBACK FileCompleteWindowProc( HWND hwnd, UINT msg, WPARAM w, LPARAM l ) { switch( msg ) { case WM_KEYDOWN: if( !BAD_ID( command_window_id ) ) { SetFocus( command_window_id ); SendMessage( command_window_id, msg, w, l ); return( 0 ); } break; case WM_ERASEBKGND: return( TRUE ); case WM_CREATE: SET_WNDINFO( hwnd, (LONG_PTR)&FileCompleteWindow ); break; case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: FileCompleteMouseClick( hwnd, GET_X( l ), GET_Y( l ), true ); break; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: FileCompleteMouseClick( hwnd, GET_X( l ), GET_Y( l ), false ); break; } return( DefWindowProc( hwnd, msg, w, l ) ); }
void update_world_cell(unsigned short x, unsigned short y){ world_cell *cell = &world[x][y]; world_cell** possible_cells; int count = 0; /* perfom logic for each cell type */ switch(cell->type){ case EMPTY: break; case WOLF: { int squirrels_found = 0; world_cell** squirrel_cells = malloc(4 * sizeof(world_cell*)); possible_cells = retrieve_possible_cells(cell); for(; count < 4 && possible_cells[count] != NULL; ++count){ if(possible_cells[count]->type == SQUIRREL) squirrel_cells[squirrels_found++] = possible_cells[count]; } if(squirrels_found){ world_cell* prev_gen_dest_cell = squirrel_cells[CHOOSE_CELL(cell, squirrels_found)]; move_wolf(cell, &world[GET_REAL_X(prev_gen_dest_cell)][GET_Y(prev_gen_dest_cell)]); } else if (count) { world_cell* prev_gen_dest_cell = possible_cells[CHOOSE_CELL(cell, count--)]; move_wolf(cell, &world[GET_REAL_X(prev_gen_dest_cell)][GET_Y(prev_gen_dest_cell)]); } else { cell->moved = UPDATED; //was updated anyways } free(squirrel_cells); free(possible_cells); break; } case SQUIRREL: case SQUIRREL_IN_TREE: possible_cells = retrieve_possible_cells(cell); for(; count < 4 && possible_cells[count] != NULL; ++count); if (count) { world_cell* prev_gen_dest_cell = possible_cells[CHOOSE_CELL(cell, count--)]; move_squirrel(cell, &world[GET_REAL_X(prev_gen_dest_cell)][GET_Y(prev_gen_dest_cell)]); } else { cell->moved = UPDATED; //was updated anyways } free(possible_cells); break; default: /* we assume that trees and ice are less frequent than the animals */ break; } }
/** @method contains?( thing ) -> boolean Returns whether thing ([x, y, w, h] or [x, y]) fits completely within the rectangle. */ static VALUE rb_array_contains(VALUE self, VALUE thing) { GET_X(); GET_Y(); GET_W(); GET_H(); double x2,y2,w2,h2; Check_Type(thing, T_ARRAY); x2=array_get_x(thing); y2=array_get_y(thing); if(RARRAY(thing)->len>3){ // It's a rectangle w2=array_get_w(thing); h2=array_get_h(thing); return INT2BOOL((x <= x2) && (y <= y2) && (x + w >= x2 + w2) && (y + h >= y2 + h2) && (x + w > x2) && (y + h > y2)); }else{ // It's a point return INT2BOOL((x2>=x && x2<x+w && y2>=y && y2<y+h)); } return Qfalse; }
/** @method union( rect ) -> [x, y, w, h] @method union!( rect ) -> self Returns a new rectangle that completely covers the given rectangle(s). There may be an area inside the new rectangle that is not covered by the inputs. Rectangles are pre-normalized. */ static VALUE rb_array_union_bang(VALUE self, VALUE other_rect) { normalize(self); normalize(other_rect); { GET_X(); GET_Y(); GET_W(); GET_H(); double other_x=array_get_x(other_rect); double other_y=array_get_y(other_rect); double other_w=array_get_w(other_rect); double other_h=array_get_h(other_rect); double new_x=RUDL_MIN(x, other_x); double new_y=RUDL_MIN(y, other_y); SET_X( new_x ); SET_Y( new_y ); SET_W( RUDL_MAX(x+w, other_x+other_w)-new_x ); SET_H( RUDL_MAX(y+h, other_y+other_h)-new_y ); } return self; }
char add_cell(world_cell* aux_cell, world_cell** possible_cells, char bad_type){ if(aux_cell->type != bad_type && aux_cell->type != ICE && aux_cell->type != SQUIRREL_IN_TREE && aux_cell->type != WOLF){ *possible_cells = &world_previous[GET_X(aux_cell)][GET_Y(aux_cell)]; return 1; } return 0; }
point transform(point v, float A[4][4]) { float v_f[] = {GET_X(v), GET_Y(v), GET_Z(v), GET_W(v)}; return std::make_tuple(dot_product(v_f, A[0]), dot_product(v_f, A[1]), dot_product(v_f, A[2]), dot_product(v_f, A[3])); }
VOID do_posn(LONG tree, WORD obj, WORD item) { WORD pobj; GRECT o, p; if (obj != ROOT) { pobj = get_parent(tree, obj); objc_xywh(tree, pobj, &p); objc_xywh(tree, obj, &o); o.g_x = GET_X(tree, obj); o.g_y = GET_Y(tree, obj); switch (item) { case JLFTPOP: o.g_x = 0; break; case JRGTPOP: o.g_x = max(0, p.g_w - o.g_w); break; case JCENPOP: o.g_x = max(0, (p.g_w - o.g_w) / 2); break; case JTOPPOP: o.g_y = 0; break; case JBOTPOP: o.g_y = max(0, p.g_h - o.g_h); break; case JMIDPOP: o.g_y = max(0, (p.g_h - o.g_h) / 2); break; case VFILLPOP: o.g_h = p.g_h; o.g_y = 0; break; case HFILLPOP: o.g_w = p.g_w; o.g_x = 0; break; case SNAPPOP: break; default: return; } rcs_edited = TRUE; if (rcs_state != PANL_STATE || item == SNAPPOP) { snap_xy(&o.g_x, &o.g_y); snap_wh(&o.g_w, &o.g_h); } obj_redraw(tree, obj); ob_setxywh(tree, obj, &o); obj_redraw(tree, obj); } }
int get_cell_color(world_cell* cell){ int x = GET_X(cell->number); int y = GET_Y(cell); if((x%2 == 0 && y%2 == 0) || (x%2 != 0 && y%2 != 0)){ return RED; } else { return BLACK; } }
/** @method same_size?( rect ) Returns whether @rect is the same area as @self. */ static VALUE rb_array_same_size(VALUE self, VALUE rect) { GET_X(); GET_Y(); GET_W(); GET_H(); if(self==rect){ return Qtrue; } Check_Type(rect, T_ARRAY); return(x==array_get_x(rect) && y==array_get_y(rect) && w==array_get_w(rect) && h==array_get_h(rect)); }
int my_send_pin(t_user *usr, t_user *player) { char tmp[100]; if (player == NULL) return (my_sbp(usr)); bzero(tmp, 100); sprintf(tmp, "pin %d %d %d %d %d %d %d %d %d %d\n", player->nb, GET_X(player), GET_Y(player), GET_INV(player).food, GET_INV(player).linemate, GET_INV(player).deraumere, GET_INV(player).sibur, GET_INV(player).mendiane, GET_INV(player).phiras, GET_INV(player).thystame); xfill_cb(usr, &usr->wr, tmp); return (0); }
static VALUE rb_array_inflate_bang(VALUE self, VALUE size) { normalize(self); { GET_X(); GET_Y(); GET_W(); GET_H(); double dx=array_get_x(size); double dy=array_get_y(size); SET_X(x-dx/2); SET_Y(y-dy/2); SET_W(w+dx); SET_H(h+dy); } return self; }
__inline__ static void normalize(VALUE self) { GET_W(); GET_H(); if(w<0){ GET_X(); x=x+w; w=-w; SET_X(x); SET_W(w); } if(h<0){ GET_Y(); y=y+h; h=-h; SET_Y(y); SET_H(h); } }
static void episodic_store_full( noble_being * local, n_byte event, n_int affect, noble_simulation * local_sim, n_byte2 name1, n_byte2 family1, n_byte2 name2, n_byte2 family2, n_byte2 arg, n_byte food) { episodic_memory * local_episodic = GET_EPI(local_sim, local); n_int replace; n_byte old_event; n_byte2 old_time; n_byte2 new_time; if (local_episodic == 0L) { return; } if (being_awake_local(local_sim, local)==FULLY_ASLEEP) return; replace = episodic_memory_replace_index(event,affect,name1,family1,name2,family2,local,local_sim); if (replace == -1) return; old_event = local_episodic[replace].event; old_time = local_episodic[replace].time; /** insert the current event into the episodic memory */ local_episodic[replace].event = event; local_episodic[replace].affect = (n_byte2)(affect+EPISODIC_AFFECT_ZERO); local_episodic[replace].location[0] = GET_X(local); local_episodic[replace].location[1] = GET_Y(local); local_episodic[replace].time = new_time =local_sim->land->time; local_episodic[replace].date[0] = local_sim->land->date[0]; local_episodic[replace].date[1] = local_sim->land->date[1]; local_episodic[replace].first_name[BEING_MEETER]=name1; local_episodic[replace].family_name[BEING_MEETER]=family1; local_episodic[replace].first_name[BEING_MET]=name2; local_episodic[replace].family_name[BEING_MET]=family2; local_episodic[replace].food=food; local_episodic[replace].arg=arg; if ((event == 0) || (event>=EVENTS)) { (void)SHOW_ERROR("Event outside scope"); } if (local_logging) { if ((old_event != event) || ((old_time+10) < (new_time))) /* this may need to be changed */ { n_string_block description; n_string_block str; n_string_block time; n_string_block combination = {0}; n_int social_event; being_name((FIND_SEX(GET_I(local)) == SEX_FEMALE), GET_NAME(local_sim, local), GET_FAMILY_FIRST_NAME(local_sim, local), GET_FAMILY_SECOND_NAME(local_sim, local), str); social_event = episode_description(local_sim, local, replace, description); if ((local_social == 1) && (social_event == 0)) { return; } io_time_to_string(time, local_sim->land->time, local_sim->land->date[0], local_sim->land->date[1]); io_three_string_combination(combination, time, str, description, 35); (*local_logging)(combination); } } }
polygon transform(polygon p, float A[4][4]) { return POLYGON(transform(GET_X(p), A), transform(GET_Y(p), A), transform(GET_Z(p), A)); }