w32: Drop snprintf(), vsnprintf() macros for Visual Studio The Visual Studio ANSI C compatibility flag now covers these functions so now the defines create a conflict. Signed-off-by: Ron Koenderink <rkoenderink@gmail.com> Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
w32: Work around a Visual Studio deprecation warning Visual Studio warns on use of certain POSIX functions. Compiler option /D_CRT_NONSTDC_NO_WARNINGS suppresses this, except for variable tzname. Work around with a macro. Signed-off-by: Ron Koenderink <rkoenderink@gmail.com> Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
w32: Provide getopt() for Visual Studio getopt() does not exist in the Visual Studio 2019 CRT. Provide one. Signed-off-by: Ron Koenderink <rkoenderink@gmail.com Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
w32: Modernize for MinGW 6.0.0, and clean up We provide gettimeofday() only #ifdef _MSC_VER, but declare it unconditionally in our own sys/time.h. This is asking for trouble. Declare it only #ifdef _MSC_VER, else pull in MinGW's sys/time.h with #include_next. Likewise, define macros ftruncate(), S_IRUSR & friends in our own unistd.h only #ifdef _MSC_VER, else pull in MinGW's unistd.h with #include_next. The #include <getopt.h> is now useless, drop. src/lib/commands/info.c relies on sys/time.h including windows.h. Unclean, and no longer the case with MinGW. Include it directly. MinGW provides EWOULDBLOCK. Drop our replacement. MinGW provides inet_ntop() in ws2tcpip.h, but only if feature test macro _WIN32_WINNT >= 0x600, i.e. Windows Vista or later. It defaults to 0x0502 (Windows Server 2003). Make configure #define _WIN32_WINNT 0x0601 in config.h. This requests Windows 7. Trying to support Vista feels unwise. Include ws2tcpip.h, and drop our replacement. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
show: Drop Windows-specific fmttime2822() code fmttime2822() works around Windows strftime() lacking %z and %T. This is no longer the case, although MinGW still warns about %T. Replace %T by the %H:%M:%S, and drop the work-around. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
chance: Avoid abuse of O_NONBLOCK for Windows O_NONBLOCK from src/lib/w32/w32misc.h is stricly for use with our fcntl(). pick_seed() passes it to open(), which is wrong. With any luck, open() fails as it should anyway (the files being opened are not expected to exist under Windows). Messed up in commit 9102ecce5 "Fix PRNG seeding to resist guessing", v4.3.31. Clean up: guard with #ifndef _WIN32. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
ship: Unbreak MOB_ACCESS real-time mobility update for ships Ships owned by countries with even country number don't gain mobility in real-time. This is due to a classic brown-paperbag typo in the condition guarding mob_inc_ship() in shp_postread(): & instead of &&. Fix it. Fixes: dd9e393b3 "subs: Simplify MOB_ACCESS mobility update", v4.4.0 Reported-by: Phil Miron <Philthy74@hotmail.com> Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
subs/wu: Avoid "may be used uninitialized" warnings typed_wu() either sends a telegram to a single recipient @to, or an announcement. It initializes @np to getnatp(to) only when sending a telegram. It also uses it only then. Clang is cool with this, but GCC gets confused and warns "‘np’ may be used uninitialized". Ron Koenderink reports Visual Studio 2019 even flags it as an error. Time to clean this up. Initialize @np to NULL when sending an announcement. Fuse conditionals while there. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
fire launch: Avoid "may be used uninitialized" warnings launch_missile() initializes @n to the target ship number only when the target is a ship. It also uses it only then, to re-get the ship. Clang is cool with this, but GCC gets confused and warns "‘n’ may be used uninitialized". Use target_ship.shp_uid instead of @n to avoid the warning. Similar issue in c_fire(): use vship.shp_uid instead of for @vhsipno. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
load tend: Avoid "may be used uninitialized" warnings c_load() initializes @ich only when @type is EF_SECTOR. It also uses it only then. Clang is cool with this, but GCC gets confused and warns "‘ich’ may be used uninitialized". Ron Koenderink reports Visual Studio 2019 even flags it as an error. Same for c_lload() and c_tend(). Time to clean this up. Rearrange the code to avoid the warning and also improve readability a bit. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
journal: Don't immediately flush output events to disk Commit 478566258 'New journal event "output"' (v4.3.27) claims "Output events are *not* flushed to disk immediately." They are. Accident. Implement the missing bit. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
move_ground: Fix getsect() error checking move_ground() has code to handle getsect() failure. It's dead, because it assumes getsect() returns a negative value on failure. It actually returns zero then. The mistake can be traced back all the way back to BSD Empire 1.1. Fix it. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
commands: Rename the command functions Command functions are traditionally named like the command shortened to four characters. When this name collides with a keyword or library function, we abbreviate more: brea(), rea(). A few are unabbreviated, e.g. execute(). A few have different names, e.g. explain(), not list(). Commit 23726b379 (v4.3.0) suppressed a GCC warning about carg() colliding with its built-in function. Ron Koenderink reported Microsoft Visual Studio 2019 fails to link: "_carg already defined in ucrtd.lib(ucrtbased.dll)". Time to clean this up: rename the functions to c_FOO(), where FOO is the unabbreviated name of the command. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>