https://github.com/libsdl-org/Maelstrom/commit/c80f34af9e5d8252b3661e43dfb7a2fd739e5d9c
From c80f34af9e5d8252b3661e43dfb7a2fd739e5d9c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 4 Nov 2011 19:20:40 -0400
Subject: [PATCH] Fixed compiler warnings
---
netlogic/game.cpp | 5 ++---
netlogic/logic.cpp | 1 -
netlogic/netplay.cpp | 1 -
screenlib/UIArea.cpp | 2 +-
screenlib/UIBaseElement.cpp | 10 +++++-----
screenlib/UIBaseElement.h | 4 ++--
screenlib/UIElementEditbox.cpp | 2 +-
screenlib/UIElementRadio.cpp | 4 ++--
screenlib/UIManager.cpp | 23 ++---------------------
screenlib/UIPanel.cpp | 2 +-
10 files changed, 16 insertions(+), 38 deletions(-)
diff --git a/netlogic/game.cpp b/netlogic/game.cpp
index 9ff09201..bb88acc2 100644
--- a/netlogic/game.cpp
+++ b/netlogic/game.cpp
@@ -139,7 +139,6 @@ int gWhenEnemy;
// Local functions used in the game module of Maelstrom
static void DoGameOver(void);
-static void DoBonus(void);
/* ----------------------------------------------------------------- */
/* -- Start a new game */
@@ -202,7 +201,7 @@ GamePanelDelegate::OnLoad()
m_lives = m_panel->GetElement<UIElement>("lives");
m_bonus = m_panel->GetElement<UIElement>("bonus");
- for (i = 0; i < SDL_arraysize(m_multiplier); ++i) {
+ for (i = 0; (unsigned)i < SDL_arraysize(m_multiplier); ++i) {
sprintf(name, "multiplier%d", 2+i);
m_multiplier[i] = m_panel->GetElement<UIElement>(name);
}
@@ -460,7 +459,7 @@ GamePanelDelegate::DrawStatus(Bool first)
}
MultFactor = TheShip->GetBonusMult();
- for (i = 0; i < SDL_arraysize(m_multiplier); ++i) {
+ for (i = 0; (unsigned)i < SDL_arraysize(m_multiplier); ++i) {
if (!m_multiplier[i]) {
continue;
}
diff --git a/netlogic/logic.cpp b/netlogic/logic.cpp
index c971e8d4..55155fbf 100644
--- a/netlogic/logic.cpp
+++ b/netlogic/logic.cpp
@@ -50,7 +50,6 @@ int InitLogicData(void)
int LogicParseArgs(char ***argvptr, int *argcptr)
{
char **argv = *argvptr;
- int argc = *argcptr;
/* Check for the '-player' option */
if ( strcmp(argv[1], "-player") == 0 ) {
diff --git a/netlogic/netplay.cpp b/netlogic/netplay.cpp
index 563f4364..e04acd3b 100644
--- a/netlogic/netplay.cpp
+++ b/netlogic/netplay.cpp
@@ -39,7 +39,6 @@ UDPsocket gNetFD;
static int GotPlayer[MAX_PLAYERS];
static IPaddress PlayAddr[MAX_PLAYERS];
-static IPaddress ServAddr;
static int FoundUs;
static Uint32 NextFrame;
UDPpacket *OutBound[2];
diff --git a/screenlib/UIArea.cpp b/screenlib/UIArea.cpp
index d9e71cd7..f1401c9a 100644
--- a/screenlib/UIArea.cpp
+++ b/screenlib/UIArea.cpp
@@ -340,7 +340,7 @@ UIArea::CalculateAnchor(bool triggerRectChanged)
void
UIArea::OnRectChanged()
{
- for (unsigned i = 0; i < m_anchoredAreas.length(); ++i) {
+ for (int i = 0; i < m_anchoredAreas.length(); ++i) {
m_anchoredAreas[i]->CalculateAnchor(true);
}
}
diff --git a/screenlib/UIBaseElement.cpp b/screenlib/UIBaseElement.cpp
index 7bb1c988..028e9124 100644
--- a/screenlib/UIBaseElement.cpp
+++ b/screenlib/UIBaseElement.cpp
@@ -58,7 +58,7 @@ UIBaseElement::~UIBaseElement()
{
SDL_free(m_name);
- for (unsigned i = 0; i < m_elements.length(); ++i) {
+ for (int i = 0; i < m_elements.length(); ++i) {
delete m_elements[i];
}
}
@@ -149,7 +149,7 @@ UIBaseElement::SetParentDisabled(bool disabled)
void
UIBaseElement::UpdateDisabledState()
{
- for (unsigned i = 0; i < m_elements.length(); ++i) {
+ for (int i = 0; i < m_elements.length(); ++i) {
m_elements[i]->SetParentDisabled(IsDisabled());
}
}
@@ -157,7 +157,7 @@ UIBaseElement::UpdateDisabledState()
void
UIBaseElement::Draw()
{
- for (unsigned i = 0; i < m_elements.length(); ++i) {
+ for (int i = 0; i < m_elements.length(); ++i) {
if (m_elements[i]->IsShown()) {
m_elements[i]->Draw();
}
@@ -167,7 +167,7 @@ UIBaseElement::Draw()
bool
UIBaseElement::HandleEvent(const SDL_Event &event)
{
- for (unsigned i = m_elements.length(); i--; ) {
+ for (int i = m_elements.length(); i--; ) {
if (m_elements[i]->IsDisabled()) {
continue;
}
@@ -181,7 +181,7 @@ UIBaseElement::HandleEvent(const SDL_Event &event)
UIBaseElement *
UIBaseElement::GetElement(const char *name)
{
- for (unsigned i = 0; i < m_elements.length(); ++i) {
+ for (int i = 0; i < m_elements.length(); ++i) {
if (strcmp(name, m_elements[i]->GetName()) == 0) {
return m_elements[i];
}
diff --git a/screenlib/UIBaseElement.h b/screenlib/UIBaseElement.h
index ce7cc04e..91559288 100644
--- a/screenlib/UIBaseElement.h
+++ b/screenlib/UIBaseElement.h
@@ -79,7 +79,7 @@ class UIBaseElement : public UIArea
}
template <typename T>
T *FindElement(UIBaseElement *start = NULL) {
- unsigned i, j;
+ int i, j;
if (start) {
// Find the starting element
for (i = 0; i < m_elements.length(); ++i) {
@@ -110,7 +110,7 @@ class UIBaseElement : public UIArea
}
template <typename T>
void FindElements(array<T*> &elements) {
- for (unsigned i = 0; i < m_elements.length(); ++i) {
+ for (int i = 0; i < m_elements.length(); ++i) {
UIBaseElement *element = m_elements[i];
if (element->IsA(T::GetType())) {
elements.add((T*)element);
diff --git a/screenlib/UIElementEditbox.cpp b/screenlib/UIElementEditbox.cpp
index 46a7a04f..e098808b 100644
--- a/screenlib/UIElementEditbox.cpp
+++ b/screenlib/UIElementEditbox.cpp
@@ -133,7 +133,7 @@ UIElementEditbox::SetFocus(bool focus)
// Take focus away from other editboxes
m_parent->FindElements<UIElementEditbox>(editboxes);
- for (unsigned i = 0; i < editboxes.length(); ++i) {
+ for (int i = 0; i < editboxes.length(); ++i) {
if (editboxes[i] != this) {
editboxes[i]->SetFocus(false);
}
diff --git a/screenlib/UIElementRadio.cpp b/screenlib/UIElementRadio.cpp
index f92d439d..fa2f32b8 100644
--- a/screenlib/UIElementRadio.cpp
+++ b/screenlib/UIElementRadio.cpp
@@ -35,7 +35,7 @@ UIElementRadioGroup::GetRadioButton(int id)
{
UIElementRadioButton *button;
- for (unsigned i = 0; i < m_elements.length(); ++i) {
+ for (int i = 0; i < m_elements.length(); ++i) {
if (!m_elements[i]->IsA(UIElementRadioButton::GetType())) {
continue;
}
@@ -54,7 +54,7 @@ UIElementRadioGroup::RadioButtonChecked(UIElementRadioButton *button)
array<UIElementRadioButton*> buttons;
FindElements<UIElementRadioButton>(buttons);
- for (unsigned i = 0; i < buttons.length(); ++i) {
+ for (int i = 0; i < buttons.length(); ++i) {
if (buttons[i] != button && buttons[i]->IsChecked()) {
buttons[i]->SetChecked(false);
}
diff --git a/screenlib/UIManager.cpp b/screenlib/UIManager.cpp
index 03b0c935..5ea0a277 100644
--- a/screenlib/UIManager.cpp
+++ b/screenlib/UIManager.cpp
@@ -60,25 +60,6 @@ UIManager::LoadTemplates(const char *file)
return m_templates.Load(path);
}
-static const char *GetLine(char *&text)
-{
- while (*text == '\r' || *text == '\n') {
- ++text;
- }
- if (!*text) {
- return NULL;
- }
-
- const char *line = text;
- while (*text && *text != '\r' && *text != '\n') {
- ++text;
- }
- if (*text) {
- *text++ = '\0';
- }
- return line;
-}
-
UIPanel *
UIManager::LoadPanel(const char *name)
{
@@ -162,7 +143,7 @@ UIManager::LoadPanel(const char *name)
UIPanel *
UIManager::GetPanel(const char *name, bool allowLoad)
{
- for (unsigned i = 0; i < m_panels.length(); ++i) {
+ for (int i = 0; i < m_panels.length(); ++i) {
if (strcmp(name, m_panels[i]->GetName()) == 0) {
return m_panels[i];
}
@@ -246,7 +227,7 @@ UIManager::Draw(bool fullUpdate)
if (fullUpdate) {
m_screen->Clear();
}
- for (unsigned i = 0; i < m_visible.length(); ++i) {
+ for (int i = 0; i < m_visible.length(); ++i) {
UIPanel *panel = m_visible[i];
panel->Draw();
diff --git a/screenlib/UIPanel.cpp b/screenlib/UIPanel.cpp
index 699cca65..39e50d68 100644
--- a/screenlib/UIPanel.cpp
+++ b/screenlib/UIPanel.cpp
@@ -115,7 +115,7 @@ UIPanel::Hide()
void
UIPanel::HideAll()
{
- for (unsigned i = 0; i < m_elements.length(); ++i) {
+ for (int i = 0; i < m_elements.length(); ++i) {
m_elements[i]->Hide();
}
}