Skip to content
Permalink
Branch: master
Commits on Mar 9, 2020
  1. Remove FindSDL2 find-module, use sdl2-config.cmake instead

    smcv authored and Razish committed Feb 14, 2020
    This requires SDL >= 2.0.4.
    
    Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in
    SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was
    not itself built using CMake: it installs a sdl2-config.cmake file to
    ${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and
    library, analogous to a pkg-config .pc file.
    
    As a result, we no longer need to copy/paste a "find-module package"
    to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2).
    Find-module packages are now discouraged by the CMake developers, in
    favour of having upstream projects behave as config-file packages.
    
    This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR
    and SDL2_LIBRARY, but the standard behaviour for config-file packages is
    to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword
    to make sure we search in config-file package mode, and will not find a
    FindSDL2.cmake in some other directory that implements the old interface.
    
    In addition to deleting redundant code, this avoids some assumptions in
    FindSDL2 about the layout of a SDL installation. The current libsdl2-dev
    package in Debian breaks those assumptions; this is considered a bug
    and will hopefully be fixed soon, but it illustrates how fragile these
    assumptions can be. We can be more robust against different installation
    layouts by relying on SDL's own CMake integration.
    
    When linking to a copy of CMake in a non-standard location, users can
    now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point
    to it; previously, these users would have used the SDL2DIR environment
    variable. This continues to be unnecessary if using matching system-wide
    installations of CMake and SDL2, for example both from Debian.
    
    Mitigates: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=951087
    Signed-off-by: Simon McVittie <smcv@debian.org>
  2. Travis-CI: Move from Ubuntu 14.04 to 18.04

    smcv authored and Razish committed Feb 15, 2020
    Ubuntu 14.04 reached EOL for mainstream support in April 2019, and I'm
    about to add a dependency on a version of SDL newer than the one in
    14.04. Instead of going via 16.04, which only has about a year of
    support lifetime left itself, let's go directly to 18.04, currently the
    latest LTS release.
    
    Update build-dependencies accordingly.
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
Commits on Aug 9, 2018
  1. JK2: Remove mismatched allocator from std::map typedefs

    smcv committed Aug 6, 2018
    The Allocator is meant to be one that is suitable for allocating
    std::pair<key, value> instances, not value instances, and the
    Standard C++ library provided by gcc 8 asserts that the types match.
    The closest valid allocator here would be
    std::allocator<std::pair<key, value>>, but that is the default for
    this template anyway, so we can just omit it.
    
    Closes: #985
    Bug-Debian: https://bugs.debian.org/905477
    Signed-off-by: Simon McVittie <smcv@debian.org>
  2. macOS CI: Upgrade Homebrew packages before installing

    smcv committed Aug 9, 2018
    Travis-CI's macOS worker image currently has libpng installed at a
    slightly outdated version. Unlike "apt install", "brew install"
    will not upgrade a package that is already installed, and will exit
    unsuccessfully when asked to do so. There does not seem to be a
    Homebrew command for "upgrade these packages if installed, or install
    them if not installed", so the most straightforward way seems to be
    to upgrade everything before invoking brew install.
    
    Fixes: #987
Commits on Jul 7, 2017
  1. Fix some compiler warnings (#917)

    smcv authored and xycaleth committed Jul 7, 2017
    * Consistently declare Com_Error implementations as noreturn
    
    According to comments in code/game/g_public.h (whose version was
    already tagged noreturn), for function pointers this only works with
    the gcc/clang-specific spelling __attribute__((noreturn)), and not with
    the gcc/clang/MSVC abstraction NORETURN. For function implementations,
    we can use NORETURN to get MSVC support too.
    
    This lets the compiler reason about what returns and what doesn't,
    and in particular silences gcc warnings about functions that
    are declared NORETURN but that did appear to return. They didn't,
    because they ended with a call to (a function pointer that
    eventually calls) Com_Error, but without these annotations
    the compiler couldn't know that.
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
    
    * AI_ClosestGroupEntityNumToPoint: Remove, unused
    
    It issues compiler warnings (or did until recently), and git grep says
    nothing actually calls or mentions this function.
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
    
    * Icarus: Squash a compiler warning about possibly uninitialized length
    
    clang can see that BufferRead() does not always assign to length,
    issuing this warning:
    
    IcarusImplementation.cpp|601 col 13| warning: ‘length’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    
    (This only happens if the buffer is null, in which case we have
    bigger problems.)
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
    
    * Move definition of NORETURN to q_platform.h
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
    
    * Introduce NORETURN_PTR, a version of NORETURN for function pointers
    
    This expands to the same thing as NORETURN on gcc (and clang), but
    expands to nothing on MSVC.
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
    
    * Define NORETURN, NORETURN_PTR for non-gcc non-MSVC compilers
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
Commits on Jan 21, 2017
  1. game: If strings are too long, raise error instead of assuming 0 length

    smcv committed Jan 21, 2017
    Signed-off-by: Simon McVittie <smcv@debian.org>
  2. icarus: Fail to load if buffer would be overflowed, don't just skip

    smcv committed Jan 21, 2017
    Unfortunately CIcarus::BufferRead returns void, so we can't
    return a failure state from here, but we can at least print an
    error message.
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
  3. icarus: fix bounds check when loading from savegames

    smcv committed Jan 21, 2017
    m_byBuffer is a pointer to a fixed amount of dynamically allocated
    memory, not a statically allocated buffer, so sizeof() is the wrong
    tool here. Use the actual size of the buffer instead.
    
    Also, reading the full size of the buffer is fine, because we aren't
    going to append '\0' afterwards like we do in the other places
    touched by #881, so use > instead of >=.
    
    Fixes #902
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
Commits on Oct 29, 2016
  1. snd_mem: fix build failure on big-endian CPUs with C++11 compilers

    smcv committed Oct 29, 2016
    The Debian powerpc, mips and s390x builds failed with:
    
    .../code/client/snd_mem.cpp: In function 'qboolean S_LoadSound_Actual(sfx_t*)':
    .../code/client/snd_mem.cpp:843:54: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator>>'
            if (sfx->fVolRange < (abs(sfx->pSoundData[i]) >> 8))
                                  ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
    .../code/client/snd_mem.cpp:845:50: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator>>'
             sfx->fVolRange = abs(sfx->pSoundData[i]) >> 8;
                              ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
    
    This appears to be because sfx->pSoundData[i] is of type short. C++98
    only provided int abs(int), long abs(long), float abs(float),
    double abs(double) and long double abs(long double) overloads, but
    C++11 also provides double abs(T) for all integral types T, including
    short. double is not a valid left-hand side for operator>> so
    compilation fails.
Commits on Oct 28, 2016
  1. Remove unused variable in JK2 mode

    smcv committed Oct 28, 2016
  2. Avoid compiler warning when sscanf writes qboolean through %i

    smcv committed Sep 22, 2016
    .../code/game/g_client.cpp:760:6: warning: format '%i' expects argument of type 'int*', but argument 26 has type 'qboolean*' [-Wformat=]
  3. Use conventional formatting to avoid -Wmisleading-indentation

    smcv committed Oct 28, 2016
    With clang 3.8:
    
    .../codemp/client/cl_cin.cpp: In function ‘short unsigned int yuv_to_rgb(long int, long int, long int)’:
    .../codemp/client/cl_cin.cpp:591:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
      if (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0;
      ^~
    .../codemp/client/cl_cin.cpp:591:18: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
      if (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0;
                      ^~
  4. savegames: bounds-check some string lengths to prevent buffer overflow

    smcv committed Oct 28, 2016
  5. g_svcmds: fix typo in avoiding non-C++11-compliant string syntax

    smcv committed Oct 28, 2016
  6. Consistently use "static QINLINE" for inline C code

    smcv committed Sep 25, 2016
    The portable idiom for type-safe macro-like constructs in C is to use
    "static inline" where C99 inline is supported, or "static __inline"
    on compilers that implement that keyword as a compiler-specific
    extension (at least gcc, clang and MSVC do), falling back to just
    "static" as a last resort on terrible compilers from the distant past.
    
    Using "static QINLINE" everywhere means there is no point in defining
    QINLINE to "static inline" on clang, so stop doing that; QINLINE now
    consistently expands to Standard C/C++ inline, or __inline on MSVC,
    or to nothing if we don't know how to inline functions on this
    compiler.
    
    This silences warnings about redundant qualifiers (static static inline)
    for all the functions that were already inline.
    
    There are a couple of uses of non-static QINLINE in C++ code; I've
    left those intact, since inline has different (more useful)
    semantics in C++, and as far as I'm aware all reasonable C++ compilers
    implement it correctly.
  7. Pick up date from SOURCE_DATE_EPOCH, for reproducible builds

    smcv committed Oct 28, 2016
    The goal of reproducible builds is that a rebuild of the same source
    code with the same compiler, libraries, etc. should result in the same
    binaries. SOURCE_DATE_EPOCH provides a standard way for build systems
    to fill in the date of the latest source change, typically from a git
    commit or from metadata like the debian/changelog in Debian packages.
    
    This does not change anything if SOURCE_DATE_EPOCH is not defined;
    the intention is that a larger build system like a Debian package
    will define it.
    
    Please see https://reproducible-builds.org/ for more information about
    reproducible builds.
    
    Similar to <ioquake/ioq3#225>.
Commits on Sep 24, 2016
  1. Use same mechanism to say "no servers found" as to say how many we found

    smcv committed Sep 22, 2016
    This avoids an array underflow: if no servers were found, we would
    write to foundPlayerServerNames[-1], which is undefined behaviour, but
    with a reasonable assumption of the stack layout is likely to result
    in a write to foundPlayerServerAddresses[MAX - 1].
  2. Fix a typo in Siege mode: attemtping -> attempting

    smcv committed Mar 20, 2016
  3. Declare platform-independent byteswapping functions QINLINE

    smcv committed Sep 21, 2016
    In addition to enabling inlining for these very simple functions,
    this suppresses warnings from gcc 6:
    
    …/shared/qcommon/q_platform.h:302:13: warning: 'void CopyShortSwap(void*, const void*)' defined but not used [-Wunused-function]
  4. botlib: print long int correctly

    smcv committed Sep 22, 2016
    value has type long, or equivalently signed long int. In C,
    abs(some_long) returns int (to get a long result you would have to use
    labs(some_long) due to lack of overloading), but in C++ it returns long.
  5. Suppress compiler warning for unused BufferToHexString

    smcv committed Sep 22, 2016
    This function is only called when debugging challenges.
Commits on Mar 13, 2016
  1. stdin_active: remove, unused

    smcv committed Mar 12, 2016
    This was only used in the old NET_Sleep() implementation, which I've
    just removed.
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
  2. Use NET_Sleep() (or Sys_Sleep() in SP) to avoid busy-waiting

    smcv committed Mar 12, 2016
    Backported and simplified from an assortment of ioquake3 commits,
    mostly by Thilo Schulz, with contributions from Zack Middleton and
    Özkan Sezer.
    
    The single-player engines don't have any netcode, and in particular
    no NET_Sleep(); if they had a straightforward port of NET_Sleep(),
    it would be roughly equivalent to Sys_Sleep() anyway, since they
    don't have anything to receive from the network. As a result, I've
    used Sys_Sleep() instead of NET_Sleep() there.
    
    This makes the hard-coded 5ms Sys_Sleep() calls in main()
    (and the 50ms equivalents in a couple of unused Windows equivalents)
    unnecessary, so I've made them conditional on this logic being
    disabled (com_busyWait 1).
    
    The practical effect of those 5ms Sys_Sleep() calls in terms of
    framerate-limiting varied according to the framerate your computer
    would be capable of without the limit, and because of the way this
    framerate limit works, it's best if the limit is an integer divisor of
    1000. I've arbitrarily chosen com_maxfpsMinimized to be 50fps, which is
    what would have happened on a PC capable of slightly less than 60fps
    in the old implementation.
    
    Fixes #507.
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
  3. Remove some unused files

    smcv committed Mar 12, 2016
    These are not mentioned in any of the CMakefiles, so they can't be
    compiled by any supported configuration.
Commits on Mar 12, 2016
  1. Use ISO C++ or ISO C isnan() on mingw

    smcv committed Oct 27, 2015
    _isnan() isn't part of a strictly conforming ISO C math.h, so mingw-w64's
    math.h doesn't declare it when compiling with gcc -std=c++11,
    which defines __STRICT_ANSI__.
  2. JK2: Fix incorrect Icarus Q3_GetString() animation name validation

    smcv committed Mar 12, 2016
    This breaks the build in clang (llvm). Equivalent to commit 973e9c2
    in JASP.
    
    Signed-off-by: Simon McVittie <smcv@debian.org>
  3. travis: use the new Ubuntu 14.04 environment

    smcv committed Oct 27, 2015
    Previously we were upgrading from 12.04 to a 12.04/14.04 hybrid,
    which was time-consuming and a bit of a hack. travis-ci.org now
    offers a pure 14.04 build environment, so use that instead.
    
    Re-enable x86 Linux builds: these aren't too slow now that we're on
    14.04.
Commits on Oct 1, 2015
  1. Don't force UseInternalSDL2Default to ON under MSVC

    smcv committed Oct 1, 2015
    This is redundant, because UseInternalSDL2Default is already ON
    when targeting Windows, and that's the only thing MSVC can target.
  2. Use bundled libpng by default when building for Windows

    smcv committed Oct 1, 2015
    This was the default before commit bace05c, and is consistent with
    how everything else works in Windows builds. In particular, we use the
    bundled zlib by default, but libpng depends on zlib, so we shouldn't
    use a system libpng unless we are also using a (compatible)
    system zlib.
Commits on Aug 13, 2015
  1. Disable the i686 Linux Travis build, the setup is quite slow

    smcv committed Aug 1, 2015
    It takes a few minutes to install/upgrade the necessary toolchain
    for 32-bit builds on a 64-bit system that mixes Ubuntu 12.04
    with Ubuntu 14.04. Most of the warnings/errors we would get from
    this build variant would come up in either x86_64 Linux or i686 mingw
    in any case.
Commits on Aug 9, 2015
  1. Link libgcc and libstdc++ statically on mingw

    smcv committed Aug 4, 2015
    gcc/g++ link with support libraries: libgcc is a support library for
    executables generated by gcc/g++, and libstdc++ is the GNU
    implementation of Standard C++. Linking them statically means we don't
    need to distribute separate libgcc_s_sjlj-1.dll and libstdc++-6.dll
    binaries alongside OpenJK.
  2. Add toolchain files for mingw-w64 compilers

    smcv committed Aug 3, 2015
    These assume that the compiler is in $PATH, and is named like the
    ones in Debian/Ubuntu.
  3. Allow linking mingw builds to the bundled SDL2 libraries

    smcv committed Aug 3, 2015
    Order is significant when using traditional Unix linkers like GNU ld:
    libraries later in the link line can provide symbols required by
    libraries earlier in the link line, but the opposite is not true.
    When using an external SDL2, FindSDL2.cmake puts SDL2main before SDL2,
    because SDL2main uses symbols from SDL2. Do the same for the bundled
    SDL2 library.
    
    This fixes the following link errors:
    
    .../lib/SDL2/lib/x86/SDL2main.lib(./Release/SDL_windows_main.obj):(.text[_main]+0x5): undefined reference to `SDL_SetMainReady'
    .../lib/SDL2/lib/x86/SDL2main.lib(./Release/SDL_windows_main.obj):(.text[_WinMain@16]+0x14): undefined reference to `SDL_wcslen'
    .../lib/SDL2/lib/x86/SDL2main.lib(./Release/SDL_windows_main.obj):(.text[_WinMain@16]+0x2f): undefined reference to `SDL_iconv_string'
    .../lib/SDL2/lib/x86/SDL2main.lib(./Release/SDL_windows_main.obj):(.text[_WinMain@16]+0x63): undefined reference to `SDL_malloc'
    .../lib/SDL2/lib/x86/SDL2main.lib(./Release/SDL_windows_main.obj):(.text[_ParseCommandLine]+0x36): undefined reference to `SDL_isspace'
    .../lib/SDL2/lib/x86/SDL2main.lib(./Release/SDL_windows_main.obj):(.text[_ParseCommandLine]+0xf5): undefined reference to `SDL_isspace'
    collect2: error: ld returned 1 exit status
  4. build: ensure that CMAKE_SIZEOF_VOID_P is set

    smcv committed Aug 2, 2015
    This gets set with native gcc on Linux, and presumably also with
    MSVC judging by its use in OpenJK, but doesn't seem to be set
    when cross-compiling with the mingw-w64 toolchain.
Older
You can’t perform that action at this time.