Fixed some warnings found by Visual Studio's code analysis
This commit is contained in:
parent
c3732f26d3
commit
9ef7f99adf
13 changed files with 19 additions and 31 deletions
ai
game
network
sound
stratagus
ui
unit
video
|
@ -487,7 +487,6 @@ static void AiCheckingWork()
|
|||
*/
|
||||
static int AiAssignHarvester(CUnit *unit, int resource)
|
||||
{
|
||||
std::vector<CUnitType *>::iterator i;
|
||||
CUnit *dest;
|
||||
int res = resource;
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ static void LoadStratagusMap(const std::string &smpname, const std::string &mapn
|
|||
strcpy_s(mapfull, sizeof(mapfull), StratagusLibPath.c_str());
|
||||
strcat_s(mapfull, sizeof(mapfull), "/");
|
||||
strcat_s(mapfull, sizeof(mapfull), smpname.c_str());
|
||||
char *p = strrchr(mapfull, '/');
|
||||
p = strrchr(mapfull, '/');
|
||||
if (!p) {
|
||||
p = mapfull;
|
||||
} else {
|
||||
|
|
|
@ -639,7 +639,6 @@ static int CclDefineSpell(lua_State *l)
|
|||
SpellType *spell;
|
||||
const char *value;
|
||||
int args;
|
||||
int i;
|
||||
|
||||
args = lua_gettop(l);
|
||||
identname = LuaToString(l, 1);
|
||||
|
@ -666,7 +665,7 @@ static int CclDefineSpell(lua_State *l)
|
|||
}
|
||||
SpellTypeTable.push_back(spell);
|
||||
}
|
||||
for (i = 1; i < args; ++i) {
|
||||
for (int i = 1; i < args; ++i) {
|
||||
value = LuaToString(l, i + 1);
|
||||
++i;
|
||||
if (!strcmp(value, "showname")) {
|
||||
|
|
|
@ -967,10 +967,10 @@ void NetworkEvent(void)
|
|||
// Handle some messages.
|
||||
//
|
||||
if (packet.Header.Type[i] == MessageQuit) {
|
||||
int player = ntohs(nc->X);
|
||||
int playerNum = ntohs(nc->X);
|
||||
|
||||
if (player >= 0 && player < NumPlayers) {
|
||||
PlayerQuit[player] = 1;
|
||||
if (playerNum >= 0 && playerNum < NumPlayers) {
|
||||
PlayerQuit[playerNum] = 1;
|
||||
validCommand = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ CSample *LoadWav(const std::string &name, int flags)
|
|||
int rem;
|
||||
int read;
|
||||
int bufrem;
|
||||
char sndbuf[SOUND_BUFFER_SIZE];
|
||||
char *sndbuf = new char[SOUND_BUFFER_SIZE];
|
||||
|
||||
sample->Buffer = NULL;
|
||||
read = 0;
|
||||
|
@ -366,6 +366,8 @@ CSample *LoadWav(const std::string &name, int flags)
|
|||
sample->Len += comp;
|
||||
}
|
||||
|
||||
delete[] sndbuf;
|
||||
|
||||
data->WavFile->close();
|
||||
delete data->WavFile;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,6 @@ static void ShowTitleImage(TitleScreen *t)
|
|||
const EventCallback *old_callbacks;
|
||||
EventCallback callbacks;
|
||||
CGraphic *g;
|
||||
int x, y;
|
||||
|
||||
WaitNoEvent = true;
|
||||
|
||||
|
@ -118,12 +117,7 @@ static void ShowTitleImage(TitleScreen *t)
|
|||
g = CGraphic::New(t->File);
|
||||
g->Load();
|
||||
if (t->StretchImage) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
g->Resize(Video.Width, Video.Height);
|
||||
} else {
|
||||
x = (Video.Width - g->Width) / 2;
|
||||
y = (Video.Height - g->Height) / 2;
|
||||
}
|
||||
|
||||
int timeout = t->Timeout * CYCLES_PER_SECOND;
|
||||
|
|
|
@ -746,7 +746,6 @@ int HandleCheats(const std::string &input)
|
|||
static int InputKey(int key)
|
||||
{
|
||||
char ChatMessage[sizeof(Input) + 40];
|
||||
int i;
|
||||
char *namestart;
|
||||
char *p;
|
||||
char *q;
|
||||
|
@ -835,7 +834,7 @@ static int InputKey(int key)
|
|||
if (!strlen(namestart)) {
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < PlayerMax; ++i) {
|
||||
for (int i = 0; i < PlayerMax; ++i) {
|
||||
if (Players[i].Type != PlayerPerson) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1298,7 +1298,6 @@ void UIHandleButtonDown(unsigned button)
|
|||
static bool OldShowAttackRange;
|
||||
static bool OldValid = false;
|
||||
CUnit *uins;
|
||||
int i;
|
||||
|
||||
/**
|
||||
** Detect long selection click, FIXME: tempory hack to test the feature.
|
||||
|
@ -1537,7 +1536,7 @@ void UIHandleButtonDown(unsigned button)
|
|||
ThisPlayer->IsTeamed(Selected[0])) {
|
||||
if (Selected[0]->BoardCount >= ButtonUnderCursor) {
|
||||
uins = Selected[0]->UnitInside;
|
||||
for (i = ButtonUnderCursor; i; uins = uins->NextContained) {
|
||||
for (int i = ButtonUnderCursor; i; uins = uins->NextContained) {
|
||||
if (uins->Boarded) {
|
||||
--i;
|
||||
}
|
||||
|
|
|
@ -68,9 +68,9 @@ CBuildRestrictionOnTop *OnTopDetails(const CUnit *unit, const CUnitType *parent)
|
|||
return ontopb;
|
||||
}
|
||||
} else if ((andb = dynamic_cast<CBuildRestrictionAnd *>(*i))) {
|
||||
for (std::vector<CBuildRestriction *>::iterator i = andb->_or_list.begin();
|
||||
i != andb->_or_list.end(); ++i) {
|
||||
if ((ontopb = dynamic_cast<CBuildRestrictionOnTop *>(*i))) {
|
||||
for (std::vector<CBuildRestriction *>::iterator it = andb->_or_list.begin();
|
||||
it != andb->_or_list.end(); ++it) {
|
||||
if ((ontopb = dynamic_cast<CBuildRestrictionOnTop *>(*it))) {
|
||||
if (!parent) {
|
||||
// Guess this is right
|
||||
return ontopb;
|
||||
|
|
|
@ -1245,11 +1245,10 @@ static int CclDefineDecorations(lua_State *l)
|
|||
*/
|
||||
void UpdateUnitVariables(const CUnit *unit)
|
||||
{
|
||||
int i;
|
||||
const CUnitType *type; // unit->Type.
|
||||
|
||||
type = unit->Type;
|
||||
for (i = 0; i < NVARALREADYDEFINED; i++) { // default values
|
||||
for (int i = 0; i < NVARALREADYDEFINED; i++) { // default values
|
||||
if (i == ARMOR_INDEX || i == PIERCINGDAMAGE_INDEX ||
|
||||
i == BASICDAMAGE_INDEX || i == MANA_INDEX ||
|
||||
i == KILL_INDEX || i == HP_INDEX) {
|
||||
|
@ -1327,7 +1326,7 @@ void UpdateUnitVariables(const CUnit *unit)
|
|||
unit->Variable[SLOT_INDEX].Value = unit->Slot;
|
||||
unit->Variable[SLOT_INDEX].Max = UnitSlotFree - 1;
|
||||
|
||||
for (i = 0; i < NVARALREADYDEFINED; i++) { // default values
|
||||
for (int i = 0; i < NVARALREADYDEFINED; i++) { // default values
|
||||
unit->Variable[i].Enable &= unit->Variable[i].Max > 0;
|
||||
#ifdef DEBUG
|
||||
if (unit->Variable[i].Value > unit->Variable[i].Max) {
|
||||
|
|
|
@ -915,7 +915,7 @@ static int DrawLevelCompare(const void *v1, const void *v2) {
|
|||
// FIXME: Use BoxHeight?
|
||||
diffpos = c1->Y * TileSizeY + c1->IY + c1->Type->Height -
|
||||
(c2->Y * TileSizeY + c2->IY + c2->Type->Height);
|
||||
return diffpos ? diffpos : c1->X - c2->X ? c1->X - c2->X : c1->Slot - c2->Slot;
|
||||
return diffpos ? diffpos : (c1->X - c2->X ? c1->X - c2->X : c1->Slot - c2->Slot);
|
||||
} else {
|
||||
return drawlevel1 <= drawlevel2 ? -1 : 1;
|
||||
}
|
||||
|
|
|
@ -463,8 +463,6 @@ static void CleanAnimation(CAnimation *anim)
|
|||
*/
|
||||
void CleanUnitTypes(void)
|
||||
{
|
||||
int j;
|
||||
|
||||
// Clean all animations.
|
||||
for (int j = 0; j < NumAnimations; ++j) {
|
||||
CleanAnimation(AnimationsArray[j]);
|
||||
|
@ -485,7 +483,7 @@ void CleanUnitTypes(void)
|
|||
UnitTypes.clear();
|
||||
UnitTypeMap.clear();
|
||||
|
||||
for (j = 0; j < UnitTypeVar.NumberVariable; ++j) { // User defined variables
|
||||
for (int j = 0; j < UnitTypeVar.NumberVariable; ++j) { // User defined variables
|
||||
delete[] UnitTypeVar.VariableName[j];
|
||||
}
|
||||
delete[] UnitTypeVar.VariableName;
|
||||
|
|
|
@ -96,7 +96,6 @@ int LoadGraphicPNG(CGraphic *g)
|
|||
SDL_Palette *palette;
|
||||
png_bytep *volatile row_pointers;
|
||||
int row;
|
||||
int i;
|
||||
volatile int ckey;
|
||||
png_color_16 *transv;
|
||||
char name[PATH_MAX];
|
||||
|
@ -282,14 +281,14 @@ int LoadGraphicPNG(CGraphic *g)
|
|||
png_get_PLTE(png_ptr, info_ptr, &png_palette, &num_palette);
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY) {
|
||||
palette->ncolors = 256;
|
||||
for (i = 0; i < 256; ++i) {
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
palette->colors[i].r = i;
|
||||
palette->colors[i].g = i;
|
||||
palette->colors[i].b = i;
|
||||
}
|
||||
} else if (num_palette > 0) {
|
||||
palette->ncolors = num_palette;
|
||||
for (i = 0; i < num_palette; ++i) {
|
||||
for (int i = 0; i < num_palette; ++i) {
|
||||
palette->colors[i].b = png_palette[i].blue;
|
||||
palette->colors[i].g = png_palette[i].green;
|
||||
palette->colors[i].r = png_palette[i].red;
|
||||
|
|
Loading…
Add table
Reference in a new issue