mirror of
https://github.com/cxong/cdogs-sdl.git
synced 2025-07-23 07:23:01 +02:00
Fix GCC10 build errors (fixes #645)
This commit is contained in:
15
.gitignore
vendored
15
.gitignore
vendored
@@ -4,17 +4,7 @@ src/cdogs-sdl
|
||||
src/cdogs-sdl-editor
|
||||
cdogs-sdl.opk
|
||||
# tests
|
||||
src/tests/autosave_test
|
||||
src/tests/c_array_test
|
||||
src/tests/c_hashmap_test
|
||||
src/tests/color_test
|
||||
src/tests/config_test
|
||||
src/tests/json_test
|
||||
src/tests/minkowski_hex_test
|
||||
src/tests/pic_test
|
||||
src/tests/player_test
|
||||
src/tests/utils_test
|
||||
src/cdogs/physfs/test_physfs
|
||||
*_test
|
||||
|
||||
# CMake stuff
|
||||
*CMakeCache.txt
|
||||
@@ -78,6 +68,9 @@ CMakeScripts/
|
||||
.idea/
|
||||
*.cbp
|
||||
|
||||
# VS Code
|
||||
.vscode/
|
||||
|
||||
# GCW-Zero
|
||||
gcw0build/
|
||||
gcw0-toolchain/
|
||||
|
@@ -24,14 +24,14 @@ addons:
|
||||
- libsdl2-mixer-dev
|
||||
- clang-9
|
||||
- cmake
|
||||
- gcc-9
|
||||
- g++-9
|
||||
- gcc-10
|
||||
- g++-10
|
||||
- libgtk-3-dev
|
||||
- ninja-build
|
||||
|
||||
install:
|
||||
# /usr/bin/gcc points to an older compiler on both Linux and macOS.
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-9" CC="gcc-9"; fi
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-10" CC="gcc-10"; fi
|
||||
# /usr/bin/clang points to an older compiler on both Linux and macOS.
|
||||
#
|
||||
# Homebrew's llvm package doesn't ship a versioned clang++ binary, so the values
|
||||
|
@@ -24,14 +24,14 @@ addons:
|
||||
- libsdl2-mixer-dev
|
||||
- clang-9
|
||||
- cmake
|
||||
- gcc-9
|
||||
- g++-9
|
||||
- gcc-10
|
||||
- g++-10
|
||||
- libgtk-3-dev
|
||||
- ninja-build
|
||||
|
||||
install:
|
||||
# /usr/bin/gcc points to an older compiler on both Linux and macOS.
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-9" CC="gcc-9"; fi
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-10" CC="gcc-10"; fi
|
||||
# /usr/bin/clang points to an older compiler on both Linux and macOS.
|
||||
#
|
||||
# Homebrew's llvm package doesn't ship a versioned clang++ binary, so the values
|
||||
|
@@ -86,7 +86,7 @@ static const Node NodeNull = {NULL, -1};
|
||||
|
||||
/********************************************/
|
||||
|
||||
static inline VisitedNodes VisitedNodesCreate(const ASPathNodeSource *source, void *context)
|
||||
static VisitedNodes VisitedNodesCreate(const ASPathNodeSource *source, void *context)
|
||||
{
|
||||
VisitedNodes nodes;
|
||||
CCALLOC(nodes, sizeof(struct __VisitedNodes));
|
||||
@@ -95,7 +95,7 @@ static inline VisitedNodes VisitedNodesCreate(const ASPathNodeSource *source, vo
|
||||
return nodes;
|
||||
}
|
||||
|
||||
static inline void VisitedNodesDestroy(VisitedNodes visitedNodes)
|
||||
static void VisitedNodesDestroy(VisitedNodes visitedNodes)
|
||||
{
|
||||
CFREE(visitedNodes->nodeRecordsIndex);
|
||||
CFREE(visitedNodes->nodeRecords);
|
||||
@@ -103,12 +103,12 @@ static inline void VisitedNodesDestroy(VisitedNodes visitedNodes)
|
||||
CFREE(visitedNodes);
|
||||
}
|
||||
|
||||
static inline int NodeIsNull(Node n)
|
||||
static int NodeIsNull(Node n)
|
||||
{
|
||||
return (n.nodes == NodeNull.nodes) && (n.index == NodeNull.index);
|
||||
}
|
||||
|
||||
static inline Node NodeMake(VisitedNodes nodes, size_t idx)
|
||||
static Node NodeMake(VisitedNodes nodes, size_t idx)
|
||||
{
|
||||
Node n;
|
||||
memset(&n, 0, sizeof n);
|
||||
@@ -117,72 +117,72 @@ static inline Node NodeMake(VisitedNodes nodes, size_t idx)
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline NodeRecord *NodeGetRecord(Node node)
|
||||
static NodeRecord *NodeGetRecord(Node node)
|
||||
{
|
||||
return (NodeRecord *)((char *)node.nodes->nodeRecords + (node.index * (node.nodes->source->nodeSize + sizeof(NodeRecord))));
|
||||
}
|
||||
|
||||
static inline void *GetNodeKey(Node node)
|
||||
static void *GetNodeKey(Node node)
|
||||
{
|
||||
return NodeGetRecord(node)->nodeKey;
|
||||
}
|
||||
|
||||
static inline int NodeIsInOpenSet(Node n)
|
||||
static int NodeIsInOpenSet(Node n)
|
||||
{
|
||||
return NodeGetRecord(n)->isOpen;
|
||||
}
|
||||
|
||||
static inline int NodeIsInClosedSet(Node n)
|
||||
static int NodeIsInClosedSet(Node n)
|
||||
{
|
||||
return NodeGetRecord(n)->isClosed;
|
||||
}
|
||||
|
||||
static inline void RemoveNodeFromClosedSet(Node n)
|
||||
static void RemoveNodeFromClosedSet(Node n)
|
||||
{
|
||||
NodeGetRecord(n)->isClosed = 0;
|
||||
}
|
||||
|
||||
static inline void AddNodeToClosedSet(Node n)
|
||||
static void AddNodeToClosedSet(Node n)
|
||||
{
|
||||
NodeGetRecord(n)->isClosed = 1;
|
||||
}
|
||||
|
||||
static inline float GetNodeRank(Node n)
|
||||
static float GetNodeRank(Node n)
|
||||
{
|
||||
NodeRecord *record = NodeGetRecord(n);
|
||||
return record->estimatedCost + record->cost;
|
||||
}
|
||||
|
||||
static inline float GetNodeCost(Node n)
|
||||
static float GetNodeCost(Node n)
|
||||
{
|
||||
return NodeGetRecord(n)->cost;
|
||||
}
|
||||
|
||||
static inline void SetNodeEstimatedCost(Node n, float estimatedCost)
|
||||
static void SetNodeEstimatedCost(Node n, float estimatedCost)
|
||||
{
|
||||
NodeRecord *record = NodeGetRecord(n);
|
||||
record->estimatedCost = estimatedCost;
|
||||
record->hasEstimatedCost = 1;
|
||||
}
|
||||
|
||||
static inline int NodeHasEstimatedCost(Node n)
|
||||
static int NodeHasEstimatedCost(Node n)
|
||||
{
|
||||
return NodeGetRecord(n)->hasEstimatedCost;
|
||||
}
|
||||
|
||||
static inline void SetNodeIsGoal(Node n)
|
||||
static void SetNodeIsGoal(Node n)
|
||||
{
|
||||
if (!NodeIsNull(n)) {
|
||||
NodeGetRecord(n)->isGoal = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int NodeIsGoal(Node n)
|
||||
static int NodeIsGoal(Node n)
|
||||
{
|
||||
return !NodeIsNull(n) && NodeGetRecord(n)->isGoal;
|
||||
}
|
||||
|
||||
static inline Node GetParentNode(Node n)
|
||||
static Node GetParentNode(Node n)
|
||||
{
|
||||
NodeRecord *record = NodeGetRecord(n);
|
||||
if (record->hasParent) {
|
||||
@@ -192,7 +192,7 @@ static inline Node GetParentNode(Node n)
|
||||
}
|
||||
}
|
||||
|
||||
static inline int NodeRankCompare(Node n1, Node n2)
|
||||
static int NodeRankCompare(Node n1, Node n2)
|
||||
{
|
||||
const float rank1 = GetNodeRank(n1);
|
||||
const float rank2 = GetNodeRank(n2);
|
||||
@@ -205,7 +205,7 @@ static inline int NodeRankCompare(Node n1, Node n2)
|
||||
}
|
||||
}
|
||||
|
||||
static inline float GetPathCostHeuristic(Node a, Node b)
|
||||
static float GetPathCostHeuristic(Node a, Node b)
|
||||
{
|
||||
if (a.nodes->source->pathCostHeuristic && !NodeIsNull(a) && !NodeIsNull(b)) {
|
||||
return a.nodes->source->pathCostHeuristic(GetNodeKey(a), GetNodeKey(b), a.nodes->context);
|
||||
@@ -214,7 +214,7 @@ static inline float GetPathCostHeuristic(Node a, Node b)
|
||||
}
|
||||
}
|
||||
|
||||
static inline int NodeKeyCompare(Node node, void *nodeKey)
|
||||
static int NodeKeyCompare(Node node, void *nodeKey)
|
||||
{
|
||||
if (node.nodes->source->nodeComparator) {
|
||||
return node.nodes->source->nodeComparator(GetNodeKey(node), nodeKey, node.nodes->context);
|
||||
@@ -273,7 +273,7 @@ static Node GetNode(VisitedNodes nodes, void *nodeKey)
|
||||
return node;
|
||||
}
|
||||
|
||||
static inline void SwapOpenSetNodesAtIndexes(VisitedNodes nodes, size_t index1, size_t index2)
|
||||
static void SwapOpenSetNodesAtIndexes(VisitedNodes nodes, size_t index1, size_t index2)
|
||||
{
|
||||
if (index1 != index2) {
|
||||
NodeRecord *record1 = NodeGetRecord(NodeMake(nodes, nodes->openNodes[index1]));
|
||||
@@ -289,7 +289,7 @@ static inline void SwapOpenSetNodesAtIndexes(VisitedNodes nodes, size_t index1,
|
||||
}
|
||||
}
|
||||
|
||||
static inline void DidRemoveFromOpenSetAtIndex(
|
||||
static void DidRemoveFromOpenSetAtIndex(
|
||||
VisitedNodes nodes, size_t idx)
|
||||
{
|
||||
size_t smallestIndex = idx;
|
||||
@@ -316,7 +316,7 @@ static inline void DidRemoveFromOpenSetAtIndex(
|
||||
} while (smallestIndex != idx);
|
||||
}
|
||||
|
||||
static inline void RemoveNodeFromOpenSet(Node n)
|
||||
static void RemoveNodeFromOpenSet(Node n)
|
||||
{
|
||||
NodeRecord *record = NodeGetRecord(n);
|
||||
|
||||
@@ -331,7 +331,7 @@ static inline void RemoveNodeFromOpenSet(Node n)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void DidInsertIntoOpenSetAtIndex(VisitedNodes nodes, size_t idx)
|
||||
static void DidInsertIntoOpenSetAtIndex(VisitedNodes nodes, size_t idx)
|
||||
{
|
||||
while (idx > 0)
|
||||
{
|
||||
@@ -349,7 +349,7 @@ static inline void DidInsertIntoOpenSetAtIndex(VisitedNodes nodes, size_t idx)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void AddNodeToOpenSet(Node n, float cost, Node parent)
|
||||
static void AddNodeToOpenSet(Node n, float cost, Node parent)
|
||||
{
|
||||
NodeRecord *record = NodeGetRecord(n);
|
||||
const size_t openIndex = n.nodes->openNodesCount;
|
||||
@@ -376,17 +376,17 @@ static inline void AddNodeToOpenSet(Node n, float cost, Node parent)
|
||||
DidInsertIntoOpenSetAtIndex(n.nodes, openIndex);
|
||||
}
|
||||
|
||||
static inline int HasOpenNode(VisitedNodes nodes)
|
||||
static int HasOpenNode(VisitedNodes nodes)
|
||||
{
|
||||
return nodes->openNodesCount > 0;
|
||||
}
|
||||
|
||||
static inline Node GetOpenNode(VisitedNodes nodes)
|
||||
static Node GetOpenNode(VisitedNodes nodes)
|
||||
{
|
||||
return NodeMake(nodes, nodes->openNodes[0]);
|
||||
}
|
||||
|
||||
static inline ASNeighborList NeighborListCreate(const ASPathNodeSource *source)
|
||||
static ASNeighborList NeighborListCreate(const ASPathNodeSource *source)
|
||||
{
|
||||
ASNeighborList list;
|
||||
CCALLOC(list, sizeof(struct __ASNeighborList));
|
||||
@@ -394,19 +394,19 @@ static inline ASNeighborList NeighborListCreate(const ASPathNodeSource *source)
|
||||
return list;
|
||||
}
|
||||
|
||||
static inline void NeighborListDestroy(ASNeighborList list)
|
||||
static void NeighborListDestroy(ASNeighborList list)
|
||||
{
|
||||
CFREE(list->costs);
|
||||
CFREE(list->nodeKeys);
|
||||
CFREE(list);
|
||||
}
|
||||
|
||||
static inline float NeighborListGetEdgeCost(ASNeighborList list, size_t idx)
|
||||
static float NeighborListGetEdgeCost(ASNeighborList list, size_t idx)
|
||||
{
|
||||
return list->costs[idx];
|
||||
}
|
||||
|
||||
static inline void *NeighborListGetNodeKey(ASNeighborList list, size_t idx)
|
||||
static void *NeighborListGetNodeKey(ASNeighborList list, size_t idx)
|
||||
{
|
||||
return (char *)list->nodeKeys + (idx * list->source->nodeSize);
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ void CharSpriteClassesLoadDir(map_t classes, const char *path)
|
||||
tinydir_dir dir;
|
||||
if (tinydir_open(&dir, buf) == -1)
|
||||
{
|
||||
goto bail;
|
||||
return;
|
||||
}
|
||||
|
||||
for (; dir.has_next; tinydir_next(&dir))
|
||||
|
@@ -256,7 +256,7 @@ static void SoundLoadMusic(CArray *tracks, const char *path)
|
||||
{
|
||||
LOG(LM_MAIN, LL_ERROR, "Cannot open music dir %s: %s", buf,
|
||||
strerror(errno));
|
||||
goto bail;
|
||||
return;
|
||||
}
|
||||
|
||||
for (; dir.has_next; tinydir_next(&dir))
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2013-2018, tinydir authors:
|
||||
Copyright (c) 2013-2019, tinydir authors:
|
||||
- Cong Xu
|
||||
- Lautis Sun
|
||||
- Baudouin Feildel
|
||||
@@ -534,7 +534,8 @@ int tinydir_readfile(const tinydir_dir *dir, tinydir_file *file)
|
||||
}
|
||||
|
||||
_tinydir_strcpy(file->path, dir->path);
|
||||
_tinydir_strcat(file->path, TINYDIR_STRING("/"));
|
||||
if (_tinydir_strcmp(dir->path, TINYDIR_STRING("/")) != 0)
|
||||
_tinydir_strcat(file->path, TINYDIR_STRING("/"));
|
||||
_tinydir_strcpy(file->name, filename);
|
||||
_tinydir_strcat(file->path, filename);
|
||||
#ifndef _MSC_VER
|
||||
@@ -657,32 +658,32 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path)
|
||||
/* Get the parent path */
|
||||
#if (defined _MSC_VER || defined __MINGW32__)
|
||||
#if ((defined _MSC_VER) && (_MSC_VER >= 1400))
|
||||
errno = _tsplitpath_s(
|
||||
path,
|
||||
drive_buf, _TINYDIR_DRIVE_MAX,
|
||||
dir_name_buf, _TINYDIR_FILENAME_MAX,
|
||||
file_name_buf, _TINYDIR_FILENAME_MAX,
|
||||
ext_buf, _TINYDIR_FILENAME_MAX);
|
||||
errno = _tsplitpath_s(
|
||||
path,
|
||||
drive_buf, _TINYDIR_DRIVE_MAX,
|
||||
dir_name_buf, _TINYDIR_FILENAME_MAX,
|
||||
file_name_buf, _TINYDIR_FILENAME_MAX,
|
||||
ext_buf, _TINYDIR_FILENAME_MAX);
|
||||
#else
|
||||
_tsplitpath(
|
||||
path,
|
||||
drive_buf,
|
||||
dir_name_buf,
|
||||
file_name_buf,
|
||||
ext_buf);
|
||||
_tsplitpath(
|
||||
path,
|
||||
drive_buf,
|
||||
dir_name_buf,
|
||||
file_name_buf,
|
||||
ext_buf);
|
||||
#endif
|
||||
|
||||
if (errno)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (errno)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* _splitpath_s not work fine with only filename and widechar support */
|
||||
#ifdef _UNICODE
|
||||
if (drive_buf[0] == L'\xFEFE')
|
||||
drive_buf[0] = '\0';
|
||||
if (dir_name_buf[0] == L'\xFEFE')
|
||||
dir_name_buf[0] = '\0';
|
||||
if (drive_buf[0] == L'\xFEFE')
|
||||
drive_buf[0] = '\0';
|
||||
if (dir_name_buf[0] == L'\xFEFE')
|
||||
dir_name_buf[0] = '\0';
|
||||
#endif
|
||||
|
||||
/* Emulate the behavior of dirname by returning "." for dir name if it's
|
||||
@@ -701,9 +702,24 @@ if (errno)
|
||||
_tinydir_strcpy(dir_name_buf, path);
|
||||
dir_name = dirname(dir_name_buf);
|
||||
_tinydir_strcpy(file_name_buf, path);
|
||||
base_name =basename(file_name_buf);
|
||||
base_name = basename(file_name_buf);
|
||||
#endif
|
||||
|
||||
/* Special case: if the path is a root dir, open the parent dir as the file */
|
||||
#if (defined _MSC_VER || defined __MINGW32__)
|
||||
if (_tinydir_strlen(base_name) == 0)
|
||||
#else
|
||||
if ((_tinydir_strcmp(base_name, TINYDIR_STRING("/"))) == 0)
|
||||
#endif
|
||||
{
|
||||
memset(file, 0, sizeof * file);
|
||||
file->is_dir = 1;
|
||||
file->is_reg = 0;
|
||||
_tinydir_strcpy(file->path, dir_name);
|
||||
file->extension = file->path + _tinydir_strlen(file->path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Open the parent directory */
|
||||
if (tinydir_open(&dir, dir_name) == -1)
|
||||
{
|
||||
|
Reference in New Issue
Block a user