gzdoom-last-svn/tools/updaterevision/updaterevision.c

130 lines
2.9 KiB
C
Raw Normal View History

/* updaterevision.c
*
* Public domain. This program uses the svnversion command to get the
* repository revision for a particular directory and writes it into
* a header file so that it can be used as a project's build number.
*/
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
int main(int argc, char **argv)
{
char *name;
char currev[64], lastrev[64], run[256], *rev;
unsigned long urev;
FILE *stream = NULL;
int gotrev = 0, needupdate = 1;
if (argc != 3)
{
fprintf (stderr, "Usage: %s <repository directory> <path to svnrevision.h>\n", argv[0]);
return 1;
}
// Use svnversion to get the revision number. If that fails, pretend it's
// revision 0. Note that this requires you have the command-line svn tools installed.
sprintf (run, "svnversion -cn %s", argv[1]);
if ((name = tempnam(NULL, "svnout")) != NULL)
{
#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(currev, sizeof currev, stream) == currev &&
(isdigit(currev[0]) || (currev[0] == '-' && currev[1] == '1')))
{
gotrev = 1;
}
}
if (stream != NULL)
{
fclose (stream);
remove (name);
}
- Fixed: Using sprites as wall textures used incorrect texture offsets because sprites are being offset by one pixel to make texture filtering look better. Now two sets of coordinates are maintained for native GL textures, one for sprites, one for textures. Update to ZDoom r930: - Fixed: MugShotFrame::getTexture() allocated space for the sprite name that it never freed. I'm not sure it's a good assumption that 9 characters is always long enough, either, since you can have longer file names than that inside a zip. - Fixed: DSBarInfo::DrawGem() crashed if chain or gem was NULL. - Fixed: Sound sequences are not thinkers, therefore they must be explicitly marked as roots for the GC. - Reduced the range that area sounds require to interpolate between 2D and 3D panning. - The listener's velocity is now set at 0 for the sound engine. The player moves so fast that you can hear the doppler shift just by running around, otherwise. - Changed the sound code so that all sounds that start playing on a single tic actually start playing at the exact same sample position. - Added the writewave command to write the internal TiMidity's output to a wave file. - Changed the default channel velocity for MUS files from 64 to 100 to better match apparent MIDI practice. (Would like to know what this is supposed to be.) - Changed the mus2midi channel assignments to match the internal player's. - Fixed: apply_envelope_to_amp() should clamp the mix levels to 0. - Made the maximum number of TiMidity voices configurable through the timidity_voices cvar. - Added stats lines for the OPL and Timidity MIDI devices. - Completely changed the way TiMidity volume calculations are done. It should now be extremely close to the output a real GUS would produce with its official MIDI player (excepting where TiMidity normalizes sample volumes). The new equations more closely match what is specified by the DLS and SF2 specs (but not quite), so I presume it's also more musically correct than what TiMidity (and TiMidity++) do. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@97 b0f79afe-0144-0410-b225-9a4edf0717df
2008-04-20 10:26:25 +00:00
if (name != NULL)
{
free (name);
}
if (!gotrev)
{
- Fixed: Using sprites as wall textures used incorrect texture offsets because sprites are being offset by one pixel to make texture filtering look better. Now two sets of coordinates are maintained for native GL textures, one for sprites, one for textures. Update to ZDoom r930: - Fixed: MugShotFrame::getTexture() allocated space for the sprite name that it never freed. I'm not sure it's a good assumption that 9 characters is always long enough, either, since you can have longer file names than that inside a zip. - Fixed: DSBarInfo::DrawGem() crashed if chain or gem was NULL. - Fixed: Sound sequences are not thinkers, therefore they must be explicitly marked as roots for the GC. - Reduced the range that area sounds require to interpolate between 2D and 3D panning. - The listener's velocity is now set at 0 for the sound engine. The player moves so fast that you can hear the doppler shift just by running around, otherwise. - Changed the sound code so that all sounds that start playing on a single tic actually start playing at the exact same sample position. - Added the writewave command to write the internal TiMidity's output to a wave file. - Changed the default channel velocity for MUS files from 64 to 100 to better match apparent MIDI practice. (Would like to know what this is supposed to be.) - Changed the mus2midi channel assignments to match the internal player's. - Fixed: apply_envelope_to_amp() should clamp the mix levels to 0. - Made the maximum number of TiMidity voices configurable through the timidity_voices cvar. - Added stats lines for the OPL and Timidity MIDI devices. - Completely changed the way TiMidity volume calculations are done. It should now be extremely close to the output a real GUS would produce with its official MIDI player (excepting where TiMidity normalizes sample volumes). The new equations more closely match what is specified by the DLS and SF2 specs (but not quite), so I presume it's also more musically correct than what TiMidity (and TiMidity++) do. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@97 b0f79afe-0144-0410-b225-9a4edf0717df
2008-04-20 10:26:25 +00:00
fprintf (stderr, "Failed to get current revision: %s\n", strerror(errno));
strcpy (currev, "0");
rev = currev;
}
else
{
rev = strchr (currev, ':');
if (rev == NULL)
{
rev = currev;
}
else
{
rev += 1;
}
}
stream = fopen (argv[2], "r");
if (stream != NULL)
{
if (!gotrev)
{ // If we didn't get a revision but the file does exist, leave it alone.
fclose (stream);
return 0;
}
// Read the revision that's in this file already. If it's the same as
// what we've got, then we don't need to modify it and can avoid rebuilding
// dependant files.
if (fgets(lastrev, sizeof lastrev, stream) == lastrev)
{
if (lastrev[0] != '\0')
{ // Strip trailing \n
lastrev[strlen(lastrev) - 1] = '\0';
}
if (strcmp(rev, lastrev + 3) == 0)
{
needupdate = 0;
}
}
fclose (stream);
}
if (needupdate)
{
stream = fopen (argv[2], "w");
if (stream == NULL)
{
return 1;
}
urev = strtoul(rev, NULL, 10);
fprintf (stream,
"// %s\n"
"//\n"
"// This file was automatically generated by the\n"
"// updaterevision tool. Do not edit by hand.\n"
"\n"
"#define SVN_REVISION_STRING \"%s\"\n"
"#define SVN_REVISION_NUMBER %lu\n",
rev, rev, urev);
fclose (stream);
fprintf (stderr, "%s updated to revision %s.\n", argv[2], rev);
}
else
{
fprintf (stderr, "%s is up to date at revision %s.\n", argv[2], rev);
}
return 0;
}