Merge branch 'next' into raise-skin-limit

This commit is contained in:
Lactozilla 2023-11-30 18:58:24 -03:00
commit 1122373304
32 changed files with 702 additions and 259 deletions

View file

@ -99,6 +99,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
lua_blockmaplib.c
lua_hudlib.c
lua_hudlib_drawlist.c
lua_colorlib.c
lua_inputlib.c
)

View file

@ -94,3 +94,4 @@ lua_blockmaplib.c
lua_hudlib.c
lua_hudlib_drawlist.c
lua_inputlib.c
lua_colorlib.c

View file

@ -51,9 +51,11 @@ static void COM_CEchoDuration_f(void);
static void COM_Exec_f(void);
static void COM_Wait_f(void);
static void COM_Help_f(void);
static void COM_Find_f(void);
static void COM_Toggle_f(void);
static void COM_Add_f(void);
static void CV_EnforceExecVersion(void);
static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr);
static boolean CV_Command(void);
@ -344,6 +346,7 @@ void COM_Init(void)
COM_AddCommand("exec", COM_Exec_f, 0);
COM_AddCommand("wait", COM_Wait_f, 0);
COM_AddCommand("help", COM_Help_f, COM_LUA);
COM_AddCommand("find", COM_Find_f, COM_LUA);
COM_AddCommand("toggle", COM_Toggle_f, COM_LUA);
COM_AddCommand("add", COM_Add_f, COM_LUA);
RegisterNetXCmd(XD_NETVAR, Got_NetVar);
@ -879,7 +882,7 @@ static void COM_Help_f(void)
boolean floatmode = false;
const char *cvalue = NULL;
CONS_Printf("\x82""Variable %s:\n", cvar->name);
CONS_Printf(M_GetText(" flags :"));
CONS_Printf(M_GetText(" flags: "));
if (cvar->flags & CV_SAVE)
CONS_Printf("AUTOSAVE ");
if (cvar->flags & CV_FLOAT)
@ -976,31 +979,8 @@ static void COM_Help_f(void)
return;
}
CONS_Printf("No exact match, searching...\n");
// variables
CONS_Printf("\x82""Variables:\n");
for (cvar = consvar_vars; cvar; cvar = cvar->next)
{
if ((cvar->flags & CV_NOSHOWHELP) || (!strstr(cvar->name, help)))
continue;
CONS_Printf("%s ", cvar->name);
i++;
}
// commands
CONS_Printf("\x82""\nCommands:\n");
for (cmd = com_commands; cmd; cmd = cmd->next)
{
if (!strstr(cmd->name, help))
continue;
CONS_Printf("%s ",cmd->name);
i++;
}
CONS_Printf("\x82""\nCheck wiki.srb2.org for more or type help <command or variable>\n");
CONS_Debug(DBG_GAMELOGIC, "\x87Total : %d\n", i);
CONS_Printf("No variable or command named %s", help);
CONS_Printf("\x82""\nCheck wiki.srb2.org for more or try typing help without arguments\n");
}
return;
}
@ -1030,6 +1010,76 @@ static void COM_Help_f(void)
}
}
static void COM_Find_f(void)
{
static char prefix[80];
xcommand_t *cmd;
consvar_t *cvar;
cmdalias_t *alias;
const char *match;
const char *help;
size_t helplen;
boolean matchesany;
if (COM_Argc() != 2)
{
CONS_Printf(M_GetText("find <text>: Search for variables, commands and aliases containing <text>\n"));
return;
}
help = COM_Argv(1);
helplen = strlen(help);
CONS_Printf("\x82""Variables:\n");
matchesany = false;
for (cvar = consvar_vars; cvar; cvar = cvar->next)
{
if (cvar->flags & CV_NOSHOWHELP)
continue;
match = strstr(cvar->name, help);
if (match != NULL)
{
memcpy(prefix, cvar->name, match - cvar->name);
prefix[match - cvar->name] = '\0';
CONS_Printf(" %s\x83%s\x80%s\n", prefix, help, &match[helplen]);
matchesany = true;
}
}
if (!matchesany)
CONS_Printf(" (none)\n");
CONS_Printf("\x82""Commands:\n");
matchesany = false;
for (cmd = com_commands; cmd; cmd = cmd->next)
{
match = strstr(cmd->name, help);
if (match != NULL)
{
memcpy(prefix, cmd->name, match - cmd->name);
prefix[match - cmd->name] = '\0';
CONS_Printf(" %s\x83%s\x80%s\n", prefix, help, &match[helplen]);
matchesany = true;
}
}
if (!matchesany)
CONS_Printf(" (none)\n");
CONS_Printf("\x82""Aliases:\n");
matchesany = false;
for (alias = com_alias; alias; alias = alias->next)
{
match = strstr(alias->name, help);
if (match != NULL)
{
memcpy(prefix, alias->name, match - alias->name);
prefix[match - alias->name] = '\0';
CONS_Printf(" %s\x83%s\x80%s\n", prefix, help, &match[helplen]);
matchesany = true;
}
}
if (!matchesany)
CONS_Printf(" (none)\n");
}
/** Toggles a console variable. Useful for on/off values.
*
* This works on on/off, yes/no values only

View file

@ -921,7 +921,8 @@ boolean CON_Responder(event_t *ev)
static UINT8 consdown = false; // console is treated differently due to rare usage
// sequential completions a la 4dos
static char completion[80];
static char completioncmd[80 + sizeof("find ")] = "find ";
static char *completion = &completioncmd[sizeof("find ")-1];
static INT32 skips;
@ -1057,36 +1058,14 @@ boolean CON_Responder(event_t *ev)
// show all cvars/commands that match what we have inputted
if (key == KEY_TAB)
{
size_t i, len;
if (!completion[0])
{
if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
return true;
strcpy(completion, inputlines[inputline]);
}
len = strlen(completion);
//first check commands
CONS_Printf("\nCommands:\n");
for (i = 0, cmd = COM_CompleteCommand(completion, i); cmd; cmd = COM_CompleteCommand(completion, ++i))
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
//now we move on to CVARs
CONS_Printf("Variables:\n");
for (i = 0, cmd = CV_CompleteVar(completion, i); cmd; cmd = CV_CompleteVar(completion, ++i))
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
//and finally aliases
CONS_Printf("Aliases:\n");
for (i = 0, cmd = COM_CompleteAlias(completion, i); cmd; cmd = COM_CompleteAlias(completion, ++i))
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
COM_BufInsertText(completioncmd);
completion[0] = 0;
return true;
}
// ---

View file

@ -164,7 +164,7 @@ void I_SetMusicVolume(UINT8 volume)
(void)volume;
}
boolean I_SetSongTrack(int track)
boolean I_SetSongTrack(INT32 track)
{
(void)track;
return false;

View file

@ -276,9 +276,6 @@ struct FSurfaceInfo
};
typedef struct FSurfaceInfo FSurfaceInfo;
#define GL_DEFAULTMIX 0x00000000
#define GL_DEFAULTFOG 0xFF000000
//Hurdler: added for backward compatibility
enum hwdsetspecialstate
{

View file

@ -169,7 +169,6 @@ ps_metric_t ps_hw_batchdrawtime = {0};
boolean gl_init = false;
boolean gl_maploaded = false;
boolean gl_sessioncommandsadded = false;
boolean gl_shadersavailable = true;
// ==========================================================================
@ -186,8 +185,8 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
RGBA_t poly_color, tint_color, fade_color;
poly_color.rgba = 0xFFFFFFFF;
tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GL_DEFAULTMIX;
fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG;
tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : 0x00000000;
fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : 0xFF000000;
// Crappy backup coloring if you can't do shaders
if (!HWR_UseShader())
@ -201,7 +200,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
blue = (float)poly_color.s.blue;
// 48 is just an arbritrary value that looked relatively okay.
tint_alpha = (float)(sqrt(tint_color.s.alpha) * 48) / 255.0f;
tint_alpha = (float)(sqrt((float)tint_color.s.alpha / 10.2) * 48) / 255.0f;
// 8 is roughly the brightness of the "close" color in Software, and 16 the brightness of the "far" color.
// 8 is too bright for dark levels, and 16 is too dark for bright levels.
@ -244,7 +243,7 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if
RGBA_t realcolor, surfcolor;
INT32 alpha;
realcolor.rgba = (colormap != NULL) ? colormap->rgba : GL_DEFAULTMIX;
realcolor.rgba = (colormap != NULL) ? colormap->rgba : 0x00000000;
if (cv_glshaders.value && gl_shadersavailable)
{
@ -6659,7 +6658,7 @@ consvar_t cv_glfakecontrast = CVAR_INIT ("gr_fakecontrast", "Smooth", CV_SAVE, g
consvar_t cv_glslopecontrast = CVAR_INIT ("gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glfiltermode = CVAR_INIT ("gr_filtermode", "Nearest", CV_SAVE|CV_CALL, glfiltermode_cons_t, CV_glfiltermode_OnChange);
consvar_t cv_glanisotropicmode = CVAR_INIT ("gr_anisotropicmode", "1", CV_CALL, glanisotropicmode_cons_t, CV_glanisotropic_OnChange);
consvar_t cv_glanisotropicmode = CVAR_INIT ("gr_anisotropicmode", "1", CV_SAVE|CV_CALL, glanisotropicmode_cons_t, CV_glanisotropic_OnChange);
consvar_t cv_glsolvetjoin = CVAR_INIT ("gr_solvetjoin", "On", 0, CV_OnOff, NULL);
@ -6701,6 +6700,7 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_glallowshaders);
CV_RegisterVar(&cv_glfiltermode);
CV_RegisterVar(&cv_glanisotropicmode);
CV_RegisterVar(&cv_glsolvetjoin);
CV_RegisterVar(&cv_glbatching);
@ -6710,14 +6710,6 @@ void HWR_AddCommands(void)
#endif
}
void HWR_AddSessionCommands(void)
{
if (gl_sessioncommandsadded)
return;
CV_RegisterVar(&cv_glanisotropicmode);
gl_sessioncommandsadded = true;
}
// --------------------------------------------------------------------------
// Setup the hardware renderer
// --------------------------------------------------------------------------
@ -6728,7 +6720,6 @@ void HWR_Startup(void)
CONS_Printf("HWR_Startup()...\n");
HWR_InitPolyPool();
HWR_AddSessionCommands();
HWR_InitMapTextures();
HWR_InitModels();
#ifdef ALAM_LIGHTING
@ -6751,10 +6742,6 @@ void HWR_Startup(void)
// --------------------------------------------------------------------------
void HWR_Switch(void)
{
// Add session commands
if (!gl_sessioncommandsadded)
HWR_AddSessionCommands();
// Set special states from CVARs
HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value);
HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value);

View file

@ -54,7 +54,6 @@ UINT8 *HWR_GetScreenshot(void);
boolean HWR_Screenshot(const char *pathname);
void HWR_AddCommands(void);
void HWR_AddSessionCommands(void);
void transform(float *cx, float *cy, float *cz);
INT32 HWR_GetTextureUsed(void);
void HWR_DoPostProcessor(player_t *player);

View file

@ -1050,9 +1050,6 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED);
}
#define NORMALFOG 0x00000000
#define FADEFOG 0x19000000
static boolean HWR_AllowModel(mobj_t *mobj)
{
// Signpost overlay. Not needed.

View file

@ -697,7 +697,7 @@ static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f};
#define GLSL_SOFTWARE_TINT_EQUATION \
"if (tint_color.a > 0.0) {\n" \
"float color_bright = sqrt((base_color.r * base_color.r) + (base_color.g * base_color.g) + (base_color.b * base_color.b));\n" \
"float strength = sqrt(9.0 * tint_color.a);\n" \
"float strength = sqrt(tint_color.a);\n" \
"final_color.r = clamp((color_bright * (tint_color.r * strength)) + (base_color.r * (1.0 - strength)), 0.0, 1.0);\n" \
"final_color.g = clamp((color_bright * (tint_color.g * strength)) + (base_color.g * (1.0 - strength)), 0.0, 1.0);\n" \
"final_color.b = clamp((color_bright * (tint_color.b * strength)) + (base_color.b * (1.0 - strength)), 0.0, 1.0);\n" \

View file

@ -213,6 +213,8 @@ static const struct {
{META_HUDINFO, "hudinfo_t"},
{META_PATCH, "patch_t"},
{META_COLORMAP, "colormap"},
{META_EXTRACOLORMAP,"extracolormap_t"},
{META_LIGHTTABLE, "lighttable_t"},
{META_CAMERA, "camera_t"},
{META_ACTION, "action"},
@ -2022,6 +2024,30 @@ static int lib_pCeilingzAtPos(lua_State *L)
return 1;
}
static int lib_pGetSectorColormapAt(lua_State *L)
{
boolean has_sector = false;
sector_t *sector = NULL;
if (!lua_isnoneornil(L, 1))
{
has_sector = true;
sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
}
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = luaL_checkfixed(L, 4);
INLEVEL
if (has_sector && !sector)
return LUA_ErrInvalid(L, "sector_t");
extracolormap_t *exc;
if (sector)
exc = P_GetColormapFromSectorAt(sector, x, y, z);
else
exc = P_GetSectorColormapAt(x, y, z);
LUA_PushUserdata(L, exc, META_EXTRACOLORMAP);
return 1;
}
static int lib_pDoSpring(lua_State *L)
{
mobj_t *spring = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -4304,6 +4330,7 @@ static luaL_Reg lib[] = {
{"P_RadiusAttack",lib_pRadiusAttack},
{"P_FloorzAtPos",lib_pFloorzAtPos},
{"P_CeilingzAtPos",lib_pCeilingzAtPos},
{"P_GetSectorColormapAt",lib_pGetSectorColormapAt},
{"P_DoSpring",lib_pDoSpring},
{"P_TouchSpecialThing",lib_pTouchSpecialThing},
{"P_TryCameraMove", lib_pTryCameraMove},

332
src/lua_colorlib.c Normal file
View file

@ -0,0 +1,332 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2021-2022 by "Lactozilla".
// Copyright (C) 2014-2023 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file lua_colorlib.c
/// \brief color and colormap libraries for Lua scripting
#include "doomdef.h"
#include "fastcmp.h"
#include "r_data.h"
#include "lua_script.h"
#include "lua_libs.h"
#define IS_HEX_CHAR(x) ((x >= '0' && x <= '9') || (x >= 'a' && x <= 'f') || (x >= 'A' && x <= 'F'))
#define ARE_HEX_CHARS(str, i) IS_HEX_CHAR(str[i]) && IS_HEX_CHAR(str[i + 1])
static UINT32 hex2int(char x)
{
if (x >= '0' && x <= '9')
return x - '0';
else if (x >= 'a' && x <= 'f')
return x - 'a' + 10;
else if (x >= 'A' && x <= 'F')
return x - 'A' + 10;
return 0;
}
static UINT8 ParseHTMLColor(const char *str, UINT8 *rgba, size_t numc)
{
const char *hex = str;
if (hex[0] == '#')
hex++;
else if (!IS_HEX_CHAR(hex[0]))
return 0;
size_t len = strlen(hex);
if (len == 3)
{
// Shorthand like #09C
for (unsigned i = 0; i < 3; i++)
{
if (!IS_HEX_CHAR(hex[i]))
return 0;
UINT32 hx = hex2int(hex[i]);
*rgba++ = (hx * 16) + hx;
}
return 3;
}
else if (len == 6 || len == 8)
{
if (numc != 4)
len = 6;
// A triplet like #0099CC
for (unsigned i = 0; i < len; i += 2)
{
if (!ARE_HEX_CHARS(hex, i))
return false;
*rgba++ = (hex2int(hex[i]) * 16) + hex2int(hex[i + 1]);
}
return len;
}
return 0;
}
/////////////////////////
// extracolormap userdata
/////////////////////////
enum extracolormap_e {
extracolormap_red = 0,
extracolormap_green,
extracolormap_blue,
extracolormap_alpha,
extracolormap_color,
extracolormap_fade_red,
extracolormap_fade_green,
extracolormap_fade_blue,
extracolormap_fade_alpha,
extracolormap_fade_color,
extracolormap_fade_start,
extracolormap_fade_end,
extracolormap_colormap
};
static const char *const extracolormap_opt[] = {
"red",
"green",
"blue",
"alpha",
"color",
"fade_red",
"fade_green",
"fade_blue",
"fade_alpha",
"fade_color",
"fade_start",
"fade_end",
"colormap",
NULL};
static int extracolormap_get(lua_State *L)
{
extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP));
enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt);
switch (field)
{
case extracolormap_red:
lua_pushinteger(L, R_GetRgbaR(exc->rgba));
break;
case extracolormap_green:
lua_pushinteger(L, R_GetRgbaG(exc->rgba));
break;
case extracolormap_blue:
lua_pushinteger(L, R_GetRgbaB(exc->rgba));
break;
case extracolormap_alpha:
lua_pushinteger(L, R_GetRgbaA(exc->rgba));
break;
case extracolormap_color:
lua_pushinteger(L, R_GetRgbaR(exc->rgba));
lua_pushinteger(L, R_GetRgbaG(exc->rgba));
lua_pushinteger(L, R_GetRgbaB(exc->rgba));
lua_pushinteger(L, R_GetRgbaA(exc->rgba));
return 4;
case extracolormap_fade_red:
lua_pushinteger(L, R_GetRgbaR(exc->fadergba));
break;
case extracolormap_fade_green:
lua_pushinteger(L, R_GetRgbaG(exc->fadergba));
break;
case extracolormap_fade_blue:
lua_pushinteger(L, R_GetRgbaB(exc->fadergba));
break;
case extracolormap_fade_alpha:
lua_pushinteger(L, R_GetRgbaA(exc->fadergba));
break;
case extracolormap_fade_color:
lua_pushinteger(L, R_GetRgbaR(exc->fadergba));
lua_pushinteger(L, R_GetRgbaG(exc->fadergba));
lua_pushinteger(L, R_GetRgbaB(exc->fadergba));
lua_pushinteger(L, R_GetRgbaA(exc->fadergba));
return 4;
case extracolormap_fade_start:
lua_pushinteger(L, exc->fadestart);
break;
case extracolormap_fade_end:
lua_pushinteger(L, exc->fadeend);
break;
case extracolormap_colormap:
LUA_PushUserdata(L, exc->colormap, META_LIGHTTABLE);
break;
}
return 1;
}
static void GetExtraColormapRGBA(lua_State *L, UINT8 *rgba, int arg)
{
if (lua_type(L, arg) == LUA_TSTRING)
{
const char *str = lua_tostring(L, arg);
UINT8 parsed = ParseHTMLColor(str, rgba, 4);
if (!parsed)
luaL_error(L, "Malformed HTML color '%s'", str);
}
else
{
UINT32 colors = lua_tointeger(L, arg);
if (colors > 0xFFFFFF)
{
rgba[0] = (colors >> 24) & 0xFF;
rgba[1] = (colors >> 16) & 0xFF;
rgba[2] = (colors >> 8) & 0xFF;
rgba[3] = colors & 0xFF;
}
else
{
rgba[0] = (colors >> 16) & 0xFF;
rgba[1] = (colors >> 8) & 0xFF;
rgba[2] = colors & 0xFF;
rgba[3] = 0xFF;
}
}
}
static int extracolormap_set(lua_State *L)
{
extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP));
enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt);
UINT8 r = R_GetRgbaR(exc->rgba);
UINT8 g = R_GetRgbaG(exc->rgba);
UINT8 b = R_GetRgbaB(exc->rgba);
UINT8 a = R_GetRgbaA(exc->rgba);
UINT8 fr = R_GetRgbaR(exc->fadergba);
UINT8 fg = R_GetRgbaG(exc->fadergba);
UINT8 fb = R_GetRgbaB(exc->fadergba);
UINT8 fa = R_GetRgbaA(exc->fadergba);
UINT8 rgba[4];
INT32 old_rgba = exc->rgba, old_fade_rgba = exc->fadergba; // It's not unsigned?
UINT8 old_fade_start = exc->fadestart, old_fade_end = exc->fadeend;
#define val luaL_checkinteger(L, 3)
switch(field)
{
case extracolormap_red:
exc->rgba = R_PutRgbaRGBA(val, g, b, a);
break;
case extracolormap_green:
exc->rgba = R_PutRgbaRGBA(r, val, b, a);
break;
case extracolormap_blue:
exc->rgba = R_PutRgbaRGBA(r, g, val, a);
break;
case extracolormap_alpha:
exc->rgba = R_PutRgbaRGBA(r, g, b, val);
break;
case extracolormap_color:
rgba[0] = r;
rgba[1] = g;
rgba[2] = b;
rgba[3] = a;
GetExtraColormapRGBA(L, rgba, 3);
exc->rgba = R_PutRgbaRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
break;
case extracolormap_fade_red:
exc->fadergba = R_PutRgbaRGBA(val, fg, fb, fa);
break;
case extracolormap_fade_green:
exc->fadergba = R_PutRgbaRGBA(fr, val, fb, fa);
break;
case extracolormap_fade_blue:
exc->fadergba = R_PutRgbaRGBA(fr, fg, val, fa);
break;
case extracolormap_fade_alpha:
exc->fadergba = R_PutRgbaRGBA(fr, fg, fb, val);
break;
case extracolormap_fade_color:
rgba[0] = fr;
rgba[1] = fg;
rgba[2] = fb;
rgba[3] = fa;
GetExtraColormapRGBA(L, rgba, 3);
exc->fadergba = R_PutRgbaRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
break;
case extracolormap_fade_start:
if (val > 31)
return luaL_error(L, "fade start %d out of range (0 - 31)", val);
exc->fadestart = val;
break;
case extracolormap_fade_end:
if (val > 31)
return luaL_error(L, "fade end %d out of range (0 - 31)", val);
exc->fadeend = val;
break;
case extracolormap_colormap:
return luaL_error(L, LUA_QL("extracolormap_t") " field " LUA_QS " should not be set directly.", extracolormap_opt[field]);
}
#undef val
if (exc->rgba != old_rgba
|| exc->fadergba != old_fade_rgba
|| exc->fadestart != old_fade_start
|| exc->fadeend != old_fade_end)
R_GenerateLightTable(exc, true);
return 0;
}
static int lighttable_get(lua_State *L)
{
void **userdata;
lighttable_t *table = *((lighttable_t **)luaL_checkudata(L, 1, META_LIGHTTABLE));
UINT32 row = luaL_checkinteger(L, 2);
if (row < 1 || row > 34)
return luaL_error(L, "lighttable row %d out of range (1 - %d)", row, 34);
userdata = lua_newuserdata(L, sizeof(void *));
*userdata = &table[256 * (row - 1)];
luaL_getmetatable(L, META_COLORMAP);
lua_setmetatable(L, -2);
return 1;
}
static int lighttable_len(lua_State *L)
{
lua_pushinteger(L, NUM_PALETTE_ENTRIES);
return 1;
}
int LUA_ColorLib(lua_State *L)
{
luaL_newmetatable(L, META_EXTRACOLORMAP);
lua_pushcfunction(L, extracolormap_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, extracolormap_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
luaL_newmetatable(L, META_LIGHTTABLE);
lua_pushcfunction(L, lighttable_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lighttable_len);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
return 0;
}

View file

@ -85,6 +85,8 @@ extern boolean ignoregameinputs;
#define META_HUDINFO "HUDINFO_T*"
#define META_PATCH "PATCH_T*"
#define META_COLORMAP "COLORMAP"
#define META_EXTRACOLORMAP "EXTRACOLORMAP_T*"
#define META_LIGHTTABLE "LIGHTTABLE_T*"
#define META_CAMERA "CAMERA_T*"
#define META_ACTION "ACTIONF_T*"
@ -112,4 +114,5 @@ int LUA_TagLib(lua_State *L);
int LUA_PolyObjLib(lua_State *L);
int LUA_BlockmapLib(lua_State *L);
int LUA_HudLib(lua_State *L);
int LUA_ColorLib(lua_State *L);
int LUA_InputLib(lua_State *L);

View file

@ -57,6 +57,7 @@ enum sector_e {
sector_ffloors,
sector_fslope,
sector_cslope,
sector_colormap,
sector_flags,
sector_specialflags,
sector_damagetype,
@ -95,6 +96,7 @@ static const char *const sector_opt[] = {
"ffloors",
"f_slope",
"c_slope",
"colormap",
"flags",
"specialflags",
"damagetype",
@ -751,6 +753,9 @@ static int sector_get(lua_State *L)
case sector_cslope: // c_slope
LUA_PushUserdata(L, sector->c_slope, META_SLOPE);
return 1;
case sector_colormap: // extra_colormap
LUA_PushUserdata(L, sector->extra_colormap, META_EXTRACOLORMAP);
return 1;
case sector_flags: // flags
lua_pushinteger(L, sector->flags);
return 1;
@ -1062,7 +1067,7 @@ static int line_get(lua_State *L)
LUA_PushUserdata(L, &sides[line->sidenum[0]], META_SIDE);
return 1;
case line_backside: // backside
if (line->sidenum[1] == 0xffff)
if (line->sidenum[1] == NO_SIDEDEF)
return 0;
LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE);
return 1;
@ -1235,6 +1240,9 @@ static int side_get(lua_State *L)
// TODO: 2.3: Delete
case side_text:
{
boolean isfrontside;
size_t sidei = side-sides;
if (udmf)
{
LUA_Deprecated(L, "(sidedef_t).text", "(sidedef_t).line.stringargs");
@ -1242,7 +1250,7 @@ static int side_get(lua_State *L)
return 1;
}
boolean isfrontside = side->line->sidenum[0] == side-sides;
isfrontside = side->line->sidenum[0] == sidei;
lua_pushstring(L, side->line->stringargs[isfrontside ? 0 : 1]);
return 1;

View file

@ -58,6 +58,7 @@ static lua_CFunction liblist[] = {
LUA_PolyObjLib, // polyobj_t
LUA_BlockmapLib, // blockmap stuff
LUA_HudLib, // HUD stuff
LUA_ColorLib, // general color functions
LUA_InputLib, // inputs
NULL
};

View file

@ -2805,3 +2805,17 @@ boolean M_IsStringEmpty(const char *s)
return true;
}
// Rounds off floating numbers and checks for 0 - 255 bounds
int M_RoundUp(double number)
{
if (number > 255.0l)
return 255;
if (number < 0.0l)
return 0;
if ((int)number <= (int)(number - 0.5f))
return (int)number + 1;
return (int)number;
}

View file

@ -112,6 +112,9 @@ boolean M_IsStringEmpty(const char *s);
// counting bits, for weapon ammo code, usually
FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size);
// Rounds off floating numbers and checks for 0 - 255 bounds
int M_RoundUp(double number);
#include "w_wad.h"
extern char configfile[MAX_WADPATH];

View file

@ -445,6 +445,10 @@ boolean PIT_PushableMoved(mobj_t *thing);
boolean P_DoSpring(mobj_t *spring, mobj_t *object);
INT32 P_GetSectorLightAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z);
extracolormap_t *P_GetColormapFromSectorAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z);
extracolormap_t *P_GetSectorColormapAt(fixed_t x, fixed_t y, fixed_t z);
//
// P_SETUP
//

View file

@ -3905,7 +3905,7 @@ retry:
P_PathTraverse(leadx, traily, leadx + mo->momx, traily + mo->momy,
PT_ADDLINES, PTR_SlideTraverse);
if (bestslideline && mo->player && bestslideline->sidenum[1] != 0xffff)
if (bestslideline && mo->player && bestslideline->sidenum[1] != NO_SIDEDEF)
{
sector_t *sec = P_PointOnLineSide(mo->x, mo->y, bestslideline) ? bestslideline->frontsector : bestslideline->backsector;
P_CheckLavaWall(mo, sec);
@ -5071,3 +5071,35 @@ fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
return ceilingz;
}
INT32 P_GetSectorLightAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z)
{
if (!sector->numlights)
return -1;
INT32 light = sector->numlights - 1;
// R_GetPlaneLight won't work on sloped lights!
for (INT32 lightnum = 1; lightnum < sector->numlights; lightnum++) {
fixed_t h = P_GetLightZAt(&sector->lightlist[lightnum], x, y);
if (h <= z) {
light = lightnum - 1;
break;
}
}
return light;
}
extracolormap_t *P_GetColormapFromSectorAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z)
{
if (sector->numlights)
return *sector->lightlist[P_GetSectorLightAt(sector, x, y, z)].extra_colormap;
else
return sector->extra_colormap;
}
extracolormap_t *P_GetSectorColormapAt(fixed_t x, fixed_t y, fixed_t z)
{
return P_GetColormapFromSectorAt(R_PointInSubsector(x, y)->sector, x, y, z);
}

View file

@ -290,7 +290,7 @@ void P_CameraLineOpening(line_t *linedef)
sector_t *back;
fixed_t frontfloor, frontceiling, backfloor, backceiling;
if (linedef->sidenum[1] == 0xffff)
if (linedef->sidenum[1] == NO_SIDEDEF)
{
// single sided line
openrange = 0;
@ -426,7 +426,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{
sector_t *front, *back;
if (linedef->sidenum[1] == 0xffff)
if (linedef->sidenum[1] == NO_SIDEDEF)
{
// single sided line
openrange = 0;

View file

@ -11206,6 +11206,10 @@ void P_RemoveMobj(mobj_t *mobj)
P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL));
// clear the reference from the mapthing
if (mobj->spawnpoint)
mobj->spawnpoint->mobj = NULL;
R_RemoveMobjInterpolator(mobj);
// free block

View file

@ -1079,7 +1079,7 @@ static void ArchiveSectors(void)
if (diff)
{
WRITEUINT16(save_p, i);
WRITEUINT32(save_p, i);
WRITEUINT8(save_p, diff);
if (diff & SD_DIFF2)
WRITEUINT8(save_p, diff2);
@ -1150,18 +1150,19 @@ static void ArchiveSectors(void)
}
}
WRITEUINT16(save_p, 0xffff);
WRITEUINT32(save_p, 0xffffffff);
}
static void UnArchiveSectors(void)
{
UINT16 i, j;
UINT32 i;
UINT16 j;
UINT8 diff, diff2, diff3, diff4;
for (;;)
{
i = READUINT16(save_p);
i = READUINT32(save_p);
if (i == 0xffff)
if (i == 0xffffffff)
break;
if (i > numsectors)
@ -1299,7 +1300,7 @@ static void ArchiveLines(void)
if (li->executordelay != spawnli->executordelay)
diff2 |= LD_EXECUTORDELAY;
if (li->sidenum[0] != 0xffff)
if (li->sidenum[0] != NO_SIDEDEF)
{
si = &sides[li->sidenum[0]];
spawnsi = &spawnsides[li->sidenum[0]];
@ -1313,7 +1314,7 @@ static void ArchiveLines(void)
if (si->midtexture != spawnsi->midtexture)
diff |= LD_S1MIDTEX;
}
if (li->sidenum[1] != 0xffff)
if (li->sidenum[1] != NO_SIDEDEF)
{
si = &sides[li->sidenum[1]];
spawnsi = &spawnsides[li->sidenum[1]];
@ -1332,7 +1333,7 @@ static void ArchiveLines(void)
if (diff)
{
WRITEINT16(save_p, i);
WRITEUINT32(save_p, i);
WRITEUINT8(save_p, diff);
if (diff & LD_DIFF2)
WRITEUINT8(save_p, diff2);
@ -1391,21 +1392,21 @@ static void ArchiveLines(void)
WRITEINT32(save_p, li->executordelay);
}
}
WRITEUINT16(save_p, 0xffff);
WRITEUINT32(save_p, 0xffffffff);
}
static void UnArchiveLines(void)
{
UINT16 i;
UINT32 i;
line_t *li;
side_t *si;
UINT8 diff, diff2; // no diff3
for (;;)
{
i = READUINT16(save_p);
i = READUINT32(save_p);
if (i == 0xffff)
if (i == 0xffffffff)
break;
if (i > numlines)
I_Error("Invalid line number %u from server", i);

View file

@ -1111,40 +1111,40 @@ static void P_InitializeLinedef(line_t *ld)
// cph 2006/09/30 - fix sidedef errors right away.
// cph 2002/07/20 - these errors are fatal if not fixed, so apply them
for (j = 0; j < 2; j++)
if (ld->sidenum[j] != 0xffff && ld->sidenum[j] >= (UINT16)numsides)
if (ld->sidenum[j] != NO_SIDEDEF && ld->sidenum[j] >= (UINT32)numsides)
{
ld->sidenum[j] = 0xffff;
ld->sidenum[j] = NO_SIDEDEF;
CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has out-of-range sidedef number\n", sizeu1((size_t)(ld - lines)));
}
// killough 11/98: fix common wad errors (missing sidedefs):
if (ld->sidenum[0] == 0xffff)
if (ld->sidenum[0] == NO_SIDEDEF)
{
ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side
// cph - print a warning about the bug
CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s missing first sidedef\n", sizeu1((size_t)(ld - lines)));
}
if ((ld->sidenum[1] == 0xffff) && (ld->flags & ML_TWOSIDED))
if ((ld->sidenum[1] == NO_SIDEDEF) && (ld->flags & ML_TWOSIDED))
{
ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side
// cph - print a warning about the bug
CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1((size_t)(ld - lines)));
}
if (ld->sidenum[0] != 0xffff)
if (ld->sidenum[0] != NO_SIDEDEF)
{
sides[ld->sidenum[0]].special = ld->special;
sides[ld->sidenum[0]].line = ld;
}
if (ld->sidenum[1] != 0xffff)
if (ld->sidenum[1] != NO_SIDEDEF)
{
sides[ld->sidenum[1]].special = ld->special;
sides[ld->sidenum[1]].line = ld;
}
}
static void P_SetLinedefV1(size_t i, UINT16 vertex_num)
static void P_SetLinedefV1(size_t i, UINT32 vertex_num)
{
if (vertex_num >= numvertexes)
{
@ -1154,7 +1154,7 @@ static void P_SetLinedefV1(size_t i, UINT16 vertex_num)
lines[i].v1 = &vertexes[vertex_num];
}
static void P_SetLinedefV2(size_t i, UINT16 vertex_num)
static void P_SetLinedefV2(size_t i, UINT32 vertex_num)
{
if (vertex_num >= numvertexes)
{
@ -1179,17 +1179,22 @@ static void P_LoadLinedefs(UINT8 *data)
memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs));
ld->alpha = FRACUNIT;
ld->executordelay = 0;
P_SetLinedefV1(i, SHORT(mld->v1));
P_SetLinedefV2(i, SHORT(mld->v2));
P_SetLinedefV1(i, (UINT16)SHORT(mld->v1));
P_SetLinedefV2(i, (UINT16)SHORT(mld->v2));
ld->sidenum[0] = SHORT(mld->sidenum[0]);
ld->sidenum[1] = SHORT(mld->sidenum[1]);
ld->sidenum[0] = (UINT16)SHORT(mld->sidenum[0]);
ld->sidenum[1] = (UINT16)SHORT(mld->sidenum[1]);
if (ld->sidenum[0] == 0xffff)
ld->sidenum[0] = NO_SIDEDEF;
if (ld->sidenum[1] == 0xffff)
ld->sidenum[1] = NO_SIDEDEF;
P_InitializeLinedef(ld);
}
}
static void P_SetSidedefSector(size_t i, UINT16 sector_num)
static void P_SetSidedefSector(size_t i, UINT32 sector_num)
{
// cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead
if (sector_num >= numsectors)
@ -1350,7 +1355,7 @@ static void P_LoadSidedefs(UINT8 *data)
sd->offsetx_top = sd->offsetx_mid = sd->offsetx_bot = 0;
sd->offsety_top = sd->offsety_mid = sd->offsety_bot = 0;
P_SetSidedefSector(i, SHORT(msd->sector));
P_SetSidedefSector(i, (UINT16)SHORT(msd->sector));
// Special info stored in texture fields!
switch (sd->special)
@ -2489,7 +2494,7 @@ static void P_WriteTextmap(void)
fprintf(f, "v1 = %s;\n", sizeu1(wlines[i].v1 - vertexes));
fprintf(f, "v2 = %s;\n", sizeu1(wlines[i].v2 - vertexes));
fprintf(f, "sidefront = %d;\n", wlines[i].sidenum[0]);
if (wlines[i].sidenum[1] != 0xffff)
if (wlines[i].sidenum[1] != NO_SIDEDEF)
fprintf(f, "sideback = %d;\n", wlines[i].sidenum[1]);
firsttag = Tag_FGet(&wlines[i].tags);
if (firsttag != 0)
@ -2954,8 +2959,8 @@ static void P_LoadTextmap(void)
memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs));
ld->alpha = FRACUNIT;
ld->executordelay = 0;
ld->sidenum[0] = 0xffff;
ld->sidenum[1] = 0xffff;
ld->sidenum[0] = NO_SIDEDEF;
ld->sidenum[1] = NO_SIDEDEF;
TextmapParse(linesPos[i], i, ParseTextmapLinedefParameter);
@ -2963,7 +2968,7 @@ static void P_LoadTextmap(void)
I_Error("P_LoadTextmap: linedef %s has no v1 value set!\n", sizeu1(i));
if (!ld->v2)
I_Error("P_LoadTextmap: linedef %s has no v2 value set!\n", sizeu1(i));
if (ld->sidenum[0] == 0xffff)
if (ld->sidenum[0] == NO_SIDEDEF)
I_Error("P_LoadTextmap: linedef %s has no sidefront value set!\n", sizeu1(i));
P_InitializeLinedef(ld);
@ -3017,7 +3022,7 @@ static void P_ProcessLinedefsAfterSidedefs(void)
for (; i--; ld++)
{
ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here
ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0;
ld->backsector = ld->sidenum[1] != NO_SIDEDEF ? sides[ld->sidenum[1]].sector : 0;
if (udmf)
continue;
@ -3256,10 +3261,10 @@ static void P_InitializeSeg(seg_t *seg)
{
if (seg->linedef)
{
UINT16 side = seg->linedef->sidenum[seg->side];
UINT32 side = seg->linedef->sidenum[seg->side];
if (side == 0xffff)
I_Error("P_InitializeSeg: Seg %s refers to side %d of linedef %s, which doesn't exist!\n", sizeu1((size_t)(seg - segs)), seg->side, sizeu1((size_t)(seg->linedef - lines)));
if (side == NO_SIDEDEF)
I_Error("P_InitializeSeg: Seg %s refers to side %d of linedef %s, which doesn't exist!\n", sizeu1((size_t)(seg - segs)), seg->side, sizeu2((size_t)(seg->linedef - lines)));
seg->sidedef = &sides[side];
@ -3443,7 +3448,7 @@ static boolean P_LoadExtraVertices(UINT8 **data)
static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype)
{
size_t i, k;
INT16 m;
size_t m;
seg_t *seg;
// Subsectors
@ -3466,23 +3471,33 @@ static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype
{
case NT_XGLN:
case NT_XGL3:
for (m = 0; m < subsectors[i].numlines; m++, k++)
for (m = 0; m < (size_t)subsectors[i].numlines; m++, k++)
{
UINT32 vertexnum = READUINT32((*data));
UINT16 linenum;
if (vertexnum >= numvertexes)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid vertex %d!\n", sizeu1(k), m, vertexnum);
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid vertex %d!\n", sizeu1(k), sizeu2(m), vertexnum);
segs[k - 1 + ((m == 0) ? subsectors[i].numlines : 0)].v2 = segs[k].v1 = &vertexes[vertexnum];
READUINT32((*data)); // partner, can be ignored by software renderer
linenum = (nodetype == NT_XGL3) ? READUINT32((*data)) : READUINT16((*data));
if (linenum != 0xFFFF && linenum >= numlines)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(i), linenum);
segs[k].glseg = (linenum == 0xFFFF);
segs[k].linedef = (linenum == 0xFFFF) ? NULL : &lines[linenum];
if (nodetype == NT_XGL3)
{
UINT32 linenum = READUINT32((*data));
if (linenum != 0xFFFFFFFF && linenum >= numlines)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(i), linenum);
segs[k].glseg = linenum == 0xFFFFFFFF;
segs[k].linedef = linenum == 0xFFFFFFFF ? NULL : &lines[linenum];
}
else
{
UINT16 linenum = READUINT16((*data));
if (linenum != 0xFFFF && linenum >= numlines)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(i), linenum);
segs[k].glseg = linenum == 0xFFFF;
segs[k].linedef = linenum == 0xFFFF ? NULL : &lines[linenum];
}
segs[k].side = READUINT8((*data));
}
while (segs[subsectors[i].firstline].glseg)
@ -3494,18 +3509,18 @@ static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype
break;
case NT_XNOD:
for (m = 0; m < subsectors[i].numlines; m++, k++)
for (m = 0; m < (size_t)subsectors[i].numlines; m++, k++)
{
UINT32 v1num = READUINT32((*data));
UINT32 v2num = READUINT32((*data));
UINT16 linenum = READUINT16((*data));
if (v1num >= numvertexes)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid v1 %d!\n", sizeu1(k), m, v1num);
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid v1 %d!\n", sizeu1(k), sizeu2(m), v1num);
if (v2num >= numvertexes)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid v2 %d!\n", sizeu1(k), m, v2num);
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid v2 %d!\n", sizeu1(k), sizeu2(m), v2num);
if (linenum >= numlines)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid linedef %d!\n", sizeu1(k), m, linenum);
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(m), linenum);
segs[k].v1 = &vertexes[v1num];
segs[k].v2 = &vertexes[v2num];
@ -3990,14 +4005,14 @@ static void P_LinkMapData(void)
if (!seg->sidedef)
CorruptMapError(va("P_LinkMapData: seg->sidedef is NULL "
"(subsector %s, firstline is %d)", sizeu1(i), ss->firstline));
if (seg->sidedef - sides < 0 || seg->sidedef - sides > (UINT16)numsides)
if (seg->sidedef - sides < 0 || sidei > numsides)
CorruptMapError(va("P_LinkMapData: seg->sidedef refers to sidedef %s of %s "
"(subsector %s, firstline is %d)", sizeu1(sidei), sizeu2(numsides),
sizeu3(i), ss->firstline));
if (!seg->sidedef->sector)
CorruptMapError(va("P_LinkMapData: seg->sidedef->sector is NULL "
"(subsector %s, firstline is %d, sidedef is %s)", sizeu1(i), ss->firstline,
sizeu1(sidei)));
sizeu2(sidei)));
ss->sector = seg->sidedef->sector;
}
@ -4915,7 +4930,7 @@ static void P_ConvertBinaryLinedefTypes(void)
break;
case 259: //Custom FOF
if (lines[i].sidenum[1] == 0xffff)
if (lines[i].sidenum[1] == NO_SIDEDEF)
I_Error("Custom FOF (tag %d) found without a linedef back side!", tag);
lines[i].args[0] = tag;
@ -5269,8 +5284,8 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[1] = sides[lines[i].sidenum[0]].midtexture;
lines[i].args[2] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[3] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[4] = (lines[i].sidenum[1] != 0xffff) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0;
lines[i].args[5] = (lines[i].sidenum[1] != 0xffff) ? sides[lines[i].sidenum[1]].rowoffset >> FRACBITS : -1;
lines[i].args[4] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0;
lines[i].args[5] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].rowoffset >> FRACBITS : -1;
lines[i].args[6] = sides[lines[i].sidenum[0]].bottomtexture;
break;
case 414: //Play sound effect
@ -5374,7 +5389,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[1] = max(sides[lines[i].sidenum[0]].textureoffset >> FRACBITS, 0);
// failsafe: if user specifies Back Y Offset and NOT Front Y Offset, use the Back Offset
// to be consistent with other light and fade specials
lines[i].args[2] = ((lines[i].sidenum[1] != 0xFFFF && !(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS)) ?
lines[i].args[2] = ((lines[i].sidenum[1] != NO_SIDEDEF && !(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS)) ?
max(min(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS, 255), 0)
: max(min(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS, 255), 0));
}
@ -5479,7 +5494,7 @@ static void P_ConvertBinaryLinedefTypes(void)
break;
case 442: //Change object type state
lines[i].args[0] = tag;
lines[i].args[1] = (lines[i].sidenum[1] == 0xffff) ? 1 : 0;
lines[i].args[1] = (lines[i].sidenum[1] == NO_SIDEDEF) ? 1 : 0;
break;
case 443: //Call Lua function
if (lines[i].stringargs[0] == NULL)
@ -5547,7 +5562,7 @@ static void P_ConvertBinaryLinedefTypes(void)
case 452: //Set FOF translucency
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[2] = lines[i].sidenum[1] != 0xffff ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS);
lines[i].args[2] = lines[i].sidenum[1] != NO_SIDEDEF ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS);
if (lines[i].flags & ML_MIDPEG)
lines[i].args[3] |= TMST_RELATIVE;
if (lines[i].flags & ML_NOCLIMB)
@ -5556,8 +5571,8 @@ static void P_ConvertBinaryLinedefTypes(void)
case 453: //Fade FOF
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[2] = lines[i].sidenum[1] != 0xffff ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (lines[i].dx >> FRACBITS);
lines[i].args[3] = lines[i].sidenum[1] != 0xffff ? (sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) : (abs(lines[i].dy) >> FRACBITS);
lines[i].args[2] = lines[i].sidenum[1] != NO_SIDEDEF ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (lines[i].dx >> FRACBITS);
lines[i].args[3] = lines[i].sidenum[1] != NO_SIDEDEF ? (sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) : (abs(lines[i].dy) >> FRACBITS);
if (lines[i].flags & ML_MIDPEG)
lines[i].args[4] |= TMFT_RELATIVE;
if (lines[i].flags & ML_WRAPMIDTEX)
@ -5584,7 +5599,7 @@ static void P_ConvertBinaryLinedefTypes(void)
break;
case 455: //Fade colormap
{
INT32 speed = (INT32)((((lines[i].flags & ML_DONTPEGBOTTOM) || !sides[lines[i].sidenum[0]].rowoffset) && lines[i].sidenum[1] != 0xFFFF) ?
INT32 speed = (INT32)((((lines[i].flags & ML_DONTPEGBOTTOM) || !sides[lines[i].sidenum[0]].rowoffset) && lines[i].sidenum[1] != NO_SIDEDEF) ?
abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS)
: abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS));
@ -5614,7 +5629,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = tag;
lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[3] = (lines[i].sidenum[1] != 0xffff) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0;
lines[i].args[3] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0;
lines[i].args[4] = !!(lines[i].flags & ML_NOSKEW);
break;
case 459: //Control text prompt
@ -5634,7 +5649,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[2] |= TMP_ALLPLAYERS;
if (lines[i].flags & ML_MIDSOLID)
lines[i].args[2] |= TMP_FREEZETHINKERS;*/
lines[i].args[3] = (lines[i].sidenum[1] != 0xFFFF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : tag;
lines[i].args[3] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : tag;
break;
case 460: //Award rings
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
@ -5647,7 +5662,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[3] = (lines[i].flags & ML_SKEWTD) ? AngleFixed(R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y)) >> FRACBITS : 0;
if (lines[i].flags & ML_NOCLIMB)
{
if (lines[i].sidenum[1] != 0xffff) // Make sure the linedef has a back side
if (lines[i].sidenum[1] != NO_SIDEDEF) // Make sure the linedef has a back side
{
lines[i].args[4] = 1;
lines[i].args[5] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS;
@ -5681,7 +5696,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = tag;
lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
if (lines[i].sidenum[1] != 0xffff)
if (lines[i].sidenum[1] != NO_SIDEDEF)
lines[i].args[3] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS;
break;
case 482: //Polyobject - move
@ -5753,7 +5768,7 @@ static void P_ConvertBinaryLinedefTypes(void)
if (!(lines[i].flags & ML_DONTPEGBOTTOM))
lines[i].args[1] /= 100;
// allow Back Y Offset to be consistent with other fade specials
lines[i].args[2] = (lines[i].sidenum[1] != 0xffff && !sides[lines[i].sidenum[0]].rowoffset) ?
lines[i].args[2] = (lines[i].sidenum[1] != NO_SIDEDEF && !sides[lines[i].sidenum[0]].rowoffset) ?
abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS)
: abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS);
if (lines[i].flags & ML_MIDPEG)
@ -5780,7 +5795,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = tag;
if (lines[i].flags & ML_MIDPEG)
{
if (lines[i].sidenum[1] == 0xffff)
if (lines[i].sidenum[1] == NO_SIDEDEF)
{
CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i));
lines[i].special = 0;
@ -5810,7 +5825,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = lines[i].special >= 507;
if (lines[i].special % 2 == 0)
{
if (lines[i].sidenum[1] == 0xffff)
if (lines[i].sidenum[1] == NO_SIDEDEF)
{
CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i));
lines[i].special = 0;
@ -5966,7 +5981,7 @@ static void P_ConvertBinaryLinedefTypes(void)
{
UINT8 side = lines[i].special >= 714;
if (side == 1 && lines[i].sidenum[1] == 0xffff)
if (side == 1 && lines[i].sidenum[1] == NO_SIDEDEF)
CONS_Debug(DBG_GAMELOGIC, "P_ConvertBinaryMap: Line special %d (line #%s) missing 2nd side!\n", lines[i].special, sizeu1(i));
else
{

View file

@ -557,7 +557,7 @@ static inline sector_t *getSector(INT32 currentSector, INT32 line, INT32 side)
*/
static inline boolean twoSided(INT32 sector, INT32 line)
{
return (sectors[sector].lines[line])->sidenum[1] != 0xffff;
return (sectors[sector].lines[line])->sidenum[1] != NO_SIDEDEF;
}
#endif
@ -1796,7 +1796,7 @@ void P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller)
if (trigid < 0 || trigid > 31) // limited by 32 bit variable
{
CONS_Debug(DBG_GAMELOGIC, "Unlockable trigger (sidedef %hu): bad trigger ID %d\n", triggerline->sidenum[0], trigid);
CONS_Debug(DBG_GAMELOGIC, "Unlockable trigger (sidedef %u): bad trigger ID %d\n", triggerline->sidenum[0], trigid);
return;
}
else if (!(unlocktriggers & (1 << trigid)))
@ -1809,7 +1809,7 @@ void P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller)
if (unlockid <= 0 || unlockid > MAXUNLOCKABLES) // limited by unlockable count
{
CONS_Debug(DBG_GAMELOGIC, "Unlockable check (sidedef %hu): bad unlockable ID %d\n", triggerline->sidenum[0], unlockid);
CONS_Debug(DBG_GAMELOGIC, "Unlockable check (sidedef %u): bad unlockable ID %d\n", triggerline->sidenum[0], unlockid);
return;
}
else if (!(serverGamedata->unlocked[unlockid-1]))
@ -2607,7 +2607,15 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
CONS_Debug(DBG_SETUP, "Line type 415 Executor: script lump %s not found/not valid.\n", line->stringargs[0]);
else
COM_BufInsertText(W_CacheLumpNum(lumpnum, PU_CACHE));
{
void *lump = W_CacheLumpNum(lumpnum, PU_CACHE);
size_t len = W_LumpLength(lumpnum);
char *text = Z_Malloc(len + 1, PU_CACHE, NULL);
memcpy(text, lump, len);
text[len] = '\0';
COM_BufInsertText(text);
Z_Free(text);
}
}
break;
@ -2897,7 +2905,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{
size_t linenum;
side_t *setfront = &sides[line->sidenum[0]];
side_t *setback = (line->args[3] && line->sidenum[1] != 0xffff) ? &sides[line->sidenum[1]] : setfront;
side_t *setback = (line->args[3] && line->sidenum[1] != NO_SIDEDEF) ? &sides[line->sidenum[1]] : setfront;
side_t *this;
boolean always = !(line->args[2]); // If args[2] is set: Only change mid texture if mid texture already exists on tagged lines, etc.
@ -2919,7 +2927,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
}
// Back side
if (line->args[1] != TMSD_FRONT && lines[linenum].sidenum[1] != 0xffff)
if (line->args[1] != TMSD_FRONT && lines[linenum].sidenum[1] != NO_SIDEDEF)
{
this = &sides[lines[linenum].sidenum[1]];
if (always || this->toptexture) this->toptexture = setback->toptexture;
@ -2940,7 +2948,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
INT32 trigid = line->args[0];
if (trigid < 0 || trigid > 31) // limited by 32 bit variable
CONS_Debug(DBG_GAMELOGIC, "Unlockable trigger (sidedef %hu): bad trigger ID %d\n", line->sidenum[0], trigid);
CONS_Debug(DBG_GAMELOGIC, "Unlockable trigger (sidedef %u): bad trigger ID %d\n", line->sidenum[0], trigid);
else
{
unlocktriggers |= 1 << trigid;
@ -3153,7 +3161,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (line->args[2] & TMCF_RELATIVE)
{
extracolormap_t *target = (!udmf && (line->flags & ML_TFERLINE) && line->sidenum[1] != 0xFFFF) ?
extracolormap_t *target = (!udmf && (line->flags & ML_TFERLINE) && line->sidenum[1] != NO_SIDEDEF) ?
sides[line->sidenum[1]].colormap_data : sectors[secnum].extra_colormap; // use back colormap instead of target sector
extracolormap_t *exc = R_AddColormaps(
@ -3482,7 +3490,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
}
if (!udmf && (line->flags & ML_TFERLINE)) // use back colormap instead of target sector
sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ?
sectors[secnum].extra_colormap = (line->sidenum[1] != NO_SIDEDEF) ?
sides[line->sidenum[1]].colormap_data : NULL;
exc = sectors[secnum].extra_colormap;
@ -7600,7 +7608,7 @@ static void P_SpawnScrollers(void)
{
if (l->args[1] != TMSD_BACK)
Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[0], accel, 0);
if (l->args[1] != TMSD_FRONT && lines[s].sidenum[1] != 0xffff)
if (l->args[1] != TMSD_FRONT && lines[s].sidenum[1] != NO_SIDEDEF)
Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[1], accel, 0);
}
break;
@ -7611,7 +7619,7 @@ static void P_SpawnScrollers(void)
Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[0], accel, 0);
if (l->args[0] != TMSD_FRONT)
{
if (l->sidenum[1] != 0xffff)
if (l->sidenum[1] != NO_SIDEDEF)
Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[1], accel, 0);
else
CONS_Debug(DBG_GAMELOGIC, "Line special 500 (line #%s) missing back side!\n", sizeu1(i));

View file

@ -438,7 +438,7 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable)
exc->fadeend = 31;
exc->flags = 0;
exc->rgba = 0;
exc->fadergba = 0x19000000;
exc->fadergba = 0xFF000000;
exc->colormap = lighttable ? R_CreateLightTable(exc) : NULL;
#ifdef EXTRACOLORMAPLUMPS
exc->lump = LUMPERROR;
@ -553,7 +553,7 @@ boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba,
&& !flags)
)
&& (!checkrgba ? true : rgba == 0)
&& (!checkfadergba ? true : fadergba == 0x19000000)
&& (!checkfadergba ? true : (unsigned)fadergba == 0xFF000000)
#ifdef EXTRACOLORMAPLUMPS
&& lump == LUMPERROR
&& extra_colormap->lumpname[0] == 0
@ -654,7 +654,7 @@ extracolormap_t *R_ColormapForName(char *name)
if (lump == LUMPERROR)
I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name);
exc = R_GetColormapFromListByValues(0, 0x19000000, 0, 31, 0, lump);
exc = R_GetColormapFromListByValues(0, 0xFF000000, 0, 31, 0, lump);
if (exc)
return exc;
@ -674,7 +674,7 @@ extracolormap_t *R_ColormapForName(char *name)
exc->fadeend = 31;
exc->flags = 0;
exc->rgba = 0;
exc->fadergba = 0x19000000;
exc->fadergba = 0xFF000000;
R_AddColormapToList(exc);
@ -692,9 +692,26 @@ extracolormap_t *R_ColormapForName(char *name)
//
static double deltas[256][3], map[256][3];
static int RoundUp(double number);
static colorlookup_t lighttable_lut;
static UINT8 LightTableNearest(UINT8 r, UINT8 g, UINT8 b)
{
return NearestColor(r, g, b);
}
static UINT8 LightTableNearest_LUT(UINT8 r, UINT8 g, UINT8 b)
{
return GetColorLUT(&lighttable_lut, r, g, b);
}
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
{
extra_colormap->colormap = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8);
R_GenerateLightTable(extra_colormap, false);
return extra_colormap->colormap;
}
void R_GenerateLightTable(extracolormap_t *extra_colormap, boolean uselookup)
{
double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb;
double maskamt = 0, othermask = 0;
@ -711,7 +728,6 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
UINT8 fadestart = extra_colormap->fadestart,
fadedist = extra_colormap->fadeend - extra_colormap->fadestart;
lighttable_t *lighttable = NULL;
size_t i;
/////////////////////
@ -721,7 +737,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
cmaskg = cg;
cmaskb = cb;
maskamt = (double)(ca/24.0l);
maskamt = (double)(ca/255.0l);
othermask = 1 - maskamt;
maskamt /= 0xff;
@ -737,7 +753,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
cdestb = cfb;
// fade alpha unused in software
// maskamt = (double)(cfa/24.0l);
// maskamt = (double)(cfa/255.0l);
// othermask = 1 - maskamt;
// maskamt /= 0xff;
@ -753,6 +769,16 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
int p;
char *colormap_p;
UINT8 (*NearestColorFunc)(UINT8, UINT8, UINT8);
if (uselookup)
{
InitColorLUT(&lighttable_lut, pMasterPalette, false);
NearestColorFunc = LightTableNearest_LUT;
}
else
NearestColorFunc = LightTableNearest;
// Initialise the map and delta arrays
// map[i] stores an RGB color (as double) for index i,
// which is then converted to SRB2's palette later
@ -783,8 +809,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
// Now allocate memory for the actual colormap array itself!
// aligned on 8 bit for asm code
colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8);
lighttable = (UINT8 *)colormap_p;
colormap_p = (char *)extra_colormap->colormap;
// Calculate the palette index for each palette index, for each light level
// (as well as the two unused colormap lines we inherited from Doom)
@ -792,9 +817,9 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
{
for (i = 0; i < 256; i++)
{
*colormap_p = NearestColor((UINT8)RoundUp(map[i][0]),
(UINT8)RoundUp(map[i][1]),
(UINT8)RoundUp(map[i][2]));
*colormap_p = NearestColorFunc((UINT8)M_RoundUp(map[i][0]),
(UINT8)M_RoundUp(map[i][1]),
(UINT8)M_RoundUp(map[i][2]));
colormap_p++;
if ((UINT32)p < fadestart)
@ -818,8 +843,6 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
}
}
}
return lighttable;
}
extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
@ -828,7 +851,7 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25;
UINT32 fadestart = 0, fadeend = 31;
UINT8 flags = 0;
INT32 rgba = 0, fadergba = 0x19000000;
INT32 rgba = 0, fadergba = 0xFF000000;
#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0)
#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0)
@ -836,13 +859,13 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
// Get base colormap value
// First alpha-only, then full value
if (p1[0] >= 'a' && p1[0] <= 'z' && !p1[1])
ca = (p1[0] - 'a');
ca = ((p1[0] - 'a') * 102) / 10;
else if (p1[0] == '#' && p1[1] >= 'a' && p1[1] <= 'z' && !p1[2])
ca = (p1[1] - 'a');
ca = ((p1[1] - 'a') * 102) / 10;
else if (p1[0] >= 'A' && p1[0] <= 'Z' && !p1[1])
ca = (p1[0] - 'A');
ca = ((p1[0] - 'A') * 102) / 10;
else if (p1[0] == '#' && p1[1] >= 'A' && p1[1] <= 'Z' && !p1[2])
ca = (p1[1] - 'A');
ca = ((p1[1] - 'A') * 102) / 10;
else if (p1[0] == '#')
{
// For each subsequent value, the value before it must exist
@ -858,20 +881,20 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6]));
if (p1[7] >= 'a' && p1[7] <= 'z')
ca = (p1[7] - 'a');
ca = ((p1[7] - 'a') * 102) / 10;
else if (p1[7] >= 'A' && p1[7] <= 'Z')
ca = (p1[7] - 'A');
ca = ((p1[7] - 'A') * 102) / 10;
else
ca = 25;
ca = 255;
}
else
ca = 25;
ca = 255;
}
else
ca = 25;
ca = 255;
}
else
ca = 25;
ca = 255;
}
#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0)
@ -901,13 +924,13 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
// Get fade (dark) colormap value
// First alpha-only, then full value
if (p3[0] >= 'a' && p3[0] <= 'z' && !p3[1])
cfa = (p3[0] - 'a');
cfa = ((p3[0] - 'a') * 102) / 10;
else if (p3[0] == '#' && p3[1] >= 'a' && p3[1] <= 'z' && !p3[2])
cfa = (p3[1] - 'a');
cfa = ((p3[1] - 'a') * 102) / 10;
else if (p3[0] >= 'A' && p3[0] <= 'Z' && !p3[1])
cfa = (p3[0] - 'A');
cfa = ((p3[0] - 'A') * 102) / 10;
else if (p3[0] == '#' && p3[1] >= 'A' && p3[1] <= 'Z' && !p3[2])
cfa = (p3[1] - 'A');
cfa = ((p3[1] - 'A') * 102) / 10;
else if (p3[0] == '#')
{
// For each subsequent value, the value before it must exist
@ -923,20 +946,20 @@ extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6]));
if (p3[7] >= 'a' && p3[7] <= 'z')
cfa = (p3[7] - 'a');
cfa = ((p3[7] - 'a') * 102) / 10;
else if (p3[7] >= 'A' && p3[7] <= 'Z')
cfa = (p3[7] - 'A');
cfa = ((p3[7] - 'A') * 102) / 10;
else
cfa = 25;
cfa = 255;
}
else
cfa = 25;
cfa = 255;
}
else
cfa = 25;
cfa = 255;
}
else
cfa = 25;
cfa = 255;
}
#undef ALPHA2INT
#undef HEX2INT
@ -1133,20 +1156,6 @@ UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette)
return (UINT8)bestcolor;
}
// Rounds off floating numbers and checks for 0 - 255 bounds
static int RoundUp(double number)
{
if (number > 255.0l)
return 255;
if (number < 0.0l)
return 0;
if ((int)number <= (int)(number - 0.5f))
return (int)number + 1;
return (int)number;
}
#ifdef EXTRACOLORMAPLUMPS
const char *R_NameForColormap(extracolormap_t *extra_colormap)
{

View file

@ -92,6 +92,7 @@ typedef enum
TMCF_OVERRIDE = 1<<13,
} textmapcolormapflags_t;
void R_GenerateLightTable(extracolormap_t *extra_colormap, boolean uselookup);
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
extracolormap_t * R_CreateColormapFromLinedef(char *p1, char *p2, char *p3);
extracolormap_t* R_CreateColormap(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags);

View file

@ -53,6 +53,9 @@ typedef struct
// Could even use more than 32 levels.
typedef UINT8 lighttable_t;
#define NUM_PALETTE_ENTRIES 256
#define DEFAULT_STARTTRANSCOLOR 96
#define CMF_FADEFULLBRIGHTSPRITES 1
#define CMF_FOG 4
@ -512,6 +515,8 @@ typedef enum
#define NUMLINEARGS 10
#define NUMLINESTRINGARGS 2
#define NO_SIDEDEF 0xFFFFFFFF
typedef struct line_s
{
// Vertices, from v1 to v2.
@ -529,7 +534,7 @@ typedef struct line_s
char *stringargs[NUMLINESTRINGARGS];
// Visual appearance: sidedefs.
UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided
UINT32 sidenum[2]; // sidenum[1] will be NO_SIDEDEF if one-sided
fixed_t alpha; // translucency
UINT8 blendmode; // blendmode
INT32 executordelay;

View file

@ -125,9 +125,6 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask;
// TRANSLATION COLORMAP CODE
// =========================================================================
#define NUM_PALETTE_ENTRIES 256
#define DEFAULT_STARTTRANSCOLOR 96
enum
{
DEFAULT_TT_CACHE_INDEX,

View file

@ -158,7 +158,7 @@ consvar_t cv_drawdist = CVAR_INIT ("drawdist", "Infinite", CV_SAVE, drawdist_con
consvar_t cv_drawdist_nights = CVAR_INIT ("drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL);
consvar_t cv_drawdist_precip = CVAR_INIT ("drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL);
//consvar_t cv_precipdensity = CVAR_INIT ("precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL);
consvar_t cv_fov = CVAR_INIT ("fov", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange);
consvar_t cv_fov = CVAR_INIT ("fov", "90", CV_SAVE|CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange);
// Okay, whoever said homremoval causes a performance hit should be shot.
consvar_t cv_homremoval = CVAR_INIT ("homremoval", "No", CV_SAVE, homremoval_cons_t, NULL);

View file

@ -1312,8 +1312,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
patch_t *patch;
fixed_t xscale, yscale, shadowxscale, shadowyscale, shadowskew, x1, x2;
INT32 heightsec, phs;
INT32 light = 0;
fixed_t scalemul; UINT8 trans;
fixed_t scalemul;
UINT8 trans;
fixed_t floordiff;
fixed_t groundz;
pslope_t *groundslope;
@ -1429,27 +1429,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
if (thing->renderflags & RF_NOCOLORMAPS)
shadow->extra_colormap = NULL;
else
{
if (thing->subsector->sector->numlights)
{
INT32 lightnum;
light = thing->subsector->sector->numlights - 1;
// R_GetPlaneLight won't work on sloped lights!
for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) {
fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], interp.x, interp.y);
if (h <= shadow->gzt) {
light = lightnum - 1;
break;
}
}
}
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->extra_colormap = P_GetColormapFromSectorAt(thing->subsector->sector, interp.x, interp.y, shadow->gzt);
shadow->transmap = R_GetTranslucencyTable(trans + 1);
shadow->colormap = scalelight[0][0]; // full dark!
@ -2146,21 +2126,9 @@ static void R_ProjectSprite(mobj_t *thing)
if (thing->subsector->sector->numlights)
{
INT32 lightnum;
fixed_t top = (splat) ? gz : gzt;
light = thing->subsector->sector->numlights - 1;
// R_GetPlaneLight won't work on sloped lights!
for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) {
fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], interp.x, interp.y);
if (h <= top) {
light = lightnum - 1;
break;
}
}
//light = R_GetPlaneLight(thing->subsector->sector, gzt, false);
lightnum = (*thing->subsector->sector->lightlist[light].lightlevel >> LIGHTSEGSHIFT);
light = P_GetSectorLightAt(thing->subsector->sector, interp.x, interp.y, splat ? gz : gzt);
INT32 lightnum = (*thing->subsector->sector->lightlist[light].lightlevel >> LIGHTSEGSHIFT);
if (lightnum < 0)
spritelights = scalelight[0];
else if (lightnum >= LIGHTLEVELS)

View file

@ -759,8 +759,8 @@ static void mix_gme(void *udata, Uint8 *stream, int len)
music_volume = 18;
// apply volume to stream
for (i = 0, p = (short *)stream; i < len/2; i++, p++)
*p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 40;
for (i = 0, p = (short *)stream; i < len / 2; i++, p++)
*p = ((INT32)*p) * music_volume * internal_volume / 100 / 20;
}
#endif
@ -783,8 +783,8 @@ static void mix_openmpt(void *udata, Uint8 *stream, int len)
music_volume = 18;
// apply volume to stream
for (i = 0, p = (short *)stream; i < len/2; i++, p++)
*p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 40;
for (i = 0, p = (short *)stream; i < len / 2; i++, p++)
*p = ((INT32)*p) * music_volume * internal_volume / 100 / 20;
}
#endif
@ -1441,7 +1441,7 @@ void I_SetMusicVolume(UINT8 volume)
Mix_VolumeMusic(get_real_volume(music_volume));
}
boolean I_SetSongTrack(int track)
boolean I_SetSongTrack(INT32 track)
{
#ifdef HAVE_GME
// If the specified track is within the number of tracks playing, then change it

View file

@ -1471,7 +1471,7 @@ void I_SetMusicVolume(UINT8 volume)
(void)volume;
}
boolean I_SetSongTrack(int track)
boolean I_SetSongTrack(INT32 track)
{
(void)track;
return false;