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 gamevars_h_
|
|
|
|
#define gamevars_h_
|
2010-08-02 08:13:51 +00:00
|
|
|
|
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
|
|
|
#include "gamedef.h"
|
2018-03-07 04:21:31 +00:00
|
|
|
#include "fix16.hpp"
|
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
|
|
|
|
2012-12-12 02:53:08 +00:00
|
|
|
#define MAXGAMEVARS 2048 // must be a power of two
|
|
|
|
#define MAXVARLABEL 26
|
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
// store global game definitions
|
2016-08-27 01:40:06 +00:00
|
|
|
enum GamevarFlags_t
|
|
|
|
{
|
|
|
|
GAMEVAR_PERPLAYER = 0x00000001, // per-player variable
|
|
|
|
GAMEVAR_PERACTOR = 0x00000002, // per-actor variable
|
|
|
|
GAMEVAR_USER_MASK = (GAMEVAR_PERPLAYER | GAMEVAR_PERACTOR),
|
|
|
|
GAMEVAR_RESET = 0x00000008, // INTERNAL, don't use
|
|
|
|
GAMEVAR_DEFAULT = 0x00000100, // UNUSED, but always cleared for user-defined gamevars
|
|
|
|
GAMEVAR_NODEFAULT = 0x00000400, // don't reset on actor spawn
|
|
|
|
GAMEVAR_SYSTEM = 0x00000800, // cannot change mode flags...(only default value)
|
|
|
|
GAMEVAR_READONLY = 0x00001000, // values are read-only (no setvar allowed)
|
Syntax changes for gamevar and gamearray declarations:
Gamevar: default value and flags are now optional. A var declared without a value will default to 0 and a var declared without flags will default to global. Multiple flags can now be stacked one after another in a var declaration, and the most useful ones (GAMEVAR_PERPLAYER, GAMEVAR_PERACTOR, GAMEVAR_NODEFAULT, and GAMEVAR_NORESET) are now pre-defined tokens for easy use.
Gamearray: flags field now allows stacking of multiple flags as described above. Arrays can now be defined with specific data types, including int16_t, uint8_t, and a new bit-packed boolean data type. The tokens GAMEARRAY_RESTORE, GAMEARRAY_INT16, GAMEARRAY_UINT8, and GAMEARRAY_BOOLEAN are pre-defined for use of this feature.
This is all still pretty experimental.
git-svn-id: https://svn.eduke32.com/eduke32@6356 1a8010ca-5511-0410-912e-c29ae57300e0
2017-07-11 04:02:52 +00:00
|
|
|
GAMEVAR_INT32PTR = 0x00002000, // plValues is a pointer to an int32_t
|
|
|
|
GAMEVAR_INT16PTR = 0x00008000, // plValues is a pointer to a short
|
|
|
|
GAMEVAR_UINT8PTR = 0x00010000, // plValues is a pointer to a char
|
2016-08-27 01:40:06 +00:00
|
|
|
GAMEVAR_NORESET = 0x00020000, // var values are not reset when restoring map state
|
|
|
|
GAMEVAR_SPECIAL = 0x00040000, // flag for structure member shortcut vars
|
|
|
|
GAMEVAR_NOMULTI = 0x00080000, // don't attach to multiplayer packets
|
2018-03-07 04:21:31 +00:00
|
|
|
GAMEVAR_Q16PTR = 0x00100000, // plValues is a pointer to a q16.16
|
|
|
|
GAMEVAR_PTR_MASK = (GAMEVAR_INT32PTR | GAMEVAR_INT16PTR | GAMEVAR_UINT8PTR | GAMEVAR_Q16PTR),
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
2013-01-20 21:17:06 +00:00
|
|
|
#if !defined LUNATIC
|
|
|
|
|
2014-11-22 18:37:16 +00:00
|
|
|
// Alignments for per-player and per-actor variables.
|
2014-11-07 22:07:12 +00:00
|
|
|
#define PLAYER_VAR_ALIGNMENT (sizeof(intptr_t))
|
|
|
|
#define ACTOR_VAR_ALIGNMENT 16
|
|
|
|
|
2017-10-31 02:09:25 +00:00
|
|
|
#define ARRAY_ALIGNMENT 16
|
|
|
|
|
2014-12-26 17:29:56 +00:00
|
|
|
# define MAXGAMEARRAYS (MAXGAMEVARS>>2) // must be strictly smaller than MAXGAMEVARS
|
2013-05-19 19:29:18 +00:00
|
|
|
# define MAXARRAYLABEL MAXVARLABEL
|
2012-12-12 02:53:08 +00:00
|
|
|
|
2016-08-27 01:40:06 +00:00
|
|
|
enum GamearrayFlags_t
|
|
|
|
{
|
|
|
|
GAMEARRAY_RESET = 0x00000008,
|
|
|
|
GAMEARRAY_RESTORE = 0x00000010,
|
|
|
|
GAMEARRAY_VARSIZE = 0x00000020,
|
|
|
|
GAMEARRAY_STRIDE2 = 0x00000100,
|
2017-07-18 20:53:22 +00:00
|
|
|
GAMEARRAY_ALLOCATED = 0x00000200, // memory allocated for user array
|
2017-07-08 19:41:43 +00:00
|
|
|
GAMEARRAY_SYSTEM = 0x00000800,
|
Syntax changes for gamevar and gamearray declarations:
Gamevar: default value and flags are now optional. A var declared without a value will default to 0 and a var declared without flags will default to global. Multiple flags can now be stacked one after another in a var declaration, and the most useful ones (GAMEVAR_PERPLAYER, GAMEVAR_PERACTOR, GAMEVAR_NODEFAULT, and GAMEVAR_NORESET) are now pre-defined tokens for easy use.
Gamearray: flags field now allows stacking of multiple flags as described above. Arrays can now be defined with specific data types, including int16_t, uint8_t, and a new bit-packed boolean data type. The tokens GAMEARRAY_RESTORE, GAMEARRAY_INT16, GAMEARRAY_UINT8, and GAMEARRAY_BOOLEAN are pre-defined for use of this feature.
This is all still pretty experimental.
git-svn-id: https://svn.eduke32.com/eduke32@6356 1a8010ca-5511-0410-912e-c29ae57300e0
2017-07-11 04:02:52 +00:00
|
|
|
GAMEARRAY_READONLY = 0x00001000,
|
2017-07-18 20:53:22 +00:00
|
|
|
GAMEARRAY_INT16 = 0x00004000,
|
|
|
|
GAMEARRAY_INT8 = 0x00008000,
|
|
|
|
GAMEARRAY_UNSIGNED = 0x00010000,
|
|
|
|
GAMEARRAY_UINT16 = GAMEARRAY_INT16 | GAMEARRAY_UNSIGNED,
|
|
|
|
GAMEARRAY_UINT8 = GAMEARRAY_INT8 | GAMEARRAY_UNSIGNED,
|
Syntax changes for gamevar and gamearray declarations:
Gamevar: default value and flags are now optional. A var declared without a value will default to 0 and a var declared without flags will default to global. Multiple flags can now be stacked one after another in a var declaration, and the most useful ones (GAMEVAR_PERPLAYER, GAMEVAR_PERACTOR, GAMEVAR_NODEFAULT, and GAMEVAR_NORESET) are now pre-defined tokens for easy use.
Gamearray: flags field now allows stacking of multiple flags as described above. Arrays can now be defined with specific data types, including int16_t, uint8_t, and a new bit-packed boolean data type. The tokens GAMEARRAY_RESTORE, GAMEARRAY_INT16, GAMEARRAY_UINT8, and GAMEARRAY_BOOLEAN are pre-defined for use of this feature.
This is all still pretty experimental.
git-svn-id: https://svn.eduke32.com/eduke32@6356 1a8010ca-5511-0410-912e-c29ae57300e0
2017-07-11 04:02:52 +00:00
|
|
|
GAMEARRAY_BITMAP = 0x00100000,
|
|
|
|
GAMEARRAY_WARN = 0x00200000,
|
2017-07-08 19:41:36 +00:00
|
|
|
|
2017-07-28 08:27:31 +00:00
|
|
|
GAMEARRAY_SIZE_MASK = GAMEARRAY_INT8 | GAMEARRAY_INT16 | GAMEARRAY_BITMAP,
|
2017-07-18 20:53:22 +00:00
|
|
|
GAMEARRAY_TYPE_MASK = GAMEARRAY_UNSIGNED | GAMEARRAY_INT8 | GAMEARRAY_INT16 | GAMEARRAY_BITMAP,
|
2010-08-02 08:13:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(push,1)
|
2016-08-27 01:40:06 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-08-02 08:13:51 +00:00
|
|
|
union {
|
2016-08-27 01:40:35 +00:00
|
|
|
intptr_t global;
|
2016-08-27 01:40:06 +00:00
|
|
|
intptr_t *pValues; // array of values when 'per-player', or 'per-actor'
|
|
|
|
};
|
2016-08-27 01:40:35 +00:00
|
|
|
intptr_t defaultValue;
|
|
|
|
uintptr_t flags;
|
2016-08-27 01:40:06 +00:00
|
|
|
char * szLabel;
|
2010-08-02 08:13:51 +00:00
|
|
|
} gamevar_t;
|
|
|
|
|
2016-08-27 01:40:06 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char * szLabel;
|
|
|
|
intptr_t *pValues; // array of values
|
|
|
|
intptr_t size;
|
2016-08-27 01:40:35 +00:00
|
|
|
uintptr_t flags;
|
2010-08-02 08:13:51 +00:00
|
|
|
} gamearray_t;
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2016-08-27 01:40:06 +00:00
|
|
|
extern gamevar_t aGameVars[MAXGAMEVARS];
|
2010-08-02 08:13:51 +00:00
|
|
|
extern gamearray_t aGameArrays[MAXGAMEARRAYS];
|
2016-08-27 01:40:06 +00:00
|
|
|
extern int32_t g_gameVarCount;
|
|
|
|
extern int32_t g_gameArrayCount;
|
2010-08-02 08:13:51 +00:00
|
|
|
|
2017-07-27 10:08:52 +00:00
|
|
|
unsigned __fastcall Gv_GetArrayElementSize(int const arrayIdx);
|
2017-07-28 08:27:35 +00:00
|
|
|
size_t __fastcall Gv_GetArrayAllocSizeForCount(int const arrayIdx, size_t const count);
|
|
|
|
size_t __fastcall Gv_GetArrayAllocSize(int const arrayIdx);
|
|
|
|
size_t __fastcall Gv_GetArrayCountFromFile(int const arrayIdx, size_t const filelength);
|
2017-01-01 13:23:29 +00:00
|
|
|
int __fastcall Gv_GetArrayValue(int const id, int index);
|
|
|
|
int __fastcall Gv_GetVar(int id, int spriteNum, int playerNum);
|
|
|
|
void __fastcall Gv_SetVar(int const id, int const lValue, int const spriteNum, int const playerNum);
|
|
|
|
int __fastcall Gv_GetVarX(int id);
|
2016-08-27 01:40:06 +00:00
|
|
|
void __fastcall Gv_GetManyVars(int const count, int32_t * const rv);
|
2017-01-01 13:23:29 +00:00
|
|
|
void __fastcall Gv_SetVarX(int const id, int const lValue);
|
2012-12-29 15:21:24 +00:00
|
|
|
|
2017-07-05 05:38:11 +00:00
|
|
|
template <typename T>
|
|
|
|
static FORCE_INLINE void Gv_FillWithVars(T & rv)
|
|
|
|
{
|
|
|
|
EDUKE32_STATIC_ASSERT(sizeof(T) % sizeof(int32_t) == 0);
|
|
|
|
EDUKE32_STATIC_ASSERT(sizeof(T) > sizeof(int32_t));
|
|
|
|
Gv_GetManyVars(sizeof(T)/sizeof(int32_t), (int32_t *)&rv);
|
|
|
|
}
|
|
|
|
|
2017-01-01 13:23:29 +00:00
|
|
|
int Gv_GetVarByLabel(const char *szGameLabel,int const lDefault,int const spriteNum,int const playerNum);
|
2017-07-18 20:53:22 +00:00
|
|
|
void Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags);
|
|
|
|
void Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
|
2014-10-29 17:05:29 +00:00
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void A_ResetVars(int const spriteNum)
|
2014-11-22 12:29:25 +00:00
|
|
|
{
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t i = 0; i < g_gameVarCount; ++i)
|
2014-10-29 17:05:29 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if ((aGameVars[i].flags & (GAMEVAR_PERACTOR | GAMEVAR_NODEFAULT)) != GAMEVAR_PERACTOR)
|
2016-06-21 00:32:44 +00:00
|
|
|
continue;
|
2016-08-27 01:40:35 +00:00
|
|
|
aGameVars[i].pValues[spriteNum] = aGameVars[i].defaultValue;
|
2014-10-29 17:05:29 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-22 12:29:25 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
void Gv_DumpValues(void);
|
|
|
|
void Gv_InitWeaponPointers(void);
|
|
|
|
void Gv_RefreshPointers(void);
|
|
|
|
void Gv_ResetVars(void);
|
2016-08-27 01:40:56 +00:00
|
|
|
int Gv_ReadSave(int32_t kFile);
|
2016-08-27 01:40:35 +00:00
|
|
|
void Gv_WriteSave(FILE *fil);
|
2017-10-16 21:17:47 +00:00
|
|
|
void Gv_Clear(void);
|
2013-05-30 18:10:59 +00:00
|
|
|
#else
|
2014-01-31 21:13:03 +00:00
|
|
|
extern int32_t g_noResetVars;
|
2016-08-27 01:40:35 +00:00
|
|
|
extern LUNATIC_CB void (*A_ResetVars)(int32_t spriteNum);
|
2013-01-01 15:24:18 +00:00
|
|
|
#endif
|
2013-05-30 18:10:59 +00:00
|
|
|
|
2013-02-07 21:00:48 +00:00
|
|
|
void Gv_ResetSystemDefaults(void);
|
2013-01-01 15:24:18 +00:00
|
|
|
void Gv_Init(void);
|
2013-06-02 14:07:56 +00:00
|
|
|
void Gv_FinalizeWeaponDefaults(void);
|
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
|
|
|
|
2013-01-20 21:17:06 +00:00
|
|
|
#if !defined LUNATIC
|
Syntax changes for gamevar and gamearray declarations:
Gamevar: default value and flags are now optional. A var declared without a value will default to 0 and a var declared without flags will default to global. Multiple flags can now be stacked one after another in a var declaration, and the most useful ones (GAMEVAR_PERPLAYER, GAMEVAR_PERACTOR, GAMEVAR_NODEFAULT, and GAMEVAR_NORESET) are now pre-defined tokens for easy use.
Gamearray: flags field now allows stacking of multiple flags as described above. Arrays can now be defined with specific data types, including int16_t, uint8_t, and a new bit-packed boolean data type. The tokens GAMEARRAY_RESTORE, GAMEARRAY_INT16, GAMEARRAY_UINT8, and GAMEARRAY_BOOLEAN are pre-defined for use of this feature.
This is all still pretty experimental.
git-svn-id: https://svn.eduke32.com/eduke32@6356 1a8010ca-5511-0410-912e-c29ae57300e0
2017-07-11 04:02:52 +00:00
|
|
|
#define VM_GAMEVAR_OPERATOR(func, operator) \
|
|
|
|
static FORCE_INLINE void __fastcall func(int const id, int32_t const operand) \
|
|
|
|
{ \
|
|
|
|
switch (aGameVars[id].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \
|
|
|
|
{ \
|
|
|
|
default: aGameVars[id].global operator operand; break; \
|
|
|
|
case GAMEVAR_PERPLAYER: \
|
|
|
|
if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum > MAXPLAYERS - 1)) \
|
|
|
|
break; \
|
|
|
|
aGameVars[id].pValues[vm.playerNum] operator operand; \
|
|
|
|
break; \
|
|
|
|
case GAMEVAR_PERACTOR: \
|
|
|
|
if (EDUKE32_PREDICT_FALSE((unsigned)vm.spriteNum > MAXSPRITES - 1)) \
|
|
|
|
break; \
|
|
|
|
aGameVars[id].pValues[vm.spriteNum] operator operand; \
|
|
|
|
break; \
|
2018-03-07 04:21:31 +00:00
|
|
|
case GAMEVAR_INT32PTR: *(int32_t *)aGameVars[id].global operator(int32_t) operand; break; \
|
|
|
|
case GAMEVAR_INT16PTR: *(int16_t *)aGameVars[id].global operator(int16_t) operand; break; \
|
|
|
|
case GAMEVAR_UINT8PTR: *(uint8_t *)aGameVars[id].global operator(uint8_t) operand; break; \
|
|
|
|
case GAMEVAR_Q16PTR: \
|
|
|
|
{ \
|
|
|
|
Fix16 *pfix = (Fix16 *)aGameVars[id].global; \
|
|
|
|
*pfix operator operand; \
|
|
|
|
break; \
|
|
|
|
} \
|
Syntax changes for gamevar and gamearray declarations:
Gamevar: default value and flags are now optional. A var declared without a value will default to 0 and a var declared without flags will default to global. Multiple flags can now be stacked one after another in a var declaration, and the most useful ones (GAMEVAR_PERPLAYER, GAMEVAR_PERACTOR, GAMEVAR_NODEFAULT, and GAMEVAR_NORESET) are now pre-defined tokens for easy use.
Gamearray: flags field now allows stacking of multiple flags as described above. Arrays can now be defined with specific data types, including int16_t, uint8_t, and a new bit-packed boolean data type. The tokens GAMEARRAY_RESTORE, GAMEARRAY_INT16, GAMEARRAY_UINT8, and GAMEARRAY_BOOLEAN are pre-defined for use of this feature.
This is all still pretty experimental.
git-svn-id: https://svn.eduke32.com/eduke32@6356 1a8010ca-5511-0410-912e-c29ae57300e0
2017-07-11 04:02:52 +00:00
|
|
|
} \
|
2014-10-29 17:05:29 +00:00
|
|
|
}
|
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
|
|
|
|
2014-10-25 03:29:21 +00:00
|
|
|
#if defined(__arm__) || defined(LIBDIVIDE_ALWAYS)
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const operand)
|
2014-10-25 03:29:21 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if (EDUKE32_PREDICT_FALSE((aGameVars[id].flags & GAMEVAR_PERPLAYER && (unsigned) vm.playerNum > MAXPLAYERS - 1) ||
|
|
|
|
(aGameVars[id].flags & GAMEVAR_PERACTOR && (unsigned) vm.spriteNum > MAXSPRITES - 1)))
|
2016-06-21 00:32:44 +00:00
|
|
|
return;
|
|
|
|
|
2014-10-25 03:29:21 +00:00
|
|
|
static libdivide_s32_t sdiv;
|
2016-08-27 01:40:35 +00:00
|
|
|
static int32_t lastValue;
|
|
|
|
intptr_t *iptr = &aGameVars[id].global;
|
2018-01-29 02:14:00 +00:00
|
|
|
bool const foundInTable = (unsigned) operand < DIVTABLESIZE;
|
|
|
|
libdivide_s32_t *dptr = foundInTable ? (libdivide_s32_t *) &divtable32[operand] : &sdiv;
|
2014-10-25 03:29:21 +00:00
|
|
|
|
2018-01-29 02:14:00 +00:00
|
|
|
if (operand == lastValue || foundInTable)
|
2016-06-21 00:32:44 +00:00
|
|
|
goto skip;
|
2014-10-25 03:29:21 +00:00
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
sdiv = libdivide_s32_gen((lastValue = operand));
|
2014-10-25 03:29:21 +00:00
|
|
|
|
2016-06-21 00:32:44 +00:00
|
|
|
skip:
|
2016-08-27 01:40:35 +00:00
|
|
|
switch (aGameVars[id].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK))
|
2014-10-25 03:29:21 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
case GAMEVAR_PERPLAYER: iptr = &aGameVars[id].pValues[vm.playerNum];
|
2014-10-29 17:05:29 +00:00
|
|
|
default: break;
|
2016-08-27 01:40:35 +00:00
|
|
|
case GAMEVAR_PERACTOR: iptr = &aGameVars[id].pValues[vm.spriteNum]; break;
|
Syntax changes for gamevar and gamearray declarations:
Gamevar: default value and flags are now optional. A var declared without a value will default to 0 and a var declared without flags will default to global. Multiple flags can now be stacked one after another in a var declaration, and the most useful ones (GAMEVAR_PERPLAYER, GAMEVAR_PERACTOR, GAMEVAR_NODEFAULT, and GAMEVAR_NORESET) are now pre-defined tokens for easy use.
Gamearray: flags field now allows stacking of multiple flags as described above. Arrays can now be defined with specific data types, including int16_t, uint8_t, and a new bit-packed boolean data type. The tokens GAMEARRAY_RESTORE, GAMEARRAY_INT16, GAMEARRAY_UINT8, and GAMEARRAY_BOOLEAN are pre-defined for use of this feature.
This is all still pretty experimental.
git-svn-id: https://svn.eduke32.com/eduke32@6356 1a8010ca-5511-0410-912e-c29ae57300e0
2017-07-11 04:02:52 +00:00
|
|
|
case GAMEVAR_INT32PTR:
|
2018-01-29 02:14:00 +00:00
|
|
|
{
|
|
|
|
int32_t & var = *(int32_t *)aGameVars[id].global;
|
|
|
|
var = (int32_t)libdivide_s32_do(var, dptr);
|
2014-10-29 17:05:29 +00:00
|
|
|
return;
|
2018-01-29 02:14:00 +00:00
|
|
|
}
|
Syntax changes for gamevar and gamearray declarations:
Gamevar: default value and flags are now optional. A var declared without a value will default to 0 and a var declared without flags will default to global. Multiple flags can now be stacked one after another in a var declaration, and the most useful ones (GAMEVAR_PERPLAYER, GAMEVAR_PERACTOR, GAMEVAR_NODEFAULT, and GAMEVAR_NORESET) are now pre-defined tokens for easy use.
Gamearray: flags field now allows stacking of multiple flags as described above. Arrays can now be defined with specific data types, including int16_t, uint8_t, and a new bit-packed boolean data type. The tokens GAMEARRAY_RESTORE, GAMEARRAY_INT16, GAMEARRAY_UINT8, and GAMEARRAY_BOOLEAN are pre-defined for use of this feature.
This is all still pretty experimental.
git-svn-id: https://svn.eduke32.com/eduke32@6356 1a8010ca-5511-0410-912e-c29ae57300e0
2017-07-11 04:02:52 +00:00
|
|
|
case GAMEVAR_INT16PTR:
|
2018-01-29 02:14:00 +00:00
|
|
|
{
|
|
|
|
int16_t & var = *(int16_t *)aGameVars[id].global;
|
|
|
|
var = (int16_t)libdivide_s32_do(var, dptr);
|
2014-10-29 17:05:29 +00:00
|
|
|
return;
|
2018-01-29 02:14:00 +00:00
|
|
|
}
|
Syntax changes for gamevar and gamearray declarations:
Gamevar: default value and flags are now optional. A var declared without a value will default to 0 and a var declared without flags will default to global. Multiple flags can now be stacked one after another in a var declaration, and the most useful ones (GAMEVAR_PERPLAYER, GAMEVAR_PERACTOR, GAMEVAR_NODEFAULT, and GAMEVAR_NORESET) are now pre-defined tokens for easy use.
Gamearray: flags field now allows stacking of multiple flags as described above. Arrays can now be defined with specific data types, including int16_t, uint8_t, and a new bit-packed boolean data type. The tokens GAMEARRAY_RESTORE, GAMEARRAY_INT16, GAMEARRAY_UINT8, and GAMEARRAY_BOOLEAN are pre-defined for use of this feature.
This is all still pretty experimental.
git-svn-id: https://svn.eduke32.com/eduke32@6356 1a8010ca-5511-0410-912e-c29ae57300e0
2017-07-11 04:02:52 +00:00
|
|
|
case GAMEVAR_UINT8PTR:
|
2018-01-29 02:14:00 +00:00
|
|
|
{
|
|
|
|
uint8_t & var = *(uint8_t *)aGameVars[id].global;
|
|
|
|
var = (uint8_t)libdivide_s32_do(var, dptr);
|
2014-10-29 17:05:29 +00:00
|
|
|
return;
|
2018-01-29 02:14:00 +00:00
|
|
|
}
|
2018-03-07 04:21:31 +00:00
|
|
|
case GAMEVAR_Q16PTR:
|
|
|
|
{
|
|
|
|
fix16_t & var = *(fix16_t *)aGameVars[id].global;
|
|
|
|
var = fix16_div(var, fix16_from_int(operand));
|
|
|
|
return;
|
|
|
|
}
|
2014-10-25 03:29:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*iptr = libdivide_s32_do(*iptr, dptr);
|
|
|
|
}
|
|
|
|
#else
|
2014-10-29 17:05:29 +00:00
|
|
|
VM_GAMEVAR_OPERATOR(Gv_DivVar, /= )
|
2014-10-25 03:29:21 +00:00
|
|
|
#endif
|
|
|
|
|
2014-10-29 17:05:29 +00:00
|
|
|
VM_GAMEVAR_OPERATOR(Gv_AddVar, +=)
|
|
|
|
VM_GAMEVAR_OPERATOR(Gv_SubVar, -=)
|
|
|
|
VM_GAMEVAR_OPERATOR(Gv_MulVar, *=)
|
|
|
|
VM_GAMEVAR_OPERATOR(Gv_ModVar, %=)
|
|
|
|
VM_GAMEVAR_OPERATOR(Gv_AndVar, &=)
|
|
|
|
VM_GAMEVAR_OPERATOR(Gv_XorVar, ^=)
|
|
|
|
VM_GAMEVAR_OPERATOR(Gv_OrVar, |=)
|
2017-07-27 09:13:21 +00:00
|
|
|
VM_GAMEVAR_OPERATOR(Gv_ShiftVarL, <<=)
|
|
|
|
VM_GAMEVAR_OPERATOR(Gv_ShiftVarR, >>=)
|
2014-10-29 17:05:29 +00:00
|
|
|
|
|
|
|
#undef VM_GAMEVAR_OPERATOR
|
2014-10-25 03:29:21 +00:00
|
|
|
|
2013-01-20 21:17:06 +00:00
|
|
|
#endif
|
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
#endif
|