diff --git a/.gitignore b/.gitignore index a388a5ae8..05a759c8b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.suo *.pdb *.ilk +*.aps /Release /wadsrc_wad *.user diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 80afa7954..50c5f5b22 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -505,7 +505,7 @@ endif( BACKPATCH ) get_target_property( UPDATEREVISION_EXE updaterevision LOCATION ) add_custom_target( revision_check ALL - COMMAND ${UPDATEREVISION_EXE} . src/gitinfo.h + COMMAND ${UPDATEREVISION_EXE} src/gitinfo.h WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} DEPENDS updaterevision ) diff --git a/src/g_game.cpp b/src/g_game.cpp index 10ab6afaf..0db149b0b 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -859,10 +859,10 @@ static void ChangeSpy (int changespy) // Otherwise, cycle to the next player. bool checkTeam = !demoplayback && deathmatch; - int pnum = int(players[consoleplayer].camera->player - players); - if (changespy == SPY_CANCEL) { - pnum = consoleplayer; - } else { + int pnum = consoleplayer; + if (changespy != SPY_CANCEL) + { + pnum = int(players[consoleplayer].camera->player - players); int step = (changespy == SPY_NEXT) ? 1 : -1; do diff --git a/tools/updaterevision/updaterevision.c b/tools/updaterevision/updaterevision.c index c1e3ccc8f..90127130a 100644 --- a/tools/updaterevision/updaterevision.c +++ b/tools/updaterevision/updaterevision.c @@ -14,6 +14,11 @@ #include #include +#ifdef _WIN32 +#define popen _popen +#define pclose _pclose +#endif + // Used to strip newline characters from lines read by fgets. void stripnl(char *str) { @@ -29,17 +34,16 @@ void stripnl(char *str) int main(int argc, char **argv) { - char *name; - char vertag[64], lastlog[64], lasthash[64], run[256], *hash = NULL; + char vertag[64], lastlog[64], lasthash[64], *hash = NULL; FILE *stream = NULL; int gotrev = 0, needupdate = 1; vertag[0] = '\0'; lastlog[0] = '\0'; - if (argc != 3) + if (argc != 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); + fprintf(stderr, "Usage: %s \n", argv[0]); return 1; } @@ -47,33 +51,19 @@ int main(int argc, char **argv) // on a tag, it returns that tag. Otherwise it returns --. // Use git log to get the time of the latest commit in ISO 8601 format and its full hash. - sprintf(run, "git describe --tags && git log -1 --format=%%ai*%%H", argv[1]); - if ((name = tempnam(NULL, "gitout")) != NULL) + stream = popen("git describe --tags && git log -1 --format=%ai*%H", "r"); + + if (NULL != stream) { -#ifdef __APPLE__ - // tempnam will return errno of 2 even though it is successful for our purposes. - errno = 0; -#endif - if((stream = freopen(name, "w+b", stdout)) != NULL && - system(run) == 0 && - errno == 0 && - fseek(stream, 0, SEEK_SET) == 0 && - fgets(vertag, sizeof vertag, stream) == vertag && - fgets(lastlog, sizeof lastlog, stream) == lastlog) + if (fgets(vertag, sizeof vertag, stream) == vertag && + fgets(lastlog, sizeof lastlog, stream) == lastlog) { stripnl(vertag); stripnl(lastlog); gotrev = 1; } - } - if (stream != NULL) - { - fclose(stream); - remove(name); - } - if (name != NULL) - { - free(name); + + pclose(stream); } if (gotrev) @@ -95,7 +85,7 @@ int main(int argc, char **argv) hash = lastlog + 1; } - stream = fopen (argv[2], "r"); + stream = fopen (argv[1], "r"); if (stream != NULL) { if (!gotrev) @@ -119,7 +109,7 @@ int main(int argc, char **argv) if (needupdate) { - stream = fopen (argv[2], "w"); + stream = fopen (argv[1], "w"); if (stream == NULL) { return 1; @@ -135,11 +125,11 @@ int main(int argc, char **argv) "#define GIT_TIME \"%s\"\n", hash, vertag, hash, lastlog); fclose(stream); - fprintf(stderr, "%s updated to commit %s.\n", argv[2], vertag); + fprintf(stderr, "%s updated to commit %s.\n", argv[1], vertag); } else { - fprintf (stderr, "%s is up to date at commit %s.\n", argv[2], vertag); + fprintf (stderr, "%s is up to date at commit %s.\n", argv[1], vertag); } return 0; diff --git a/zdoom.vcproj b/zdoom.vcproj index 99b52e4c8..89cf4c7b0 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -29,7 +29,7 @@