Browse Source

Added acsconstants

tags/r189
Sean Baggaley 2 months ago
parent
commit
67c814f807
5 changed files with 95 additions and 1 deletions
  1. 1
    1
      .gitignore
  2. 4
    0
      build.bat
  3. 1
    0
      src/core/decorate.txt
  4. 89
    0
      tools/acsconstants.c
  5. BIN
      tools/acsconstants.exe

+ 1
- 1
.gitignore View File

@@ -13,5 +13,5 @@ out/

# Generated files
a_gitcommit.acs
acsconstants.txt
src/core/readme.txt

+ 4
- 0
build.bat View File

@@ -30,6 +30,10 @@ IF NOT "%GIT_BRANCH%" == "master" (
python "tools\gitcommit.py" "src\core\acs_source\a_gitcommit.acs"


:: Generate acsconstants.txt
"tools\acsconstants.exe" "src\core\acs_source\aow2scrp.acs" "src\core\actors\acsconstants.txt"


:: Compile ACS
IF NOT EXIST "src\core\acs" MKDIR "src\core\acs"
acc "src\core\acs_source\aow2scrp.acs" "src\core\acs\aow2scrp.o"

+ 1
- 0
src/core/decorate.txt View File

@@ -1,5 +1,6 @@
// don't edit the load order unless you know what you're doing
#include "actors/crucial/constants.txt"
#include "actors/acsconstants.txt"
#include "actors/crucial/skeletal.txt"

#include "actors/effects/explosions.txt"

+ 89
- 0
tools/acsconstants.c View File

@@ -0,0 +1,89 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS

# pragma warning(push)
# pragma warning(disable: 4996)
#endif

const char defineString[] = "#define";
const char libdefineString[] = "#libdefine";

int isWhitespace (char* c) {
return (*c == ' ' || *c == '\t');
}

int main (int argc, char* argv[]) {
if (argc != 3) {
fprintf (stderr, "usage: %s <in> <out>\n", argv[0]);
exit (EXIT_FAILURE);
}
FILE* fp = fopen (argv[1], "r");
FILE* fp2 = fopen (argv[2], "w");
char text[1024];
char name[64];
char value[64];
char* c;
size_t len;
int count = 0;
size_t deflen;
const time_t t = time (NULL);
fprintf (fp2, "// Auto-generated by %s at %s\n", argv[0], asctime (localtime (&t)));
for (;;) {
fgets (text, 1024, fp);
if (feof (fp))
break;
c = &text[0];
deflen = strlen (defineString);
if (strncmp (text, defineString, deflen) != 0)
{
deflen = strlen(libdefineString);
if (strncmp (text, libdefineString, deflen) != 0)
continue;
}
c = text + deflen;
while (*c && isWhitespace (c)) c++;
if (!*c) continue;
char* nameptr = c;
while (*c && !isWhitespace (c)) c++;
if (!*c) continue;
len = c - nameptr;
strncpy (name, nameptr, len);
name[len] = '\0';
while (*c && isWhitespace (c)) c++;
if (!*c) continue;
char* valueptr = c;
while (*c && !isWhitespace (c) && *c != '\n') c++;
len = c - valueptr;
strncpy (value, valueptr, len);
value[len] = '\0';
fprintf (fp2, "const int %s = %d;\n", name, atoi (value));
++count;
}
fclose (fp);
fclose (fp2);
printf ("%s: %d ACS constants copied to DECORATE\n", argv[0], count);
exit (EXIT_SUCCESS);
}

#ifdef _MSC_VER
#pragma warning(pop)
#endif

BIN
tools/acsconstants.exe View File


Loading…
Cancel
Save