initialize some variables to fix -Werror=maybe-uninitialized warnings

most aren't actually bugs, but gcc isn't able to determine that the paths it can follow guarantee they are initialized
This commit is contained in:
jacob1 2018-07-08 00:49:35 -04:00
parent 8e09edd188
commit 92244f78bb
4 changed files with 8 additions and 8 deletions

View File

@ -858,8 +858,8 @@ int luatpt_reset_spark(lua_State* l)
int luatpt_set_property(lua_State* l)
{
const char *name;
int r, i, x, y, w, h, t, nx, ny, partsel = 0;
float f;
int r, i, x, y, w, h, t = 0, nx, ny, partsel = 0;
float f = 0;
int acount = lua_gettop(l);
const char* prop = luaL_optstring(l, 1, "");
@ -877,14 +877,14 @@ int luatpt_set_property(lua_State* l)
return luaL_error(l, "Unrecognised element '%s'", name);
}
}
if (lua_isnumber(l, 2))
if (lua_isnumber(l, 2) || format == CommandInterface::FormatElement)
{
if (format == CommandInterface::FormatFloat)
f = luaL_optnumber(l, 2, 0);
else
t = luaL_optint(l, 2, 0);
if (!strcmp(prop,"type") && (t<0 || t>=PT_NUM || !luacon_sim->elements[t].Enabled))
if (!strcmp(prop, "type") && (t<0 || t>=PT_NUM || !luacon_sim->elements[t].Enabled))
return luaL_error(l, "Unrecognised element number '%d'", t);
}
else

View File

@ -1075,7 +1075,7 @@ void Simulation::ApplyDecorationPoint(int positionX, int positionY, int colR, in
void Simulation::ApplyDecorationLine(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode, Brush * cBrush)
{
bool reverseXY = abs(y2-y1) > abs(x2-x1);
int x, y, dx, dy, sy, rx, ry;
int x, y, dx, dy, sy, rx = 0, ry = 0;
float e = 0.0f, de;
if(cBrush)
@ -2404,7 +2404,7 @@ int Simulation::eval_move(int pt, int nx, int ny, unsigned *rr)
int Simulation::try_move(int i, int x, int y, int nx, int ny)
{
unsigned r, e;
unsigned r = 0, e;
if (x==nx && y==ny)
return 1;

View File

@ -97,7 +97,7 @@ int Element_TRON::update(UPDATE_FUNC_ARGS)
}
if (parts[i].tmp&TRON_HEAD)
{
int firstdircheck = 0,seconddir,seconddircheck = 0,lastdir,lastdircheck = 0;
int firstdircheck = 0, seconddir = 0, seconddircheck = 0, lastdir = 0, lastdircheck = 0;
int direction = (parts[i].tmp>>5 & 0x3);
int originaldir = direction;

View File

@ -47,7 +47,7 @@ Element_VIBR::Element_VIBR()
//#TPT-Directive ElementHeader Element_VIBR static int update(UPDATE_FUNC_ARGS)
int Element_VIBR::update(UPDATE_FUNC_ARGS) {
int r, rx, ry, rndstore;
int r, rx, ry, rndstore = 0;
int trade, transfer;
if (!parts[i].life) //if not exploding
{