diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..1329f0102ed --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: c +dist: +# precise doesn't have `qtscript5-dev` +- trusty +- xenial +install: +- sudo apt-get update +- sudo apt-get build-dep warzone2100 +- sudo apt-get install qtscript5-dev libsdl2-dev libharfbuzz-dev +script: +- export MAKEFLAGS="-j$((`grep -c ^processor /proc/cpuinfo`*2))" +- ./autogen.sh && ./configure && make && make check && sudo make install diff --git a/lib/exceptionhandler/exceptionhandler.cpp b/lib/exceptionhandler/exceptionhandler.cpp index f8ee98244f3..723c8a74ef9 100644 --- a/lib/exceptionhandler/exceptionhandler.cpp +++ b/lib/exceptionhandler/exceptionhandler.cpp @@ -142,8 +142,6 @@ static LONG WINAPI windowsExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) # define MAX_BACKTRACE 20 # endif -#define write(x, y, z) abs(write(x, y, z)) // HACK Squelch unused result warning. - # define MAX_PID_STRING 16 # define MAX_DATE_STRING 256 @@ -382,6 +380,33 @@ static void setFatalSignalHandler(SigActionHandler signalHandler) #endif // _XOPEN_UNIX } +static ssize_t writeAll(int const fd, const char* const str) +{ + size_t const to_write = strlen(str); + size_t written = 0; + while (written < to_write) + { + ssize_t ret = write(fd, str + written, to_write - written); + if (ret == -1) + { + switch (errno) + { + case EAGAIN: +#if defined(EWOULDBLOCK) && EAGAIN != EWOULDBLOCK + case EWOULDBLOCK: +#endif + case EINTR: + continue; + default: + return -1; + } + } + written += ret; + } + + return written; +} + /** * Spawn a new GDB process and attach it to the current process. * @@ -415,18 +440,15 @@ static pid_t execGdb(int const dumpFile, int *gdbWritePipe) if (!programIsAvailable || !gdbIsAvailable) { - write(dumpFile, "No extended backtrace dumped:\n", - strlen("No extended backtrace dumped:\n")); + writeAll(dumpFile, "No extended backtrace dumped:\n"); if (!programIsAvailable) { - write(dumpFile, "- Program path not available\n", - strlen("- Program path not available\n")); + writeAll(dumpFile, "- Program path not available\n"); } if (!gdbIsAvailable) { - write(dumpFile, "- GDB not available\n", - strlen("- GDB not available\n")); + writeAll(dumpFile, "- GDB not available\n"); } return 0; @@ -435,8 +457,7 @@ static pid_t execGdb(int const dumpFile, int *gdbWritePipe) // Create a pipe to use for communication with 'gdb' if (pipe(gdbPipe) == -1) { - write(dumpFile, "Pipe failed\n", - strlen("Pipe failed\n")); + writeAll(dumpFile, "Pipe failed\n"); printf("Pipe failed\n"); @@ -447,8 +468,7 @@ static pid_t execGdb(int const dumpFile, int *gdbWritePipe) pid = fork(); if (pid == -1) { - write(dumpFile, "Fork failed\n", - strlen("Fork failed\n")); + writeAll(dumpFile, "Fork failed\n"); printf("Fork failed\n"); @@ -478,8 +498,7 @@ static pid_t execGdb(int const dumpFile, int *gdbWritePipe) dup2(gdbPipe[0], STDIN_FILENO); // STDIN from pipe dup2(dumpFile, STDOUT_FILENO); // STDOUT to dumpFile - write(dumpFile, "GDB extended backtrace:\n", - strlen("GDB extended backtrace:\n")); + writeAll(dumpFile, "GDB extended backtrace:\n"); /* If execve() is successful it effectively prevents further * execution of this function. @@ -487,8 +506,7 @@ static pid_t execGdb(int const dumpFile, int *gdbWritePipe) execve(gdbPath, (char **)gdbArgv, (char **)gdbEnv); // If we get here it means that execve failed! - write(dumpFile, "execcv(\"gdb\") failed\n", - strlen("execcv(\"gdb\") failed\n")); + writeAll(dumpFile, "execcv(\"gdb\") failed\n"); // Terminate the child, indicating failure _exit(1); @@ -574,7 +592,7 @@ static bool gdbExtendedBacktrace(int const dumpFile) "disassemble /m\n", frame); } - write(gdbPipe, gdbCommands, strlen(gdbCommands)); + writeAll(gdbPipe, gdbCommands); /* Flush our end of the pipe to make sure that GDB has all commands * directly available to it. @@ -590,8 +608,7 @@ static bool gdbExtendedBacktrace(int const dumpFile) // waitpid(): on error, -1 is returned if (wpid == -1) { - write(dumpFile, "GDB failed\n", - strlen("GDB failed\n")); + writeAll(dumpFile, "GDB failed\n"); printf("GDB failed\n"); return false; @@ -612,8 +629,7 @@ static bool gdbExtendedBacktrace(int const dumpFile) if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - write(dumpFile, "GDB failed\n", - strlen("GDB failed\n")); + writeAll(dumpFile, "GDB failed\n"); printf("GDB failed\n"); return false; @@ -671,23 +687,22 @@ static void posixExceptionHandler(int signum) dbgDumpHeader(dumpFile); #ifdef SA_SIGINFO - write(dumpFile, "Dump caused by signal: ", strlen("Dump caused by signal: ")); + writeAll(dumpFile, "Dump caused by signal: "); signal = wz_strsignal(siginfo->si_signo, siginfo->si_code); - write(dumpFile, signal, strlen(signal)); - write(dumpFile, "\n\n", 2); + writeAll(dumpFile, signal); + writeAll(dumpFile, "\n\n"); #endif dbgDumpLog(dumpFile); // dump out the last several log calls # if defined(__GLIBC__) // Dump raw backtrace in case GDB is not available or fails - write(dumpFile, "GLIBC raw backtrace:\n", strlen("GLIBC raw backtrace:\n")); + writeAll(dumpFile, "GLIBC raw backtrace:\n"); backtrace_symbols_fd(btBuffer, btSize, dumpFile); - write(dumpFile, "\n", 1); + writeAll(dumpFile, "\n"); # else - write(dumpFile, "GLIBC not available, no raw backtrace dumped\n\n", - strlen("GLIBC not available, no raw backtrace dumped\n\n")); + writeAll(dumpFile, "GLIBC not available, no raw backtrace dumped\n\n"); # endif diff --git a/lib/qtgame/wzapp_qt.cpp b/lib/qtgame/wzapp_qt.cpp index 2f23c15288d..a511e70cdef 100644 --- a/lib/qtgame/wzapp_qt.cpp +++ b/lib/qtgame/wzapp_qt.cpp @@ -131,7 +131,7 @@ static QImage loadQImage(char const *fileName, char const *format = nullptr) data.resize(lengthRead); QImage image; image.loadFromData(&data[0], data.size(), format); - return std::move(image); + return image; } data.resize(data.size() + 16384); } diff --git a/lib/widget/button.h b/lib/widget/button.h index 21462b35c1e..38cf87bd516 100644 --- a/lib/widget/button.h +++ b/lib/widget/button.h @@ -65,14 +65,8 @@ class W_BUTTON : public WIDGET void setImages(Images const &images); void setImages(Image image, Image imageDown, Image imageHighlight, Image imageDisabled = Image()); - void setString(char const *stringUtf8) - { - WIDGET::setString(stringUtf8); // Unhide the WIDGET::setString(char const *) function... - } - void setTip(char const *stringUtf8) - { - WIDGET::setTip(stringUtf8); // Unhide the WIDGET::setTip(char const *) function... - } + using WIDGET::setString; + using WIDGET::setTip; signals: void clicked(); @@ -99,6 +93,8 @@ class StateButton : public W_BUTTON void setTip(int state, char const *stringUtf8); void setImages(int state, Images const &images); + using WIDGET::setTip; + private: int currentState; std::map tips; diff --git a/lib/widget/form.h b/lib/widget/form.h index 6e75de25854..ab590ad4b88 100644 --- a/lib/widget/form.h +++ b/lib/widget/form.h @@ -63,14 +63,8 @@ class W_CLICKFORM : public W_FORM void setFlash(bool enable); void setTip(QString string); - void setString(char const *stringUtf8) - { - WIDGET::setString(stringUtf8); // Unhide the WIDGET::setString(char const *) function... - } - void setTip(char const *stringUtf8) - { - WIDGET::setTip(stringUtf8); // Unhide the WIDGET::setTip(char const *) function... - } + using WIDGET::setString; + using WIDGET::setTip; bool isDown() const; bool isHighlighted() const; diff --git a/lib/widget/label.h b/lib/widget/label.h index 81543ac275d..c3e11202e22 100644 --- a/lib/widget/label.h +++ b/lib/widget/label.h @@ -60,14 +60,8 @@ class W_LABEL : public WIDGET } void setTextAlignment(WzTextAlignment align); - void setString(char const *stringUtf8) - { - WIDGET::setString(stringUtf8); // Unhide the WIDGET::setString(char const *) function... - } - void setTip(char const *stringUtf8) - { - WIDGET::setTip(stringUtf8); // Unhide the WIDGET::setTip(char const *) function... - } + using WIDGET::setString; + using WIDGET::setTip; QString aText; // Text on the label iV_fonts FontID; diff --git a/src/fpath.cpp b/src/fpath.cpp index 55566030e92..84f3793bfc2 100644 --- a/src/fpath.cpp +++ b/src/fpath.cpp @@ -398,7 +398,7 @@ static FPATH_RETVAL fpathRoute(MOVE_CONTROL *psMove, unsigned id, int startX, in fpathRemoveDroidData(id); packagedPathJob task([job]() { return fpathExecute(job); }); - pathResults[id] = std::move(task.get_future()); + pathResults[id] = task.get_future(); // Add to end of list wzMutexLock(fpathMutex); diff --git a/src/game.cpp b/src/game.cpp index 5252639e96e..0210ca7ae3b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4466,7 +4466,7 @@ static bool loadSaveDroid(const char *pFileName, DROID **ppsCurrentDroidLists) /* Create the Droid */ turnOffMultiMsg(true); psDroid = reallyBuildDroid(psTemplate, pos, player, onMission, rot); - ASSERT_OR_RETURN(NULL, psDroid != NULL, "Failed to build unit %s", sortedList[i].second.toUtf8().constData()); + ASSERT_OR_RETURN(false, psDroid != NULL, "Failed to build unit %s", sortedList[i].second.toUtf8().constData()); turnOffMultiMsg(false); // Copy the values across diff --git a/src/intimage.cpp b/src/intimage.cpp index fbba4044b22..789494d7c31 100644 --- a/src/intimage.cpp +++ b/src/intimage.cpp @@ -77,38 +77,6 @@ struct IMAGEFRAME IMAGEFILE *IntImages; // All the 2d graphics for the user interface. -static const uint16_t MousePointerImageIDs[CURSOR_MAX] = -{ - IMAGE_CURSOR_DEFAULT, // CURSOR_ARROW - IMAGE_CURSOR_DEST, // CURSOR_DEST - IMAGE_CURSOR_DEFAULT, // CURSOR_SIGHT - IMAGE_CURSOR_DEFAULT, // CURSOR_TARGET - IMAGE_CURSOR_DEFAULT, // CURSOR_LARROW - IMAGE_CURSOR_DEFAULT, // CURSOR_RARROW - IMAGE_CURSOR_DEFAULT, // CURSOR_DARROW - IMAGE_CURSOR_DEFAULT, // CURSOR_UARROW - IMAGE_CURSOR_DEFAULT, // CURSOR_DEFAULT - IMAGE_CURSOR_DEFAULT, // CURSOR_EDGEOFMAP - IMAGE_CURSOR_ATTACH, // CURSOR_ATTACH - IMAGE_CURSOR_ATTACK, // CURSOR_ATTACK - IMAGE_CURSOR_BOMB, // CURSOR_BOMB - IMAGE_CURSOR_BRIDGE, // CURSOR_BRIDGE - IMAGE_CURSOR_BUILD, // CURSOR_BUILD - IMAGE_CURSOR_EMBARK, // CURSOR_EMBARK - IMAGE_CURSOR_DISEMBARK, // CURSOR_DISEMBARK - IMAGE_CURSOR_FIX, // CURSOR_FIX - IMAGE_CURSOR_GUARD, // CURSOR_GUARD - IMAGE_CURSOR_ECM, // CURSOR_JAM - IMAGE_CURSOR_LOCKON, // CURSOR_LOCKON - IMAGE_CURSOR_SCOUT, // CURSOR_SCOUT - IMAGE_CURSOR_DEFAULT, // CURSOR_MENU - IMAGE_CURSOR_MOVE, // CURSOR_MOVE - IMAGE_CURSOR_NOTPOS, // CURSOR_NOTPOSSIBLE - IMAGE_CURSOR_PICKUP, // CURSOR_PICKUP - IMAGE_CURSOR_REPAIR, // CURSOR_SEEKREPAIR - IMAGE_CURSOR_SELECT, // CURSOR_SELECT -}; - /** Form frame definition for normal frames. */ IMAGEFRAME FrameNormal = { diff --git a/src/scriptobj.cpp b/src/scriptobj.cpp index dbbb6ef1003..1dfac402685 100644 --- a/src/scriptobj.cpp +++ b/src/scriptobj.cpp @@ -50,9 +50,6 @@ #include "scriptvals.h" #include "research.h" -// Marks a NULL pointer for the script value save/load routines -static const int UNALLOCATED_OBJECT = -1; - static INTERP_VAL scrFunctionResult; //function return value to be pushed to stack // Get values from a base object diff --git a/src/scripttabs.cpp b/src/scripttabs.cpp index be34dd2c6cf..19248edf8a6 100644 --- a/src/scripttabs.cpp +++ b/src/scripttabs.cpp @@ -108,7 +108,7 @@ TYPE_SYMBOL asTypeTable[] = { "", (INTERP_TYPE)ST_POINTER_STRUCTSTAT, AT_SIMPLE, NULL, NULL }, //for NULLSTRUCTURESTAT /* This final entry marks the end of the type list */ - { "END OF TYPE LIST", (INTERP_TYPE)NULL, AT_SIMPLE, NULL, NULL }, + { "END OF TYPE LIST", (INTERP_TYPE)0, AT_SIMPLE, NULL, NULL }, }; diff --git a/src/stats.cpp b/src/stats.cpp index 993c97fc2da..605f5c11e97 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -114,11 +114,6 @@ static void updateMaxECMStats(UWORD maxValue); static void updateMaxBodyStats(UWORD maxBody, UWORD maxPower, UWORD maxArmour); static void updateMaxConstStats(UWORD maxValue); -static inline bool stringToEnumFindFunction(std::pair const &a, char const *b) -{ - return strcmp(a.first, b) < 0; -} - /*********************************************************************************** * Dealloc the extra storage tables ***********************************************************************************/ diff --git a/src/terrain.cpp b/src/terrain.cpp index 13528b86fed..6026a490eea 100644 --- a/src/terrain.cpp +++ b/src/terrain.cpp @@ -344,13 +344,6 @@ static void getGridPos(Vector3i *result, int x, int y, bool center, bool water) } } -/// Get the texture coordinates for the map position -static inline void getTexCoords(Vector2f *uv, float x, float y, int groundType) -{ - uv->x = (x / psGroundTypes[groundType].textureSize); - uv->y = (y / psGroundTypes[groundType].textureSize); -} - /// Calculate the average colour of 4 points static inline void averageColour(PIELIGHT *average, PIELIGHT a, PIELIGHT b, PIELIGHT c, PIELIGHT d)