mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Split apart some of P_WriteTextmap
This commit is contained in:
parent
19eae9f95a
commit
7def36aaeb
1 changed files with 77 additions and 56 deletions
133
src/p_setup.c
133
src/p_setup.c
|
|
@ -2016,11 +2016,80 @@ typedef struct
|
||||||
mapthing_t *angleanchor;
|
mapthing_t *angleanchor;
|
||||||
} sectorspecialthings_t;
|
} sectorspecialthings_t;
|
||||||
|
|
||||||
static void P_WriteTextmap(void)
|
static FILE *P_OpenTextmap(const char *mode, const char *error)
|
||||||
{
|
{
|
||||||
size_t i, j;
|
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *filepath = va(pandf, srb2home, "TEXTMAP");
|
char *filepath = va(pandf, srb2home, "TEXTMAP");
|
||||||
|
|
||||||
|
f = fopen(filepath, mode);
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_ERROR, M_GetText("%s %s\n"), error, filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void P_WriteTextmapThing(FILE *f, mapthing_t *wmapthings, size_t i, size_t k)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
fprintf(f, "thing // %s\n", sizeu1(k));
|
||||||
|
fprintf(f, "{\n");
|
||||||
|
if (wmapthings[i].tid != 0)
|
||||||
|
fprintf(f, "id = %d;\n", wmapthings[i].tid);
|
||||||
|
fprintf(f, "x = %d;\n", wmapthings[i].x);
|
||||||
|
fprintf(f, "y = %d;\n", wmapthings[i].y);
|
||||||
|
if (wmapthings[i].z != 0)
|
||||||
|
fprintf(f, "height = %d;\n", wmapthings[i].z);
|
||||||
|
fprintf(f, "angle = %d;\n", wmapthings[i].angle);
|
||||||
|
if (wmapthings[i].pitch != 0)
|
||||||
|
fprintf(f, "pitch = %d;\n", wmapthings[i].pitch);
|
||||||
|
if (wmapthings[i].roll != 0)
|
||||||
|
fprintf(f, "roll = %d;\n", wmapthings[i].roll);
|
||||||
|
if (wmapthings[i].type != 0)
|
||||||
|
fprintf(f, "type = %d;\n", wmapthings[i].type);
|
||||||
|
if (wmapthings[i].scale != FRACUNIT)
|
||||||
|
fprintf(f, "scale = %f;\n", FIXED_TO_FLOAT(wmapthings[i].scale));
|
||||||
|
if (wmapthings[i].options & MTF_OBJECTFLIP)
|
||||||
|
fprintf(f, "flip = true;\n");
|
||||||
|
if (wmapthings[i].special != 0)
|
||||||
|
fprintf(f, "special = %d;\n", wmapthings[i].special);
|
||||||
|
for (j = 0; j < NUMMAPTHINGARGS; j++)
|
||||||
|
if (wmapthings[i].args[j] != 0)
|
||||||
|
fprintf(f, "arg%s = %d;\n", sizeu1(j), wmapthings[i].args[j]);
|
||||||
|
for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++)
|
||||||
|
if (mapthings[i].stringargs[j])
|
||||||
|
fprintf(f, "stringarg%s = \"%s\";\n", sizeu1(j), mapthings[i].stringargs[j]);
|
||||||
|
if (wmapthings[i].user.length > 0)
|
||||||
|
{
|
||||||
|
for (j = 0; j < wmapthings[i].user.length; j++)
|
||||||
|
{
|
||||||
|
mapUserProperty_t *const prop = &wmapthings[i].user.properties[j];
|
||||||
|
switch (prop->type)
|
||||||
|
{
|
||||||
|
case USER_PROP_BOOL:
|
||||||
|
fprintf(f, "user_%s = %s;\n", prop->key, (prop->valueBool == true) ? "true" : "false");
|
||||||
|
break;
|
||||||
|
case USER_PROP_INT:
|
||||||
|
fprintf(f, "user_%s = %d;\n", prop->key, prop->valueInt);
|
||||||
|
break;
|
||||||
|
case USER_PROP_FIXED:
|
||||||
|
fprintf(f, "user_%s = %f;\n", prop->key, FIXED_TO_FLOAT(prop->valueFixed));
|
||||||
|
break;
|
||||||
|
case USER_PROP_STR:
|
||||||
|
fprintf(f, "user_%s = \"%s\";\n", prop->key, prop->valueStr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(f, "}\n");
|
||||||
|
fprintf(f, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void P_WriteTextmap(void)
|
||||||
|
{
|
||||||
|
size_t i, j, k;
|
||||||
|
FILE *f;
|
||||||
mtag_t firsttag;
|
mtag_t firsttag;
|
||||||
mapthing_t *wmapthings;
|
mapthing_t *wmapthings;
|
||||||
vertex_t *wvertexes;
|
vertex_t *wvertexes;
|
||||||
|
|
@ -2031,10 +2100,9 @@ static void P_WriteTextmap(void)
|
||||||
sectorspecialthings_t *specialthings;
|
sectorspecialthings_t *specialthings;
|
||||||
boolean *wusedvertexes;
|
boolean *wusedvertexes;
|
||||||
|
|
||||||
f = fopen(filepath, "w");
|
f = P_OpenTextmap("w", "Couldn't save map file");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("Couldn't save map file %s\n"), filepath);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2354,59 +2422,12 @@ static void P_WriteTextmap(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "namespace = \"srb2\";\n");
|
fprintf(f, "namespace = \"srb2\";\n");
|
||||||
for (i = 0; i < nummapthings; i++)
|
for (i = k = 0; i < nummapthings; i++)
|
||||||
{
|
{
|
||||||
fprintf(f, "thing // %s\n", sizeu1(i));
|
|
||||||
fprintf(f, "{\n");
|
P_WriteTextmapThing(f, wmapthings, i, k);
|
||||||
if (wmapthings[i].tid != 0)
|
|
||||||
fprintf(f, "id = %d;\n", wmapthings[i].tid);
|
k++;
|
||||||
fprintf(f, "x = %d;\n", wmapthings[i].x);
|
|
||||||
fprintf(f, "y = %d;\n", wmapthings[i].y);
|
|
||||||
if (wmapthings[i].z != 0)
|
|
||||||
fprintf(f, "height = %d;\n", wmapthings[i].z);
|
|
||||||
fprintf(f, "angle = %d;\n", wmapthings[i].angle);
|
|
||||||
if (wmapthings[i].pitch != 0)
|
|
||||||
fprintf(f, "pitch = %d;\n", wmapthings[i].pitch);
|
|
||||||
if (wmapthings[i].roll != 0)
|
|
||||||
fprintf(f, "roll = %d;\n", wmapthings[i].roll);
|
|
||||||
if (wmapthings[i].type != 0)
|
|
||||||
fprintf(f, "type = %d;\n", wmapthings[i].type);
|
|
||||||
if (wmapthings[i].scale != FRACUNIT)
|
|
||||||
fprintf(f, "scale = %f;\n", FIXED_TO_FLOAT(wmapthings[i].scale));
|
|
||||||
if (wmapthings[i].options & MTF_OBJECTFLIP)
|
|
||||||
fprintf(f, "flip = true;\n");
|
|
||||||
if (wmapthings[i].special != 0)
|
|
||||||
fprintf(f, "special = %d;\n", wmapthings[i].special);
|
|
||||||
for (j = 0; j < NUMMAPTHINGARGS; j++)
|
|
||||||
if (wmapthings[i].args[j] != 0)
|
|
||||||
fprintf(f, "arg%s = %d;\n", sizeu1(j), wmapthings[i].args[j]);
|
|
||||||
for (j = 0; j < NUMMAPTHINGSTRINGARGS; j++)
|
|
||||||
if (mapthings[i].stringargs[j])
|
|
||||||
fprintf(f, "stringarg%s = \"%s\";\n", sizeu1(j), mapthings[i].stringargs[j]);
|
|
||||||
if (wmapthings[i].user.length > 0)
|
|
||||||
{
|
|
||||||
for (j = 0; j < wmapthings[i].user.length; j++)
|
|
||||||
{
|
|
||||||
mapUserProperty_t *const prop = &wmapthings[i].user.properties[j];
|
|
||||||
switch (prop->type)
|
|
||||||
{
|
|
||||||
case USER_PROP_BOOL:
|
|
||||||
fprintf(f, "user_%s = %s;\n", prop->key, (prop->valueBool == true) ? "true" : "false");
|
|
||||||
break;
|
|
||||||
case USER_PROP_INT:
|
|
||||||
fprintf(f, "user_%s = %d;\n", prop->key, prop->valueInt);
|
|
||||||
break;
|
|
||||||
case USER_PROP_FIXED:
|
|
||||||
fprintf(f, "user_%s = %f;\n", prop->key, FIXED_TO_FLOAT(prop->valueFixed));
|
|
||||||
break;
|
|
||||||
case USER_PROP_STR:
|
|
||||||
fprintf(f, "user_%s = \"%s\";\n", prop->key, prop->valueStr);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(f, "}\n");
|
|
||||||
fprintf(f, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue