Smashing windows with thrown rocks

I don’t think it makes sounds and it doesn’t make sticks or sheets come out.

I just checked and you were right, so I decided to look into it and here’s what I found :

Throwing stuff, as far as terrain goes, uses the function “shoot”, whereas smashing uses “bash”.

These functions are created in “map.cpp”, starting as follows :
Shoot

void map::shoot(game *g, const int x, const int y, int &dam, const bool hit_items, const unsigned effects)
Bash

There are probably other discrepancies between Shoot and Bash than just with breaking windows, but I focused on windows and indeed the Shoot function lacks sound and item generation when destroying windows, as well as not handling some types of windows, whereas Bash does everything properly, so I did some creative copypasta, and here’s the result :

Right now, Shoot does this :

[code] case t_window:
case t_window_domestic:
case t_window_alarm:
dam -= rng(0, 5);
ter_set(x, y, t_window_frame);
break;

case t_window_boarded:
dam -= rng(10, 30);
if (dam > 0)
ter_set(x, y, t_window_frame);
break;

case t_wall_glass_h:
case t_wall_glass_v:
case t_wall_glass_h_alarm:
case t_wall_glass_v_alarm:
dam -= rng(0, 8);
ter_set(x, y, t_floor);
break;[/code]

where it should do that :

 case t_window_domestic:
 case t_curtains:
 case t_window_domestic_taped:
  dam -= rng(0, 5);
  g->sound(g->u.posx, g->u.posy, 18, "glass breaking!");
   ter_set(x, y, t_window_frame);
  spawn_item(x, y, (*itypes)["sheet"], 0, 1);
  spawn_item(x, y, (*itypes)["stick"], 0);
  break;

 case t_window_boarded:
  dam -= rng(10, 30);
  if (dam > 0)
  g->sound(g->u.posx, g->u.posy, 18, "crash!");
   ter_set(x, y, t_window_frame);
   const int num_boards = rng(0, 2) * rng(0, 1);
   for (int i = 0; i < num_boards; i++)
    spawn_item(x, y, (*itypes)["splinter"], 0);
  break;

 case t_window:
 case t_window_alarm:
 case t_window_alarm_taped:
 case t_window_taped:
  dam -= rng(0, 5);
  g->sound(g->u.posx, g->u.posy, 18, "glass breaking!");
   ter_set(x, y, t_window_frame);
  break;

 case t_wall_glass_h:
 case t_wall_glass_v:
 case t_wall_glass_h_alarm:
 case t_wall_glass_v_alarm:
  dam -= rng(0, 8);
  g->sound(g->u.posx, g->u.posy, 18, "glass breaking!");
  ter_set(x, y, t_floor);
  break;

For the sound volume I used 18, the same as smashing, and I used the same way to generate sound as when shooting triggers an alarm, but I used the bashing sounds text. Hopefully I did this right.

If someone with a github account could check this and do the change/report here if it doesn’t work, I’d be most grateful (crossing my fingers here, since I’m not exactly used to write code).

but but it’s completely helpful things are buggy in this case, except for the lack of sheets, but it’s not like there isn’t 100 windows per house