diff --git a/src/dehacked.c b/src/dehacked.c index af5c1c407..f8e631160 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -430,16 +430,20 @@ static void readAnimTex(MYFILE *f, INT32 num) } */ -static boolean findFreeSlot(INT32 *num) +static boolean findFreeSlot(INT32 *num, UINT16 wadnum) { // Send the character select entry to a free slot. - while (*num < 32 && !(PlayerMenu[*num].status & IT_DISABLED)) // Will overwrite hidden characters, but it works out. You can't unlock if you're adding extra characters anyways. + while (*num < 32 && !(PlayerMenu[*num].status & IT_DISABLED && description[*num].wadnum != wadnum)) // Will kill hidden characters from other files, but that's okay. *num = *num+1; // No more free slots. :( if (*num >= 32) return false; + PlayerMenu[*num].status = IT_CALL; + description[*num].wadnum = wadnum; + description[*num].picname[0] = '\0'; // Redesign your logo. (See M_DrawSetupChoosePlayerMenu in m_menu.c...) + // Found one! ^_^ return true; } @@ -473,9 +477,8 @@ static void readPlayer(MYFILE *f, INT32 num) { char *playertext = NULL; - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) + if (!slotfound && (slotfound = findFreeSlot(&num, f->wad)) == false) goto done; - PlayerMenu[num].status = IT_CALL; for (i = 0; i < MAXLINELEN-3; i++) { @@ -521,34 +524,12 @@ static void readPlayer(MYFILE *f, INT32 num) word2[strlen(word2)-1] = '\0'; i = atoi(word2); - /*if (fastcmp(word, "PLAYERNAME")) + if (fastcmp(word, "PICNAME")) { - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - DEH_WriteUndoline(word, description[num].text, UNDO_NONE); - strlcpy(description[num].text, word2, sizeof (description[num].text)); - for (word2 = description[num].text; *word2; word2++) - if (*word2 == '_') - *word2 = ' '; - PlayerMenu[num].text = description[num].text; - }*/ -/* else if (fastcmp(word, "MENUPOSITION")) - { // Make sure you make MENUPOSITION the first thing under CHARACTER if you're using it! - // This is to manually choose a slot and overwrite existing characters! It is NOT necessary for most individual character wads!! -#ifdef DELFILE - if (disableundo) -#endif - { - slotfound = true; - num = i; - } - } */ - /*else*/ if (fastcmp(word, "PICNAME")) - { - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) + if (!slotfound && (slotfound = findFreeSlot(&num, f->wad)) == false) goto done; DEH_WriteUndoline(word, &description[num].picname[0], UNDO_NONE); - PlayerMenu[num].status = IT_CALL; + strncpy(description[num].picname, word2, 8); } else if (fastcmp(word, "STATUS")) @@ -565,11 +546,8 @@ static void readPlayer(MYFILE *f, INT32 num) Because of this, you are allowed to edit any previous entries you like, but only if you signal that you are purposely doing so by disabling and then reenabling the slot. - - ... Or use MENUPOSITION first, that works too. Hell, you could edit multiple character - slots in a single section that way, due to how SOC editing works. */ - if (i != IT_DISABLED && !slotfound && (slotfound = findFreeSlot(&num)) == false) + 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; @@ -577,15 +555,12 @@ static void readPlayer(MYFILE *f, INT32 num) else if (fastcmp(word, "SKINNAME")) { // Send to free slot. - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) + if (!slotfound && (slotfound = findFreeSlot(&num, f->wad)) == false) goto done; DEH_WriteUndoline(word, description[num].skinname, UNDO_NONE); - PlayerMenu[num].status = IT_CALL; strlcpy(description[num].skinname, word2, sizeof description[num].skinname); strlwr(description[num].skinname); - - description[num].picname[0] = '\0'; // Redesign your logo. (See M_DrawSetupChoosePlayerMenu in m_menu.c...) } else deh_warning("readPlayer %d: unknown word '%s'", num, word); diff --git a/src/m_menu.h b/src/m_menu.h index 2ff1cea90..d578e155e 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -177,6 +177,7 @@ typedef struct char notes[441]; char picname[8]; char skinname[SKINNAMESIZE*2+2]; // skin&skin\0 + UINT16 wadnum; // for duplicate characters } description_t; // mode descriptions for video mode menu diff --git a/src/r_things.c b/src/r_things.c index 056663445..2b036fb56 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2355,9 +2355,6 @@ INT32 R_SkinAvailable(const char *name) { INT32 i; - if (stricmp("NONE",name) == 0) - return -1; - for (i = 0; i < numskins; i++) { // search in the skin list @@ -2531,10 +2528,11 @@ void R_AddSkins(UINT16 wadnum) if (!stricmp(stoken, "name")) { + INT32 skinnum = R_SkinAvailable(value); // the skin name must uniquely identify a single skin // I'm lazy so if name is already used I leave the 'skin x' // default skin name set in Sk_SetDefaultValue - if (R_SkinAvailable(value) == -1) + if (skinnum == -1) { STRBUFCPY(skin->name, value); strlwr(skin->name); @@ -2639,7 +2637,15 @@ void R_AddSkins(UINT16 wadnum) else if (!stricmp(stoken, "availability")) #ifdef DEVELOP { - PlayerMenu[R_SkinAvailable(skin->name)].status = (IT_DISABLED|IT_CENTER); + char *name; + INT32 i; + for (i = 0; i < 32; i++) + { + name = strtok(Z_StrDup(description[i].skinname), "&"); + if (name == skin->name && PlayerMenu[i].status != IT_DISABLED) + PlayerMenu[i].status = (IT_DISABLED|IT_CENTER); + Z_Free(name); + } skin->availability = atoi(value); } #else