Whoops, forgot about voices still being writable from kartvoice_t
which means kartvoice_t no longer has any writable fields, so gut the setter
This commit is contained in:
parent
891459b53b
commit
797b0adecd
1 changed files with 13 additions and 69 deletions
|
|
@ -9,8 +9,8 @@
|
|||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file lua_waypointslib.c
|
||||
/// \brief wapoint structure library for Lua scripting
|
||||
/// \file lua_voicelib.c
|
||||
/// \brief voice structure library for Lua scripting
|
||||
|
||||
#include "doomdef.h"
|
||||
#include "fastcmp.h"
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
enum voicevars
|
||||
{
|
||||
voicevars_id = 0,
|
||||
voicevars_name, // Not actually in kartvoice_t; returns the name of the voice
|
||||
voicevars_name,
|
||||
voicevars_win,
|
||||
voicevars_lose,
|
||||
voicevars_pain,
|
||||
|
|
@ -52,12 +52,7 @@ static const char *const voicevars_opt[] = {
|
|||
};
|
||||
|
||||
#define RNOFIELD luaL_error(L, LUA_QL("kartvoice_t") " has no field named " LUA_QS, field)
|
||||
|
||||
#define RNOSET luaL_error(L, LUA_QL("kartvoice_t") " field " LUA_QS " cannot be set.", field)
|
||||
#define RNOGET luaL_error(L, LUA_QL("kartvoice_t") " field " LUA_QS " cannot be get.", field)
|
||||
#define NOSET luaL_error(L, LUA_QL("kartvoice_t") " field " LUA_QS " should not be set directly.", field)
|
||||
|
||||
#define UNIMPLEMENTED luaL_error(L, LUA_QL("kartvoice_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", voicevars_opt[field])
|
||||
|
||||
static int voice_get(lua_State* L)
|
||||
{
|
||||
|
|
@ -105,64 +100,6 @@ static int voice_get(lua_State* L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int voice_set(lua_State* L)
|
||||
{
|
||||
kartvoice_t* voice = *((kartvoice_t**)luaL_checkudata(L, 1, META_VOICE));
|
||||
enum voicevars field = luaL_checkoption(L, 2, voicevars_opt[0], voicevars_opt);
|
||||
|
||||
// voices are always valid, only added, never removed
|
||||
I_Assert(voice != NULL);
|
||||
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter kartvoice_t in HUD rendering code!");
|
||||
if (hook_cmd_running)
|
||||
return luaL_error(L, "Do not alter kartvoice_t in CMD building code!");
|
||||
|
||||
lua_Integer i, k;
|
||||
|
||||
i = 0;
|
||||
k = sfx_thok;
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case voicevars_id:
|
||||
return RNOSET;
|
||||
case voicevars_name:
|
||||
return RNOSET;
|
||||
case voicevars_win:
|
||||
// For the actual sound values, you pass the actual sfxenum_t enums.
|
||||
// Yes, I know what I said about skin structs literally just above.
|
||||
voice->win = (sfxenum_t)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case voicevars_lose:
|
||||
voice->lose = (sfxenum_t)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case voicevars_pain:
|
||||
return NOSET;
|
||||
case voicevars_attack:
|
||||
return NOSET;
|
||||
case voicevars_boost:
|
||||
return NOSET;
|
||||
case voicevars_overtake:
|
||||
voice->overtake = (sfxenum_t)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case voicevars_hitem:
|
||||
voice->hitem = (sfxenum_t)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case voicevars_power:
|
||||
voice->power = (sfxenum_t)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
default:
|
||||
return RNOFIELD;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef RNOSET
|
||||
#undef RNOFIELD
|
||||
#undef UNIMPLEMENTED
|
||||
|
||||
static int voice_num(lua_State* L)
|
||||
{
|
||||
kartvoice_t* voice = *((kartvoice_t**)luaL_checkudata(L, 1, META_VOICE));
|
||||
|
|
@ -192,6 +129,11 @@ static int voice_array_set(lua_State *L)
|
|||
sfxenum_t *voice_array = *((sfxenum_t **)luaL_checkudata(L, 1, META_VOICE_ARRAY));
|
||||
INT32 i = luaL_checkinteger(L, 2);
|
||||
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter kartvoice_t.array[] in HUD rendering code!");
|
||||
if (hook_cmd_running)
|
||||
return luaL_error(L, "Do not alter kartvoice_t.array[] in CMD building code!");
|
||||
|
||||
if (i < 0 || i >= VOICEARRAYSIZE)
|
||||
return luaL_error(L, "index %d out of range (0 - %d)", i, VOICEARRAYSIZE-1);
|
||||
|
||||
|
|
@ -227,6 +169,11 @@ static int voice_array1_set(lua_State *L)
|
|||
sfxenum_t *voice_array = *((sfxenum_t **)luaL_checkudata(L, 1, META_VOICE_ARRAY1));
|
||||
INT32 i = luaL_checkinteger(L, 2);
|
||||
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter kartvoice_t.array[1] in HUD rendering code!");
|
||||
if (hook_cmd_running)
|
||||
return luaL_error(L, "Do not alter kartvoice_t.array[1] in CMD building code!");
|
||||
|
||||
if (i < 0 || i >= 1)
|
||||
return luaL_error(L, "index %d out of range (0 - %d)", i, 1-1);
|
||||
|
||||
|
|
@ -247,9 +194,6 @@ int LUA_VoiceLib(lua_State* L)
|
|||
lua_pushcfunction(L, voice_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
|
||||
lua_pushcfunction(L, voice_set);
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
|
||||
lua_pushcfunction(L, voice_num);
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue