On Wed, Oct 15, 2003 at 22:22:19 +0200, Jochen Suckfuell wrote: > Hi! > > The parse_game_button_press() function in x11/x11.c didn't take the > configured mapsize into account, but calculated the direction relative > to the player position in the default sized map. > Besides this, I cleaned up the code a bit, so I can as well paste the > whole function here instead of a patch: > > > static void parse_game_button_press(int button, int x, int y) > { > int dx, dy, i; > x = (x-2)/image_size; > y = (y-2)/image_size; > dx = x-use_config[CONFIG_MAPWIDTH]/2; > dy = y-use_config[CONFIG_MAPHEIGHT]/2; > > if(button == 1) > { > > /* Its unlikely this will happen, but if the window is > * resized, its possible to be out of bounds. > */ > if(dx<(-use_config[CONFIG_MAPWIDTH]/2)||dx>(use_config[CONFIG_MAPWIDTH]/2)||dy<(-use_config[CONFIG_MAPHEIGHT]/2)||dy>(use_config[CONFIG_MAPHEIGHT]/2)) return; Sorry, this line should of course be: if(x < 0 || x > use_config[CONFIG_MAPWIDTH] || y < 0 || y > use_config[CONFIG_MAPHEIGHT]) return; > look_at(dx,dy); > return; > } > > if (dx<0) > i = 0; > else if (dx>0) > i = 6; > else i =3; > > if (dy>0) > i += 2; > else if (dy==0) > i++; > > if (button==2) { > switch (i) { > case 0: fire_dir (8);break; > case 1: fire_dir (7);break; > case 2: fire_dir (6);break; > case 3: fire_dir (1);break; > case 5: fire_dir (5);break; > case 6: fire_dir (2);break; > case 7: fire_dir (3);break; > case 8: fire_dir (4);break; > } > /* Only want to fire once */ > clear_fire(); > return; > } > > switch (i) { > case 0: move_player (8);break; > case 1: move_player (7);break; > case 2: move_player (6);break; > case 3: move_player (1);break; > case 5: move_player (5);break; > case 6: move_player (2);break; > case 7: move_player (3);break; > case 8: move_player (4);break; > } > } > > > It would be nice if someone could commit this to CVS. > > Bye > Jochen > > -- > Jochen Suckfuell --- http://www.suckfuell.net/jochen/ --- > > _______________________________________________ > crossfire-devel mailing list > crossfire-devel at lists.real-time.com > https://mailman.real-time.com/mailman/listinfo/crossfire-devel Bye Jochen -- Jochen Suckfuell --- http://www.suckfuell.net/jochen/ --- _______________________________________________ crossfire-devel mailing list crossfire-devel at lists.real-time.com https://mailman.real-time.com/mailman/listinfo/crossfire-devel