mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-24 21:31:46 +00:00
Bring back WRITETHINGS, with custom filename and UDMF support!
This commit is contained in:
parent
a5bf4a5b8f
commit
73d354b956
5 changed files with 91 additions and 56 deletions
|
@ -1424,14 +1424,22 @@ void OP_ObjectplaceMovement(player_t *player)
|
|||
//
|
||||
// Objectplace related commands.
|
||||
//
|
||||
/*void Command_Writethings_f(void)
|
||||
void Command_Writethings_f(void)
|
||||
{
|
||||
REQUIRE_INLEVEL;
|
||||
REQUIRE_SINGLEPLAYER;
|
||||
REQUIRE_OBJECTPLACE;
|
||||
|
||||
P_WriteThings();
|
||||
}*/
|
||||
if (COM_Argc() > 1)
|
||||
{
|
||||
P_WriteThings(COM_Argv(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Printf(M_GetText("writethings <filename>: write out map things to a file, .txt or .lmp automatically appended.\n"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Command_ObjectPlace_f(void)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ void cht_Init(void);
|
|||
// ObjectPlace
|
||||
//
|
||||
void Command_ObjectPlace_f(void);
|
||||
//void Command_Writethings_f(void);
|
||||
void Command_Writethings_f(void);
|
||||
|
||||
extern consvar_t cv_opflags, cv_ophoopflags, cv_mapthingnum, cv_speed;
|
||||
//extern consvar_t cv_snapto, cv_grid;
|
||||
|
|
|
@ -908,7 +908,7 @@ void D_RegisterClientCommands(void)
|
|||
|
||||
// ingame object placing
|
||||
COM_AddCommand("objectplace", Command_ObjectPlace_f, COM_LUA);
|
||||
//COM_AddCommand("writethings", Command_Writethings_f);
|
||||
COM_AddCommand("writethings", Command_Writethings_f, COM_LUA);
|
||||
CV_RegisterVar(&cv_speed);
|
||||
CV_RegisterVar(&cv_opflags);
|
||||
CV_RegisterVar(&cv_ophoopflags);
|
||||
|
|
127
src/p_setup.c
127
src/p_setup.c
|
@ -877,14 +877,32 @@ static void P_SpawnMapThings(boolean spawnemblems)
|
|||
P_SpawnEmeraldHunt();
|
||||
}
|
||||
|
||||
static void P_WriteTextmap_Things(FILE *f, const mapthing_t *wmapthings); // proto
|
||||
|
||||
// Experimental groovy write function!
|
||||
/*void P_WriteThings(void)
|
||||
void P_WriteThings(const char *filepath)
|
||||
{
|
||||
size_t i, length;
|
||||
mapthing_t *mt;
|
||||
UINT8 *savebuffer, *savebuf_p;
|
||||
INT16 temp;
|
||||
|
||||
if (udmf)
|
||||
{
|
||||
FILE *f = fopen(va("%s.txt", filepath), "w");
|
||||
if (!f)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, M_GetText("Couldn't write to file %s\n"), filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
P_WriteTextmap_Things(f, mapthings);
|
||||
fclose(f);
|
||||
|
||||
CONS_Printf(M_GetText("%s.txt saved.\n"), filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
savebuf_p = savebuffer = (UINT8 *)malloc(nummapthings * sizeof (mapthing_t));
|
||||
|
||||
if (!savebuf_p)
|
||||
|
@ -908,12 +926,12 @@ static void P_SpawnMapThings(boolean spawnemblems)
|
|||
|
||||
length = savebuf_p - savebuffer;
|
||||
|
||||
FIL_WriteFile(va("newthings%d.lmp", gamemap), savebuffer, length);
|
||||
FIL_WriteFile(va("%s.lmp", filepath), savebuffer, length);
|
||||
free(savebuffer);
|
||||
savebuf_p = NULL;
|
||||
|
||||
CONS_Printf(M_GetText("newthings%d.lmp saved.\n"), gamemap);
|
||||
}*/
|
||||
CONS_Printf(M_GetText("%s.lmp saved.\n"), filepath);
|
||||
}
|
||||
|
||||
//
|
||||
// MAP LOADING FUNCTIONS
|
||||
|
@ -2144,6 +2162,60 @@ typedef struct
|
|||
mapthing_t *angleanchor;
|
||||
} sectorspecialthings_t;
|
||||
|
||||
static void P_WriteTextmap_Things(FILE *f, const mapthing_t *wmapthings)
|
||||
{
|
||||
size_t i, j;
|
||||
mtag_t firsttag;
|
||||
|
||||
// Actual writing
|
||||
for (i = 0; i < nummapthings; i++)
|
||||
{
|
||||
fprintf(f, "thing // %s\n", sizeu1(i));
|
||||
fprintf(f, "{\n");
|
||||
firsttag = Tag_FGet(&wmapthings[i].tags);
|
||||
if (firsttag != 0)
|
||||
fprintf(f, "id = %d;\n", firsttag);
|
||||
if (wmapthings[i].tags.count > 1)
|
||||
{
|
||||
fprintf(f, "moreids = \"");
|
||||
for (j = 1; j < wmapthings[i].tags.count; j++)
|
||||
{
|
||||
if (j > 1)
|
||||
fprintf(f, " ");
|
||||
fprintf(f, "%d", wmapthings[i].tags.tags[j]);
|
||||
}
|
||||
fprintf(f, "\";\n");
|
||||
}
|
||||
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].spritexscale != FRACUNIT)
|
||||
fprintf(f, "scalex = %f;\n", FIXED_TO_FLOAT(wmapthings[i].spritexscale));
|
||||
if (wmapthings[i].spriteyscale != FRACUNIT)
|
||||
fprintf(f, "scaley = %f;\n", FIXED_TO_FLOAT(wmapthings[i].spriteyscale));
|
||||
if (wmapthings[i].scale != FRACUNIT)
|
||||
fprintf(f, "mobjscale = %f;\n", FIXED_TO_FLOAT(wmapthings[i].scale));
|
||||
if (wmapthings[i].options & MTF_OBJECTFLIP)
|
||||
fprintf(f, "flip = true;\n");
|
||||
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]);
|
||||
fprintf(f, "}\n");
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void P_WriteTextmap(void)
|
||||
{
|
||||
size_t i, j;
|
||||
|
@ -2411,52 +2483,7 @@ static void P_WriteTextmap(void)
|
|||
}
|
||||
|
||||
fprintf(f, "namespace = \"srb2\";\n");
|
||||
for (i = 0; i < nummapthings; i++)
|
||||
{
|
||||
fprintf(f, "thing // %s\n", sizeu1(i));
|
||||
fprintf(f, "{\n");
|
||||
firsttag = Tag_FGet(&wmapthings[i].tags);
|
||||
if (firsttag != 0)
|
||||
fprintf(f, "id = %d;\n", firsttag);
|
||||
if (wmapthings[i].tags.count > 1)
|
||||
{
|
||||
fprintf(f, "moreids = \"");
|
||||
for (j = 1; j < wmapthings[i].tags.count; j++)
|
||||
{
|
||||
if (j > 1)
|
||||
fprintf(f, " ");
|
||||
fprintf(f, "%d", wmapthings[i].tags.tags[j]);
|
||||
}
|
||||
fprintf(f, "\";\n");
|
||||
}
|
||||
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].spritexscale != FRACUNIT)
|
||||
fprintf(f, "scalex = %f;\n", FIXED_TO_FLOAT(wmapthings[i].spritexscale));
|
||||
if (wmapthings[i].spriteyscale != FRACUNIT)
|
||||
fprintf(f, "scaley = %f;\n", FIXED_TO_FLOAT(wmapthings[i].spriteyscale));
|
||||
if (wmapthings[i].scale != FRACUNIT)
|
||||
fprintf(f, "mobjscale = %f;\n", FIXED_TO_FLOAT(wmapthings[i].scale));
|
||||
if (wmapthings[i].options & MTF_OBJECTFLIP)
|
||||
fprintf(f, "flip = true;\n");
|
||||
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]);
|
||||
fprintf(f, "}\n");
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
P_WriteTextmap_Things(f, wmapthings);
|
||||
|
||||
for (i = 0; i < numvertexes; i++)
|
||||
{
|
||||
|
|
|
@ -71,7 +71,7 @@ boolean P_AddFolder(const char *folderpath);
|
|||
boolean P_RunSOC(const char *socfilename);
|
||||
void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num);
|
||||
void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num);
|
||||
//void P_WriteThings(void);
|
||||
void P_WriteThings(const char *filepath);
|
||||
size_t P_PrecacheLevelFlats(void);
|
||||
void P_AllocMapHeader(INT16 i);
|
||||
|
||||
|
|
Loading…
Reference in a new issue