diff --git a/src/client/Client.cpp b/src/client/Client.cpp index cb9f4db61..663aad7cb 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -168,7 +168,7 @@ bool Client::DoInstallation() IShellLinkW *shellLink = NULL; IPersistFile *shellLinkPersist = NULL; - int returnval; + int returnval = 0; LONG rresult; HKEY newkey; ByteString currentfilename = Platform::ExecutableName(); @@ -188,19 +188,16 @@ bool Client::DoInstallation() //Create protocol entry rresult = createKey("Software\\Classes\\ptsave", newkey); if (rresult != ERROR_SUCCESS) { - returnval = 0; goto finalise; } rresult = setValue(newkey, "Powder Toy Save"); if (rresult != ERROR_SUCCESS) { RegCloseKey(newkey); - returnval = 0; goto finalise; } rresult = RegSetValueExW(newkey, (LPWSTR)L"URL Protocol", 0, REG_SZ, (LPBYTE)L"", 1); if (rresult != ERROR_SUCCESS) { RegCloseKey(newkey); - returnval = 0; goto finalise; } RegCloseKey(newkey); @@ -208,13 +205,11 @@ bool Client::DoInstallation() //Set Protocol DefaultIcon rresult = createKey("Software\\Classes\\ptsave\\DefaultIcon", newkey); if (rresult != ERROR_SUCCESS) { - returnval = 0; goto finalise; } rresult = setValue(newkey, iconname); if (rresult != ERROR_SUCCESS) { RegCloseKey(newkey); - returnval = 0; goto finalise; } RegCloseKey(newkey); @@ -222,13 +217,11 @@ bool Client::DoInstallation() //Set Protocol Launch command rresult = createKey("Software\\Classes\\ptsave\\shell\\open\\command", newkey); if (rresult != ERROR_SUCCESS) { - returnval = 0; goto finalise; } rresult = setValue(newkey, protocolcommand); if (rresult != ERROR_SUCCESS) { RegCloseKey(newkey); - returnval = 0; goto finalise; } RegCloseKey(newkey); @@ -236,26 +229,22 @@ bool Client::DoInstallation() //Create extension entry rresult = createKey("Software\\Classes\\.cps", newkey); if (rresult != ERROR_SUCCESS) { - returnval = 0; goto finalise; } rresult = setValue(newkey, "PowderToySave"); if (rresult != ERROR_SUCCESS) { RegCloseKey(newkey); - returnval = 0; goto finalise; } RegCloseKey(newkey); rresult = createKey("Software\\Classes\\.stm", newkey); if (rresult != ERROR_SUCCESS) { - returnval = 0; goto finalise; } rresult = setValue(newkey, "PowderToySave"); if (rresult != ERROR_SUCCESS) { RegCloseKey(newkey); - returnval = 0; goto finalise; } RegCloseKey(newkey); @@ -263,13 +252,11 @@ bool Client::DoInstallation() //Create program entry rresult = createKey("Software\\Classes\\PowderToySave", newkey); if (rresult != ERROR_SUCCESS) { - returnval = 0; goto finalise; } rresult = setValue(newkey, "Powder Toy Save"); if (rresult != ERROR_SUCCESS) { RegCloseKey(newkey); - returnval = 0; goto finalise; } RegCloseKey(newkey); @@ -277,13 +264,11 @@ bool Client::DoInstallation() //Set DefaultIcon rresult = createKey("Software\\Classes\\PowderToySave\\DefaultIcon", newkey); if (rresult != ERROR_SUCCESS) { - returnval = 0; goto finalise; } rresult = setValue(newkey, iconname); if (rresult != ERROR_SUCCESS) { RegCloseKey(newkey); - returnval = 0; goto finalise; } RegCloseKey(newkey); @@ -291,13 +276,11 @@ bool Client::DoInstallation() //Set Launch command rresult = createKey("Software\\Classes\\PowderToySave\\shell\\open\\command", newkey); if (rresult != ERROR_SUCCESS) { - returnval = 0; goto finalise; } rresult = setValue(newkey, opencommand); if (rresult != ERROR_SUCCESS) { RegCloseKey(newkey); - returnval = 0; goto finalise; } RegCloseKey(newkey); diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index b335d1317..b8afde495 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -2253,7 +2253,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength) partsData[partsDataLen++] = particles[i].type; //Location of the field descriptor - int fieldDesc3Loc; + int fieldDesc3Loc = 0; int fieldDescLoc = partsDataLen++; partsDataLen++; diff --git a/src/gui/interface/TextWrapper.cpp b/src/gui/interface/TextWrapper.cpp index 7afce4e92..394f2c581 100644 --- a/src/gui/interface/TextWrapper.cpp +++ b/src/gui/interface/TextWrapper.cpp @@ -26,7 +26,7 @@ namespace ui std::vector records; int word_begins_at = -1; // this is a pointer into records; we're not currently in a word - int word_width; + int word_width = 0; int lines = 1; int char_width; int clear_count = 0; diff --git a/src/simulation/elements/GLAS.cpp b/src/simulation/elements/GLAS.cpp index c398b5233..9361d5aec 100644 --- a/src/simulation/elements/GLAS.cpp +++ b/src/simulation/elements/GLAS.cpp @@ -49,8 +49,8 @@ void Element::Element_GLAS() static int update(UPDATE_FUNC_ARGS) { - auto press = sim->pv[y/CELL][x/CELL] * 64; - float diff = press - parts[i].tmp3; + auto press = int(sim->pv[y/CELL][x/CELL] * 64); + auto diff = press - parts[i].tmp3; if (diff > 16 || diff < -16) { sim->part_change_type(i,x,y,PT_BGLA); @@ -61,5 +61,5 @@ static int update(UPDATE_FUNC_ARGS) static void create(ELEMENT_CREATE_FUNC_ARGS) { - sim->parts[i].tmp3 = sim->pv[y/CELL][x/CELL] * 64; + sim->parts[i].tmp3 = int(sim->pv[y/CELL][x/CELL] * 64); } diff --git a/src/simulation/elements/QRTZ.cpp b/src/simulation/elements/QRTZ.cpp index 29392330a..f7228236f 100644 --- a/src/simulation/elements/QRTZ.cpp +++ b/src/simulation/elements/QRTZ.cpp @@ -54,7 +54,7 @@ int Element_QRTZ_update(UPDATE_FUNC_ARGS) int r, tmp, trade, rx, ry, np, t = parts[i].type; if (t == PT_QRTZ) { - auto press = sim->pv[y/CELL][x/CELL] * 64; + auto press = int(sim->pv[y/CELL][x/CELL] * 64); auto diffTolerance = parts[i].temp * 1.0666f; if (press - parts[i].tmp3 > diffTolerance || press - parts[i].tmp3 < -diffTolerance) { @@ -161,5 +161,5 @@ int Element_QRTZ_graphics(GRAPHICS_FUNC_ARGS) static void create(ELEMENT_CREATE_FUNC_ARGS) { sim->parts[i].tmp2 = RNG::Ref().between(0, 10); - sim->parts[i].tmp3 = sim->pv[y/CELL][x/CELL] * 64; + sim->parts[i].tmp3 = int(sim->pv[y/CELL][x/CELL] * 64); } diff --git a/src/simulation/elements/TUNG.cpp b/src/simulation/elements/TUNG.cpp index eecb3fd72..08cf3bc62 100644 --- a/src/simulation/elements/TUNG.cpp +++ b/src/simulation/elements/TUNG.cpp @@ -95,8 +95,8 @@ static int update(UPDATE_FUNC_ARGS) parts[i].vy += RNG::Ref().between(-50, 50); return 1; } - auto press = sim->pv[y/CELL][x/CELL] * 64; - float diff = press - parts[i].tmp3; + auto press = int(sim->pv[y/CELL][x/CELL] * 64); + auto diff = press - parts[i].tmp3; if (diff > 32 || diff < -32) { sim->part_change_type(i,x,y,PT_BRMT); @@ -132,5 +132,5 @@ static int graphics(GRAPHICS_FUNC_ARGS) static void create(ELEMENT_CREATE_FUNC_ARGS) { - sim->parts[i].tmp3 = sim->pv[y/CELL][x/CELL] * 64; + sim->parts[i].tmp3 = int(sim->pv[y/CELL][x/CELL] * 64); }