From 3f1d58754e9961de98fe84124a0ed8bc1508680c Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 8 Aug 2020 19:08:19 -0400 Subject: [PATCH] Merge r_things.c/h Includes r_skins, obviously, but also a little bit of m_cond to make availabilities better for kart's purposes --- src/m_cond.h | 34 +- src/r_skins.c | 447 +++++++++++------- src/r_skins.h | 87 ++-- src/r_things.c | 1172 +++--------------------------------------------- src/r_things.h | 82 +--- 5 files changed, 431 insertions(+), 1391 deletions(-) diff --git a/src/m_cond.h b/src/m_cond.h index 0241eccb0..b9d1c08de 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -20,8 +20,8 @@ // [required] typedef enum { - UC_PLAYTIME, // PLAYTIME [tics] - UC_MATCHESPLAYED, // SRB2Kart: MATCHESPLAYED [x played] + UC_PLAYTIME, // PLAYTIME [tics] + UC_MATCHESPLAYED, // SRB2Kart: MATCHESPLAYED [x played] UC_POWERLEVEL, // SRB2Kart: POWERLEVEL [power level to reach] [gametype, "0" for race, "1" for battle] UC_GAMECLEAR, // GAMECLEAR UC_ALLEMERALDS, // ALLEMERALDS @@ -60,11 +60,11 @@ typedef struct #define ET_GLOBAL 0 // Emblem with a position in space #define ET_MAP 1 // Beat the map #define ET_TIME 2 // Get the time -//#define ET_DEVTIME 3 // Time, but +//#define ET_DEVTIME 3 // Time, but the value is tied to a Time Trial demo, not pre-defined // Global emblem flags // (N/A to Kart yet) -//#define GE_NIGHTSPULL 1 +//#define GE_OH 1 // Map emblem flags #define ME_ENCORE 1 @@ -109,21 +109,23 @@ typedef struct #define SECRET_NONE 0 // Does nil. Use with levels locked by UnlockRequired #define SECRET_HEADER 1 // Does nothing on its own, just serves as a header for the menu -#define SECRET_LEVELSELECT 2 // Selectable level select +#define SECRET_SKIN 2 // Allow this character to be selected #define SECRET_WARP 3 // Selectable warp -#define SECRET_TIMEATTACK 4 // Enables Time Attack on the main menu -#define SECRET_BREAKTHECAPSULES 5 // Enables Break the Capsules on the main menu -#define SECRET_SOUNDTEST 6 // Sound Test -#define SECRET_CREDITS 7 // Enables Credits +#define SECRET_LEVELSELECT 4 // Selectable level select -#define SECRET_ITEMFINDER 8 // Enables Item Finder/Emblem Radar -#define SECRET_EMBLEMHINTS 9 // Enables Emblem Hints +#define SECRET_TIMEATTACK 5 // Enables Time Attack on the main menu +#define SECRET_BREAKTHECAPSULES 6 // Enables Break the Capsules on the main menu +#define SECRET_SOUNDTEST 7 // Sound Test +#define SECRET_CREDITS 8 // Enables Credits -#define SECRET_ENCORE 10 // Enables Encore mode cvar -#define SECRET_HARDSPEED 11 // Enables Hard gamespeed -#define SECRET_HELLATTACK 12 // Map Hell in record attack +#define SECRET_ITEMFINDER 9 // Enables Item Finder/Emblem Radar +#define SECRET_EMBLEMHINTS 10 // Enables Emblem Hints -#define SECRET_PANDORA 13 // Enables Pandora's Box +#define SECRET_ENCORE 11 // Enables Encore mode cvar +#define SECRET_HARDSPEED 12 // Enables Hard gamespeed +#define SECRET_HELLATTACK 13 // Map Hell in record attack + +#define SECRET_PANDORA 14 // Enables Pandora's Box // If you have more secrets than these variables allow in your game, // you seriously need to get a life. @@ -174,8 +176,6 @@ const char *M_GetExtraEmblemPatch(extraemblem_t *em, boolean big); // They stop checking upon reaching the target number so they // should be (theoretically?) slightly faster. UINT8 M_GotEnoughEmblems(INT32 number); -//UINT8 M_GotHighEnoughScore(INT32 tscore); UINT8 M_GotLowEnoughTime(INT32 tictime); -//UINT8 M_GotHighEnoughRings(INT32 trings); #define M_Achieved(a) ((a) >= MAXCONDITIONSETS || conditionSets[a].achieved) diff --git a/src/r_skins.c b/src/r_skins.c index 57ce382c4..66f81006d 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -46,6 +46,11 @@ skin_t skins[MAXSKINS]; CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; #endif +CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; + +// SRB2Kart followers +follower_t followers[MAXSKINS]; + // // P_GetSkinSprite2 // For non-super players, tries each sprite2's immediate predecessor until it finds one with a number of frames or ends up at standing. @@ -125,36 +130,12 @@ static void Sk_SetDefaultValue(skin_t *skin) skin->supercolor = SKINCOLOR_SUPERGOLD1; skin->prefoppositecolor = 0; // use tables - skin->normalspeed = 36<runspeed = 28<thrustfactor = 5; - skin->accelstart = 96; - skin->acceleration = 40; + skin->kartspeed = 5; + skin->kartweight = 5; - skin->ability = CA_NONE; - skin->ability2 = CA2_SPINDASH; - skin->jumpfactor = FRACUNIT; - skin->actionspd = 30<mindash = 15<maxdash = 70<radius = mobjinfo[MT_PLAYER].radius; - skin->height = mobjinfo[MT_PLAYER].height; - skin->spinheight = FixedMul(skin->height, 2*FRACUNIT/3); - - skin->shieldscale = FRACUNIT; - skin->camerascale = FRACUNIT; - - skin->thokitem = -1; - skin->spinitem = -1; - skin->revitem = -1; skin->followitem = 0; skin->highresscale = FRACUNIT; - skin->contspeed = 17; - skin->contangle = 0; - - skin->availability = 0; for (i = 0; i < sfx_skinsoundslot0; i++) if (S_sfx[i].skinsound != -1) @@ -182,14 +163,18 @@ void R_InitSkins(void) UINT32 R_GetSkinAvailabilities(void) { - INT32 s; + UINT8 i; UINT32 response = 0; - for (s = 0; s < MAXSKINS; s++) + for (i = 0; i < MAXUNLOCKABLES; s++) { - if (skins[s].availability && unlockables[skins[s].availability - 1].unlocked) + if (unlockables[i].type == SECRET_SKIN && unlockables[i].unlocked) + { + UINT8 s = min(unlockables[i].variable, MAXSKINS); response |= (1 << s); + } } + return response; } @@ -197,14 +182,70 @@ UINT32 R_GetSkinAvailabilities(void) // warning don't use with an invalid skinnum other than -1 which always returns true boolean R_SkinUsable(INT32 playernum, INT32 skinnum) { - return ((skinnum == -1) // Simplifies things elsewhere, since there's already plenty of checks for less-than-0... - || (!skins[skinnum].availability) - || (((netgame || multiplayer) && playernum != -1) ? (players[playernum].availabilities & (1 << skinnum)) : (unlockables[skins[skinnum].availability - 1].unlocked)) - || (modeattacking) // If you have someone else's run you might as well take a look - || (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) // Force 1. - || (netgame && (cv_forceskin.value == skinnum)) // Force 2. - || (metalrecording && skinnum == 5) // Force 3. - ); + boolean needsunlocked = false; + UINT8 i; + + if (skinnum == -1) + { + // Simplifies things elsewhere, since there's already plenty of checks for less-than-0... + return true; + } + + if (modeattacking) + { + // If you have someone else's run, you should be able to take a look + return true; + } + + if (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) + { + // Being forced to play as this character by the level + return true; + } + + if (netgame && (cv_forceskin.value == skinnum)) + { + // Being forced to play as this character by the server + return true; + } + + if (metalrecording) + { + // Recording a Metal Sonic race + const INT32 metalskin = R_SkinAvailable("metalsonic"); + return (skinnum == metalskin); + } + + // Determine if this character is supposed to be unlockable or not + for (i = 0; i < MAXUNLOCKABLES; i++) + { + if (unlockables[i].type == SECRET_SKIN && unlockables[i].variable == skinnum) + { + // i is now the unlockable index, we can use this later + needsunlocked = true; + break; + } + } + + if (needsunlocked == true) + { + // You can use this character IF you have it unlocked. + if ((netgame || multiplayer) && playernum != -1) + { + // Use the netgame synchronized unlocks. + return (boolean)(!(players[playernum].availabilities & (1 << skinnum))); + } + else + { + // Use the unlockables table directly + return (boolean)(unlockables[i].unlocked); + } + } + else + { + // Didn't trip anything, so we can use this character. + return true; + } } // returns true if the skin name is found (loaded from pwad) @@ -249,50 +290,33 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) player_t *player = &players[playernum]; skin_t *skin = &skins[skinnum]; UINT16 newcolor = 0; + UINT8 i; if (skinnum >= 0 && skinnum < numskins && R_SkinUsable(playernum, skinnum)) // Make sure it exists! { player->skin = skinnum; - player->camerascale = skin->camerascale; - player->shieldscale = skin->shieldscale; - - player->charability = (UINT8)skin->ability; - player->charability2 = (UINT8)skin->ability2; - player->charflags = (UINT32)skin->flags; - player->thokitem = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem; - player->spinitem = skin->spinitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].damage : (UINT32)skin->spinitem; - player->revitem = skin->revitem < 0 ? (mobjtype_t)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem; player->followitem = skin->followitem; - if (((player->powers[pw_shield] & SH_NOSTACK) == SH_PINK) && (player->revitem == MT_LHRT || player->spinitem == MT_LHRT || player->thokitem == MT_LHRT)) // Healers can't keep their buff. - player->powers[pw_shield] &= SH_STACK; + player->kartspeed = skin->kartspeed; + player->kartweight = skin->kartweight; - player->actionspd = skin->actionspd; - player->mindash = skin->mindash; - player->maxdash = skin->maxdash; - - player->normalspeed = skin->normalspeed; - player->runspeed = skin->runspeed; - player->thrustfactor = skin->thrustfactor; - player->accelstart = skin->accelstart; - player->acceleration = skin->acceleration; - - player->jumpfactor = skin->jumpfactor; - - player->height = skin->height; - player->spinheight = skin->spinheight; - - if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) +#if 0 + if (!(cv_debug || devparm) && !(netgame || multiplayer || demo.playback)) { - if (playernum == consoleplayer) - CV_StealthSetValue(&cv_playercolor, skin->prefcolor); - else if (playernum == secondarydisplayplayer) - CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); + for (i = 0; i <= r_splitscreen; i++) + { + if (playernum == g_localplayers[i]) + { + CV_StealthSetValue(&cv_playercolor[i], skin->prefcolor); + } + } + player->skincolor = newcolor = skin->prefcolor; } +#endif if (player->followmobj) { @@ -302,22 +326,20 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) if (player->mo) { - fixed_t radius = FixedMul(skin->radius, player->mo->scale); - if ((player->powers[pw_carry] == CR_NIGHTSMODE) && (skin->sprites[SPR2_NFLY].numframes == 0)) // If you don't have a sprite for flying horizontally, use the default NiGHTS skin. - { - skin = &skins[DEFAULTNIGHTSSKIN]; - player->followitem = skin->followitem; - if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) - newcolor = skin->prefcolor; // will be updated in thinker to flashing - } player->mo->skin = skin; - if (newcolor) - player->mo->color = newcolor; - P_SetScale(player->mo, player->mo->scale); - player->mo->radius = radius; + if (newcolor) + { + player->mo->color = newcolor; + } + + P_SetScale(player->mo, player->mo->scale); P_SetPlayerMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames } + + // for replays: We have changed our skin mid-game; let the game know so it can do the same in the replay! + demo_extradata[playernum] |= DXD_SKIN; + return; } @@ -325,7 +347,8 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); else if(server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); - SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin + + SetPlayerSkinByNum(playernum, 0); // not found, put in the default skin } // @@ -434,36 +457,9 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) #define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); // character type identification FULLPROCESS(flags) - FULLPROCESS(ability) - FULLPROCESS(ability2) - - FULLPROCESS(thokitem) - FULLPROCESS(spinitem) - FULLPROCESS(revitem) FULLPROCESS(followitem) #undef FULLPROCESS -#define GETFRACBITS(field) else if (!stricmp(stoken, #field)) skin->field = atoi(value)<field = atoi(value); - GETINT(thrustfactor) - GETINT(accelstart) - GETINT(acceleration) - GETINT(contspeed) - GETINT(contangle) -#undef GETINT - #define GETSKINCOLOR(field) else if (!stricmp(stoken, #field)) skin->field = R_GetColorByName(value); GETSKINCOLOR(prefcolor) GETSKINCOLOR(prefoppositecolor) @@ -472,12 +468,21 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) skin->supercolor = R_GetSuperColorByName(value); #define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value)); - GETFLOAT(jumpfactor) GETFLOAT(highresscale) - GETFLOAT(shieldscale) - GETFLOAT(camerascale) #undef GETFLOAT +#define GETKARTSTAT(field) \ + else if (!stricmp(stoken, #field)) \ + { \ + skin->field = atoi(value); \ + if (skin->field < 1) skin->field = 1; \ + if (skin->field > 9) skin->field = 9; \ + } + GETKARTSTAT(kartspeed) + GETKARTSTAT(kartweight) +#undef GETKARTSTAT + + #define GETFLAG(field) else if (!stricmp(stoken, #field)) { \ strupr(value); \ if (atoi(value) || value[0] == 'T' || value[0] == 'Y') \ @@ -488,23 +493,8 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) // parameters for individual character flags // these are uppercase so they can be concatenated with SF_ // 1, true, yes are all valid values - GETFLAG(SUPER) - GETFLAG(NOSUPERSPIN) - GETFLAG(NOSPINDASHDUST) GETFLAG(HIRES) - GETFLAG(NOSKID) - GETFLAG(NOSPEEDADJUST) - GETFLAG(RUNONWATER) - GETFLAG(NOJUMPSPIN) - GETFLAG(NOJUMPDAMAGE) - GETFLAG(STOMPDAMAGE) - GETFLAG(MARIODAMAGE) GETFLAG(MACHINE) - GETFLAG(DASHMODE) - GETFLAG(FASTEDGE) - GETFLAG(MULTIABILITY) - GETFLAG(NONIGHTSROTATION) - GETFLAG(NONIGHTSSUPER) #undef GETFLAG else // let's check if it's a sound, otherwise error out @@ -557,7 +547,7 @@ void R_AddSkins(UINT16 wadnum) char *value; size_t size; skin_t *skin; - boolean hudname, realname; + boolean realname; // // search for all skin markers in pwad @@ -587,7 +577,7 @@ void R_AddSkins(UINT16 wadnum) skin = &skins[numskins]; Sk_SetDefaultValue(skin); skin->wadnum = wadnum; - hudname = realname = false; + realname = false; // parse stoken = strtok (buf2, "\r\n= "); while (stoken) @@ -640,34 +630,51 @@ void R_AddSkins(UINT16 wadnum) else if (*value == '.') *value = '\x1E'; // turn . into katana dot. } } - if (!hudname) - { - HUDNAMEWRITE(skin->name); - strupr(skin->hudname); - SYMBOLCONVERT(skin->hudname) - } } else if (!stricmp(stoken, "realname")) { // Display name (eg. "Knuckles") realname = true; STRBUFCPY(skin->realname, value); SYMBOLCONVERT(skin->realname) - if (!hudname) - HUDNAMEWRITE(skin->realname); } - else if (!stricmp(stoken, "hudname")) - { // Life icon name (eg. "K.T.E") - hudname = true; - HUDNAMEWRITE(value); - SYMBOLCONVERT(skin->hudname) - if (!realname) - STRBUFCPY(skin->realname, skin->hudname); - } - else if (!stricmp(stoken, "availability")) + else if (!stricmp(stoken, "rivals")) { - skin->availability = atoi(value); - if (skin->availability >= MAXUNLOCKABLES) - skin->availability = 0; + size_t len = strlen(value); + size_t i; + char rivalname[SKINNAMESIZE] = ""; + UINT8 pos = 0; + UINT8 numrivals = 0; + + // Can't use strtok, because this function's already using it. + // Using it causes it to upset the saved pointer, + // corrupting the reading for the rest of the file. + + // So instead we get to crawl through the value, character by character, + // and write it down as we go, until we hit a comma or the end of the string. + // Yaaay. + + for (i = 0; i <= len; i++) + { + if (numrivals >= SKINRIVALS) + { + break; + } + + if (value[i] == ',' || i == len) + { + STRBUFCPY(skin->rivals[numrivals], rivalname); + strlwr(skin->rivals[numrivals]); + numrivals++; + + memset(rivalname, 0, sizeof (rivalname)); + pos = 0; + + continue; + } + + rivalname[pos] = value[i]; + pos++; + } } else if (!R_ProcessPatchableFields(skin, stoken, value)) CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); @@ -690,6 +697,10 @@ next_token: skin_cons_t[numskins].strvalue = skin->name; #endif + // Update the forceskin possiblevalues + Forceskin_cons_t[numskins+1].value = numskins; + Forceskin_cons_t[numskins+1].strvalue = skins[numskins].name; + #ifdef HWRENDER if (rendermode == render_opengl) HWR_AddPlayerModel(numskins); @@ -712,7 +723,7 @@ void R_PatchSkins(UINT16 wadnum) char *value; size_t size; skin_t *skin; - boolean noskincomplain, realname, hudname; + boolean noskincomplain, realname; // // search for all skin patch markers in pwad @@ -736,7 +747,7 @@ void R_PatchSkins(UINT16 wadnum) buf2[size] = '\0'; skin = NULL; - noskincomplain = realname = hudname = false; + noskincomplain = realname = false; /* Parse. Has more phases than the parser in R_AddSkins because it needs to have the patching name first (no default skin name is acceptible for patching, unlike skin creation) @@ -780,16 +791,45 @@ void R_PatchSkins(UINT16 wadnum) realname = true; STRBUFCPY(skin->realname, value); SYMBOLCONVERT(skin->realname) - if (!hudname) - HUDNAMEWRITE(skin->realname); } - else if (!stricmp(stoken, "hudname")) - { // Life icon name (eg. "K.T.E") - hudname = true; - HUDNAMEWRITE(value); - SYMBOLCONVERT(skin->hudname) - if (!realname) - STRBUFCPY(skin->realname, skin->hudname); + else if (!stricmp(stoken, "rivals")) + { + size_t len = strlen(value); + size_t i; + char rivalname[SKINNAMESIZE] = ""; + UINT8 pos = 0; + UINT8 numrivals = 0; + + // Can't use strtok, because this function's already using it. + // Using it causes it to upset the saved pointer, + // corrupting the reading for the rest of the file. + + // So instead we get to crawl through the value, character by character, + // and write it down as we go, until we hit a comma or the end of the string. + // Yaaay. + + for (i = 0; i <= len; i++) + { + if (numrivals >= SKINRIVALS) + { + break; + } + + if (value[i] == ',' || i == len) + { + STRBUFCPY(skin->rivals[numrivals], rivalname); + strlwr(skin->rivals[numrivals]); + numrivals++; + + memset(rivalname, 0, sizeof (rivalname)); + pos = 0; + + continue; + } + + rivalname[pos] = value[i]; + pos++; + } } else if (!R_ProcessPatchableFields(skin, stoken, value)) CONS_Debug(DBG_SETUP, "R_PatchSkins: Unknown keyword '%s' in P_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); @@ -824,3 +864,92 @@ next_token: #undef HUDNAMEWRITE #undef SYMBOLCONVERT + +// SRB2Kart: Followers! +// TODO: put this stuff in its own file? + +// same thing as R_SkinAvailable, but for followers +INT32 R_FollowerAvailable(const char *name) +{ + INT32 i; + + for (i = 0; i < numfollowers; i++) + { + if (stricmp(followers[i].skinname,name)==0) + return i; + } + return -1; +} + +// same thing as SetPlayerSkin, but for followers +boolean SetPlayerFollower(INT32 playernum, const char *skinname) +{ + INT32 i; + player_t *player = &players[playernum]; + + for (i = 0; i < numfollowers; i++) + { + // search in the skin list + if (stricmp(followers[i].skinname, skinname) == 0) + { + SetFollower(playernum, i); + return true; + } + } + + if (P_IsLocalPlayer(player)) + CONS_Alert(CONS_WARNING, M_GetText("Follower '%s' not found.\n"), skinname); + else if(server || IsPlayerAdmin(consoleplayer)) + CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) follower '%s' not found\n"), playernum, player_names[playernum], skinname); + + SetFollower(playernum, -1); // reminder that -1 is nothing + return false; +} + +// SetPlayerSkinByNum, for followers +void SetFollower(INT32 playernum, INT32 skinnum) +{ + player_t *player = &players[playernum]; + mobj_t *bub; + mobj_t *tmp; + + player->followerready = true; // we are ready to perform follower related actions in the player thinker, now. + + if (skinnum >= -1 && skinnum <= numfollowers) // Make sure it exists! + { + /* + We don't spawn the follower here since it'll be easier to handle all of it in the Player thinker itself. + However, we will despawn it right here if there's any to make it easy for the player thinker to replace it or delete it. + */ + + if (player->follower && skinnum != player->followerskin) // this is also called when we change colour so don't respawn the follower unless we changed skins + { + // Remove follower's possible hnext list (bubble) + bub = player->follower->hnext; + + while (bub && !P_MobjWasRemoved(bub)) + { + tmp = bub->hnext; + P_RemoveMobj(bub); + bub = tmp; + } + + P_RemoveMobj(player->follower); + P_SetTarget(&player->follower, NULL); + } + + player->followerskin = skinnum; + + // for replays: We have changed our follower mid-game; let the game know so it can do the same in the replay! + demo_extradata[playernum] |= DXD_FOLLOWER; + + return; + } + + if (P_IsLocalPlayer(player)) + CONS_Alert(CONS_WARNING, M_GetText("Follower %d not found\n"), skinnum); + else if(server || IsPlayerAdmin(consoleplayer)) + CONS_Alert(CONS_WARNING, "Player %d (%s) follower %d not found\n", playernum, player_names[playernum], skinnum); + + SetFollower(playernum, -1); // Not found, then set -1 (nothing) as our follower. +} diff --git a/src/r_skins.h b/src/r_skins.h index 45c90bdb4..e8c002b0d 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -22,10 +22,12 @@ /// Defaults #define SKINNAMESIZE 16 +#define SKINRIVALS 3 // should be all lowercase!! S_SKIN processing does a strlwr -#define DEFAULTSKIN "sonic" +#define DEFAULTSKIN "eggman" #define DEFAULTSKIN2 "tails" // secondary player -#define DEFAULTNIGHTSSKIN 0 +#define DEFAULTSKIN3 "sonic" // third player +#define DEFAULTSKIN4 "knuckles" // fourth player /// The skin_t struct typedef struct @@ -35,33 +37,11 @@ typedef struct skinflags_t flags; char realname[SKINNAMESIZE+1]; // Display name for level completion. - char hudname[SKINNAMESIZE+1]; // HUD name to display (officially exactly 5 characters long) - UINT8 ability; // ability definition - UINT8 ability2; // secondary ability definition - INT32 thokitem; - INT32 spinitem; - INT32 revitem; + UINT8 kartspeed; + UINT8 kartweight; + INT32 followitem; - fixed_t actionspd; - fixed_t mindash; - fixed_t maxdash; - - fixed_t normalspeed; // Normal ground - fixed_t runspeed; // Speed that you break into your run animation - - UINT8 thrustfactor; // Thrust = thrustfactor * acceleration - UINT8 accelstart; // Acceleration if speed = 0 - UINT8 acceleration; // Acceleration - - fixed_t jumpfactor; // multiple of standard jump height - - fixed_t radius; // Bounding box changes. - fixed_t height; - fixed_t spinheight; - - fixed_t shieldscale; // no change to bounding box, but helps set the shield's sprite size - fixed_t camerascale; // Definable color translation table UINT8 starttranscolor; @@ -70,8 +50,6 @@ typedef struct UINT16 prefoppositecolor; // if 0 use tables instead fixed_t highresscale; // scale of highres, default is 0.5 - UINT8 contspeed; // continue screen animation speed - UINT8 contangle; // initial angle on continue screen // specific sounds per skin sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table @@ -80,13 +58,15 @@ typedef struct spritedef_t sprites[NUMPLAYERSPRITES*2]; spriteinfo_t sprinfo[NUMPLAYERSPRITES*2]; - UINT8 availability; // lock? + char rivals[SKINRIVALS][SKINNAMESIZE+1]; // Your top 3 rivals for GP mode. Uses names so that you can reference skins that aren't added } skin_t; /// Externs extern INT32 numskins; extern skin_t skins[MAXSKINS]; +extern CV_PossibleValue_t Forceskin_cons_t[]; + /// Function prototypes void R_InitSkins(void); @@ -100,4 +80,51 @@ void R_AddSkins(UINT16 wadnum); UINT8 P_GetSkinSprite2(skin_t *skin, UINT8 spr2, player_t *player); +// SRB2Kart Followers + +// +// We'll define these here because they're really just a mobj that'll follow some rules behind a player +// +typedef struct follower_s +{ + char skinname[SKINNAMESIZE+1]; // Skin Name. This is what to refer to when asking the commands anything. + char name[SKINNAMESIZE+1]; // Name. This is used for the menus. We'll just follow the same rules as skins for this. + + UINT8 defaultcolor; // default color for menus. + + fixed_t scale; // Scale relative to the player's. + fixed_t bubblescale; // Bubble scale relative to the player scale. If not set, no bubble will spawn (default) + + // some position shenanigans: + INT32 atangle; // angle the object will be at around the player. The object itself will always face the same direction as the player. + INT32 dist; // distance relative to the player. (In a circle) + INT32 height; // height of the follower, this is mostly important for Z flipping. + INT32 zoffs; // Z offset relative to the player's height. Cannot be negative. + + // movement options + + INT32 horzlag; // Lag for X/Y displacement. Default is 2. Must be > 0 because we divide by this number. + INT32 vertlag; // not Vert from Neptunia lagging, this is for Z displacement lag Default is 6. Must be > 0 because we divide by this number. + INT32 bobamp; // Bob amplitude. Default is 4. + INT32 bobspeed; // Arbitrary modifier for bobbing speed, default is TICRATE*2 (70). + + // from there on out, everything is STATES to allow customization + // these are only set once when the action is performed and are then free to animate however they want. + + INT32 idlestate; // state when the player is at a standstill + INT32 followstate; // state when the player is moving + INT32 hurtstate; // state when the player is being hurt + INT32 winstate; // state when the player has won + INT32 losestate; // state when the player has lost + INT32 hitconfirmstate; // state for hit confirm + INT32 hitconfirmtime; // time to keep the above playing for +} follower_t; + +extern INT32 numfollowers; +extern follower_t followers[MAXSKINS]; // again, use the same rules as skins, no reason not to. + +INT32 R_FollowerAvailable(const char *name); +boolean SetPlayerFollower(INT32 playernum,const char *skinname); +void SetFollower(INT32 playernum,INT32 skinnum); + #endif //__R_SKINS__ diff --git a/src/r_things.c b/src/r_things.c index 1bd558606..1a9a2c789 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -41,17 +41,6 @@ #include "hardware/hw_drv.h" #endif -<<<<<<< HEAD -#ifdef PC_DOS -#include // for snprintf -int snprintf(char *str, size_t n, const char *fmt, ...); -//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap); -#endif - -CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; - -======= ->>>>>>> srb2/next #define MINZ (FRACUNIT*4) #define BASEYCENTER (BASEVIDHEIGHT/2) @@ -308,12 +297,8 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer if (rendermode != render_none) // not for psprite -<<<<<<< HEAD - spritecachedinfo[numspritelumps].topoffset += 4<>>>>>> srb2/next + // Being selective with this causes bad things. :( Like the special stage tokens breaking apart. /*if (rendermode != render_none // not for psprite && SHORT(patch.topoffset)>0 && SHORT(patch.topoffset)>>>>>> srb2/next fixed_t frac; patch_t *patch = vis->patch; fixed_t this_scale = vis->mobj->scale; @@ -794,11 +775,7 @@ static void R_DrawVisSprite(vissprite_t *vis) colfunc = colfuncs[BASEDRAWFUNC]; // hack: this isn't resetting properly somewhere. dc_colormap = vis->colormap; -<<<<<<< HEAD - if (!(vis->cut & SC_PRECIP) && (vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" -======= if (!(vis->cut & SC_PRECIP) && (vis->mobj->flags & (MF_ENEMY|MF_BOSS)) && (vis->mobj->flags2 & MF2_FRET) && !(vis->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" ->>>>>>> srb2/next { // translate certain pixels to white colfunc = colfuncs[COLDRAWFUNC_TRANS]; @@ -813,11 +790,6 @@ static void R_DrawVisSprite(vissprite_t *vis) { colfunc = colfuncs[COLDRAWFUNC_TRANSTRANS]; dc_transmap = vis->transmap; -<<<<<<< HEAD - if (vis->mobj->colorized) - dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); - else if (vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // MT_GHOST LOOKS LIKE A PLAYER SO USE THE PLAYER TRANSLATION TABLES. >_> -======= if (!(vis->cut & SC_PRECIP) && vis->mobj->colorized) dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); else if (!(vis->cut & SC_PRECIP) @@ -831,7 +803,6 @@ static void R_DrawVisSprite(vissprite_t *vis) dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); } else if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // MT_GHOST LOOKS LIKE A PLAYER SO USE THE PLAYER TRANSLATION TABLES. >_> ->>>>>>> srb2/next { size_t skinnum = (skin_t*)vis->mobj->skin-skins; dc_translation = R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE); @@ -850,11 +821,6 @@ static void R_DrawVisSprite(vissprite_t *vis) colfunc = colfuncs[COLDRAWFUNC_TRANS]; // New colormap stuff for skins Tails 06-07-2002 -<<<<<<< HEAD - if (vis->mobj->colorized) - dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); - else if (vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // This thing is a player! -======= if (!(vis->cut & SC_PRECIP) && vis->mobj->colorized) dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); else if (!(vis->cut & SC_PRECIP) @@ -868,7 +834,6 @@ static void R_DrawVisSprite(vissprite_t *vis) dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); } else if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // This thing is a player! ->>>>>>> srb2/next { size_t skinnum = (skin_t*)vis->mobj->skin-skins; dc_translation = R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE); @@ -938,93 +903,52 @@ static void R_DrawVisSprite(vissprite_t *vis) if (vis->x2 >= vid.width) vis->x2 = vid.width-1; -<<<<<<< HEAD -#if 1 - // Something is occasionally setting 1px-wide sprites whose frac is exactly the width of the sprite, causing crashes due to - // accessing invalid column info. Until the cause is found, let's try to correct those manually... - while (frac + vis->xiscale*(vis->x2-vis->x1) > SHORT(patch->width)<x2 >= vis->x1) - vis->x2--; -#endif -======= localcolfunc = (vis->cut & SC_VFLIP) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn; lengthcol = SHORT(patch->height); ->>>>>>> srb2/next // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) { -<<<<<<< HEAD -======= pwidth = SHORT(patch->width); ->>>>>>> srb2/next // Papersprite drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += vis->scalestep) { angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF; texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / this_scale; -<<<<<<< HEAD - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) - continue; - - if (vis->xiscale < 0) // Flipped sprite - texturecolumn = SHORT(patch->width) - 1 - texturecolumn; -======= if (texturecolumn < 0 || texturecolumn >= pwidth) continue; if (vis->xiscale < 0) // Flipped sprite texturecolumn = pwidth - 1 - texturecolumn; ->>>>>>> srb2/next sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); dc_iscale = (0xffffffffu / (unsigned)spryscale); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); -<<<<<<< HEAD - if (vis->cut & SC_VFLIP) - R_DrawFlippedMaskedColumn(column, patch->height); - else - R_DrawMaskedColumn(column); -======= localcolfunc (column); ->>>>>>> srb2/next } } else { -<<<<<<< HEAD -======= #ifdef RANGECHECK pwidth = SHORT(patch->width); #endif ->>>>>>> srb2/next // Non-paper drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan) { #ifdef RANGECHECK texturecolumn = frac>>FRACBITS; -<<<<<<< HEAD - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) -======= if (texturecolumn < 0 || texturecolumn >= pwidth) ->>>>>>> srb2/next I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); #else column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); #endif -<<<<<<< HEAD - if (vis->cut & SC_VFLIP) - R_DrawFlippedMaskedColumn(column, patch->height); - else - R_DrawMaskedColumn(column); -======= localcolfunc (column); ->>>>>>> srb2/next } } @@ -1101,11 +1025,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) // // R_SplitSprite -<<<<<<< HEAD -// runs through a sector's lightlist and -======= // runs through a sector's lightlist and Knuckles ->>>>>>> srb2/next static void R_SplitSprite(vissprite_t *sprite) { INT32 i, lightnum, lindex; @@ -1173,20 +1093,8 @@ static void R_SplitSprite(vissprite_t *sprite) newsprite->extra_colormap = *sector->lightlist[i].extra_colormap; -<<<<<<< HEAD -/* - if (thing->frame & FF_TRANSMASK) - ; - else if (thing->flags2 & MF2_SHADOW) - ; - else -*/ - if (!((newsprite->cut & SC_FULLBRIGHT) - && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) -======= if (!(newsprite->cut & SC_FULLBRIGHT) || (newsprite->extra_colormap && (newsprite->extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES))) ->>>>>>> srb2/next { lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); @@ -1207,7 +1115,6 @@ static void R_SplitSprite(vissprite_t *sprite) // R_GetShadowZ(thing, shadowslope) // Get the first visible floor below the object for shadows // shadowslope is filled with the floor's slope, if provided -<<<<<<< HEAD // fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) { @@ -1221,300 +1128,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) { sector = node->m_sector; - slope = (sector->heightsec != -1) ? NULL : sector->f_slope; - z = slope ? P_GetZAt(slope, thing->x, thing->y) : ( - (sector->heightsec != -1) ? sectors[sector->heightsec].floorheight : sector->floorheight - ); - - if (z < thing->z+thing->height/2 && z > floorz) - { - floorz = z; - floorslope = slope; - } - - if (sector->ffloors) - for (rover = sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) - continue; - - z = *rover->t_slope ? P_GetZAt(*rover->t_slope, thing->x, thing->y) : *rover->topheight; - if (z < thing->z+thing->height/2 && z > floorz) - { - floorz = z; - floorslope = *rover->t_slope; - } - } - } - - if (thing->floorz > floorz + (!floorslope ? 0 : FixedMul(abs(floorslope->zdelta), thing->radius*3/2))) - { - floorz = thing->floorz; - floorslope = NULL; - } - -#if 0 // Unfortunately, this drops CEZ2 down to sub-17 FPS on my i7. -//#ifdef POLYOBJECTS - // Check polyobjects and see if floorz needs to be altered, for rings only because they don't update floorz - if (thing->type == MT_RING) - { - INT32 xl, xh, yl, yh, bx, by; - - xl = (unsigned)(thing->x - thing->radius - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(thing->x + thing->radius - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(thing->y - thing->radius - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(thing->y + thing->radius - bmaporgy)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - validcount++; - - for (by = yl; by <= yh; by++) - for (bx = xl; bx <= xh; bx++) - { - INT32 offset; - polymaplink_t *plink; // haleyjd 02/22/06 - - if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) - continue; - - offset = by*bmapwidth + bx; - - // haleyjd 02/22/06: consider polyobject lines - plink = polyblocklinks[offset]; - - while (plink) - { - polyobj_t *po = plink->po; - - if (po->validcount != validcount) // if polyobj hasn't been checked - { - po->validcount = validcount; - - if (!P_MobjInsidePolyobj(po, thing) || !(po->flags & POF_RENDERPLANES)) - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - // We're inside it! Yess... - z = po->lines[0]->backsector->ceilingheight; - - if (z < thing->z+thing->height/2 && z > floorz) - { - floorz = z; - floorslope = NULL; - } - } - plink = (polymaplink_t *)(plink->link.next); - } - } - } -#endif - - if (shadowslope != NULL) - *shadowslope = floorslope; - - return floorz; -} - -static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, fixed_t tx, fixed_t tz) -{ - vissprite_t *shadow; - patch_t *patch; - fixed_t xscale, yscale, shadowxscale, shadowyscale, shadowskew, x1, x2; - INT32 light = 0; - fixed_t scalemul; UINT8 trans; - fixed_t floordiff; - fixed_t floorz; - pslope_t *floorslope; - - floorz = R_GetShadowZ(thing, &floorslope); - - if (abs(floorz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes - - floordiff = abs(thing->z - floorz); - - trans = floordiff / (100*FRACUNIT) + 3; - if (trans >= 9) return; - - scalemul = FixedMul(FRACUNIT - floordiff/640, scale); - - if (thing->whiteshadow) - patch = W_CachePatchName("LSHADOW", PU_CACHE); - else - patch = W_CachePatchName("DSHADOW", PU_CACHE); - - xscale = FixedDiv(projection, tz); - yscale = FixedDiv(projectiony, tz); - shadowxscale = FixedMul(thing->radius*2, scalemul); - shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(floorz - viewz), tz)); - shadowyscale = min(shadowyscale, shadowxscale) / patch->height; - shadowxscale /= patch->width; - shadowskew = 0; - - if (floorslope) - { - // haha let's try some dumb stuff - fixed_t xslope, zslope; - angle_t sloperelang = (R_PointToAngle(thing->x, thing->y) - floorslope->xydirection) >> ANGLETOFINESHIFT; - - xslope = FixedMul(FINESINE(sloperelang), floorslope->zdelta); - zslope = FixedMul(FINECOSINE(sloperelang), floorslope->zdelta); - - //CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope); - - if (viewz < floorz) - shadowyscale += FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), zslope); - else - shadowyscale -= FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), zslope); - - shadowyscale = abs(shadowyscale); - - shadowskew = xslope; - } - - tx -= patch->width * shadowxscale/2; - x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; - if (x1 >= viewwidth) return; - - tx += patch->width * shadowxscale; - x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; - if (x2 < 0 || x2 <= x1) return; - - if (shadowyscale < FRACUNIT/patch->height) return; // fix some crashes? - - shadow = R_NewVisSprite(); - - if (thing->whiteshadow) - shadow->patch = W_CheckNumForName("LSHADOW"); - else - shadow->patch = W_CheckNumForName("DSHADOW"); - - shadow->heightsec = vis->heightsec; - - shadow->thingheight = FRACUNIT; - shadow->pz = floorz; - shadow->pzt = shadow->pz + shadow->thingheight; - - shadow->mobjflags = 0; - shadow->sortscale = vis->sortscale; - shadow->dispoffset = vis->dispoffset - 5; - shadow->gx = thing->x; - shadow->gy = thing->y; - shadow->gzt = shadow->pz + patch->height * shadowyscale / 2; - shadow->gz = shadow->gzt - patch->height * shadowyscale; - shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); - if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) - shadow->texturemid = FixedMul(shadow->texturemid, ((skin_t *)thing->skin)->highresscale); - shadow->scalestep = 0; - shadow->shear.tan = shadowskew; // repurposed variable - - shadow->mobj = thing; // Easy access! Tails 06-07-2002 - - shadow->x1 = x1 < 0 ? 0 : x1; - shadow->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - - // PORTAL SEMI-CLIPPING - if (portalrender) - { - if (shadow->x1 < portalclipstart) - shadow->x1 = portalclipstart; - if (shadow->x2 >= portalclipend) - shadow->x2 = portalclipend-1; - } - - shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000 - shadow->scale = FixedMul(yscale, shadowyscale); - shadow->sector = vis->sector; - shadow->szt = (INT16)((centeryfrac - FixedMul(shadow->gzt - viewz, yscale))>>FRACBITS); - shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS); - shadow->cut = SC_ISSCALED|SC_SHADOW; //check this - - shadow->startfrac = 0; - //shadow->xiscale = 0x7ffffff0 / (shadow->xscale/2); - shadow->xiscale = (patch->width<x1 > x1) - shadow->startfrac += shadow->xiscale*(shadow->x1-x1); - - // reusing x1 variable - x1 += (x2-x1)/2; - shadow->shear.offset = shadow->x1-x1; - - if (thing->subsector->sector->numlights) - { - INT32 lightnum; -#ifdef ESLOPE // R_GetPlaneLight won't work on sloped lights! - light = thing->subsector->sector->numlights - 1; - - for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { - fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, thing->x, thing->y) - : thing->subsector->sector->lightlist[lightnum].height; - if (h <= shadow->gzt) { - light = lightnum - 1; - break; - } - } -#else - light = R_GetPlaneLight(thing->subsector->sector, shadow->gzt, false); -#endif - } - - if (thing->subsector->sector->numlights) - shadow->extra_colormap = thing->subsector->sector->lightlist[light].extra_colormap; - else - shadow->extra_colormap = thing->subsector->sector->extra_colormap; - - shadow->transmap = transtables + (trans<whiteshadow) - shadow->colormap = scalelight[LIGHTLEVELS - 1][0]; // full bright! - else - shadow->colormap = scalelight[0][0]; // full dark! - - objectsdrawn++; -} - -// -// R_ProjectSprite -// Generates a vissprite for a thing -// if it might be visible. -======= ->>>>>>> srb2/next -// -fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) -{ -<<<<<<< HEAD - const fixed_t thingxpos = thing->x + thing->sprxoff; - const fixed_t thingypos = thing->y + thing->spryoff; - const fixed_t thingzpos = thing->z + thing->sprzoff; - - fixed_t tr_x, tr_y; - fixed_t gxt, gyt; - fixed_t tx, tz; - fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! - - INT32 x1, x2; -======= - fixed_t z, floorz = INT32_MIN; - pslope_t *slope, *floorslope = NULL; - msecnode_t *node; - sector_t *sector; - ffloor_t *rover; ->>>>>>> srb2/next - - for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next) - { - sector = node->m_sector; - -<<<<<<< HEAD - size_t rot; - UINT8 flip; - boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); -======= slope = sector->heightsec != -1 ? NULL : sector->f_slope; ->>>>>>> srb2/next if (sector->heightsec != -1) z = sectors[sector->heightsec].floorheight; @@ -1527,23 +1141,11 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) floorslope = slope; } -<<<<<<< HEAD - angle_t ang = 0; // gcc 4.6 and lower fix - fixed_t iscale; - fixed_t scalestep; // toast '16 - fixed_t offset, offset2; - - fixed_t basetx; // drop shadows - - boolean papersprite = !!(thing->frame & FF_PAPERSPRITE); - fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; -======= if (sector->ffloors) for (rover = sector->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) continue; ->>>>>>> srb2/next z = P_GetFFloorTopZAt(rover, thing->x, thing->y); if (z < thing->z+thing->height/2 && z > floorz) @@ -1554,11 +1156,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) } } -<<<<<<< HEAD - // transform the origin point - tr_x = thingxpos - viewx; - tr_y = thingypos - viewy; -======= if (thing->floorz > floorz + (!floorslope ? 0 : FixedMul(abs(floorslope->zdelta), thing->radius*3/2))) { floorz = thing->floorz; @@ -1570,7 +1167,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) if (thing->type == MT_RING) { INT32 xl, xh, yl, yh, bx, by; ->>>>>>> srb2/next xl = (unsigned)(thing->x - thing->radius - bmaporgx)>>MAPBLOCKSHIFT; xh = (unsigned)(thing->x + thing->radius - bmaporgx)>>MAPBLOCKSHIFT; @@ -1579,19 +1175,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) BMBOUNDFIX(xl, xh, yl, yh); -<<<<<<< HEAD - // thing is behind view plane? - if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later - return; - - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - basetx = tx = -(gyt + gxt); - - // too far off the side? - if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later - return; -======= validcount++; for (by = yl; by <= yh; by++) @@ -1602,7 +1185,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) continue; ->>>>>>> srb2/next offset = by*bmapwidth + bx; @@ -1638,18 +1220,8 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) } #endif -<<<<<<< HEAD - if (sprframe->rotate != SRF_SINGLE || papersprite) - { - if (thing->player) - ang = R_PointToAngle (thingxpos, thingypos) - thing->player->frameangle; - else - ang = R_PointToAngle (thingxpos, thingypos) - thing->angle; - } -======= if (shadowslope != NULL) *shadowslope = floorslope; ->>>>>>> srb2/next return floorz; } @@ -1676,7 +1248,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, scalemul = FixedMul(FRACUNIT - floordiff/640, scale); - patch = W_CachePatchName("DSHADOW", PU_CACHE); + patch = W_CachePatchName((thing->whiteshadow == true ? "LSHADOW" : "DSHADOW"), PU_CACHE); xscale = FixedDiv(projection, tz); yscale = FixedDiv(projectiony, tz); shadowxscale = FixedMul(thing->radius*2, scalemul); @@ -1782,7 +1354,15 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->extra_colormap = thing->subsector->sector->extra_colormap; shadow->transmap = transtables + (trans<colormap = scalelight[0][0]; // full dark! + + if (thing->whiteshadow == true) + { + shadow->colormap = scalelight[LIGHTLEVELS - 1][0]; // full bright! + } + else + { + shadow->colormap = scalelight[0][0]; // full dark! + } objectsdrawn++; } @@ -1794,7 +1374,16 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, // static void R_ProjectSprite(mobj_t *thing) { + const fixed_t thingxpos = thing->x + thing->sprxoff; + const fixed_t thingypos = thing->y + thing->spryoff; + const fixed_t thingzpos = thing->z + thing->sprzoff; + mobj_t *oldthing = thing; + + const fixed_t oldthingxpos = oldthing->x + oldthing->sprxoff; + const fixed_t oldthingypos = oldthing->y + oldthing->spryoff; + const fixed_t oldthingzpos = oldthing->z + oldthing->sprzoff; + fixed_t tr_x, tr_y; fixed_t tx, tz; fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! @@ -1845,8 +1434,8 @@ static void R_ProjectSprite(mobj_t *thing) #endif // transform the origin point - tr_x = thing->x - viewx; - tr_y = thing->y - viewy; + tr_x = thingxpos - viewx; + tr_y = thingypos - viewy; tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance @@ -1921,7 +1510,7 @@ static void R_ProjectSprite(mobj_t *thing) #endif if (sprframe->rotate != SRF_SINGLE || papersprite) - ang = R_PointToAngle (thing->x, thing->y) - (thing->player ? thing->player->drawangle : thing->angle); + ang = R_PointToAngle (thingxpos, thingypos) - (thing->player ? thing->player->drawangle : thing->angle); if (sprframe->rotate == SRF_SINGLE) { @@ -1987,11 +1576,7 @@ static void R_ProjectSprite(mobj_t *thing) else offset = -spr_offset; offset = FixedMul(offset, this_scale); -<<<<<<< HEAD - offset2 = FixedMul(spritecachedinfo[lump].width, this_scale); -======= offset2 = FixedMul(spr_width, this_scale); ->>>>>>> srb2/next if (papersprite) { @@ -2009,23 +1594,9 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset, cosmul); tr_y += FixedMul(offset, sinmul); -<<<<<<< HEAD - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - tz = gxt-gyt; - yscale = FixedDiv(projectiony, tz); - //if (yscale < 64) return; // Fix some funky visuals - - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx = -(gyt + gxt); - xscale = FixedDiv(projection, tz); - x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; -======= tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); ->>>>>>> srb2/next // Get paperoffset (offset) and paperoffset (distance) paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul); @@ -2039,23 +1610,9 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset2, cosmul); tr_y += FixedMul(offset2, sinmul); -<<<<<<< HEAD - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - tz2 = gxt-gyt; - yscale2 = FixedDiv(projectiony, tz2); - //if (yscale2 < 64) return; // ditto - - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx2 = -(gyt + gxt); - xscale2 = FixedDiv(projection, tz2); - x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS); -======= tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); ->>>>>>> srb2/next if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; @@ -2066,25 +1623,12 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz); tx += FixedDiv(tx2-tx, div); tz = FixedMul(MINZ, this_scale); -<<<<<<< HEAD - yscale = FixedDiv(projectiony, tz); - xscale = FixedDiv(projection, tz); - x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; -======= ->>>>>>> srb2/next } else if (tz2 < FixedMul(MINZ, this_scale)) { fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2); tx2 += FixedDiv(tx-tx2, div); tz2 = FixedMul(MINZ, this_scale); -<<<<<<< HEAD - yscale2 = FixedDiv(projectiony, tz2); - xscale2 = FixedDiv(projection, tz2); - x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; - } - -======= } if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side? @@ -2095,19 +1639,15 @@ static void R_ProjectSprite(mobj_t *thing) x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; ->>>>>>> srb2/next // off the right side? if (x1 > viewwidth) return; -<<<<<<< HEAD -======= yscale2 = FixedDiv(projectiony, tz2); xscale2 = FixedDiv(projection, tz2); x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; ->>>>>>> srb2/next // off the left side if (x2 < 0) return; @@ -2130,19 +1670,6 @@ static void R_ProjectSprite(mobj_t *thing) yscale = sortscale; tx += offset; x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; -<<<<<<< HEAD - - // off the right side? - if (x1 > viewwidth) - return; - - tx += offset2; - x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; - - // off the left side - if (x2 < 0) - return; -======= // off the right side? if (x1 > viewwidth) @@ -2165,8 +1692,8 @@ static void R_ProjectSprite(mobj_t *thing) if (! R_ThingVisible(thing)) return; - tr_x = thing->x - viewx; - tr_y = thing->y - viewy; + tr_x = thingxpos - viewx; + tr_y = thingypos - viewy; tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); linkscale = FixedDiv(projectiony, tz); @@ -2178,7 +1705,6 @@ static void R_ProjectSprite(mobj_t *thing) sortscale = linkscale; // now make sure it's linked cut = SC_LINKDRAW; ->>>>>>> srb2/next } // PORTAL SPRITE CLIPPING @@ -2197,23 +1723,13 @@ static void R_ProjectSprite(mobj_t *thing) // When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned. // sprite height - sprite topoffset is the proper inverse of the vertical offset, of course. // remember gz and gzt should be seperated by sprite height, not thing height - thing height can be shorter than the sprite itself sometimes! -<<<<<<< HEAD - gz = thingzpos + thing->height - FixedMul(spritecachedinfo[lump].topoffset, this_scale); - gzt = gz + FixedMul(spritecachedinfo[lump].height, this_scale); - } - else - { - gzt = thingzpos + FixedMul(spritecachedinfo[lump].topoffset, this_scale); - gz = gzt - FixedMul(spritecachedinfo[lump].height, this_scale); -======= - gz = oldthing->z + oldthing->height - FixedMul(spr_topoffset, this_scale); + gz = oldthingzpos + oldthing->height - FixedMul(spr_topoffset, this_scale); gzt = gz + FixedMul(spr_height, this_scale); } else { - gzt = oldthing->z + FixedMul(spr_topoffset, this_scale); + gzt = oldthingzpos + FixedMul(spr_topoffset, this_scale); gz = gzt - FixedMul(spr_height, this_scale); ->>>>>>> srb2/next } if (thing->subsector->sector->cullheight) @@ -2229,12 +1745,7 @@ static void R_ProjectSprite(mobj_t *thing) // R_GetPlaneLight won't work on sloped lights! for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { -<<<<<<< HEAD - fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, thingxpos, thingypos) - : thing->subsector->sector->lightlist[lightnum].height; -======= - fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], thing->x, thing->y); ->>>>>>> srb2/next + fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], thingxpos, thingypos); if (h <= gzt) { light = lightnum - 1; break; @@ -2275,15 +1786,9 @@ static void R_ProjectSprite(mobj_t *thing) vis->mobjflags = thing->flags; vis->scale = yscale; //<sortscale = sortscale; -<<<<<<< HEAD - vis->dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15 + vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15 vis->gx = thingxpos; vis->gy = thingypos; -======= - vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15 - vis->gx = thing->x; - vis->gy = thing->y; ->>>>>>> srb2/next vis->gz = gz; vis->gzt = gzt; vis->thingheight = thing->height; @@ -2353,21 +1858,13 @@ static void R_ProjectSprite(mobj_t *thing) else if (oldthing->frame & FF_TRANSMASK) vis->transmap = transtables + (oldthing->frame & FF_TRANSMASK) - 0x10000; -<<<<<<< HEAD - if (thing->frame & FF_FULLBRIGHT || thing->flags2 & MF2_SHADOW) + if (oldthing->frame & FF_FULLBRIGHT || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) vis->cut |= SC_FULLBRIGHT; - else if (thing->frame & FF_SEMIBRIGHT) + else if (oldthing->frame & FF_SEMIBRIGHT) vis->cut |= SC_SEMIBRIGHT; - if (vis->cut & SC_FULLBRIGHT - && (!vis->extra_colormap || !(vis->extra_colormap->fog & 1))) -======= - if (oldthing->frame & FF_FULLBRIGHT || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) - vis->cut |= SC_FULLBRIGHT; - if (vis->cut & SC_FULLBRIGHT && (!vis->extra_colormap || !(vis->extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES))) ->>>>>>> srb2/next { // full bright: goggles vis->colormap = colormaps; @@ -2392,13 +1889,8 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->numlights) R_SplitSprite(vis); -<<<<<<< HEAD - if (thing->shadowscale && cv_shadow.value) - R_ProjectDropShadow(thing, vis, thing->shadowscale, basetx, tz); -======= if (oldthing->shadowscale && cv_shadow.value) R_ProjectDropShadow(oldthing, vis, oldthing->shadowscale, basetx, tz); ->>>>>>> srb2/next // Debug ++objectsdrawn; @@ -2493,16 +1985,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } -<<<<<<< HEAD - // okay, we can't return now except for vertical clipping... this is a hack, but weather isn't networked, so it should be ok - if (!(thing->precipflags & PCF_THUNK)) - { - P_PrecipThinker(thing); - thing->precipflags |= PCF_THUNK; - } -======= ->>>>>>> srb2/next - //SoM: 3/17/2000: Disregard sprites that are out of view.. gzt = thing->z + spritecachedinfo[lump].topoffset; gz = gzt - spritecachedinfo[lump].height; @@ -2564,20 +2046,14 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) // Fullbright vis->colormap = colormaps; -<<<<<<< HEAD -======= weatherthink: // okay... this is a hack, but weather isn't networked, so it should be ok if (!(thing->precipflags & PCF_THUNK)) { - if (thing->precipflags & PCF_RAIN) - P_RainThinker(thing); - else - P_SnowThinker(thing); + P_PrecipThinker(thing); thing->precipflags |= PCF_THUNK; } ->>>>>>> srb2/next } // R_AddSprites @@ -2590,9 +2066,6 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) INT32 lightnum; fixed_t limit_dist, hoop_limit_dist; - INT32 splitflags; // check if a mobj has spliscreen flags - boolean split_drawsprite; // used for splitscreen flags - if (rendermode != render_soft) return; @@ -2622,122 +2095,20 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. -<<<<<<< HEAD - if ((limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale)) - { - for (thing = sec->thinglist; thing; thing = thing->snext) - { - split_drawsprite = false; - - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) - continue; - - splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); - - if (r_splitscreen && splitflags) - { - if (thing->eflags & MFE_DRAWONLYFORP1) - if (viewssnum == 0) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP2) - if (viewssnum == 1) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) - if (viewssnum == 2) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) - if (viewssnum == 3) - split_drawsprite = true; - } - else - split_drawsprite = true; - - if (!split_drawsprite) - continue; - - approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - - if (approx_dist > limit_dist) - continue; - - R_ProjectSprite(thing); - } - } - else - { - // Draw everything in sector, no checks - for (thing = sec->thinglist; thing; thing = thing->snext) - { - - split_drawsprite = false; - - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) - continue; - - splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); - - if (r_splitscreen && splitflags) - { - if (thing->eflags & MFE_DRAWONLYFORP1) - if (viewssnum == 0) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP2) - if (viewssnum == 1) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) - if (viewssnum == 2) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) - if (viewssnum == 3) - split_drawsprite = true; - } - else - split_drawsprite = true; - - if (!split_drawsprite) - continue; - - R_ProjectSprite(thing); - } - } - - // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off - if ((limit_dist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale)) - { - for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) - { - if (precipthing->precipflags & PCF_INVISIBLE) - continue; - - approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); - - if (approx_dist > limit_dist) - continue; - - R_ProjectPrecipitationSprite(precipthing); -======= - limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS; - hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS; + limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; for (thing = sec->thinglist; thing; thing = thing->snext) { - if (R_ThingVisibleWithinDist(thing, limit_dist, hoop_limit_dist)) + if (R_ThingVisibleWithinDist(thing, limit_dist)) R_ProjectSprite(thing); } // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off - if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS)) + if ((limit_dist = (fixed_t)cv_drawdist_precip.value * mapobjectscale)) { for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) { if (R_PrecipThingVisible(precipthing, limit_dist)) R_ProjectPrecipitationSprite(precipthing); ->>>>>>> srb2/next } } } @@ -3422,16 +2793,40 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible (mobj_t *thing) { - return (!( - thing->sprite == SPR_NULL || - ( thing->flags2 & (MF2_DONTDRAW) ) || - thing == r_viewmobj - )); + boolean split_drawsprite = true; + UINT16 splitflags = 0; + + if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW || thing == r_viewmobj) + return false; + + splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); + + if (r_splitscreen && splitflags) + { + split_drawsprite = false; + + if (thing->eflags & MFE_DRAWONLYFORP1) + if (viewssnum == 0) + split_drawsprite = true; + + if (thing->eflags & MFE_DRAWONLYFORP2) + if (viewssnum == 1) + split_drawsprite = true; + + if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) + if (viewssnum == 2) + split_drawsprite = true; + + if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) + if (viewssnum == 3) + split_drawsprite = true; + } + + return split_drawsprite; } boolean R_ThingVisibleWithinDist (mobj_t *thing, - fixed_t limit_dist, - fixed_t hoop_limit_dist) + fixed_t limit_dist) { fixed_t approx_dist; @@ -3440,16 +2835,8 @@ boolean R_ThingVisibleWithinDist (mobj_t *thing, approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - if (thing->sprite == SPR_HOOP) - { - if (hoop_limit_dist && approx_dist > hoop_limit_dist) - return false; - } - else - { - if (limit_dist && approx_dist > limit_dist) - return false; - } + if (limit_dist && approx_dist > limit_dist) + return false; return true; } @@ -3513,103 +2900,13 @@ static void R_DrawMaskedList (drawnode_t* head) { vissprite_t *ds = r2->sprite->linkdraw; -<<<<<<< HEAD - R_DoneWithNode(r2); - r2 = next; - } - } - R_ClearDrawNodes(); -} - -// ========================================================================== -// -// SKINS CODE -// -// ========================================================================== - -INT32 numskins = 0; -skin_t skins[MAXSKINS]; -// FIXTHIS: don't work because it must be inistilised before the config load -//#define SKINVALUES -#ifdef SKINVALUES -CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; -#endif - -static void Sk_SetDefaultValue(skin_t *skin) -{ - INT32 i; - // - // set default skin values - // - memset(skin, 0, sizeof (skin_t)); - snprintf(skin->name, - sizeof skin->name, "skin %u", (UINT32)(skin-skins)); - skin->name[sizeof skin->name - 1] = '\0'; - skin->wadnum = INT16_MAX; - strcpy(skin->sprite, ""); - - skin->flags = 0; - - strcpy(skin->realname, "Someone"); - strcpy(skin->hudname, "???"); - strncpy(skin->facerank, "PLAYRANK", 9); - strncpy(skin->facewant, "PLAYWANT", 9); - strncpy(skin->facemmap, "PLAYMMAP", 9); - - skin->starttranscolor = 96; - skin->prefcolor = SKINCOLOR_GREEN; - - // SRB2kart - skin->kartspeed = 5; - skin->kartweight = 5; - // - - skin->highresscale = FRACUNIT>>1; - - for (i = 0; i < sfx_skinsoundslot0; i++) - if (S_sfx[i].skinsound != -1) - skin->soundsid[S_sfx[i].skinsound] = i; -} - -// returns true if the skin name is found (loaded from pwad) -// warning return -1 if not found -INT32 R_SkinAvailable(const char *name) -{ - INT32 i; -======= for (; (ds != NULL && r2->sprite->dispoffset > ds->dispoffset); ds = ds->next) R_DrawSprite(ds); ->>>>>>> srb2/next R_DrawSprite(r2->sprite); -<<<<<<< HEAD -// network code calls this when a 'skin change' is received -boolean SetPlayerSkin(INT32 playernum, const char *skinname) -{ - INT32 i; - player_t *player = &players[playernum]; - - for (i = 0; i < numskins; i++) - { - // search in the skin list - if (stricmp(skins[i].name, skinname) == 0) - { - SetPlayerSkinByNum(playernum, i); - return true; - } - } - - if (P_IsLocalPlayer(player)) - CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); - else if(server || IsPlayerAdmin(consoleplayer)) - CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); - - SetPlayerSkinByNum(playernum, 0); - return false; -======= for (; ds != NULL; ds = ds->next) R_DrawSprite(ds); } @@ -3618,61 +2915,10 @@ boolean SetPlayerSkin(INT32 playernum, const char *skinname) r2 = next; } } ->>>>>>> srb2/next } void R_DrawMasked(maskcount_t* masks, UINT8 nummasks) { -<<<<<<< HEAD - player_t *player = &players[playernum]; - skin_t *skin = &skins[skinnum]; - - if (skinnum >= 0 && skinnum < numskins) // Make sure it exists! - { - player->skin = skinnum; - if (player->mo) - player->mo->skin = skin; - - player->charflags = (UINT32)skin->flags; - - // SRB2kart - player->kartspeed = skin->kartspeed; - player->kartweight = skin->kartweight; - - /*if (!(cv_debug || devparm) && !(netgame || multiplayer || demo.playback || modeattacking)) - { - if (playernum == consoleplayer) - CV_StealthSetValue(&cv_playercolor, skin->prefcolor); - else if (playernum == displayplayers[1]) - CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); - else if (playernum == displayplayers[2]) - CV_StealthSetValue(&cv_playercolor3, skin->prefcolor); - else if (playernum == displayplayers[3]) - CV_StealthSetValue(&cv_playercolor4, skin->prefcolor); - player->skincolor = skin->prefcolor; - if (player->mo) - player->mo->color = player->skincolor; - }*/ - - if (player->mo) - P_SetScale(player->mo, player->mo->scale); - - demo_extradata[playernum] |= DXD_SKIN; - - return; - } - - if (P_IsLocalPlayer(player)) - CONS_Alert(CONS_WARNING, M_GetText("Skin %d not found\n"), skinnum); - else if(server || IsPlayerAdmin(consoleplayer)) - CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); - SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin -} - -// -// Add skins from a pwad, each skin preceded by 'S_SKIN' marker -// -======= drawnode_t *heads; /**< Drawnode lists; as many as number of views/portals. */ SINT8 i; @@ -3681,7 +2927,6 @@ void R_DrawMasked(maskcount_t* masks, UINT8 nummasks) for (i = 0; i < nummasks; i++) { heads[i].next = heads[i].prev = &heads[i]; ->>>>>>> srb2/next viewx = masks[i].viewx; viewy = masks[i].viewy; @@ -3690,292 +2935,12 @@ void R_DrawMasked(maskcount_t* masks, UINT8 nummasks) R_CreateDrawNodes(&masks[i], &heads[i], false); } -<<<<<<< HEAD - return INT16_MAX; // not found -} - -// -// Find skin sprites, sounds & optional status bar face, & add them -// -void R_AddSkins(UINT16 wadnum) -{ - UINT16 lump, lastlump = 0; - char *buf; - char *buf2; - char *stoken; - char *value; - size_t size; - skin_t *skin; - boolean hudname, realname; -======= ->>>>>>> srb2/next //for (i = 0; i < nummasks; i++) // CONS_Printf("Mask no.%d:\ndrawsegs: %d\n vissprites: %d\n\n", i, masks[i].drawsegs[1] - masks[i].drawsegs[0], masks[i].vissprites[1] - masks[i].vissprites[0]); for (; nummasks > 0; nummasks--) { -<<<<<<< HEAD - // advance by default - lastlump = lump + 1; - - if (numskins >= MAXSKINS) - { - CONS_Debug(DBG_RENDER, "ignored skin (%d skins maximum)\n", MAXSKINS); - continue; // so we know how many skins couldn't be added - } - buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); - size = W_LumpLengthPwad(wadnum, lump); - - // for strtok - buf2 = malloc(size+1); - if (!buf2) - I_Error("R_AddSkins: No more free memory\n"); - M_Memcpy(buf2,buf,size); - buf2[size] = '\0'; - - // set defaults - skin = &skins[numskins]; - Sk_SetDefaultValue(skin); - skin->wadnum = wadnum; - hudname = realname = false; - // parse - stoken = strtok (buf2, "\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_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); - - if (!stricmp(stoken, "name")) - { - // 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) - { - STRBUFCPY(skin->name, value); - strlwr(skin->name); - } - // I'm not lazy, so if the name is already used I make the name 'namex' - // using the default skin name's number set above - else - { - const size_t stringspace = - strlen(value) + sizeof (numskins) + 1; - char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); - snprintf(value2, stringspace, - "%s%d", value, numskins); - value2[stringspace - 1] = '\0'; - if (R_SkinAvailable(value2) == -1) - { - STRBUFCPY(skin->name, - value2); - strlwr(skin->name); - } - Z_Free(value2); - } - - // copy to hudname and fullname as a default. - if (!realname) - { - STRBUFCPY(skin->realname, skin->name); - for (value = skin->realname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - } - if (!hudname) - { - STRBUFCPY(skin->hudname, skin->name); - strupr(skin->hudname); - for (value = skin->hudname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - } - } - else if (!stricmp(stoken, "realname")) - { // Display name (eg. "Knuckles") - realname = true; - STRBUFCPY(skin->realname, value); - for (value = skin->realname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - if (!hudname) - STRBUFCPY(skin->hudname, skin->realname); - } - else if (!stricmp(stoken, "hudname")) - { // Life icon name (eg. "K.T.E") - hudname = true; - STRBUFCPY(skin->hudname, value); - for (value = skin->hudname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - if (!realname) - STRBUFCPY(skin->realname, skin->hudname); - } - - else if (!stricmp(stoken, "sprite")) - { - strupr(value); - strncpy(skin->sprite, value, sizeof skin->sprite); - } - else if (!stricmp(stoken, "facerank")) - { - strupr(value); - strncpy(skin->facerank, value, sizeof skin->facerank); - } - else if (!stricmp(stoken, "facewant")) - { - strupr(value); - strncpy(skin->facewant, value, sizeof skin->facewant); - } - else if (!stricmp(stoken, "facemmap")) - { - strupr(value); - strncpy(skin->facemmap, value, sizeof skin->facemmap); - } - -#define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); - // character type identification - FULLPROCESS(flags) -#undef FULLPROCESS - -#define GETKARTSTAT(field) \ - else if (!stricmp(stoken, #field)) \ - { \ - skin->field = atoi(value); \ - if (skin->field < 1) skin->field = 1; \ - if (skin->field > 9) skin->field = 9; \ - } - GETKARTSTAT(kartspeed) - GETKARTSTAT(kartweight) -#undef GETKARTSTAT - - // custom translation table - else if (!stricmp(stoken, "startcolor")) - skin->starttranscolor = atoi(value); - - else if (!stricmp(stoken, "prefcolor")) - skin->prefcolor = K_GetKartColorByName(value); - else if (!stricmp(stoken, "highresscale")) - skin->highresscale = FLOAT_TO_FIXED(atof(value)); - else - { - INT32 found = false; - sfxenum_t i; - // copy name of sounds that are remapped - // for this skin - for (i = 0; i < sfx_skinsoundslot0; i++) - { - if (!S_sfx[i].name) - continue; - if (S_sfx[i].skinsound != -1 - && !stricmp(S_sfx[i].name, - stoken + 2)) - { - skin->soundsid[S_sfx[i].skinsound] = - S_AddSoundFx(value+2, S_sfx[i].singularity, S_sfx[i].pitch, true); - found = true; - } - } - if (!found) - CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump# %d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); - } -next_token: - stoken = strtok(NULL, "\r\n= "); - } - free(buf2); - - lump++; // if no sprite defined use spirte just after this one - if (skin->sprite[0] == '\0') - { - const char *csprname = W_CheckNameForNumPwad(wadnum, lump); - - // 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_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump); - } - else - { - // search in the normal sprite tables - size_t name; - boolean found = false; - const char *sprname = skin->sprite; - for (name = 0;sprnames[name][0] != '\0';name++) - if (strncmp(sprnames[name], sprname, 4) == 0) - { - found = true; - skin->spritedef = sprites[name]; - } - - // not found so make a new one - // go through the entire current wad looking for our sprite - // don't just mass add anything beginning with our four letters. - // "HOODFACE" is not a sprite name. - if (!found) - { - UINT16 localllump = 0, lstart = UINT16_MAX, lend = UINT16_MAX; - const char *lname; - - while ((lname = W_CheckNameForNumPwad(wadnum,localllump))) - { - // If this is a valid sprite... - if (!memcmp(lname,sprname,4) && lname[4] && lname[5] && lname[5] >= '0' && lname[5] <= '8') - { - if (lstart == UINT16_MAX) - lstart = localllump; - // If already set do nothing - } - else - { - if (lstart != UINT16_MAX) - { - lend = localllump; - break; - } - // If not already set do nothing - } - ++localllump; - } - - R_AddSingleSpriteDef(sprname, &skin->spritedef, wadnum, lstart, lend); - } - - // I don't particularly care about skipping to the end of the used frames. - // We could be using frames from ANYWHERE in the current WAD file, including - // right before us, which is a terrible idea. - // So just let the function in the while loop take care of it for us. - } - - R_FlushTranslationColormapCache(); - - CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); -#ifdef SKINVALUES - skin_cons_t[numskins].value = numskins; - skin_cons_t[numskins].strvalue = skin->name; -#endif - - // Update the forceskin possiblevalues - Forceskin_cons_t[numskins+1].value = numskins; - Forceskin_cons_t[numskins+1].strvalue = skins[numskins].name; - - // add face graphics - ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins); - -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_AddPlayerMD2(numskins); -#endif - - numskins++; -======= viewx = masks[nummasks - 1].viewx; viewy = masks[nummasks - 1].viewy; viewz = masks[nummasks - 1].viewz; @@ -3983,7 +2948,6 @@ next_token: R_DrawMaskedList(&heads[nummasks - 1]); R_ClearDrawNodes(&heads[nummasks - 1]); ->>>>>>> srb2/next } free(heads); diff --git a/src/r_things.h b/src/r_things.h index 90ba8bedb..af71d2661 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -53,20 +53,12 @@ void R_DrawFlippedMaskedColumn(column_t *column); // SPRITE RENDERING // ---------------- -<<<<<<< HEAD -fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); - -#ifdef DELFILE -void R_DelSpriteDefs(UINT16 wadnum); -#endif -======= // Constant arrays used for psprite clipping // and initializing clipping. extern INT16 negonearray[MAXVIDWIDTH]; extern INT16 screenheightarray[MAXVIDWIDTH]; fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); ->>>>>>> srb2/next //SoM: 6/5/2000: Light sprites correctly! void R_AddSprites(sector_t *sec, INT32 lightlevel); @@ -74,19 +66,7 @@ void R_InitSprites(void); void R_ClearSprites(void); void R_ClipSprites(drawseg_t* dsstart, portal_t* portal); -<<<<<<< HEAD -// ----------- -// SKINS STUFF -// ----------- -#define SKINNAMESIZE 16 -// should be all lowercase!! S_SKIN processing does a strlwr -#define DEFAULTSKIN "sonic" -#define DEFAULTSKIN2 "tails" // secondary player -#define DEFAULTSKIN3 "knuckles" // third player -#define DEFAULTSKIN4 "eggman" // fourth player -======= boolean R_ThingVisible (mobj_t *thing); ->>>>>>> srb2/next boolean R_ThingVisibleWithinDist (mobj_t *thing, fixed_t draw_dist, @@ -104,37 +84,6 @@ boolean R_PrecipThingVisible (precipmobj_t *precipthing, */ typedef struct { -<<<<<<< HEAD - char name[SKINNAMESIZE+1]; // INT16 descriptive name of the skin - spritedef_t spritedef; - UINT16 wadnum; - char sprite[4]; // Sprite name, if seperated from S_SKIN. - skinflags_t flags; - - char realname[SKINNAMESIZE+1]; // Display name for level completion. - char hudname[SKINNAMESIZE+1]; // HUD name to display (officially exactly 5 characters long) - char facerank[9], facewant[9], facemmap[9]; // Arbitrarily named patch lumps - - // SRB2kart - UINT8 kartspeed; - UINT8 kartweight; - // - - // Definable color translation table - UINT8 starttranscolor; - UINT8 prefcolor; - fixed_t highresscale; // scale of highres, default is 0.5 - - // specific sounds per skin - sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table -} skin_t; - -extern CV_PossibleValue_t Forceskin_cons_t[]; - -// ----------- -// NOT SKINS STUFF ! -// ----------- -======= size_t drawsegs[2]; size_t vissprites[2]; fixed_t viewx, viewy, viewz; /**< View z stored at the time of the BSP traversal for the view/portal. Masked sorting/drawing needs it. */ @@ -155,7 +104,6 @@ void R_DrawMasked(maskcount_t* masks, UINT8 nummasks); #define VISSPRITESPERCHUNK (1 << VISSPRITECHUNKBITS) #define VISSPRITEINDEXMASK (VISSPRITESPERCHUNK - 1) ->>>>>>> srb2/next typedef enum { // actual cuts @@ -164,20 +112,12 @@ typedef enum SC_BOTTOM = 1<<1, // other flags SC_PRECIP = 1<<2, -<<<<<<< HEAD - //SC_LINKDRAW = 1<<3, -- 2.2 compat + SC_LINKDRAW = 1<<3, SC_FULLBRIGHT = 1<<4, SC_SEMIBRIGHT = 1<<5, SC_VFLIP = 1<<6, SC_ISSCALED = 1<<7, SC_SHADOW = 1<<8, -======= - SC_LINKDRAW = 1<<3, - SC_FULLBRIGHT = 1<<4, - SC_VFLIP = 1<<5, - SC_ISSCALED = 1<<6, - SC_SHADOW = 1<<7, ->>>>>>> srb2/next // masks SC_CUTMASK = SC_TOP|SC_BOTTOM, SC_FLAGMASK = ~SC_CUTMASK @@ -203,13 +143,8 @@ typedef struct vissprite_s fixed_t pz, pzt; // physical bottom/top for sorting with 3D floors fixed_t startfrac; // horizontal position of x1 -<<<<<<< HEAD - fixed_t scale, sortscale; // sortscale only differs from scale for flat sprites - fixed_t scalestep; // only for flat sprites, 0 otherwise -======= fixed_t scale, sortscale; // sortscale only differs from scale for paper sprites and MF2_LINKDRAW fixed_t scalestep; // only for paper sprites, 0 otherwise ->>>>>>> srb2/next fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle fixed_t xiscale; // negative if flipped @@ -268,21 +203,6 @@ typedef struct drawnode_s struct drawnode_s *prev; } drawnode_t; -<<<<<<< HEAD -extern INT32 numskins; -extern skin_t skins[MAXSKINS]; - -boolean SetPlayerSkin(INT32 playernum,const char *skinname); -void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 -INT32 R_SkinAvailable(const char *name); -void R_AddSkins(UINT16 wadnum); - -#ifdef DELFILE -void R_DelSkins(UINT16 wadnum); -#endif - -======= ->>>>>>> srb2/next void R_InitDrawNodes(void); // -----------------------