Merge branch 'sky-improvements' into 'master'

Sky improvements

See merge request KartKrew/Kart!174
This commit is contained in:
Sal 2019-09-27 03:06:51 -04:00
commit 39115db560
14 changed files with 48 additions and 43 deletions

View file

@ -1230,8 +1230,9 @@ static void readlevelheader(MYFILE *f, INT32 num)
} }
else if (fastcmp(word, "WEATHER")) else if (fastcmp(word, "WEATHER"))
mapheaderinfo[num-1]->weather = (UINT8)get_number(word2); mapheaderinfo[num-1]->weather = (UINT8)get_number(word2);
else if (fastcmp(word, "SKYNUM")) else if (fastcmp(word, "SKYTEXTURE"))
mapheaderinfo[num-1]->skynum = (INT16)i; deh_strlcpy(mapheaderinfo[num-1]->skytexture, word2,
sizeof(mapheaderinfo[num-1]->skytexture), va("Level header %d: sky texture", num));
else if (fastcmp(word, "INTERSCREEN")) else if (fastcmp(word, "INTERSCREEN"))
strncpy(mapheaderinfo[num-1]->interscreen, word2, 8); strncpy(mapheaderinfo[num-1]->interscreen, word2, 8);
else if (fastcmp(word, "PRECUTSCENENUM")) else if (fastcmp(word, "PRECUTSCENENUM"))
@ -9926,11 +9927,11 @@ static inline int lib_getenum(lua_State *L)
} else if (fastcmp(word,"globalweather")) { } else if (fastcmp(word,"globalweather")) {
lua_pushinteger(L, globalweather); lua_pushinteger(L, globalweather);
return 1; return 1;
} else if (fastcmp(word,"levelskynum")) { } else if (fastcmp(word,"levelskytexture")) {
lua_pushinteger(L, levelskynum); lua_pushstring(L, levelskytexture);
return 1; return 1;
} else if (fastcmp(word,"globallevelskynum")) { } else if (fastcmp(word,"globallevelskytexture")) {
lua_pushinteger(L, globallevelskynum); lua_pushstring(L, globallevelskytexture);
return 1; return 1;
} else if (fastcmp(word,"mapmusname")) { } else if (fastcmp(word,"mapmusname")) {
lua_pushstring(L, mapmusname); lua_pushstring(L, mapmusname);

View file

@ -227,7 +227,7 @@ typedef struct
UINT32 muspos; ///< Music position to jump to. UINT32 muspos; ///< Music position to jump to.
char forcecharacter[17]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable. char forcecharacter[17]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable.
UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave. UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave.
INT16 skynum; ///< Sky number to use. char skytexture[9]; ///< Sky texture to use.
INT16 skybox_scalex; ///< Skybox X axis scale. (0 = no movement, 1 = 1:1 movement, 16 = 16:1 slow movement, -4 = 1:4 fast movement, etc.) INT16 skybox_scalex; ///< Skybox X axis scale. (0 = no movement, 1 = 1:1 movement, 16 = 16:1 slow movement, -4 = 1:4 fast movement, etc.)
INT16 skybox_scaley; ///< Skybox Y axis scale. INT16 skybox_scaley; ///< Skybox Y axis scale.
INT16 skybox_scalez; ///< Skybox Z axis scale. INT16 skybox_scalez; ///< Skybox Z axis scale.

View file

@ -5922,11 +5922,13 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
static void HWR_DrawSkyBackground(void) static void HWR_DrawSkyBackground(void)
{ {
FOutVector v[4]; FOutVector v[4];
texture_t *tex;
angle_t angle; angle_t angle;
float dimensionmultiply; float dimensionmultiply;
float aspectratio; float aspectratio;
float angleturn; float angleturn;
tex = textures[texturetranslation[skytexture]];
HWR_GetTexture(texturetranslation[skytexture]); HWR_GetTexture(texturetranslation[skytexture]);
aspectratio = (float)vid.width / (float)vid.height; aspectratio = (float)vid.width / (float)vid.height;
@ -5952,22 +5954,22 @@ static void HWR_DrawSkyBackground(void)
// software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly // software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly
// The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture
angle = (dup_viewangle + gr_xtoviewangle[0]); angle = -(dup_viewangle + gr_xtoviewangle[0]);
dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f); dimensionmultiply = ((float)tex->width/256.0f);
if (atransform.mirror) if (atransform.mirror)
{ {
angle = InvAngle(angle); angle = InvAngle(angle);
dimensionmultiply *= -1; dimensionmultiply = -dimensionmultiply;
} }
v[0].sow = v[3].sow = ((float) angle / ((ANGLE_90-1)*dimensionmultiply)); v[0].sow = v[3].sow = ((float) angle / ((ANGLE_90-1)*dimensionmultiply));
v[2].sow = v[1].sow = (-1.0f/dimensionmultiply)+((float) angle / ((ANGLE_90-1)*dimensionmultiply)); v[2].sow = v[1].sow = (1.0f/dimensionmultiply)+((float) angle / ((ANGLE_90-1)*dimensionmultiply));
// Y // Y
angle = aimingangle; angle = aimingangle;
dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->height/(128.0f*aspectratio)); dimensionmultiply = ((float)tex->height/(128.0f*aspectratio));
if (splitscreen == 1) if (splitscreen == 1)
{ {

View file

@ -1405,15 +1405,15 @@ static int lib_pIsFlagAtBase(lua_State *L)
static int lib_pSetupLevelSky(lua_State *L) static int lib_pSetupLevelSky(lua_State *L)
{ {
INT32 skynum = (INT32)luaL_checkinteger(L, 1); const char *skytexname = luaL_checkstring(L, 1);
player_t *user = NULL; player_t *user = NULL;
NOHUD NOHUD
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) // if a player, setup sky for only the player, otherwise setup sky for all players if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) // if a player, setup sky for only the player, otherwise setup sky for all players
user = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); user = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
if (!user) // global if (!user) // global
P_SetupLevelSky(skynum, true); P_SetupLevelSky(skytexname, true);
else if (P_IsLocalPlayer(user)) else if (P_IsLocalPlayer(user))
P_SetupLevelSky(skynum, false); P_SetupLevelSky(skytexname, false);
return 0; return 0;
} }

View file

@ -1487,8 +1487,8 @@ static int mapheaderinfo_get(lua_State *L)
lua_pushstring(L, header->forcecharacter); lua_pushstring(L, header->forcecharacter);
else if (fastcmp(field,"weather")) else if (fastcmp(field,"weather"))
lua_pushinteger(L, header->weather); lua_pushinteger(L, header->weather);
else if (fastcmp(field,"skynum")) else if (fastcmp(field,"skytexture"))
lua_pushinteger(L, header->skynum); lua_pushstring(L, header->skytexture);
else if (fastcmp(field,"skybox_scalex")) else if (fastcmp(field,"skybox_scalex"))
lua_pushinteger(L, header->skybox_scalex); lua_pushinteger(L, header->skybox_scalex);
else if (fastcmp(field,"skybox_scaley")) else if (fastcmp(field,"skybox_scaley"))

View file

@ -577,14 +577,14 @@ void Command_Skynum_f(void)
if (COM_Argc() != 2) if (COM_Argc() != 2)
{ {
CONS_Printf(M_GetText("skynum <sky#>: change the sky\n")); CONS_Printf(M_GetText("skynum <texture name>: change the sky\n"));
CONS_Printf(M_GetText("Current sky is %d\n"), levelskynum); CONS_Printf(M_GetText("Current sky is %s\n"), levelskytexture);
return; return;
} }
CONS_Printf(M_GetText("Previewing sky %s...\n"), COM_Argv(1)); CONS_Printf(M_GetText("Previewing sky %s...\n"), COM_Argv(1));
P_SetupLevelSky(atoi(COM_Argv(1)), false); P_SetupLevelSky(COM_Argv(1), false);
} }
void Command_Weather_f(void) void Command_Weather_f(void)

View file

@ -3096,7 +3096,7 @@ static inline void P_NetArchiveSpecials(void)
WRITEUINT32(save_p, 0xffffffff); WRITEUINT32(save_p, 0xffffffff);
// Sky number // Sky number
WRITEINT32(save_p, globallevelskynum); WRITESTRINGN(save_p, globallevelskytexture, 9);
// Current global weather type // Current global weather type
WRITEUINT8(save_p, globalweather); WRITEUINT8(save_p, globalweather);
@ -3115,8 +3115,8 @@ static inline void P_NetArchiveSpecials(void)
// //
static void P_NetUnArchiveSpecials(void) static void P_NetUnArchiveSpecials(void)
{ {
char skytex[9];
size_t i; size_t i;
INT32 j;
if (READUINT32(save_p) != ARCHIVEBLOCK_SPECIALS) if (READUINT32(save_p) != ARCHIVEBLOCK_SPECIALS)
I_Error("Bad $$$.sav at archive block Specials"); I_Error("Bad $$$.sav at archive block Specials");
@ -3129,9 +3129,9 @@ static void P_NetUnArchiveSpecials(void)
itemrespawntime[iquehead++] = READINT32(save_p); itemrespawntime[iquehead++] = READINT32(save_p);
} }
j = READINT32(save_p); READSTRINGN(save_p, skytex, sizeof(skytex));
if (j != globallevelskynum) if (strcmp(skytex, globallevelskytexture))
P_SetupLevelSky(j, true); P_SetupLevelSky(skytex, true);
globalweather = READUINT8(save_p); globalweather = READUINT8(save_p);

View file

@ -207,8 +207,9 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
mapheaderinfo[num]->forcecharacter[0] = '\0'; mapheaderinfo[num]->forcecharacter[0] = '\0';
DEH_WriteUndoline("WEATHER", va("%d", mapheaderinfo[num]->weather), UNDO_NONE); DEH_WriteUndoline("WEATHER", va("%d", mapheaderinfo[num]->weather), UNDO_NONE);
mapheaderinfo[num]->weather = 0; mapheaderinfo[num]->weather = 0;
DEH_WriteUndoline("SKYNUM", va("%d", mapheaderinfo[num]->skynum), UNDO_NONE); DEH_WriteUndoline("SKYTEXTURE", va("%d", mapheaderinfo[num]->skytexture), UNDO_NONE);
mapheaderinfo[num]->skynum = 1; snprintf(mapheaderinfo[num]->skytexture, 9, "SKY1");
mapheaderinfo[num]->skytexture[8] = 0;
DEH_WriteUndoline("SKYBOXSCALEX", va("%d", mapheaderinfo[num]->skybox_scalex), UNDO_NONE); DEH_WriteUndoline("SKYBOXSCALEX", va("%d", mapheaderinfo[num]->skybox_scalex), UNDO_NONE);
mapheaderinfo[num]->skybox_scalex = 16; mapheaderinfo[num]->skybox_scalex = 16;
DEH_WriteUndoline("SKYBOXSCALEY", va("%d", mapheaderinfo[num]->skybox_scaley), UNDO_NONE); DEH_WriteUndoline("SKYBOXSCALEY", va("%d", mapheaderinfo[num]->skybox_scaley), UNDO_NONE);
@ -2255,17 +2256,18 @@ static inline boolean P_CheckLevel(lumpnum_t lumpnum)
/** Sets up a sky texture to use for the level. /** Sets up a sky texture to use for the level.
* The sky texture is used instead of F_SKY1. * The sky texture is used instead of F_SKY1.
*/ */
void P_SetupLevelSky(INT32 skynum, boolean global) void P_SetupLevelSky(const char *skytexname, boolean global)
{ {
char skytexname[12]; char tex[9];
strncpy(tex, skytexname, 9);
tex[8] = 0;
sprintf(skytexname, "SKY%d", skynum); skytexture = R_TextureNumForName(tex);
skytexture = R_TextureNumForName(skytexname); strncpy(levelskytexture, tex, 9);
levelskynum = skynum;
// Global change // Global change
if (global) if (global)
globallevelskynum = levelskynum; strncpy(globallevelskytexture, tex, 9);
// Don't go beyond for dedicated servers // Don't go beyond for dedicated servers
if (dedicated) if (dedicated)
@ -2973,7 +2975,7 @@ boolean P_SetupLevel(boolean skipprecip)
CON_SetupBackColormap(); CON_SetupBackColormap();
// SRB2 determines the sky texture to be used depending on the map header. // SRB2 determines the sky texture to be used depending on the map header.
P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); P_SetupLevelSky(mapheaderinfo[gamemap-1]->skytexture, true);
P_MakeMapMD5(lastloadedmaplumpnum, &mapmd5); P_MakeMapMD5(lastloadedmaplumpnum, &mapmd5);

View file

@ -54,7 +54,7 @@ INT32 P_CheckLevelFlat(const char *flatname);
extern size_t nummapthings; extern size_t nummapthings;
extern mapthing_t *mapthings; extern mapthing_t *mapthings;
void P_SetupLevelSky(INT32 skynum, boolean global); void P_SetupLevelSky(const char *skytexname, boolean global);
#ifdef SCANTHINGS #ifdef SCANTHINGS
void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum);
#endif #endif

View file

@ -2802,7 +2802,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 423: // Change Sky case 423: // Change Sky
if ((mo && mo->player && P_IsLocalPlayer(mo->player)) || (line->flags & ML_NOCLIMB)) if ((mo && mo->player && P_IsLocalPlayer(mo->player)) || (line->flags & ML_NOCLIMB))
P_SetupLevelSky(sides[line->sidenum[0]].textureoffset>>FRACBITS, (line->flags & ML_NOCLIMB)); P_SetupLevelSky(sides[line->sidenum[0]].text, (line->flags & ML_NOCLIMB));
break; break;
case 424: // Change Weather case 424: // Change Weather

View file

@ -1631,7 +1631,7 @@ void R_PrecacheLevel(void)
// Sky texture is always present. // Sky texture is always present.
// Note that F_SKY1 is the name used to indicate a sky floor/ceiling as a flat, // Note that F_SKY1 is the name used to indicate a sky floor/ceiling as a flat,
// while the sky texture is stored like a wall texture, with a skynum dependent name. // while the sky texture is stored like a wall texture, with a texture name set by the map.
texturepresent[skytexture] = 1; texturepresent[skytexture] = 1;
texturememory = 0; texturememory = 0;

View file

@ -734,7 +734,7 @@ void R_DrawPlanes(void)
dc_x = x; dc_x = x;
dc_source = dc_source =
R_GetColumn(texturetranslation[skytexture], R_GetColumn(texturetranslation[skytexture],
angle); -angle); // Negative because skies were being drawn horizontally flipped
wallcolfunc(); wallcolfunc();
} }
} }

View file

@ -47,8 +47,8 @@ fixed_t skyscale;
/** \brief used for keeping track of the current sky /** \brief used for keeping track of the current sky
*/ */
INT32 levelskynum; char levelskytexture[9];
INT32 globallevelskynum; char globallevelskytexture[9];
/** \brief The R_SetupSkyDraw function /** \brief The R_SetupSkyDraw function

View file

@ -30,8 +30,8 @@ extern INT32 skytexture, skytexturemid;
extern fixed_t skyscale; extern fixed_t skyscale;
extern INT32 skyflatnum; extern INT32 skyflatnum;
extern INT32 levelskynum; extern char levelskytexture[9];
extern INT32 globallevelskynum; extern char globallevelskytexture[9];
// call after skytexture is set to adapt for old/new skies // call after skytexture is set to adapt for old/new skies
void R_SetupSkyDraw(void); void R_SetupSkyDraw(void);