From de8bf651f2155d007ca7320e94722fe3b716bb70 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 14 Sep 2011 23:24:32 +0000 Subject: [PATCH] - Fix warnings reported by gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) SVN r3293 (trunk) --- src/p_teleport.cpp | 4 +- src/r_data/voxels.cpp | 5 +- src/resourcefiles/file_directory.cpp | 10 ++-- src/sdl/i_main.cpp | 19 ++++++- src/sdl/i_system.cpp | 76 ++++++++++++++++++++++++++++ src/thingdef/thingdef_codeptr.cpp | 2 +- 6 files changed, 103 insertions(+), 13 deletions(-) diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 59359a981..6d3969234 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -513,9 +513,9 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO while (P_PointOnLineSide(x, y, l) != side && --fudge >= 0) { if (abs(l->dx) > abs(l->dy)) - y -= l->dx < 0 != side ? -1 : 1; + y -= (l->dx < 0) != side ? -1 : 1; else - x += l->dy < 0 != side ? -1 : 1; + x += (l->dy < 0) != side ? -1 : 1; } // Adjust z position to be same height above ground as before. diff --git a/src/r_data/voxels.cpp b/src/r_data/voxels.cpp index bbfe706e8..50705c5cc 100644 --- a/src/r_data/voxels.cpp +++ b/src/r_data/voxels.cpp @@ -417,8 +417,6 @@ void FVoxel::Remap() static bool VOX_ReadSpriteNames(FScanner &sc, TArray &vsprites) { - unsigned int i; - vsprites.Clear(); while (sc.GetString()) { @@ -442,8 +440,7 @@ static bool VOX_ReadSpriteNames(FScanner &sc, TArray &vsprites) else { int frame = (sc.StringLen == 4) ? 255 : sc.String[4] - 'A'; - - i = GetSpriteIndex(sc.String, false); + int i = GetSpriteIndex(sc.String, false); if (i != -1) { vsprites.Push((frame << 24) | i); diff --git a/src/resourcefiles/file_directory.cpp b/src/resourcefiles/file_directory.cpp index 89fb2be9c..420b7dde3 100644 --- a/src/resourcefiles/file_directory.cpp +++ b/src/resourcefiles/file_directory.cpp @@ -186,7 +186,7 @@ int FDirectory::AddDirectory(const char *dirpath) { if (strstr(fileinfo.name, ".orig") || strstr(fileinfo.name, ".bak")) { - // We shuuldn't add backup files to the lump directory + // We shouldn't add backup files to the lump directory continue; } @@ -211,8 +211,8 @@ int FDirectory::AddDirectory(const char *dirpath) DIR* directory = opendir(scanDirectories[i].GetChars()); if (directory == NULL) { - Printf("Could not ready directory: %s\n", strerror(errno)); - return NULL; + Printf("Could not read directory: %s\n", strerror(errno)); + return 0; } struct dirent *file; @@ -250,7 +250,7 @@ int FDirectory::AddDirectory(const char *dirpath) int FDirectory::AddDirectory(const char *dirpath) { - char *argv [2] = {NULL, NULL }; + char *argv [2] = { NULL, NULL }; argv[0] = new char[strlen(dirpath)+1]; strcpy(argv[0], dirpath); FTS *fts; @@ -261,7 +261,7 @@ int FDirectory::AddDirectory(const char *dirpath) if (fts == NULL) { Printf("Failed to start directory traversal: %s\n", strerror(errno)); - return NULL; + return 0; } while ((ent = fts_read(fts)) != NULL) { diff --git a/src/sdl/i_main.cpp b/src/sdl/i_main.cpp index d80d8a430..3b2de3c57 100644 --- a/src/sdl/i_main.cpp +++ b/src/sdl/i_main.cpp @@ -81,6 +81,10 @@ extern "C" int cc_install_handlers(int, char**, int, int*, const char*, int(*)(c // EXTERNAL DATA DECLARATIONS ---------------------------------------------- +#ifdef USE_XCURSOR +extern bool UseXCursor; +#endif + // PUBLIC DATA DEFINITIONS ------------------------------------------------- #ifndef NO_GTK @@ -256,7 +260,7 @@ int main (int argc, char **argv) cc_install_handlers(argc, argv, 4, s, "zdoom-crash.log", DoomSpecificInfo); } - printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n\n", + printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n", DOTVERSIONSTR_NOREV,SVN_REVISION_STRING,__DATE__); seteuid (getuid ()); @@ -279,6 +283,19 @@ int main (int argc, char **argv) } atterm (SDL_Quit); + { + char viddriver[80]; + + if (SDL_VideoDriverName(viddriver, sizeof(viddriver)) != NULL) + { + printf("Using video driver %s\n", viddriver); +#ifdef USE_XCURSOR + UseXCursor = (strcmp(viddriver, "x11") == 0); +#endif + } + printf("\n"); + } + SDL_WM_SetCaption (GAMESIG " " DOTVERSIONSTR " (" __DATE__ ")", NULL); try diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index ecaf1a26e..55ba296b6 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -79,6 +79,13 @@ #include "m_fixed.h" #include "g_level.h" +#ifdef USE_XCURSOR +// Xlib has its own GC, so don't let it interfere. +#define GC XGC +#include +#undef GC +#endif + EXTERN_CVAR (String, language) extern "C" @@ -92,6 +99,11 @@ extern bool GtkAvailable; #elif defined(__APPLE__) int I_PickIWad_Cocoa (WadStuff *wads, int numwads, bool showwin, int defaultiwad); #endif +#ifdef USE_XCURSOR +bool UseXCursor; +SDL_Cursor *X11Cursor; +SDL_Cursor *FirstCursor; +#endif DWORD LanguageIDs[4] = { @@ -830,6 +842,47 @@ unsigned int I_MakeRNGSeed() return seed; } +#ifdef USE_XCURSOR +// Hack! Hack! SDL does not provide a clean way to get the XDisplay. +// On the other hand, there are no more planned updates for SDL 1.2, +// so we should be fine making assumptions. +struct SDL_PrivateVideoData +{ + int local_X11; + Display *X11_Display; +}; + +struct SDL_VideoDevice +{ + const char *name; + int (*functions)()[9]; + SDL_VideoInfo info; + SDL_PixelFormat *displayformatalphapixel; + int (*morefuncs)()[9]; + Uint16 *gamma; + int (*somefuncs)()[9]; + unsigned int texture; // Only here if SDL was compiled with OpenGL support. Ack! + int is_32bit; + int (*itsafuncs)()[13]; + SDL_Surface *surfaces[3]; + SDL_Palette *physpal; + SDL_Color *gammacols; + char *wm_strings[2]; + int offsets[2]; + SDL_GrabMode input_grab; + int handles_any_size; + SDL_PrivateVideoData *hidden; // Why did they have to bury this so far in? +}; + +extern SDL_VideDevice *current_video; +#define SDL_Display (current_video->hidden->X11_Display) + +SDL_Cursor *CreateColorCursor(FTexture *cursorpic) +{ + return NULL; +} +#endif + SDL_Surface *cursorSurface = NULL; SDL_Rect cursorBlit = {0, 0, 32, 32}; bool I_SetCursor(FTexture *cursorpic) @@ -842,6 +895,21 @@ bool I_SetCursor(FTexture *cursorpic) return false; } +#ifdef USE_XCURSOR + if (UseXCursor) + { + if (FirstCursor == NULL) + { + FirstCursor = SDL_GetCursor(); + } + X11Cursor = CreateColorCursor(cursorpic); + if (X11Cursor != NULL) + { + SDL_SetCursor(X11Cursor); + return true; + } + } +#endif if (cursorSurface == NULL) cursorSurface = SDL_CreateRGBSurface (0, 32, 32, 32, MAKEARGB(0,255,0,0), MAKEARGB(0,0,255,0), MAKEARGB(0,0,0,255), MAKEARGB(255,0,0,0)); @@ -863,6 +931,14 @@ bool I_SetCursor(FTexture *cursorpic) SDL_FreeSurface(cursorSurface); cursorSurface = NULL; } +#ifdef USE_XCURSOR + if (X11Cursor != NULL) + { + SDL_SetCursor(FirstCursor); + SDL_FreeCursor(X11Cursor); + X11Cursor = NULL; + } +#endif } return true; } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index e1c5e1363..965d4de08 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3888,7 +3888,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) if (dpuff->flags2 & MF2_THRUGHOST && self->target->flags3 & MF3_GHOST) damage = 0; - if (0 && dpuff->flags3 & MF3_PUFFONACTORS || !spawnblood) + if ((0 && dpuff->flags3 & MF3_PUFFONACTORS) || !spawnblood) { spawnblood = false; P_SpawnPuff(self, pufftype, dx, dy, dz, angle, 0);