Skip to content

Commit

Permalink
Fixed some little bugs (thanks to Clang static analyzer)
Browse files Browse the repository at this point in the history
  • Loading branch information
yvt committed Feb 25, 2014
1 parent ea273fc commit db88ee4
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Resources/Scripts/Gui/MainScreen.as
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ namespace spades {

// fade the map
float fade = Clamp((time - 1.f) / 2.2f, 0.f, 1.f);
sceneDef.globalBlur = Clamp((1.f - (time - 1.f) / 2.5f) * 4.f, 0.f, 1.f);
sceneDef.globalBlur = Clamp((1.f - (time - 1.f) / 2.5f), 0.f, 1.f);
if(!mainMenu.IsEnabled) {
sceneDef.globalBlur = Max(sceneDef.globalBlur, 0.5f);
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Audio/ALDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ namespace spades {

alDevice = al::qalcOpenDevice(NULL);
if(!alDevice){
if(ext = al::qalcGetString(NULL, ALC_EXTENSIONS)){
if((ext = al::qalcGetString(NULL, ALC_EXTENSIONS))){
std::vector<std::string> strs = Split(ext, " ");
SPLog("OpenAL ALC Extensions (NULL):");
for(size_t i = 0; i < strs.size(); i++) {
Expand All @@ -409,7 +409,7 @@ namespace spades {
SPLog(" Version: %s", al::qalGetString(AL_VERSION));
SPLog(" Renderer: %s", al::qalGetString(AL_RENDERER));

if(ext = al::qalcGetString(alDevice, ALC_EXTENSIONS)){
if((ext = al::qalcGetString(alDevice, ALC_EXTENSIONS))){
std::vector<std::string> strs = Split(ext, " ");
SPLog("OpenAL ALC Extensions:");
for(size_t i = 0; i < strs.size(); i++) {
Expand Down
15 changes: 9 additions & 6 deletions Sources/Client/GameMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,24 +242,27 @@ namespace spades {
else if (c.x != a.x) {
d.x = 1; f.x = a.x+1-v0.x; g.x = (v1.x-v0.x)*1024; cnt += c.x-a.x;
}
else
f.x = g.x = 0;
else {
d.x = 0; f.x = g.x = 0;
}
if (c.y < a.y) {
d.y = -1; f.y = v0.y-a.y; g.y = (v0.y-v1.y)*1024; cnt += a.y-c.y;
}
else if (c.y != a.y) {
d.y = 1; f.y = a.y+1-v0.y; g.y = (v1.y-v0.y)*1024; cnt += c.y-a.y;
}
else
f.y = g.y = 0;
else {
d.y = 0; f.y = g.y = 0;
}
if (c.z < a.z) {
d.z = -1; f.z = v0.z-a.z; g.z = (v0.z-v1.z)*1024; cnt += a.z-c.z;
}
else if (c.z != a.z) {
d.z = 1; f.z = a.z+1-v0.z; g.z = (v1.z-v0.z)*1024; cnt += c.z-a.z;
}
else
f.z = g.z = 0;
else {
d.z = 0; f.z = g.z = 0;
}

Vector3 pp = MakeVector3(f.x * g.z - f.z * g.x,
f.y * g.z - f.z * g.y,
Expand Down
3 changes: 2 additions & 1 deletion Sources/Client/IFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ namespace spades {
float newScale = scale <= .8f ?
0.5f : std::max(1.f, floorf(scale));
// vertical-align: baseline
y += (scale - newScale) * glyph.size;
// FIXME: not working correctly
offset.y += (scale - newScale) * glyph.size;
scale = newScale;
}

Expand Down
1 change: 1 addition & 0 deletions Sources/Client/MapView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ namespace spades {
fv.x = Mix(fv.x, avg, 0.5f);
fv.y = Mix(fv.y, avg, 0.5f);
fv.z = Mix(fv.z, avg, 0.5f);
fv.w = 0.f; // suppress "operating on garbase value" static analyzer message
fv = fv * 0.8f + 0.2f;
fv.w = 1.f;
return fv;
Expand Down
6 changes: 6 additions & 0 deletions Sources/Client/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ namespace spades {
case HitTypeArms: return 33;
case HitTypeLegs: return 33;
case HitTypeBlock: return 50;
default: SPAssert(false); return 0;
}
}
virtual Vector3 GetRecoil () {
Expand All @@ -225,6 +226,7 @@ namespace spades {
case HitTypeArms: return 18;
case HitTypeLegs: return 18;
case HitTypeBlock: return 25;
default: SPAssert(false); return 0;
}
}
virtual Vector3 GetRecoil () {
Expand Down Expand Up @@ -253,6 +255,7 @@ namespace spades {
case HitTypeBlock:
// Actually, you cast a hit per pallet. This value is a guess, by the way. --GM
return 34;
default: SPAssert(false); return 0;
}
}
virtual Vector3 GetRecoil () {
Expand Down Expand Up @@ -283,6 +286,7 @@ namespace spades {
case HitTypeArms: return 33;
case HitTypeLegs: return 33;
case HitTypeBlock: return 50;
default: SPAssert(false); return 0;
}
}
virtual Vector3 GetRecoil () {
Expand All @@ -309,6 +313,7 @@ namespace spades {
case HitTypeArms: return 18;
case HitTypeLegs: return 18;
case HitTypeBlock: return 34;
default: SPAssert(false); return 0;
}
}
virtual Vector3 GetRecoil () {
Expand Down Expand Up @@ -336,6 +341,7 @@ namespace spades {
case HitTypeLegs: return 16;
case HitTypeBlock:
return 34;
default: SPAssert(false); return 0;
}
}
virtual Vector3 GetRecoil () {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/RefCountedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace spades {
}
void Set(T *p, bool add = true) {
if(p == ptr){
if(!add)
if((!add) && ptr != nullptr)
ptr->Release();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Draw/GLDepthOfFieldFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ namespace spades {

GLColorBuffer coc;

globalBlur = std::min(globalBlur * 3.f, 1.f);
{
GLProfiler p(dev, "CoC Computation");
coc = GenerateCoC(blurDepthRange, vignetteBlur, globalBlur);
Expand All @@ -397,8 +398,7 @@ namespace spades {
float sin60 = sinf(static_cast<float>(M_PI) / 3.f);

maxCoc *= .7f + vignetteBlur * 0.5f;
maxCoc += 1.f + 5.f * globalBlur;
globalBlur = std::min(globalBlur * 5.f, 1.f);
maxCoc *= 1.f + 3.f * globalBlur;

// reduce resolution to make it faster
int divide = 1;
Expand Down
2 changes: 2 additions & 0 deletions Sources/Draw/GLFramebufferManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ namespace spades {
case IGLDevice:: FramebufferIncompleteLayerTargets:
type = "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS";
break;
default: // IGLDevice::Enum contains values unrelevant to framebuffer status error causing static analyzer to say something
type = "Unknown";
}
SPRaise("OpenGL Framebuffer completeness check failed: %s",
type.c_str());
Expand Down
1 change: 0 additions & 1 deletion Sources/Gui/StartupScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "StartupScreen.h"
#include <Core/Exception.h>
#include <Client/Quake3Font.h>
#include <Client/FontData.h>
#include <ScriptBindings/ScriptFunction.h>
#include "StartupScreenHelper.h"
#include <Client/Client.h>
Expand Down
1 change: 1 addition & 0 deletions Sources/ScriptBindings/IRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ namespace spades {
"void opAssign(const DynamicLightParam& in)",
asFUNCTION(DynamicLightParamAssign),
asCALL_CDECL_OBJLAST);
manager->CheckError(r);
r = eng->RegisterObjectProperty("DynamicLightParam",
"DynamicLightType type",
asOFFSET(DynamicLightParam, type));
Expand Down
4 changes: 4 additions & 0 deletions Sources/binpack2d/binpack2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
yvt: modified to fix some bug
*/
/**
* BinPack2D is a 2 dimensional, multi-bin, bin-packer. ( Texture Atlas Array! )
Expand Down Expand Up @@ -162,6 +164,7 @@ class Size {

if(this->w != that.w) return this->w < that.w;
if(this->h != that.h) return this->h < that.h;
return false; // yvt
}
};

Expand Down Expand Up @@ -199,6 +202,7 @@ class Coord {
if(this->x != that.x) return this->x < that.x;
if(this->y != that.y) return this->y < that.y;
if(this->z != that.z) return this->z < that.z;
return false; // yvt
}
};

Expand Down
2 changes: 1 addition & 1 deletion Sources/unzip/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
return UNZ_PARAMERROR;


if ((pfile_in_zip_read_info->read_buffer == NULL))
if (pfile_in_zip_read_info->read_buffer == NULL)
return UNZ_END_OF_LIST_OF_FILE;
if (len==0)
return 0;
Expand Down

0 comments on commit db88ee4

Please sign in to comment.