1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-18 10:38:31 +02:00

Ensure that all member attributes are initialized

I ran the game through cppcheck and it spat out a bunch of member
attributes that weren't being initialized. So I initialized them.

In the previous version of this commit, I added constructors to
GraphicsResources, otherlevelclass, labclass, warpclass, and finalclass,
but flibit says this changes the code flow enough that it's risky to
merge before 2.4, so I got rid of those constructors, too.
This commit is contained in:
Misa 2020-07-06 13:04:34 -07:00 committed by Ethan Lee
parent 3b6867243b
commit 7703b2c1c2
9 changed files with 88 additions and 21 deletions

View File

@ -11,6 +11,7 @@ binaryBlob::binaryBlob()
{
numberofHeaders = 0;
SDL_memset(m_headers, 0, sizeof(m_headers));
SDL_memset(m_memblocks, 0, sizeof(m_memblocks));
}
#ifdef VVV_COMPILEMUSIC

View File

@ -19,6 +19,9 @@ blockclass::blockclass()
r = 0;
g = 0;
b = 0;
x = 0.0f;
y = 0.0f;
}
void blockclass::rectset(const int xi, const int yi, const int wi, const int hi)

View File

@ -72,6 +72,28 @@ void entityclass::init()
resetallflags();
SDL_memset(collect, false, sizeof(collect));
SDL_memset(customcollect, false, sizeof(customcollect));
colpoint1 = point();
colpoint2 = point();
tempx = 0;
tempy = 0;
tempw = 0;
temph = 0;
temp = 0;
temp2 = 0;
tpx1 = 0;
tpy1 = 0;
tpx2 = 0;
tpy2 = 0;
x = 0;
k = 0;
dx = 0.0f;
dy = 0.0f;
dr = 0.0f;
px = 0;
py = 0;
linetemp = 0;
activetrigger = 0;
}
void entityclass::resetallflags()

View File

@ -114,6 +114,8 @@ void Graphics::init()
tl = point();
towerbuffer = NULL;
towerbuffer_lerp = NULL;
footerbuffer = NULL;
ghostbuffer = NULL;
trinketr = 0;
trinketg = 0;
trinketb = 0;

View File

@ -109,26 +109,31 @@ void GraphicsResources::init(void)
void GraphicsResources::destroy(void)
{
SDL_FreeSurface(im_tiles);
SDL_FreeSurface(im_tiles2);
SDL_FreeSurface(im_tiles3);
SDL_FreeSurface(im_entcolours);
SDL_FreeSurface(im_sprites);
SDL_FreeSurface(im_flipsprites);
SDL_FreeSurface(im_bfont);
SDL_FreeSurface(im_teleporter);
#define CLEAR(img) \
SDL_FreeSurface(img); \
img = NULL;
SDL_FreeSurface(im_image0);
SDL_FreeSurface(im_image1);
SDL_FreeSurface(im_image2);
SDL_FreeSurface(im_image3);
SDL_FreeSurface(im_image4);
SDL_FreeSurface(im_image5);
SDL_FreeSurface(im_image6);
SDL_FreeSurface(im_image7);
SDL_FreeSurface(im_image8);
SDL_FreeSurface(im_image9);
SDL_FreeSurface(im_image10);
SDL_FreeSurface(im_image11);
SDL_FreeSurface(im_image12);
CLEAR(im_tiles);
CLEAR(im_tiles2);
CLEAR(im_tiles3);
CLEAR(im_entcolours);
CLEAR(im_sprites);
CLEAR(im_flipsprites);
CLEAR(im_bfont);
CLEAR(im_teleporter);
CLEAR(im_image0);
CLEAR(im_image1);
CLEAR(im_image2);
CLEAR(im_image3);
CLEAR(im_image4);
CLEAR(im_image5);
CLEAR(im_image6);
CLEAR(im_image7);
CLEAR(im_image8);
CLEAR(im_image9);
CLEAR(im_image10);
CLEAR(im_image11);
CLEAR(im_image12);
#undef CLEAR
}

View File

@ -57,6 +57,8 @@ KeyPoll::KeyPoll()
linealreadyemptykludge = false;
pauseStart = 0;
isActive = true;
}
void KeyPoll::enabletextentry()

View File

@ -76,6 +76,21 @@ mapclass::mapclass()
ypos = 0;
oldypos = 0;
bypos = 0;
background = 0;
cameramode = 0;
cameraseek = 0;
minitowermode = false;
scrolldir = 0;
check = 0;
cmode = 0;
towercol = 0;
tdrawback = false;
bscroll = 0;
roomtexton = false;
kludge_bypos = 0;
kludge_colstate = 0;
kludge_scrolldir = 0;
}
//Areamap starts at 100,100 and extends 20x20

View File

@ -132,6 +132,9 @@ void musicclass::init()
songEnd = 0;
Mix_HookMusicFinished(&songend);
mmmmmm = false;
usingmmmmmm = false;
}
void songend()

View File

@ -13,6 +13,20 @@ textboxclass::textboxclass()
tm = 0;
timer = 0;
allowspecial = false;
xp = 0;
yp = 0;
r = 0;
g = 0;
b = 0;
tr = 0;
tg = 0;
tb = 0;
max = 0;
textrect.x = 0;
textrect.y = 0;
textrect.w = 0;
textrect.h = 0;
}
void textboxclass::centerx()