Introducing skin patching! (Also, DELFILE is super dead.)

* Create a normal skin, but replace the S_SKIN lump with an almost empty one named P_SKIN.
* Provide "name = existing skin name as one of the first line (comments allowed)
* Reset individual spritenames back to zero sprite2s (or one for SPR2_STND to prevent complete removal) via "reset = SPR2_****" statements.
* No support for changing skin properties that are non-visual at the moment, but I don't really feel like it's wise to have those changable with patch alone. (Hello, tons of "modern Sonic" wadfiles which just change vanilla Sonic's ability to CA_HOMINGTHOK!)
* Sprites patch over.

To see an example in action, look at <root>/toaster/smilespatch.wad.
This commit is contained in:
toasterbabe 2017-01-17 00:16:23 +00:00
parent 90166d7b1f
commit 299ba49161
13 changed files with 201 additions and 687 deletions

View File

@ -60,9 +60,6 @@ static void Got_WeaponPref(UINT8 **cp, INT32 playernum);
static void Got_Mapcmd(UINT8 **cp, INT32 playernum);
static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum);
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum);
#ifdef DELFILE
static void Got_Delfilecmd(UINT8 **cp, INT32 playernum);
#endif
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum);
static void Got_Pause(UINT8 **cp, INT32 playernum);
static void Got_Suicide(UINT8 **cp, INT32 playernum);
@ -110,9 +107,6 @@ static void Command_ResetCamera_f(void);
static void Command_Addfile(void);
static void Command_ListWADS_f(void);
#ifdef DELFILE
static void Command_Delfile(void);
#endif
static void Command_RunSOC(void);
static void Command_Pause(void);
static void Command_Suicide(void);
@ -385,7 +379,6 @@ const char *netxcmdnames[MAXNETXCMD - 1] =
"RANDOMSEED",
"RUNSOC",
"REQADDFILE",
"DELFILE",
"SETMOTD",
"SUICIDE",
#ifdef HAVE_BLUA
@ -411,9 +404,6 @@ void D_RegisterServerCommands(void)
RegisterNetXCmd(XD_EXITLEVEL, Got_ExitLevelcmd);
RegisterNetXCmd(XD_ADDFILE, Got_Addfilecmd);
RegisterNetXCmd(XD_REQADDFILE, Got_RequestAddfilecmd);
#ifdef DELFILE
RegisterNetXCmd(XD_DELFILE, Got_Delfilecmd);
#endif
RegisterNetXCmd(XD_PAUSE, Got_Pause);
RegisterNetXCmd(XD_SUICIDE, Got_Suicide);
RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd);
@ -447,9 +437,6 @@ void D_RegisterServerCommands(void)
COM_AddCommand("addfile", Command_Addfile);
COM_AddCommand("listwad", Command_ListWADS_f);
#ifdef DELFILE
COM_AddCommand("delfile", Command_Delfile);
#endif
COM_AddCommand("runsoc", Command_RunSOC);
COM_AddCommand("pause", Command_Pause);
COM_AddCommand("suicide", Command_Suicide);
@ -3032,42 +3019,6 @@ static void Command_Addfile(void)
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
}
#ifdef DELFILE
/** removes the last added pwad at runtime.
* Searches for sounds, maps, music and images to remove
*/
static void Command_Delfile(void)
{
if (gamestate == GS_LEVEL)
{
CONS_Printf(M_GetText("You must NOT be in a level to use this.\n"));
return;
}
if (netgame && !(server || adminplayer == consoleplayer))
{
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
return;
}
if (numwadfiles <= mainwads)
{
CONS_Printf(M_GetText("No additional WADs are loaded.\n"));
return;
}
if (!(netgame || multiplayer))
{
P_DelWadFile();
if (mainwads == numwadfiles && modifiedgame)
modifiedgame = false;
return;
}
SendNetXCmd(XD_DELFILE, NULL, 0);
}
#endif
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
{
char filename[241];
@ -3124,33 +3075,6 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
COM_BufAddText(va("addfile %s\n", filename));
}
#ifdef DELFILE
static void Got_Delfilecmd(UINT8 **cp, INT32 playernum)
{
if (playernum != serverplayer && playernum != adminplayer)
{
CONS_Alert(CONS_WARNING, M_GetText("Illegal delfile command received from %s\n"), player_names[playernum]);
if (server)
{
XBOXSTATIC UINT8 buf[2];
buf[0] = (UINT8)playernum;
buf[1] = KICK_MSG_CON_FAIL;
SendNetXCmd(XD_KICK, &buf, 2);
}
return;
}
(void)cp;
if (numwadfiles <= mainwads) //sanity
return;
P_DelWadFile();
if (mainwads == numwadfiles && modifiedgame)
modifiedgame = false;
}
#endif
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
{
char filename[241];

View File

@ -151,7 +151,6 @@ typedef enum
XD_RANDOMSEED, // 15
XD_RUNSOC, // 16
XD_REQADDFILE, // 17
XD_DELFILE, // 18
XD_SETMOTD, // 19
XD_SUICIDE, // 20
#ifdef HAVE_BLUA

View File

@ -78,97 +78,6 @@ static int dbg_line;
static boolean gamedataadded = false;
#ifdef DELFILE
typedef struct undehacked_s
{
char *undata;
struct undehacked_s *next;
} undehacked_t;
static UINT16 unsocwad;
static undehacked_t *unsocdata[MAX_WADFILES];
static boolean disableundo = false;
void DEH_WriteUndoline(const char *value, const char *data, undotype_f flags)
{
const char *eqstr = " = ";
const char *space = " ";
const char *pader = eqstr;
undehacked_t *newdata;
if (disableundo || !unsocwad)
return;
if ((newdata = malloc(sizeof(*newdata))) == NULL)
I_Error("Out of memory for unsoc line");
if (flags & UNDO_SPACE)
pader = space;
if (flags & UNDO_ENDTEXT && !data)
data = space;
if (value)
{
const size_t plen = strlen(pader);
const char *pound = "#";
char *undata = NULL;
const size_t elen = strlen(pound);
size_t vlen = strlen(value), dlen = 0, len = 1;
if (*(value+vlen-1) == '\n')
vlen--; // lnet not copy the ending \n
if (flags & UNDO_ENDTEXT)
len += elen; // let malloc more space
if (flags & UNDO_NEWLINE)
len++; // more space for the beginning \n
if (data)
{
dlen = strlen(data);
if (flags & UNDO_CUTLINE && *(data+dlen-1) == '\n')
dlen--; // let not copy the ending \n
newdata->undata = malloc(vlen+plen+dlen+len);
newdata->undata[vlen+plen+dlen+len-1] = '\0';
}
else
{
newdata->undata = malloc(vlen+len);
newdata->undata[vlen+len-1] = '\0';
}
if (newdata->undata)
{
undata = newdata->undata;
*undata = '\0';
}
else
{
free(newdata);
I_Error("Out of memory for unsoc data");
}
if (flags & UNDO_NEWLINE) // let start with \n
strcat(undata, "\n");
strncat(undata, value, vlen);
if (data) // value+pader+data
strncat(strncat(undata, pader, plen), data, dlen);
if (flags & UNDO_ENDTEXT) // let end the text
strncat(undata, pound, elen);
}
else
newdata->undata = NULL;
newdata->next = unsocdata[unsocwad];
unsocdata[unsocwad] = newdata;
}
#endif
ATTRINLINE static FUNCINLINE char myfget_color(MYFILE *f)
{
char c = *f->curpos++;
@ -460,8 +369,6 @@ static void readPlayer(MYFILE *f, INT32 num)
INT32 i;
boolean slotfound = false;
DEH_WriteUndoline("PLAYERTEXT", description[num].notes, UNDO_ENDTEXT);
do
{
if (myfgets(s, MAXLINELEN, f))
@ -530,7 +437,6 @@ static void readPlayer(MYFILE *f, INT32 num)
{
if (!slotfound && (slotfound = findFreeSlot(&num, f->wad)) == false)
goto done;
DEH_WriteUndoline(word, &description[num].picname[0], UNDO_NONE);
strncpy(description[num].picname, word2, 8);
}
@ -551,7 +457,6 @@ static void readPlayer(MYFILE *f, INT32 num)
*/
if (i != IT_DISABLED && !slotfound && (slotfound = findFreeSlot(&num, f->wad)) == false)
goto done;
DEH_WriteUndoline(word, va("%d", PlayerMenu[num].status), UNDO_NONE);
PlayerMenu[num].status = (INT16)i;
}
else if (fastcmp(word, "SKINNAME"))
@ -559,7 +464,6 @@ static void readPlayer(MYFILE *f, INT32 num)
// Send to free slot.
if (!slotfound && (slotfound = findFreeSlot(&num, f->wad)) == false)
goto done;
DEH_WriteUndoline(word, description[num].skinname, UNDO_NONE);
strlcpy(description[num].skinname, word2, sizeof description[num].skinname);
strlwr(description[num].skinname);
@ -569,11 +473,6 @@ static void readPlayer(MYFILE *f, INT32 num)
}
} while (!myfeof(f)); // finish when the line is empty
#ifdef DELFILE
if (slotfound)
DEH_WriteUndoline("MENUPOSITION", va("%d", num), UNDO_NONE);
#endif
done:
Z_Free(s);
}
@ -711,122 +610,98 @@ static void readthing(MYFILE *f, INT32 num)
if (fastcmp(word, "MAPTHINGNUM") || fastcmp(word, "DOOMEDNUM"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].doomednum), UNDO_NONE);
mobjinfo[num].doomednum = (INT32)atoi(word2);
}
else if (fastcmp(word, "SPAWNSTATE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].spawnstate), UNDO_NONE);
mobjinfo[num].spawnstate = get_number(word2);
}
else if (fastcmp(word, "SPAWNHEALTH"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].spawnhealth), UNDO_NONE);
mobjinfo[num].spawnhealth = (INT32)get_number(word2);
}
else if (fastcmp(word, "SEESTATE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].seestate), UNDO_NONE);
mobjinfo[num].seestate = get_number(word2);
}
else if (fastcmp(word, "SEESOUND"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].seesound), UNDO_NONE);
mobjinfo[num].seesound = get_number(word2);
}
else if (fastcmp(word, "REACTIONTIME"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].reactiontime), UNDO_NONE);
mobjinfo[num].reactiontime = (INT32)get_number(word2);
}
else if (fastcmp(word, "ATTACKSOUND"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].attacksound), UNDO_NONE);
mobjinfo[num].attacksound = get_number(word2);
}
else if (fastcmp(word, "PAINSTATE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].painstate), UNDO_NONE);
mobjinfo[num].painstate = get_number(word2);
}
else if (fastcmp(word, "PAINCHANCE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].painchance), UNDO_NONE);
mobjinfo[num].painchance = (INT32)get_number(word2);
}
else if (fastcmp(word, "PAINSOUND"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].painsound), UNDO_NONE);
mobjinfo[num].painsound = get_number(word2);
}
else if (fastcmp(word, "MELEESTATE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].meleestate), UNDO_NONE);
mobjinfo[num].meleestate = get_number(word2);
}
else if (fastcmp(word, "MISSILESTATE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].missilestate), UNDO_NONE);
mobjinfo[num].missilestate = get_number(word2);
}
else if (fastcmp(word, "DEATHSTATE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].deathstate), UNDO_NONE);
mobjinfo[num].deathstate = get_number(word2);
}
else if (fastcmp(word, "DEATHSOUND"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].deathsound), UNDO_NONE);
mobjinfo[num].deathsound = get_number(word2);
}
else if (fastcmp(word, "XDEATHSTATE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].xdeathstate), UNDO_NONE);
mobjinfo[num].xdeathstate = get_number(word2);
}
else if (fastcmp(word, "SPEED"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].speed), UNDO_NONE);
mobjinfo[num].speed = get_number(word2);
}
else if (fastcmp(word, "RADIUS"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].radius), UNDO_NONE);
mobjinfo[num].radius = get_number(word2);
}
else if (fastcmp(word, "HEIGHT"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].height), UNDO_NONE);
mobjinfo[num].height = get_number(word2);
}
else if (fastcmp(word, "DISPOFFSET"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].dispoffset), UNDO_NONE);
mobjinfo[num].dispoffset = get_number(word2);
}
else if (fastcmp(word, "MASS"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].mass), UNDO_NONE);
mobjinfo[num].mass = (INT32)get_number(word2);
}
else if (fastcmp(word, "DAMAGE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].damage), UNDO_NONE);
mobjinfo[num].damage = (INT32)get_number(word2);
}
else if (fastcmp(word, "ACTIVESOUND"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].activesound), UNDO_NONE);
mobjinfo[num].activesound = get_number(word2);
}
else if (fastcmp(word, "FLAGS"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].flags), UNDO_NONE);
mobjinfo[num].flags = (INT32)get_number(word2);
}
else if (fastcmp(word, "RAISESTATE"))
{
DEH_WriteUndoline(word, va("%d", mobjinfo[num].raisestate), UNDO_NONE);
mobjinfo[num].raisestate = get_number(word2);
}
else
@ -870,37 +745,30 @@ static void readlight(MYFILE *f, INT32 num)
if (fastcmp(word, "TYPE"))
{
DEH_WriteUndoline(word, va("%d", lspr[num].type), UNDO_NONE);
lspr[num].type = (UINT16)value;
}
else if (fastcmp(word, "OFFSETX"))
{
DEH_WriteUndoline(word, va("%f", lspr[num].light_xoffset), UNDO_NONE);
lspr[num].light_xoffset = fvalue;
}
else if (fastcmp(word, "OFFSETY"))
{
DEH_WriteUndoline(word, va("%f", lspr[num].light_yoffset), UNDO_NONE);
lspr[num].light_yoffset = fvalue;
}
else if (fastcmp(word, "CORONACOLOR"))
{
DEH_WriteUndoline(word, va("%u", lspr[num].corona_color), UNDO_NONE);
lspr[num].corona_color = value;
}
else if (fastcmp(word, "CORONARADIUS"))
{
DEH_WriteUndoline(word, va("%f", lspr[num].corona_radius), UNDO_NONE);
lspr[num].corona_radius = fvalue;
}
else if (fastcmp(word, "DYNAMICCOLOR"))
{
DEH_WriteUndoline(word, va("%u", lspr[num].dynamic_color), UNDO_NONE);
lspr[num].dynamic_color = value;
}
else if (fastcmp(word, "DYNAMICRADIUS"))
{
DEH_WriteUndoline(word, va("%f", lspr[num].dynamic_radius), UNDO_NONE);
lspr[num].dynamic_radius = fvalue;
/// \note Update the sqrradius! unnecessary?
@ -947,7 +815,6 @@ static void readspritelight(MYFILE *f, INT32 num)
INT32 oldvar;
for (oldvar = 0; t_lspr[num] != &lspr[oldvar]; oldvar++)
;
DEH_WriteUndoline(word, va("%d", oldvar), UNDO_NONE);
t_lspr[num] = &lspr[value];
}
else
@ -1030,8 +897,6 @@ static void readlevelheader(MYFILE *f, INT32 num)
INT32 i;
// Reset all previous map header information
// This call automatically saves all previous information when DELFILE is defined.
// We don't need to do it ourselves.
P_AllocMapHeader((INT16)(num-1));
do
@ -1437,8 +1302,6 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum)
UINT16 usi;
UINT8 picid;
DEH_WriteUndoline("SCENETEXT", cutscenes[num]->scene[scenenum].text, UNDO_ENDTEXT);
do
{
if (myfgets(s, MAXLINELEN, f))
@ -1515,7 +1378,6 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum)
if (fastcmp(word, "NUMBEROFPICS"))
{
DEH_WriteUndoline(word, va("%d", cutscenes[num]->scene[scenenum].numpics), UNDO_NONE);
cutscenes[num]->scene[scenenum].numpics = (UINT8)i;
}
else if (fastncmp(word, "PIC", 3))
@ -1530,27 +1392,22 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum)
if (fastcmp(word+4, "NAME"))
{
DEH_WriteUndoline(word, cutscenes[num]->scene[scenenum].picname[picid], UNDO_NONE);
strncpy(cutscenes[num]->scene[scenenum].picname[picid], word2, 8);
}
else if (fastcmp(word+4, "HIRES"))
{
DEH_WriteUndoline(word, va("%d", cutscenes[num]->scene[scenenum].pichires[picid]), UNDO_NONE);
cutscenes[num]->scene[scenenum].pichires[picid] = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y');
}
else if (fastcmp(word+4, "DURATION"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].picduration[picid]), UNDO_NONE);
cutscenes[num]->scene[scenenum].picduration[picid] = usi;
}
else if (fastcmp(word+4, "XCOORD"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].xcoord[picid]), UNDO_NONE);
cutscenes[num]->scene[scenenum].xcoord[picid] = usi;
}
else if (fastcmp(word+4, "YCOORD"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].ycoord[picid]), UNDO_NONE);
cutscenes[num]->scene[scenenum].ycoord[picid] = usi;
}
else
@ -1558,14 +1415,12 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum)
}
else if (fastcmp(word, "MUSIC"))
{
DEH_WriteUndoline(word, cutscenes[num]->scene[scenenum].musswitch, UNDO_NONE);
strncpy(cutscenes[num]->scene[scenenum].musswitch, word2, 7);
cutscenes[num]->scene[scenenum].musswitch[6] = 0;
}
#ifdef MUSICSLOT_COMPATIBILITY
else if (fastcmp(word, "MUSICSLOT"))
{
DEH_WriteUndoline(word, cutscenes[num]->scene[scenenum].musswitch, UNDO_NONE);
i = get_mus(word2, true);
if (i && i <= 1035)
snprintf(cutscenes[num]->scene[scenenum].musswitch, 7, "%sM", G_BuildMapName(i));
@ -1578,37 +1433,30 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum)
#endif
else if (fastcmp(word, "MUSICTRACK"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musswitchflags), UNDO_NONE);
cutscenes[num]->scene[scenenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK;
}
else if (fastcmp(word, "MUSICLOOP"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musicloop), UNDO_NONE);
cutscenes[num]->scene[scenenum].musicloop = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y');
}
else if (fastcmp(word, "TEXTXPOS"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].textxpos), UNDO_NONE);
cutscenes[num]->scene[scenenum].textxpos = usi;
}
else if (fastcmp(word, "TEXTYPOS"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].textypos), UNDO_NONE);
cutscenes[num]->scene[scenenum].textypos = usi;
}
else if (fastcmp(word, "FADEINID"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].fadenum), UNDO_NONE);
cutscenes[num]->scene[scenenum].fadeinid = (UINT8)i;
}
else if (fastcmp(word, "FADEOUTID"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].fadenum), UNDO_NONE);
cutscenes[num]->scene[scenenum].fadeoutid = (UINT8)i;
}
else if (fastcmp(word, "FADECOLOR"))
{
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].fadenum), UNDO_NONE);
cutscenes[num]->scene[scenenum].fadecolor = (UINT8)i;
}
else
@ -1626,9 +1474,6 @@ static void readcutscene(MYFILE *f, INT32 num)
char *word2;
char *tmp;
INT32 value;
#ifdef DELFILE
const INT32 oldnumscenes = cutscenes[num]->numscenes;
#endif
// Allocate memory for this cutscene if we don't yet have any
if (!cutscenes[num])
@ -1671,8 +1516,6 @@ static void readcutscene(MYFILE *f, INT32 num)
if (1 <= value && value <= 128)
{
readcutscenescene(f, num, value - 1);
DEH_WriteUndoline(word, word2, UNDO_SPACE|UNDO_CUTLINE);
DEH_WriteUndoline("NUMSCENES", va("%d", oldnumscenes), UNDO_SPACE);
}
else
deh_warning("Scene number %d out of range (1 - 128)", value);
@ -1725,12 +1568,10 @@ static void readhuditem(MYFILE *f, INT32 num)
if (fastcmp(word, "X"))
{
DEH_WriteUndoline(word, va("%d", hudinfo[num].x), UNDO_NONE);
hudinfo[num].x = i;
}
else if (fastcmp(word, "Y"))
{
DEH_WriteUndoline(word, va("%d", hudinfo[num].y), UNDO_NONE);
hudinfo[num].y = i;
}
else
@ -2015,32 +1856,26 @@ static void readframe(MYFILE *f, INT32 num)
if (fastcmp(word1, "SPRITENUMBER") || fastcmp(word1, "SPRITENAME"))
{
DEH_WriteUndoline(word1, va("%u", states[num].sprite), UNDO_NONE);
states[num].sprite = get_sprite(word2);
}
else if (fastcmp(word1, "SPRITESUBNUMBER") || fastcmp(word1, "SPRITEFRAME"))
{
DEH_WriteUndoline(word1, va("%d", states[num].frame), UNDO_NONE);
states[num].frame = (INT32)get_number(word2); // So the FF_ flags get calculated
}
else if (fastcmp(word1, "DURATION"))
{
DEH_WriteUndoline(word1, va("%u", states[num].tics), UNDO_NONE);
states[num].tics = (INT32)get_number(word2); // So TICRATE can be used
}
else if (fastcmp(word1, "NEXT"))
{
DEH_WriteUndoline(word1, va("%d", states[num].nextstate), UNDO_NONE);
states[num].nextstate = get_state(word2);
}
else if (fastcmp(word1, "VAR1"))
{
DEH_WriteUndoline(word1, va("%d", states[num].var1), UNDO_NONE);
states[num].var1 = (INT32)get_number(word2);
}
else if (fastcmp(word1, "VAR2"))
{
DEH_WriteUndoline(word1, va("%d", states[num].var2), UNDO_NONE);
states[num].var2 = (INT32)get_number(word2);
}
else if (fastcmp(word1, "ACTION"))
@ -2065,10 +1900,7 @@ static void readframe(MYFILE *f, INT32 num)
for (z = 0; actionpointers[z].name; z++)
{
if (actionpointers[z].action.acv == states[num].action.acv)
{
DEH_WriteUndoline(word1, actionpointers[z].name, UNDO_NONE);
break;
}
}
z = 0;
@ -2142,17 +1974,14 @@ static void readsound(MYFILE *f, INT32 num, const char *savesfxnames[])
}
else */if (fastcmp(word, "SINGULAR"))
{
DEH_WriteUndoline(word, va("%d", S_sfx[num].singularity), UNDO_NONE);
S_sfx[num].singularity = value;
}
else if (fastcmp(word, "PRIORITY"))
{
DEH_WriteUndoline(word, va("%d", S_sfx[num].priority), UNDO_NONE);
S_sfx[num].priority = value;
}
else if (fastcmp(word, "FLAGS"))
{
DEH_WriteUndoline(word, va("%d", S_sfx[num].pitch), UNDO_NONE);
S_sfx[num].pitch = value;
}
else
@ -2193,11 +2022,7 @@ static boolean GoodDataFileName(const char *s)
p = s + strlen(s) - strlen(tail);
if (p <= s) return false; // too short
if (!fasticmp(p, tail)) return false; // doesn't end in .dat
#ifdef DELFILE
if (fasticmp(s, "gamedata.dat") && !disableundo) return false;
#else
if (fasticmp(s, "gamedata.dat")) return false;
#endif
return true;
}
@ -2210,17 +2035,6 @@ static void reademblemdata(MYFILE *f, INT32 num)
char *tmp;
INT32 value;
// Reset all data initially
DEH_WriteUndoline("TYPE", va("%d", emblemlocations[num-1].type), UNDO_NONE);
DEH_WriteUndoline("X", va("%d", emblemlocations[num-1].x), UNDO_NONE);
DEH_WriteUndoline("Y", va("%d", emblemlocations[num-1].y), UNDO_NONE);
DEH_WriteUndoline("Z", va("%d", emblemlocations[num-1].z), UNDO_NONE);
DEH_WriteUndoline("MAPNUM", va("%d", emblemlocations[num-1].level), UNDO_NONE);
DEH_WriteUndoline("VAR", va("%d", emblemlocations[num-1].var), UNDO_NONE);
DEH_WriteUndoline("SPRITE", va("%d", emblemlocations[num-1].sprite), UNDO_NONE);
DEH_WriteUndoline("COLOR", va("%d", emblemlocations[num-1].color), UNDO_NONE);
DEH_WriteUndoline("HINT", extraemblems[num-1].hint, UNDO_NONE);
memset(&emblemlocations[num-1], 0, sizeof(emblem_t));
do
@ -2354,13 +2168,6 @@ static void readextraemblemdata(MYFILE *f, INT32 num)
char *tmp;
INT32 value;
// Reset all data initially
DEH_WriteUndoline("NAME", extraemblems[num-1].name, UNDO_NONE);
DEH_WriteUndoline("OBJECTIVE", extraemblems[num-1].description, UNDO_NONE);
DEH_WriteUndoline("CONDITIONSET", va("%d", extraemblems[num-1].conditionset), UNDO_NONE);
DEH_WriteUndoline("SPRITE", va("%d", extraemblems[num-1].sprite), UNDO_NONE);
DEH_WriteUndoline("COLOR", va("%d", extraemblems[num-1].color), UNDO_NONE);
memset(&extraemblems[num-1], 0, sizeof(extraemblem_t));
do
@ -2435,16 +2242,6 @@ static void readunlockable(MYFILE *f, INT32 num)
char *tmp;
INT32 i;
// Same deal with unlockables, clear all first
DEH_WriteUndoline("NAME", unlockables[num].name, UNDO_NONE);
DEH_WriteUndoline("OBJECTIVE", unlockables[num].objective, UNDO_NONE);
DEH_WriteUndoline("HEIGHT", va("%d", unlockables[num].height), UNDO_NONE);
DEH_WriteUndoline("CONDITIONSET", va("%d", unlockables[num].conditionset), UNDO_NONE);
DEH_WriteUndoline("TYPE", va("%d", unlockables[num].type), UNDO_NONE);
DEH_WriteUndoline("NOCECHO", va("%d", unlockables[num].nocecho), UNDO_NONE);
DEH_WriteUndoline("NOCHECKLIST", va("%d", unlockables[num].nochecklist), UNDO_NONE);
DEH_WriteUndoline("VAR", va("%d", unlockables[num].variable), UNDO_NONE);
memset(&unlockables[num], 0, sizeof(unlockable_t));
do
@ -2825,19 +2622,16 @@ static void readtexture(MYFILE *f, const char *name)
// Width of the texture.
if (fastcmp(word, "WIDTH"))
{
DEH_WriteUndoline(word, va("%d", width), UNDO_NONE);
width = SHORT((UINT16)value);
}
// Height of the texture.
else if (fastcmp(word, "HEIGHT"))
{
DEH_WriteUndoline(word, va("%d", height), UNDO_NONE);
height = SHORT((UINT16)value);
}
// Number of patches the texture has.
else if (fastcmp(word, "NUMPATCHES"))
{
DEH_WriteUndoline(word, va("%d", patchcount), UNDO_NONE);
patchcount = SHORT((UINT16)value);
}
else
@ -2941,13 +2735,11 @@ static void readpatch(MYFILE *f, const char *name, UINT16 wad)
// X position of the patch in the texture.
if (fastcmp(word, "X"))
{
//DEH_WriteUndoline(word, va("%d", patch->originx), UNDO_NONE);
patch.originx = (INT16)value;
}
// Y position of the patch in the texture.
else if (fastcmp(word, "Y"))
{
//DEH_WriteUndoline(word, va("%d", patch->originy), UNDO_NONE);
patch.originy = (INT16)value;
}
else
@ -3022,7 +2814,6 @@ static void readmaincfg(MYFILE *f)
else
value = get_number(word2);
DEH_WriteUndoline(word, va("%d", spstage_start), UNDO_NONE);
spstage_start = (INT16)value;
}
else if (fastcmp(word, "SSTAGE_START"))
@ -3036,79 +2827,64 @@ static void readmaincfg(MYFILE *f)
else
value = get_number(word2);
DEH_WriteUndoline(word, va("%d", sstage_start), UNDO_NONE);
sstage_start = (INT16)value;
sstage_end = (INT16)(sstage_start+6); // 7 special stages total
}
else if (fastcmp(word, "USENIGHTSSS"))
{
DEH_WriteUndoline(word, va("%d", useNightsSS), UNDO_NONE);
useNightsSS = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y');
}
else if (fastcmp(word, "REDTEAM"))
{
DEH_WriteUndoline(word, va("%d", skincolor_redteam), UNDO_NONE);
skincolor_redteam = (UINT8)get_number(word2);
}
else if (fastcmp(word, "BLUETEAM"))
{
DEH_WriteUndoline(word, va("%d", skincolor_blueteam), UNDO_NONE);
skincolor_blueteam = (UINT8)get_number(word2);
}
else if (fastcmp(word, "REDRING"))
{
DEH_WriteUndoline(word, va("%d", skincolor_redring), UNDO_NONE);
skincolor_redring = (UINT8)get_number(word2);
}
else if (fastcmp(word, "BLUERING"))
{
DEH_WriteUndoline(word, va("%d", skincolor_bluering), UNDO_NONE);
skincolor_bluering = (UINT8)get_number(word2);
}
else if (fastcmp(word, "INVULNTICS"))
{
DEH_WriteUndoline(word, va("%u", invulntics), UNDO_NONE);
invulntics = (UINT16)get_number(word2);
}
else if (fastcmp(word, "SNEAKERTICS"))
{
DEH_WriteUndoline(word, va("%u", sneakertics), UNDO_NONE);
sneakertics = (UINT16)get_number(word2);
}
else if (fastcmp(word, "FLASHINGTICS"))
{
DEH_WriteUndoline(word, va("%u", flashingtics), UNDO_NONE);
flashingtics = (UINT16)get_number(word2);
}
else if (fastcmp(word, "TAILSFLYTICS"))
{
DEH_WriteUndoline(word, va("%u", tailsflytics), UNDO_NONE);
tailsflytics = (UINT16)get_number(word2);
}
else if (fastcmp(word, "UNDERWATERTICS"))
{
DEH_WriteUndoline(word, va("%u", underwatertics), UNDO_NONE);
underwatertics = (UINT16)get_number(word2);
}
else if (fastcmp(word, "SPACETIMETICS"))
{
DEH_WriteUndoline(word, va("%u", spacetimetics), UNDO_NONE);
spacetimetics = (UINT16)get_number(word2);
}
else if (fastcmp(word, "EXTRALIFETICS"))
{
DEH_WriteUndoline(word, va("%u", extralifetics), UNDO_NONE);
extralifetics = (UINT16)get_number(word2);
}
else if (fastcmp(word, "GAMEOVERTICS"))
{
DEH_WriteUndoline(word, va("%u", gameovertics), UNDO_NONE);
gameovertics = get_number(word2);
}
else if (fastcmp(word, "INTROTOPLAY"))
{
DEH_WriteUndoline(word, va("%d", introtoplay), UNDO_NONE);
introtoplay = (UINT8)get_number(word2);
// range check, you morons.
if (introtoplay > 128)
@ -3116,17 +2892,14 @@ static void readmaincfg(MYFILE *f)
}
else if (fastcmp(word, "LOOPTITLE"))
{
DEH_WriteUndoline(word, va("%d", looptitle), UNDO_NONE);
looptitle = (boolean)(value || word2[0] == 'T' || word2[0] == 'Y');
}
else if (fastcmp(word, "TITLESCROLLSPEED"))
{
DEH_WriteUndoline(word, va("%d", titlescrollspeed), UNDO_NONE);
titlescrollspeed = get_number(word2);
}
else if (fastcmp(word, "CREDITSCUTSCENE"))
{
DEH_WriteUndoline(word, va("%d", creditscutscene), UNDO_NONE);
creditscutscene = (UINT8)get_number(word2);
// range check, you morons.
if (creditscutscene > 128)
@ -3134,32 +2907,26 @@ static void readmaincfg(MYFILE *f)
}
else if (fastcmp(word, "DISABLESPEEDADJUST"))
{
DEH_WriteUndoline(word, va("%d", disableSpeedAdjust), UNDO_NONE);
disableSpeedAdjust = (UINT8)get_number(word2);
}
else if (fastcmp(word, "NUMDEMOS"))
{
DEH_WriteUndoline(word, va("%d", numDemos), UNDO_NONE);
numDemos = (UINT8)get_number(word2);
}
else if (fastcmp(word, "DEMODELAYTIME"))
{
DEH_WriteUndoline(word, va("%d", demoDelayTime), UNDO_NONE);
demoDelayTime = get_number(word2);
}
else if (fastcmp(word, "DEMOIDLETIME"))
{
DEH_WriteUndoline(word, va("%d", demoIdleTime), UNDO_NONE);
demoIdleTime = get_number(word2);
}
else if (fastcmp(word, "USE1UPSOUND"))
{
DEH_WriteUndoline(word, va("%u", use1upSound), UNDO_NONE);
use1upSound = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y');
}
else if (fastcmp(word, "MAXXTRALIFE"))
{
DEH_WriteUndoline(word, va("%u", maxXtraLife), UNDO_NONE);
maxXtraLife = (UINT8)get_number(word2);
}
@ -3173,7 +2940,6 @@ static void readmaincfg(MYFILE *f)
I_Error("Maincfg: bad data file name '%s'\n", word2);
G_SaveGameData();
DEH_WriteUndoline(word, gamedatafilename, UNDO_NONE);
strlcpy(gamedatafilename, word2, sizeof (gamedatafilename));
strlwr(gamedatafilename);
savemoddata = true;
@ -3190,12 +2956,10 @@ static void readmaincfg(MYFILE *f)
}
else if (fastcmp(word, "RESETDATA"))
{
DEH_WriteUndoline(word, "0", UNDO_TODO); /// \todo
P_ResetData(value);
}
else if (fastcmp(word, "CUSTOMVERSION"))
{
DEH_WriteUndoline(word, customversionstring, UNDO_NONE);
strlcpy(customversionstring, word2, sizeof (customversionstring));
}
else
@ -3446,13 +3210,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
else if (fastcmp(word, "MAINCFG"))
{
readmaincfg(f);
DEH_WriteUndoline(word, "", UNDO_HEADER);
continue;
}
else if (fastcmp(word, "WIPES"))
{
readwipes(f);
DEH_WriteUndoline(word, "", UNDO_HEADER);
continue;
}
word2 = strtok(NULL, " ");
@ -3472,7 +3234,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Character %d out of range (0 - 31)", i);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
continue;
}
if (word2)
@ -3485,13 +3246,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
{
// Read texture from spec file.
readtexture(f, word2);
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "PATCH"))
{
// Read patch from spec file.
readpatch(f, word2, wad);
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "THING") || fastcmp(word, "MOBJ") || fastcmp(word, "OBJECT"))
{
@ -3504,7 +3263,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Thing %d out of range (1 - %d)", i, NUMMOBJTYPES-1);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
/* else if (fastcmp(word, "ANIMTEX"))
{
@ -3521,7 +3279,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Light number %d out of range (1 - %d)", i, NUMLIGHTS-1);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
#endif
}
else if (fastcmp(word, "SPRITE"))
@ -3536,7 +3293,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Sprite number %d out of range (0 - %d)", i, NUMSPRITES-1);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
#endif
}
else if (fastcmp(word, "LEVEL"))
@ -3555,7 +3311,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Level number %d out of range (1 - %d)", i, NUMMAPS);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "CUTSCENE"))
{
@ -3566,7 +3321,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Cutscene number %d out of range (1 - 128)", i);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "FRAME") || fastcmp(word, "STATE"))
{
@ -3579,7 +3333,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Frame %d out of range (0 - %d)", i, NUMSTATES-1);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
// <Callum> Added translations to this just in case its re-enabled
/* else if (fastcmp(word, "POINTER"))
@ -3614,7 +3367,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Sound %d out of range (0 - %d)", i, NUMSFX-1);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
/* else if (fastcmp(word, "SPRITE"))
{
@ -3647,7 +3399,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("HUD item number %d out of range (0 - %d)", i, NUMHUDITEMS-1);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "EMBLEM"))
{
@ -3667,7 +3418,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Emblem number %d out of range (1 - %d)", i, MAXEMBLEMS);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "EXTRAEMBLEM"))
{
@ -3687,7 +3437,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Extra emblem number %d out of range (1 - %d)", i, MAXEXTRAEMBLEMS);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "UNLOCKABLE"))
{
@ -3703,7 +3452,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Unlockable number %d out of range (1 - %d)", i, MAXUNLOCKABLES);
ignorelines(f);
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "CONDITIONSET"))
{
@ -3719,15 +3467,12 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
deh_warning("Condition set number %d out of range (1 - %d)", i, MAXCONDITIONSETS);
ignorelines(f);
}
// no undo support for this insanity yet
//DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "SRB2"))
{
INT32 ver = searchvalue(strtok(NULL, "\n"));
if (ver != PATCHVERSION)
deh_warning("Patch is for SRB2 version %d,\nonly version %d is supported", ver, PATCHVERSION);
//DEH_WriteUndoline(word, va("%d", ver), UNDO_NONE);
}
// Clear all data in certain locations (mostly for unlocks)
// Unless you REALLY want to piss people off,
@ -3797,9 +3542,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump)
{
MYFILE f;
#ifdef DELFILE
unsocwad = wad;
#endif
f.wad = wad;
f.size = W_LumpLengthPwad(wad, lump);
f.data = Z_Malloc(f.size + 1, PU_STATIC, NULL);
@ -3807,7 +3549,6 @@ void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump)
f.curpos = f.data;
f.data[f.size] = 0;
DEH_LoadDehackedFile(&f, wad);
DEH_WriteUndoline(va("# uload for wad: %u, lump: %u", wad, lump), NULL, UNDO_DONE);
Z_Free(f.data);
}
@ -3816,67 +3557,6 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum)
DEH_LoadDehackedLumpPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum));
}
#ifdef DELFILE
#define DUMPUNDONE
// read (un)dehacked lump in wad's memory
void DEH_UnloadDehackedWad(UINT16 wad)
{
undehacked_t *tmp, *curundo = unsocdata[wad];
MYFILE f;
size_t len = 0;
char *data;
#ifdef DUMPUNDONE
FILE *UNDO = fopen("undo.soc", "wt");
#endif
CONS_Printf(M_GetText("Unloading WAD SOC edits\n"));
while (curundo)
{
data = curundo->undata;
curundo = curundo->next;
if (data)
len += strlen(data);
len += 1;
#ifdef DUMPUNDONE
if (UNDO)
{
if (data)
fprintf(UNDO, "%s\n", data);
else
fprintf(UNDO, "\n");
}
#endif
}
#ifndef DUMPUNDONE
if (UNDO) fclose(UNDO);
#endif
if (!len) return;
f.size = len;
data = f.data = Z_Malloc(f.size + 1, PU_STATIC, NULL);
curundo = unsocdata[wad];
unsocdata[wad] = NULL;
while (curundo)
{
tmp = curundo;
curundo = curundo->next;
if (tmp->undata)
data += sprintf(data, "%s\n", tmp->undata);
else
data += sprintf(data, "\n");
if (tmp->undata) free(tmp->undata);
free(tmp);
}
f.wad = wad;
f.curpos = f.data;
f.data[f.size] = 0;
disableundo = true;
DEH_LoadDehackedFile(&f);
disableundo = false;
Z_Free(f.data);
}
#endif //DELFILE
////////////////////////////////////////////////////////////////////////////////
// CRAZY LIST OF STATE NAMES AND ALL FROM HERE DOWN
// TODO: Make this all a seperate file or something, like part of info.c??

View File

@ -27,13 +27,6 @@ typedef enum
UNDO_DONE = 0,
} undotype_f;
#ifdef DELFILE
void DEH_WriteUndoline(const char *value, const char *data, undotype_f flags);
void DEH_UnloadDehackedWad(UINT16 wad);
#else // null the undo lines
#define DEH_WriteUndoline(a,b,c)
#endif
void DEH_LoadDehackedLump(lumpnum_t lumpnum);
void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump);

View File

@ -483,10 +483,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
#define ESLOPE_TYPESHIM
#endif
/// Delete file while the game is running.
/// \note EXTREMELY buggy, tends to crash game.
//#define DELFILE
/// Allows the use of devmode in multiplayer. AKA "fishcake"
//#define NETGAME_DEVMODE

View File

@ -197,72 +197,41 @@ void P_DeleteFlickies(INT16 i)
static void P_ClearSingleMapHeaderInfo(INT16 i)
{
const INT16 num = (INT16)(i-1);
DEH_WriteUndoline("LEVELNAME", mapheaderinfo[num]->lvlttl, UNDO_NONE);
mapheaderinfo[num]->lvlttl[0] = '\0';
DEH_WriteUndoline("SUBTITLE", mapheaderinfo[num]->subttl, UNDO_NONE);
mapheaderinfo[num]->subttl[0] = '\0';
DEH_WriteUndoline("ACT", va("%d", mapheaderinfo[num]->actnum), UNDO_NONE);
mapheaderinfo[num]->actnum = 0;
DEH_WriteUndoline("TYPEOFLEVEL", va("%d", mapheaderinfo[num]->typeoflevel), UNDO_NONE);
mapheaderinfo[num]->typeoflevel = 0;
DEH_WriteUndoline("NEXTLEVEL", va("%d", mapheaderinfo[num]->nextlevel), UNDO_NONE);
mapheaderinfo[num]->nextlevel = (INT16)(i + 1);
DEH_WriteUndoline("MUSIC", mapheaderinfo[num]->musname, UNDO_NONE);
snprintf(mapheaderinfo[num]->musname, 7, "%sM", G_BuildMapName(i));
mapheaderinfo[num]->musname[6] = 0;
DEH_WriteUndoline("MUSICTRACK", va("%d", mapheaderinfo[num]->mustrack), UNDO_NONE);
mapheaderinfo[num]->mustrack = 0;
DEH_WriteUndoline("FORCECHARACTER", va("%d", mapheaderinfo[num]->forcecharacter), UNDO_NONE);
mapheaderinfo[num]->forcecharacter[0] = '\0';
DEH_WriteUndoline("WEATHER", va("%d", mapheaderinfo[num]->weather), UNDO_NONE);
mapheaderinfo[num]->weather = 0;
DEH_WriteUndoline("SKYNUM", va("%d", mapheaderinfo[num]->skynum), UNDO_NONE);
mapheaderinfo[num]->skynum = 1;
DEH_WriteUndoline("SKYBOXSCALEX", va("%d", mapheaderinfo[num]->skybox_scalex), UNDO_NONE);
mapheaderinfo[num]->skybox_scalex = 16;
DEH_WriteUndoline("SKYBOXSCALEY", va("%d", mapheaderinfo[num]->skybox_scaley), UNDO_NONE);
mapheaderinfo[num]->skybox_scaley = 16;
DEH_WriteUndoline("SKYBOXSCALEZ", va("%d", mapheaderinfo[num]->skybox_scalez), UNDO_NONE);
mapheaderinfo[num]->skybox_scalez = 16;
DEH_WriteUndoline("INTERSCREEN", mapheaderinfo[num]->interscreen, UNDO_NONE);
mapheaderinfo[num]->interscreen[0] = '#';
DEH_WriteUndoline("RUNSOC", mapheaderinfo[num]->runsoc, UNDO_NONE);
mapheaderinfo[num]->runsoc[0] = '#';
DEH_WriteUndoline("SCRIPTNAME", mapheaderinfo[num]->scriptname, UNDO_NONE);
mapheaderinfo[num]->scriptname[0] = '#';
DEH_WriteUndoline("PRECUTSCENENUM", va("%d", mapheaderinfo[num]->precutscenenum), UNDO_NONE);
mapheaderinfo[num]->precutscenenum = 0;
DEH_WriteUndoline("CUTSCENENUM", va("%d", mapheaderinfo[num]->cutscenenum), UNDO_NONE);
mapheaderinfo[num]->cutscenenum = 0;
DEH_WriteUndoline("COUNTDOWN", va("%d", mapheaderinfo[num]->countdown), UNDO_NONE);
mapheaderinfo[num]->countdown = 0;
DEH_WriteUndoline("PALLETE", va("%u", mapheaderinfo[num]->palette), UNDO_NONE);
mapheaderinfo[num]->palette = UINT16_MAX;
DEH_WriteUndoline("NUMLAPS", va("%u", mapheaderinfo[num]->numlaps), UNDO_NONE);
mapheaderinfo[num]->numlaps = NUMLAPS_DEFAULT;
DEH_WriteUndoline("UNLOCKABLE", va("%s", mapheaderinfo[num]->unlockrequired), UNDO_NONE);
mapheaderinfo[num]->unlockrequired = -1;
DEH_WriteUndoline("LEVELSELECT", va("%d", mapheaderinfo[num]->levelselect), UNDO_NONE);
mapheaderinfo[num]->levelselect = 0;
DEH_WriteUndoline("BONUSTYPE", va("%d", mapheaderinfo[num]->bonustype), UNDO_NONE);
mapheaderinfo[num]->bonustype = 0;
DEH_WriteUndoline("LEVELFLAGS", va("%d", mapheaderinfo[num]->levelflags), UNDO_NONE);
mapheaderinfo[num]->levelflags = 0;
DEH_WriteUndoline("MENUFLAGS", va("%d", mapheaderinfo[num]->menuflags), UNDO_NONE);
mapheaderinfo[num]->menuflags = 0;
// Flickies. Nope, no delfile support here either
#if 1 // equivalent to "FlickyList = DEMO"
P_SetDemoFlickies(num);
#else // equivalent to "FlickyList = NONE"
P_DeleteFlickies(num);
#endif
// TODO grades support for delfile (pfft yeah right)
P_DeleteGrades(num);
// an even further impossibility, delfile custom opts support
mapheaderinfo[num]->customopts = NULL;
mapheaderinfo[num]->numCustomOptions = 0;
DEH_WriteUndoline(va("# uload for map %d", i), NULL, UNDO_DONE);
}
/** Allocates a new map-header structure.
@ -3109,6 +3078,7 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
// look for skins
//
R_AddSkins(wadnum); // faB: wadfile index in wadfiles[]
R_PatchSkins(wadnum); // toast: PATCH PATCH
//
// search for maps
@ -3159,31 +3129,3 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
return true;
}
#ifdef DELFILE
boolean P_DelWadFile(void)
{
sfxenum_t i;
const UINT16 wadnum = (UINT16)(numwadfiles - 1);
const lumpnum_t lumpnum = numwadfiles<<16;
//lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo;
R_DelSkins(wadnum); // only used by DELFILE
R_DelSpriteDefs(wadnum); // only used by DELFILE
for (i = 0; i < NUMSFX; i++)
{
if (S_sfx[i].lumpnum != LUMPERROR && S_sfx[i].lumpnum >= lumpnum)
{
S_StopSoundByNum(i);
S_RemoveSoundFx(i);
if (S_sfx[i].lumpnum != LUMPERROR)
{
I_FreeSfx(&S_sfx[i]);
S_sfx[i].lumpnum = LUMPERROR;
}
}
}
W_UnloadWadFile(wadnum); // only used by DELFILE
R_LoadTextures();
return false;
}
#endif

View File

@ -60,9 +60,6 @@ void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum);
void P_LoadThingsOnly(void);
boolean P_SetupLevel(boolean skipprecip);
boolean P_AddWadFile(const char *wadfilename, char **firstmapname);
#ifdef DELFILE
boolean P_DelWadFile(void);
#endif
boolean P_RunSOC(const char *socfilename);
void P_WriteThings(lumpnum_t lump);
size_t P_PrecacheLevelFlats(void);

View File

@ -20,6 +20,7 @@
#include "z_zone.h"
#include "m_menu.h" // character select
#include "m_misc.h"
#include "info.h" // spr2names
#include "i_video.h" // rendermode
#include "r_things.h"
#include "r_plane.h"
@ -30,6 +31,7 @@
#include "d_netfil.h" // blargh. for nameonly().
#include "m_cheat.h" // objectplace
#include "m_cond.h"
#include "fastcmp.h"
#ifdef HWRENDER
#include "hardware/hw_md2.h"
#endif
@ -429,117 +431,6 @@ void R_AddSpriteDefs(UINT16 wadnum)
CONS_Printf(M_GetText("%s added %d frames in %s sprites\n"), wadname, end-start, sizeu1(addsprites));
}
#ifdef DELFILE
static void R_RemoveSpriteLump(UINT16 wad, // graphics patch
UINT16 lump,
size_t lumpid, // identifier
UINT8 frame,
UINT8 rotation,
UINT8 flipped)
{
(void)wad; /// \todo: how do I remove sprites?
(void)lump;
(void)lumpid;
(void)frame;
(void)rotation;
(void)flipped;
}
static boolean R_DelSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump)
{
UINT16 l;
UINT8 frame;
UINT8 rotation;
lumpinfo_t *lumpinfo;
maxframe = (size_t)-1;
// scan the lumps,
// filling in the frames for whatever is found
lumpinfo = wadfiles[wadnum]->lumpinfo;
if (endlump > wadfiles[wadnum]->numlumps)
endlump = wadfiles[wadnum]->numlumps;
for (l = startlump; l < endlump; l++)
{
if (memcmp(lumpinfo[l].name,sprname,4)==0)
{
frame = (UINT8)(lumpinfo[l].name[4] - 'A');
rotation = (UINT8)(lumpinfo[l].name[5] - '0');
// skip NULL sprites from very old dmadds pwads
if (W_LumpLengthPwad(wadnum,l)<=8)
continue;
//----------------------------------------------------
R_RemoveSpriteLump(wadnum, l, numspritelumps, frame, rotation, 0);
if (lumpinfo[l].name[6])
{
frame = (UINT8)(lumpinfo[l].name[6] - 'A');
rotation = (UINT8)(lumpinfo[l].name[7] - '0');
R_RemoveSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1);
}
}
}
if (maxframe == (size_t)-1)
return false;
spritedef->numframes = 0;
Z_Free(spritedef->spriteframes);
spritedef->spriteframes = NULL;
return true;
}
void R_DelSpriteDefs(UINT16 wadnum)
{
size_t i, delsprites = 0;
UINT16 start, end;
// find the sprites section in this pwad
// we need at least the S_END
// (not really, but for speedup)
start = W_CheckNumForNamePwad("S_START", wadnum, 0);
if (start == INT16_MAX)
start = W_CheckNumForNamePwad("SS_START", wadnum, 0); //deutex compatib.
if (start == INT16_MAX)
start = 0; //let say S_START is lump 0
else
start++; // just after S_START
end = W_CheckNumForNamePwad("S_END",wadnum,start);
if (end == INT16_MAX)
end = W_CheckNumForNamePwad("SS_END",wadnum,start); //deutex compatib.
if (end == INT16_MAX)
{
CONS_Debug(DBG_SETUP, "no sprites in pwad %d\n", wadnum);
return;
//I_Error("R_DelSpriteDefs: S_END, or SS_END missing for sprites "
// "in pwad %d\n",wadnum);
}
//
// scan through lumps, for each sprite, find all the sprite frames
//
for (i = 0; i < numsprites; i++)
{
spritename = sprnames[i];
if (R_DelSingleSpriteDef(spritename, &sprites[i], wadnum, start, end))
{
// if a new sprite was removed (not just replaced)
delsprites++;
CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", spritename, wadnum);
}
}
CONS_Printf(M_GetText("%s sprites removed from file %s\n"), sizeu1(delsprites), wadfiles[wadnum]->filename);
}
#endif
//
// GAME FUNCTIONS
//
@ -2695,6 +2586,51 @@ static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump)
return INT16_MAX; // not found
}
//
// Add skins from a pwad, each skin preceded by 'S_SKIN' marker
//
// Does the same is in w_wad, but check only for
// the first 6 characters (this is so we can have S_SKIN1, S_SKIN2..
// for wad editors that don't like multiple resources of the same name)
//
static UINT16 W_CheckForPatchSkinMarkerInPwad(UINT16 wadid, UINT16 startlump)
{
UINT16 i;
const char *P_SKIN = "P_SKIN";
lumpinfo_t *lump_p;
// scan forward, start at <startlump>
if (startlump < wadfiles[wadid]->numlumps)
{
lump_p = wadfiles[wadid]->lumpinfo + startlump;
for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++)
if (memcmp(lump_p->name,P_SKIN,6)==0)
return i;
}
return INT16_MAX; // not found
}
//
void R_LoadSkinSprites(UINT16 wadnum, UINT16 lump, skin_t *skin)
{
UINT16 lastlump, z;
UINT8 sprite2;
lastlump = W_CheckNumForNamePwad("S_END",wadnum,lump); // stop at S_END
// old wadding practices die hard -- stop at S_SKIN (/P_SKIN) or S_START if they come before S_END.
z = W_CheckNumForNamePwad("S_SKIN",wadnum,lump);
if (z < lastlump) lastlump = z;
z = W_CheckNumForNamePwad("P_SKIN",wadnum,lump);
if (z < lastlump) lastlump = z;
z = W_CheckNumForNamePwad("S_START",wadnum,lump);
if (z < lastlump) lastlump = z;
// load all sprite sets we are aware of.
for (sprite2 = 0; sprite2 < free_spr2; sprite2++)
R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[sprite2], wadnum, lump, lastlump);
}
//
// Find skin sprites, sounds & optional status bar face, & add them
//
@ -2955,22 +2891,7 @@ next_token:
free(buf2);
// Add sprites
{
UINT16 z;
UINT8 sprite2;
lump++; // start after S_SKIN
lastlump = W_CheckNumForNamePwad("S_END",wadnum,lump); // stop at S_END
// old wadding practices die hard -- stop at S_SKIN or S_START if they come before S_END.
z = W_CheckNumForNamePwad("S_SKIN",wadnum,lump);
if (z < lastlump) lastlump = z;
z = W_CheckNumForNamePwad("S_START",wadnum,lump);
if (z < lastlump) lastlump = z;
// load all sprite sets we are aware of.
for (sprite2 = 0; sprite2 < free_spr2; sprite2++)
R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[sprite2], wadnum, lump, lastlump);
}
R_LoadSkinSprites(wadnum, ++lump, skin);
R_FlushTranslationColormapCache();
@ -2994,48 +2915,163 @@ next_token:
return;
}
#ifdef DELFILE
void R_DelSkins(UINT16 wadnum)
//
// Patch skin sprites
//
void R_PatchSkins(UINT16 wadnum)
{
UINT16 lump, lastlump = 0;
while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX)
char *buf;
char *buf2;
char *stoken;
char *value;
size_t size;
skin_t *skin;
boolean noskincomplain;
//
// search for all skin patch markers in pwad
//
while ((lump = W_CheckForPatchSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX)
{
if (skins[numskins].wadnum != wadnum)
break;
numskins--;
ST_UnLoadFaceGraphics(numskins); // only used by DELFILE
if (skins[numskins].sprite[0] != '\0')
{
const char *csprname = W_CheckNameForNumPwad(wadnum, lump);
INT32 skinnum = 0;
// advance by default
lastlump = lump + 1;
// skip to end of this skin's frames
lastlump = lump;
while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),csprname,4)==0)
lastlump++;
// allocate (or replace) sprite frames, and set spritedef
R_DelSingleSpriteDef(csprname, &skins[numskins].spritedef, wadnum, lump, lastlump);
}
else
buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
size = W_LumpLengthPwad(wadnum, lump);
// for strtok
buf2 = malloc(size+1);
if (!buf2)
I_Error("R_PatchSkins: No more free memory\n");
M_Memcpy(buf2,buf,size);
buf2[size] = '\0';
skin = NULL;
noskincomplain = false;
// Parse initial comments and name parameter. Don't look at anything else until that's done!
stoken = strtok (buf2, "\r\n= ");
while (stoken)
{
// search in the normal sprite tables
size_t name;
boolean found = false;
const char *sprname = skins[numskins].sprite;
for (name = 0;sprnames[name][0] != '\0';name++)
if (strcmp(sprnames[name], sprname) == 0)
if ((stoken[0] == '/' && stoken[1] == '/')
|| (stoken[0] == '#'))// skip comments
{
stoken = strtok(NULL, "\r\n"); // skip end of line
stoken = strtok(NULL, "\r\n= "); // find the real next token
continue;
}
value = strtok(NULL, "\r\n= ");
if (!value)
I_Error("R_PatchSkins: syntax error looking for name in P_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename);
if (!stricmp(stoken, "name"))
{
strlwr(value);
skinnum = R_SkinAvailable(value);
if (skinnum != -1)
skin = &skins[skinnum];
else
{
found = true;
skins[numskins].spritedef = sprites[name];
CONS_Debug(DBG_SETUP, "R_PatchSkins: unknown skin name in P_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename);
noskincomplain = true;
}
}
// not found so make a new one
if (!found)
R_DelSingleSpriteDef(sprname, &skins[numskins].spritedef, wadnum, 0, INT16_MAX);
while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),sprname,4)==0)
lastlump++;
break; // Intentionally unconditional.
}
CONS_Printf(M_GetText("Removed skin '%s'\n"), skins[numskins].name);
if (!skin) // Didn't include a name parameter? What a waste.
{
if (!noskincomplain)
CONS_Debug(DBG_SETUP, "R_PatchSkins: no skin name given in P_SKIN lump #%d (WAD %s)\n", lump, wadfiles[wadnum]->filename);
continue;
}
// Parse SPR2 reset info and additional comments.
// If support is to be added for modifying additional skin properties, it should be done here, seperately from the strtok section above. This is to enforce that the skin must be properly selected before attempting to change properties.
stoken = strtok(NULL, "\r\n= ");
while (stoken)
{
if ((stoken[0] == '/' && stoken[1] == '/')
|| (stoken[0] == '#'))// skip comments
{
stoken = strtok(NULL, "\r\n"); // skip end of line
goto next_token; // find the real next token
}
value = strtok(NULL, "\r\n= ");
if (!value)
I_Error("R_PatchSkins: syntax error looking for properties in P_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename);
if (!stricmp(stoken, "reset"))
{
strupr(value);
if (strncmp(value, "spr2_", 5))
{
UINT8 i;
for (i = 0; i < (UINT8)free_spr2; i++)
{
if (!spr2names[i][4])
{
// special 3-char cases, e.g. SPR2_RUN
// the spr2names entry will have "_" on the end, as in "RUN_"
if (spr2names[i][3] == '_' && !value[3]) {
if (fastncmp(value+5,spr2names[i],3)) {
break;
}
}
else if (fastncmp(value+5,spr2names[i],4)) {
break;
}
}
}
if (i == free_spr2)
{
CONS_Debug(DBG_SETUP, "R_PatchSkins: unknown sprite2 %s given to reset in P_SKIN lump #%d (WAD %s)\n", value, lump, wadfiles[wadnum]->filename);
}
else if (i == SPR2_STND) // Not permitted to completely clear the spr2 every other one defaults to when not present...
{
if (skin->sprites[i].numframes && skin->sprites[i].numframes > 1) // Preserve number one only.
{
memset(sprtemp,0xFF, sizeof (spriteframe_t));
M_Memcpy(sprtemp, skin->sprites[i].spriteframes, sizeof (spriteframe_t));
Z_Free(skin->sprites[i].spriteframes);
skin->sprites[i].spriteframes = NULL;
M_Memcpy(skin->sprites[i].spriteframes, sprtemp, sizeof (spriteframe_t));
skin->sprites[i].numframes = 1;
}
}
else // Clear 'em all out!
{
if (skin->sprites[i].numframes) // has been allocated?
{
CONS_Debug(DBG_SETUP, "R_PatchSkins: Getting rid of %d frames in sprite2 %s...\n", skin->sprites[i].numframes, value);
Z_Free(skin->sprites[i].spriteframes);
skin->sprites[i].spriteframes = NULL;
skin->sprites[i].numframes = 0;
}
}
}
else
CONS_Debug(DBG_SETUP, "R_PatchSkins: malformed sprite2 %s given to reset in P_SKIN lump #%d (WAD %s)\n", value, lump, wadfiles[wadnum]->filename);
}
next_token:
stoken = strtok(NULL, "\r\n= ");
}
free(buf2);
// Patch sprites
R_LoadSkinSprites(wadnum, ++lump, skin);
if (!skin->availability) // Safe to print...
CONS_Printf(M_GetText("Patched skin '%s'\n"), skin->name);
}
}
#endif
return;
}

View File

@ -53,10 +53,6 @@ void R_SortVisSprites(void);
// (only sprites from namelist are added or replaced)
void R_AddSpriteDefs(UINT16 wadnum);
#ifdef DELFILE
void R_DelSpriteDefs(UINT16 wadnum);
#endif
//SoM: 6/5/2000: Light sprites correctly!
void R_AddSprites(sector_t *sec, INT32 lightlevel);
void R_InitSprites(void);
@ -206,12 +202,10 @@ void SetPlayerSkin(INT32 playernum,const char *skinname);
void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002
boolean R_SkinUnlock(INT32 skinnum);
INT32 R_SkinAvailable(const char *name);
void R_LoadSkinSprites(UINT16 wadnum, UINT16 lump, skin_t *skin);
void R_PatchSkins(UINT16 wadnum);
void R_AddSkins(UINT16 wadnum);
#ifdef DELFILE
void R_DelSkins(UINT16 wadnum);
#endif
void R_InitDrawNodes(void);
char *GetPlayerFacePic(INT32 skinnum);

View File

@ -353,15 +353,6 @@ void ST_LoadFaceGraphics(char *facestr, char *superstr, INT32 skinnum)
facefreed[skinnum] = false;
}
#ifdef DELFILE
void ST_UnLoadFaceGraphics(INT32 skinnum)
{
Z_Free(faceprefix[skinnum]);
Z_Free(superprefix[skinnum]);
facefreed[skinnum] = true;
}
#endif
void ST_ReloadSkinFaceGraphics(void)
{
INT32 i;

View File

@ -44,9 +44,6 @@ void ST_LoadGraphics(void);
// face load graphics, called when skin changes
void ST_LoadFaceGraphics(char *facestr, char *superstr, INT32 playernum);
void ST_ReloadSkinFaceGraphics(void);
#ifdef DELFILE
void ST_UnLoadFaceGraphics(INT32 skinnum);
#endif
void ST_doPaletteStuff(void);

View File

@ -483,38 +483,6 @@ UINT16 W_LoadWadFile(const char *filename)
return wadfile->numlumps;
}
#ifdef DELFILE
void W_UnloadWadFile(UINT16 num)
{
INT32 i;
wadfile_t *delwad = wadfiles[num];
lumpcache_t *lumpcache;
if (num == 0)
return;
CONS_Printf(M_GetText("Removing WAD %s...\n"), wadfiles[num]->filename);
DEH_UnloadDehackedWad(num);
wadfiles[num] = NULL;
lumpcache = delwad->lumpcache;
numwadfiles--;
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none)
HWR_FreeTextureCache();
M_AATreeFree(delwad->hwrcache);
#endif
if (*lumpcache)
{
for (i = 0;i < delwad->numlumps;i++)
Z_ChangeTag(lumpcache[i], PU_PURGELEVEL);
}
Z_Free(lumpcache);
fclose(delwad->handle);
Z_Free(delwad->filename);
Z_Free(delwad);
CONS_Printf(M_GetText("Done unloading WAD.\n"));
}
#endif
/** Tries to load a series of files.
* All files are wads unless they have an extension of ".soc" or ".lua".
*

View File

@ -84,9 +84,6 @@ void W_Shutdown(void);
// Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error
UINT16 W_LoadWadFile(const char *filename);
#ifdef DELFILE
void W_UnloadWadFile(UINT16 num);
#endif
// W_InitMultipleFiles returns 1 if all is okay, 0 otherwise,
// so that it stops with a message if a file was not found, but not if all is okay.