Merge remote-tracking branch 'srb2public/next'

This commit is contained in:
TehRealSalt 2018-11-08 17:37:05 -05:00
commit 1e4d196e5e
13 changed files with 480 additions and 10 deletions

View File

@ -2419,7 +2419,7 @@ void CL_ClearPlayer(INT32 playernum)
//
// Removes a player from the current game
//
static void CL_RemovePlayer(INT32 playernum)
static void CL_RemovePlayer(INT32 playernum, INT32 reason)
{
// Sanity check: exceptional cases (i.e. c-fails) can cause multiple
// kick commands to be issued for the same player.
@ -2477,6 +2477,10 @@ static void CL_RemovePlayer(INT32 playernum)
}
}
}
#ifdef HAVE_BLUA
LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting
#endif
// Reset player data
CL_ClearPlayer(playernum);
@ -2757,6 +2761,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
INT32 pnum, msg;
XBOXSTATIC char buf[3 + MAX_REASONLENGTH];
char *reason = buf;
kickreason_t kickreason = KR_KICK;
pnum = READUINT8(*p);
msg = READUINT8(*p);
@ -2831,14 +2836,17 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
{
case KICK_MSG_GO_AWAY:
HU_AddChatText(va("\x82*%s has been kicked (Go away)", player_names[pnum]), false);
kickreason = KR_KICK;
break;
#ifdef NEWPING
case KICK_MSG_PING_HIGH:
HU_AddChatText(va("\x82*%s left the game (Broke ping limit)", player_names[pnum]), false);
kickreason = KR_PINGLIMIT;
break;
#endif
case KICK_MSG_CON_FAIL:
HU_AddChatText(va("\x82*%s left the game (Synch Failure)", player_names[pnum]), false);
kickreason = KR_SYNCH;
if (M_CheckParm("-consisdump")) // Helps debugging some problems
{
@ -2875,21 +2883,26 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
break;
case KICK_MSG_TIMEOUT:
HU_AddChatText(va("\x82*%s left the game (Connection timeout)", player_names[pnum]), false);
kickreason = KR_TIMEOUT;
break;
case KICK_MSG_PLAYER_QUIT:
if (netgame) // not splitscreen/bots
HU_AddChatText(va("\x82*%s left the game", player_names[pnum]), false);
kickreason = KR_LEAVE;
break;
case KICK_MSG_BANNED:
HU_AddChatText(va("\x82*%s has been banned (Don't come back)", player_names[pnum]), false);
kickreason = KR_BAN;
break;
case KICK_MSG_CUSTOM_KICK:
READSTRINGN(*p, reason, MAX_REASONLENGTH+1);
HU_AddChatText(va("\x82*%s has been kicked (%s)", player_names[pnum], reason), false);
kickreason = KR_KICK;
break;
case KICK_MSG_CUSTOM_BAN:
READSTRINGN(*p, reason, MAX_REASONLENGTH+1);
HU_AddChatText(va("\x82*%s has been banned (%s)", player_names[pnum], reason), false);
kickreason = KR_BAN;
break;
}
@ -2918,7 +2931,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
}
else if (server)
{
XBOXSTATIC UINT8 buf[0];
XBOXSTATIC UINT8 buf[2];
// Sal: Because kicks (and a lot of other commands) are player-based, we can't tell which player pnum is on the node from a glance.
// When we want to remove everyone from a node, we have to get the kicked player's node, then remove everyone on that node manually so we don't miss any.
@ -2930,10 +2943,15 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
#define removethisplayer(otherp) \
if (otherp >= 0) \
{ \
if (otherp != pnum) \
HU_AddChatText(va("\x82*%s left the game (Joined with %s)", player_names[otherp], player_names[pnum]), false); \
buf[0] = (UINT8)otherp; \
SendNetXCmd(XD_REMOVEPLAYER, &buf, 1); \
if (otherp != pnum) \
{ \
HU_AddChatText(va("\x82*%s left the game (Joined with %s)", player_names[otherp], player_names[pnum]), false); \
buf[1] = KR_LEAVE; \
} \
else \
buf[1] = (UINT8)kickreason; \
SendNetXCmd(XD_REMOVEPLAYER, &buf, 2); \
otherp = -1; \
}
removethisplayer(nodetoplayer[playernode[pnum]])
@ -3275,6 +3293,8 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
// Xcmd XD_REMOVEPLAYER
static void Got_RemovePlayer(UINT8 **p, INT32 playernum)
{
SINT8 pnum, reason;
if (playernum != serverplayer && !IsPlayerAdmin(playernum))
{
// protect against hacked/buggy client
@ -3290,7 +3310,10 @@ static void Got_RemovePlayer(UINT8 **p, INT32 playernum)
return;
}
CL_RemovePlayer(READUINT8(*p));
pnum = READUINT8(*p);
reason = READUINT8(*p);
CL_RemovePlayer(pnum, reason);
}
static boolean SV_AddWaitingPlayers(void)

View File

@ -483,6 +483,17 @@ extern consvar_t cv_playbackspeed;
#define KICK_MSG_CUSTOM_KICK 7
#define KICK_MSG_CUSTOM_BAN 8
typedef enum
{
KR_KICK = 1, //Kicked by server
KR_PINGLIMIT = 2, //Broke Ping Limit
KR_SYNCH = 3, //Synch Failure
KR_TIMEOUT = 4, //Connection Timeout
KR_BAN = 5, //Banned by server
KR_LEAVE = 6, //Quit the game
} kickreason_t;
extern boolean server;
#define client (!server)
extern boolean dedicated; // For dedicated server

View File

@ -32,6 +32,7 @@
#include "fastcmp.h"
#include "lua_script.h"
#include "lua_hook.h"
#include "d_clisrv.h"
#include "m_cond.h"
@ -8661,6 +8662,14 @@ struct {
{"FF_COLORMAPONLY",FF_COLORMAPONLY}, ///< Only copy the colormap, not the lightlevel
{"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop.
#ifdef ESLOPE
// Slope flags
{"SL_NOPHYSICS",SL_NOPHYSICS}, // Don't do momentum adjustment with this slope
{"SL_NODYNAMIC",SL_NODYNAMIC}, // Slope will never need to move during the level, so don't fuss with recalculating it
{"SL_ANCHORVERTEX",SL_ANCHORVERTEX},// Slope is using a Slope Vertex Thing to anchor its position
{"SL_VERTEXSLOPE",SL_VERTEXSLOPE}, // Slope is built from three Slope Vertex Things
#endif
// Angles
{"ANG1",ANG1},
{"ANG2",ANG2},
@ -8789,6 +8798,14 @@ struct {
{"V_CHARCOLORSHIFT",V_CHARCOLORSHIFT},
{"V_ALPHASHIFT",V_ALPHASHIFT},
//Kick Reasons
{"KR_KICK",KR_KICK},
{"KR_PINGLIMIT",KR_PINGLIMIT},
{"KR_SYNCH",KR_SYNCH},
{"KR_TIMEOUT",KR_TIMEOUT},
{"KR_BAN",KR_BAN},
{"KR_LEAVE",KR_LEAVE},
// SRB2Kart
// kartitems_t
{"KITEM_SAD",KITEM_SAD}, // Actual items (can be set for k_itemtype)
@ -9662,6 +9679,9 @@ static inline int lib_getenum(lua_State *L)
} else if (fastcmp(word,"maptol")) {
lua_pushinteger(L, maptol);
return 1;
} else if (fastcmp(word,"ultimatemode")) {
lua_pushboolean(L, ultimatemode != 0);
return 1;
} else if (fastcmp(word,"mariomode")) {
lua_pushboolean(L, mariomode != 0);
return 1;

View File

@ -262,6 +262,33 @@ static void wattcp_outch(char s)
}
#endif
#ifdef USE_WINSOCK
// stupid microsoft makes things complicated
static char *get_WSAErrorStr(int e)
{
static char buf[256]; // allow up to 255 bytes
buf[0] = '\0';
FormatMessageA(
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
(DWORD)e,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)buf,
sizeof (buf),
NULL);
if (!buf[0]) // provide a fallback error message if no message is available for some reason
sprintf(buf, "Unknown error");
return buf;
}
#undef strerror
#define strerror get_WSAErrorStr
#endif
#ifdef USE_WINSOCK2
#define inet_ntop inet_ntopA
#define HAVE_NTOP
@ -740,9 +767,13 @@ static void SOCK_Send(void)
c = SOCK_SendToAddr(nodesocket[doomcom->remotenode], &clientaddress[doomcom->remotenode]);
}
if (c == ERRSOCKET && errno != ECONNREFUSED && errno != EWOULDBLOCK)
I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode,
SOCK_GetNodeAddress(doomcom->remotenode), errno, strerror(errno));
if (c == ERRSOCKET)
{
int e = errno; // save error code so it can't be modified later
if (e != ECONNREFUSED && e != EWOULDBLOCK)
I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode,
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
}
}
#endif

View File

@ -14,6 +14,9 @@
#ifdef HAVE_BLUA
#include "p_local.h"
#include "p_setup.h" // So we can have P_SetupLevelSky
#ifdef ESLOPE
#include "p_slopes.h" // P_GetZAt
#endif
#include "z_zone.h"
#include "r_main.h"
#include "r_things.h"
@ -1618,6 +1621,24 @@ static int lib_evCrumbleChain(lua_State *L)
return 0;
}
#ifdef ESLOPE
// P_SLOPES
////////////
static int lib_pGetZAt(lua_State *L)
{
pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
//HUDSAFE
if (!slope)
return LUA_ErrInvalid(L, "pslope_t");
lua_pushfixed(L, P_GetZAt(slope, x, y));
return 1;
}
#endif
// R_DEFS
////////////
@ -2571,6 +2592,11 @@ static luaL_Reg lib[] = {
{"P_StartQuake",lib_pStartQuake},
{"EV_CrumbleChain",lib_evCrumbleChain},
#ifdef ESLOPE
// p_slopes
{"P_GetZAt",lib_pGetZAt},
#endif
// r_defs
{"R_PointToAngle",lib_rPointToAngle},
{"R_PointToAngle2",lib_rPointToAngle2},

View File

@ -43,6 +43,7 @@ enum hook {
hook_PlayerMsg,
hook_HurtMsg,
hook_PlayerSpawn,
hook_PlayerQuit,
hook_MAX // last hook
};
@ -77,5 +78,6 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook
boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute); // Hook for chat messages
boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
#define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
#endif

View File

@ -54,6 +54,7 @@ const char *const hookNames[hook_MAX+1] = {
"PlayerMsg",
"HurtMsg",
"PlayerSpawn",
"PlayerQuit",
NULL
};
@ -1081,4 +1082,30 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc)
// stack: tables
}
void LUAh_PlayerQuit(player_t *plr, int reason)
{
hook_p hookp;
if (!gL || !(hooksAvailable[hook_PlayerQuit/8] & (1<<(hook_PlayerQuit%8))))
return;
lua_settop(gL, 0);
for (hookp = roothook; hookp; hookp = hookp->next)
if (hookp->type == hook_PlayerQuit)
{
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit
lua_pushinteger(gL, reason); // Reason for quitting
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -3);
lua_pushvalue(gL, -3);
LUA_Call(gL, 2);
}
lua_settop(gL, 0);
}
#endif

View File

@ -40,6 +40,11 @@ extern lua_State *gL;
#define META_SUBSECTOR "SUBSECTOR_T*"
#define META_SECTOR "SECTOR_T*"
#define META_FFLOOR "FFLOOR_T*"
#ifdef ESLOPE
#define META_SLOPE "PSLOPE_T*"
#define META_VECTOR2 "VECTOR2_T"
#define META_VECTOR3 "VECTOR3_T"
#endif
#define META_MAPHEADER "MAPHEADER_T*"
#define META_CVAR "CONSVAR_T*"

View File

@ -16,6 +16,10 @@
#include "p_local.h"
#include "p_setup.h"
#include "z_zone.h"
#ifdef ESLOPE
#include "p_slopes.h"
#endif
#include "r_main.h"
#include "lua_script.h"
#include "lua_libs.h"
@ -38,7 +42,13 @@ enum sector_e {
sector_heightsec,
sector_camsec,
sector_lines,
#ifdef ESLOPE
sector_ffloors,
sector_fslope,
sector_cslope
#else
sector_ffloors
#endif
};
static const char *const sector_opt[] = {
@ -55,6 +65,10 @@ static const char *const sector_opt[] = {
"camsec",
"lines",
"ffloors",
#ifdef ESLOPE
"f_slope",
"c_slope",
#endif
NULL};
enum subsector_e {
@ -160,6 +174,10 @@ enum ffloor_e {
ffloor_toplightlevel,
ffloor_bottomheight,
ffloor_bottompic,
#ifdef ESLOPE
ffloor_tslope,
ffloor_bslope,
#endif
ffloor_sector,
ffloor_flags,
ffloor_master,
@ -176,6 +194,10 @@ static const char *const ffloor_opt[] = {
"toplightlevel",
"bottomheight",
"bottompic",
#ifdef ESLOPE
"t_slope",
"b_slope",
#endif
"sector", // secnum pushed as control sector userdata
"flags",
"master", // control linedef
@ -185,6 +207,47 @@ static const char *const ffloor_opt[] = {
"alpha",
NULL};
#ifdef ESLOPE
enum slope_e {
slope_valid = 0,
slope_o,
slope_d,
slope_zdelta,
slope_normal,
slope_zangle,
slope_xydirection,
slope_sourceline,
slope_refpos,
slope_flags
};
static const char *const slope_opt[] = {
"valid",
"o",
"d",
"zdelta",
"normal",
"zangle",
"xydirection",
"sourceline",
"refpos",
"flags",
NULL};
// shared by both vector2_t and vector3_t
enum vector_e {
vector_x = 0,
vector_y,
vector_z
};
static const char *const vector_opt[] = {
"x",
"y",
"z",
NULL};
#endif
static const char *const array_opt[] ={"iterate",NULL};
static const char *const valid_opt[] ={"valid",NULL};
@ -399,6 +462,14 @@ static int sector_get(lua_State *L)
LUA_PushUserdata(L, sector->ffloors, META_FFLOOR);
lua_pushcclosure(L, sector_iterate, 2); // push lib_iterateFFloors and sector->ffloors as upvalues for the function
return 1;
#ifdef ESLOPE
case sector_fslope: // f_slope
LUA_PushUserdata(L, sector->f_slope, META_SLOPE);
return 1;
case sector_cslope: // c_slope
LUA_PushUserdata(L, sector->c_slope, META_SLOPE);
return 1;
#endif
}
return 0;
}
@ -421,6 +492,10 @@ static int sector_set(lua_State *L)
case sector_heightsec: // heightsec
case sector_camsec: // camsec
case sector_ffloors: // ffloors
#ifdef ESLOPE
case sector_fslope: // f_slope
case sector_cslope: // c_slope
#endif
default:
return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]);
case sector_floorheight: { // floorheight
@ -1055,6 +1130,14 @@ static int ffloor_get(lua_State *L)
lua_pushlstring(L, levelflat->name, 8);
return 1;
}
#ifdef ESLOPE
case ffloor_tslope:
LUA_PushUserdata(L, *ffloor->t_slope, META_SLOPE);
return 1;
case ffloor_bslope:
LUA_PushUserdata(L, *ffloor->b_slope, META_SLOPE);
return 1;
#endif
case ffloor_sector:
LUA_PushUserdata(L, &sectors[ffloor->secnum], META_SECTOR);
return 1;
@ -1094,6 +1177,10 @@ static int ffloor_set(lua_State *L)
switch(field)
{
case ffloor_valid: // valid
#ifdef ESLOPE
case ffloor_tslope: // t_slope
case ffloor_bslope: // b_slope
#endif
case ffloor_sector: // sector
case ffloor_master: // master
case ffloor_target: // target
@ -1154,6 +1241,181 @@ static int ffloor_set(lua_State *L)
return 0;
}
#ifdef ESLOPE
static int slope_get(lua_State *L)
{
pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE));
enum slope_e field = luaL_checkoption(L, 2, slope_opt[0], slope_opt);
if (!slope)
{
if (field == slope_valid) {
lua_pushboolean(L, 0);
return 1;
}
return luaL_error(L, "accessed pslope_t doesn't exist anymore.");
}
switch(field)
{
case slope_valid: // valid
lua_pushboolean(L, 1);
return 1;
case slope_o: // o
LUA_PushUserdata(L, &slope->o, META_VECTOR3);
return 1;
case slope_d: // d
LUA_PushUserdata(L, &slope->d, META_VECTOR2);
return 1;
case slope_zdelta: // zdelta
lua_pushfixed(L, slope->zdelta);
return 1;
case slope_normal: // normal
LUA_PushUserdata(L, &slope->normal, META_VECTOR3);
return 1;
case slope_zangle: // zangle
lua_pushangle(L, slope->zangle);
return 1;
case slope_xydirection: // xydirection
lua_pushangle(L, slope->xydirection);
return 1;
case slope_sourceline: // source linedef
LUA_PushUserdata(L, slope->sourceline, META_LINE);
return 1;
case slope_refpos: // refpos
lua_pushinteger(L, slope->refpos);
return 1;
case slope_flags: // flags
lua_pushinteger(L, slope->flags);
return 1;
}
return 0;
}
static int slope_set(lua_State *L)
{
pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE));
enum slope_e field = luaL_checkoption(L, 2, slope_opt[0], slope_opt);
if (!slope)
return luaL_error(L, "accessed pslope_t doesn't exist anymore.");
if (hud_running)
return luaL_error(L, "Do not alter pslope_t in HUD rendering code!");
switch(field) // todo: reorganize this shit
{
case slope_valid: // valid
case slope_sourceline: // sourceline
case slope_d: // d
case slope_flags: // flags
case slope_normal: // normal
case slope_refpos: // refpos
default:
return luaL_error(L, "pslope_t field " LUA_QS " cannot be set.", slope_opt[field]);
case slope_o: { // o
luaL_checktype(L, 3, LUA_TTABLE);
lua_getfield(L, 3, "x");
if (lua_isnil(L, -1))
{
lua_pop(L, 1);
lua_rawgeti(L, 3, 1);
}
if (!lua_isnil(L, -1))
slope->o.x = luaL_checkfixed(L, -1);
else
slope->o.x = 0;
lua_pop(L, 1);
lua_getfield(L, 3, "y");
if (lua_isnil(L, -1))
{
lua_pop(L, 1);
lua_rawgeti(L, 3, 2);
}
if (!lua_isnil(L, -1))
slope->o.y = luaL_checkfixed(L, -1);
else
slope->o.y = 0;
lua_pop(L, 1);
lua_getfield(L, 3, "z");
if (lua_isnil(L, -1))
{
lua_pop(L, 1);
lua_rawgeti(L, 3, 3);
}
if (!lua_isnil(L, -1))
slope->o.z = luaL_checkfixed(L, -1);
else
slope->o.z = 0;
lua_pop(L, 1);
break;
}
case slope_zdelta: { // zdelta, this is temp until i figure out wtf to do
slope->zdelta = luaL_checkfixed(L, 3);
slope->zangle = R_PointToAngle2(0, 0, FRACUNIT, -slope->zdelta);
P_CalculateSlopeNormal(slope);
break;
}
case slope_zangle: { // zangle
angle_t zangle = luaL_checkangle(L, 3);
if (zangle == ANGLE_90 || zangle == ANGLE_270)
return luaL_error(L, "invalid zangle for slope!");
slope->zangle = zangle;
slope->zdelta = -FINETANGENT(((slope->zangle+ANGLE_90)>>ANGLETOFINESHIFT) & 4095);
P_CalculateSlopeNormal(slope);
break;
}
case slope_xydirection: // xydirection
slope->xydirection = luaL_checkangle(L, 3);
slope->d.x = -FINECOSINE((slope->xydirection>>ANGLETOFINESHIFT) & FINEMASK);
slope->d.y = -FINESINE((slope->xydirection>>ANGLETOFINESHIFT) & FINEMASK);
P_CalculateSlopeNormal(slope);
break;
}
return 0;
}
static int vector2_get(lua_State *L)
{
vector2_t *vec = *((vector2_t **)luaL_checkudata(L, 1, META_VECTOR2));
enum vector_e field = luaL_checkoption(L, 2, vector_opt[0], vector_opt);
if (!vec)
return luaL_error(L, "accessed vector2_t doesn't exist anymore.");
switch(field)
{
case vector_x: lua_pushfixed(L, vec->x); return 1;
case vector_y: lua_pushfixed(L, vec->y); return 1;
default: break;
}
return 0;
}
static int vector3_get(lua_State *L)
{
vector3_t *vec = *((vector3_t **)luaL_checkudata(L, 1, META_VECTOR3));
enum vector_e field = luaL_checkoption(L, 2, vector_opt[0], vector_opt);
if (!vec)
return luaL_error(L, "accessed vector3_t doesn't exist anymore.");
switch(field)
{
case vector_x: lua_pushfixed(L, vec->x); return 1;
case vector_y: lua_pushfixed(L, vec->y); return 1;
case vector_z: lua_pushfixed(L, vec->z); return 1;
default: break;
}
return 0;
}
#endif
static int lib_getMapheaderinfo(lua_State *L)
{
// i -> mapheaderinfo[i-1]
@ -1336,6 +1598,26 @@ int LUA_MapLib(lua_State *L)
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
#ifdef ESLOPE
luaL_newmetatable(L, META_SLOPE);
lua_pushcfunction(L, slope_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, slope_set);
lua_setfield(L, -2, "__newindex");
lua_pop(L, 1);
luaL_newmetatable(L, META_VECTOR2);
lua_pushcfunction(L, vector2_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
luaL_newmetatable(L, META_VECTOR3);
lua_pushcfunction(L, vector3_get);
lua_setfield(L, -2, "__index");
lua_pop(L, 1);
#endif
luaL_newmetatable(L, META_MAPHEADER);
lua_pushcfunction(L, mapheaderinfo_get);
lua_setfield(L, -2, "__index");

View File

@ -81,6 +81,9 @@ enum mobj_e {
mobj_extravalue2,
mobj_cusval,
mobj_cvmem,
#ifdef ESLOPE
mobj_standingslope,
#endif
mobj_colorized
};
@ -141,6 +144,9 @@ static const char *const mobj_opt[] = {
"extravalue2",
"cusval",
"cvmem",
#ifdef ESLOPE
"standingslope",
#endif
"colorized",
NULL};
@ -345,6 +351,11 @@ static int mobj_get(lua_State *L)
case mobj_cvmem:
lua_pushinteger(L, mo->cvmem);
break;
#ifdef ESLOPE
case mobj_standingslope:
LUA_PushUserdata(L, mo->standingslope, META_SLOPE);
break;
#endif
case mobj_colorized:
lua_pushboolean(L, mo->colorized);
break;
@ -655,6 +666,10 @@ static int mobj_set(lua_State *L)
case mobj_cvmem:
mo->cvmem = luaL_checkinteger(L, 3);
break;
#ifdef ESLOPE
case mobj_standingslope:
return NOSET;
#endif
case mobj_colorized:
mo->colorized = luaL_checkboolean(L, 3);
break;

View File

@ -22,6 +22,9 @@
#include "byteptr.h"
#include "p_saveg.h"
#include "p_local.h"
#ifdef ESLOPE
#include "p_slopes.h" // for P_SlopeById
#endif
#ifdef LUA_ALLOW_BYTECODE
#include "d_netfil.h" // for LUA_DumpFile
#endif
@ -458,6 +461,9 @@ enum
ARCH_SIDE,
ARCH_SUBSECTOR,
ARCH_SECTOR,
#ifdef ESLOPE
ARCH_SLOPE,
#endif
ARCH_MAPHEADER,
ARCH_TEND=0xFF,
@ -477,6 +483,9 @@ static const struct {
{META_SIDE, ARCH_SIDE},
{META_SUBSECTOR,ARCH_SUBSECTOR},
{META_SECTOR, ARCH_SECTOR},
#ifdef ESLOPE
{META_SLOPE, ARCH_SLOPE},
#endif
{META_MAPHEADER, ARCH_MAPHEADER},
{NULL, ARCH_NULL}
};
@ -681,6 +690,19 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex)
}
break;
}
#ifdef ESLOPE
case ARCH_SLOPE:
{
pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex));
if (!slope)
WRITEUINT8(save_p, ARCH_NULL);
else {
WRITEUINT8(save_p, ARCH_SLOPE);
WRITEUINT16(save_p, slope->id);
}
break;
}
#endif
case ARCH_MAPHEADER:
{
mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex));
@ -885,6 +907,11 @@ static UINT8 UnArchiveValue(int TABLESINDEX)
case ARCH_SECTOR:
LUA_PushUserdata(gL, &sectors[READUINT16(save_p)], META_SECTOR);
break;
#ifdef ESLOPE
case ARCH_SLOPE:
LUA_PushUserdata(gL, P_SlopeById(READUINT16(save_p)), META_SLOPE);
break;
#endif
case ARCH_MAPHEADER:
LUA_PushUserdata(gL, mapheaderinfo[READUINT16(save_p)], META_MAPHEADER);
break;

View File

@ -29,7 +29,7 @@ static pslope_t *slopelist = NULL;
static UINT16 slopecount = 0;
// Calculate line normal
static void P_CalculateSlopeNormal(pslope_t *slope) {
void P_CalculateSlopeNormal(pslope_t *slope) {
slope->normal.z = FINECOSINE(slope->zangle>>ANGLETOFINESHIFT);
slope->normal.x = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.x);
slope->normal.y = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.y);

View File

@ -14,6 +14,7 @@
#define P_SLOPES_H__
#ifdef ESLOPE
void P_CalculateSlopeNormal(pslope_t *slope);
void P_ResetDynamicSlopes(void);
void P_RunDynamicSlopes(void);
// P_SpawnSlope_Line