CnC_Red_Alert/CODE/VER_FUNC.TXT

99 lines
3.1 KiB
Plaintext

/***********************************************************************************************
* Version_Number -- Determines the version number. *
* *
* This routine will determine the version number by analyzing the date and teim that the *
* program was compiled and then generating a unique version number based on it. The *
* version numbers are guaranteed to be larger for later dates. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with the version number. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 03/24/1995 JLB : Created. *
*=============================================================================================*/
int Version_Number(void)
{
#ifdef OBSOLETE
static bool initialized = false;
static int version;
static char * date = __DATE__;
static char * time = __TIME__;
static char const * months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
if (!initialized) {
char * ptr;
char * tok;
/*
** Fetch the month and place in the first two digit positions.
*/
strupr(date);
tok = strtok(date, " ");
ptr = strstr(months, tok);
if (ptr) {
version = (((ptr - months) / 3)+1) * 10000;
}
/*
** Fetch the date and place that in the next two digit positions.
*/
tok = strtok(NULL, " ");
if (tok) {
version += atoi(tok) * 100;
}
/*
** Fetch the time and place that in the last two digit positions.
*/
tok = strtok(time, ": ");
if (tok) {
version += atoi(tok);
}
/*
** Fetch the virgin text file (if present).
*/
RawFileClass file("VERSION.TXT");
if (file.Is_Available()) {
file.Read(VersionText, sizeof(VersionText));
VersionText[sizeof(VersionText)-1] = '\0';
while (VersionText[sizeof(VersionText)-1] == '\r') {
VersionText[sizeof(VersionText)-1] = '\0';
}
} else {
VersionText[0] = '\0';
}
initialized = true;
}
return(version);
#endif
#ifdef PATCH
#ifdef DEMO
sprintf(VersionText, " 1.1a"); // Demo version.
#else
strcpy(VersionText, ".19a ");
// strcpy(VersionText, ".34 ");
#endif
return(1);
#else
#ifdef DEMO
sprintf(VersionText, " 1.0a"); // Demo version.
#else
// sprintf(VersionText, ".%02dp", 13); // Patch version.
sprintf(VersionText, ".%02d", 14); // Master version.
#endif
return(1);
#endif
}