https://github.com/libsdl-org/Maelstrom/commit/6ad250e00e5d0aa446700aabe70e96bd3e5d5aff
From 6ad250e00e5d0aa446700aabe70e96bd3e5d5aff Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 23 Oct 2011 10:29:40 -0400
Subject: [PATCH] Miscellaneous cleanup
---
Maelstrom-netd.c | 7 ++++---
UI/loading.xml | 2 +-
UIElementLabel.cpp | 1 +
controls.cpp | 1 -
init.cpp | 3 ---
load.cpp | 4 ++--
main.cpp | 2 +-
screenlib/SDL_FrameBuf.cpp | 2 +-
screenlib/UIArea.h | 4 ++++
screenlib/UIPanel.h | 3 +++
10 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/Maelstrom-netd.c b/Maelstrom-netd.c
index fa4be99c..cd4ad850 100644
--- a/Maelstrom-netd.c
+++ b/Maelstrom-netd.c
@@ -130,7 +130,7 @@ void CheckNewGame(void)
sprintf(message,
"There are %d, not %d players in this game",
numplayers, players[i].numplayers);
- SendError(i, buffer);
+ SendError(i, (char*)buffer);
}
}
@@ -184,7 +184,7 @@ void I_Crashed(int sig)
exit(sig);
}
-main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
int netfd, i, slot;
struct sockaddr_in serv_addr;
@@ -258,7 +258,8 @@ printf("Waiting for players...\n");
/* Check for new players first */
if ( FD_ISSET(netfd, &fdset) ) {
- int sockfd, clilen;
+ int sockfd;
+ socklen_t clilen;
for ( i=0; i<MAX_CONNECTIONS; ++i ) {
if ( players[i].state == UNCONNECTED )
diff --git a/UI/loading.xml b/UI/loading.xml
index d52a9357..54ce8163 100644
--- a/UI/loading.xml
+++ b/UI/loading.xml
@@ -44,7 +44,7 @@
</Label>
<!-- Loading Bar -->
- <Rectangle name="loadingBar">
+ <Rectangle>
<Color r="0x00" g="0x00" b="0x00"/>
<Size w="200" h="10"/>
<Anchor anchorFrom="CENTER" anchorTo="CENTER" y="185"/>
diff --git a/UIElementLabel.cpp b/UIElementLabel.cpp
index 06153d83..83082259 100644
--- a/UIElementLabel.cpp
+++ b/UIElementLabel.cpp
@@ -30,6 +30,7 @@ static Uint8 ParseStyle(const char *text)
} else if (strcasecmp(text, "italic") == 0) {
style = STYLE_ITALIC;
}
+ return style;
}
bool
diff --git a/controls.cpp b/controls.cpp
index 9e31f34f..d92fc8fe 100644
--- a/controls.cpp
+++ b/controls.cpp
@@ -71,7 +71,6 @@ void KeyName(SDL_Keycode keycode, char *namebuf)
static FILE *OpenData(const char *mode, char **fname)
{
static char datafile[BUFSIZ];
- const char *home;
FILE *data;
if ( fname ) {
diff --git a/init.cpp b/init.cpp
index ff77bcae..4412c3d1 100644
--- a/init.cpp
+++ b/init.cpp
@@ -614,8 +614,6 @@ static void BuildVelocityTable(void)
*/
void CleanUp(void)
{
- int i;
-
HaltLogic();
if ( ui ) {
delete ui;
@@ -643,7 +641,6 @@ void CleanUp(void)
/* -- Perform some initializations and report failure if we choke */
int DoInitializations(Uint32 window_flags, Uint32 render_flags)
{
- UIPanel *panel;
Uint32 start;
int i;
SDL_Surface *icon;
diff --git a/load.cpp b/load.cpp
index 1dd2a919..28e3457f 100644
--- a/load.cpp
+++ b/load.cpp
@@ -46,14 +46,14 @@ SDL_Texture *GetCIcon(FrameBuf *screen, short cicn_id)
w = SDL_ReadBE16(cicn_src);
h = SDL_ReadBE16(cicn_src);
pixels = new Uint8[w*h];
- if ( SDL_RWread(cicn_src, pixels, 1, w*h) != (w*h) ) {
+ if ( SDL_RWread(cicn_src, pixels, 1, w*h) != size_t(w*h) ) {
error("GetCIcon(%hd): Corrupt CICN!\n", cicn_id);
delete[] pixels;
SDL_RWclose(cicn_src);
return(NULL);
}
mask = new Uint8[(w/8)*h];
- if ( SDL_RWread(cicn_src, mask, 1, (w/8)*h) != ((w/8)*h) ) {
+ if ( SDL_RWread(cicn_src, mask, 1, (w/8)*h) != size_t((w/8)*h) ) {
error("GetCIcon(%hd): Corrupt CICN!\n", cicn_id);
delete[] pixels;
delete[] mask;
diff --git a/main.cpp b/main.cpp
index b7884f8d..0810fffc 100644
--- a/main.cpp
+++ b/main.cpp
@@ -123,7 +123,7 @@ static void RunSpeedTest(void)
const int test_reps = 100; /* How many full cycles to run */
Uint32 then, now;
- int i, frame, x=((640/2)-16), y=((480/2)-16), onscreen=0;
+ int i, frame, x=((640/2)-16), y=((480/2)-16);
then = SDL_GetTicks();
for ( i=0; i<test_reps; ++i ) {
diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index a190e6c9..9e6f1b05 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -131,7 +131,7 @@ void
FrameBuf:: Fade(void)
{
// Temporary for development
-//return;
+return;
const int max = 32;
Uint16 ramp[256];
diff --git a/screenlib/UIArea.h b/screenlib/UIArea.h
index b1fe7348..44771e54 100644
--- a/screenlib/UIArea.h
+++ b/screenlib/UIArea.h
@@ -80,6 +80,10 @@ class UIArea : public ErrorBase
m_rect.h = h;
CalculateAnchor();
}
+ bool ContainsPoint(int x, int y) const {
+ return (x >= m_rect.x && x < m_rect.x+m_rect.w &&
+ y >= m_rect.y && y < m_rect.y+m_rect.h);
+ }
FrameBuf *GetScreen() const {
return m_screen;
diff --git a/screenlib/UIPanel.h b/screenlib/UIPanel.h
index 10d0dec3..350ddb4d 100644
--- a/screenlib/UIPanel.h
+++ b/screenlib/UIPanel.h
@@ -41,6 +41,9 @@ class UIPanel : public UIArea
UIPanel(UIManager *ui, const char *name);
virtual ~UIPanel();
+ UIManager *GetUI() const {
+ return m_ui;
+ }
const char *GetName() const {
return m_name;
}