LunaCON: implement 'clearmapstate', fix 'resetplayerflags' parsing.

git-svn-id: https://svn.eduke32.com/eduke32@5231 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2015-05-25 12:57:44 +00:00
parent c6f0c467e3
commit fd94930f14
6 changed files with 36 additions and 6 deletions

View file

@ -94,6 +94,12 @@ function bcheck.level_idx(level)
end
end
function bcheck.linear_map_idx(idx)
if (not (idx >= 0 and idx <= con_lang.MAXLEVELS * con_lang.MAXVOLUMES)) then
error("invalid linear map index "..idx, 3)
end
end
function bcheck.quote_idx(qnum, onlyidx)
if (not (qnum >= 0 and qnum < con_lang.MAXQUOTES)) then
error("invalid quote number "..qnum, 3)

View file

@ -1946,6 +1946,11 @@ function _loadmapstate()
ffiC.G_RestoreMapState()
end
function _clearmapstate(idx)
bcheck.linear_map_idx(idx)
ffiC.G_FreeMapState(idx)
end
-- Gamevar persistence in the configuration file
function _savegamevar(name, val)

View file

@ -728,6 +728,7 @@ const char* G_PrintBestTime(void);
void G_UpdateScreenArea(void);
void G_SaveMapState(void);
void G_RestoreMapState(void);
void G_FreeMapState(int32_t mapnum);
]]
decl[[

View file

@ -249,4 +249,5 @@ G_PrintBestTime;
G_UpdateScreenArea;
G_SaveMapState;
G_RestoreMapState;
G_FreeMapState;
};

View file

@ -2727,7 +2727,7 @@ local Cinner = {
/ ACS":reset_acount()",
resetcount = cmd()
/ ACS":set_count(0)",
resetplayer = cmd() -- NLCF
resetplayer = cmd() * #sp1 -- NLCF
/ "if (_con._VM_ResetPlayer2(_pli,0)) then _con.longjmp() end",
resetplayerflags = cmd(R) -- NLCF
/ "if (_con._VM_ResetPlayer2(_pli,%1)) then _con.longjmp() end",
@ -2818,7 +2818,7 @@ local Cinner = {
-- Persistence
clearmapstate = cmd(R)
/ handle.NYI,
/ "_con._clearmapstate(%1)",
loadmapstate = cmd()
/ "_con._loadmapstate()",
savemapstate = cmd()

View file

@ -3,9 +3,10 @@
// To warp to a particular map, press the steroids key.
// Volume: player angle / 512, displayed on screen.
// Level: current weapon.
// Clear mapstate: press [QuickKick]
define Q 400
definequote Q ====== TEMP =======
define Q_tmp 400
definequote Q_tmp ====== TEMP =======
definequote 401 WILL WARP TO VOLUME %d
@ -24,6 +25,9 @@ definequote 412 <dest>
definequote 413 <dest>
definequote 414 <dest>
define Q_cms 500
definequote Q_cms Cleared mapstate for volume %d level %d
// Test gamevar flags GAMEVAR_NODEFAULT and GAMEVAR_NORESET.
// Global.
define GV_NODEFAULT 1024
@ -73,8 +77,8 @@ ends
onevent EVENT_DISPLAYREST
state calcvolume
qsprintf Q /*<-*/ 401 /**/ gs
gametext STARTALPHANUM 20 20 Q 0 0 0 0 0 xdim ydim
qsprintf Q_tmp /*<-*/ 401 /**/ gs
gametext STARTALPHANUM 20 20 Q_tmp 0 0 0 0 0 xdim ydim
setvar y 40
setvar dq 403
@ -148,6 +152,19 @@ onevent EVENT_USESTEROIDS
startlevel gs currentweapon
endevent
onevent EVENT_QUICKKICK
state calcvolume
qsprintf Q_tmp Q_cms gs currentweapon
userquote Q_tmp
// Calc linear map index.
mulvar gs 64 // MAXLEVELS (XXX: should be exposed via CON)
addvarvar gs currentweapon
clearmapstate gs
endevent
onevent EVENT_ENTERLEVEL
loadmapstate
endevent