Skip to content

Commit

Permalink
Merge remote-tracking branches 'amdmi3/patch-1', 'krichter722/travis'…
Browse files Browse the repository at this point in the history
… and 'muggenhor/warn-fixes'
  • Loading branch information
Cyp committed Mar 7, 2017
4 parents 3509ccc + 3b4b826 + 447e6e9 + 4c1a0de commit cfc0ed3
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 103 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
71 changes: 43 additions & 28 deletions lib/exceptionhandler/exceptionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
Expand All @@ -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");

Expand All @@ -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");

Expand Down Expand Up @@ -478,17 +498,15 @@ 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.
*/
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);
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion lib/qtgame/wzapp_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 4 additions & 8 deletions lib/widget/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<int, QString> tips;
Expand Down
10 changes: 2 additions & 8 deletions lib/widget/form.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 2 additions & 8 deletions lib/widget/label.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/fpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 0 additions & 32 deletions src/intimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
{
Expand Down
3 changes: 0 additions & 3 deletions src/scriptobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/scripttabs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
};


Expand Down
5 changes: 0 additions & 5 deletions src/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char const *, unsigned> const &a, char const *b)
{
return strcmp(a.first, b) < 0;
}

/***********************************************************************************
* Dealloc the extra storage tables
***********************************************************************************/
Expand Down
7 changes: 0 additions & 7 deletions src/terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cfc0ed3

Please sign in to comment.