init NhRect, before passing to selection_getbounds

selection_getbounds() has a check and early return.
Initialization will ensure a known state if that early return
were ever taken.

This is an alternative approach to pr #1163.
This commit is contained in:
nhmall
2023-12-13 00:21:32 -05:00
parent dc02eb3e4f
commit 3cfd579d37
4 changed files with 16 additions and 14 deletions

View File

@@ -4675,7 +4675,7 @@ struct selectionvar *
selection_not(struct selectionvar *s)
{
int x, y;
NhRect tmprect;
NhRect tmprect = cg.zeroNhRect;
for (x = 0; x < s->wid; x++)
for (y = 0; y < s->hei; y++)
@@ -4689,7 +4689,7 @@ selection_filter_mapchar(struct selectionvar *ov, xint16 typ, int lit)
{
int x, y;
struct selectionvar *ret;
NhRect rect;
NhRect rect = cg.zeroNhRect;
if (!ov)
return NULL;
@@ -4727,7 +4727,7 @@ selection_filter_percent(
{
int x, y;
struct selectionvar *ret;
NhRect rect;
NhRect rect = cg.zeroNhRect;
if (!ov)
return NULL;
@@ -4753,7 +4753,7 @@ selection_rndcoord(
int idx = 0;
int c;
int dx, dy;
NhRect rect;
NhRect rect = cg.zeroNhRect;
selection_getbounds(ov, &rect);
@@ -4794,7 +4794,7 @@ selection_do_grow(struct selectionvar *ov, int dir)
{
coordxy x, y;
struct selectionvar *tmp;
NhRect rect;
NhRect rect = cg.zeroNhRect;
if (!ov)
return;
@@ -5222,7 +5222,7 @@ selection_iterate(
genericptr_t arg)
{
coordxy x, y;
NhRect rect;
NhRect rect = cg.zeroNhRect;
if (!ov)
return;
@@ -5645,7 +5645,7 @@ lspo_replace_terrain(lua_State *L)
lua_Integer x1, y1, x2, y2;
int chance;
int tolit;
NhRect rect;
NhRect rect = cg.zeroNhRect;
create_des_coder();