2010-08-02 08:13:51 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010 EDuke32 developers and contributors
|
|
|
|
|
|
|
|
This file is part of EDuke32.
|
|
|
|
|
|
|
|
EDuke32 is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2014-07-20 08:55:56 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-08-02 08:13:51 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef gameexec_h_
|
|
|
|
#define gameexec_h_
|
2010-08-02 08:13:51 +00:00
|
|
|
|
2012-02-09 22:44:45 +00:00
|
|
|
#include "build.h"
|
2014-10-30 21:44:22 +00:00
|
|
|
#include "events_defs.h"
|
2018-11-18 18:09:48 +00:00
|
|
|
#include "gamedef.h" // vmstate_t
|
|
|
|
#include "sector.h" // mapstate_t
|
2012-02-09 22:44:45 +00:00
|
|
|
|
2019-09-21 20:53:00 +00:00
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
2019-05-19 03:53:25 +00:00
|
|
|
int32_t VM_ExecuteEvent(int const nEventID, int const spriteNum, int const playerNum, int const nDist, int32_t const nReturn);
|
|
|
|
int32_t VM_ExecuteEvent(int const nEventID, int const spriteNum, int const playerNum, int const nDist);
|
|
|
|
int32_t VM_ExecuteEvent(int const nEventID, int const spriteNum, int const playerNum);
|
|
|
|
int32_t VM_ExecuteEventWithValue(int const nEventID, int const spriteNum, int const playerNum, int32_t const nReturn);
|
|
|
|
|
|
|
|
static FORCE_INLINE bool VM_HaveEvent(int const nEventID)
|
|
|
|
{
|
|
|
|
return !!apScriptEvents[nEventID];
|
|
|
|
}
|
|
|
|
|
|
|
|
static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn)
|
|
|
|
{
|
|
|
|
return VM_HaveEvent(nEventID) ? VM_ExecuteEvent(nEventID, spriteNum, playerNum, nDist, nReturn) : nReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum, int nDist)
|
|
|
|
{
|
|
|
|
return VM_HaveEvent(nEventID) ? VM_ExecuteEvent(nEventID, spriteNum, playerNum, nDist) : 0;
|
|
|
|
}
|
|
|
|
|
2019-06-25 11:30:17 +00:00
|
|
|
static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum = -1, int playerNum = -1)
|
2019-05-19 03:53:25 +00:00
|
|
|
{
|
|
|
|
return VM_HaveEvent(nEventID) ? VM_ExecuteEvent(nEventID, spriteNum, playerNum) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int spriteNum, int playerNum, int32_t nReturn)
|
|
|
|
{
|
|
|
|
return VM_HaveEvent(nEventID) ? VM_ExecuteEventWithValue(nEventID, spriteNum, playerNum, nReturn) : nReturn;
|
|
|
|
}
|
|
|
|
|
2018-11-18 18:10:45 +00:00
|
|
|
enum vmflags_t
|
|
|
|
{
|
2019-05-19 03:53:25 +00:00
|
|
|
VM_RETURN = 0x00000001,
|
|
|
|
VM_KILL = 0x00000002,
|
|
|
|
VM_NOEXECUTE = 0x00000004,
|
2018-11-18 18:10:45 +00:00
|
|
|
};
|
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
extern int32_t ticrandomseed;
|
|
|
|
|
2013-02-07 21:00:52 +00:00
|
|
|
extern vmstate_t vm;
|
|
|
|
#if !defined LUNATIC
|
|
|
|
extern int32_t g_tw;
|
2018-11-18 18:11:44 +00:00
|
|
|
extern int32_t g_currentEvent;
|
2013-02-21 18:54:07 +00:00
|
|
|
|
2019-05-19 03:54:17 +00:00
|
|
|
void A_LoadActor(int const spriteNum);
|
2013-02-07 21:00:52 +00:00
|
|
|
#endif
|
2011-08-03 17:22:46 +00:00
|
|
|
|
2018-03-08 00:29:41 +00:00
|
|
|
extern uint32_t g_eventCalls[MAXEVENTS], g_actorCalls[MAXTILES];
|
|
|
|
extern double g_eventTotalMs[MAXEVENTS], g_actorTotalMs[MAXTILES], g_actorMinMs[MAXTILES], g_actorMaxMs[MAXTILES];
|
|
|
|
|
2016-09-06 04:25:32 +00:00
|
|
|
void A_Execute(int spriteNum, int playerNum, int playerDist);
|
2018-10-16 06:08:58 +00:00
|
|
|
void A_Fall(int spriteNum);
|
2019-05-19 03:54:17 +00:00
|
|
|
int A_GetFurthestAngle(int const spriteNum, int const angDiv);
|
2018-10-16 06:08:58 +00:00
|
|
|
void A_GetZLimits(int spriteNum);
|
2018-11-18 18:11:27 +00:00
|
|
|
int __fastcall G_GetAngleDelta(int currAngle, int newAngle);
|
2013-05-19 19:29:26 +00:00
|
|
|
void G_RestoreMapState();
|
|
|
|
void G_SaveMapState();
|
2014-10-25 03:33:53 +00:00
|
|
|
|
2019-04-18 17:25:38 +00:00
|
|
|
void VM_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32_t tilenum,
|
|
|
|
int32_t shade, int32_t orientation, int32_t p);
|
|
|
|
|
2016-02-13 21:05:57 +00:00
|
|
|
#if !defined LUNATIC
|
|
|
|
void VM_DrawTile(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation);
|
2019-04-18 17:25:38 +00:00
|
|
|
static inline void VM_DrawTilePal(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p)
|
|
|
|
{
|
|
|
|
VM_DrawTileGeneric(x, y, 65536, tilenum, shade, orientation, p);
|
|
|
|
}
|
|
|
|
static inline void VM_DrawTilePalSmall(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p)
|
|
|
|
{
|
|
|
|
VM_DrawTileGeneric(x, y, 32768, tilenum, shade, orientation, p);
|
|
|
|
}
|
2016-02-13 21:05:57 +00:00
|
|
|
void VM_DrawTileSmall(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation);
|
|
|
|
#endif
|
|
|
|
|
2019-11-05 19:07:16 +00:00
|
|
|
|
2012-09-05 17:25:47 +00:00
|
|
|
#define CON_ERRPRINTF(Text, ...) do { \
|
2018-11-18 18:10:45 +00:00
|
|
|
vm.flags |= VM_RETURN; \
|
2019-05-19 03:55:01 +00:00
|
|
|
OSD_Printf("Line %d, %s: " Text, VM_DECODE_LINE_NUMBER(g_tw), VM_GetKeywordForID(VM_DECODE_INST(g_tw)), ## __VA_ARGS__); \
|
2017-07-08 19:41:55 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define CON_CRITICALERRPRINTF(Text, ...) do { \
|
2018-11-18 18:10:45 +00:00
|
|
|
vm.flags |= VM_RETURN; \
|
2019-11-05 19:07:16 +00:00
|
|
|
I_Error("Line %d, %s: " Text, VM_DECODE_LINE_NUMBER(g_tw), VM_GetKeywordForID(VM_DECODE_INST(g_tw)), ## __VA_ARGS__); \
|
2012-11-15 14:28:04 +00:00
|
|
|
} while (0)
|
2012-09-05 17:25:47 +00:00
|
|
|
|
2018-10-16 06:08:58 +00:00
|
|
|
void G_GetTimeDate(int32_t * pValues);
|
|
|
|
int G_StartTrack(int levelNum);
|
2014-11-26 04:39:23 +00:00
|
|
|
|
2019-05-19 03:54:17 +00:00
|
|
|
void VM_UpdateAnim(int const spriteNum, int32_t * const pData);
|
2019-05-19 03:55:40 +00:00
|
|
|
void VM_GetZRange(int const spriteNum, int32_t * const ceilhit, int32_t * const florhit, int const wallDist);
|
2016-08-27 01:42:01 +00:00
|
|
|
|
2019-09-21 20:53:00 +00:00
|
|
|
END_DUKE_NS
|
|
|
|
|
2012-12-09 13:24:36 +00:00
|
|
|
#endif
|