Merge remote-tracking branch 'public/lua-32bit-changes' into next

Conflicts:
	src/lua_mobjlib.c
This commit is contained in:
Alam Ed Arias 2015-06-18 10:22:07 -04:00
commit ac5c8f10e9
16 changed files with 812 additions and 976 deletions

View File

@ -11,6 +11,13 @@
#include <limits.h> #include <limits.h>
#include <stddef.h> #include <stddef.h>
#ifdef _MSC_VER
#define INT32 __int32
#else
#include <stdint.h>
#define INT32 int32_t
#endif
/* /*
** ================================================================== ** ==================================================================
@ -140,7 +147,7 @@
** CHANGE that if ptrdiff_t is not adequate on your machine. (On most ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
** machines, ptrdiff_t gives a good choice between int or long.) ** machines, ptrdiff_t gives a good choice between int or long.)
*/ */
#define LUA_INTEGER ptrdiff_t #define LUA_INTEGER INT32
/* /*
@ -502,13 +509,13 @@
*/ */
//#define LUA_NUMBER_DOUBLE //#define LUA_NUMBER_DOUBLE
#define LUA_NUMBER ptrdiff_t #define LUA_NUMBER INT32
/* /*
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
@* over a number. @* over a number.
*/ */
#define LUAI_UACNUMBER ptrdiff_t #define LUAI_UACNUMBER INT32
/* /*
@ -519,14 +526,14 @@
@@ lua_str2number converts a string to a number. @@ lua_str2number converts a string to a number.
*/ */
#ifdef LUA_WIN #ifdef LUA_WIN
#define LUA_NUMBER_SCAN "%Ii" #define LUA_NUMBER_SCAN "%d"
#define LUA_NUMBER_FMT "%Ii" #define LUA_NUMBER_FMT "%d"
#else #else
#define LUA_NUMBER_SCAN "%ti" #define LUA_NUMBER_SCAN "%d"
#define LUA_NUMBER_FMT "%ti" #define LUA_NUMBER_FMT "%d"
#endif #endif
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ #define LUAI_MAXNUMBER2STR 12 /* 10 digits, sign, and \0 */
#define lua_str2number(s,p) strtol((s), (p), 10) #define lua_str2number(s,p) strtol((s), (p), 10)

View File

@ -96,6 +96,10 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "hardware/hw3sound.h" #include "hardware/hw3sound.h"
#endif #endif
#ifdef HAVE_BLUA
#include "lua_script.h"
#endif
// platform independant focus loss // platform independant focus loss
UINT8 window_notinfocus = false; UINT8 window_notinfocus = false;
@ -634,6 +638,10 @@ void D_SRB2Loop(void)
#ifdef HW3SOUND #ifdef HW3SOUND
HW3S_EndFrameUpdate(); HW3S_EndFrameUpdate();
#endif #endif
#ifdef HAVE_BLUA
LUA_Step();
#endif
} }
} }

View File

@ -7757,36 +7757,36 @@ struct {
{"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop. {"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop.
// Angles // Angles
{"ANG1",ANG1}, {"ANG1",ANG1>>16},
{"ANG2",ANG2}, {"ANG2",ANG2>>16},
{"ANG10",ANG10}, {"ANG10",ANG10>>16},
{"ANG15",ANG15}, {"ANG15",ANG15>>16},
{"ANG20",ANG20}, {"ANG20",ANG20>>16},
{"ANG30",ANG30}, {"ANG30",ANG30>>16},
{"ANG60",ANG60}, {"ANG60",ANG60>>16},
{"ANG64h",ANG64h}, {"ANG64h",ANG64h>>16},
{"ANG105",ANG105}, {"ANG105",ANG105>>16},
{"ANG210",ANG210}, {"ANG210",ANG210>>16},
{"ANG255",ANG255}, {"ANG255",ANG255>>16},
{"ANG340",ANG340}, {"ANG340",ANG340>>16},
{"ANG350",ANG350}, {"ANG350",ANG350>>16},
{"ANGLE_11hh",ANGLE_11hh}, {"ANGLE_11hh",ANGLE_11hh>>16},
{"ANGLE_22h",ANGLE_22h}, {"ANGLE_22h",ANGLE_22h>>16},
{"ANGLE_45",ANGLE_45}, {"ANGLE_45",ANGLE_45>>16},
{"ANGLE_67h",ANGLE_67h}, {"ANGLE_67h",ANGLE_67h>>16},
{"ANGLE_90",ANGLE_90}, {"ANGLE_90",ANGLE_90>>16},
{"ANGLE_112h",ANGLE_112h}, {"ANGLE_112h",ANGLE_112h>>16},
{"ANGLE_135",ANGLE_135}, {"ANGLE_135",ANGLE_135>>16},
{"ANGLE_157h",ANGLE_157h}, {"ANGLE_157h",ANGLE_157h>>16},
{"ANGLE_180",ANGLE_180}, {"ANGLE_180",ANGLE_180>>16},
{"ANGLE_202h",ANGLE_202h}, {"ANGLE_202h",ANGLE_202h>>16},
{"ANGLE_225",ANGLE_225}, {"ANGLE_225",ANGLE_225>>16},
{"ANGLE_247h",ANGLE_247h}, {"ANGLE_247h",ANGLE_247h>>16},
{"ANGLE_270",ANGLE_270}, {"ANGLE_270",ANGLE_270>>16},
{"ANGLE_292h",ANGLE_292h}, {"ANGLE_292h",ANGLE_292h>>16},
{"ANGLE_315",ANGLE_315}, {"ANGLE_315",ANGLE_315>>16},
{"ANGLE_337h",ANGLE_337h}, {"ANGLE_337h",ANGLE_337h>>16},
{"ANGLE_MAX",ANGLE_MAX}, {"ANGLE_MAX",ANGLE_MAX>>16},
// P_Chase directions (dirtype_t) // P_Chase directions (dirtype_t)
{"DI_NODIR",DI_NODIR}, {"DI_NODIR",DI_NODIR},

View File

@ -85,13 +85,6 @@ static int lib_print(lua_State *L)
return 0; return 0;
} }
static int lib_evalMath(lua_State *L)
{
const char *word = luaL_checkstring(L, 1);
lua_pushinteger(L, LUA_EvalMath(word));
return 1;
}
// M_RANDOM // M_RANDOM
////////////// //////////////
@ -138,25 +131,25 @@ static int lib_pRandomRange(lua_State *L)
static int lib_pAproxDistance(lua_State *L) static int lib_pAproxDistance(lua_State *L)
{ {
fixed_t dx = (fixed_t)luaL_checkinteger(L, 1); fixed_t dx = luaL_checkfixed(L, 1);
fixed_t dy = (fixed_t)luaL_checkinteger(L, 2); fixed_t dy = luaL_checkfixed(L, 2);
//HUDSAFE //HUDSAFE
lua_pushinteger(L, P_AproxDistance(dx, dy)); lua_pushfixed(L, P_AproxDistance(dx, dy));
return 1; return 1;
} }
static int lib_pClosestPointOnLine(lua_State *L) static int lib_pClosestPointOnLine(lua_State *L)
{ {
fixed_t x = (fixed_t)luaL_checkinteger(L, 1); fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2); fixed_t y = luaL_checkfixed(L, 2);
line_t *line = *((line_t **)luaL_checkudata(L, 3, META_LINE)); line_t *line = *((line_t **)luaL_checkudata(L, 3, META_LINE));
vertex_t result; vertex_t result;
//HUDSAFE //HUDSAFE
if (!line) if (!line)
return LUA_ErrInvalid(L, "line_t"); return LUA_ErrInvalid(L, "line_t");
P_ClosestPointOnLine(x, y, line, &result); P_ClosestPointOnLine(x, y, line, &result);
lua_pushinteger(L, result.x); lua_pushfixed(L, result.x);
lua_pushinteger(L, result.y); lua_pushfixed(L, result.y);
return 2; return 2;
} }
@ -241,9 +234,9 @@ static int lib_pLookForPlayers(lua_State *L)
static int lib_pSpawnMobj(lua_State *L) static int lib_pSpawnMobj(lua_State *L)
{ {
fixed_t x = (fixed_t)luaL_checkinteger(L, 1); fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2); fixed_t y = luaL_checkfixed(L, 2);
fixed_t z = (fixed_t)luaL_checkinteger(L, 3); fixed_t z = luaL_checkfixed(L, 3);
mobjtype_t type = luaL_checkinteger(L, 4); mobjtype_t type = luaL_checkinteger(L, 4);
NOHUD NOHUD
if (type > MT_LASTFREESLOT) if (type > MT_LASTFREESLOT)
@ -283,9 +276,9 @@ static int lib_pSpawnXYZMissile(lua_State *L)
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *dest = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); mobj_t *dest = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
mobjtype_t type = luaL_checkinteger(L, 3); mobjtype_t type = luaL_checkinteger(L, 3);
fixed_t x = (fixed_t)luaL_checkinteger(L, 4); fixed_t x = luaL_checkfixed(L, 4);
fixed_t y = (fixed_t)luaL_checkinteger(L, 5); fixed_t y = luaL_checkfixed(L, 5);
fixed_t z = (fixed_t)luaL_checkinteger(L, 6); fixed_t z = luaL_checkfixed(L, 6);
NOHUD NOHUD
if (!source || !dest) if (!source || !dest)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -298,13 +291,13 @@ static int lib_pSpawnXYZMissile(lua_State *L)
static int lib_pSpawnPointMissile(lua_State *L) static int lib_pSpawnPointMissile(lua_State *L)
{ {
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t xa = (fixed_t)luaL_checkinteger(L, 2); fixed_t xa = luaL_checkfixed(L, 2);
fixed_t ya = (fixed_t)luaL_checkinteger(L, 3); fixed_t ya = luaL_checkfixed(L, 3);
fixed_t za = (fixed_t)luaL_checkinteger(L, 4); fixed_t za = luaL_checkfixed(L, 4);
mobjtype_t type = luaL_checkinteger(L, 5); mobjtype_t type = luaL_checkinteger(L, 5);
fixed_t x = (fixed_t)luaL_checkinteger(L, 6); fixed_t x = luaL_checkfixed(L, 6);
fixed_t y = (fixed_t)luaL_checkinteger(L, 7); fixed_t y = luaL_checkfixed(L, 7);
fixed_t z = (fixed_t)luaL_checkinteger(L, 8); fixed_t z = luaL_checkfixed(L, 8);
NOHUD NOHUD
if (!source) if (!source)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -318,9 +311,9 @@ static int lib_pSpawnAlteredDirectionMissile(lua_State *L)
{ {
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobjtype_t type = luaL_checkinteger(L, 2); mobjtype_t type = luaL_checkinteger(L, 2);
fixed_t x = (fixed_t)luaL_checkinteger(L, 3); fixed_t x = luaL_checkfixed(L, 3);
fixed_t y = (fixed_t)luaL_checkinteger(L, 4); fixed_t y = luaL_checkfixed(L, 4);
fixed_t z = (fixed_t)luaL_checkinteger(L, 5); fixed_t z = luaL_checkfixed(L, 5);
INT32 shiftingAngle = (INT32)luaL_checkinteger(L, 5); INT32 shiftingAngle = (INT32)luaL_checkinteger(L, 5);
NOHUD NOHUD
if (!source) if (!source)
@ -348,7 +341,7 @@ static int lib_pSPMAngle(lua_State *L)
{ {
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobjtype_t type = luaL_checkinteger(L, 2); mobjtype_t type = luaL_checkinteger(L, 2);
angle_t angle = (angle_t)luaL_checkinteger(L, 3); angle_t angle = luaL_checkangle(L, 3);
UINT8 allowaim = (UINT8)luaL_optinteger(L, 4, 0); UINT8 allowaim = (UINT8)luaL_optinteger(L, 4, 0);
UINT32 flags2 = (UINT32)luaL_optinteger(L, 5, 0); UINT32 flags2 = (UINT32)luaL_optinteger(L, 5, 0);
NOHUD NOHUD
@ -418,13 +411,13 @@ static int lib_pGetClosestAxis(lua_State *L)
static int lib_pSpawnParaloop(lua_State *L) static int lib_pSpawnParaloop(lua_State *L)
{ {
fixed_t x = (fixed_t)luaL_checkinteger(L, 1); fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2); fixed_t y = luaL_checkfixed(L, 2);
fixed_t z = (fixed_t)luaL_checkinteger(L, 3); fixed_t z = luaL_checkfixed(L, 3);
fixed_t radius = (fixed_t)luaL_checkinteger(L, 4); fixed_t radius = luaL_checkfixed(L, 4);
INT32 number = (INT32)luaL_checkinteger(L, 5); INT32 number = (INT32)luaL_checkinteger(L, 5);
mobjtype_t type = luaL_checkinteger(L, 6); mobjtype_t type = luaL_checkinteger(L, 6);
angle_t rotangle = (angle_t)luaL_checkinteger(L, 7); angle_t rotangle = luaL_checkangle(L, 7);
statenum_t nstate = luaL_optinteger(L, 8, S_NULL); statenum_t nstate = luaL_optinteger(L, 8, S_NULL);
boolean spawncenter = lua_optboolean(L, 9); boolean spawncenter = lua_optboolean(L, 9);
NOHUD NOHUD
@ -458,7 +451,7 @@ static int lib_pSupermanLook4Players(lua_State *L)
static int lib_pSetScale(lua_State *L) static int lib_pSetScale(lua_State *L)
{ {
mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t newscale = (fixed_t)luaL_checkinteger(L, 2); fixed_t newscale = luaL_checkfixed(L, 2);
NOHUD NOHUD
if (!mobj) if (!mobj)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -526,7 +519,7 @@ static int lib_pGetPlayerHeight(lua_State *L)
//HUDSAFE //HUDSAFE
if (!player) if (!player)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
lua_pushinteger(L, P_GetPlayerHeight(player)); lua_pushfixed(L, P_GetPlayerHeight(player));
return 1; return 1;
} }
@ -536,7 +529,7 @@ static int lib_pGetPlayerSpinHeight(lua_State *L)
//HUDSAFE //HUDSAFE
if (!player) if (!player)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
lua_pushinteger(L, P_GetPlayerSpinHeight(player)); lua_pushfixed(L, P_GetPlayerSpinHeight(player));
return 1; return 1;
} }
@ -639,7 +632,7 @@ static int lib_pInQuicksand(lua_State *L)
static int lib_pSetObjectMomZ(lua_State *L) static int lib_pSetObjectMomZ(lua_State *L)
{ {
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t value = (fixed_t)luaL_checkinteger(L, 2); fixed_t value = luaL_checkfixed(L, 2);
boolean relative = lua_optboolean(L, 3); boolean relative = lua_optboolean(L, 3);
NOHUD NOHUD
if (!mo) if (!mo)
@ -753,8 +746,8 @@ static int lib_pDoPlayerExit(lua_State *L)
static int lib_pInstaThrust(lua_State *L) static int lib_pInstaThrust(lua_State *L)
{ {
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
angle_t angle = (angle_t)luaL_checkinteger(L, 2); angle_t angle = luaL_checkangle(L, 2);
fixed_t move = (fixed_t)luaL_checkinteger(L, 3); fixed_t move = luaL_checkfixed(L, 3);
NOHUD NOHUD
if (!mo) if (!mo)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -768,10 +761,10 @@ static int lib_pReturnThrustX(lua_State *L)
fixed_t move; fixed_t move;
if (lua_isnil(L, 1) || lua_isuserdata(L, 1)) if (lua_isnil(L, 1) || lua_isuserdata(L, 1))
lua_remove(L, 1); // ignore mobj as arg1 lua_remove(L, 1); // ignore mobj as arg1
angle = (angle_t)luaL_checkinteger(L, 1); angle = luaL_checkangle(L, 1);
move = (fixed_t)luaL_checkinteger(L, 2); move = luaL_checkfixed(L, 2);
//HUDSAFE //HUDSAFE
lua_pushinteger(L, P_ReturnThrustX(NULL, angle, move)); lua_pushfixed(L, P_ReturnThrustX(NULL, angle, move));
return 1; return 1;
} }
@ -781,10 +774,10 @@ static int lib_pReturnThrustY(lua_State *L)
fixed_t move; fixed_t move;
if (lua_isnil(L, 1) || lua_isuserdata(L, 1)) if (lua_isnil(L, 1) || lua_isuserdata(L, 1))
lua_remove(L, 1); // ignore mobj as arg1 lua_remove(L, 1); // ignore mobj as arg1
angle = (angle_t)luaL_checkinteger(L, 1); angle = luaL_checkangle(L, 1);
move = (fixed_t)luaL_checkinteger(L, 2); move = luaL_checkfixed(L, 2);
//HUDSAFE //HUDSAFE
lua_pushinteger(L, P_ReturnThrustY(NULL, angle, move)); lua_pushfixed(L, P_ReturnThrustY(NULL, angle, move));
return 1; return 1;
} }
@ -802,7 +795,7 @@ static int lib_pNukeEnemies(lua_State *L)
{ {
mobj_t *inflictor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *inflictor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
fixed_t radius = (fixed_t)luaL_checkinteger(L, 3); fixed_t radius = luaL_checkfixed(L, 3);
NOHUD NOHUD
if (!inflictor || !source) if (!inflictor || !source)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -868,8 +861,8 @@ static int lib_pSpawnSpinMobj(lua_State *L)
static int lib_pTelekinesis(lua_State *L) static int lib_pTelekinesis(lua_State *L)
{ {
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
fixed_t thrust = (fixed_t)luaL_checkinteger(L, 2); fixed_t thrust = luaL_checkfixed(L, 2);
fixed_t range = (fixed_t)luaL_checkinteger(L, 3); fixed_t range = luaL_checkfixed(L, 3);
NOHUD NOHUD
if (!player) if (!player)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
@ -884,8 +877,8 @@ static int lib_pCheckPosition(lua_State *L)
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = (fixed_t)luaL_checkinteger(L, 2); fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = (fixed_t)luaL_checkinteger(L, 3); fixed_t y = luaL_checkfixed(L, 3);
NOHUD NOHUD
if (!thing) if (!thing)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -899,8 +892,8 @@ static int lib_pTryMove(lua_State *L)
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = (fixed_t)luaL_checkinteger(L, 2); fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = (fixed_t)luaL_checkinteger(L, 3); fixed_t y = luaL_checkfixed(L, 3);
boolean allowdropoff = lua_optboolean(L, 4); boolean allowdropoff = lua_optboolean(L, 4);
NOHUD NOHUD
if (!thing) if (!thing)
@ -915,7 +908,7 @@ static int lib_pMove(lua_State *L)
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t speed = (fixed_t)luaL_checkinteger(L, 2); fixed_t speed = luaL_checkfixed(L, 2);
NOHUD NOHUD
if (!actor) if (!actor)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -929,9 +922,9 @@ static int lib_pTeleportMove(lua_State *L)
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = (fixed_t)luaL_checkinteger(L, 2); fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = (fixed_t)luaL_checkinteger(L, 3); fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = (fixed_t)luaL_checkinteger(L, 4); fixed_t z = luaL_checkfixed(L, 4);
NOHUD NOHUD
if (!thing) if (!thing)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -975,10 +968,10 @@ static int lib_pCheckSight(lua_State *L)
static int lib_pCheckHoopPosition(lua_State *L) static int lib_pCheckHoopPosition(lua_State *L)
{ {
mobj_t *hoopthing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *hoopthing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = (fixed_t)luaL_checkinteger(L, 2); fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = (fixed_t)luaL_checkinteger(L, 3); fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = (fixed_t)luaL_checkinteger(L, 4); fixed_t z = luaL_checkfixed(L, 4);
fixed_t radius = (fixed_t)luaL_checkinteger(L, 5); fixed_t radius = luaL_checkfixed(L, 5);
NOHUD NOHUD
if (!hoopthing) if (!hoopthing)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -990,7 +983,7 @@ static int lib_pRadiusAttack(lua_State *L)
{ {
mobj_t *spot = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *spot = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
fixed_t damagedist = (fixed_t)luaL_checkinteger(L, 3); fixed_t damagedist = luaL_checkfixed(L, 3);
NOHUD NOHUD
if (!spot || !source) if (!spot || !source)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -1000,12 +993,12 @@ static int lib_pRadiusAttack(lua_State *L)
static int lib_pFloorzAtPos(lua_State *L) static int lib_pFloorzAtPos(lua_State *L)
{ {
fixed_t x = (fixed_t)luaL_checkinteger(L, 1); fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2); fixed_t y = luaL_checkfixed(L, 2);
fixed_t z = (fixed_t)luaL_checkinteger(L, 3); fixed_t z = luaL_checkfixed(L, 3);
fixed_t height = (fixed_t)luaL_checkinteger(L, 4); fixed_t height = luaL_checkfixed(L, 4);
//HUDSAFE //HUDSAFE
lua_pushinteger(L, P_FloorzAtPos(x, y, z, height)); lua_pushfixed(L, P_FloorzAtPos(x, y, z, height));
return 1; return 1;
} }
@ -1209,8 +1202,8 @@ static int lib_pDoNightsScore(lua_State *L)
static int lib_pThrust(lua_State *L) static int lib_pThrust(lua_State *L)
{ {
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
angle_t angle = (angle_t)luaL_checkinteger(L, 2); angle_t angle = luaL_checkangle(L, 2);
fixed_t move = (fixed_t)luaL_checkinteger(L, 3); fixed_t move = luaL_checkfixed(L, 3);
NOHUD NOHUD
if (!mo) if (!mo)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
@ -1485,48 +1478,48 @@ static int lib_evCrumbleChain(lua_State *L)
static int lib_rPointToAngle(lua_State *L) static int lib_rPointToAngle(lua_State *L)
{ {
fixed_t x = (fixed_t)luaL_checkinteger(L, 1); fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2); fixed_t y = luaL_checkfixed(L, 2);
//HUDSAFE //HUDSAFE
lua_pushinteger(L, R_PointToAngle(x, y)); lua_pushangle(L, R_PointToAngle(x, y));
return 1; return 1;
} }
static int lib_rPointToAngle2(lua_State *L) static int lib_rPointToAngle2(lua_State *L)
{ {
fixed_t px2 = (fixed_t)luaL_checkinteger(L, 1); fixed_t px2 = luaL_checkfixed(L, 1);
fixed_t py2 = (fixed_t)luaL_checkinteger(L, 2); fixed_t py2 = luaL_checkfixed(L, 2);
fixed_t px1 = (fixed_t)luaL_checkinteger(L, 3); fixed_t px1 = luaL_checkfixed(L, 3);
fixed_t py1 = (fixed_t)luaL_checkinteger(L, 4); fixed_t py1 = luaL_checkfixed(L, 4);
//HUDSAFE //HUDSAFE
lua_pushinteger(L, R_PointToAngle2(px2, py2, px1, py1)); lua_pushangle(L, R_PointToAngle2(px2, py2, px1, py1));
return 1; return 1;
} }
static int lib_rPointToDist(lua_State *L) static int lib_rPointToDist(lua_State *L)
{ {
fixed_t x = (fixed_t)luaL_checkinteger(L, 1); fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2); fixed_t y = luaL_checkfixed(L, 2);
//HUDSAFE //HUDSAFE
lua_pushinteger(L, R_PointToDist(x, y)); lua_pushfixed(L, R_PointToDist(x, y));
return 1; return 1;
} }
static int lib_rPointToDist2(lua_State *L) static int lib_rPointToDist2(lua_State *L)
{ {
fixed_t px2 = (fixed_t)luaL_checkinteger(L, 1); fixed_t px2 = luaL_checkfixed(L, 1);
fixed_t py2 = (fixed_t)luaL_checkinteger(L, 2); fixed_t py2 = luaL_checkfixed(L, 2);
fixed_t px1 = (fixed_t)luaL_checkinteger(L, 3); fixed_t px1 = luaL_checkfixed(L, 3);
fixed_t py1 = (fixed_t)luaL_checkinteger(L, 4); fixed_t py1 = luaL_checkfixed(L, 4);
//HUDSAFE //HUDSAFE
lua_pushinteger(L, R_PointToDist2(px2, py2, px1, py1)); lua_pushfixed(L, R_PointToDist2(px2, py2, px1, py1));
return 1; return 1;
} }
static int lib_rPointInSubsector(lua_State *L) static int lib_rPointInSubsector(lua_State *L)
{ {
fixed_t x = (fixed_t)luaL_checkinteger(L, 1); fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2); fixed_t y = luaL_checkfixed(L, 2);
//HUDSAFE //HUDSAFE
LUA_PushUserdata(L, R_PointInSubsector(x, y), META_SUBSECTOR); LUA_PushUserdata(L, R_PointInSubsector(x, y), META_SUBSECTOR);
return 1; return 1;
@ -1660,7 +1653,7 @@ static int lib_sChangeMusic(lua_State *L)
static int lib_sSpeedMusic(lua_State *L) static int lib_sSpeedMusic(lua_State *L)
{ {
fixed_t fixedspeed = (fixed_t)luaL_checkinteger(L, 1); fixed_t fixedspeed = luaL_checkfixed(L, 1);
float speed = FIXED_TO_FLOAT(fixedspeed); float speed = FIXED_TO_FLOAT(fixedspeed);
player_t *player = NULL; player_t *player = NULL;
NOHUD NOHUD
@ -1861,7 +1854,6 @@ static int lib_gTicsToMilliseconds(lua_State *L)
static luaL_Reg lib[] = { static luaL_Reg lib[] = {
{"print", lib_print}, {"print", lib_print},
{"EvalMath", lib_evalMath},
// m_random // m_random
{"P_Random",lib_pRandom}, {"P_Random",lib_pRandom},

View File

@ -41,7 +41,7 @@ enum hook {
hook_BotAI, hook_BotAI,
hook_LinedefExecute, hook_LinedefExecute,
hook_PlayerMsg, hook_PlayerMsg,
hook_DeathMsg, hook_HurtMsg,
hook_MAX // last hook hook_MAX // last hook
}; };
@ -54,8 +54,9 @@ void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers)
boolean LUAh_MobjHook(mobj_t *mo, enum hook which); boolean LUAh_MobjHook(mobj_t *mo, enum hook which);
boolean LUAh_PlayerHook(player_t *plr, enum hook which); boolean LUAh_PlayerHook(player_t *plr, enum hook which);
#define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type #define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type
UINT8 LUAh_MobjCollide(mobj_t *thing1, mobj_t *thing2); // Hook for PIT_CheckThing by (thing) mobj type UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which);
UINT8 LUAh_MobjMoveCollide(mobj_t *thing1, mobj_t *thing2); // Hook for PIT_CheckThing by (tmthing) mobj type #define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type
#define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type
boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type
#define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type #define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type
#define LUAh_MobjThinker(mo) LUAh_MobjHook(mo, hook_MobjThinker) // Hook for P_MobjThinker or P_SceneryThinker by mobj type #define LUAh_MobjThinker(mo) LUAh_MobjHook(mo, hook_MobjThinker) // Hook for P_MobjThinker or P_SceneryThinker by mobj type
@ -73,6 +74,6 @@ boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd); // Hook for B_BuildTiccmd
boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_BuildTailsTiccmd by skin name boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_BuildTailsTiccmd by skin name
boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors
boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages
boolean LUAh_DeathMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -674,8 +674,6 @@ void LUAh_GameHUD(player_t *stplayr)
LUA_Call(gL, 3); LUA_Call(gL, 3);
} }
lua_pop(gL, -1); lua_pop(gL, -1);
lua_gc(gL, LUA_GCCOLLECT, 0);
hud_running = false; hud_running = false;
} }
@ -701,8 +699,6 @@ void LUAh_ScoresHUD(void)
LUA_Call(gL, 1); LUA_Call(gL, 1);
} }
lua_pop(gL, -1); lua_pop(gL, -1);
lua_gc(gL, LUA_GCCOLLECT, 0);
hud_running = false; hud_running = false;
} }

View File

@ -137,8 +137,6 @@ static void A_Lua(mobj_t *actor)
--superstack; --superstack;
superactions[superstack] = NULL; superactions[superstack] = NULL;
} }
lua_gc(gL, LUA_GCSTEP, 1);
} }
// Arbitrary states[] table index -> state_t * // Arbitrary states[] table index -> state_t *
@ -510,11 +508,11 @@ static int lib_setMobjInfo(lua_State *L)
else if (i == 15 || (str && fastcmp(str,"deathsound"))) else if (i == 15 || (str && fastcmp(str,"deathsound")))
info->deathsound = luaL_checkinteger(L, 3); info->deathsound = luaL_checkinteger(L, 3);
else if (i == 16 || (str && fastcmp(str,"speed"))) else if (i == 16 || (str && fastcmp(str,"speed")))
info->speed = (fixed_t)luaL_checkinteger(L, 3); info->speed = luaL_checkfixed(L, 3);
else if (i == 17 || (str && fastcmp(str,"radius"))) else if (i == 17 || (str && fastcmp(str,"radius")))
info->radius = (fixed_t)luaL_checkinteger(L, 3); info->radius = luaL_checkfixed(L, 3);
else if (i == 18 || (str && fastcmp(str,"height"))) else if (i == 18 || (str && fastcmp(str,"height")))
info->height = (fixed_t)luaL_checkinteger(L, 3); info->height = luaL_checkfixed(L, 3);
else if (i == 19 || (str && fastcmp(str,"dispoffset"))) else if (i == 19 || (str && fastcmp(str,"dispoffset")))
info->dispoffset = (INT32)luaL_checkinteger(L, 3); info->dispoffset = (INT32)luaL_checkinteger(L, 3);
else if (i == 20 || (str && fastcmp(str,"mass"))) else if (i == 20 || (str && fastcmp(str,"mass")))
@ -580,11 +578,11 @@ static int mobjinfo_get(lua_State *L)
else if (fastcmp(field,"deathsound")) else if (fastcmp(field,"deathsound"))
lua_pushinteger(L, info->deathsound); lua_pushinteger(L, info->deathsound);
else if (fastcmp(field,"speed")) else if (fastcmp(field,"speed"))
lua_pushinteger(L, info->speed); lua_pushinteger(L, info->speed); // sometimes it's fixed_t, sometimes it's not...
else if (fastcmp(field,"radius")) else if (fastcmp(field,"radius"))
lua_pushinteger(L, info->radius); lua_pushfixed(L, info->radius);
else if (fastcmp(field,"height")) else if (fastcmp(field,"height"))
lua_pushinteger(L, info->height); lua_pushfixed(L, info->height);
else if (fastcmp(field,"dispoffset")) else if (fastcmp(field,"dispoffset"))
lua_pushinteger(L, info->dispoffset); lua_pushinteger(L, info->dispoffset);
else if (fastcmp(field,"mass")) else if (fastcmp(field,"mass"))
@ -656,11 +654,11 @@ static int mobjinfo_set(lua_State *L)
else if (fastcmp(field,"deathsound")) else if (fastcmp(field,"deathsound"))
info->deathsound = luaL_checkinteger(L, 3); info->deathsound = luaL_checkinteger(L, 3);
else if (fastcmp(field,"speed")) else if (fastcmp(field,"speed"))
info->speed = (fixed_t)luaL_checkinteger(L, 3); info->speed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"radius")) else if (fastcmp(field,"radius"))
info->radius = (fixed_t)luaL_checkinteger(L, 3); info->radius = luaL_checkfixed(L, 3);
else if (fastcmp(field,"height")) else if (fastcmp(field,"height"))
info->height = (fixed_t)luaL_checkinteger(L, 3); info->height = luaL_checkfixed(L, 3);
else if (fastcmp(field,"dispoffset")) else if (fastcmp(field,"dispoffset"))
info->dispoffset = (INT32)luaL_checkinteger(L, 3); info->dispoffset = (INT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"mass")) else if (fastcmp(field,"mass"))

View File

@ -280,10 +280,10 @@ static int sector_get(lua_State *L)
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
return 1; return 1;
case sector_floorheight: case sector_floorheight:
lua_pushinteger(L, sector->floorheight); lua_pushfixed(L, sector->floorheight);
return 1; return 1;
case sector_ceilingheight: case sector_ceilingheight:
lua_pushinteger(L, sector->ceilingheight); lua_pushfixed(L, sector->ceilingheight);
return 1; return 1;
case sector_floorpic: { // floorpic case sector_floorpic: { // floorpic
levelflat_t *levelflat; levelflat_t *levelflat;
@ -396,26 +396,30 @@ static int sector_set(lua_State *L)
return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]); return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]);
case sector_floorheight: { // floorheight case sector_floorheight: { // floorheight
boolean flag; boolean flag;
mobj_t *ptmthing = tmthing;
fixed_t lastpos = sector->floorheight; fixed_t lastpos = sector->floorheight;
sector->floorheight = (fixed_t)luaL_checkinteger(L, 3); sector->floorheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true); flag = P_CheckSector(sector, true);
if (flag && sector->numattached) if (flag && sector->numattached)
{ {
sector->floorheight = lastpos; sector->floorheight = lastpos;
P_CheckSector(sector, true); P_CheckSector(sector, true);
} }
P_SetTarget(&tmthing, ptmthing);
break; break;
} }
case sector_ceilingheight: { // ceilingheight case sector_ceilingheight: { // ceilingheight
boolean flag; boolean flag;
mobj_t *ptmthing = tmthing;
fixed_t lastpos = sector->ceilingheight; fixed_t lastpos = sector->ceilingheight;
sector->ceilingheight = (fixed_t)luaL_checkinteger(L, 3); sector->ceilingheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true); flag = P_CheckSector(sector, true);
if (flag && sector->numattached) if (flag && sector->numattached)
{ {
sector->ceilingheight = lastpos; sector->ceilingheight = lastpos;
P_CheckSector(sector, true); P_CheckSector(sector, true);
} }
P_SetTarget(&tmthing, ptmthing);
break; break;
} }
case sector_floorpic: case sector_floorpic:
@ -509,10 +513,10 @@ static int line_get(lua_State *L)
LUA_PushUserdata(L, line->v2, META_VERTEX); LUA_PushUserdata(L, line->v2, META_VERTEX);
return 1; return 1;
case line_dx: case line_dx:
lua_pushinteger(L, line->dx); lua_pushfixed(L, line->dx);
return 1; return 1;
case line_dy: case line_dy:
lua_pushinteger(L, line->dy); lua_pushfixed(L, line->dy);
return 1; return 1;
case line_flags: case line_flags:
lua_pushinteger(L, line->flags); lua_pushinteger(L, line->flags);
@ -628,10 +632,10 @@ static int side_get(lua_State *L)
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
return 1; return 1;
case side_textureoffset: case side_textureoffset:
lua_pushinteger(L, side->textureoffset); lua_pushfixed(L, side->textureoffset);
return 1; return 1;
case side_rowoffset: case side_rowoffset:
lua_pushinteger(L, side->rowoffset); lua_pushfixed(L, side->rowoffset);
return 1; return 1;
case side_toptexture: case side_toptexture:
lua_pushinteger(L, side->toptexture); lua_pushinteger(L, side->toptexture);
@ -658,6 +662,50 @@ static int side_get(lua_State *L)
return 0; return 0;
} }
static int side_set(lua_State *L)
{
side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE));
enum side_e field = luaL_checkoption(L, 2, side_opt[0], side_opt);
if (!side)
{
if (field == side_valid) {
lua_pushboolean(L, 0);
return 1;
}
return luaL_error(L, "accessed side_t doesn't exist anymore.");
}
switch(field)
{
case side_valid: // valid
case side_sector:
case side_special:
case side_text:
default:
return luaL_error(L, "side_t field " LUA_QS " cannot be set.", side_opt[field]);
case side_textureoffset:
side->textureoffset = luaL_checkfixed(L, 3);
break;
case side_rowoffset:
side->rowoffset = luaL_checkfixed(L, 3);
break;
case side_toptexture:
side->toptexture = luaL_checkinteger(L, 3);
break;
case side_bottomtexture:
side->bottomtexture = luaL_checkinteger(L, 3);
break;
case side_midtexture:
side->midtexture = luaL_checkinteger(L, 3);
break;
case side_repeatcnt:
side->repeatcnt = luaL_checkinteger(L, 3);
break;
}
return 0;
}
static int side_num(lua_State *L) static int side_num(lua_State *L)
{ {
side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE)); side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE));
@ -685,13 +733,13 @@ static int vertex_get(lua_State *L)
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
return 1; return 1;
case vertex_x: case vertex_x:
lua_pushinteger(L, vertex->x); lua_pushfixed(L, vertex->x);
return 1; return 1;
case vertex_y: case vertex_y:
lua_pushinteger(L, vertex->y); lua_pushfixed(L, vertex->y);
return 1; return 1;
case vertex_z: case vertex_z:
lua_pushinteger(L, vertex->z); lua_pushfixed(L, vertex->z);
return 1; return 1;
} }
return 0; return 0;
@ -954,7 +1002,7 @@ static int ffloor_get(lua_State *L)
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
return 1; return 1;
case ffloor_topheight: case ffloor_topheight:
lua_pushinteger(L, *ffloor->topheight); lua_pushfixed(L, *ffloor->topheight);
return 1; return 1;
case ffloor_toppic: { // toppic case ffloor_toppic: { // toppic
levelflat_t *levelflat; levelflat_t *levelflat;
@ -968,7 +1016,7 @@ static int ffloor_get(lua_State *L)
lua_pushinteger(L, *ffloor->toplightlevel); lua_pushinteger(L, *ffloor->toplightlevel);
return 1; return 1;
case ffloor_bottomheight: case ffloor_bottomheight:
lua_pushinteger(L, *ffloor->bottomheight); lua_pushfixed(L, *ffloor->bottomheight);
return 1; return 1;
case ffloor_bottompic: { // bottompic case ffloor_bottompic: { // bottompic
levelflat_t *levelflat; levelflat_t *levelflat;
@ -1027,14 +1075,16 @@ static int ffloor_set(lua_State *L)
case ffloor_topheight: { // topheight case ffloor_topheight: { // topheight
boolean flag; boolean flag;
fixed_t lastpos = *ffloor->topheight; fixed_t lastpos = *ffloor->topheight;
mobj_t *ptmthing = tmthing;
sector_t *sector = &sectors[ffloor->secnum]; sector_t *sector = &sectors[ffloor->secnum];
sector->ceilingheight = (fixed_t)luaL_checkinteger(L, 3); sector->ceilingheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true); flag = P_CheckSector(sector, true);
if (flag && sector->numattached) if (flag && sector->numattached)
{ {
*ffloor->topheight = lastpos; *ffloor->topheight = lastpos;
P_CheckSector(sector, true); P_CheckSector(sector, true);
} }
P_SetTarget(&tmthing, ptmthing);
break; break;
} }
case ffloor_toppic: case ffloor_toppic:
@ -1046,14 +1096,16 @@ static int ffloor_set(lua_State *L)
case ffloor_bottomheight: { // bottomheight case ffloor_bottomheight: { // bottomheight
boolean flag; boolean flag;
fixed_t lastpos = *ffloor->bottomheight; fixed_t lastpos = *ffloor->bottomheight;
mobj_t *ptmthing = tmthing;
sector_t *sector = &sectors[ffloor->secnum]; sector_t *sector = &sectors[ffloor->secnum];
sector->floorheight = (fixed_t)luaL_checkinteger(L, 3); sector->floorheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true); flag = P_CheckSector(sector, true);
if (flag && sector->numattached) if (flag && sector->numattached)
{ {
*ffloor->bottomheight = lastpos; *ffloor->bottomheight = lastpos;
P_CheckSector(sector, true); P_CheckSector(sector, true);
} }
P_SetTarget(&tmthing, ptmthing);
break; break;
} }
case ffloor_bottompic: case ffloor_bottompic:
@ -1214,6 +1266,9 @@ int LUA_MapLib(lua_State *L)
lua_pushcfunction(L, side_get); lua_pushcfunction(L, side_get);
lua_setfield(L, -2, "__index"); lua_setfield(L, -2, "__index");
lua_pushcfunction(L, side_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, side_num); lua_pushcfunction(L, side_num);
lua_setfield(L, -2, "__len"); lua_setfield(L, -2, "__len");
lua_pop(L, 1); lua_pop(L, 1);

View File

@ -47,37 +47,37 @@ static int lib_max(lua_State *L)
static int lib_fixedangle(lua_State *L) static int lib_fixedangle(lua_State *L)
{ {
lua_pushinteger(L, FixedAngle((fixed_t)luaL_checkinteger(L, 1))); lua_pushangle(L, FixedAngle(luaL_checkfixed(L, 1)));
return 1; return 1;
} }
static int lib_anglefixed(lua_State *L) static int lib_anglefixed(lua_State *L)
{ {
lua_pushinteger(L, AngleFixed((angle_t)luaL_checkinteger(L, 1))); lua_pushfixed(L, AngleFixed(luaL_checkangle(L, 1)));
return 1; return 1;
} }
static int lib_invangle(lua_State *L) static int lib_invangle(lua_State *L)
{ {
lua_pushinteger(L, InvAngle((angle_t)luaL_checkinteger(L, 1))); lua_pushangle(L, InvAngle(luaL_checkangle(L, 1)));
return 1; return 1;
} }
static int lib_finesine(lua_State *L) static int lib_finesine(lua_State *L)
{ {
lua_pushinteger(L, FINESINE((luaL_checkinteger(L, 1)>>ANGLETOFINESHIFT) & FINEMASK)); lua_pushfixed(L, FINESINE((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
return 1; return 1;
} }
static int lib_finecosine(lua_State *L) static int lib_finecosine(lua_State *L)
{ {
lua_pushinteger(L, FINECOSINE((luaL_checkinteger(L, 1)>>ANGLETOFINESHIFT) & FINEMASK)); lua_pushfixed(L, FINECOSINE((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
return 1; return 1;
} }
static int lib_finetangent(lua_State *L) static int lib_finetangent(lua_State *L)
{ {
lua_pushinteger(L, FINETANGENT((luaL_checkinteger(L, 1)>>ANGLETOFINESHIFT) & FINEMASK)); lua_pushfixed(L, FINETANGENT((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
return 1; return 1;
} }
@ -86,61 +86,61 @@ static int lib_finetangent(lua_State *L)
static int lib_fixedmul(lua_State *L) static int lib_fixedmul(lua_State *L)
{ {
lua_pushinteger(L, FixedMul((fixed_t)luaL_checkinteger(L, 1), (fixed_t)luaL_checkinteger(L, 2))); lua_pushfixed(L, FixedMul(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1; return 1;
} }
static int lib_fixedint(lua_State *L) static int lib_fixedint(lua_State *L)
{ {
lua_pushinteger(L, FixedInt((fixed_t)luaL_checkinteger(L, 1))); lua_pushinteger(L, FixedInt(luaL_checkfixed(L, 1)));
return 1; return 1;
} }
static int lib_fixeddiv(lua_State *L) static int lib_fixeddiv(lua_State *L)
{ {
lua_pushinteger(L, FixedDiv((fixed_t)luaL_checkinteger(L, 1), (fixed_t)luaL_checkinteger(L, 2))); lua_pushfixed(L, FixedDiv(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1; return 1;
} }
static int lib_fixedrem(lua_State *L) static int lib_fixedrem(lua_State *L)
{ {
lua_pushinteger(L, FixedRem((fixed_t)luaL_checkinteger(L, 1), (fixed_t)luaL_checkinteger(L, 2))); lua_pushfixed(L, FixedRem(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1; return 1;
} }
static int lib_fixedsqrt(lua_State *L) static int lib_fixedsqrt(lua_State *L)
{ {
lua_pushinteger(L, FixedSqrt((fixed_t)luaL_checkinteger(L, 1))); lua_pushfixed(L, FixedSqrt(luaL_checkfixed(L, 1)));
return 1; return 1;
} }
static int lib_fixedhypot(lua_State *L) static int lib_fixedhypot(lua_State *L)
{ {
lua_pushinteger(L, FixedHypot((fixed_t)luaL_checkinteger(L, 1), (fixed_t)luaL_checkinteger(L, 2))); lua_pushfixed(L, FixedHypot(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1; return 1;
} }
static int lib_fixedfloor(lua_State *L) static int lib_fixedfloor(lua_State *L)
{ {
lua_pushinteger(L, FixedFloor((fixed_t)luaL_checkinteger(L, 1))); lua_pushfixed(L, FixedFloor(luaL_checkfixed(L, 1)));
return 1; return 1;
} }
static int lib_fixedtrunc(lua_State *L) static int lib_fixedtrunc(lua_State *L)
{ {
lua_pushinteger(L, FixedTrunc((fixed_t)luaL_checkinteger(L, 1))); lua_pushfixed(L, FixedTrunc(luaL_checkfixed(L, 1)));
return 1; return 1;
} }
static int lib_fixedceil(lua_State *L) static int lib_fixedceil(lua_State *L)
{ {
lua_pushinteger(L, FixedCeil((fixed_t)luaL_checkinteger(L, 1))); lua_pushfixed(L, FixedCeil(luaL_checkfixed(L, 1)));
return 1; return 1;
} }
static int lib_fixedround(lua_State *L) static int lib_fixedround(lua_State *L)
{ {
lua_pushinteger(L, FixedRound((fixed_t)luaL_checkinteger(L, 1))); lua_pushfixed(L, FixedRound(luaL_checkfixed(L, 1)));
return 1; return 1;
} }
@ -156,7 +156,7 @@ static int lib_getsecspecial(lua_State *L)
static int lib_all7emeralds(lua_State *L) static int lib_all7emeralds(lua_State *L)
{ {
lua_pushinteger(L, ALL7EMERALDS(luaL_checkinteger(L, 1))); lua_pushboolean(L, ALL7EMERALDS(luaL_checkinteger(L, 1)));
return 1; return 1;
} }

View File

@ -162,13 +162,13 @@ static int mobj_get(lua_State *L)
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
break; break;
case mobj_x: case mobj_x:
lua_pushinteger(L, mo->x); lua_pushfixed(L, mo->x);
break; break;
case mobj_y: case mobj_y:
lua_pushinteger(L, mo->y); lua_pushfixed(L, mo->y);
break; break;
case mobj_z: case mobj_z:
lua_pushinteger(L, mo->z); lua_pushfixed(L, mo->z);
break; break;
case mobj_snext: case mobj_snext:
LUA_PushUserdata(L, mo->snext, META_MOBJ); LUA_PushUserdata(L, mo->snext, META_MOBJ);
@ -179,7 +179,7 @@ static int mobj_get(lua_State *L)
// i.e. it will always ultimately point to THIS mobj -- so that's actually not useful to Lua and won't be included. // i.e. it will always ultimately point to THIS mobj -- so that's actually not useful to Lua and won't be included.
return UNIMPLEMENTED; return UNIMPLEMENTED;
case mobj_angle: case mobj_angle:
lua_pushinteger(L, mo->angle); lua_pushangle(L, mo->angle);
break; break;
case mobj_sprite: case mobj_sprite:
lua_pushinteger(L, mo->sprite); lua_pushinteger(L, mo->sprite);
@ -193,28 +193,28 @@ static int mobj_get(lua_State *L)
LUA_PushUserdata(L, mo->subsector, META_SUBSECTOR); LUA_PushUserdata(L, mo->subsector, META_SUBSECTOR);
break; break;
case mobj_floorz: case mobj_floorz:
lua_pushinteger(L, mo->floorz); lua_pushfixed(L, mo->floorz);
break; break;
case mobj_ceilingz: case mobj_ceilingz:
lua_pushinteger(L, mo->ceilingz); lua_pushfixed(L, mo->ceilingz);
break; break;
case mobj_radius: case mobj_radius:
lua_pushinteger(L, mo->radius); lua_pushfixed(L, mo->radius);
break; break;
case mobj_height: case mobj_height:
lua_pushinteger(L, mo->height); lua_pushfixed(L, mo->height);
break; break;
case mobj_momx: case mobj_momx:
lua_pushinteger(L, mo->momx); lua_pushfixed(L, mo->momx);
break; break;
case mobj_momy: case mobj_momy:
lua_pushinteger(L, mo->momy); lua_pushfixed(L, mo->momy);
break; break;
case mobj_momz: case mobj_momz:
lua_pushinteger(L, mo->momz); lua_pushfixed(L, mo->momz);
break; break;
case mobj_pmomz: case mobj_pmomz:
lua_pushinteger(L, mo->pmomz); lua_pushfixed(L, mo->pmomz);
break; break;
case mobj_tics: case mobj_tics:
lua_pushinteger(L, mo->tics); lua_pushinteger(L, mo->tics);
@ -299,32 +299,32 @@ static int mobj_get(lua_State *L)
LUA_PushUserdata(L, mo->tracer, META_MOBJ); LUA_PushUserdata(L, mo->tracer, META_MOBJ);
break; break;
case mobj_friction: case mobj_friction:
lua_pushinteger(L, mo->friction); lua_pushfixed(L, mo->friction);
break; break;
case mobj_movefactor: case mobj_movefactor:
lua_pushinteger(L, mo->movefactor); lua_pushfixed(L, mo->movefactor);
break; break;
case mobj_fuse: case mobj_fuse:
lua_pushinteger(L, mo->fuse); lua_pushinteger(L, mo->fuse);
break; break;
case mobj_watertop: case mobj_watertop:
lua_pushinteger(L, mo->watertop); lua_pushfixed(L, mo->watertop);
break; break;
case mobj_waterbottom: case mobj_waterbottom:
lua_pushinteger(L, mo->waterbottom); lua_pushfixed(L, mo->waterbottom);
break; break;
case mobj_mobjnum: case mobj_mobjnum:
// mobjnum is a networking thing generated for $$$.sav // mobjnum is a networking thing generated for $$$.sav
// and therefore shouldn't be used by Lua. // and therefore shouldn't be used by Lua.
return UNIMPLEMENTED; return UNIMPLEMENTED;
case mobj_scale: case mobj_scale:
lua_pushinteger(L, mo->scale); lua_pushfixed(L, mo->scale);
break; break;
case mobj_destscale: case mobj_destscale:
lua_pushinteger(L, mo->destscale); lua_pushfixed(L, mo->destscale);
break; break;
case mobj_scalespeed: case mobj_scalespeed:
lua_pushinteger(L, mo->scalespeed); lua_pushfixed(L, mo->scalespeed);
break; break;
case mobj_extravalue1: case mobj_extravalue1:
lua_pushinteger(L, mo->extravalue1); lua_pushinteger(L, mo->extravalue1);
@ -382,7 +382,7 @@ static int mobj_set(lua_State *L)
{ {
// z doesn't cross sector bounds so it's okay. // z doesn't cross sector bounds so it's okay.
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mo->z = (fixed_t)luaL_checkinteger(L, 3); mo->z = luaL_checkfixed(L, 3);
P_CheckPosition(mo, mo->x, mo->y); P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz; mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz; mo->ceilingz = tmceilingz;
@ -394,7 +394,7 @@ static int mobj_set(lua_State *L)
case mobj_sprev: case mobj_sprev:
return UNIMPLEMENTED; return UNIMPLEMENTED;
case mobj_angle: case mobj_angle:
mo->angle = (angle_t)luaL_checkinteger(L, 3); mo->angle = luaL_checkangle(L, 3);
if (mo->player == &players[consoleplayer]) if (mo->player == &players[consoleplayer])
localangle = mo->angle; localangle = mo->angle;
else if (mo->player == &players[secondarydisplayplayer]) else if (mo->player == &players[secondarydisplayplayer])
@ -417,7 +417,7 @@ static int mobj_set(lua_State *L)
case mobj_radius: case mobj_radius:
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mo->radius = (fixed_t)luaL_checkinteger(L, 3); mo->radius = luaL_checkfixed(L, 3);
if (mo->radius < 0) if (mo->radius < 0)
mo->radius = 0; mo->radius = 0;
P_CheckPosition(mo, mo->x, mo->y); P_CheckPosition(mo, mo->x, mo->y);
@ -429,7 +429,7 @@ static int mobj_set(lua_State *L)
case mobj_height: case mobj_height:
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mo->height = (fixed_t)luaL_checkinteger(L, 3); mo->height = luaL_checkfixed(L, 3);
if (mo->height < 0) if (mo->height < 0)
mo->height = 0; mo->height = 0;
P_CheckPosition(mo, mo->x, mo->y); P_CheckPosition(mo, mo->x, mo->y);
@ -439,16 +439,16 @@ static int mobj_set(lua_State *L)
break; break;
} }
case mobj_momx: case mobj_momx:
mo->momx = (fixed_t)luaL_checkinteger(L, 3); mo->momx = luaL_checkfixed(L, 3);
break; break;
case mobj_momy: case mobj_momy:
mo->momy = (fixed_t)luaL_checkinteger(L, 3); mo->momy = luaL_checkfixed(L, 3);
break; break;
case mobj_momz: case mobj_momz:
mo->momz = (fixed_t)luaL_checkinteger(L, 3); mo->momz = luaL_checkfixed(L, 3);
break; break;
case mobj_pmomz: case mobj_pmomz:
mo->pmomz = (fixed_t)luaL_checkinteger(L, 3); mo->pmomz = luaL_checkfixed(L, 3);
mo->eflags |= MFE_APPLYPMOMZ; mo->eflags |= MFE_APPLYPMOMZ;
break; break;
case mobj_tics: case mobj_tics:
@ -573,25 +573,25 @@ static int mobj_set(lua_State *L)
} }
break; break;
case mobj_friction: case mobj_friction:
mo->friction = (fixed_t)luaL_checkinteger(L, 3); mo->friction = luaL_checkfixed(L, 3);
break; break;
case mobj_movefactor: case mobj_movefactor:
mo->movefactor = (fixed_t)luaL_checkinteger(L, 3); mo->movefactor = luaL_checkfixed(L, 3);
break; break;
case mobj_fuse: case mobj_fuse:
mo->fuse = luaL_checkinteger(L, 3); mo->fuse = luaL_checkinteger(L, 3);
break; break;
case mobj_watertop: case mobj_watertop:
mo->watertop = (fixed_t)luaL_checkinteger(L, 3); mo->watertop = luaL_checkfixed(L, 3);
break; break;
case mobj_waterbottom: case mobj_waterbottom:
mo->waterbottom = (fixed_t)luaL_checkinteger(L, 3); mo->waterbottom = luaL_checkfixed(L, 3);
break; break;
case mobj_mobjnum: case mobj_mobjnum:
return UNIMPLEMENTED; return UNIMPLEMENTED;
case mobj_scale: case mobj_scale:
{ {
fixed_t scale = (fixed_t)luaL_checkinteger(L, 3); fixed_t scale = luaL_checkfixed(L, 3);
if (scale < FRACUNIT/100) if (scale < FRACUNIT/100)
scale = FRACUNIT/100; scale = FRACUNIT/100;
mo->destscale = scale; mo->destscale = scale;
@ -600,14 +600,14 @@ static int mobj_set(lua_State *L)
} }
case mobj_destscale: case mobj_destscale:
{ {
fixed_t scale = (fixed_t)luaL_checkinteger(L, 3); fixed_t scale = luaL_checkfixed(L, 3);
if (scale < FRACUNIT/100) if (scale < FRACUNIT/100)
scale = FRACUNIT/100; scale = FRACUNIT/100;
mo->destscale = scale; mo->destscale = scale;
break; break;
} }
case mobj_scalespeed: case mobj_scalespeed:
mo->scalespeed = (fixed_t)luaL_checkinteger(L, 3); mo->scalespeed = luaL_checkfixed(L, 3);
break; break;
case mobj_extravalue1: case mobj_extravalue1:
mo->extravalue1 = luaL_checkinteger(L, 3); mo->extravalue1 = luaL_checkinteger(L, 3);

View File

@ -109,15 +109,15 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"playerstate")) else if (fastcmp(field,"playerstate"))
lua_pushinteger(L, plr->playerstate); lua_pushinteger(L, plr->playerstate);
else if (fastcmp(field,"viewz")) else if (fastcmp(field,"viewz"))
lua_pushinteger(L, plr->viewz); lua_pushfixed(L, plr->viewz);
else if (fastcmp(field,"viewheight")) else if (fastcmp(field,"viewheight"))
lua_pushinteger(L, plr->viewheight); lua_pushfixed(L, plr->viewheight);
else if (fastcmp(field,"deltaviewheight")) else if (fastcmp(field,"deltaviewheight"))
lua_pushinteger(L, plr->deltaviewheight); lua_pushfixed(L, plr->deltaviewheight);
else if (fastcmp(field,"bob")) else if (fastcmp(field,"bob"))
lua_pushinteger(L, plr->bob); lua_pushfixed(L, plr->bob);
else if (fastcmp(field,"aiming")) else if (fastcmp(field,"aiming"))
lua_pushinteger(L, plr->aiming); lua_pushangle(L, plr->aiming);
else if (fastcmp(field,"health")) else if (fastcmp(field,"health"))
lua_pushinteger(L, plr->health); lua_pushinteger(L, plr->health);
else if (fastcmp(field,"pity")) else if (fastcmp(field,"pity"))
@ -141,13 +141,13 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"score")) else if (fastcmp(field,"score"))
lua_pushinteger(L, plr->score); lua_pushinteger(L, plr->score);
else if (fastcmp(field,"dashspeed")) else if (fastcmp(field,"dashspeed"))
lua_pushinteger(L, plr->dashspeed); lua_pushfixed(L, plr->dashspeed);
else if (fastcmp(field,"dashtime")) else if (fastcmp(field,"dashtime"))
lua_pushinteger(L, plr->dashtime); lua_pushinteger(L, plr->dashtime);
else if (fastcmp(field,"normalspeed")) else if (fastcmp(field,"normalspeed"))
lua_pushinteger(L, plr->normalspeed); lua_pushfixed(L, plr->normalspeed);
else if (fastcmp(field,"runspeed")) else if (fastcmp(field,"runspeed"))
lua_pushinteger(L, plr->runspeed); lua_pushfixed(L, plr->runspeed);
else if (fastcmp(field,"thrustfactor")) else if (fastcmp(field,"thrustfactor"))
lua_pushinteger(L, plr->thrustfactor); lua_pushinteger(L, plr->thrustfactor);
else if (fastcmp(field,"accelstart")) else if (fastcmp(field,"accelstart"))
@ -167,13 +167,13 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"revitem")) else if (fastcmp(field,"revitem"))
lua_pushinteger(L, plr->revitem); lua_pushinteger(L, plr->revitem);
else if (fastcmp(field,"actionspd")) else if (fastcmp(field,"actionspd"))
lua_pushinteger(L, plr->actionspd); lua_pushfixed(L, plr->actionspd);
else if (fastcmp(field,"mindash")) else if (fastcmp(field,"mindash"))
lua_pushinteger(L, plr->mindash); lua_pushfixed(L, plr->mindash);
else if (fastcmp(field,"maxdash")) else if (fastcmp(field,"maxdash"))
lua_pushinteger(L, plr->maxdash); lua_pushfixed(L, plr->maxdash);
else if (fastcmp(field,"jumpfactor")) else if (fastcmp(field,"jumpfactor"))
lua_pushinteger(L, plr->jumpfactor); lua_pushfixed(L, plr->jumpfactor);
else if (fastcmp(field,"lives")) else if (fastcmp(field,"lives"))
lua_pushinteger(L, plr->lives); lua_pushinteger(L, plr->lives);
else if (fastcmp(field,"continues")) else if (fastcmp(field,"continues"))
@ -183,7 +183,7 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"gotcontinue")) else if (fastcmp(field,"gotcontinue"))
lua_pushinteger(L, plr->gotcontinue); lua_pushinteger(L, plr->gotcontinue);
else if (fastcmp(field,"speed")) else if (fastcmp(field,"speed"))
lua_pushinteger(L, plr->speed); lua_pushfixed(L, plr->speed);
else if (fastcmp(field,"jumping")) else if (fastcmp(field,"jumping"))
lua_pushboolean(L, plr->jumping); lua_pushboolean(L, plr->jumping);
else if (fastcmp(field,"secondjump")) else if (fastcmp(field,"secondjump"))
@ -205,13 +205,13 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"skidtime")) else if (fastcmp(field,"skidtime"))
lua_pushinteger(L, plr->skidtime); lua_pushinteger(L, plr->skidtime);
else if (fastcmp(field,"cmomx")) else if (fastcmp(field,"cmomx"))
lua_pushinteger(L, plr->cmomx); lua_pushfixed(L, plr->cmomx);
else if (fastcmp(field,"cmomy")) else if (fastcmp(field,"cmomy"))
lua_pushinteger(L, plr->cmomy); lua_pushfixed(L, plr->cmomy);
else if (fastcmp(field,"rmomx")) else if (fastcmp(field,"rmomx"))
lua_pushinteger(L, plr->rmomx); lua_pushfixed(L, plr->rmomx);
else if (fastcmp(field,"rmomy")) else if (fastcmp(field,"rmomy"))
lua_pushinteger(L, plr->rmomy); lua_pushfixed(L, plr->rmomy);
else if (fastcmp(field,"numboxes")) else if (fastcmp(field,"numboxes"))
lua_pushinteger(L, plr->numboxes); lua_pushinteger(L, plr->numboxes);
else if (fastcmp(field,"totalring")) else if (fastcmp(field,"totalring"))
@ -239,11 +239,11 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"starposttime")) else if (fastcmp(field,"starposttime"))
lua_pushinteger(L, plr->starposttime); lua_pushinteger(L, plr->starposttime);
else if (fastcmp(field,"starpostangle")) else if (fastcmp(field,"starpostangle"))
lua_pushinteger(L, plr->starpostangle); lua_pushangle(L, plr->starpostangle);
else if (fastcmp(field,"angle_pos")) else if (fastcmp(field,"angle_pos"))
lua_pushinteger(L, plr->angle_pos); lua_pushangle(L, plr->angle_pos);
else if (fastcmp(field,"old_angle_pos")) else if (fastcmp(field,"old_angle_pos"))
lua_pushinteger(L, plr->old_angle_pos); lua_pushangle(L, plr->old_angle_pos);
else if (fastcmp(field,"axis1")) else if (fastcmp(field,"axis1"))
LUA_PushUserdata(L, plr->axis1, META_MOBJ); LUA_PushUserdata(L, plr->axis1, META_MOBJ);
else if (fastcmp(field,"axis2")) else if (fastcmp(field,"axis2"))
@ -305,16 +305,16 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"awayviewtics")) else if (fastcmp(field,"awayviewtics"))
lua_pushinteger(L, plr->awayviewtics); lua_pushinteger(L, plr->awayviewtics);
else if (fastcmp(field,"awayviewaiming")) else if (fastcmp(field,"awayviewaiming"))
lua_pushinteger(L, plr->awayviewaiming); lua_pushangle(L, plr->awayviewaiming);
else if (fastcmp(field,"spectator")) else if (fastcmp(field,"spectator"))
lua_pushinteger(L, plr->spectator); lua_pushboolean(L, plr->spectator);
else if (fastcmp(field,"bot")) else if (fastcmp(field,"bot"))
lua_pushinteger(L, plr->bot); lua_pushinteger(L, plr->bot);
else if (fastcmp(field,"jointime")) else if (fastcmp(field,"jointime"))
lua_pushinteger(L, plr->jointime); lua_pushinteger(L, plr->jointime);
#ifdef HWRENDER #ifdef HWRENDER
else if (fastcmp(field,"fovadd")) else if (fastcmp(field,"fovadd"))
lua_pushinteger(L, plr->fovadd); lua_pushfixed(L, plr->fovadd);
#endif #endif
else { else {
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
@ -354,15 +354,15 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"playerstate")) else if (fastcmp(field,"playerstate"))
plr->playerstate = luaL_checkinteger(L, 3); plr->playerstate = luaL_checkinteger(L, 3);
else if (fastcmp(field,"viewz")) else if (fastcmp(field,"viewz"))
plr->viewz = (fixed_t)luaL_checkinteger(L, 3); plr->viewz = luaL_checkfixed(L, 3);
else if (fastcmp(field,"viewheight")) else if (fastcmp(field,"viewheight"))
plr->viewheight = (fixed_t)luaL_checkinteger(L, 3); plr->viewheight = luaL_checkfixed(L, 3);
else if (fastcmp(field,"deltaviewheight")) else if (fastcmp(field,"deltaviewheight"))
plr->deltaviewheight = (fixed_t)luaL_checkinteger(L, 3); plr->deltaviewheight = luaL_checkfixed(L, 3);
else if (fastcmp(field,"bob")) else if (fastcmp(field,"bob"))
plr->bob = (fixed_t)luaL_checkinteger(L, 3); plr->bob = luaL_checkfixed(L, 3);
else if (fastcmp(field,"aiming")) { else if (fastcmp(field,"aiming")) {
plr->aiming = (angle_t)luaL_checkinteger(L, 3); plr->aiming = luaL_checkangle(L, 3);
if (plr == &players[consoleplayer]) if (plr == &players[consoleplayer])
localaiming = plr->aiming; localaiming = plr->aiming;
else if (plr == &players[secondarydisplayplayer]) else if (plr == &players[secondarydisplayplayer])
@ -391,13 +391,13 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"score")) else if (fastcmp(field,"score"))
plr->score = (UINT32)luaL_checkinteger(L, 3); plr->score = (UINT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"dashspeed")) else if (fastcmp(field,"dashspeed"))
plr->dashspeed = (fixed_t)luaL_checkinteger(L, 3); plr->dashspeed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"dashtime")) else if (fastcmp(field,"dashtime"))
plr->dashtime = (INT32)luaL_checkinteger(L, 3); plr->dashtime = (INT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"normalspeed")) else if (fastcmp(field,"normalspeed"))
plr->normalspeed = (fixed_t)luaL_checkinteger(L, 3); plr->normalspeed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"runspeed")) else if (fastcmp(field,"runspeed"))
plr->runspeed = (fixed_t)luaL_checkinteger(L, 3); plr->runspeed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"thrustfactor")) else if (fastcmp(field,"thrustfactor"))
plr->thrustfactor = (UINT8)luaL_checkinteger(L, 3); plr->thrustfactor = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"accelstart")) else if (fastcmp(field,"accelstart"))
@ -433,7 +433,7 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"gotcontinue")) else if (fastcmp(field,"gotcontinue"))
plr->gotcontinue = (UINT8)luaL_checkinteger(L, 3); plr->gotcontinue = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"speed")) else if (fastcmp(field,"speed"))
plr->speed = (fixed_t)luaL_checkinteger(L, 3); plr->speed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"jumping")) else if (fastcmp(field,"jumping"))
plr->jumping = luaL_checkboolean(L, 3); plr->jumping = luaL_checkboolean(L, 3);
else if (fastcmp(field,"secondjump")) else if (fastcmp(field,"secondjump"))
@ -455,13 +455,13 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"skidtime")) else if (fastcmp(field,"skidtime"))
plr->skidtime = (tic_t)luaL_checkinteger(L, 3); plr->skidtime = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"cmomx")) else if (fastcmp(field,"cmomx"))
plr->cmomx = (fixed_t)luaL_checkinteger(L, 3); plr->cmomx = luaL_checkfixed(L, 3);
else if (fastcmp(field,"cmomy")) else if (fastcmp(field,"cmomy"))
plr->cmomy = (fixed_t)luaL_checkinteger(L, 3); plr->cmomy = luaL_checkfixed(L, 3);
else if (fastcmp(field,"rmomx")) else if (fastcmp(field,"rmomx"))
plr->rmomx = (fixed_t)luaL_checkinteger(L, 3); plr->rmomx = luaL_checkfixed(L, 3);
else if (fastcmp(field,"rmomy")) else if (fastcmp(field,"rmomy"))
plr->rmomy = (fixed_t)luaL_checkinteger(L, 3); plr->rmomy = luaL_checkfixed(L, 3);
else if (fastcmp(field,"numboxes")) else if (fastcmp(field,"numboxes"))
plr->numboxes = (INT16)luaL_checkinteger(L, 3); plr->numboxes = (INT16)luaL_checkinteger(L, 3);
else if (fastcmp(field,"totalring")) else if (fastcmp(field,"totalring"))
@ -489,11 +489,11 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"starposttime")) else if (fastcmp(field,"starposttime"))
plr->starposttime = (tic_t)luaL_checkinteger(L, 3); plr->starposttime = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"starpostangle")) else if (fastcmp(field,"starpostangle"))
plr->starpostangle = (angle_t)luaL_checkinteger(L, 3); plr->starpostangle = luaL_checkangle(L, 3);
else if (fastcmp(field,"angle_pos")) else if (fastcmp(field,"angle_pos"))
plr->angle_pos = (angle_t)luaL_checkinteger(L, 3); plr->angle_pos = luaL_checkangle(L, 3);
else if (fastcmp(field,"old_angle_pos")) else if (fastcmp(field,"old_angle_pos"))
plr->old_angle_pos = (angle_t)luaL_checkinteger(L, 3); plr->old_angle_pos = luaL_checkangle(L, 3);
else if (fastcmp(field,"axis1")) else if (fastcmp(field,"axis1"))
P_SetTarget(&plr->axis1, *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ))); P_SetTarget(&plr->axis1, *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)));
else if (fastcmp(field,"axis2")) else if (fastcmp(field,"axis2"))
@ -569,7 +569,7 @@ static int player_set(lua_State *L)
P_SetTarget(&plr->awayviewmobj, plr->mo); // but since the script might set awayviewmobj immediately AFTER setting awayviewtics, use player mobj as filler for now. P_SetTarget(&plr->awayviewmobj, plr->mo); // but since the script might set awayviewmobj immediately AFTER setting awayviewtics, use player mobj as filler for now.
} }
else if (fastcmp(field,"awayviewaiming")) else if (fastcmp(field,"awayviewaiming"))
plr->awayviewaiming = (angle_t)luaL_checkinteger(L, 3); plr->awayviewaiming = luaL_checkangle(L, 3);
else if (fastcmp(field,"spectator")) else if (fastcmp(field,"spectator"))
plr->spectator = lua_toboolean(L, 3); plr->spectator = lua_toboolean(L, 3);
else if (fastcmp(field,"bot")) else if (fastcmp(field,"bot"))
@ -578,7 +578,7 @@ static int player_set(lua_State *L)
plr->jointime = (tic_t)luaL_checkinteger(L, 3); plr->jointime = (tic_t)luaL_checkinteger(L, 3);
#ifdef HWRENDER #ifdef HWRENDER
else if (fastcmp(field,"fovadd")) else if (fastcmp(field,"fovadd"))
plr->fovadd = (fixed_t)luaL_checkinteger(L, 3); plr->fovadd = luaL_checkfixed(L, 3);
#endif #endif
else { else {
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);

View File

@ -442,7 +442,6 @@ enum
ARCH_NULL=0, ARCH_NULL=0,
ARCH_BOOLEAN, ARCH_BOOLEAN,
ARCH_SIGNED, ARCH_SIGNED,
ARCH_UNSIGNED,
ARCH_STRING, ARCH_STRING,
ARCH_TABLE, ARCH_TABLE,
@ -522,13 +521,8 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex)
case LUA_TNUMBER: case LUA_TNUMBER:
{ {
lua_Integer number = lua_tointeger(gL, myindex); lua_Integer number = lua_tointeger(gL, myindex);
if (number < 0) { WRITEUINT8(save_p, ARCH_SIGNED);
WRITEUINT8(save_p, ARCH_SIGNED); WRITEFIXED(save_p, number);
WRITEFIXED(save_p, number);
} else {
WRITEUINT8(save_p, ARCH_UNSIGNED);
WRITEANGLE(save_p, number);
}
break; break;
} }
case LUA_TSTRING: case LUA_TSTRING:
@ -797,9 +791,6 @@ static UINT8 UnArchiveValue(int TABLESINDEX)
case ARCH_SIGNED: case ARCH_SIGNED:
lua_pushinteger(gL, READFIXED(save_p)); lua_pushinteger(gL, READFIXED(save_p));
break; break;
case ARCH_UNSIGNED:
lua_pushinteger(gL, READANGLE(save_p));
break;
case ARCH_STRING: case ARCH_STRING:
{ {
char value[1024]; char value[1024];
@ -948,6 +939,14 @@ static void NetArchiveHook(lua_CFunction archFunc)
lua_pop(gL, 2); lua_pop(gL, 2);
} }
void LUA_Step(void)
{
if (!gL)
return;
lua_settop(gL, 0);
lua_gc(gL, LUA_GCSTEP, 1);
}
void LUA_Archive(void) void LUA_Archive(void)
{ {
INT32 i; INT32 i;

View File

@ -19,9 +19,21 @@
#include "blua/lua.h" #include "blua/lua.h"
#include "blua/lualib.h" #include "blua/lualib.h"
#include "blua/lauxlib.h" #include "blua/lauxlib.h"
#define lua_optboolean(L, i) (!lua_isnoneornil(L, i) && lua_toboolean(L, i)) #define lua_optboolean(L, i) (!lua_isnoneornil(L, i) && lua_toboolean(L, i))
#define lua_opttrueboolean(L, i) (lua_isnoneornil(L, i) || lua_toboolean(L, i)) #define lua_opttrueboolean(L, i) (lua_isnoneornil(L, i) || lua_toboolean(L, i))
// fixed_t casting
// TODO add some distinction between fixed numbers and integer numbers
// for at least the purpose of printing and maybe math.
#define luaL_checkfixed(L, i) luaL_checkinteger(L, i)
#define lua_pushfixed(L, f) lua_pushinteger(L, f)
// angle_t casting
// we reduce the angle to a fixed point between 0.0 and 1.0
#define luaL_checkangle(L, i) (((angle_t)(luaL_checkfixed(L, i)&0xFFFF))<<16)
#define lua_pushangle(L, a) lua_pushfixed(L, a>>16)
#ifdef _DEBUG #ifdef _DEBUG
void LUA_ClearExtVars(void); void LUA_ClearExtVars(void);
#endif #endif
@ -36,6 +48,7 @@ void LUA_InvalidateUserdata(void *data);
void LUA_InvalidateLevel(void); void LUA_InvalidateLevel(void);
void LUA_InvalidateMapthings(void); void LUA_InvalidateMapthings(void);
void LUA_InvalidatePlayer(player_t *player); void LUA_InvalidatePlayer(player_t *player);
void LUA_Step(void);
void LUA_Archive(void); void LUA_Archive(void);
void LUA_UnArchive(void); void LUA_UnArchive(void);
void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c

View File

@ -147,19 +147,19 @@ static int skin_get(lua_State *L)
lua_pushinteger(L, skin->revitem); lua_pushinteger(L, skin->revitem);
break; break;
case skin_actionspd: case skin_actionspd:
lua_pushinteger(L, skin->actionspd); lua_pushfixed(L, skin->actionspd);
break; break;
case skin_mindash: case skin_mindash:
lua_pushinteger(L, skin->mindash); lua_pushfixed(L, skin->mindash);
break; break;
case skin_maxdash: case skin_maxdash:
lua_pushinteger(L, skin->maxdash); lua_pushfixed(L, skin->maxdash);
break; break;
case skin_normalspeed: case skin_normalspeed:
lua_pushinteger(L, skin->normalspeed); lua_pushfixed(L, skin->normalspeed);
break; break;
case skin_runspeed: case skin_runspeed:
lua_pushinteger(L, skin->runspeed); lua_pushfixed(L, skin->runspeed);
break; break;
case skin_thrustfactor: case skin_thrustfactor:
lua_pushinteger(L, skin->thrustfactor); lua_pushinteger(L, skin->thrustfactor);
@ -171,7 +171,7 @@ static int skin_get(lua_State *L)
lua_pushinteger(L, skin->acceleration); lua_pushinteger(L, skin->acceleration);
break; break;
case skin_jumpfactor: case skin_jumpfactor:
lua_pushinteger(L, skin->jumpfactor); lua_pushfixed(L, skin->jumpfactor);
break; break;
case skin_starttranscolor: case skin_starttranscolor:
lua_pushinteger(L, skin->starttranscolor); lua_pushinteger(L, skin->starttranscolor);

View File

@ -1478,7 +1478,7 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour
return; // Presumably it's obvious what's happening in splitscreen. return; // Presumably it's obvious what's happening in splitscreen.
#ifdef HAVE_BLUA #ifdef HAVE_BLUA
if (LUAh_DeathMsg(player, inflictor, source)) if (LUAh_HurtMsg(player, inflictor, source))
return; return;
#endif #endif