Massive readability cleanup of game code part 1. DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@5825 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-08-27 01:40:35 +00:00
parent 8e92183835
commit 52f678a743
45 changed files with 8693 additions and 8843 deletions

View file

@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
typedef int32_t instype;
typedef int32_t ofstype;
extern char *ScriptQuotes[MAXQUOTES+1], *ScriptQuoteRedefinitions[MAXQUOTES+1];
extern char *apStrings[MAXQUOTES+1], *apXStrings[MAXQUOTES+1];
extern int32_t g_numQuoteRedefinitions;
extern int32_t VM_Execute(int32_t once);
@ -58,7 +58,7 @@ extern void SetGamePalette(int32_t);
extern int32_t *constants, constants_allocsize;
extern int32_t g_numSavedConstants;
extern instype *script ,*insptr;
extern instype *apScript ,*insptr;
extern int32_t *labelval;
extern uint8_t *labeltype;
extern int32_t g_numLabels, g_numDefaultLabels;

View file

@ -310,174 +310,174 @@ static const char *
mode_desc (int mode) /* for debugging messages */
{
switch (mode) {
# define SS(X) case GL_##X: return STRINGIFY(X);
SS(ALPHA)
SS(ALPHA_TEST)
SS(AMBIENT)
SS(AMBIENT_AND_DIFFUSE)
SS(ARRAY_BUFFER)
SS(AUTO_NORMAL)
SS(BACK)
SS(BLEND)
SS(BLEND_DST)
SS(BLEND_SRC)
SS(BLEND_SRC_ALPHA)
SS(BYTE)
SS(C3F_V3F)
SS(C4F_N3F_V3F)
SS(C4UB_V2F)
SS(C4UB_V3F)
SS(CCW)
SS(CLAMP)
SS(COLOR_ARRAY)
SS(COLOR_ARRAY_BUFFER_BINDING);
SS(COLOR_MATERIAL)
SS(COLOR_MATERIAL_FACE)
SS(COLOR_MATERIAL_PARAMETER)
SS(COMPILE)
SS(CULL_FACE)
SS(CW)
SS(DECAL)
SS(DEPTH_BUFFER_BIT)
SS(DEPTH_TEST)
SS(DIFFUSE)
SS(DOUBLEBUFFER)
SS(DST_ALPHA)
SS(DST_COLOR)
SS(DYNAMIC_DRAW)
SS(ELEMENT_ARRAY_BUFFER)
SS(EYE_LINEAR)
SS(EYE_PLANE)
SS(FEEDBACK)
SS(FILL)
SS(FLAT)
SS(FLOAT)
SS(FOG)
SS(FRONT)
SS(FRONT_AND_BACK)
SS(GREATER)
SS(INTENSITY)
SS(INVALID_ENUM)
SS(INVALID_OPERATION)
SS(INVALID_VALUE)
SS(LESS)
SS(LIGHT0)
SS(LIGHT1)
SS(LIGHT2)
SS(LIGHT3)
SS(LIGHTING)
SS(LIGHT_MODEL_AMBIENT)
SS(LIGHT_MODEL_COLOR_CONTROL)
SS(LIGHT_MODEL_LOCAL_VIEWER)
SS(LIGHT_MODEL_TWO_SIDE)
SS(LINE)
SS(LINEAR)
SS(LINEAR_MIPMAP_LINEAR)
SS(LINEAR_MIPMAP_NEAREST)
SS(LINES)
SS(LINE_LOOP)
SS(LINE_STRIP)
SS(LUMINANCE)
SS(LUMINANCE_ALPHA)
SS(MATRIX_MODE)
SS(MODELVIEW)
SS(MODULATE)
SS(N3F_V3F)
SS(NEAREST)
SS(NEAREST_MIPMAP_LINEAR)
SS(NEAREST_MIPMAP_NEAREST)
SS(NORMALIZE)
SS(NORMAL_ARRAY)
SS(NORMAL_ARRAY_BUFFER_BINDING);
SS(OBJECT_LINEAR)
SS(OBJECT_PLANE)
SS(ONE_MINUS_DST_ALPHA)
SS(ONE_MINUS_DST_COLOR)
SS(ONE_MINUS_SRC_ALPHA)
SS(ONE_MINUS_SRC_COLOR)
SS(OUT_OF_MEMORY)
SS(PACK_ALIGNMENT)
SS(POINTS)
SS(POLYGON)
SS(POLYGON_OFFSET_FILL)
SS(POLYGON_SMOOTH)
SS(POLYGON_STIPPLE)
SS(POSITION)
SS(PROJECTION)
SS(Q)
SS(QUADS)
SS(QUAD_STRIP)
SS(R)
SS(RENDER)
SS(REPEAT)
SS(RGB)
SS(RGBA)
SS(RGBA_MODE)
SS(S)
SS(SELECT)
SS(SEPARATE_SPECULAR_COLOR)
SS(SHADE_MODEL)
SS(SHININESS)
SS(SHORT)
SS(SINGLE_COLOR)
SS(SMOOTH)
SS(SPECULAR)
SS(SPHERE_MAP)
SS(SRC_ALPHA)
SS(SRC_ALPHA_SATURATE)
SS(SRC_COLOR)
SS(STACK_OVERFLOW)
SS(STACK_UNDERFLOW)
SS(STATIC_DRAW)
SS(STENCIL_BUFFER_BIT)
SS(T)
SS(T2F_C3F_V3F)
SS(T2F_C4F_N3F_V3F)
SS(T2F_C4UB_V3F)
SS(T2F_N3F_V3F)
SS(T2F_V3F)
SS(T4F_C4F_N3F_V4F)
SS(T4F_V4F)
SS(TEXTURE)
SS(TEXTURE_1D)
SS(TEXTURE_2D)
SS(TEXTURE_ALPHA_SIZE)
SS(TEXTURE_BINDING_2D)
SS(TEXTURE_BLUE_SIZE)
SS(TEXTURE_BORDER)
SS(TEXTURE_BORDER_COLOR)
SS(TEXTURE_COMPONENTS)
SS(TEXTURE_COORD_ARRAY)
SS(TEXTURE_COORD_ARRAY_BUFFER_BINDING);
SS(TEXTURE_ENV)
SS(TEXTURE_ENV_COLOR)
SS(TEXTURE_ENV_MODE)
SS(TEXTURE_GEN_MODE)
SS(TEXTURE_GEN_Q)
SS(TEXTURE_GEN_R)
SS(TEXTURE_GEN_S)
SS(TEXTURE_GEN_T)
SS(TEXTURE_GREEN_SIZE)
SS(TEXTURE_HEIGHT)
SS(TEXTURE_INTENSITY_SIZE)
SS(TEXTURE_LUMINANCE_SIZE)
SS(TEXTURE_MAG_FILTER)
SS(TEXTURE_MIN_FILTER)
SS(TEXTURE_RED_SIZE)
SS(TEXTURE_WRAP_S)
SS(TEXTURE_WRAP_T)
SS(TRIANGLES)
SS(TRIANGLE_FAN)
SS(TRIANGLE_STRIP)
SS(UNPACK_ALIGNMENT)
SS(UNPACK_ROW_LENGTH)
SS(UNSIGNED_BYTE)
SS(UNSIGNED_INT_8_8_8_8_REV)
SS(UNSIGNED_SHORT)
SS(V2F)
SS(V3F)
SS(VERTEX_ARRAY)
SS(VERTEX_ARRAY_BUFFER_BINDING);
# define SS(i)(X) case GL_##X: return STRINGIFY(X);
SS(i)(ALPHA)
SS(i)(ALPHA_TEST)
SS(i)(AMBIENT)
SS(i)(AMBIENT_AND_DIFFUSE)
SS(i)(ARRAY_BUFFER)
SS(i)(AUTO_NORMAL)
SS(i)(BACK)
SS(i)(BLEND)
SS(i)(BLEND_DST)
SS(i)(BLEND_SRC)
SS(i)(BLEND_SRC_ALPHA)
SS(i)(BYTE)
SS(i)(C3F_V3F)
SS(i)(C4F_N3F_V3F)
SS(i)(C4UB_V2F)
SS(i)(C4UB_V3F)
SS(i)(CCW)
SS(i)(CLAMP)
SS(i)(COLOR_ARRAY)
SS(i)(COLOR_ARRAY_BUFFER_BINDING);
SS(i)(COLOR_MATERIAL)
SS(i)(COLOR_MATERIAL_FACE)
SS(i)(COLOR_MATERIAL_PARAMETER)
SS(i)(COMPILE)
SS(i)(CULL_FACE)
SS(i)(CW)
SS(i)(DECAL)
SS(i)(DEPTH_BUFFER_BIT)
SS(i)(DEPTH_TEST)
SS(i)(DIFFUSE)
SS(i)(DOUBLEBUFFER)
SS(i)(DST_ALPHA)
SS(i)(DST_COLOR)
SS(i)(DYNAMIC_DRAW)
SS(i)(ELEMENT_ARRAY_BUFFER)
SS(i)(EYE_LINEAR)
SS(i)(EYE_PLANE)
SS(i)(FEEDBACK)
SS(i)(FILL)
SS(i)(FLAT)
SS(i)(FLOAT)
SS(i)(FOG)
SS(i)(FRONT)
SS(i)(FRONT_AND_BACK)
SS(i)(GREATER)
SS(i)(INTENSITY)
SS(i)(INVALID_ENUM)
SS(i)(INVALID_OPERATION)
SS(i)(INVALID_VALUE)
SS(i)(LESS)
SS(i)(LIGHT0)
SS(i)(LIGHT1)
SS(i)(LIGHT2)
SS(i)(LIGHT3)
SS(i)(LIGHTING)
SS(i)(LIGHT_MODEL_AMBIENT)
SS(i)(LIGHT_MODEL_COLOR_CONTROL)
SS(i)(LIGHT_MODEL_LOCAL_VIEWER)
SS(i)(LIGHT_MODEL_TWO_SIDE)
SS(i)(LINE)
SS(i)(LINEAR)
SS(i)(LINEAR_MIPMAP_LINEAR)
SS(i)(LINEAR_MIPMAP_NEAREST)
SS(i)(LINES)
SS(i)(LINE_LOOP)
SS(i)(LINE_STRIP)
SS(i)(LUMINANCE)
SS(i)(LUMINANCE_ALPHA)
SS(i)(MATRIX_MODE)
SS(i)(MODELVIEW)
SS(i)(MODULATE)
SS(i)(N3F_V3F)
SS(i)(NEAREST)
SS(i)(NEAREST_MIPMAP_LINEAR)
SS(i)(NEAREST_MIPMAP_NEAREST)
SS(i)(NORMALIZE)
SS(i)(NORMAL_ARRAY)
SS(i)(NORMAL_ARRAY_BUFFER_BINDING);
SS(i)(OBJECT_LINEAR)
SS(i)(OBJECT_PLANE)
SS(i)(ONE_MINUS_DST_ALPHA)
SS(i)(ONE_MINUS_DST_COLOR)
SS(i)(ONE_MINUS_SRC_ALPHA)
SS(i)(ONE_MINUS_SRC_COLOR)
SS(i)(OUT_OF_MEMORY)
SS(i)(PACK_ALIGNMENT)
SS(i)(POINTS)
SS(i)(POLYGON)
SS(i)(POLYGON_OFFSET_FILL)
SS(i)(POLYGON_SMOOTH)
SS(i)(POLYGON_STIPPLE)
SS(i)(POSITION)
SS(i)(PROJECTION)
SS(i)(Q)
SS(i)(QUADS)
SS(i)(QUAD_STRIP)
SS(i)(R)
SS(i)(RENDER)
SS(i)(REPEAT)
SS(i)(RGB)
SS(i)(RGBA)
SS(i)(RGBA_MODE)
SS(i)(S)
SS(i)(SELECT)
SS(i)(SEPARATE_SPECULAR_COLOR)
SS(i)(SHADE_MODEL)
SS(i)(SHININESS)
SS(i)(SHORT)
SS(i)(SINGLE_COLOR)
SS(i)(SMOOTH)
SS(i)(SPECULAR)
SS(i)(SPHERE_MAP)
SS(i)(SRC_ALPHA)
SS(i)(SRC_ALPHA_SATURATE)
SS(i)(SRC_COLOR)
SS(i)(STACK_OVERFLOW)
SS(i)(STACK_UNDERFLOW)
SS(i)(STATIC_DRAW)
SS(i)(STENCIL_BUFFER_BIT)
SS(i)(T)
SS(i)(T2F_C3F_V3F)
SS(i)(T2F_C4F_N3F_V3F)
SS(i)(T2F_C4UB_V3F)
SS(i)(T2F_N3F_V3F)
SS(i)(T2F_V3F)
SS(i)(T4F_C4F_N3F_V4F)
SS(i)(T4F_V4F)
SS(i)(TEXTURE)
SS(i)(TEXTURE_1D)
SS(i)(TEXTURE_2D)
SS(i)(TEXTURE_ALPHA_SIZE)
SS(i)(TEXTURE_BINDING_2D)
SS(i)(TEXTURE_BLUE_SIZE)
SS(i)(TEXTURE_BORDER)
SS(i)(TEXTURE_BORDER_COLOR)
SS(i)(TEXTURE_COMPONENTS)
SS(i)(TEXTURE_COORD_ARRAY)
SS(i)(TEXTURE_COORD_ARRAY_BUFFER_BINDING);
SS(i)(TEXTURE_ENV)
SS(i)(TEXTURE_ENV_COLOR)
SS(i)(TEXTURE_ENV_MODE)
SS(i)(TEXTURE_GEN_MODE)
SS(i)(TEXTURE_GEN_Q)
SS(i)(TEXTURE_GEN_R)
SS(i)(TEXTURE_GEN_S)
SS(i)(TEXTURE_GEN_T)
SS(i)(TEXTURE_GREEN_SIZE)
SS(i)(TEXTURE_HEIGHT)
SS(i)(TEXTURE_INTENSITY_SIZE)
SS(i)(TEXTURE_LUMINANCE_SIZE)
SS(i)(TEXTURE_MAG_FILTER)
SS(i)(TEXTURE_MIN_FILTER)
SS(i)(TEXTURE_RED_SIZE)
SS(i)(TEXTURE_WRAP_S)
SS(i)(TEXTURE_WRAP_T)
SS(i)(TRIANGLES)
SS(i)(TRIANGLE_FAN)
SS(i)(TRIANGLE_STRIP)
SS(i)(UNPACK_ALIGNMENT)
SS(i)(UNPACK_ROW_LENGTH)
SS(i)(UNSIGNED_BYTE)
SS(i)(UNSIGNED_INT_8_8_8_8_REV)
SS(i)(UNSIGNED_SHORT)
SS(i)(V2F)
SS(i)(V3F)
SS(i)(VERTEX_ARRAY)
SS(i)(VERTEX_ARRAY_BUFFER_BINDING);
/*SS(COLOR_BUFFER_BIT) -- same value as GL_LIGHT0 */
# undef SS
case (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT):

View file

@ -124,6 +124,7 @@
<ClInclude Include="build\include\kplib.h" />
<ClInclude Include="build\include\libdivide.h" />
<ClInclude Include="build\include\lzwnew.h" />
<ClInclude Include="build\include\m32script.h" />
<ClInclude Include="build\include\md4.h" />
<ClInclude Include="build\include\mdsprite.h" />
<ClInclude Include="build\include\mmulti.h" />

View file

@ -540,6 +540,9 @@
<ClInclude Include="source\jaudiolib\include\multivoc.h">
<Filter>jaudiolib\headers</Filter>
</ClInclude>
<ClInclude Include="build\include\m32script.h">
<Filter>eduke32\headers\editor</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="build\src\a-c.c">

View file

@ -141,7 +141,6 @@ static int32_t _MIDI_InterpretControllerInfo(track *Track, int32_t TimeSet, int3
static int32_t _MIDI_SendControlChange(int32_t channel, int32_t c1, int32_t c2);
static void _MIDI_SetChannelVolume(int32_t channel, int32_t volume);
static void _MIDI_SendChannelVolumes(void);
static int32_t _MIDI_ProcessNextTick(void);
static void _MIDI_InitEMIDI(void);
#endif

File diff suppressed because it is too large Load diff

View file

@ -33,6 +33,8 @@ extern "C" {
#define SLEEPTIME 1536
#define ZOFFSET (1<<8)
#define ZOFFSET2 (16<<8)
#define ZOFFSET3 (8<<8)
#define ZOFFSET4 (12<<8)
#define ACTOR_MAXFALLINGZVEL 6144
#define ACTOR_ONWATER_ADDZ (24<<8)
@ -302,9 +304,9 @@ extern projectile_t SpriteProjectile[MAXSPRITES];
void A_AddToDeleteQueue(int32_t i);
int32_t A_CheckNoSE7Water(const spritetype *s, int32_t sectnum, int32_t slotag, int32_t *othersectptr);
int32_t A_CheckNoSE7Water(uspritetype const * const pSprite, int32_t sectNum, int32_t sectLotag, int32_t *pOther);
int32_t A_CheckSwitchTile(int32_t i);
void A_DeleteSprite(int32_t s);
void A_DeleteSprite(int spriteNum);
void A_DoGuts(int32_t sp, int32_t gtype, int32_t n);
void A_DoGutsDir(int32_t sp, int32_t gtype, int32_t n);
int32_t A_IncurDamage(int32_t sn);
@ -395,7 +397,7 @@ EXTERN_INLINE int32_t G_CheckForSpaceFloor(int32_t sectnum)
EXTERN_INLINE int A_CheckEnemySprite(void const * const pSprite)
{
return A_CheckEnemyTile(((uspritetype *) pSprite)->picnum);
return A_CheckEnemyTile(((uspritetype const *) pSprite)->picnum);
}
#endif

View file

@ -264,21 +264,21 @@ static void copy_prlight_colors(_prlight *mylightptr, int32_t i)
static void addprlight_common1(_prlight *mylightptr, int32_t i)
{
mylightptr->sector = SECT;
mylightptr->sector = SECT(i);
Bmemcpy(mylightptr, &sprite[i], sizeof(vec3_t));
mylightptr->range = SHT;
mylightptr->range = SHT(i);
copy_prlight_colors(mylightptr, i);
mylightptr->angle = SA;
mylightptr->horiz = SH;
mylightptr->angle = SA(i);
mylightptr->horiz = SH(i);
mylightptr->minshade = sprite[i].xoffset;
mylightptr->maxshade = sprite[i].yoffset;
// overridden for spot lights
mylightptr->radius = mylightptr->faderadius = mylightptr->tilenum = 0;
if (CS & 2)
if (CS(i) & 2)
{
if (CS & 512)
if (CS(i) & 512)
mylightptr->priority = PR_LIGHT_PRIO_LOW;
else
mylightptr->priority = PR_LIGHT_PRIO_HIGH;
@ -286,7 +286,7 @@ static void addprlight_common1(_prlight *mylightptr, int32_t i)
else
mylightptr->priority = PR_LIGHT_PRIO_MAX;
mylightptr->publicflags.negative = !!(CS & 128);
mylightptr->publicflags.negative = !!(CS(i) & 128);
spritelightid[i] = polymer_addlight(mylightptr);
if (spritelightid[i] >= 0)
@ -2483,8 +2483,8 @@ static int32_t SelectAllTiles(int32_t iCurrentTile)
return iCurrentTile;
}
static int32_t OnGotoTile(int32_t iTile);
static int32_t OnSelectTile(int32_t iTile);
static int32_t OnGotoTile(int32_t tileNum);
static int32_t OnSelectTile(int32_t tileNum);
static int32_t OnSaveTileGroup();
static int32_t loadtilegroups(const char *fn);
static int32_t s_Zoom = INITIAL_ZOOM;
@ -2533,7 +2533,7 @@ static int32_t m32gettile(int32_t idInitialTile)
int32_t gap, temp, zoomsz;
int32_t nXTiles, nYTiles, nDisplayedTiles;
int32_t i;
int32_t iTile, iTopLeftTile, iLastTile;
int32_t tileNum, iTopLeftTile, iLastTile;
int32_t idSelectedTile;
int32_t scrollmode;
int32_t mousedx, mousedy, mtile, omousex=searchx, omousey=searchy, moffset=0;
@ -2574,7 +2574,7 @@ static int32_t m32gettile(int32_t idInitialTile)
localartlookup[i] = i;
}
iLastTile = iTile = idSelectedTile = idInitialTile;
iLastTile = tileNum = idSelectedTile = idInitialTile;
switch (searchstat)
{
@ -2631,10 +2631,10 @@ static int32_t m32gettile(int32_t idInitialTile)
localartlookup[temp] = localartlookup[temp+gap];
localartlookup[temp+gap] = tempint;
if (iTile == temp)
iTile = temp + gap;
else if (iTile == temp + gap)
iTile = temp;
if (tileNum == temp)
tileNum = temp + gap;
else if (tileNum == temp + gap)
tileNum = temp;
temp -= gap;
}
@ -2665,20 +2665,20 @@ static int32_t m32gettile(int32_t idInitialTile)
localartfreq[i] = 0; // Terrible bodge : zero tilefreq's not displayed in tile view. Still, when in Rome ... :-)
}
iTile = idInitialTile;
tileNum = idInitialTile;
}
//
//
//
iTopLeftTile = iTile - (iTile % nXTiles);
iTopLeftTile = tileNum - (tileNum % nXTiles);
iTopLeftTile = clamp(iTopLeftTile, 0, MAXTILES-nDisplayedTiles);
zoomsz = ZoomToThumbSize[s_Zoom];
searchx = ((iTile-iTopLeftTile)%nXTiles)*zoomsz + zoomsz/2;
searchy = ((iTile-iTopLeftTile)/nXTiles)*zoomsz + zoomsz/2;
searchx = ((tileNum-iTopLeftTile)%nXTiles)*zoomsz + zoomsz/2;
searchy = ((tileNum-iTopLeftTile)/nXTiles)*zoomsz + zoomsz/2;
////////////////////////////////
// Start of key handling code //
@ -2689,9 +2689,9 @@ static int32_t m32gettile(int32_t idInitialTile)
int32_t ret;
zoomsz = ZoomToThumbSize[s_Zoom];
ret = DrawTiles(iTopLeftTile, (iTile >= localartlookupnum) ? localartlookupnum-1 : iTile,
ret = DrawTiles(iTopLeftTile, (tileNum >= localartlookupnum) ? localartlookupnum-1 : tileNum,
nXTiles, nYTiles, zoomsz, moffset,
(tilesel_showerr && (iTile==iLastTile || (tilesel_showerr=0))));
(tilesel_showerr && (tileNum==iLastTile || (tilesel_showerr=0))));
if (ret==0)
{
@ -2703,7 +2703,7 @@ static int32_t m32gettile(int32_t idInitialTile)
}
getmousevalues(&mousedx,&mousedy,&bstatus);
iLastTile = iTile;
iLastTile = tileNum;
searchx += mousedx;
searchy += mousedy;
@ -2750,11 +2750,11 @@ static int32_t m32gettile(int32_t idInitialTile)
iTopLeftTile += (nXTiles*scrollamount);
}
mtile = iTile = searchx/zoomsz + ((searchy-moffset)/zoomsz)*nXTiles + iTopLeftTile;
while (iTile >= iTopLeftTile + nDisplayedTiles)
mtile = tileNum = searchx/zoomsz + ((searchy-moffset)/zoomsz)*nXTiles + iTopLeftTile;
while (tileNum >= iTopLeftTile + nDisplayedTiles)
{
iTile -= nXTiles;
mtile = iTile;
tileNum -= nXTiles;
mtile = tileNum;
}
// These two lines are so obvious I don't need to comment them ...;-)
@ -2788,8 +2788,8 @@ static int32_t m32gettile(int32_t idInitialTile)
zoomsz = ZoomToThumbSize[s_Zoom];
if (iTile >= localartlookupnum)
iTile = localartlookupnum-1;
if (tileNum >= localartlookupnum)
tileNum = localartlookupnum-1;
// Calculate new num of tiles to display
nXTiles = xdim / zoomsz;
@ -2801,82 +2801,82 @@ static int32_t m32gettile(int32_t idInitialTile)
// Determine if the top-left displayed tile needs to
// alter in order to display selected tile
iTopLeftTile = iTile - (iTile % nXTiles);
iTopLeftTile = tileNum - (tileNum % nXTiles);
iTopLeftTile = clamp(iTopLeftTile, 0, MAXTILES - nDisplayedTiles);
// scroll window so mouse points the same tile as it was before zooming
iTopLeftTile -= searchx/zoomsz + ((searchy-moffset)/zoomsz)*nXTiles + iTopLeftTile-iTile;
iTopLeftTile -= searchx/zoomsz + ((searchy-moffset)/zoomsz)*nXTiles + iTopLeftTile-tileNum;
}
if (PRESSED_KEYSC(LEFT))
{
if (eitherCTRL) // same as HOME, for consistency with CTRL-UP/DOWN
iTile = (iTile/nXTiles)*nXTiles;
tileNum = (tileNum/nXTiles)*nXTiles;
else
iTile--;
tileNum--;
}
if (PRESSED_KEYSC(RIGHT))
{
if (eitherCTRL) // same as END, for consistency with CTRL-UP/DOWN
iTile = ((iTile+nXTiles)/nXTiles)*nXTiles - 1;
tileNum = ((tileNum+nXTiles)/nXTiles)*nXTiles - 1;
else
iTile++;
tileNum++;
}
if (PRESSED_KEYSC(UP))
{
if (eitherCTRL)
while (iTile-nXTiles >= iTopLeftTile)
iTile -= nXTiles;
while (tileNum-nXTiles >= iTopLeftTile)
tileNum -= nXTiles;
else
iTile -= nXTiles;
tileNum -= nXTiles;
}
if (PRESSED_KEYSC(DOWN))
{
if (eitherCTRL)
while (iTile+nXTiles < iTopLeftTile + nDisplayedTiles)
iTile += nXTiles;
while (tileNum+nXTiles < iTopLeftTile + nDisplayedTiles)
tileNum += nXTiles;
else
iTile += nXTiles;
tileNum += nXTiles;
}
if (PRESSED_KEYSC(PGUP))
{
if (eitherCTRL)
iTile = 0;
tileNum = 0;
else
iTile -= nDisplayedTiles;
tileNum -= nDisplayedTiles;
}
if (PRESSED_KEYSC(PGDN))
{
if (eitherCTRL)
iTile = localartlookupnum-1;
tileNum = localartlookupnum-1;
else
iTile += nDisplayedTiles;
tileNum += nDisplayedTiles;
}
if (PRESSED_KEYSC(HOME))
{
if (eitherCTRL)
iTile = iTopLeftTile;
tileNum = iTopLeftTile;
else
iTile = (iTile/nXTiles)*nXTiles;
tileNum = (tileNum/nXTiles)*nXTiles;
}
if (PRESSED_KEYSC(END))
{
if (eitherCTRL)
iTile = iTopLeftTile + nDisplayedTiles - 1;
tileNum = iTopLeftTile + nDisplayedTiles - 1;
else
iTile = ((iTile+nXTiles)/nXTiles)*nXTiles - 1;
tileNum = ((tileNum+nXTiles)/nXTiles)*nXTiles - 1;
}
// 'V' KEYPRESS
if (PRESSED_KEYSC(V))
iTile = SelectAllTiles(iTile);
tileNum = SelectAllTiles(tileNum);
// 'G' KEYPRESS - Goto frame
if (PRESSED_KEYSC(G))
@ -2885,43 +2885,43 @@ static int32_t m32gettile(int32_t idInitialTile)
{
if (OnSaveTileGroup() == 0)
{
// iTile = SelectAllTiles(iTile);
// tileNum = SelectAllTiles(tileNum);
Bmemset(tilemarked, 0, sizeof(tilemarked));
mark_lastk = -1;
noTilesMarked = 1;
}
}
else
iTile = OnGotoTile(iTile);
tileNum = OnGotoTile(tileNum);
}
// 'U' KEYPRESS : go straight to user defined art
if (PRESSED_KEYSC(U))
{
SelectAllTiles(iTile);
iTile = FIRST_USER_ART_TILE;
SelectAllTiles(tileNum);
tileNum = FIRST_USER_ART_TILE;
}
// 'A' KEYPRESS : Go straight to start of Atomic edition's art
if (PRESSED_KEYSC(A))
{
SelectAllTiles(iTile);
iTile = FIRST_ATOMIC_TILE;
SelectAllTiles(tileNum);
tileNum = FIRST_ATOMIC_TILE;
}
// 'E' KEYPRESS : Go straight to start of extended art
if (PRESSED_KEYSC(E))
{
SelectAllTiles(iTile);
SelectAllTiles(tileNum);
if (iTile == FIRST_EXTENDED_TILE)
iTile = SECOND_EXTENDED_TILE;
else iTile = FIRST_EXTENDED_TILE;
if (tileNum == FIRST_EXTENDED_TILE)
tileNum = SECOND_EXTENDED_TILE;
else tileNum = FIRST_EXTENDED_TILE;
}
// 'T' KEYPRESS = Select from pre-defined tileset
if (PRESSED_KEYSC(T))
iTile = OnSelectTile(iTile);
tileNum = OnSelectTile(tileNum);
if (PRESSED_KEYSC(Z))
s_TileZoom = !s_TileZoom;
@ -2929,7 +2929,7 @@ static int32_t m32gettile(int32_t idInitialTile)
//
// Ensure tilenum is within valid range
//
iTile = clamp(iTile, 0, min(MAXTILES-1, localartlookupnum+nDisplayedTiles-1));
tileNum = clamp(tileNum, 0, min(MAXTILES-1, localartlookupnum+nDisplayedTiles-1));
// 'S' KEYPRESS: search for named tile
if (PRESSED_KEYSC(S))
@ -2943,7 +2943,7 @@ static int32_t m32gettile(int32_t idInitialTile)
int32_t i, i0, slen=Bstrlen(searchstr)-1;
Bstrncpyz(laststr, searchstr, 25);
i0 = localartlookup[iTile];
i0 = localartlookup[tileNum];
Bmemcpy(buf[0], laststr, 25);
Bstrupr(buf[0]);
@ -2958,7 +2958,7 @@ static int32_t m32gettile(int32_t idInitialTile)
(searchstr[0]!='^' && Bstrstr(buf[1], buf[0])))
{
SelectAllTiles(i);
iTile = i;
tileNum = i;
break;
}
}
@ -2971,10 +2971,10 @@ static int32_t m32gettile(int32_t idInitialTile)
// Adjust top-left to ensure tilenum is within displayed range of tiles
//
while (iTile < iTopLeftTile - (moffset<0)?nXTiles:0)
while (tileNum < iTopLeftTile - (moffset<0)?nXTiles:0)
iTopLeftTile -= nXTiles;
while (iTile >= iTopLeftTile + nDisplayedTiles)
while (tileNum >= iTopLeftTile + nDisplayedTiles)
iTopLeftTile += nXTiles;
iTopLeftTile = clamp(iTopLeftTile, 0, MAXTILES - nDisplayedTiles);
@ -2983,7 +2983,7 @@ static int32_t m32gettile(int32_t idInitialTile)
// SPACE keypress: mark/unmark selected tile
if (PRESSED_KEYSC(SPACE))
{
if (iTile < localartlookupnum && IsValidTile(localartlookup[iTile]))
if (tileNum < localartlookupnum && IsValidTile(localartlookup[tileNum]))
{
if (keystatus[KEYSC_LCTRL] && keystatus[KEYSC_RSHIFT])
{
@ -2993,7 +2993,7 @@ static int32_t m32gettile(int32_t idInitialTile)
}
else
{
int32_t k=iTile, kend, dir;
int32_t k=tileNum, kend, dir;
if (noTilesMarked)
{
@ -3031,10 +3031,10 @@ static int32_t m32gettile(int32_t idInitialTile)
}
else
{
if (iTile < localartlookupnum)
if (tileNum < localartlookupnum)
{
// Convert tile num from index to actual tile num
idSelectedTile = localartlookup[iTile];
idSelectedTile = localartlookup[tileNum];
// Check : if invalid tile selected, return original tile num
if (!IsValidTile(idSelectedTile))
@ -3045,10 +3045,10 @@ static int32_t m32gettile(int32_t idInitialTile)
idSelectedTile = idInitialTile;
}
}
if (mtile!=iTile) // if changed by keyboard, update mouse cursor
if (mtile!=tileNum) // if changed by keyboard, update mouse cursor
{
searchx = ((iTile-iTopLeftTile)%nXTiles) * zoomsz + zoomsz/2;
searchy = ((iTile-iTopLeftTile)/nXTiles) * zoomsz + zoomsz/2 + moffset;
searchx = ((tileNum-iTopLeftTile)%nXTiles) * zoomsz + zoomsz/2;
searchy = ((tileNum-iTopLeftTile)/nXTiles) * zoomsz + zoomsz/2 + moffset;
}
}
@ -3223,10 +3223,10 @@ static int32_t OnSaveTileGroup(void)
}
static int32_t OnGotoTile(int32_t iTile)
static int32_t OnGotoTile(int32_t tileNum)
{
//Automatically press 'V'
iTile = SelectAllTiles(iTile);
tileNum = SelectAllTiles(tileNum);
return getnumber256("Goto tile: ", 0, MAXTILES-1, 0+2+16);
}
@ -3253,7 +3253,7 @@ static int32_t LoadTileSet(const int32_t idCurrentTile, const int32_t *pIds, con
return iNewTile;
}
static int32_t OnSelectTile(int32_t iTile)
static int32_t OnSelectTile(int32_t tileNum)
{
int32_t bDone = 0;
int32_t i;
@ -3262,10 +3262,10 @@ static int32_t OnSelectTile(int32_t iTile)
if (tile_groups <= 0)
{
TMPERRMSG_PRINT("No tile groups loaded. Check for existence of `%s'.", default_tiles_cfg);
return iTile;
return tileNum;
}
SelectAllTiles(iTile);
SelectAllTiles(tileNum);
bflushchars();
@ -3316,7 +3316,7 @@ static int32_t OnSelectTile(int32_t iTile)
if (s_TileGroups[i].pIds != NULL && s_TileGroups[i].key1)
if (ch == s_TileGroups[i].key1 || ch == s_TileGroups[i].key2)
{
iTile = LoadTileSet(iTile, s_TileGroups[i].pIds, s_TileGroups[i].nIds);
tileNum = LoadTileSet(tileNum, s_TileGroups[i].pIds, s_TileGroups[i].nIds);
bDone = 1;
}
}
@ -3326,7 +3326,7 @@ static int32_t OnSelectTile(int32_t iTile)
clearkeys();
return iTile;
return tileNum;
}
static const char *GetTilePixels(int32_t idTile)
@ -3387,7 +3387,7 @@ static void classic_drawtilescreen(int32_t x, int32_t y, int32_t idTile, int32_t
static void tilescreen_drawbox(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles,
int32_t TileDim, int32_t offset,
int32_t iTile, int32_t idTile)
int32_t tileNum, int32_t idTile)
{
int32_t marked = (IsValidTile(idTile) && tilemarked[idTile>>3]&(1<<(idTile&7)));
@ -3395,10 +3395,10 @@ static void tilescreen_drawbox(int32_t iTopLeft, int32_t iSelected, int32_t nXTi
// Draw white box around currently selected tile or marked tile
// p1=(x1, y1), p2=(x1+TileDim-1, y1+TileDim-1)
//
if (iTile == iSelected || marked)
if (tileNum == iSelected || marked)
{
int32_t x1 = ((iTile-iTopLeft) % nXTiles)*TileDim;
int32_t y1 = ((iTile - ((iTile-iTopLeft) % nXTiles) - iTopLeft)/nXTiles)*TileDim + offset;
int32_t x1 = ((tileNum-iTopLeft) % nXTiles)*TileDim;
int32_t y1 = ((tileNum - ((tileNum-iTopLeft) % nXTiles) - iTopLeft)/nXTiles)*TileDim + offset;
int32_t x2 = x1+TileDim-1;
int32_t y2 = y1+TileDim-1, oydim16=ydim16;
@ -3416,7 +3416,7 @@ static void tilescreen_drawbox(int32_t iTopLeft, int32_t iSelected, int32_t nXTi
// box
int32_t xx[] = {x1, x1, x2, x2, x1};
int32_t yy[] = {y1, y2, y2, y1, y1};
plotlines2d(xx, yy, 5, iTile==iSelected ? whitecol : markedcol);
plotlines2d(xx, yy, 5, tileNum==iSelected ? whitecol : markedcol);
}
// cross
@ -3486,7 +3486,7 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i
int32_t TileDim, int32_t offset, int32_t showmsg)
{
int32_t XTile, YTile;
int32_t iTile, idTile;
int32_t tileNum, idTile;
int32_t i, x, y;
const char *pRawPixels;
char szT[128];
@ -3519,15 +3519,15 @@ restart:
{
for (XTile = 0; XTile < nXTiles; XTile++)
{
iTile = iTopLeft + XTile + (YTile * nXTiles);
tileNum = iTopLeft + XTile + (YTile * nXTiles);
if (iTile < 0 || iTile >= localartlookupnum)
if (tileNum < 0 || tileNum >= localartlookupnum)
continue;
#ifdef USE_OPENGL
usehitile = (runi || !lazyselector);
#endif
idTile = localartlookup[ iTile ];
idTile = localartlookup[ tileNum ];
if (loadedhitile[idTile>>3]&(1<<(idTile&7)))
{
if (runi==1)
@ -3552,14 +3552,14 @@ restart:
#endif
classic_drawtilescreen(x, y, idTile, TileDim, pRawPixels);
if (localartfreq[iTile] != 0 && y >= 0 && y <= ydim-20)
if (localartfreq[tileNum] != 0 && y >= 0 && y <= ydim-20)
{
Bsprintf(szT, "%d", localartfreq[iTile]);
Bsprintf(szT, "%d", localartfreq[tileNum]);
printext256(x, y, whitecol, -1, szT, 1);
}
}
tilescreen_drawbox(iTopLeft, iSelected, nXTiles, TileDim, offset, iTile, idTile);
tilescreen_drawbox(iTopLeft, iSelected, nXTiles, TileDim, offset, tileNum, idTile);
if (runi==1 && lazyselector)
{
@ -8995,7 +8995,7 @@ static int32_t osdcmd_do(const osdfuncparm_t *parm)
if (parm->numparms==0)
return OSDCMD_SHOWHELP;
oscrofs = (g_scriptPtr-script);
oscrofs = (g_scriptPtr-apScript);
ofs = 2*(parm->numparms>0); // true if "do" command
slen = Bstrlen(parm->raw+ofs);
@ -9032,15 +9032,15 @@ static int32_t osdcmd_do(const osdfuncparm_t *parm)
g_numSavedConstants = onumconstants;
*g_scriptPtr = CON_RETURN + (g_lineNumber<<12);
g_scriptPtr = script + oscrofs;
g_scriptPtr = apScript + oscrofs;
insptr = script + oscrofs;
insptr = apScript + oscrofs;
Bmemcpy(&vm, &vm_default, sizeof(vmstate_t));
if (in3dmode() && AIMING_AT_SPRITE)
{
vm.g_i = searchwall;
vm.g_sp = (uspritetype *)&sprite[vm.g_i];
vm.spriteNum = searchwall;
vm.pSprite = &sprite[vm.spriteNum];
}
// If OSD is down, that would interfere with user input, so don't consider
@ -10166,16 +10166,16 @@ void ExtPreCheckKeys(void) // just before drawrooms
spritelightptr[i]->sector = sprite[i].sectnum;
spritelightptr[i]->flags.invalidate = 1;
}
if (SHT != spritelightptr[i]->range)
if (SHT(i) != spritelightptr[i]->range)
{
spritelightptr[i]->range = SHT;
spritelightptr[i]->range = SHT(i);
spritelightptr[i]->flags.invalidate = 1;
}
if (check_prlight_colors(i))
copy_prlight_colors(spritelightptr[i], i);
if ((int)!!(CS & 128) != spritelightptr[i]->publicflags.negative)
if ((int)!!(CS(i) & 128) != spritelightptr[i]->publicflags.negative)
{
spritelightptr[i]->publicflags.negative = !!(CS & 128);
spritelightptr[i]->publicflags.negative = !!(CS(i) & 128);
}
}
}
@ -10189,10 +10189,10 @@ void ExtPreCheckKeys(void) // just before drawrooms
#pragma pack(push,1)
_prlight mylight;
#pragma pack(pop)
mylight.radius = (256-(SS+128))<<1;
mylight.radius = (256-(SS(i)+128))<<1;
mylight.faderadius = (int16_t)(mylight.radius * 0.75f);
mylight.tilenum = OW;
mylight.publicflags.emitshadow = !(CS & 64);
mylight.tilenum = OW(i);
mylight.publicflags.emitshadow = !(CS(i) & 64);
addprlight_common1(&mylight, i);
}
@ -10204,38 +10204,38 @@ void ExtPreCheckKeys(void) // just before drawrooms
spritelightptr[i]->sector = sprite[i].sectnum;
spritelightptr[i]->flags.invalidate = 1;
}
if (SHT != spritelightptr[i]->range)
if (SHT(i) != spritelightptr[i]->range)
{
spritelightptr[i]->range = SHT;
spritelightptr[i]->range = SHT(i);
spritelightptr[i]->flags.invalidate = 1;
}
if (check_prlight_colors(i))
copy_prlight_colors(spritelightptr[i], i);
if (((256-(SS+128))<<1) != spritelightptr[i]->radius)
if (((256-(SS(i)+128))<<1) != spritelightptr[i]->radius)
{
spritelightptr[i]->radius = (256-(SS+128))<<1;
spritelightptr[i]->radius = (256-(SS(i)+128))<<1;
spritelightptr[i]->faderadius = (int16_t)(spritelightptr[i]->radius * 0.75f);
spritelightptr[i]->flags.invalidate = 1;
}
if (SA != spritelightptr[i]->angle)
if (SA(i) != spritelightptr[i]->angle)
{
spritelightptr[i]->angle = SA;
spritelightptr[i]->angle = SA(i);
spritelightptr[i]->flags.invalidate = 1;
}
if (SH != spritelightptr[i]->horiz)
if (SH(i) != spritelightptr[i]->horiz)
{
spritelightptr[i]->horiz = SH;
spritelightptr[i]->horiz = SH(i);
spritelightptr[i]->flags.invalidate = 1;
}
if ((int)!(CS & 64) != spritelightptr[i]->publicflags.emitshadow)
if ((int)!(CS(i) & 64) != spritelightptr[i]->publicflags.emitshadow)
{
spritelightptr[i]->publicflags.emitshadow = !(CS & 64);
spritelightptr[i]->publicflags.emitshadow = !(CS(i) & 64);
}
if ((int)!!(CS & 128) != spritelightptr[i]->publicflags.negative)
if ((int)!!(CS(i) & 128) != spritelightptr[i]->publicflags.negative)
{
spritelightptr[i]->publicflags.negative = !!(CS & 128);
spritelightptr[i]->publicflags.negative = !!(CS(i) & 128);
}
spritelightptr[i]->tilenum = OW;
spritelightptr[i]->tilenum = OW(i);
}
}
}

View file

@ -392,7 +392,7 @@ void G_DoCheats(void)
}
else
{
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "Come Get Some!");
Bstrcpy(apStrings[QUOTE_RESERVED4], "Come Get Some!");
S_PlaySound(DUKE_GETWEAPON2);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
@ -471,7 +471,7 @@ void G_DoCheats(void)
levnume--;
if ((VOLUMEONE && volnume > 0) || volnume > g_numVolumes-1 ||
levnume >= MAXLEVELS || MapInfo[volnume *MAXLEVELS+levnume].filename == NULL)
levnume >= MAXLEVELS || aMapInfo[volnume *MAXLEVELS+levnume].filename == NULL)
{
end_cheat();
return;
@ -581,7 +581,7 @@ void G_DoCheats(void)
case CHEAT_TODD:
if (NAM)
{
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], g_NAMMattCheatQuote);
Bstrcpy(apStrings[QUOTE_RESERVED4], g_NAMMattCheatQuote);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
}
else
@ -619,7 +619,7 @@ void G_DoCheats(void)
if (++g_noEnemies == 3)
g_noEnemies = 0;
Bsprintf(ScriptQuotes[QUOTE_RESERVED4], "Monsters: %s", s[g_noEnemies]);
Bsprintf(apStrings[QUOTE_RESERVED4], "Monsters: %s", s[g_noEnemies]);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
end_cheat();

View file

@ -137,7 +137,7 @@ void G_OpenDemoWrite(void)
{
#ifdef LUNATIC
// TODO: Currently, we can't diff gamevars in Lunatic...
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "DEMOS UNSUPPORTED IN LUNATIC BUILD");
Bstrcpy(apStrings[QUOTE_RESERVED4], "DEMOS UNSUPPORTED IN LUNATIC BUILD");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
ud.recstat = ud.m_recstat = 0;
return;
@ -153,7 +153,7 @@ void G_OpenDemoWrite(void)
if ((g_player[myconnectindex].ps->gm&MODE_GAME) && g_player[myconnectindex].ps->dead_flag)
{
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "CANNOT START DEMO RECORDING WHEN DEAD!");
Bstrcpy(apStrings[QUOTE_RESERVED4], "CANNOT START DEMO RECORDING WHEN DEAD!");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
ud.recstat = ud.m_recstat = 0;
return;
@ -162,8 +162,8 @@ void G_OpenDemoWrite(void)
if (demorec_diffs_cvar && !demorec_force_cvar)
for (i=1; i<g_scriptSize-2; i++)
{
intptr_t w=script[i];
if ((w&0x0fff)==CON_RESIZEARRAY && (w>>12) && script[i+1]>=0 && script[i+1]<g_gameArrayCount)
intptr_t w=apScript[i];
if ((w&0x0fff)==CON_RESIZEARRAY && (w>>12) && apScript[i+1]>=0 && apScript[i+1]<g_gameArrayCount)
{
OSD_Printf("\nThe CON code possibly contains a RESIZEARRAY command.\n");
OSD_Printf("Gamearrays that change their size during the game are unsupported by\n");
@ -171,7 +171,7 @@ void G_OpenDemoWrite(void)
OSD_Printf("contain a RESIZEARRAY command, you can force recording with the\n");
OSD_Printf("`demorec_force' cvar. Alternatively, you can disable diff recording\n");
OSD_Printf("with the `demorec_diffs' cvar.\n\n");
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD.");
Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD.");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
ud.recstat = ud.m_recstat = 0;
return;
@ -209,7 +209,7 @@ void G_OpenDemoWrite(void)
{
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
error_wopen_demo:
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS.");
Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS.");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
ud.recstat = ud.m_recstat = 0;
return;
@ -220,7 +220,7 @@ error_wopen_demo:
demo_synccompress = demorec_synccompress_cvar;
demorec_difftics = demorec_difftics_cvar;
Bsprintf(ScriptQuotes[QUOTE_RESERVED4], "DEMO %d RECORDING STARTED", demonum-1);
Bsprintf(apStrings[QUOTE_RESERVED4], "DEMO %d RECORDING STARTED", demonum-1);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
ud.reccnt = 0;
@ -321,7 +321,7 @@ void G_CloseDemoWrite(void)
sv_freemem();
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "DEMO RECORDING STOPPED");
Bstrcpy(apStrings[QUOTE_RESERVED4], "DEMO RECORDING STOPPED");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
}
#if KRANDDEBUG

View file

@ -1218,17 +1218,17 @@ void G_DumpDebugInfo(void)
TrackerCast(sprite[j].x),TrackerCast(sprite[j].y),TrackerCast(sprite[j].z),TrackerCast(sprite[j].picnum));
for (i=0; i<g_gameVarCount; i++)
{
if (aGameVars[i].nFlags & (GAMEVAR_PERACTOR))
if (aGameVars[i].flags & (GAMEVAR_PERACTOR))
{
if (aGameVars[i].pValues[j] != aGameVars[i].nDefault)
if (aGameVars[i].pValues[j] != aGameVars[i].defaultValue)
{
OSD_Printf("gamevar %s ",aGameVars[i].szLabel);
OSD_Printf("%" PRIdPTR "",aGameVars[i].pValues[j]);
OSD_Printf(" GAMEVAR_PERACTOR");
if (aGameVars[i].nFlags != GAMEVAR_PERACTOR)
if (aGameVars[i].flags != GAMEVAR_PERACTOR)
{
OSD_Printf(" // ");
if (aGameVars[i].nFlags & (GAMEVAR_SYSTEM))
if (aGameVars[i].flags & (GAMEVAR_SYSTEM))
{
OSD_Printf(" (system)");
}
@ -1255,12 +1255,12 @@ static int32_t G_InitActor(int32_t i, int32_t tilenum, int32_t set_movflag_uncon
#if !defined LUNATIC
if (g_tile[tilenum].execPtr)
{
SH = *(g_tile[tilenum].execPtr);
SH(i) = *(g_tile[tilenum].execPtr);
AC_ACTION_ID(actor[i].t_data) = *(g_tile[tilenum].execPtr+1);
AC_MOVE_ID(actor[i].t_data) = *(g_tile[tilenum].execPtr+2);
if (set_movflag_uncond || SHT == 0) // AC_MOVFLAGS
SHT = *(g_tile[tilenum].execPtr+3);
if (set_movflag_uncond || SHT(i) == 0) // AC_MOVFLAGS
SHT(i) = *(g_tile[tilenum].execPtr+3);
return 1;
}
@ -1271,7 +1271,7 @@ static int32_t G_InitActor(int32_t i, int32_t tilenum, int32_t set_movflag_uncon
const el_actor_t *a = &g_elActors[tilenum];
uint16_t *movflagsptr = &AC_MOVFLAGS(&sprite[i], &actor[i]);
SH = a->strength;
SH(i) = a->strength;
AC_ACTION_ID(actor[i].t_data) = a->act.id;
AC_MOVE_ID(actor[i].t_data) = a->mov.id;
Bmemcpy(&actor[i].ac, &a->act.ac, sizeof(struct action));
@ -1405,58 +1405,58 @@ int32_t A_Spawn(int32_t j, int32_t pn)
Bmemset(&actor[i], 0, sizeof(actor_t));
Bmemcpy(&actor[i].bpos, &sprite[i], sizeof(vec3_t));
actor[i].picnum = PN;
actor[i].picnum = PN(i);
if (PN == SECTOREFFECTOR && SLT == 50)
actor[i].picnum = OW;
if (PN(i) == SECTOREFFECTOR && SLT(i) == 50)
actor[i].picnum = OW(i);
OW = actor[i].owner = i;
OW(i) = actor[i].owner = i;
actor[i].floorz = sector[SECT].floorz;
actor[i].ceilingz = sector[SECT].ceilingz;
actor[i].floorz = sector[SECT(i)].floorz;
actor[i].ceilingz = sector[SECT(i)].ceilingz;
actor[i].actorstayput = actor[i].lightId = actor[i].extra = -1;
if ((CS&48) && PN != SPEAKER && PN != LETTER && PN != DUCK && PN != TARGET && PN != TRIPBOMB && PN != VIEWSCREEN && PN != VIEWSCREEN2)
if (!(PN >= CRACK1 && PN <= CRACK4))
if ((CS(i)&48) && PN(i) != SPEAKER && PN(i) != LETTER && PN(i) != DUCK && PN(i) != TARGET && PN(i) != TRIPBOMB && PN(i) != VIEWSCREEN && PN(i) != VIEWSCREEN2)
if (!(PN(i) >= CRACK1 && PN(i) <= CRACK4))
{
if (SS == 127)
if (SS(i) == 127)
goto SPAWN_END;
if (A_CheckSwitchTile(i) && (CS&16))
if (A_CheckSwitchTile(i) && (CS(i)&16))
{
if (sprite[i].pal && PN != ACCESSSWITCH && PN != ACCESSSWITCH2)
if (sprite[i].pal && PN(i) != ACCESSSWITCH && PN(i) != ACCESSSWITCH2)
{
if (((!g_netServer && ud.multimode < 2)) || ((g_netServer || ud.multimode > 1) && !GTFLAGS(GAMETYPE_DMSWITCHES)))
{
sprite[i].xrepeat = sprite[i].yrepeat = 0;
SLT = SHT = 0;
SLT(i) = SHT(i) = 0;
sprite[i].cstat = 32768;
goto SPAWN_END;
}
}
CS |= 257;
CS(i) |= 257;
if (sprite[i].pal && PN != ACCESSSWITCH && PN != ACCESSSWITCH2)
if (sprite[i].pal && PN(i) != ACCESSSWITCH && PN(i) != ACCESSSWITCH2)
sprite[i].pal = 0;
goto SPAWN_END;
}
if (SHT)
if (SHT(i))
{
changespritestat(i, STAT_FALLER);
CS |= 257;
SH = g_impactDamage;
CS(i) |= 257;
SH(i) = g_impactDamage;
goto SPAWN_END;
}
}
if (CS&1)
CS |= 256;
if (CS(i)&1)
CS(i) |= 256;
if (!G_InitActor(i, sprite[i].picnum, 0))
T2 = T5 = 0; // AC_MOVE_ID, AC_ACTION_ID
T2(i) = T5(i) = 0; // AC_MOVE_ID, AC_ACTION_ID
}
sp = &sprite[i];
@ -1466,8 +1466,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
if ((sp->picnum >= BOLT1 && sp->picnum <= BOLT1+3) ||
(sp->picnum >= SIDEBOLT1 && sp->picnum <= SIDEBOLT1+3))
{
T1 = sp->xrepeat;
T2 = sp->yrepeat;
T1(i) = sp->xrepeat;
T2(i) = sp->yrepeat;
sp->yvel = 0;
changespritestat(i, STAT_STANDABLE);
}
@ -1567,11 +1567,11 @@ int32_t A_Spawn(int32_t j, int32_t pn)
{
if (sector[sprite[j].sectnum].lotag == ST_2_UNDERWATER)
{
sp->z = getceilzofslope(SECT,SX,SY)+(16<<8);
sp->z = getceilzofslope(SECT(i),SX(i),SY(i))+(16<<8);
sp->cstat |= 8;
}
else if (sector[sprite[j].sectnum].lotag == ST_1_ABOVE_WATER)
sp->z = getflorzofslope(SECT,SX,SY);
sp->z = getflorzofslope(SECT(i),SX(i),SY(i));
}
if (sector[sect].floorpicnum == FLOORSLIME ||
@ -1657,7 +1657,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
{
sp->xrepeat = sprite[j].xrepeat;
sp->yrepeat = sprite[j].yrepeat;
T2 = sprite[j].picnum;
T2(i) = sprite[j].picnum;
}
else sp->xrepeat = sp->yrepeat = 0;
@ -1752,7 +1752,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
}
if (sector[SECT].lotag == ST_1_ABOVE_WATER)
if (sector[SECT(i)].lotag == ST_1_ABOVE_WATER)
{
changespritestat(i, STAT_MISC);
break;
@ -2047,8 +2047,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
case SPOTLITE__STATIC:
T1 = sp->x;
T2 = sp->y;
T1(i) = sp->x;
T2(i) = sp->y;
break;
case BULLETHOLE__STATIC:
sp->xrepeat = sp->yrepeat = 3;
@ -2087,7 +2087,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
a = ps->ang-(krand()&63)+8; //Fine tune
T1 = krand()&1;
T1(i) = krand()&1;
sp->z = (3<<8) + ps->pyoff + ps->pos.z - ((ps->horizoff + ps->horiz-100)<<4);
if (sp->picnum == SHOTGUNSHELL)
sp->z += (3<<8);
@ -2174,8 +2174,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
if (j >= 0)
{
int32_t z = getflorzofslope(sp->sectnum,sp->x,sp->y);
if (sp->z > z-(12<<8))
sp->z = z-(12<<8);
if (sp->z > z-ZOFFSET4)
sp->z = z-ZOFFSET4;
}
changespritestat(i, STAT_MISC);
@ -2223,7 +2223,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
sp->picnum += 2;
sp->z = sector[sect].ceilingz+(48<<8);
T5 = tempwallptr;
T5(i) = tempwallptr;
g_origins[tempwallptr] = *(vec2_t *) sp;
g_origins[tempwallptr+2].x = sp->z;
@ -2231,11 +2231,11 @@ int32_t A_Spawn(int32_t j, int32_t pn)
s = headspritestat[STAT_DEFAULT];
while (s >= 0)
{
if (sprite[s].picnum == CRANEPOLE && SHT == (sprite[s].hitag))
if (sprite[s].picnum == CRANEPOLE && SHT(i) == (sprite[s].hitag))
{
g_origins[tempwallptr+2].y = s;
T2 = sprite[s].sectnum;
T2(i) = sprite[s].sectnum;
sprite[s].xrepeat = 48;
sprite[s].yrepeat = 128;
@ -2279,8 +2279,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
else if (j == -1)
{
sp->z += (4<<8);
T1 = sp->z;
T2 = krand()&127;
T1(i) = sp->z;
T2(i) = krand()&127;
}
case WATERDRIPSPLASH__STATIC:
sp->xrepeat = sp->yrepeat = 24;
@ -2292,7 +2292,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
changespritestat(i, STAT_STANDABLE);
break;
case TOUCHPLATE__STATIC:
T3 = sector[sect].floorz;
T3(i) = sector[sect].floorz;
if (sector[sect].lotag != ST_1_ABOVE_WATER && sector[sect].lotag != ST_2_UNDERWATER)
sector[sect].floorz = sp->z;
if (sp->pal && (g_netServer || ud.multimode > 1))
@ -2502,7 +2502,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case REACTOR2__STATIC:
case REACTOR__STATIC:
sp->extra = g_impactDamage;
CS |= 257;
CS(i) |= 257;
if ((!g_netServer && ud.multimode < 2) && sp->pal != 0)
{
sp->xrepeat = sp->yrepeat = 0;
@ -2510,7 +2510,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
}
sp->pal = 0;
SS = -17;
SS(i) = -17;
changespritestat(i, STAT_ZOMBIEACTOR);
break;
@ -2522,7 +2522,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
sp->xrepeat = sp->yrepeat = 9;
sp->yvel = 4;
CS |= 257;
CS(i) |= 257;
if ((!g_netServer && ud.multimode < 2) && sp->pal != 0)
{
@ -2531,7 +2531,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
}
sp->pal = 0;
SS = -17;
SS(i) = -17;
changespritestat(i, STAT_ZOMBIEACTOR);
break;
@ -2552,7 +2552,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
}
sp->extra = 130;
CS |= 256; // Make it hitable
CS(i) |= 256; // Make it hitable
if ((!g_netServer && ud.multimode < 2) && sp->pal != 0)
{
@ -2561,7 +2561,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
}
sp->pal = 0;
SS = -17;
SS(i) = -17;
changespritestat(i, STAT_ZOMBIEACTOR);
break;
@ -2650,14 +2650,14 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
case WATERFOUNTAIN__STATIC:
SLT = 1;
SLT(i) = 1;
case TREE1__STATIC:
case TREE2__STATIC:
case TIRE__STATIC:
case CONE__STATIC:
case BOX__STATIC:
CS = 257; // Make it hitable
CS(i) = 257; // Make it hitable
sprite[i].extra = 1;
changespritestat(i, STAT_STANDABLE);
break;
@ -2734,7 +2734,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
switch (sp->lotag)
{
case SE_28_LIGHTNING:
T6 = 65;// Delay for lightning
T6(i) = 65;// Delay for lightning
break;
case SE_7_TELEPORT: // Transporters!!!!
case SE_23_ONE_WAY_TELEPORT:// XPTR END
@ -2742,33 +2742,33 @@ int32_t A_Spawn(int32_t j, int32_t pn)
{
for (j=0; j<MAXSPRITES; j++)
if (sprite[j].statnum < MAXSTATUS && sprite[j].picnum == SECTOREFFECTOR &&
(sprite[j].lotag == SE_7_TELEPORT || sprite[j].lotag == SE_23_ONE_WAY_TELEPORT) && i != j && sprite[j].hitag == SHT)
(sprite[j].lotag == SE_7_TELEPORT || sprite[j].lotag == SE_23_ONE_WAY_TELEPORT) && i != j && sprite[j].hitag == SHT(i))
{
OW = j;
OW(i) = j;
break;
}
}
else OW = i;
else OW(i) = i;
T5 = (sector[sect].floorz == SZ); // ONFLOORZ
T5(i) = (sector[sect].floorz == SZ(i)); // ONFLOORZ
sp->cstat = 0;
changespritestat(i, STAT_TRANSPORT);
goto SPAWN_END;
case SE_1_PIVOT:
sp->owner = -1;
T1 = 1;
T1(i) = 1;
break;
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
if (sp->ang == 512)
{
T2 = sector[sect].ceilingz;
T2(i) = sector[sect].ceilingz;
if (sp->pal)
sector[sect].ceilingz = sp->z;
}
else
{
T2 = sector[sect].floorz;
T2(i) = sector[sect].floorz;
if (sp->pal)
sector[sect].floorz = sp->z;
}
@ -2780,8 +2780,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
sp->owner = -1;
break;
case SE_25_PISTON: // Pistons
T4 = sector[sect].ceilingz;
T5 = 1;
T4(i) = sector[sect].ceilingz;
T5(i) = 1;
sector[sect].ceilingz = sp->z;
G_SetInterpolation(&sector[sect].ceilingz);
break;
@ -2797,16 +2797,16 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
case SE_12_LIGHT_SWITCH:
T2 = sector[sect].floorshade;
T3 = sector[sect].ceilingshade;
T2(i) = sector[sect].floorshade;
T3(i) = sector[sect].ceilingshade;
break;
case SE_13_EXPLOSIVE:
T1 = sector[sect].ceilingz;
T2 = sector[sect].floorz;
T1(i) = sector[sect].ceilingz;
T2(i) = sector[sect].floorz;
if (klabs(T1-sp->z) < klabs(T2-sp->z))
if (klabs(T1(i)-sp->z) < klabs(T2(i)-sp->z))
sp->owner = 1;
else sp->owner = 0;
@ -2845,12 +2845,12 @@ int32_t A_Spawn(int32_t j, int32_t pn)
if (sector[sect].ceilingstat&1)
{
sector[sect].ceilingstat ^= 1;
T4 = 1;
T4(i) = 1;
if (!sp->owner && sp->ang==512)
{
sector[sect].ceilingstat ^= 1;
T4 = 0;
T4(i) = 0;
}
sector[sect].ceilingshade =
@ -2880,16 +2880,16 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_17_WARP_ELEVATOR:
T3 = sector[sect].floorz; //Stopping loc
T3(i) = sector[sect].floorz; //Stopping loc
j = nextsectorneighborz(sect,sector[sect].floorz,-1,-1);
if (EDUKE32_PREDICT_TRUE(j >= 0))
T4 = sector[j].ceilingz;
T4(i) = sector[j].ceilingz;
else
{
// use elevator sector's ceiling as heuristic
T4 = sector[sect].ceilingz;
T4(i) = sector[sect].ceilingz;
OSD_Printf(OSD_ERROR "WARNING: SE17 sprite %d using own sector's ceilingz to "
"determine when to warp. Sector %d adjacent to a door?\n", i, sect);
@ -2898,7 +2898,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
j = nextsectorneighborz(sect,sector[sect].ceilingz,1,1);
if (EDUKE32_PREDICT_TRUE(j >= 0))
T5 = sector[j].floorz;
T5(i) = sector[j].floorz;
else
{
// XXX: we should return to the menu for this and similar failures
@ -2942,7 +2942,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
}
}
T2 = clostest;
T2(i) = clostest;
q = INT32_MAX;
@ -2952,21 +2952,21 @@ int32_t A_Spawn(int32_t j, int32_t pn)
y = wall[s].y;
d = FindDistance2D(sp->x-x,sp->y-y);
if (d < q && s != T2)
if (d < q && s != T2(i))
{
q = d;
clostest = s;
}
}
T3 = clostest;
T3(i) = clostest;
}
break;
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT:
T4=sector[sect].floorshade;
T4(i)=sector[sect].floorshade;
sector[sect].floorshade = sp->shade;
sector[sect].ceilingshade = sp->shade;
@ -2990,7 +2990,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_31_FLOOR_RISE_FALL:
{
T2 = sector[sect].floorz;
T2(i) = sector[sect].floorz;
// T3 = sp->hitag;
if (sp->ang != 1536)
{
@ -3011,8 +3011,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_32_CEILING_RISE_FALL:
{
T2 = sector[sect].ceilingz;
T3 = sp->hitag;
T2(i) = sector[sect].ceilingz;
T3(i) = sp->hitag;
if (sp->ang != 1536)
{
sector[sect].ceilingz = sp->z;
@ -3032,7 +3032,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_4_RANDOM_LIGHTS: //Flashing lights
T3 = sector[sect].floorshade;
T3(i) = sector[sect].floorshade;
startwall = sector[sect].wallptr;
endwall = startwall+sector[sect].wallnum;
@ -3041,8 +3041,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
sp->owner |= sector[sect].floorpal;
for (s=startwall; s<endwall; s++)
if (wall[s].shade > T4)
T4 = wall[s].shade;
if (wall[s].shade > T4(i))
T4(i) = wall[s].shade;
break;
@ -3053,22 +3053,22 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_8_UP_OPEN_DOOR_LIGHTS:
//First, get the ceiling-floor shade
T1 = sector[sect].floorshade;
T2 = sector[sect].ceilingshade;
T1(i) = sector[sect].floorshade;
T2(i) = sector[sect].ceilingshade;
startwall = sector[sect].wallptr;
endwall = startwall+sector[sect].wallnum;
for (s=startwall; s<endwall; s++)
if (wall[s].shade > T3)
T3 = wall[s].shade;
if (wall[s].shade > T3(i))
T3(i) = wall[s].shade;
T4 = 1; //Take Out;
T4(i) = 1; //Take Out;
break;
case SE_11_SWINGING_DOOR://Pivitor rotater
T4 = (sp->ang > 1024) ? 2 : -2;
T4(i) = (sp->ang > 1024) ? 2 : -2;
/* fall-through */
case SE_0_ROTATING_SECTOR:
case SE_2_EARTHQUAKE://Earthquakemakers
@ -3084,7 +3084,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
if (sector[sect].lotag == ST_30_ROTATE_RISE_BRIDGE)
{
sprite[i].clipdist = (sp->pal) ? 1 : 0;
T4 = sector[sect].floorz;
T4(i) = sector[sect].floorz;
sector[sect].hitag = i;
}
@ -3116,7 +3116,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
startwall = sector[sect].wallptr;
endwall = startwall+sector[sect].wallnum;
T2 = tempwallptr;
T2(i) = tempwallptr;
for (s=startwall; s<endwall; s++)
{
g_origins[tempwallptr].x = wall[s].x-sp->x;
@ -3191,19 +3191,19 @@ int32_t A_Spawn(int32_t j, int32_t pn)
}
sp->owner = -1;
T1 = s;
T1(i) = s;
if (sp->lotag != SE_30_TWO_WAY_TRAIN)
T4 = sp->hitag;
T4(i) = sp->hitag;
}
else if (sp->lotag == SE_16_REACTOR)
T4 = sector[sect].ceilingz;
T4(i) = sector[sect].ceilingz;
else if (sp->lotag == SE_26)
{
T4 = sp->x;
T5 = sp->y;
T4(i) = sp->x;
T5(i) = sp->y;
if (sp->shade==sector[sect].floorshade) //UP
sp->zvel = -256;
else
@ -3213,7 +3213,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
}
else if (sp->lotag == SE_2_EARTHQUAKE)
{
T6 = sector[sp->sectnum].floorheinum;
T6(i) = sector[sp->sectnum].floorheinum;
sector[sp->sectnum].floorheinum = 0;
}
}
@ -3743,7 +3743,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
const int viewscrShift = G_GetViewscreenSizeShift(t);
const int viewscrTile = TILE_VIEWSCR-viewscrShift;
if (g_curViewscreen >= 0 && actor[OW].t_data[0] == 1)
if (g_curViewscreen >= 0 && actor[OW(i)].t_data[0] == 1)
{
t->picnum = STATIC;
t->cstat |= (rand()&12);
@ -3875,7 +3875,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
newt->picnum = (curweap==GROW_WEAPON ? GROWSPRITEICON : WeaponPickupSprites[curweap]);
if (s->owner >= 0)
newt->z = g_player[p].ps->pos.z-(12<<8);
newt->z = g_player[p].ps->pos.z-ZOFFSET4;
else
newt->z = s->z-(51<<8);
@ -4025,7 +4025,7 @@ PALONLY:
case SCRAP5__STATIC:
if (actor[i].picnum == BLIMP && t->picnum == SCRAP1 && s->yvel >= 0)
t->picnum = s->yvel < MAXUSERTILES ? s->yvel : 0;
else t->picnum += T1;
else t->picnum += T1(i);
t->shade -= 6;
G_MaybeTakeOnFloorPal(t, sect);
@ -4048,7 +4048,7 @@ PALONLY:
if ((unsigned)scrofs_action + 2 >= (unsigned)g_scriptSize)
goto skip;
l = script[scrofs_action + 2];
l = apScript[scrofs_action + 2];
#else
l = viewtype;
#endif
@ -4102,7 +4102,7 @@ PALONLY:
l = klabs(l);
#if !defined LUNATIC
t->picnum += k + script[scrofs_action] + l*curframe;
t->picnum += k + apScript[scrofs_action] + l*curframe;
#else
t->picnum += k + startframe + l*curframe;
#endif
@ -4162,7 +4162,7 @@ skip:
else
daz = actor[i].floorz;
if ((s->z-daz) < (8<<8) && g_player[screenpeek].ps->pos.z < daz)
if ((s->z-daz) < ZOFFSET3 && g_player[screenpeek].ps->pos.z < daz)
{
uspritetype *const newt = &tsprite[spritesortcnt];
@ -4259,21 +4259,21 @@ skip:
#endif
k = getofs_viewtype5(t, t, oura, 0);
t->picnum = s->picnum+k+((T1<4)*5);
t->picnum = s->picnum+k+((T1(i)<4)*5);
t->shade = sprite[s->owner].shade;
break;
case WATERSPLASH2__STATIC:
// WATERSPLASH_T2
t->picnum = WATERSPLASH2+T2;
t->picnum = WATERSPLASH2+T2(i);
break;
case SHELL__STATIC:
t->picnum = s->picnum+(T1&1);
t->picnum = s->picnum+(T1(i)&1);
case SHOTGUNSHELL__STATIC:
t->cstat |= 12;
if (T1 > 2) t->cstat &= ~16;
else if (T1 > 1) t->cstat &= ~4;
if (T1(i) > 2) t->cstat &= ~16;
else if (T1(i) > 1) t->cstat &= ~4;
break;
case FRAMEEFFECT1_13__STATIC:
if (PLUTOPAK) break;
@ -4383,12 +4383,12 @@ int32_t G_StartRTS(int32_t i, int localp)
void G_StartMusic(void)
{
const int32_t i = g_musicIndex;
Bassert(MapInfo[i].musicfn != NULL);
Bassert(aMapInfo[i].musicfn != NULL);
{
S_PlayMusic(MapInfo[i].musicfn);
S_PlayMusic(aMapInfo[i].musicfn);
Bsnprintf(ScriptQuotes[QUOTE_MUSIC], MAXQUOTELEN, "Playing %s", MapInfo[i].musicfn);
Bsnprintf(apStrings[QUOTE_MUSIC], MAXQUOTELEN, "Playing %s", aMapInfo[i].musicfn);
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
}
}
@ -4619,7 +4619,7 @@ void G_HandleLocalKeys(void)
if (g_musicIndex >= maxi)
g_musicIndex = 0;
}
while (MapInfo[g_musicIndex].musicfn == NULL);
while (aMapInfo[g_musicIndex].musicfn == NULL);
G_StartMusic();
@ -4788,8 +4788,8 @@ FAKE_F3:
if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicToggle)
{
map_t *map = &MapInfo[g_musicIndex];
char *const qmusic = ScriptQuotes[QUOTE_MUSIC];
map_t *map = &aMapInfo[g_musicIndex];
char *const qmusic = apStrings[QUOTE_MUSIC];
KB_ClearKeyDown(sc_F5);
@ -4825,7 +4825,7 @@ FAKE_F3:
// dirty hack... char 127 in last position indicates an auto-filled name
if (ud.savegame[g_lastSaveSlot][MAXSAVEGAMENAME-2] == 127)
{
Bstrncpy(&ud.savegame[g_lastSaveSlot][0], MapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, 19);
Bstrncpy(&ud.savegame[g_lastSaveSlot][0], aMapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, 19);
ud.savegame[g_lastSaveSlot][MAXSAVEGAMENAME-2] = 127;
}
@ -5020,7 +5020,7 @@ static int32_t S_DefineMusic(const char *ID, const char *name)
return -1;
}
return S_DefineAudioIfSupported(&MapInfo[sel].musicfn, name);
return S_DefineAudioIfSupported(&aMapInfo[sel].musicfn, name);
}
static int32_t parsedefinitions_game(scriptfile *script, int32_t preload);
@ -5447,17 +5447,17 @@ static void G_Cleanup(void)
for (i=(MAXLEVELS*(MAXVOLUMES+1))-1; i>=0; i--) // +1 volume for "intro", "briefing" music
{
Bfree(MapInfo[i].name);
Bfree(MapInfo[i].filename);
Bfree(MapInfo[i].musicfn);
Bfree(aMapInfo[i].name);
Bfree(aMapInfo[i].filename);
Bfree(aMapInfo[i].musicfn);
G_FreeMapState(i);
}
for (i=MAXQUOTES-1; i>=0; i--)
{
Bfree(ScriptQuotes[i]);
Bfree(ScriptQuoteRedefinitions[i]);
Bfree(apStrings[i]);
Bfree(apXStrings[i]);
}
for (i=MAXPLAYERS-1; i>=0; i--)
@ -5473,7 +5473,7 @@ static void G_Cleanup(void)
#if !defined LUNATIC
if (label != (char *)&sprite[0]) Bfree(label);
if (labelcode != (int32_t *)&sector[0]) Bfree(labelcode);
Bfree(script);
Bfree(apScript);
Bfree(bitptr);
// Bfree(MusicPtr);
@ -6768,7 +6768,7 @@ int32_t G_DoMoveThings(void)
{
if (ldist(&sprite[p->i], &sprite[hit.sprite]) < 9216)
{
Bsprintf(ScriptQuotes[QUOTE_RESERVED3], "%s", &g_player[snum].user_name[0]);
Bsprintf(apStrings[QUOTE_RESERVED3], "%s", &g_player[snum].user_name[0]);
p->fta = 12, p->ftq = QUOTE_RESERVED3;
}
}
@ -6908,8 +6908,8 @@ void A_SpawnWallGlass(int32_t i,int32_t wallnum,int32_t n)
{
for (j=n-1; j >= 0 ; j--)
{
a = SA-256+(krand()&511)+1024;
A_InsertSprite(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&1023),i,5);
a = SA(i)-256+(krand()&511)+1024;
A_InsertSprite(SECT(i),SX(i),SY(i),SZ(i),GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&1023),i,5);
}
return;
}
@ -6938,9 +6938,9 @@ void A_SpawnWallGlass(int32_t i,int32_t wallnum,int32_t n)
{
z = sector[sect].floorz-(krand()&(klabs(sector[sect].ceilingz-sector[sect].floorz)));
if (z < -(32<<8) || z > (32<<8))
z = SZ-(32<<8)+(krand()&((64<<8)-1));
a = SA-1024;
A_InsertSprite(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&1023),i,5);
z = SZ(i)-(32<<8)+(krand()&((64<<8)-1));
a = SA(i)-1024;
A_InsertSprite(SECT(i),x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&1023),i,5);
}
}
}
@ -6949,7 +6949,7 @@ void A_SpawnGlass(int32_t i,int32_t n)
{
for (; n>0; n--)
{
int32_t k = A_InsertSprite(SECT,SX,SY,SZ-((krand()&16)<<8),GLASSPIECES+(n%3),
int32_t k = A_InsertSprite(SECT(i),SX(i),SY(i),SZ(i)-((krand()&16)<<8),GLASSPIECES+(n%3),
krand()&15,36,36,krand()&2047,32+(krand()&63),-512-(krand()&2047),i,5);
sprite[k].pal = sprite[i].pal;
}
@ -6991,7 +6991,7 @@ void A_SpawnRandomGlass(int32_t i,int32_t wallnum,int32_t n)
for (j=n-1; j >= 0 ; j--)
{
a = krand()&2047;
k = A_InsertSprite(SECT,SX,SY,SZ-(krand()&(63<<8)),GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&2047),i,5);
k = A_InsertSprite(SECT(i),SX(i),SY(i),SZ(i)-(krand()&(63<<8)),GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&2047),i,5);
sprite[k].pal = krand()&15;
}
return;
@ -7012,9 +7012,9 @@ void A_SpawnRandomGlass(int32_t i,int32_t wallnum,int32_t n)
updatesector(x1,y1,&sect);
z = sector[sect].floorz-(krand()&(klabs(sector[sect].ceilingz-sector[sect].floorz)));
if (z < -(32<<8) || z > (32<<8))
z = SZ-(32<<8)+(krand()&((64<<8)-1));
a = SA-1024;
k = A_InsertSprite(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&2047),i,5);
z = SZ(i)-(32<<8)+(krand()&((64<<8)-1));
a = SA(i)-1024;
k = A_InsertSprite(SECT(i),x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&2047),i,5);
sprite[k].pal = krand()&7;
}
}

View file

@ -98,7 +98,7 @@ enum LogoFlags_t {
LOGO_NODUKETEAMPIC = 0x00100000,
};
void A_DeleteSprite(int32_t s);
void A_DeleteSprite(int spriteNum);
static inline int32_t G_GetLogoFlags(void)
{
@ -366,7 +366,7 @@ static inline int32_t G_GetTeamPalette(int32_t team)
return pal[team];
}
#define A_CheckSpriteFlags(iActor, iType) (((g_tile[sprite[iActor].picnum].flags^actor[iActor].flags) & iType) != 0)
#define A_CheckSpriteFlags(spriteNum, iType) (((g_tile[sprite[spriteNum].picnum].flags^actor[spriteNum].flags) & iType) != 0)
// (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots)
#define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (g_tile[iPicnum].flags & iType) != 0)
#define S_StopSound(num) S_StopEnvSound(num, -1)

File diff suppressed because it is too large Load diff

View file

@ -40,15 +40,20 @@ extern "C" {
#define VM_INSTMASK 0xfff
#define C_CUSTOMERROR(Text, ...) do { \
C_ReportError(-1); \
initprintf("%s:%d: error: " Text "\n", g_szScriptFileName, g_lineNumber, ## __VA_ARGS__); \
g_numCompilerErrors++; \
#define C_CUSTOMERROR(Text, ...) \
do \
{ \
C_ReportError(-1); \
initprintf("%s:%d: error: " Text "\n", g_szScriptFileName, g_lineNumber, ##__VA_ARGS__); \
g_numCompilerErrors++; \
} while (0)
#define C_CUSTOMWARNING(Text, ...) do { \
C_ReportError(-1); \
initprintf("%s:%d: warning: " Text "\n", g_szScriptFileName, g_lineNumber, ## __VA_ARGS__); \
g_numCompilerWarnings++; \
#define C_CUSTOMWARNING(Text, ...) \
do \
{ \
C_ReportError(-1); \
initprintf("%s:%d: warning: " Text "\n", g_szScriptFileName, g_lineNumber, ##__VA_ARGS__); \
g_numCompilerWarnings++; \
} while (0)
#if !defined LUNATIC
@ -63,19 +68,20 @@ extern hashtable_t h_gamevars;
extern hashtable_t h_arrays;
extern hashtable_t h_labels;
extern int32_t g_iReturnVarID; // var ID of "RETURN"
extern int32_t g_iWeaponVarID; // var ID of "WEAPON"
extern int32_t g_iWorksLikeVarID; // var ID of "WORKSLIKE"
extern int32_t g_iZRangeVarID; // var ID of "ZRANGE"
extern int32_t g_iAngRangeVarID; // var ID of "ANGRANGE"
extern int32_t g_iAimAngleVarID; // var ID of "AUTOAIMANGLE"
extern int32_t g_iLoTagID; // var ID of "LOTAG"
extern int32_t g_iHiTagID; // var ID of "HITAG"
extern int32_t g_iTextureID; // var ID of "TEXTURE"
extern int32_t g_iThisActorID; // var ID of "THISACTOR"
extern int32_t g_returnVarID; // var ID of "RETURN"
extern int32_t g_weaponVarID; // var ID of "WEAPON"
extern int32_t g_worksLikeVarID; // var ID of "WORKSLIKE"
extern int32_t g_zRangeVarID; // var ID of "ZRANGE"
extern int32_t g_angRangeVarID; // var ID of "ANGRANGE"
extern int32_t g_aimAngleVarID; // var ID of "AUTOAIMANGLE"
extern int32_t g_lotagVarID; // var ID of "LOTAG"
extern int32_t g_hitagVarID; // var ID of "HITAG"
extern int32_t g_textureVarID; // var ID of "TEXTURE"
extern int32_t g_thisActorVarID; // var ID of "THISACTOR"
// KEEPINSYNC gamevars.c: "special vars for struct access"
enum QuickStructureAccess_t {
enum QuickStructureAccess_t
{
STRUCT_SPRITE,
STRUCT_SECTOR,
STRUCT_WALL,
@ -92,20 +98,20 @@ enum QuickStructureAccess_t {
NUMQUICKSTRUCTS,
};
extern int32_t g_iStructVarIDs;
extern int32_t g_structVarIDs;
extern intptr_t apScriptGameEvent[MAXGAMEEVENTS];
extern intptr_t apScriptEvents[MAXGAMEEVENTS];
#endif
extern int32_t otherp;
extern char CheatStrings[][MAXCHEATLEN];
extern int32_t otherp;
extern char CheatStrings[][MAXCHEATLEN];
extern const uint32_t CheatFunctionFlags[];
extern const uint8_t CheatFunctionIDs[];
extern char g_szScriptFileName[BMAX_PATH];
extern int32_t g_totalLines,g_lineNumber;
extern int32_t g_numCompilerErrors,g_numCompilerWarnings,g_numQuoteRedefinitions;
extern int32_t g_scriptVersion;
extern char g_szBuf[1024];
extern const uint8_t CheatFunctionIDs[];
extern char g_szScriptFileName[BMAX_PATH];
extern int32_t g_totalLines, g_lineNumber;
extern int32_t g_numCompilerErrors, g_numCompilerWarnings, g_numXStrings;
extern int32_t g_scriptVersion;
extern char g_szBuf[1024];
extern const char *EventNames[]; // MAXEVENTS
@ -142,11 +148,19 @@ void C_InitProjectiles(void);
extern int32_t g_numProjectiles;
typedef struct {
int g_i, g_p, g_x;
int32_t *g_t;
spritetype *g_sp;
DukePlayer_t *g_pp;
int g_flags;
int spriteNum;
int playerNum;
int playerDist;
int flags;
union {
spritetype * pSprite;
uspritetype *pUSprite;
};
int32_t * pData;
DukePlayer_t *pPlayer;
} vmstate_t;
extern vmstate_t vm;

File diff suppressed because it is too large Load diff

View file

@ -44,14 +44,14 @@ extern int32_t g_tw;
extern int32_t g_errorLineNum;
extern int32_t g_currentEventExec;
void A_LoadActor(int32_t iActor);
void A_LoadActor(int32_t spriteNum);
#endif
void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist);
void A_Fall(int nSprite);
int32_t A_FurthestVisiblePoint(int32_t iActor,uspritetype * const ts,int32_t *dax,int32_t *day);
int32_t A_GetFurthestAngle(int32_t iActor,int32_t angs);
void A_GetZLimits(int32_t iActor);
void A_Execute(int32_t spriteNum, int32_t playerNum, int32_t lDist);
void A_Fall(int spriteNum);
int32_t A_FurthestVisiblePoint(int32_t spriteNum,uspritetype * const ts,int32_t *dax,int32_t *day);
int32_t A_GetFurthestAngle(int spriteNum,int angDiv);
void A_GetZLimits(int32_t spriteNum);
int G_GetAngleDelta(int a,int na);
void G_RestoreMapState();
void G_SaveMapState();
@ -66,38 +66,38 @@ void VM_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32_t tilenum,
int32_t shade, int32_t orientation, int32_t p);
#endif
int32_t VM_OnEventWithBoth_(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn);
int32_t VM_OnEventWithReturn_(int nEventID, int nSprite, int nPlayer, int32_t nReturn);
int32_t VM_OnEventWithDist_(int nEventID, int nSprite, int nPlayer, int nDist);
int32_t VM_OnEvent_(int nEventID, int nSprite, int nPlayer);
int32_t VM_OnEventWithBoth_(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn);
int32_t VM_OnEventWithReturn_(int nEventID, int spriteNum, int playerNum, int32_t nReturn);
int32_t VM_OnEventWithDist_(int nEventID, int spriteNum, int playerNum, int nDist);
int32_t VM_OnEvent_(int nEventID, int spriteNum, int playerNum);
FORCE_INLINE int VM_HaveEvent(int nEventID)
{
#ifdef LUNATIC
return L_IsInitialized(&g_ElState) && El_HaveEvent(nEventID);
#else
return !!apScriptGameEvent[nEventID];
return !!apScriptEvents[nEventID];
#endif
}
FORCE_INLINE int32_t VM_OnEventWithBoth(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn)
FORCE_INLINE int32_t VM_OnEventWithBoth(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn)
{
return VM_HaveEvent(nEventID) ? VM_OnEventWithBoth_(nEventID, nSprite, nPlayer, nDist, nReturn) : nReturn;
return VM_HaveEvent(nEventID) ? VM_OnEventWithBoth_(nEventID, spriteNum, playerNum, nDist, nReturn) : nReturn;
}
FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int nSprite, int nPlayer, int nReturn)
FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int spriteNum, int playerNum, int nReturn)
{
return VM_HaveEvent(nEventID) ? VM_OnEventWithReturn_(nEventID, nSprite, nPlayer, nReturn) : nReturn;
return VM_HaveEvent(nEventID) ? VM_OnEventWithReturn_(nEventID, spriteNum, playerNum, nReturn) : nReturn;
}
FORCE_INLINE int32_t VM_OnEventWithDist(int nEventID, int nSprite, int nPlayer, int nDist)
FORCE_INLINE int32_t VM_OnEventWithDist(int nEventID, int spriteNum, int playerNum, int nDist)
{
return VM_HaveEvent(nEventID) ? VM_OnEventWithDist_(nEventID, nSprite, nPlayer, nDist) : 0;
return VM_HaveEvent(nEventID) ? VM_OnEventWithDist_(nEventID, spriteNum, playerNum, nDist) : 0;
}
FORCE_INLINE int32_t VM_OnEvent(int nEventID, int nSprite, int nPlayer)
FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum)
{
return VM_HaveEvent(nEventID) ? VM_OnEvent_(nEventID, nSprite, nPlayer) : 0;
return VM_HaveEvent(nEventID) ? VM_OnEvent_(nEventID, spriteNum, playerNum) : 0;
}
#define CON_ERRPRINTF(Text, ...) do { \
@ -105,7 +105,7 @@ FORCE_INLINE int32_t VM_OnEvent(int nEventID, int nSprite, int nPlayer)
} while (0)
void G_GetTimeDate(int32_t *vals);
int G_StartTrack(int nLevel);
int G_StartTrack(int levelNum);
int32_t A_Dodge(spritetype *s);
#ifdef LUNATIC
void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -76,11 +76,11 @@ enum GamearrayFlags_t
typedef struct
{
union {
intptr_t nValue;
intptr_t global;
intptr_t *pValues; // array of values when 'per-player', or 'per-actor'
};
intptr_t nDefault;
uintptr_t nFlags;
intptr_t defaultValue;
uintptr_t flags;
char * szLabel;
} gamevar_t;
@ -89,7 +89,7 @@ typedef struct
char * szLabel;
intptr_t *pValues; // array of values
intptr_t size;
intptr_t nFlags;
uintptr_t flags;
} gamearray_t;
#pragma pack(pop)
@ -101,23 +101,23 @@ extern int32_t g_gameVarCount;
extern int32_t g_gameArrayCount;
int32_t __fastcall Gv_GetGameArrayValue(int const id, int index);
int32_t __fastcall Gv_GetVar(int id, int nSprite, int nPlayer);
void __fastcall Gv_SetVar(int const id, int32_t const lValue, int const nSprite, int const nPlayer);
int32_t __fastcall Gv_GetVar(int id, int spriteNum, int playerNum);
void __fastcall Gv_SetVar(int const id, int32_t const lValue, int const spriteNum, int const playerNum);
int32_t __fastcall Gv_GetVarX(int id);
void __fastcall Gv_GetManyVars(int const count, int32_t * const rv);
void __fastcall Gv_SetVarX(int const id, int32_t const lValue);
int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t const lDefault,int32_t const iActor,int32_t const iPlayer);
int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t const lDefault,int32_t const spriteNum,int32_t const playerNum);
int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags);
int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
FORCE_INLINE void A_ResetVars(int const nSprite)
FORCE_INLINE void A_ResetVars(int const spriteNum)
{
for (int i = 0; i < g_gameVarCount; ++i)
{
if ((aGameVars[i].nFlags & (GAMEVAR_PERACTOR | GAMEVAR_NODEFAULT)) != GAMEVAR_PERACTOR)
if ((aGameVars[i].flags & (GAMEVAR_PERACTOR | GAMEVAR_NODEFAULT)) != GAMEVAR_PERACTOR)
continue;
aGameVars[i].pValues[nSprite] = aGameVars[i].nDefault;
aGameVars[i].pValues[spriteNum] = aGameVars[i].defaultValue;
}
}
@ -125,11 +125,11 @@ void Gv_DumpValues(void);
void Gv_InitWeaponPointers(void);
void Gv_RefreshPointers(void);
void Gv_ResetVars(void);
int32_t Gv_ReadSave(int32_t fil,int32_t newbehav);
void Gv_WriteSave(FILE *fil,int32_t newbehav);
int32_t Gv_ReadSave(int32_t kFile);
void Gv_WriteSave(FILE *fil);
#else
extern int32_t g_noResetVars;
extern LUNATIC_CB void (*A_ResetVars)(int32_t iActor);
extern LUNATIC_CB void (*A_ResetVars)(int32_t spriteNum);
#endif
void Gv_ResetSystemDefaults(void);
@ -137,62 +137,62 @@ void Gv_Init(void);
void Gv_FinalizeWeaponDefaults(void);
#if !defined LUNATIC
#define VM_GAMEVAR_OPERATOR(func, operator) \
FORCE_INLINE void __fastcall func(int const id, int32_t const nValue) \
{ \
switch (aGameVars[id].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \
{ \
default: aGameVars[id].nValue operator nValue; break; \
case GAMEVAR_PERPLAYER: \
if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p > MAXPLAYERS - 1)) \
break; \
aGameVars[id].pValues[vm.g_p] operator nValue; \
break; \
case GAMEVAR_PERACTOR: \
if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i > MAXSPRITES - 1)) \
break; \
aGameVars[id].pValues[vm.g_i] operator nValue; \
break; \
case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].nValue) operator(int32_t) nValue; break; \
case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].nValue) operator(int16_t) nValue; break; \
case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].nValue) operator(uint8_t) nValue; break; \
} \
#define VM_GAMEVAR_OPERATOR(func, operator) \
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; \
case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].global) operator(int32_t) operand; break; \
case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].global) operator(int16_t) operand; break; \
case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].global) operator(uint8_t) operand; break; \
} \
}
#if defined(__arm__) || defined(LIBDIVIDE_ALWAYS)
FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const nValue)
FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const operand)
{
if (EDUKE32_PREDICT_FALSE((aGameVars[id].nFlags & GAMEVAR_PERPLAYER && (unsigned) vm.g_p > MAXPLAYERS - 1) ||
(aGameVars[id].nFlags & GAMEVAR_PERACTOR && (unsigned) vm.g_i > MAXSPRITES - 1)))
if (EDUKE32_PREDICT_FALSE((aGameVars[id].flags & GAMEVAR_PERPLAYER && (unsigned) vm.playerNum > MAXPLAYERS - 1) ||
(aGameVars[id].flags & GAMEVAR_PERACTOR && (unsigned) vm.spriteNum > MAXSPRITES - 1)))
return;
static libdivide_s32_t sdiv;
static int32_t nLastValue;
libdivide_s32_t *dptr = ((unsigned) nValue < DIVTABLESIZE) ? (libdivide_s32_t *) &divtable32[nValue] : &sdiv;
intptr_t *iptr = &aGameVars[id].nValue;
static int32_t lastValue;
libdivide_s32_t *dptr = ((unsigned) operand < DIVTABLESIZE) ? (libdivide_s32_t *) &divtable32[operand] : &sdiv;
intptr_t *iptr = &aGameVars[id].global;
if (nValue == nLastValue || dptr != &sdiv)
if (operand == lastValue || dptr != &sdiv)
goto skip;
sdiv = libdivide_s32_gen((nLastValue = nValue));
sdiv = libdivide_s32_gen((lastValue = operand));
skip:
switch (aGameVars[id].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK))
switch (aGameVars[id].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK))
{
case GAMEVAR_PERPLAYER: iptr = &aGameVars[id].pValues[vm.g_p];
case GAMEVAR_PERPLAYER: iptr = &aGameVars[id].pValues[vm.playerNum];
default: break;
case GAMEVAR_PERACTOR: iptr = &aGameVars[id].pValues[vm.g_i]; break;
case GAMEVAR_PERACTOR: iptr = &aGameVars[id].pValues[vm.spriteNum]; break;
case GAMEVAR_INTPTR:
*((int32_t *)aGameVars[id].nValue) =
(int32_t)libdivide_s32_do(*((int32_t *)aGameVars[id].nValue), dptr);
*((int32_t *)aGameVars[id].global) =
(int32_t)libdivide_s32_do(*((int32_t *)aGameVars[id].global), dptr);
return;
case GAMEVAR_SHORTPTR:
*((int16_t *)aGameVars[id].nValue) =
(int16_t)libdivide_s32_do(*((int16_t *)aGameVars[id].nValue), dptr);
*((int16_t *)aGameVars[id].global) =
(int16_t)libdivide_s32_do(*((int16_t *)aGameVars[id].global), dptr);
return;
case GAMEVAR_CHARPTR:
*((uint8_t *)aGameVars[id].nValue) =
(uint8_t)libdivide_s32_do(*((uint8_t *)aGameVars[id].nValue), dptr);
*((uint8_t *)aGameVars[id].global) =
(uint8_t)libdivide_s32_do(*((uint8_t *)aGameVars[id].global), dptr);
return;
}

View file

@ -35,7 +35,7 @@ extern "C" {
// JBF: g_spriteGravity modified to default to Atomic ed. default when using 1.3d CONs
int32_t g_spriteGravity=176;
int16_t g_spriteDeleteQueueSize = 64;
int16_t g_deleteQueueSize = 64;
char EpisodeNames[MAXVOLUMES][33] = { "L.A. Meltdown", "Lunar Apocalypse", "Shrapnel City" };
int32_t EpisodeFlags[MAXVOLUMES]; // all initialize to zero

View file

@ -69,7 +69,7 @@ G_EXTERN actor_t actor[MAXSPRITES];
// g_tile: tile-specific data THAT DOES NOT CHANGE during the course of a game
G_EXTERN tiledata_t g_tile[MAXTILES];
G_EXTERN animwalltype animwall[MAXANIMWALLS];
G_EXTERN char *ScriptQuotes[MAXQUOTES],*ScriptQuoteRedefinitions[MAXQUOTES];
G_EXTERN char *apStrings[MAXQUOTES],*apXStrings[MAXQUOTES];
G_EXTERN char *label;
G_EXTERN int32_t g_musicIndex;
G_EXTERN char g_loadFromGroupOnly;
@ -83,6 +83,7 @@ G_EXTERN char szPlayerName[MAXPLAYERNAME];
G_EXTERN char tempbuf[MAXSECTORS<<1],packbuf[PACKBUF_SIZE],menutextbuf[128],buf[1024];
#define TYPEBUFSIZE 141
G_EXTERN char typebuf[TYPEBUFSIZE];
G_EXTERN input_t avg;
G_EXTERN input_t loc;
G_EXTERN input_t recsync[RECSYNCBUFSIZ];
@ -119,8 +120,8 @@ G_EXTERN int32_t startofdynamicinterpolations;
G_EXTERN int32_t ototalclock;
G_EXTERN intptr_t *g_scriptPtr;
G_EXTERN int32_t *labelcode,*labeltype;
G_EXTERN intptr_t *script;
G_EXTERN map_t MapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" and "loading" music
G_EXTERN intptr_t *apScript;
G_EXTERN map_t aMapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" and "loading" music
// XXX: I think this pragma pack is meaningless here.
// MSDN (https://msdn.microsoft.com/en-us/library/2e70t5y1%28VS.80%29.aspx) says:
@ -142,39 +143,39 @@ G_EXTERN sound_t g_sounds[MAXSOUNDS];
G_EXTERN uint32_t everyothertime;
G_EXTERN uint32_t g_moveThingsCount;
G_EXTERN vec3_t my,omy,myvel;
G_EXTERN char g_soundlocks[MAXSOUNDS];
G_EXTERN char g_soundlocks[MAXSOUNDS];
G_EXTERN int32_t g_restorePalette;
G_EXTERN int32_t g_screenCapture;
G_EXTERN int32_t g_noEnemies;
#ifndef global_c_
extern const char *s_buildDate;
extern int32_t g_spriteGravity;
extern int16_t g_spriteDeleteQueueSize;
extern char EpisodeNames[MAXVOLUMES][33];
extern int32_t EpisodeFlags[MAXVOLUMES];
extern char SkillNames[MAXSKILLS][33];
extern char GametypeNames[MAXGAMETYPES][33];
extern int32_t GametypeFlags[MAXGAMETYPES];
extern char g_numGametypes;
extern char g_numVolumes;
extern int32_t g_timerTicsPerSecond;
extern int32_t g_actorRespawnTime;
extern int32_t g_itemRespawnTime;
extern int32_t g_scriptSize;
extern int16_t BlimpSpawnSprites[15];
extern int32_t g_playerFriction;
extern int32_t g_numFreezeBounces;
extern int32_t g_lastSaveSlot;
extern int32_t g_rpgBlastRadius;
extern int32_t g_pipebombBlastRadius;
extern int32_t g_tripbombBlastRadius;
extern int32_t g_shrinkerBlastRadius;
extern int32_t g_morterBlastRadius;
extern int32_t g_bouncemineBlastRadius;
extern int32_t g_seenineBlastRadius;
extern char CheatKeys[2];
extern char setupfilename[BMAX_PATH];
extern int32_t g_spriteGravity;
extern int16_t g_deleteQueueSize;
extern char EpisodeNames[MAXVOLUMES][33];
extern int32_t EpisodeFlags[MAXVOLUMES];
extern char SkillNames[MAXSKILLS][33];
extern char GametypeNames[MAXGAMETYPES][33];
extern int32_t GametypeFlags[MAXGAMETYPES];
extern char g_numGametypes;
extern char g_numVolumes;
extern int32_t g_timerTicsPerSecond;
extern int32_t g_actorRespawnTime;
extern int32_t g_itemRespawnTime;
extern int32_t g_scriptSize;
extern int16_t BlimpSpawnSprites[15];
extern int32_t g_playerFriction;
extern int32_t g_numFreezeBounces;
extern int32_t g_lastSaveSlot;
extern int32_t g_rpgBlastRadius;
extern int32_t g_pipebombBlastRadius;
extern int32_t g_tripbombBlastRadius;
extern int32_t g_shrinkerBlastRadius;
extern int32_t g_morterBlastRadius;
extern int32_t g_bouncemineBlastRadius;
extern int32_t g_seenineBlastRadius;
extern char CheatKeys[2];
extern char setupfilename[BMAX_PATH];
#endif
enum

View file

@ -83,7 +83,7 @@ typedef struct scriptsection
typedef struct
{
ScriptSectionType * script;
ScriptSectionType * apScript;
ScriptSectionType * lastsection;
ScriptLineType * scriptlines;
char scriptfilename[128];

View file

@ -73,17 +73,17 @@ void SCRIPT_Delete(int32_t scripthandle)
if (!SC(scripthandle)) return;
if (SCRIPT(scripthandle,script))
if (SCRIPT(scripthandle,apScript))
{
while (SCRIPT(scripthandle,script)->nextsection != SCRIPT(scripthandle,script))
while (SCRIPT(scripthandle,apScript)->nextsection != SCRIPT(scripthandle,apScript))
{
s = SCRIPT(scripthandle,script)->nextsection;
SCRIPT_FreeSection(SCRIPT(scripthandle,script));
Bfree(SCRIPT(scripthandle,script));
SCRIPT(scripthandle,script) = s;
s = SCRIPT(scripthandle,apScript)->nextsection;
SCRIPT_FreeSection(SCRIPT(scripthandle,apScript));
Bfree(SCRIPT(scripthandle,apScript));
SCRIPT(scripthandle,apScript) = s;
}
Bfree(SCRIPT(scripthandle,script));
Bfree(SCRIPT(scripthandle,apScript));
}
Bfree(SC(scripthandle));
@ -138,9 +138,9 @@ ScriptSectionType * SCRIPT_SectionExists(int32_t scripthandle, const char * sect
if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return NULL;
if (!sectionname) return NULL;
if (!SC(scripthandle)) return NULL;
if (!SCRIPT(scripthandle,script)) return NULL;
if (!SCRIPT(scripthandle,apScript)) return NULL;
for (s = SCRIPT(scripthandle,script); ls != s; ls=s,s=s->nextsection)
for (s = SCRIPT(scripthandle,apScript); ls != s; ls=s,s=s->nextsection)
if (!Bstrcasecmp(s->name, sectionname)) return s;
return NULL;
@ -159,13 +159,13 @@ ScriptSectionType * SCRIPT_AddSection(int32_t scripthandle, const char * section
AllocSection(s);
s->name = Bstrdup(sectionname);
if (!SCRIPT(scripthandle,script))
if (!SCRIPT(scripthandle,apScript))
{
SCRIPT(scripthandle,script) = s;
SCRIPT(scripthandle,apScript) = s;
}
else
{
s2 = SCRIPT(scripthandle,script);
s2 = SCRIPT(scripthandle,apScript);
while (s2->nextsection != s2) s2=s2->nextsection;
s2->nextsection = s;
s->prevsection = s2;
@ -503,9 +503,9 @@ int32_t SCRIPT_NumberSections(int32_t scripthandle)
ScriptSectionType *s,*ls=NULL;
if (!SC(scripthandle)) return 0;
if (!SCRIPT(scripthandle,script)) return 0;
if (!SCRIPT(scripthandle,apScript)) return 0;
for (s = SCRIPT(scripthandle,script); ls != s; ls=s,s=s->nextsection) c++;
for (s = SCRIPT(scripthandle,apScript); ls != s; ls=s,s=s->nextsection) c++;
return c;
}
@ -515,9 +515,9 @@ char const * SCRIPT_Section(int32_t scripthandle, int32_t which)
ScriptSectionType *s,*ls=NULL;
if (!SC(scripthandle)) return "";
if (!SCRIPT(scripthandle,script)) return "";
if (!SCRIPT(scripthandle,apScript)) return "";
for (s = SCRIPT(scripthandle,script); which>0 && ls != s; ls=s, s=s->nextsection, which--) ;
for (s = SCRIPT(scripthandle,apScript); which>0 && ls != s; ls=s, s=s->nextsection, which--) ;
return s->name;
}
@ -529,7 +529,7 @@ int32_t SCRIPT_NumberEntries(int32_t scripthandle, char const * sectionname)
int32_t c=0;
if (!SC(scripthandle)) return 0;
if (!SCRIPT(scripthandle,script)) return 0;
if (!SCRIPT(scripthandle,apScript)) return 0;
s = SCRIPT_SectionExists(scripthandle, sectionname);
if (!s) return 0;
@ -544,7 +544,7 @@ char const * SCRIPT_Entry(int32_t scripthandle, char const * sectionname, int32_
ScriptEntryType *e,*le=NULL;
if (!SC(scripthandle)) return 0;
if (!SCRIPT(scripthandle,script)) return 0;
if (!SCRIPT(scripthandle,apScript)) return 0;
s = SCRIPT_SectionExists(scripthandle, sectionname);
if (!s) return "";
@ -559,7 +559,7 @@ char const * SCRIPT_GetRaw(int32_t scripthandle, char const * sectionname, char
ScriptEntryType *e;
if (!SC(scripthandle)) return 0;
if (!SCRIPT(scripthandle,script)) return 0;
if (!SCRIPT(scripthandle,apScript)) return 0;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);
@ -654,7 +654,7 @@ int32_t SCRIPT_GetStringPtr(int32_t scripthandle, char const * sectionname, char
char *p;
if (!SC(scripthandle)) return 1;
if (!SCRIPT(scripthandle,script)) return 1;
if (!SCRIPT(scripthandle,apScript)) return 1;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);
@ -681,7 +681,7 @@ int32_t SCRIPT_GetDoubleString(int32_t scripthandle, const char * sectionname, c
char *p;
if (!SC(scripthandle)) return 1;
if (!SCRIPT(scripthandle,script)) return 1;
if (!SCRIPT(scripthandle,apScript)) return 1;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);
@ -712,7 +712,7 @@ int32_t SCRIPT_GetNumber(int32_t scripthandle, const char * sectionname, const c
char *p;
if (!SC(scripthandle)) return 1;
if (!SCRIPT(scripthandle,script)) return 1;
if (!SCRIPT(scripthandle,apScript)) return 1;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);
@ -743,7 +743,7 @@ int32_t SCRIPT_GetBoolean(int32_t scripthandle, char const * sectionname, char c
ScriptEntryType *e;
if (!SC(scripthandle)) return 1;
if (!SCRIPT(scripthandle,script)) return 1;
if (!SCRIPT(scripthandle,apScript)) return 1;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);

View file

@ -364,7 +364,7 @@ int32_t A_InsertSprite(int16_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int1
uint8_t s_xr,uint8_t s_yr,int16_t s_a,int16_t s_ve,int16_t s_zv,int16_t s_ow,int16_t s_ss);
extern void A_AddToDeleteQueue(int32_t i);
extern int32_t A_PlaySound(uint32_t num, int32_t i);
extern void A_DeleteSprite(int32_t s);
void A_DeleteSprite(int spriteNum);
extern void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect,
int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t unbiasedp);
extern void G_GameExit(const char *msg);
@ -575,7 +575,7 @@ static int32_t SetActor_CF(lua_State *L)
//////////////////////////////
static int32_t call_regd_function3(lua_State *L, void *keyaddr,
int32_t iActor, int32_t iPlayer, int32_t lDist)
int32_t spriteNum, int32_t playerNum, int32_t lDist)
{
#if !defined NDEBUG
const int32_t top = lua_gettop(L);
@ -586,8 +586,8 @@ static int32_t call_regd_function3(lua_State *L, void *keyaddr,
lua_pushlightuserdata(L, keyaddr);
lua_gettable(L, LUA_REGISTRYINDEX);
lua_pushinteger(L, iActor);
lua_pushinteger(L, iPlayer);
lua_pushinteger(L, spriteNum);
lua_pushinteger(L, playerNum);
lua_pushinteger(L, lDist);
// -- call it! --
@ -611,7 +611,7 @@ static void El_EventErrorPrint(const char *errmsg)
EventNames[g_eventIdx], errmsg);
}
int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t *iReturn)
int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t spriteNum, int32_t playerNum, int32_t lDist, int32_t *iReturn)
{
// XXX: estate must be the one where the events were registered...
// make a global?
@ -623,7 +623,7 @@ int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t
g_RETURN = *iReturn;
g_elCallDepth++;
i = call_regd_function3(L, &g_elEvents[eventidx], iActor, iPlayer, lDist);
i = call_regd_function3(L, &g_elEvents[eventidx], spriteNum, playerNum, lDist);
g_elCallDepth--;
*iReturn = g_RETURN;
@ -646,19 +646,19 @@ static void El_ActorErrorPrint(const char *errmsg)
g_actorTile, g_iActor, errmsg);
}
int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t iActor, int32_t iPlayer, int32_t lDist)
int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t spriteNum, int32_t playerNum, int32_t lDist)
{
lua_State *const L = estate->L;
int32_t i;
g_elCallDepth++;
i = call_regd_function3(L, &g_elActors[actortile], iActor, iPlayer, lDist);
i = call_regd_function3(L, &g_elActors[actortile], spriteNum, playerNum, lDist);
g_elCallDepth--;
if (i != 0)
{
g_actorTile = actortile;
g_iActor = iActor;
g_iActor = spriteNum;
return L_HandleError(L, i, &El_ActorErrorPrint);
}

View file

@ -40,8 +40,8 @@ void El_DisplayErrors(void);
int32_t El_CreateState(L_State *estate, const char *name);
void El_DestroyState(L_State *estate);
int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t *iReturn);
int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t iActor, int32_t iPlayer, int32_t lDist);
int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t spriteNum, int32_t playerNum, int32_t lDist, int32_t *iReturn);
int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t spriteNum, int32_t playerNum, int32_t lDist);
extern int8_t el_addNewErrors; // add new errors to display?
void El_OnError(const char *str);

View file

@ -28,16 +28,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//#include "osd.h"
#include "keys.h"
char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling
static char g_szCurrentBlockName[BMAX_PATH] = "(none)", g_szLastBlockName[BMAX_PATH] = "NULL";
char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling
static char g_szCurrentBlockName[BMAX_PATH] = "(none)";
static char g_szLastBlockName[BMAX_PATH] = "NULL";
////// compiler state vvv
static const char *textptr, *start_textptr, *g_curkwptr;
static int32_t def_tw;
int32_t g_totalLines, g_lineNumber;
int32_t g_numCompilerErrors, g_numCompilerWarnings;
int32_t g_didDefineSomething;
static char const *textptr;
static char const *start_textptr;
static char const *g_curkwptr;
static int32_t def_tw;
int32_t g_totalLines;
int32_t g_lineNumber;
int32_t g_numCompilerErrors;
int32_t g_numCompilerWarnings;
int32_t g_didDefineSomething;
typedef struct
{
@ -61,42 +65,46 @@ static compilerstate_t cs;
static compilerstate_t cs_default = {-1, -1, NULL, -1, -1, 0, 0, NULL, NULL, 0, 0, 0, 0};
////// -------------------
instype *script = NULL;
instype *g_scriptPtr;
int32_t g_scriptSize = 65536;
int32_t *constants, constants_allocsize=1024;
int32_t g_numSavedConstants=0;
static int32_t g_wasConstant=0;
char *label;
int32_t *labelval;
uint8_t *labeltype;
int32_t g_numLabels=0, g_numDefaultLabels=0;
static int32_t label_allocsize = 512;
int32_t g_stateCount = 0;
statesinfo_t *statesinfo = NULL;
static int32_t statesinfo_allocsize = 512;
instype * apScript = NULL;
instype * g_scriptPtr;
int32_t g_scriptSize = 65536;
int32_t * constants;
int32_t constants_allocsize = 1024;
int32_t g_numSavedConstants = 0;
static int32_t g_wasConstant = 0;
char * label;
int32_t * labelval;
uint8_t * labeltype;
int32_t g_numLabels = 0;
int32_t g_numDefaultLabels = 0;
static int32_t label_allocsize = 512;
int32_t g_stateCount = 0;
statesinfo_t * statesinfo = NULL;
static int32_t statesinfo_allocsize = 512;
static int32_t interactive_compilation = 0;
static char tempbuf[2048];
static char tlabel[MAXLABELLEN], tlabel2[MAXLABELLEN];
static char tlabel[MAXLABELLEN];
static char tlabel2[MAXLABELLEN];
int32_t g_iReturnVar=0;
int32_t m32_sortvar1, m32_sortvar2;
int32_t g_iReturnVar = 0;
char *ScriptQuotes[MAXQUOTES+1], *ScriptQuoteRedefinitions[MAXQUOTES+1];
int32_t g_numQuoteRedefinitions = 0;
int32_t m32_sortvar1;
int32_t m32_sortvar2;
ofstype aEventOffsets[MAXEVENTS];
int32_t aEventSizes[MAXEVENTS];
uint16_t aEventNumLocals[MAXEVENTS];
char * apStrings[MAXQUOTES + 1];
char * apXStrings[MAXQUOTES + 1];
int32_t g_numXStrings = 0;
gamevar_t aGameVars[MAXGAMEVARS];
ofstype aEventOffsets[MAXEVENTS];
int32_t aEventSizes[MAXEVENTS];
uint16_t aEventNumLocals[MAXEVENTS];
gamevar_t aGameVars[MAXGAMEVARS];
gamearray_t aGameArrays[MAXGAMEARRAYS];
int32_t g_gameVarCount=0, g_systemVarCount=0;
int32_t g_gameArrayCount=0, g_systemArrayCount=0;
int32_t g_gameVarCount = 0;
int32_t g_systemVarCount = 0;
int32_t g_gameArrayCount = 0;
int32_t g_systemArrayCount = 0;
// "magic" number for { and }, overrides line number in compiled code for later detection
@ -611,9 +619,9 @@ static void C_InitHashes()
// returns: 0:success, 1:failure
static int32_t C_SetScriptSize(int32_t size)
{
ofstype oscriptOfs = (unsigned)(g_scriptPtr-script);
ofstype ocaseScriptOfs = (unsigned)(cs.caseScriptPtr-script);
ofstype ocaseCodeOfs = (unsigned)(cs.caseCodePtr-script);
ofstype oscriptOfs = (unsigned)(g_scriptPtr-apScript);
ofstype ocaseScriptOfs = (unsigned)(cs.caseScriptPtr-apScript);
ofstype ocaseCodeOfs = (unsigned)(cs.caseCodePtr-apScript);
instype *newscript;
int32_t osize = g_scriptSize;
@ -625,24 +633,24 @@ static int32_t C_SetScriptSize(int32_t size)
g_scriptSize = size;
initprintf("Resizing code buffer to %d*%d bytes\n", g_scriptSize, (int32_t)sizeof(instype));
newscript = (instype *)Xrealloc(script, g_scriptSize * sizeof(instype));
newscript = (instype *)Xrealloc(apScript, g_scriptSize * sizeof(instype));
if (size >= osize)
Bmemset(&newscript[osize], 0, (size-osize) * sizeof(instype));
if (script != newscript)
if (apScript != newscript)
{
initprintf("Relocating compiled code from to 0x%" PRIxPTR " to 0x%" PRIxPTR "\n", (intptr_t)script, (intptr_t)newscript);
script = newscript;
initprintf("Relocating compiled code from to 0x%" PRIxPTR " to 0x%" PRIxPTR "\n", (intptr_t)apScript, (intptr_t)newscript);
apScript = newscript;
}
g_scriptPtr = (instype *)(script+oscriptOfs);
g_scriptPtr = (instype *)(apScript+oscriptOfs);
// initprintf("script: %d, \n",script); initprintf("offset: %d\n",(unsigned)(g_scriptPtr-script));
if (cs.caseScriptPtr != NULL)
cs.caseScriptPtr = (instype *)(script+ocaseScriptOfs);
cs.caseScriptPtr = (instype *)(apScript+ocaseScriptOfs);
if (cs.caseCodePtr != NULL)
cs.caseCodePtr = (instype *)(script+ocaseCodeOfs);
cs.caseCodePtr = (instype *)(apScript+ocaseCodeOfs);
return 0;
}
@ -703,7 +711,7 @@ static int32_t C_SkipComments(void)
// Be sure to have enough space allocated for the command to be parsed next.
// Currently, the commands that potentially need the most space are
// various string handling function that accept inline strings.
if ((unsigned)(g_scriptPtr-script) > (unsigned)(g_scriptSize - max(40, MAXQUOTELEN/sizeof(instype)+8)))
if ((unsigned)(g_scriptPtr-apScript) > (unsigned)(g_scriptSize - max(40, MAXQUOTELEN/sizeof(instype)+8)))
return C_SetScriptSize(g_scriptSize<<1);
return 0;
@ -1032,7 +1040,7 @@ static void C_GetNextVarType(int32_t type)
{
// current sprite shortcut access
int32_t lLabelID;
int32_t labelNum;
flags = M32_FLAG_STRUCT;
if (*textptr=='-')
@ -1045,16 +1053,16 @@ static void C_GetNextVarType(int32_t type)
/// now pointing at 'xxx'
C_GetNextLabelName(0);
lLabelID = C_GetLabelNameID(SpriteLabels, &h_sprite, Bstrtolower(tlabel));
labelNum = C_GetLabelNameID(SpriteLabels, &h_sprite, Bstrtolower(tlabel));
if (lLabelID == -1)
if (labelNum == -1)
{
g_numCompilerErrors++;
C_ReportError(ERROR_SYMBOLNOTRECOGNIZED);
return;
}
*g_scriptPtr++ = ((M32_THISACTOR_VAR_ID<<16) | flags | (lLabelID<<2) | M32_SPRITE_VAR_ID);
*g_scriptPtr++ = ((M32_THISACTOR_VAR_ID<<16) | flags | (labelNum<<2) | M32_SPRITE_VAR_ID);
return;
}
@ -1091,7 +1099,7 @@ static void C_GetNextVarType(int32_t type)
if (*textptr == '[') //read of array as a gamevar
{
int32_t lLabelID = -1, aridx;
int32_t labelNum = -1, aridx;
int32_t lightp = 0;
textptr++;
@ -1218,16 +1226,16 @@ static void C_GetNextVarType(int32_t type)
/*initprintf("found xxx label of \"%s\"\n", label+(g_numLabels*MAXLABELLEN));*/
if (lightp)
lLabelID = C_GetLabelNameID(LightLabels, &h_light, Bstrtolower(tlabel));
labelNum = C_GetLabelNameID(LightLabels, &h_light, Bstrtolower(tlabel));
else if (id==M32_SPRITE_VAR_ID || id==M32_TSPRITE_VAR_ID)
lLabelID = C_GetLabelNameID(SpriteLabels, &h_sprite, Bstrtolower(tlabel));
labelNum = C_GetLabelNameID(SpriteLabels, &h_sprite, Bstrtolower(tlabel));
else if (id==M32_SECTOR_VAR_ID)
lLabelID = C_GetLabelNameID(SectorLabels, &h_sector, Bstrtolower(tlabel));
labelNum = C_GetLabelNameID(SectorLabels, &h_sector, Bstrtolower(tlabel));
else if (id==M32_WALL_VAR_ID)
lLabelID = C_GetLabelNameID(WallLabels, &h_wall, Bstrtolower(tlabel));
//printf("LabelID is %d\n",lLabelID);
labelNum = C_GetLabelNameID(WallLabels, &h_wall, Bstrtolower(tlabel));
//printf("LabelID is %d\n",labelNum);
if (lLabelID == -1)
if (labelNum == -1)
{
g_numCompilerErrors++;
C_ReportError(ERROR_SYMBOLNOTRECOGNIZED);
@ -1235,9 +1243,9 @@ static void C_GetNextVarType(int32_t type)
}
if ((aridx & M32_BITS_MASK) == M32_FLAG_CONSTANTINDEX)
*g_scriptPtr++ = (aridx | flags | (lLabelID<<2) | id);
*g_scriptPtr++ = (aridx | flags | (labelNum<<2) | id);
else // simple or local gamevar
*g_scriptPtr++ = (aridx<<16 | flags | (lLabelID<<2) | id);
*g_scriptPtr++ = (aridx<<16 | flags | (labelNum<<2) | id);
}
return;
@ -1537,7 +1545,7 @@ static int32_t C_CheckMalformedBranch(ofstype lastScriptOfs)
case CON_ENDEVENT:
case CON_ENDS:
case CON_ELSE:
g_scriptPtr = script + lastScriptOfs;
g_scriptPtr = apScript + lastScriptOfs;
cs.ifElseAborted = 1;
C_CUSTOMWARNING("malformed `%s' branch", keyw[*g_scriptPtr & 0xFFF]);
return 1;
@ -1559,7 +1567,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, ofstype lastScriptOfs)
if (cs.ifElseAborted)
{
g_scriptPtr = script + lastScriptOfs;
g_scriptPtr = apScript + lastScriptOfs;
C_CUSTOMWARNING("empty `%s' branch", keyw[*g_scriptPtr & 0xFFF]);
*g_scriptPtr = (CON_NULLOP + (IFELSE_MAGIC<<12));
return 1;
@ -1574,8 +1582,8 @@ static int32_t C_CountCaseStatements()
int32_t lCount;
const char *temptextptr = textptr;
int32_t temp_ScriptLineNumber = g_lineNumber;
ofstype scriptoffset = (unsigned)(g_scriptPtr-script);
ofstype caseoffset = (unsigned)(cs.caseScriptPtr-script);
ofstype scriptoffset = (unsigned)(g_scriptPtr-apScript);
ofstype caseoffset = (unsigned)(cs.caseScriptPtr-apScript);
cs.numCases=0;
cs.caseScriptPtr=NULL;
@ -1590,13 +1598,13 @@ static int32_t C_CountCaseStatements()
cs.checkingSwitch++;
textptr = temptextptr;
g_scriptPtr = (instype *)(script+scriptoffset);
g_scriptPtr = (instype *)(apScript+scriptoffset);
g_lineNumber = temp_ScriptLineNumber;
lCount = cs.numCases;
cs.numCases = 0;
cs.caseScriptPtr = (instype *)(script+caseoffset);
cs.caseScriptPtr = (instype *)(apScript+caseoffset);
return lCount;
}
@ -1786,7 +1794,7 @@ static int32_t C_ParseCommand(void)
}
cs.currentStateOfs = (g_scriptPtr-script);
cs.currentStateOfs = (g_scriptPtr-apScript);
j = hash_find(&h_states, tlabel);
if (j>=0) // only redefining
@ -1866,7 +1874,7 @@ static int32_t C_ParseCommand(void)
if (g_numCompilerErrors)
{
g_scriptPtr = script+cs.currentStateOfs;
g_scriptPtr = apScript+cs.currentStateOfs;
cs.currentStateOfs = -1;
cs.currentStateIdx = -1;
Bsprintf(g_szCurrentBlockName,"(none)");
@ -1878,7 +1886,7 @@ static int32_t C_ParseCommand(void)
if (cs.currentStateIdx == g_stateCount) // we were defining a new state
{
statesinfo[j].ofs = cs.currentStateOfs;
statesinfo[j].codesize = (g_scriptPtr-script) - cs.currentStateOfs;
statesinfo[j].codesize = (g_scriptPtr-apScript) - cs.currentStateOfs;
g_stateCount++;
@ -1890,7 +1898,7 @@ static int32_t C_ParseCommand(void)
int32_t oofs = statesinfo[j].ofs;
int32_t nofs = cs.currentStateOfs;
int32_t osize = statesinfo[j].codesize;
int32_t nsize = (g_scriptPtr-script) - nofs;
int32_t nsize = (g_scriptPtr-apScript) - nofs;
if (nsize == osize)
{
@ -1898,8 +1906,8 @@ static int32_t C_ParseCommand(void)
for (ii=0; ii<nsize; ii++)
{
ow = *(script+oofs+ii);
nw = *(script+nofs+ii);
ow = *(apScript+oofs+ii);
nw = *(apScript+nofs+ii);
if (ow != nw)
{
int32_t ld = (nw>>12) - (ow>>12);
@ -1918,7 +1926,7 @@ static int32_t C_ParseCommand(void)
}
if (equal!=2)
Bmemcpy(script+oofs, script+nofs, nsize*sizeof(instype));
Bmemcpy(apScript+oofs, apScript+nofs, nsize*sizeof(instype));
if (equal==0)
initprintf(" Redefined State %3d `%s'.\n", j, g_szCurrentBlockName);
// initprintf(" oo:%d os:%d, no:%d ns:%d\n", oofs, osize, nofs, nsize);
@ -1926,9 +1934,9 @@ static int32_t C_ParseCommand(void)
else
{
int32_t ii;
uint32_t movedcodesize = g_scriptPtr - (script+oofs+osize);
uint32_t movedcodesize = g_scriptPtr - (apScript+oofs+osize);
Bmemmove(script+oofs, script+oofs+osize, movedcodesize*sizeof(instype));
Bmemmove(apScript+oofs, apScript+oofs+osize, movedcodesize*sizeof(instype));
for (ii=0; ii<g_stateCount; ii++)
{
@ -2051,7 +2059,7 @@ static int32_t C_ParseCommand(void)
cs.currentEvent = j;
aEventNumLocals[j] = 0;
cs.parsingEventOfs = g_scriptPtr-script;
cs.parsingEventOfs = g_scriptPtr-apScript;
//Bsprintf(g_szBuf,"Adding Event for %d at %lX",j, g_parsingEventPtr); AddLog(g_szBuf);
if (j<0 || j >= MAXEVENTS)
@ -2086,7 +2094,7 @@ static int32_t C_ParseCommand(void)
if (g_numCompilerErrors)
{
g_scriptPtr = script+cs.parsingEventOfs;
g_scriptPtr = apScript+cs.parsingEventOfs;
cs.parsingEventOfs = -1;
cs.currentEvent = -1;
Bsprintf(g_szCurrentBlockName, "(none)");
@ -2097,7 +2105,7 @@ static int32_t C_ParseCommand(void)
if (aEventOffsets[j] >= 0) // if event was previously declared, overwrite it
{
int32_t oofs = aEventOffsets[j], nofs = cs.parsingEventOfs;
int32_t osize = aEventSizes[j], nsize = (g_scriptPtr-script) - nofs;
int32_t osize = aEventSizes[j], nsize = (g_scriptPtr-apScript) - nofs;
if (osize == nsize)
{
@ -2105,8 +2113,8 @@ static int32_t C_ParseCommand(void)
for (ii=0; ii<nsize; ii++)
{
ow = *(script+oofs+ii);
nw = *(script+nofs+ii);
ow = *(apScript+oofs+ii);
nw = *(apScript+nofs+ii);
if (ow != nw)
{
int32_t ld = (nw>>12) - (ow>>12);
@ -2125,7 +2133,7 @@ static int32_t C_ParseCommand(void)
}
if (equal!=2)
Bmemcpy(script+oofs, script+nofs, nsize*sizeof(instype));
Bmemcpy(apScript+oofs, apScript+nofs, nsize*sizeof(instype));
if (equal==0)
initprintf(" Redefined Event %3d `%s'.\n", j, g_szCurrentBlockName);
// initprintf(" oo:%d os:%d, no:%d ns:%d\n", oofs, osize, nofs, nsize);
@ -2133,9 +2141,9 @@ static int32_t C_ParseCommand(void)
else
{
int32_t ii;
uint32_t movedcodesize = g_scriptPtr - (script+oofs + osize);
uint32_t movedcodesize = g_scriptPtr - (apScript+oofs + osize);
Bmemmove(script+oofs, script+oofs + osize, movedcodesize*sizeof(instype));
Bmemmove(apScript+oofs, apScript+oofs + osize, movedcodesize*sizeof(instype));
for (ii=0; ii<g_stateCount; ii++)
{
@ -2157,7 +2165,7 @@ static int32_t C_ParseCommand(void)
else // event defined for the first time
{
aEventOffsets[j] = cs.parsingEventOfs;
aEventSizes[j] = (g_scriptPtr-script) - cs.parsingEventOfs;
aEventSizes[j] = (g_scriptPtr-apScript) - cs.parsingEventOfs;
initprintf(" Defined Event %3d `%s'.\n", j, g_szCurrentBlockName);
// initprintf(" o:%d s:%d\n", aEventOffsets[j], aEventSizes[j]);
@ -2178,7 +2186,7 @@ static int32_t C_ParseCommand(void)
if (cs.checkingIfElse)
{
ofstype offset;
ofstype lastScriptOfs = (g_scriptPtr-script) - 1;
ofstype lastScriptOfs = (g_scriptPtr-apScript) - 1;
instype *tscrptr;
cs.ifElseAborted = 0;
@ -2187,7 +2195,7 @@ static int32_t C_ParseCommand(void)
if (C_CheckMalformedBranch(lastScriptOfs))
return 0;
offset = (unsigned)(g_scriptPtr-script);
offset = (unsigned)(g_scriptPtr-apScript);
g_scriptPtr++; //Leave a spot for the fail location
C_ParseCommand();
@ -2195,8 +2203,8 @@ static int32_t C_ParseCommand(void)
if (C_CheckEmptyBranch(tw, lastScriptOfs))
return 0;
tscrptr = (instype *)script+offset;
*tscrptr = (ofstype)(g_scriptPtr-script)-offset; // relative offset
tscrptr = (instype *)apScript+offset;
*tscrptr = (ofstype)(g_scriptPtr-apScript)-offset; // relative offset
}
else
{
@ -2241,7 +2249,7 @@ static int32_t C_ParseCommand(void)
C_GetNextVar(); // Get The ID of the DEF
tempoffset = (unsigned)(g_scriptPtr-script);
tempoffset = (unsigned)(g_scriptPtr-apScript);
*g_scriptPtr++ = 0; // leave spot for end location (for after processing)
*g_scriptPtr++ = 0; // count of case statements
@ -2259,7 +2267,7 @@ static int32_t C_ParseCommand(void)
C_SkipComments();
g_scriptPtr -= j*2; // allocate buffer for the table
tempscrptr = (instype *)(script+tempoffset);
tempscrptr = (instype *)(apScript+tempoffset);
// if (cs.checkingSwitch>1) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf);
if (j<0)
return 1;
@ -2283,7 +2291,7 @@ static int32_t C_ParseCommand(void)
//Bsprintf(g_szBuf,"SWITCH2: '%.22s'",textptr); AddLog(g_szBuf);
}
tempscrptr = (instype *)(script+tempoffset);
tempscrptr = (instype *)(apScript+tempoffset);
//Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr); AddLog(g_szBuf);
// done processing switch. clean up.
// if (cs.checkingSwitch < 1) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=%d",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf);
@ -2364,7 +2372,7 @@ repeatcase:
goto repeatcase;
}
//Bsprintf(g_szBuf,"case4: '%.12s'",textptr); AddLog(g_szBuf);
tempoffset = (unsigned)(tempscrptr-script);
tempoffset = (unsigned)(tempscrptr-apScript);
while (C_ParseCommand() == 0)
{
//Bsprintf(g_szBuf,"case5 '%.25s'",textptr); AddLog(g_szBuf);
@ -2373,11 +2381,11 @@ repeatcase:
{
//AddLog("Found Repeat Case");
C_GetNextKeyword(); // eat 'case'
tempscrptr = (instype *)(script+tempoffset);
tempscrptr = (instype *)(apScript+tempoffset);
goto repeatcase;
}
}
tempscrptr = (instype *)(script+tempoffset);
tempscrptr = (instype *)(apScript+tempoffset);
//AddLog("End Case");
return 0;
// break;
@ -2854,13 +2862,13 @@ repeatcase:
if (how >= ITER_SPRITESOFSECTOR)
C_GetNextVar();
offset = g_scriptPtr-script;
offset = g_scriptPtr-apScript;
g_scriptPtr++; //Leave a spot for the location to jump to after completion
C_ParseCommand();
tscrptr = (instype *)script+offset;
*tscrptr = (g_scriptPtr-script)-offset; // relative offset
tscrptr = (instype *)apScript+offset;
*tscrptr = (g_scriptPtr-apScript)-offset; // relative offset
return 0;
}
@ -2930,7 +2938,7 @@ repeatcase:
case CON_IFINTERACTIVE:
{
ofstype offset;
ofstype lastScriptOfs = (g_scriptPtr-script-1);
ofstype lastScriptOfs = (g_scriptPtr-apScript-1);
instype *tscrptr;
cs.ifElseAborted = 0;
@ -2989,7 +2997,7 @@ repeatcase:
if (C_CheckMalformedBranch(lastScriptOfs))
return 0;
offset = (g_scriptPtr-script);
offset = (g_scriptPtr-apScript);
g_scriptPtr++; //Leave a spot for the fail location
C_ParseCommand();
@ -2997,8 +3005,8 @@ repeatcase:
if (C_CheckEmptyBranch(tw, lastScriptOfs))
return 0;
tscrptr = (instype *)script+offset;
*tscrptr = (g_scriptPtr-script)-offset; // relative offset
tscrptr = (instype *)apScript+offset;
*tscrptr = (g_scriptPtr-apScript)-offset; // relative offset
if (tw != CON_WHILEVARN && tw != CON_WHILEVARVARN)
{
@ -3182,8 +3190,8 @@ repeatcase:
k = MAXQUOTES;
}
if (ScriptQuotes[k] == NULL)
ScriptQuotes[k] = (char *)Xcalloc(MAXQUOTELEN, sizeof(uint8_t));
if (apStrings[k] == NULL)
apStrings[k] = (char *)Xcalloc(MAXQUOTELEN, sizeof(uint8_t));
if (tw == CON_DEFINEQUOTE)
g_scriptPtr--;
@ -3193,8 +3201,8 @@ repeatcase:
if (tw == CON_REDEFINEQUOTE)
{
if (ScriptQuoteRedefinitions[g_numQuoteRedefinitions] == NULL)
ScriptQuoteRedefinitions[g_numQuoteRedefinitions] = (char *)Xcalloc(MAXQUOTELEN, sizeof(uint8_t));
if (apXStrings[g_numXStrings] == NULL)
apXStrings[g_numXStrings] = (char *)Xcalloc(MAXQUOTELEN, sizeof(uint8_t));
}
i = 0;
@ -3208,9 +3216,9 @@ repeatcase:
// break;
// }
if (tw == CON_DEFINEQUOTE)
*(ScriptQuotes[k]+i) = *textptr;
*(apStrings[k]+i) = *textptr;
else
*(ScriptQuoteRedefinitions[g_numQuoteRedefinitions]+i) = *textptr;
*(apXStrings[g_numXStrings]+i) = *textptr;
textptr++;
i++;
@ -3225,12 +3233,12 @@ repeatcase:
}
if (tw == CON_DEFINEQUOTE)
*(ScriptQuotes[k]+i) = '\0';
*(apStrings[k]+i) = '\0';
else
{
*(ScriptQuoteRedefinitions[g_numQuoteRedefinitions]+i) = '\0';
*g_scriptPtr++ = g_numQuoteRedefinitions;
g_numQuoteRedefinitions++;
*(apXStrings[g_numXStrings]+i) = '\0';
*g_scriptPtr++ = g_numXStrings;
g_numXStrings++;
}
return 0;
@ -3612,7 +3620,7 @@ void C_CompilationInfo(void)
int32_t j, k=0;
initprintf(" \n");
initprintf("Compiled code info: (size=%ld*%d bytes)\n",
(unsigned long)(g_scriptPtr-script), (int32_t)sizeof(instype));
(unsigned long)(g_scriptPtr-apScript), (int32_t)sizeof(instype));
initprintf(" %d/%d user labels, %d/65536 indirect constants,\n",
g_numLabels-g_numDefaultLabels, 65536-g_numDefaultLabels,
g_numSavedConstants);
@ -3625,10 +3633,10 @@ void C_CompilationInfo(void)
initprintf(" %d states, %d/%d defined events\n", g_stateCount, k,MAXEVENTS);
for (k=0, j=MAXQUOTES-1; j>=0; j--)
if (ScriptQuotes[j])
if (apStrings[j])
k++;
if (k || g_numQuoteRedefinitions)
initprintf(" %d/%d quotes, %d/%d quote redefinitions\n", k,MAXQUOTES, g_numQuoteRedefinitions,MAXQUOTES);
if (k || g_numXStrings)
initprintf(" %d/%d quotes, %d/%d quote redefinitions\n", k,MAXQUOTES, g_numXStrings,MAXQUOTES);
}
EDUKE32_STATIC_ASSERT(ARRAY_SIZE(keyw)-1 == CON_END);
@ -3666,9 +3674,9 @@ void C_Compile(const char *filenameortext, int32_t isfilename)
Gv_Init();
C_AddDefaultDefinitions();
script = (instype *)Xcalloc(g_scriptSize, sizeof(instype));
apScript = (instype *)Xcalloc(g_scriptSize, sizeof(instype));
g_scriptPtr = script+1;
g_scriptPtr = apScript+1;
firstime = 0;
}

View file

@ -107,12 +107,15 @@ enum miscvmflags
};
typedef struct {
int32_t g_i;
int32_t spriteNum;
// VM state: either ==0 (top-level), >=1 and < MAXEVENTS+1 (event),
// or >= MAXEVENTS+1 and < MAXEVENTS+1+g_stateCount (state)
int32_t g_st;
uspritetype *g_sp;
uint32_t flags; //g_errorFlag, g_returnFlag;
union {
spritetype * pSprite;
uspritetype *pUSprite;
};
uint32_t flags; // g_errorFlag, g_returnFlag;
// 1:updatehighlight, 2:updatehighlightsector, 4:interactive (from menu)?
uint32_t miscflags;

View file

@ -66,11 +66,11 @@ void X_Disasm(ofstype beg, int32_t size)
{
instype *p;
if (!script) return;
if (!apScript) return;
if (beg<0 || beg+size>g_scriptSize) return;
initprintf("beg=%d, size=%d: ", beg, size);
for (p=script+beg; p<script+beg+size; p++)
for (p=apScript+beg; p<apScript+beg+size; p++)
{
if (*p>>12 && (*p&0xFFF)<CON_END)
initprintf("%s ", keyw[*p&0xFFF]);
@ -83,23 +83,23 @@ void X_Disasm(ofstype beg, int32_t size)
void VM_ScriptInfo(void)
{
if (script)
if (apScript)
{
instype *p;
if (insptr)
for (p=max(insptr-20,script); p<min(insptr+20, script+g_scriptSize); p++)
for (p=max(insptr-20,apScript); p<min(insptr+20, apScript+g_scriptSize); p++)
{
if (p==insptr) initprintf("<<");
if (*p>>12 && (*p&0xFFF)<CON_END)
initprintf("\n%5d: L%5d: %s ",(int32_t)(p-script),(int32_t)(*p>>12),keyw[*p&0xFFF]);
initprintf("\n%5d: L%5d: %s ",(int32_t)(p-apScript),(int32_t)(*p>>12),keyw[*p&0xFFF]);
else initprintf(" %d",*p);
if (p==insptr) initprintf(">>");
}
initprintf(" \n");
if (vm.g_i >= 0)
initprintf("current sprite: %d\n",vm.g_i);
if (vm.spriteNum >= 0)
initprintf("current sprite: %d\n",vm.spriteNum);
if (g_tw>=0 && g_tw<CON_END)
initprintf("g_errorLineNum: %d, g_tw: %s\n",g_errorLineNum,keyw[g_tw]);
else
@ -124,7 +124,7 @@ void M32_PostScriptExec(void)
}
}
void VM_OnEvent(register int32_t iEventID, register int32_t iActor)
void VM_OnEvent(register int32_t iEventID, register int32_t spriteNum)
{
if (iEventID < 0 || iEventID >= MAXEVENTS)
{
@ -155,15 +155,15 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor)
Bmemcpy(&vm_backup, &vm, sizeof(vmstate_t));
vm.g_i = iActor; // current sprite ID
if (vm.g_i >= 0)
vm.g_sp = (uspritetype *)&sprite[vm.g_i];
vm.spriteNum = spriteNum; // current sprite ID
if (vm.spriteNum >= 0)
vm.pSprite = &sprite[vm.spriteNum];
vm.g_st = 1+iEventID;
vm.flags = 0;
insptr = script + aEventOffsets[iEventID];
insptr = apScript + aEventOffsets[iEventID];
aGameArrays[M32_LOCAL_ARRAY_ID].vals = localvars;
VM_Execute(0);
@ -239,46 +239,46 @@ static int X_DoSort(const void *lv, const void *rv)
}
// in interactive execution, allow the current sprite index to be the aimed-at sprite (in 3d mode)
#define X_ERROR_INVALIDCI() \
if ((vm.g_i < 0 || vm.g_i >= MAXSPRITES) && \
(vm.g_st != 0 || searchstat != 3 || (vm.g_i = searchwall, vm.g_sp = (uspritetype *)&sprite[vm.g_i], 0))) \
{ \
M32_ERROR("Current sprite index invalid!"); \
continue; \
#define X_ERROR_INVALIDCI() \
if ((vm.spriteNum < 0 || vm.spriteNum >= MAXSPRITES) && \
(vm.g_st != 0 || searchstat != 3 || (vm.spriteNum = searchwall, vm.pSprite = &sprite[vm.spriteNum], 0))) \
{ \
M32_ERROR("Current sprite index invalid!"); \
continue; \
}
#define X_ERROR_INVALIDSPRI(dasprite) \
if (dasprite < 0 || dasprite>=MAXSPRITES) \
{ \
M32_ERROR("Invalid sprite index %d!", dasprite); \
continue; \
#define X_ERROR_INVALIDSPRI(dasprite) \
if (dasprite < 0 || dasprite >= MAXSPRITES) \
{ \
M32_ERROR("Invalid sprite index %d!", dasprite); \
continue; \
}
#define X_ERROR_INVALIDSECT(dasect) \
if (dasect < 0 || dasect>=numsectors) \
{ \
M32_ERROR("Invalid sector index %d!", dasect); \
continue; \
#define X_ERROR_INVALIDSECT(dasect) \
if (dasect < 0 || dasect >= numsectors) \
{ \
M32_ERROR("Invalid sector index %d!", dasect); \
continue; \
}
#define X_ERROR_INVALIDSP() \
if (!vm.g_sp && (vm.g_st != 0 || searchstat != 3 || (vm.g_sp = (uspritetype *)&sprite[searchwall], 0))) \
{ \
M32_ERROR("Current sprite invalid!"); \
continue; \
#define X_ERROR_INVALIDSP() \
if (!vm.pSprite && (vm.g_st != 0 || searchstat != 3 || (vm.pSprite = &sprite[searchwall], 0))) \
{ \
M32_ERROR("Current sprite invalid!"); \
continue; \
}
#define X_ERROR_INVALIDQUOTE(q, array) \
if (q<0 || q>=MAXQUOTES) \
{ \
M32_ERROR("Invalid quote number %d!", q); \
continue; \
} \
else if (array[q] == NULL) \
{ \
M32_ERROR("Null quote %d!", q); \
continue; \
} \
#define X_ERROR_INVALIDQUOTE(q, array) \
if (q < 0 || q >= MAXQUOTES) \
{ \
M32_ERROR("Invalid quote number %d!", q); \
continue; \
} \
else if (array[q] == NULL) \
{ \
M32_ERROR("Null quote %d!", q); \
continue; \
}
static char *GetMaybeInlineQuote(int32_t quotei)
{
@ -291,10 +291,10 @@ static char *GetMaybeInlineQuote(int32_t quotei)
else
{
quotei = Gv_GetVarX(quotei);
do { X_ERROR_INVALIDQUOTE(quotei, ScriptQuotes) } while (0);
do { X_ERROR_INVALIDQUOTE(quotei, apStrings) } while (0);
if (vm.flags&VMFLAG_ERROR)
return NULL;
quotetext = ScriptQuotes[quotei];
quotetext = apStrings[quotei];
}
return quotetext;
@ -351,7 +351,7 @@ skip_check:
if (statesinfo[stateidx].numlocals > 0)
Bmemset(localvars, 0, statesinfo[stateidx].numlocals*sizeof(int32_t));
insptr = script + statesinfo[stateidx].ofs;
insptr = apScript + statesinfo[stateidx].ofs;
vm.g_st = 1+MAXEVENTS+stateidx;
aGameArrays[M32_LOCAL_ARRAY_ID].vals = localvars;
VM_Execute(0);
@ -453,7 +453,7 @@ skip_check:
insptr++;
{
int32_t j=*insptr++;
Gv_SetVarX(j, insptr-script);
Gv_SetVarX(j, insptr-apScript);
}
continue;
@ -461,12 +461,12 @@ skip_check:
insptr++;
{
int32_t j = Gv_GetVarX(*insptr++);
if (j<0 || j>=(g_scriptPtr-script))
if (j<0 || j>=(g_scriptPtr-apScript))
{
M32_ERROR("script index out of bounds (%d)", j);
continue;
}
insptr = (instype *)(j+script);
insptr = (instype *)(j+apScript);
}
continue;
@ -1206,7 +1206,7 @@ skip_check:
if (sectbitmap[ns>>3]&(1<<(ns&7)))
continue;
vm.g_st = 1+MAXEVENTS+state;
insptr = script + statesinfo[state].ofs;
insptr = apScript + statesinfo[state].ofs;
g_iReturnVar = ns;
VM_Execute(0);
if (g_iReturnVar)
@ -1255,7 +1255,7 @@ skip_check:
}
else
{
x_sortingstateptr = script + statesinfo[state].ofs;
x_sortingstateptr = apScript + statesinfo[state].ofs;
vm.g_st = 1+MAXEVENTS+state;
qsort(gar->vals, count, sizeof(int32_t), X_DoSort);
vm.g_st = o_g_st;
@ -1270,8 +1270,8 @@ skip_check:
const int32_t var = *insptr++, how = *insptr++;
const int32_t parm2 = how<=ITER_DRAWNSPRITES ? 0 : Gv_GetVarX(*insptr++);
instype *const end = insptr + *insptr, *const beg = ++insptr;
const int32_t vm_i_bak = vm.g_i;
uspritetype *const vm_sp_bak = vm.g_sp;
const int32_t vm_i_bak = vm.spriteNum;
uspritetype *const vm_sp_bak = vm.pUSprite;
if (vm.flags&VMFLAG_ERROR)
continue;
@ -1284,8 +1284,8 @@ skip_check:
if (sprite[jj].statnum == MAXSTATUS)
continue;
Gv_SetVarX(var, jj);
vm.g_i = jj;
vm.g_sp = (uspritetype *)&sprite[jj];
vm.spriteNum = jj;
vm.pSprite = &sprite[jj];
insptr = beg;
VM_Execute(1);
}
@ -1330,8 +1330,8 @@ skip_check:
{
jj &= (MAXSPRITES-1);
Gv_SetVarX(var, jj);
vm.g_i = jj;
vm.g_sp = (uspritetype *)&sprite[jj];
vm.spriteNum = jj;
vm.pSprite = &sprite[jj];
insptr = beg;
VM_Execute(1);
}
@ -1367,7 +1367,7 @@ skip_check:
for (int ii=0; ii<spritesortcnt && !vm.flags; ii++)
{
vm.g_sp = lastSpritePtr;
vm.pUSprite = lastSpritePtr;
Bmemcpy(lastSpritePtr, &tsprite[ii], sizeof(uspritetype));
Gv_SetVarX(var, ii);
@ -1388,8 +1388,8 @@ skip_check:
for (int jj=headspritesect[parm2]; jj>=0 && !vm.flags; jj=nextspritesect[jj])
{
Gv_SetVarX(var, jj);
vm.g_i = jj;
vm.g_sp = (uspritetype *)&sprite[jj];
vm.spriteNum = jj;
vm.pSprite = &sprite[jj];
insptr = beg;
VM_Execute(1);
}
@ -1437,10 +1437,10 @@ badindex:
vm.flags |= VMFLAG_ERROR;
continue;
}
vm.g_i = vm_i_bak;
vm.g_sp = vm_sp_bak;
vm.flags &= ~VMFLAG_BREAK;
insptr = end;
vm.spriteNum = vm_i_bak;
vm.pUSprite = vm_sp_bak;
vm.flags &= ~VMFLAG_BREAK;
insptr = end;
}
continue;
@ -1564,7 +1564,7 @@ badindex:
case CON_IFSPRITEPAL:
insptr++;
X_ERROR_INVALIDSP();
VM_DoConditional(vm.g_sp->pal == Gv_GetVarX(*insptr));
VM_DoConditional(vm.pSprite->pal == Gv_GetVarX(*insptr));
continue;
case CON_IFHIGHLIGHTED:
@ -1590,7 +1590,7 @@ badindex:
{
int32_t j;
X_ERROR_INVALIDSP();
j = klabs(G_GetAngleDelta(ang, vm.g_sp->ang));
j = klabs(G_GetAngleDelta(ang, vm.pSprite->ang));
VM_DoConditional(j <= Gv_GetVarX(*insptr));
}
continue;
@ -1601,18 +1601,18 @@ badindex:
int32_t j = 0;
X_ERROR_INVALIDSP();
s1 = vm.g_sp->sectnum;
updatesector(vm.g_sp->x+108,vm.g_sp->y+108,&s1);
if (s1 == vm.g_sp->sectnum)
s1 = vm.pSprite->sectnum;
updatesector(vm.pSprite->x+108,vm.pSprite->y+108,&s1);
if (s1 == vm.pSprite->sectnum)
{
updatesector(vm.g_sp->x-108,vm.g_sp->y-108,&s1);
if (s1 == vm.g_sp->sectnum)
updatesector(vm.pSprite->x-108,vm.pSprite->y-108,&s1);
if (s1 == vm.pSprite->sectnum)
{
updatesector(vm.g_sp->x+108,vm.g_sp->y-108,&s1);
if (s1 == vm.g_sp->sectnum)
updatesector(vm.pSprite->x+108,vm.pSprite->y-108,&s1);
if (s1 == vm.pSprite->sectnum)
{
updatesector(vm.g_sp->x-108,vm.g_sp->y+108,&s1);
if (s1 == vm.g_sp->sectnum)
updatesector(vm.pSprite->x-108,vm.pSprite->y+108,&s1);
if (s1 == vm.pSprite->sectnum)
j = 1;
}
}
@ -1626,7 +1626,7 @@ badindex:
int32_t j;
X_ERROR_INVALIDSP();
j = cansee(vm.g_sp->x,vm.g_sp->y,vm.g_sp->z/*-((krand()&41)<<8)*/,vm.g_sp->sectnum,
j = cansee(vm.pSprite->x,vm.pSprite->y,vm.pSprite->z/*-((krand()&41)<<8)*/,vm.pSprite->sectnum,
pos.x, pos.y, pos.z /*-((krand()&41)<<8)*/, cursectnum);
VM_DoConditional(j);
}
@ -1634,18 +1634,18 @@ badindex:
case CON_IFONWATER:
X_ERROR_INVALIDSP();
VM_DoConditional(sector[vm.g_sp->sectnum].lotag == 1 && klabs(vm.g_sp->z-sector[vm.g_sp->sectnum].floorz) < (32<<8));
VM_DoConditional(sector[vm.pSprite->sectnum].lotag == 1 && klabs(vm.pSprite->z-sector[vm.pSprite->sectnum].floorz) < (32<<8));
continue;
case CON_IFINWATER:
X_ERROR_INVALIDSP();
VM_DoConditional(sector[vm.g_sp->sectnum].lotag == 2);
VM_DoConditional(sector[vm.pSprite->sectnum].lotag == 2);
continue;
case CON_IFACTOR:
insptr++;
X_ERROR_INVALIDSP();
VM_DoConditional(vm.g_sp->picnum == Gv_GetVarX(*insptr));
VM_DoConditional(vm.pSprite->picnum == Gv_GetVarX(*insptr));
continue;
case CON_IFINSIDE:
@ -1666,14 +1666,14 @@ badindex:
case CON_IFOUTSIDE:
X_ERROR_INVALIDSP();
VM_DoConditional(sector[vm.g_sp->sectnum].ceilingstat&1);
VM_DoConditional(sector[vm.pSprite->sectnum].ceilingstat&1);
continue;
case CON_IFPDISTL:
insptr++;
{
X_ERROR_INVALIDSP();
VM_DoConditional(dist((spritetype *)&pos, vm.g_sp) < Gv_GetVarX(*insptr));
VM_DoConditional(dist((spritetype *)&pos, vm.pSprite) < Gv_GetVarX(*insptr));
}
continue;
@ -1681,7 +1681,7 @@ badindex:
insptr++;
{
X_ERROR_INVALIDSP();
VM_DoConditional(dist((spritetype *)&pos, vm.g_sp) > Gv_GetVarX(*insptr));
VM_DoConditional(dist((spritetype *)&pos, vm.pSprite) > Gv_GetVarX(*insptr));
}
continue;
// ^^^
@ -1700,8 +1700,8 @@ badindex:
}
ret = insertsprite(dasectnum, 0);
vm.g_i = ret;
vm.g_sp = (uspritetype *)&sprite[ret];
vm.spriteNum = ret;
vm.pSprite = &sprite[ret];
}
continue;
@ -1735,15 +1735,15 @@ badindex:
}
Bmemcpy(&sprite[nspritenum], &sprite[ospritenum], sizeof(spritetype));
vm.g_i = nspritenum;
vm.g_sp = (uspritetype *)&sprite[nspritenum];
vm.spriteNum = nspritenum;
vm.pSprite = &sprite[nspritenum];
}
else
{
Bmemcpy(&tsprite[spritesortcnt], &sprite[ospritenum], sizeof(spritetype));
tsprite[spritesortcnt].owner = ospritenum;
vm.g_i = -1;
vm.g_sp = &tsprite[spritesortcnt];
vm.spriteNum = -1;
vm.pUSprite = &tsprite[spritesortcnt];
spritesortcnt++;
}
}
@ -2036,7 +2036,7 @@ badindex:
int16_t w;
X_ERROR_INVALIDCI();
w=sprite[vm.g_i].sectnum;
w=sprite[vm.spriteNum].sectnum;
if (tw==CON_UPDATESECTOR) updatesector(x,y,&w);
else updatesectorz(x,y,z,&w);
@ -2401,15 +2401,15 @@ badindex:
insptr++;
{
int32_t q = *insptr++, i = *insptr++;
X_ERROR_INVALIDQUOTE(q, ScriptQuotes);
X_ERROR_INVALIDQUOTE(i, ScriptQuoteRedefinitions);
Bstrcpy(ScriptQuotes[q],ScriptQuoteRedefinitions[i]);
X_ERROR_INVALIDQUOTE(q, apStrings);
X_ERROR_INVALIDQUOTE(i, apXStrings);
Bstrcpy(apStrings[q],apXStrings[i]);
continue;
}
insptr++;
X_ERROR_INVALIDQUOTE(*insptr, ScriptQuotes);
OSD_Printf("%s", ScriptQuotes[*insptr++]);
X_ERROR_INVALIDQUOTE(*insptr, apStrings);
OSD_Printf("%s", apStrings[*insptr++]);
continue;
case CON_GETNUMBER16: /* deprecated */
@ -2548,12 +2548,12 @@ badindex:
if (vm.flags&VMFLAG_ERROR)
continue;
X_ERROR_INVALIDQUOTE(q1, ScriptQuotes);
X_ERROR_INVALIDQUOTE(q1, apStrings);
{
int32_t st = Gv_GetVarX(*insptr++);
int32_t ln = Gv_GetVarX(*insptr++);
char *s1 = ScriptQuotes[q1];
char *s1 = apStrings[q1];
const char *s2 = q2text;
while (*s2 && st--) s2++;
@ -2580,18 +2580,18 @@ badindex:
if (vm.flags&VMFLAG_ERROR)
continue;
X_ERROR_INVALIDQUOTE(i, ScriptQuotes);
X_ERROR_INVALIDQUOTE(i, apStrings);
switch (tw)
{
case CON_QSTRCAT:
Bstrncat(ScriptQuotes[i], quotetext, (MAXQUOTELEN-1)-Bstrlen(ScriptQuotes[i]));
Bstrncat(apStrings[i], quotetext, (MAXQUOTELEN-1)-Bstrlen(apStrings[i]));
break;
case CON_QSTRNCAT:
Bstrncat(ScriptQuotes[i], quotetext, Gv_GetVarX(*insptr++));
Bstrncat(apStrings[i], quotetext, Gv_GetVarX(*insptr++));
break;
case CON_QSTRCPY:
Bstrcpy(ScriptQuotes[i], quotetext);
Bstrcpy(apStrings[i], quotetext);
break;
}
continue;
@ -2605,7 +2605,7 @@ badindex:
if (vm.flags&VMFLAG_ERROR)
continue;
X_ERROR_INVALIDQUOTE(dq, ScriptQuotes);
X_ERROR_INVALIDQUOTE(dq, apStrings);
{
int32_t arg[32], numvals=0, i=0, j=0, k=0;
@ -2670,10 +2670,10 @@ badindex:
case 's':
{
if (arg[i]>=0 && arg[i]<MAXQUOTES && ScriptQuotes[arg[i]])
if (arg[i]>=0 && arg[i]<MAXQUOTES && apStrings[arg[i]])
{
int32_t ii = Bstrlen(ScriptQuotes[arg[i]]);
Bmemcpy(&tmpbuf[j], ScriptQuotes[arg[i]], ii);
int32_t ii = Bstrlen(apStrings[arg[i]]);
Bmemcpy(&tmpbuf[j], apStrings[arg[i]], ii);
j += ii;
}
k++;
@ -2690,8 +2690,8 @@ dodefault:
while (k < len && j < MAXQUOTELEN);
tmpbuf[j] = '\0';
Bmemcpy(ScriptQuotes[dq], tmpbuf, MAXQUOTELEN);
ScriptQuotes[dq][MAXQUOTELEN-1] = '\0';
Bmemcpy(apStrings[dq], tmpbuf, MAXQUOTELEN);
apStrings[dq][MAXQUOTELEN-1] = '\0';
continue;
}
}
@ -2723,7 +2723,7 @@ dodefault:
{
while (j>=0)
{
if (sprite[j].picnum == lType && j != vm.g_i && dist(&sprite[vm.g_i], &sprite[j]) < lMaxDist)
if (sprite[j].picnum == lType && j != vm.spriteNum && dist(&sprite[vm.spriteNum], &sprite[j]) < lMaxDist)
{
lFound=j;
j = MAXSPRITES;
@ -2738,7 +2738,7 @@ dodefault:
while (j>=0)
{
if (sprite[j].picnum == lType && j != vm.g_i && ldist(&sprite[vm.g_i], &sprite[j]) < lMaxDist)
if (sprite[j].picnum == lType && j != vm.spriteNum && ldist(&sprite[vm.spriteNum], &sprite[j]) < lMaxDist)
{
lFound=j;
j = MAXSPRITES;
@ -2777,12 +2777,12 @@ dodefault:
if (j == -1) continue;
do
{
if (sprite[j].picnum == lType && j != vm.g_i)
if (sprite[j].picnum == lType && j != vm.spriteNum)
{
lTemp=ldist(&sprite[vm.g_i], &sprite[j]);
lTemp=ldist(&sprite[vm.spriteNum], &sprite[j]);
if (lTemp < lMaxDist)
{
lTemp2=klabs(sprite[vm.g_i].z-sprite[j].z);
lTemp2=klabs(sprite[vm.spriteNum].z-sprite[j].z);
if (lTemp2 < lMaxZDist)
{
lFound=j;
@ -2832,88 +2832,88 @@ dodefault:
insptr++;
newcurspritei = Gv_GetVarX(*insptr++);
X_ERROR_INVALIDSPRI(newcurspritei);
vm.g_i = newcurspritei;
vm.g_sp = (uspritetype *)&sprite[vm.g_i];
vm.spriteNum = newcurspritei;
vm.pSprite = &sprite[vm.spriteNum];
continue;
}
case CON_SIZEAT:
insptr += 3;
X_ERROR_INVALIDSP();
vm.g_sp->xrepeat = (uint8_t) Gv_GetVarX(*(insptr-2));
vm.g_sp->yrepeat = (uint8_t) Gv_GetVarX(*(insptr-1));
if (vm.g_i != -1) spritechanged[vm.g_i]++;
vm.pSprite->xrepeat = (uint8_t) Gv_GetVarX(*(insptr-2));
vm.pSprite->yrepeat = (uint8_t) Gv_GetVarX(*(insptr-1));
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
continue;
case CON_CSTAT:
insptr += 2;
X_ERROR_INVALIDSP();
vm.g_sp->cstat = (int16_t) *(insptr-1);
if (vm.g_i != -1) spritechanged[vm.g_i]++;
vm.pSprite->cstat = (int16_t) *(insptr-1);
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
continue;
case CON_CSTATOR:
insptr += 2;
X_ERROR_INVALIDSP();
vm.g_sp->cstat |= (int16_t) Gv_GetVarX(*(insptr-1));
if (vm.g_i != -1) spritechanged[vm.g_i]++;
vm.pSprite->cstat |= (int16_t) Gv_GetVarX(*(insptr-1));
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
continue;
case CON_CLIPDIST:
insptr += 2;
X_ERROR_INVALIDSP();
vm.g_sp->clipdist = (uint8_t) Gv_GetVarX(*(insptr-1));
if (vm.g_i != -1) spritechanged[vm.g_i]++;
vm.pSprite->clipdist = (uint8_t) Gv_GetVarX(*(insptr-1));
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
continue;
case CON_SPRITEPAL:
insptr += 2;
X_ERROR_INVALIDSP();
vm.g_sp->pal = Gv_GetVarX(*(insptr-1));
if (vm.g_i != -1) spritechanged[vm.g_i]++;
vm.pSprite->pal = Gv_GetVarX(*(insptr-1));
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
continue;
case CON_CACTOR:
insptr += 2;
X_ERROR_INVALIDSP();
vm.g_sp->picnum = Gv_GetVarX(*(insptr-1));
if (vm.g_i != -1) spritechanged[vm.g_i]++;
vm.pSprite->picnum = Gv_GetVarX(*(insptr-1));
if (vm.spriteNum != -1) spritechanged[vm.spriteNum]++;
continue;
case CON_SPGETLOTAG:
insptr++;
X_ERROR_INVALIDSP();
Gv_SetVarX(M32_LOTAG_VAR_ID, vm.g_sp->lotag);
Gv_SetVarX(M32_LOTAG_VAR_ID, vm.pSprite->lotag);
continue;
case CON_SPGETHITAG:
insptr++;
X_ERROR_INVALIDSP();
Gv_SetVarX(M32_HITAG_VAR_ID, vm.g_sp->hitag);
Gv_SetVarX(M32_HITAG_VAR_ID, vm.pSprite->hitag);
continue;
case CON_SECTGETLOTAG:
insptr++;
X_ERROR_INVALIDSP();
Gv_SetVarX(M32_LOTAG_VAR_ID, sector[vm.g_sp->sectnum].lotag);
Gv_SetVarX(M32_LOTAG_VAR_ID, sector[vm.pSprite->sectnum].lotag);
continue;
case CON_SECTGETHITAG:
insptr++;
X_ERROR_INVALIDSP();
Gv_SetVarX(M32_HITAG_VAR_ID, sector[vm.g_sp->sectnum].hitag);
Gv_SetVarX(M32_HITAG_VAR_ID, sector[vm.pSprite->sectnum].hitag);
continue;
case CON_GETTEXTUREFLOOR:
insptr++;
X_ERROR_INVALIDSP();
Gv_SetVarX(M32_TEXTURE_VAR_ID, sector[vm.g_sp->sectnum].floorpicnum);
Gv_SetVarX(M32_TEXTURE_VAR_ID, sector[vm.pSprite->sectnum].floorpicnum);
continue;
case CON_GETTEXTURECEILING:
insptr++;
X_ERROR_INVALIDSP();
Gv_SetVarX(M32_TEXTURE_VAR_ID, sector[vm.g_sp->sectnum].ceilingpicnum);
Gv_SetVarX(M32_TEXTURE_VAR_ID, sector[vm.pSprite->sectnum].ceilingpicnum);
continue;
// ^^^
case CON_DRAWLINE16:
@ -3019,12 +3019,12 @@ dodefault:
insptr++;
continue;
}
VM_DoConditional(S_CheckSoundPlaying(vm.g_i,j));
VM_DoConditional(S_CheckSoundPlaying(vm.spriteNum,j));
}
continue;
case CON_IFNOSOUNDS:
VM_DoConditional(S_SoundsPlaying(vm.g_i) < 0);
VM_DoConditional(S_SoundsPlaying(vm.spriteNum) < 0);
continue;
case CON_IFIN3DMODE:
@ -3077,18 +3077,18 @@ dodefault:
switch (tw)
{
case CON_SOUNDONCEVAR:
if (!S_CheckSoundPlaying(vm.g_i,j))
A_PlaySound((int16_t)j,vm.g_i);
if (!S_CheckSoundPlaying(vm.spriteNum,j))
A_PlaySound((int16_t)j,vm.spriteNum);
break;
case CON_GLOBALSOUNDVAR:
A_PlaySound((int16_t)j,-1);
break;
case CON_STOPSOUNDVAR:
if (S_CheckSoundPlaying(vm.g_i,j))
if (S_CheckSoundPlaying(vm.spriteNum,j))
S_StopSound((int16_t)j);
break;
case CON_SOUNDVAR:
A_PlaySound((int16_t)j,vm.g_i);
A_PlaySound((int16_t)j,vm.spriteNum);
break;
}
}

View file

@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
/// This file is #included into other files, so don't define variables here!
static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)
static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t labelNum, int32_t lVar2)
{
int32_t lValue;
int32_t i = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar1) : lVar1;
@ -48,22 +48,22 @@ static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLab
if (how&ACCESS_SET)
{
if (!m32_script_expertmode && (WallLabels[lLabelID].flags & 1))
if (!m32_script_expertmode && (WallLabels[labelNum].flags & 1))
goto readonly;
lValue = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar2) : lVar2;
asksave = 1;
if (!m32_script_expertmode && (WallLabels[lLabelID].min != 0 || WallLabels[lLabelID].max != 0))
if (!m32_script_expertmode && (WallLabels[labelNum].min != 0 || WallLabels[labelNum].max != 0))
{
if (lValue < WallLabels[lLabelID].min)
lValue = WallLabels[lLabelID].min;
if (lValue > WallLabels[lLabelID].max)
lValue = WallLabels[lLabelID].max;
if (lValue < WallLabels[labelNum].min)
lValue = WallLabels[labelNum].min;
if (lValue > WallLabels[labelNum].max)
lValue = WallLabels[labelNum].max;
}
switch (lLabelID)
switch (labelNum)
{
case WALL_X: wall[i].x=lValue; break;
case WALL_Y: wall[i].y=lValue; break;
@ -109,7 +109,7 @@ static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLab
}
else
{
switch (lLabelID)
switch (labelNum)
{
case WALL_X: lValue=wall[i].x; break;
case WALL_Y: lValue=wall[i].y; break;
@ -142,21 +142,21 @@ badwall:
M32_ERROR("Invalid wall %d", i);
return -1;
readonly:
M32_ERROR("Wall structure member `%s' is read-only.", WallLabels[lLabelID].name);
M32_ERROR("Wall structure member `%s' is read-only.", WallLabels[labelNum].name);
return -1;
#ifdef YAX_ENABLE__COMPAT
yax_readonly:
M32_ERROR("Wall structure member `%s' is read-only because it is used for TROR",
WallLabels[lLabelID].name);
WallLabels[labelNum].name);
return -1;
#endif
}
// how: bitfield: 1=set? 2=vars?
static int32_t __fastcall VM_AccessSector(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)
static int32_t __fastcall VM_AccessSector(int32_t how, int32_t lVar1, int32_t labelNum, int32_t lVar2)
{
int32_t lValue;
int32_t i = (how&ACCESS_USEVARS) ? sprite[vm.g_i].sectnum : lVar1;
int32_t i = (how&ACCESS_USEVARS) ? sprite[vm.spriteNum].sectnum : lVar1;
if ((how&ACCESS_USEVARS) && lVar1 != M32_THISACTOR_VAR_ID)
i = Gv_GetVarX(lVar1);
@ -166,22 +166,22 @@ static int32_t __fastcall VM_AccessSector(int32_t how, int32_t lVar1, int32_t lL
if (how&ACCESS_SET)
{
if (!m32_script_expertmode && (SectorLabels[lLabelID].flags & 1))
if (!m32_script_expertmode && (SectorLabels[labelNum].flags & 1))
goto readonly;
lValue = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar2) : lVar2;
asksave = 1;
if (!m32_script_expertmode && (SectorLabels[lLabelID].min != 0 || SectorLabels[lLabelID].max != 0))
if (!m32_script_expertmode && (SectorLabels[labelNum].min != 0 || SectorLabels[labelNum].max != 0))
{
if (lValue < SectorLabels[lLabelID].min)
lValue = SectorLabels[lLabelID].min;
if (lValue > SectorLabels[lLabelID].max)
lValue = SectorLabels[lLabelID].max;
if (lValue < SectorLabels[labelNum].min)
lValue = SectorLabels[labelNum].min;
if (lValue > SectorLabels[labelNum].max)
lValue = SectorLabels[labelNum].max;
}
switch (lLabelID)
switch (labelNum)
{
case SECTOR_WALLPTR: sector[i].wallptr=lValue; break;
case SECTOR_WALLNUM: sector[i].wallnum=lValue; break;
@ -232,7 +232,7 @@ static int32_t __fastcall VM_AccessSector(int32_t how, int32_t lVar1, int32_t lL
}
else
{
switch (lLabelID)
switch (labelNum)
{
case SECTOR_WALLPTR: lValue=sector[i].wallptr; break;
case SECTOR_WALLNUM: lValue=sector[i].wallnum; break;
@ -271,15 +271,15 @@ badsector:
M32_ERROR("Invalid sector %d", i);
return -1;
readonly:
M32_ERROR("Sector structure member `%s' is read-only.", SectorLabels[lLabelID].name);
M32_ERROR("Sector structure member `%s' is read-only.", SectorLabels[labelNum].name);
return -1;
}
// how: bitfield: 1=set? 2=vars?
static int32_t __fastcall VM_AccessSprite(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)
static int32_t __fastcall VM_AccessSprite(int32_t how, int32_t lVar1, int32_t labelNum, int32_t lVar2)
{
int32_t lValue;
register int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;
register int32_t i = (how&ACCESS_USEVARS) ? vm.spriteNum : lVar1;
if ((how&ACCESS_USEVARS) && lVar1 != M32_THISACTOR_VAR_ID)
i = Gv_GetVarX(lVar1);
@ -289,22 +289,22 @@ static int32_t __fastcall VM_AccessSprite(int32_t how, int32_t lVar1, int32_t lL
if (how&ACCESS_SET)
{
if (!m32_script_expertmode && (SpriteLabels[lLabelID].flags & 1))
if (!m32_script_expertmode && (SpriteLabels[labelNum].flags & 1))
goto readonly;
lValue = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar2) : lVar2;
asksave = 1;
if (!m32_script_expertmode && (SpriteLabels[lLabelID].min != 0 || SpriteLabels[lLabelID].max != 0))
if (!m32_script_expertmode && (SpriteLabels[labelNum].min != 0 || SpriteLabels[labelNum].max != 0))
{
if (lValue < SpriteLabels[lLabelID].min)
lValue = SpriteLabels[lLabelID].min;
if (lValue > SpriteLabels[lLabelID].max)
lValue = SpriteLabels[lLabelID].max;
if (lValue < SpriteLabels[labelNum].min)
lValue = SpriteLabels[labelNum].min;
if (lValue > SpriteLabels[labelNum].max)
lValue = SpriteLabels[labelNum].max;
}
switch (lLabelID)
switch (labelNum)
{
case SPRITE_X: sprite[i].x=lValue; break;
case SPRITE_Y: sprite[i].y=lValue; break;
@ -341,7 +341,7 @@ static int32_t __fastcall VM_AccessSprite(int32_t how, int32_t lVar1, int32_t lL
}
else
{
switch (lLabelID)
switch (labelNum)
{
case SPRITE_X: lValue=sprite[i].x; break;
case SPRITE_Y: lValue=sprite[i].y; break;
@ -376,20 +376,20 @@ static int32_t __fastcall VM_AccessSprite(int32_t how, int32_t lVar1, int32_t lL
return lValue;
}
badsprite:
M32_ERROR("tried to set %s on invalid target sprite (%d)", SpriteLabels[lLabelID].name, i);
M32_ERROR("tried to set %s on invalid target sprite (%d)", SpriteLabels[labelNum].name, i);
return -1;
readonly:
M32_ERROR("sprite structure member `%s' is read-only.", SpriteLabels[lLabelID].name);
M32_ERROR("sprite structure member `%s' is read-only.", SpriteLabels[labelNum].name);
return -1;
}
// how: bitfield: 1=set? 2=vars? 4=use spriteext[].tspr? (otherwise use tsprite[])
static int32_t __fastcall VM_AccessTsprite(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)
static int32_t __fastcall VM_AccessTsprite(int32_t how, int32_t lVar1, int32_t labelNum, int32_t lVar2)
{
int32_t lightp = (lLabelID >= LIGHT_X);
int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;
int32_t lightp = (labelNum >= LIGHT_X);
int32_t i = (how&ACCESS_USEVARS) ? vm.spriteNum : lVar1;
uspritetype *datspr = NULL;
const memberlabel_t *dalabel = lightp ? &LightLabels[lLabelID-LIGHT_X] : &SpriteLabels[lLabelID];
const memberlabel_t *dalabel = lightp ? &LightLabels[labelNum-LIGHT_X] : &SpriteLabels[labelNum];
if ((how&ACCESS_USEVARS) && lVar1 != M32_THISACTOR_VAR_ID)
i = Gv_GetVarX(lVar1);
@ -423,7 +423,7 @@ static int32_t __fastcall VM_AccessTsprite(int32_t how, int32_t lVar1, int32_t l
return -1;
}
if (lLabelID != LIGHT_ACTIVE && !prlights[i].flags.active)
if (labelNum != LIGHT_ACTIVE && !prlights[i].flags.active)
{
M32_ERROR("light with index %d is inactive!", i);
return -1;
@ -452,7 +452,7 @@ static int32_t __fastcall VM_AccessTsprite(int32_t how, int32_t lVar1, int32_t l
lValue = damax;
}
switch (lLabelID)
switch (labelNum)
{
case SPRITE_X: datspr->x=lValue; break;
case SPRITE_Y: datspr->y=lValue; break;
@ -510,7 +510,7 @@ static int32_t __fastcall VM_AccessTsprite(int32_t how, int32_t lVar1, int32_t l
{
int32_t lValue;
switch (lLabelID)
switch (labelNum)
{
case SPRITE_X: lValue=datspr->x; break;
case SPRITE_Y: lValue=datspr->y; break;

View file

@ -217,7 +217,7 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags)
int32_t __fastcall Gv_GetVarN(register int32_t id) // 'N' for "no side-effects"... vars and locals only!
{
if (id == M32_THISACTOR_VAR_ID)
return vm.g_i;
return vm.spriteNum;
switch (id&M32_VARTYPE_MASK)
{
@ -260,7 +260,7 @@ int32_t __fastcall Gv_GetVarX(register int32_t id)
register int32_t negateResult = !!(id&M32_FLAG_NEGATE);
if (id == M32_THISACTOR_VAR_ID)
return vm.g_i;
return vm.spriteNum;
id &= ~M32_FLAG_NEGATE;

View file

@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define WIN_IS_PRESSED ( KB_KeyPressed( sc_RightWin ) || KB_KeyPressed( sc_LeftWin ) )
#define ALT_IS_PRESSED ( KB_KeyPressed( sc_RightAlt ) || KB_KeyPressed( sc_LeftAlt ) )
#define SHIFTS_IS_PRESSED ( KB_KeyPressed( sc_RightShift ) || KB_KeyPressed( sc_LeftShift ) )
#define RANDOMSCRAP A_InsertSprite(s->sectnum,s->x+(krand()&255)-128,s->y+(krand()&255)-128,s->z-(8<<8)-(krand()&8191),\
#define RANDOMSCRAP(s, i) A_InsertSprite(s->sectnum,s->x+(krand()&255)-128,s->y+(krand()&255)-128,s->z-ZOFFSET3-(krand()&8191),\
SCRAP6+(krand()&15),-8,48,48,krand()&2047,(krand()&63)+64,-512-(krand()&2047),i,5)
#define GTFLAGS(x) (GametypeFlags[ud.coop] & x)
@ -182,36 +182,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define CSTAT_SPRITE_BREAKABLE (CSTAT_SPRITE_BLOCK_HITSCAN)
#define SP sprite[i].yvel
#define SX sprite[i].x
#define SY sprite[i].y
#define SZ sprite[i].z
#define SS sprite[i].shade
#define PN sprite[i].picnum
#define SA sprite[i].ang
#define SP(i) sprite[i].yvel
#define SX(i) sprite[i].x
#define SY(i) sprite[i].y
#define SZ(i) sprite[i].z
#define SS(i) sprite[i].shade
#define PN(i) sprite[i].picnum
#define SA(i) sprite[i].ang
//#define SV sprite[i].xvel
//#define ZV sprite[i].zvel
//#define RX sprite[i].xrepeat
//#define RY sprite[i].yrepeat
#define OW sprite[i].owner
#define CS sprite[i].cstat
#define SH sprite[i].extra
#define OW(i) sprite[i].owner
#define CS(i) sprite[i].cstat
#define SH(i) sprite[i].extra
//#define CX sprite[i].xoffset
//#define CY sprite[i].yoffset
//#define CD sprite[i].clipdist
//#define PL sprite[i].pal
#define SLT sprite[i].lotag
#define SHT sprite[i].hitag
#define SECT sprite[i].sectnum
#define SLT(i) sprite[i].lotag
#define SHT(i) sprite[i].hitag
#define SECT(i) sprite[i].sectnum
#define T1 actor[i].t_data[0]
#define T2 actor[i].t_data[1]
#define T3 actor[i].t_data[2]
#define T4 actor[i].t_data[3]
#define T5 actor[i].t_data[4]
#define T6 actor[i].t_data[5]
#define T7 actor[i].t_data[6]
#define T8 actor[i].t_data[7]
#define T9 actor[i].t_data[8]
#define T1(i) actor[i].t_data[0]
#define T2(i) actor[i].t_data[1]
#define T3(i) actor[i].t_data[2]
#define T4(i) actor[i].t_data[3]
#define T5(i) actor[i].t_data[4]
#define T6(i) actor[i].t_data[5]
#endif

View file

@ -1460,8 +1460,8 @@ void M_Init(void)
MEOS_NETOPTIONS_LEVEL[i] = MEOS_NETOPTIONS_LEVEL_TEMPLATE;
for (j = 0; j < MAXLEVELS; ++j)
{
MEOSN_NetLevels[i][j] = MapInfo[MAXLEVELS*i+j].name;
if (MapInfo[i*MAXLEVELS+j].filename != NULL)
MEOSN_NetLevels[i][j] = aMapInfo[MAXLEVELS*i+j].name;
if (aMapInfo[i*MAXLEVELS+j].filename != NULL)
MEOS_NETOPTIONS_LEVEL[i].numOptions = j+1;
}
MEOS_NETOPTIONS_LEVEL[i].optionNames = MEOSN_NetLevels[i];
@ -1830,9 +1830,9 @@ static void M_PreMenu(MenuID_t cm)
// refresh display names of quote cheats
if (!DUKEBETA)
{
ME_CheatCodes[CHEATFUNC_QUOTEBETA].name = ScriptQuotes[QUOTE_CHEAT_BETA];
ME_CheatCodes[CHEATFUNC_QUOTETODD].name = NAM ? g_NAMMattCheatQuote : ScriptQuotes[QUOTE_CHEAT_TODD];
ME_CheatCodes[CHEATFUNC_QUOTEALLEN].name = ScriptQuotes[QUOTE_CHEAT_ALLEN];
ME_CheatCodes[CHEATFUNC_QUOTEBETA].name = apStrings[QUOTE_CHEAT_BETA];
ME_CheatCodes[CHEATFUNC_QUOTETODD].name = NAM ? g_NAMMattCheatQuote : apStrings[QUOTE_CHEAT_TODD];
ME_CheatCodes[CHEATFUNC_QUOTEALLEN].name = apStrings[QUOTE_CHEAT_ALLEN];
}
MenuEntry_DisableOnCondition(&ME_ENTERCHEAT, (cl_cheatmask == UINT32_MAX));
@ -1927,7 +1927,7 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin)
mminitext(origin.x + ((90+60)<<16), origin.y + (90<<16), GametypeNames[ud.m_coop], 0);
mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8)<<16), EpisodeNames[ud.m_volume_number], 0);
mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8+8)<<16), MapInfo[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name, 0);
mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8+8)<<16), aMapInfo[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name, 0);
if (ud.m_monsters_off == 0 || ud.m_player_skill > 0)
mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8+8+8)<<16), SkillNames[ud.m_player_skill], 0);
else mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8+8+8)<<16), "None", 0);
@ -2029,7 +2029,7 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin)
}
{
const char *name = MapInfo[(savehead.volnum*MAXLEVELS) + savehead.levnum].name;
const char *name = aMapInfo[(savehead.volnum*MAXLEVELS) + savehead.levnum].name;
Bsprintf(tempbuf, "%s / %s", name ? name : "^10unnamed^0", SkillNames[savehead.skill-1]);
}
@ -2083,7 +2083,7 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin)
mgametextcenter(origin.x, origin.y + (156<<16), tempbuf);
}
Bsprintf(tempbuf,"%s / %s",MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, SkillNames[ud.player_skill-1]);
Bsprintf(tempbuf,"%s / %s",aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, SkillNames[ud.player_skill-1]);
mgametextcenter(origin.x, origin.y + (168<<16), tempbuf);
if (ud.volume_number == 0 && ud.level_number == 7)
mgametextcenter(origin.x, origin.y + (180<<16), currentboardfilename);
@ -2104,7 +2104,7 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin)
if (g_oldverSavegame[M_LOAD.currentEntry])
{
mgametextcenter(origin.x, origin.y + (90<<16), "Start new game:");
Bsprintf(tempbuf,"%s / %s",MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, SkillNames[ud.player_skill-1]);
Bsprintf(tempbuf,"%s / %s",aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, SkillNames[ud.player_skill-1]);
mgametextcenter(origin.x, origin.y + (99<<16), tempbuf);
}
else
@ -2567,7 +2567,7 @@ static int32_t M_Cheat_Warp(char const * const numbers)
osdcmd_cheatsinfo_stat.level--;
if ((VOLUMEONE && osdcmd_cheatsinfo_stat.volume > 0) || osdcmd_cheatsinfo_stat.volume > g_numVolumes-1 ||
osdcmd_cheatsinfo_stat.level >= MAXLEVELS || MapInfo[osdcmd_cheatsinfo_stat.volume *MAXLEVELS+osdcmd_cheatsinfo_stat.level].filename == NULL)
osdcmd_cheatsinfo_stat.level >= MAXLEVELS || aMapInfo[osdcmd_cheatsinfo_stat.volume *MAXLEVELS+osdcmd_cheatsinfo_stat.level].filename == NULL)
return 1;
osdcmd_cheatsinfo_stat.cheatnum = CHEAT_SCOTTY;
@ -3064,7 +3064,7 @@ static int32_t M_MenuEntryStringSubmit(MenuEntry_t *entry, char *input)
save_xxh == XXH32((uint8_t *)&ud.savegame[M_SAVE.currentEntry][0], MAXSAVEGAMENAME-3, 0xDEADBEEF)))
#endif
{
Bstrncpy(&ud.savegame[M_SAVE.currentEntry][0], MapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, MAXSAVEGAMENAME-3);
Bstrncpy(&ud.savegame[M_SAVE.currentEntry][0], aMapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, MAXSAVEGAMENAME-3);
ud.savegame[M_SAVE.currentEntry][MAXSAVEGAMENAME-2] = 127;
returnvar = -1;
}

View file

@ -730,106 +730,6 @@ void MIDI_SetDivision(int32_t division)
int32_t MIDI_GetTempo(void) { return MIDI_Tempo; }
static int32_t _MIDI_ProcessNextTick(void)
{
int32_t TimeSet = FALSE;
track *Track = _MIDI_TrackPtr;
int32_t tracknum = 0;
while ((tracknum < _MIDI_NumTracks) && (Track != NULL))
{
while ((Track->active) && (Track->delay == 0))
{
int32_t event;
GET_NEXT_EVENT(Track, event);
if (GET_MIDI_COMMAND(event) == MIDI_SPECIAL)
{
switch (event)
{
case MIDI_SYSEX:
case MIDI_SYSEX_CONTINUE: _MIDI_SysEx(Track); break;
case MIDI_META_EVENT: _MIDI_MetaEvent(Track); break;
}
if (Track->active)
Track->delay = _MIDI_ReadDelta(Track);
continue;
}
if (event & MIDI_RUNNING_STATUS)
Track->RunningStatus = event;
else
{
event = Track->RunningStatus;
Track->pos--;
}
int const channel = GET_MIDI_CHANNEL(event);
int const command = GET_MIDI_COMMAND(event);
int32_t c1 = 0;
int32_t c2 = 0;
if (_MIDI_CommandLengths[ command ] > 0)
{
GET_NEXT_EVENT(Track, c1);
if (_MIDI_CommandLengths[ command ] > 1)
GET_NEXT_EVENT(Track, c2);
}
switch (command)
{
case MIDI_NOTE_OFF:
case MIDI_NOTE_ON: break;
case MIDI_POLY_AFTER_TCH:
if (_MIDI_Funcs->PolyAftertouch)
_MIDI_Funcs->PolyAftertouch(channel, c1, c2);
break;
case MIDI_CONTROL_CHANGE:
TimeSet = _MIDI_InterpretControllerInfo(Track, TimeSet, channel, c1, c2);
break;
case MIDI_PROGRAM_CHANGE:
if ((_MIDI_Funcs->ProgramChange) && (!Track->EMIDI_ProgramChange))
_MIDI_Funcs->ProgramChange(channel, c1);
break;
case MIDI_AFTER_TOUCH:
if (_MIDI_Funcs->ChannelAftertouch)
_MIDI_Funcs->ChannelAftertouch(channel, c1);
break;
case MIDI_PITCH_BEND:
if (_MIDI_Funcs->PitchBend)
_MIDI_Funcs->PitchBend(channel, c1, c2);
break;
default: break;
}
Track->delay = _MIDI_ReadDelta(Track);
}
Track->delay--;
Track++;
tracknum++;
if (_MIDI_ActiveTracks == 0)
break;
}
_MIDI_AdvanceTick();
return TimeSet;
}
static void _MIDI_InitEMIDI(void)
{
int32_t type = EMIDI_GeneralMIDI;

View file

@ -112,7 +112,7 @@ static void P_RemovePlayer(int32_t p)
voting = -1;
}
Bstrcpy(ScriptQuotes[QUOTE_RESERVED2],recbuf);
Bstrcpy(apStrings[QUOTE_RESERVED2],recbuf);
g_player[myconnectindex].ps->ftq = QUOTE_RESERVED2;
g_player[myconnectindex].ps->fta = 180;
}
@ -2079,7 +2079,7 @@ void Net_ReceiveMapVoteInitiate(uint8_t *pbuf)
Bsprintf(tempbuf,"%s^00 has called a vote to change map to %s (E%dL%d)",
g_player[voting].user_name,
MapInfo[(uint8_t)(vote_episode*MAXLEVELS + vote_map)].name,
aMapInfo[(uint8_t)(vote_episode*MAXLEVELS + vote_map)].name,
vote_episode+1,vote_map+1);
G_AddUserQuote(tempbuf);

View file

@ -83,7 +83,7 @@ static int32_t osdcmd_changelevel(const osdfuncparm_t *parm)
}
}
if (level > MAXLEVELS || MapInfo[volume *MAXLEVELS+level].filename == NULL)
if (level > MAXLEVELS || aMapInfo[volume *MAXLEVELS+level].filename == NULL)
{
OSD_Printf("changelevel: invalid level number\n");
return OSDCMD_SHOWHELP;
@ -386,7 +386,7 @@ static int32_t osdcmd_music(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
if (MapInfo[sel].musicfn != NULL)
if (aMapInfo[sel].musicfn != NULL)
{
g_musicIndex = sel;
G_StartMusic();

File diff suppressed because it is too large Load diff

View file

@ -356,12 +356,14 @@ void P_UpdateScreenPal(DukePlayer_t *p);
void P_EndLevel(void);
void P_CheckWeaponI(int32_t snum);
int32_t P_GetHudPal(const DukePlayer_t *p);
int P_GetHudPal(const DukePlayer_t *p);
int32_t Proj_GetDamage(projectile_t const * pProj);
#if !defined LUNATIC
void P_SetWeaponGamevars(int32_t snum, const DukePlayer_t *p);
void P_SetWeaponGamevars(int snum, const DukePlayer_t *p);
#else
static inline void P_SetWeaponGamevars(int32_t snum, const DukePlayer_t *p)
void P_SetWeaponGamevars(int snum, const DukePlayer_t *p)
{
UNREFERENCED_PARAMETER(snum);
UNREFERENCED_PARAMETER(p);

View file

@ -75,10 +75,10 @@ static void G_CacheSpriteNum(int32_t i)
maxc = 1;
for (j = PN; j <= g_tile[PN].cacherange; j++)
for (j = PN(i); j <= g_tile[PN(i)].cacherange; j++)
tloadtile(j,1);
switch (DYNAMICTILEMAP(PN))
switch (DYNAMICTILEMAP(PN(i)))
{
case HYDRENT__STATIC:
tloadtile(BROKEFIREHYDRENT,1);
@ -201,7 +201,7 @@ static void G_CacheSpriteNum(int32_t i)
}
for (j = PN; j < (PN+maxc); j++) tloadtile(j,1);
for (j = PN(i); j < (PN(i)+maxc); j++) tloadtile(j,1);
}
static void G_PrecacheSprites(void)
@ -353,8 +353,8 @@ static void G_DoLoadScreen(const char *statustext, int32_t percent)
else
{
menutext(160,90,0,0,"Loading");
if (MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL)
menutext(160,90+16+8,0,0,MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name);
if (aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL)
menutext(160,90+16+8,0,0,aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name);
}
#ifndef EDUKE32_TOUCH_DEVICES
@ -426,10 +426,10 @@ void G_CacheMapData(void)
S_PauseMusic(1);
#endif
if (MapInfo[MUS_LOADING].musicfn)
if (aMapInfo[MUS_LOADING].musicfn)
{
S_StopMusic();
S_PlayMusic(MapInfo[MUS_LOADING].musicfn);
S_PlayMusic(aMapInfo[MUS_LOADING].musicfn);
}
#if defined EDUKE32_TOUCH_DEVICES && defined USE_OPENGL
@ -884,7 +884,7 @@ static void resetprestat(int32_t snum,int32_t g)
int32_t i;
g_spriteDeleteQueuePos = 0;
for (i=0; i<g_spriteDeleteQueueSize; i++) SpriteDeletionQueue[i] = -1;
for (i=0; i<g_deleteQueueSize; i++) SpriteDeletionQueue[i] = -1;
p->hbomb_on = 0;
p->cheat_phase = 0;
@ -1091,14 +1091,14 @@ static void prelevel(char g)
VM_OnEvent(EVENT_LOADACTOR, i, -1);
if (G_CheckExitSprite(i))
{
g_player[0].ps->exitx = SX;
g_player[0].ps->exity = SY;
g_player[0].ps->exitx = SX(i);
g_player[0].ps->exity = SY(i);
}
else switch (DYNAMICTILEMAP(PN))
else switch (DYNAMICTILEMAP(PN(i)))
{
case GPSPEED__STATIC:
// DELETE_AFTER_LOADACTOR. Must not change statnum.
sector[SECT].extra = SLT;
sector[SECT(i)].extra = SLT(i);
break;
case CYCLER__STATIC:
@ -1108,12 +1108,12 @@ static void prelevel(char g)
Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS);
G_GameExit(tempbuf);
}
cyclers[g_numCyclers][0] = SECT;
cyclers[g_numCyclers][1] = SLT;
cyclers[g_numCyclers][2] = SS;
cyclers[g_numCyclers][3] = sector[SECT].floorshade;
cyclers[g_numCyclers][4] = SHT;
cyclers[g_numCyclers][5] = (SA == 1536);
cyclers[g_numCyclers][0] = SECT(i);
cyclers[g_numCyclers][1] = SLT(i);
cyclers[g_numCyclers][2] = SS(i);
cyclers[g_numCyclers][3] = sector[SECT(i)].floorshade;
cyclers[g_numCyclers][4] = SHT(i);
cyclers[g_numCyclers][5] = (SA(i) == 1536);
g_numCyclers++;
break;
@ -1134,7 +1134,7 @@ static void prelevel(char g)
// the LOADACTOR events. DELETE_AFTER_LOADACTOR.
for (SPRITES_OF_STAT_SAFE(STAT_DEFAULT, i, nexti))
if (!G_CheckExitSprite(i))
switch (DYNAMICTILEMAP(PN))
switch (DYNAMICTILEMAP(PN(i)))
{
case GPSPEED__STATIC:
case CYCLER__STATIC:
@ -1144,13 +1144,13 @@ static void prelevel(char g)
for (i = 0; i < MAXSPRITES; i++)
{
if (sprite[i].statnum < MAXSTATUS && (PN != SECTOREFFECTOR || SLT != SE_14_SUBWAY_CAR))
if (sprite[i].statnum < MAXSTATUS && (PN(i) != SECTOREFFECTOR || SLT(i) != SE_14_SUBWAY_CAR))
A_Spawn(-1, i);
}
for (i = 0; i < MAXSPRITES; i++)
{
if (sprite[i].statnum < MAXSTATUS && PN == SECTOREFFECTOR && SLT == SE_14_SUBWAY_CAR)
if (sprite[i].statnum < MAXSTATUS && PN(i) == SECTOREFFECTOR && SLT(i) == SE_14_SUBWAY_CAR)
A_Spawn(-1, i);
}
@ -1160,11 +1160,11 @@ static void prelevel(char g)
{
int32_t ii;
if (PN <= 0) // oob safety for switch below
if (PN(i) <= 0) // oob safety for switch below
continue;
for (ii=0; ii<2; ii++)
switch (DYNAMICTILEMAP(PN-1+ii))
switch (DYNAMICTILEMAP(PN(i)-1+ii))
{
case DIPSWITCH__STATIC:
case DIPSWITCH2__STATIC:
@ -1380,7 +1380,7 @@ void G_NewGame(int32_t vn, int32_t ln, int32_t sk)
if (ln == 0 && vn == 3 && (!g_netServer && ud.multimode < 2) && ud.lockout == 0
&& (G_GetLogoFlags() & LOGO_NOE4CUTSCENE)==0)
{
S_PlayMusic(MapInfo[MUS_BRIEFING].musicfn);
S_PlayMusic(aMapInfo[MUS_BRIEFING].musicfn);
flushperms();
setview(0,0,xdim-1,ydim-1);
@ -1439,7 +1439,7 @@ end_vol4a:
Gv_ResetSystemDefaults();
for (i=0; i<(MAXVOLUMES*MAXLEVELS); i++)
ALIGNED_FREE_AND_NULL(MapInfo[i].savedstate);
ALIGNED_FREE_AND_NULL(aMapInfo[i].savedstate);
if (ud.m_coop != 1)
{
@ -1680,10 +1680,10 @@ int32_t G_FindLevelByFile(const char *fn)
const int voloff = volume * MAXLEVELS;
for (int level = 0; level < MAXLEVELS; level++)
{
if (MapInfo[voloff + level].filename == NULL)
if (aMapInfo[voloff + level].filename == NULL)
continue;
if (!Bstrcasecmp(fn, MapInfo[voloff + level].filename))
if (!Bstrcasecmp(fn, aMapInfo[voloff + level].filename))
return voloff + level;
}
}
@ -1776,12 +1776,12 @@ void G_SetupFilenameBasedMusic(char *levnamebuf, const char *boardfilename, int3
if ((fil = kopen4loadfrommod(levnamebuf, 0)) != -1)
{
kclose(fil);
realloc_copy(&MapInfo[level_number].musicfn, levnamebuf);
realloc_copy(&aMapInfo[level_number].musicfn, levnamebuf);
return;
}
}
realloc_copy(&MapInfo[level_number].musicfn, "dethtoll.mid");
realloc_copy(&aMapInfo[level_number].musicfn, "dethtoll.mid");
}
static inline int G_HaveUserMap(void)
@ -1841,14 +1841,14 @@ int32_t G_EnterLevel(int32_t g)
mii = (ud.volume_number*MAXLEVELS)+ud.level_number;
if (MapInfo[mii].name == NULL || MapInfo[mii].filename == NULL)
if (aMapInfo[mii].name == NULL || aMapInfo[mii].filename == NULL)
{
if (G_HaveUserMap())
{
if (MapInfo[mii].filename == NULL)
MapInfo[mii].filename = (char *)Xcalloc(BMAX_PATH, sizeof(uint8_t));
if (MapInfo[mii].name == NULL)
MapInfo[mii].name = Xstrdup("User Map");
if (aMapInfo[mii].filename == NULL)
aMapInfo[mii].filename = (char *)Xcalloc(BMAX_PATH, sizeof(uint8_t));
if (aMapInfo[mii].name == NULL)
aMapInfo[mii].name = Xstrdup("User Map");
}
else
{
@ -1876,9 +1876,9 @@ int32_t G_EnterLevel(int32_t g)
else
{
if (g_gameNamePtr)
Bsprintf(apptitle,"%s - %s - " APPNAME,MapInfo[mii].name,g_gameNamePtr);
Bsprintf(apptitle,"%s - %s - " APPNAME,aMapInfo[mii].name,g_gameNamePtr);
else
Bsprintf(apptitle,"%s - " APPNAME,MapInfo[mii].name);
Bsprintf(apptitle,"%s - " APPNAME,aMapInfo[mii].name);
}
Bstrcpy(tempbuf,apptitle);
@ -1899,15 +1899,15 @@ int32_t G_EnterLevel(int32_t g)
G_LoadMapHack(levname, boardfilename);
G_SetupFilenameBasedMusic(levname, boardfilename, ud.m_level_number);
}
else if (loadboard(MapInfo[mii].filename, VOLUMEONE, &ps->pos, &ps->ang, &ps->cursectnum) < 0)
else if (loadboard(aMapInfo[mii].filename, VOLUMEONE, &ps->pos, &ps->ang, &ps->cursectnum) < 0)
{
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n",
MapInfo[mii].filename);
aMapInfo[mii].filename);
return 1;
}
else
{
G_LoadMapHack(levname, MapInfo[mii].filename);
G_LoadMapHack(levname, aMapInfo[mii].filename);
}
}
@ -1922,7 +1922,7 @@ int32_t G_EnterLevel(int32_t g)
G_AlignWarpElevators();
resetpspritevars(g);
ud.playerbest = CONFIG_GetMapBestTime(G_HaveUserMap() ? boardfilename : MapInfo[mii].filename, g_loadedMapHack.md4);
ud.playerbest = CONFIG_GetMapBestTime(G_HaveUserMap() ? boardfilename : aMapInfo[mii].filename, g_loadedMapHack.md4);
G_FadeLoad(0,0,0, 252,0, -28, 4, -1);
G_CacheMapData();
@ -1931,8 +1931,8 @@ int32_t G_EnterLevel(int32_t g)
if (ud.recstat != 2)
{
g_musicIndex = mii;
if (MapInfo[g_musicIndex].musicfn != NULL)
S_PlayMusic(MapInfo[g_musicIndex].musicfn);
if (aMapInfo[g_musicIndex].musicfn != NULL)
S_PlayMusic(aMapInfo[g_musicIndex].musicfn);
}
if (g & (MODE_GAME|MODE_EOL))
@ -2014,7 +2014,7 @@ int32_t G_EnterLevel(int32_t g)
}
OSD_Printf(OSDTEXT_YELLOW "E%dL%d: %s\n", ud.volume_number+1, ud.level_number+1,
MapInfo[mii].name);
aMapInfo[mii].name);
g_restorePalette = -1;
@ -2029,7 +2029,7 @@ int32_t G_EnterLevel(int32_t g)
void G_FreeMapState(int32_t mapnum)
{
map_t *mapinfo = &MapInfo[mapnum];
map_t *mapinfo = &aMapInfo[mapnum];
#if !defined LUNATIC
int32_t j;
#endif
@ -2039,8 +2039,8 @@ void G_FreeMapState(int32_t mapnum)
#if !defined LUNATIC
for (j=0; j<g_gameVarCount; j++)
{
if (aGameVars[j].nFlags & GAMEVAR_NORESET) continue;
if (aGameVars[j].nFlags & (GAMEVAR_PERPLAYER|GAMEVAR_PERACTOR))
if (aGameVars[j].flags & GAMEVAR_NORESET) continue;
if (aGameVars[j].flags & (GAMEVAR_PERPLAYER|GAMEVAR_PERACTOR))
Baligned_free(mapinfo->savedstate->vars[j]);
}
#else

View file

@ -301,8 +301,8 @@ int32_t G_LoadPlayer(int32_t spot)
if (boardfilename[0])
Bstrcpy(currentboardfilename, boardfilename);
else if (MapInfo[mapIdx].filename)
Bstrcpy(currentboardfilename, MapInfo[mapIdx].filename);
else if (aMapInfo[mapIdx].filename)
Bstrcpy(currentboardfilename, aMapInfo[mapIdx].filename);
if (currentboardfilename[0])
{
@ -448,10 +448,10 @@ int32_t G_SavePlayer(int32_t spot)
{
#ifdef LUNATIC
if (!g_savedOK)
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "^10Failed Saving Game");
Bstrcpy(apStrings[QUOTE_RESERVED4], "^10Failed Saving Game");
else
#endif
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "Game Saved");
Bstrcpy(apStrings[QUOTE_RESERVED4], "Game Saved");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
}
@ -468,7 +468,7 @@ void G_LoadPlayerMaybeMulti(int32_t slot)
{
if (g_netServer || ud.multimode > 1)
{
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "Multiplayer Loading Not Yet Supported");
Bstrcpy(apStrings[QUOTE_RESERVED4], "Multiplayer Loading Not Yet Supported");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
// G_LoadPlayer(-1-g_lastSaveSlot);
@ -490,7 +490,7 @@ void G_SavePlayerMaybeMulti(int32_t slot)
if (g_netServer || ud.multimode > 1)
{
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "Multiplayer Saving Not Yet Supported");
Bstrcpy(apStrings[QUOTE_RESERVED4], "Multiplayer Saving Not Yet Supported");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
// G_SavePlayer(-1-slot);
}
@ -1107,7 +1107,7 @@ static const dataspec_t svgm_script[] =
{ DS_LOADFN, (void *) &sv_postprojectileload, 0, 1 },
#if !defined LUNATIC
{ DS_LOADFN|DS_NOCHK, (void *)&sv_prescriptload_once, 0, 1 },
{ DS_DYNAMIC|DS_CNT(g_scriptSize)|DS_NOCHK, &script, sizeof(script[0]), (intptr_t)&g_scriptSize },
{ DS_DYNAMIC|DS_CNT(g_scriptSize)|DS_NOCHK, &apScript, sizeof(apScript[0]), (intptr_t)&g_scriptSize },
// { DS_NOCHK, &apScriptGameEvent[0], sizeof(apScriptGameEvent[0]), MAXGAMEEVENTS },
{ DS_SAVEFN|DS_LOADFN|DS_NOCHK, (void *)&sv_postscript_once, 0, 1 },
#endif
@ -1136,8 +1136,8 @@ static const dataspec_t svgm_anmisc[] =
{ 0, &g_curViewscreen, sizeof(g_curViewscreen), 1 },
{ 0, &g_origins[0], sizeof(g_origins[0]), ARRAY_SIZE(g_origins) },
{ 0, &g_spriteDeleteQueuePos, sizeof(g_spriteDeleteQueuePos), 1 },
{ DS_NOCHK, &g_spriteDeleteQueueSize, sizeof(g_spriteDeleteQueueSize), 1 },
{ DS_CNT(g_spriteDeleteQueueSize), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&g_spriteDeleteQueueSize },
{ DS_NOCHK, &g_deleteQueueSize, sizeof(g_deleteQueueSize), 1 },
{ DS_CNT(g_deleteQueueSize), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&g_deleteQueueSize },
{ 0, &show2dsector[0], sizeof(uint8_t), MAXSECTORS>>3 },
{ DS_NOCHK, &g_numClouds, sizeof(g_numClouds), 1 },
{ 0, &clouds[0], sizeof(clouds), 1 },
@ -1152,10 +1152,10 @@ static const dataspec_t svgm_anmisc[] =
{ DS_DYNAMIC, &savegame_quotes, MAXQUOTELEN, MAXQUOTES },
{ DS_LOADFN, (void *)&sv_quoteload, 0, 1 },
{ DS_NOCHK, &g_numQuoteRedefinitions, sizeof(g_numQuoteRedefinitions), 1 },
{ DS_NOCHK, &g_numXStrings, sizeof(g_numXStrings), 1 },
{ DS_NOCHK|DS_SAVEFN|DS_LOADFN, (void *)&sv_prequoteredef, 0, 1 },
{ DS_NOCHK|DS_SAVEFN, (void *)&sv_quoteredefsave, 0, 1 }, // quote redefinitions replace quotes at runtime, but cannot be changed after CON compilation
{ DS_NOCHK|DS_DYNAMIC|DS_CNT(g_numQuoteRedefinitions), &savegame_quoteredefs, MAXQUOTELEN, (intptr_t)&g_numQuoteRedefinitions },
{ DS_NOCHK|DS_DYNAMIC|DS_CNT(g_numXStrings), &savegame_quoteredefs, MAXQUOTELEN, (intptr_t)&g_numXStrings },
{ DS_NOCHK|DS_LOADFN, (void *)&sv_quoteredefload, 0, 1 },
{ DS_NOCHK|DS_SAVEFN|DS_LOADFN, (void *)&sv_postquoteredef, 0, 1 },
#ifdef LUNATIC
@ -1196,10 +1196,10 @@ static void sv_makevarspec()
int32_t i, j, numsavedvars=0, numsavedarrays=0, per;
for (i=0; i<g_gameVarCount; i++)
numsavedvars += (aGameVars[i].nFlags&SV_SKIPMASK) ? 0 : 1;
numsavedvars += (aGameVars[i].flags&SV_SKIPMASK) ? 0 : 1;
for (i=0; i<g_gameArrayCount; i++)
numsavedarrays += !(aGameArrays[i].nFlags & GAMEARRAY_READONLY); // SYSTEM_GAMEARRAY
numsavedarrays += !(aGameArrays[i].flags & GAMEARRAY_READONLY); // SYSTEM_GAMEARRAY
Bfree(svgm_vars);
svgm_vars = (dataspec_gv_t *)Xmalloc((numsavedvars+numsavedarrays+2)*sizeof(dataspec_gv_t));
@ -1211,13 +1211,13 @@ static void sv_makevarspec()
j=1;
for (i=0; i<g_gameVarCount; i++)
{
if (aGameVars[i].nFlags&SV_SKIPMASK)
if (aGameVars[i].flags&SV_SKIPMASK)
continue;
per = aGameVars[i].nFlags&GAMEVAR_USER_MASK;
per = aGameVars[i].flags&GAMEVAR_USER_MASK;
svgm_vars[j].flags = 0;
svgm_vars[j].ptr = (per==0) ? &aGameVars[i].nValue : aGameVars[i].pValues;
svgm_vars[j].ptr = (per==0) ? &aGameVars[i].global : aGameVars[i].pValues;
svgm_vars[j].size = sizeof(intptr_t);
svgm_vars[j].cnt = (per==0) ? 1 : (per==GAMEVAR_PERPLAYER ? MAXPLAYERS : MAXSPRITES);
j++;
@ -1228,7 +1228,7 @@ static void sv_makevarspec()
// We must not update read-only SYSTEM_GAMEARRAY gamearrays: besides
// being questionable by itself, sizeof(...) may be e.g. 4 whereas the
// actual element type is int16_t (such as tilesizx[]/tilesizy[]).
if (aGameArrays[i].nFlags & GAMEARRAY_READONLY)
if (aGameArrays[i].flags & GAMEARRAY_READONLY)
continue;
intptr_t * const plValues = aGameArrays[i].pValues;
@ -1657,26 +1657,26 @@ static void sv_prescriptsave_once()
int32_t i;
for (i=0; i<g_scriptSize; i++)
if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)))
script[i] = (intptr_t *)script[i] - script;
apScript[i] = (intptr_t *)apScript[i] - apScript;
G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0);
G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0);
G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_FWD_NON0);
G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_FWD_NON0);
}
static void sv_prescriptload_once()
{
Bfree(script);
script = (intptr_t *)Xmalloc(g_scriptSize * sizeof(script[0]));
Bfree(apScript);
apScript = (intptr_t *)Xmalloc(g_scriptSize * sizeof(apScript[0]));
}
static void sv_postscript_once()
{
int32_t i;
G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0);
G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0);
G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_BACK_NON0);
G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_BACK_NON0);
for (i=0; i<g_scriptSize; i++)
if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)))
script[i] = (intptr_t)(script + script[i]);
apScript[i] = (intptr_t)(apScript + apScript[i]);
}
#endif
@ -1723,10 +1723,10 @@ static void sv_quotesave()
int32_t i;
Bmemset(savegame_quotedef, 0, sizeof(savegame_quotedef));
for (i=0; i<MAXQUOTES; i++)
if (ScriptQuotes[i])
if (apStrings[i])
{
savegame_quotedef[i>>3] |= 1<<(i&7);
Bmemcpy(savegame_quotes[i], ScriptQuotes[i], MAXQUOTELEN);
Bmemcpy(savegame_quotes[i], apStrings[i], MAXQUOTELEN);
}
}
static void sv_quoteload()
@ -1737,7 +1737,7 @@ static void sv_quoteload()
if (savegame_quotedef[i>>3]&(1<<(i&7)))
{
C_AllocQuote(i);
Bmemcpy(ScriptQuotes[i], savegame_quotes[i], MAXQUOTELEN);
Bmemcpy(apStrings[i], savegame_quotes[i], MAXQUOTELEN);
}
}
}
@ -1808,24 +1808,24 @@ static void sv_postprojectileload()
static void sv_prequoteredef()
{
// "+1" needed for dfwrite which doesn't handle the src==NULL && cnt==0 case
void *ptr = Xcalloc(g_numQuoteRedefinitions+1, MAXQUOTELEN);
void *ptr = Xcalloc(g_numXStrings+1, MAXQUOTELEN);
savegame_quoteredefs = (char(*)[MAXQUOTELEN])ptr;
}
static void sv_quoteredefsave()
{
int32_t i;
for (i=0; i<g_numQuoteRedefinitions; i++)
if (ScriptQuoteRedefinitions[i])
Bmemcpy(savegame_quoteredefs[i], ScriptQuoteRedefinitions[i], MAXQUOTELEN);
for (i=0; i<g_numXStrings; i++)
if (apXStrings[i])
Bmemcpy(savegame_quoteredefs[i], apXStrings[i], MAXQUOTELEN);
}
static void sv_quoteredefload()
{
int32_t i;
for (i=0; i<g_numQuoteRedefinitions; i++)
for (i=0; i<g_numXStrings; i++)
{
if (!ScriptQuoteRedefinitions[i])
ScriptQuoteRedefinitions[i] = (char *)Xcalloc(1,MAXQUOTELEN);
Bmemcpy(ScriptQuoteRedefinitions[i], savegame_quoteredefs[i], MAXQUOTELEN);
if (!apXStrings[i])
apXStrings[i] = (char *)Xcalloc(1,MAXQUOTELEN);
Bmemcpy(apXStrings[i], savegame_quoteredefs[i], MAXQUOTELEN);
}
}
static void sv_postquoteredef()
@ -1930,7 +1930,7 @@ static uint8_t *dosaveplayer2(FILE *fil, uint8_t *mem)
PRINTSIZE("animisc");
#if !defined LUNATIC
Gv_WriteSave(fil, 1); // gamevars
Gv_WriteSave(fil); // gamevars
mem=writespecdata((const dataspec_t *)svgm_vars, 0, mem);
PRINTSIZE("vars");
#endif
@ -2024,7 +2024,7 @@ static int32_t doloadplayer2(int32_t fil, uint8_t **memptr)
PRINTSIZE("animisc");
#if !defined LUNATIC
if (Gv_ReadSave(fil, 1)) return -7;
if (Gv_ReadSave(fil)) return -7;
if (mem)
{
@ -2121,13 +2121,13 @@ static void postloadplayer(int32_t savegamep)
if (ud.config.MusicToggle)
{
if (MapInfo[musicIdx].musicfn != NULL &&
if (aMapInfo[musicIdx].musicfn != NULL &&
(musicIdx != g_musicIndex /* || MapInfo[MUS_LOADING].musicfn */))
{
S_StopMusic();
g_musicIndex = musicIdx;
S_PlayMusic(MapInfo[g_musicIndex].musicfn);
S_PlayMusic(aMapInfo[g_musicIndex].musicfn);
}
S_PauseMusic(0);
@ -2150,8 +2150,8 @@ static void postloadplayer(int32_t savegamep)
for (SPRITES_OF(STAT_FX, i))
if (sprite[i].picnum == MUSICANDSFX)
{
T2 = ud.config.SoundToggle;
T1 = 0;
T2(i) = ud.config.SoundToggle;
T1(i) = 0;
}
G_UpdateScreenArea();

View file

@ -180,7 +180,7 @@ static void G_ShowScores(void)
if (playerswhenstarted > 1 && (GametypeFlags[ud.coop]&GAMETYPE_SCORESHEET))
{
gametext(160, SCORESHEETOFFSET+58+2, "Multiplayer Totals", 0, 2+8+16);
gametext(160, SCORESHEETOFFSET+58+10, MapInfo[G_LastMapInfoIndex()].name, 0, 2+8+16);
gametext(160, SCORESHEETOFFSET+58+10, aMapInfo[G_LastMapInfoIndex()].name, 0, 2+8+16);
t = 0;
minitext(70, SCORESHEETOFFSET+80, "Name", 8, 2+8+16+ROTATESPRITE_MAX);
@ -268,7 +268,7 @@ static void G_DrawCameraText(int16_t i)
if (VM_OnEvent(EVENT_DISPLAYCAMERAOSD, i, screenpeek) != 0)
return;
if (!T1)
if (!T1(i))
{
rotatesprite_win(24<<16, 33<<16, 65536L, 0, CAMCORNER, 0, 0, 2);
rotatesprite_win((320-26)<<16, 34<<16, 65536L, 0, CAMCORNER+1, 0, 0, 2);
@ -1047,7 +1047,7 @@ void G_DisplayRest(int32_t smoothratio)
{
const int32_t a = (ud.screen_size > 0) ? 147 : 179;
minitext(5, a+6, EpisodeNames[ud.volume_number], 0, 2+8+16+256);
minitext(5, a+6+6, MapInfo[ud.volume_number*MAXLEVELS + ud.level_number].name, 0, 2+8+16+256);
minitext(5, a+6+6, aMapInfo[ud.volume_number*MAXLEVELS + ud.level_number].name, 0, 2+8+16+256);
}
}
}
@ -1077,11 +1077,11 @@ void G_DisplayRest(int32_t smoothratio)
else if (g_levelTextTime < 5)
bits |= 1;
if (MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL)
if (aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL)
{
if (currentboardfilename[0] != 0 && ud.volume_number == 0 && ud.level_number == 7)
menutext_(160, 90+16+8, -g_levelTextTime+22/*quotepulseshade*/, 0, currentboardfilename, bits);
else menutext_(160, 90+16+8, -g_levelTextTime+22/*quotepulseshade*/, 0, MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, bits);
else menutext_(160, 90+16+8, -g_levelTextTime+22/*quotepulseshade*/, 0, aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, bits);
}
}
@ -1221,7 +1221,7 @@ void G_DisplayRest(int32_t smoothratio)
{
Bsprintf(tempbuf, "%s^00 has called a vote for map", g_player[voting].user_name);
gametext(160, 40, tempbuf, 0, 2+8+16);
Bsprintf(tempbuf, "%s (E%dL%d)", MapInfo[vote_episode*MAXLEVELS + vote_map].name, vote_episode+1, vote_map+1);
Bsprintf(tempbuf, "%s (E%dL%d)", aMapInfo[vote_episode*MAXLEVELS + vote_map].name, vote_episode+1, vote_map+1);
gametext(160, 48, tempbuf, 0, 2+8+16);
gametext(160, 70, "Press F1 to Accept, F2 to Decline", 0, 2+8+16);
}
@ -1451,7 +1451,7 @@ void G_DisplayLogo(void)
if (logoflags & LOGO_PLAYMUSIC)
{
g_musicIndex = MUS_INTRO;
S_PlayMusic(MapInfo[g_musicIndex].musicfn);
S_PlayMusic(aMapInfo[g_musicIndex].musicfn);
}
if (!NAM)
@ -1971,7 +1971,7 @@ static void G_DisplayMPResultsScreen(void)
if (PLUTOPAK) // JBF 20030804
rotatesprite_fs((260)<<16, 36<<16, 65536L, 0, PLUTOPAKSPRITE+2, 0, 0, 2+8);
gametext(160, 58+2, "Multiplayer Totals", 0, 2+8+16);
gametext(160, 58+10, MapInfo[G_LastMapInfoIndex()].name, 0, 2+8+16);
gametext(160, 58+10, aMapInfo[G_LastMapInfoIndex()].name, 0, 2+8+16);
gametext(160, 165, "Press any key or button to continue", quotepulseshade, 2+8+16);
@ -2037,11 +2037,11 @@ static int32_t G_PrintTime_ClockPad(void)
clockpad = max(clockpad, ij);
if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0]))
{
for (ii=MapInfo[G_LastMapInfoIndex()].partime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { }
for (ii=aMapInfo[G_LastMapInfoIndex()].partime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { }
clockpad = max(clockpad, ij);
if (!NAM_WW2GI && MapInfo[G_LastMapInfoIndex()].designertime)
if (!NAM_WW2GI && aMapInfo[G_LastMapInfoIndex()].designertime)
{
for (ii=MapInfo[G_LastMapInfoIndex()].designertime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { }
for (ii=aMapInfo[G_LastMapInfoIndex()].designertime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { }
clockpad = max(clockpad, ij);
}
}
@ -2070,13 +2070,13 @@ const char* G_PrintParTime(void)
{
if (ud.last_level < 1)
return "<invalid>";
return G_PrintTime2(MapInfo[G_LastMapInfoIndex()].partime);
return G_PrintTime2(aMapInfo[G_LastMapInfoIndex()].partime);
}
const char* G_PrintDesignerTime(void)
{
if (ud.last_level < 1)
return "<invalid>";
return G_PrintTime2(MapInfo[G_LastMapInfoIndex()].designertime);
return G_PrintTime2(aMapInfo[G_LastMapInfoIndex()].designertime);
}
const char* G_PrintBestTime(void)
{
@ -2103,9 +2103,9 @@ void G_BonusScreen(int32_t bonusonly)
}
else
{
lastmapname = MapInfo[G_LastMapInfoIndex()].name;
lastmapname = aMapInfo[G_LastMapInfoIndex()].name;
if (!lastmapname) // this isn't right but it's better than no name at all
lastmapname = MapInfo[G_LastMapInfoIndex()].name;
lastmapname = aMapInfo[G_LastMapInfoIndex()].name;
}
@ -2269,12 +2269,12 @@ void G_BonusScreen(int32_t bonusonly)
yy+=10;
if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0]))
{
if (MapInfo[G_LastMapInfoIndex()].partime)
if (aMapInfo[G_LastMapInfoIndex()].partime)
{
gametext(10, yy+9, "Par Time:", 0, 2+8+16);
yy+=10;
}
if (!NAM_WW2GI && !DUKEBETA && MapInfo[G_LastMapInfoIndex()].designertime)
if (!NAM_WW2GI && !DUKEBETA && aMapInfo[G_LastMapInfoIndex()].designertime)
{
// EDuke 2.0 / NAM source suggests "Green Beret's Time:"
gametext(10, yy+9, "3D Realms' Time:", 0, 2+8+16);
@ -2313,13 +2313,13 @@ void G_BonusScreen(int32_t bonusonly)
if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0]))
{
if (MapInfo[G_LastMapInfoIndex()].partime)
if (aMapInfo[G_LastMapInfoIndex()].partime)
{
G_PrintParTime();
gametext((320>>2)+71, yy+9, tempbuf, 0, 2+8+16);
yy+=10;
}
if (!NAM_WW2GI && !DUKEBETA && MapInfo[G_LastMapInfoIndex()].designertime)
if (!NAM_WW2GI && !DUKEBETA && aMapInfo[G_LastMapInfoIndex()].designertime)
{
G_PrintDesignerTime();
gametext((320>>2)+71, yy+9, tempbuf, 0, 2+8+16);

View file

@ -1118,7 +1118,7 @@ void G_PrintGameQuotes(int32_t snum)
if (ps->fta <= 1)
return;
if (EDUKE32_PREDICT_FALSE(ScriptQuotes[ps->ftq] == NULL))
if (EDUKE32_PREDICT_FALSE(apStrings[ps->ftq] == NULL))
{
OSD_Printf(OSD_ERROR "%s %d null quote %d\n", __FILE__, __LINE__, ps->ftq);
return;
@ -1175,7 +1175,7 @@ void G_PrintGameQuotes(int32_t snum)
}
#endif
gametextpalbits(160, k, ScriptQuotes[ps->ftq], ftapulseshade, pal, 2 + 8 + 16, texta(ps->fta));
gametextpalbits(160, k, apStrings[ps->ftq], ftapulseshade, pal, 2 + 8 + 16, texta(ps->fta));
}
void P_DoQuote(int32_t q, DukePlayer_t *p)
@ -1191,7 +1191,7 @@ void P_DoQuote(int32_t q, DukePlayer_t *p)
q &= ~MAXQUOTES;
}
if (EDUKE32_PREDICT_FALSE(ScriptQuotes[q] == NULL))
if (EDUKE32_PREDICT_FALSE(apStrings[q] == NULL))
{
OSD_Printf(OSD_ERROR "%s %d null quote %d\n", __FILE__, __LINE__, q);
return;
@ -1205,10 +1205,10 @@ void P_DoQuote(int32_t q, DukePlayer_t *p)
if (p->ftq != q)
{
if (p == g_player[screenpeek].ps
&& Bstrcmp(ScriptQuotes[q], "")) // avoid printing blank quotes
&& Bstrcmp(apStrings[q], "")) // avoid printing blank quotes
{
if (cq) OSD_Printf(OSDTEXT_BLUE "%s\n", ScriptQuotes[q]);
else OSD_Printf("%s\n", ScriptQuotes[q]);
if (cq) OSD_Printf(OSDTEXT_BLUE "%s\n", apStrings[q]);
else OSD_Printf("%s\n", apStrings[q]);
}
p->ftq = q;

File diff suppressed because it is too large Load diff

View file

@ -124,7 +124,7 @@ void G_AnimateWalls(void);
int32_t G_ActivateWarpElevators(int32_t s,int32_t d);
int32_t G_CheckActivatorMotion(int32_t lotag);
void G_DoSectorAnimations(void);
void G_OperateActivators(int nTag, int nPlayer);
void G_OperateActivators(int nTag, int playerNum);
void G_OperateForceFields(int32_t s,int32_t low);
void G_OperateMasterSwitches(int nTag);
void G_OperateRespawns(int32_t low);
@ -133,7 +133,7 @@ void P_HandleSharedKeys(int32_t snum);
int32_t GetAnimationGoal(const int32_t *animptr);
int32_t isanearoperator(int32_t lotag);
int32_t isanunderoperator(int32_t lotag);
int P_ActivateSwitch(int nPlayer, int nObject, int nSwitchType);
int P_ActivateSwitch(int playerNum, int nObject, int nSwitchType);
void P_CheckSectors(int32_t snum);
int Sect_DamageCeilingOrFloor(int nDmgFloor, int const nSectnum);
int32_t SetAnimation(int32_t animsect,int32_t *animptr,int32_t thegoal,int32_t thevel);

View file

@ -168,13 +168,13 @@ void S_RestartMusic(void)
{
if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME)
{
if (MapInfo[g_musicIndex].musicfn != NULL)
S_PlayMusic(MapInfo[g_musicIndex].musicfn);
if (aMapInfo[g_musicIndex].musicfn != NULL)
S_PlayMusic(aMapInfo[g_musicIndex].musicfn);
}
else if (MapInfo[MUS_INTRO].musicfn != 0 && (G_GetLogoFlags() & LOGO_PLAYMUSIC))
else if (aMapInfo[MUS_INTRO].musicfn != 0 && (G_GetLogoFlags() & LOGO_PLAYMUSIC))
{
g_musicIndex = MUS_INTRO;
S_PlayMusic(MapInfo[MUS_INTRO].musicfn);
S_PlayMusic(aMapInfo[MUS_INTRO].musicfn);
}
}
@ -441,7 +441,7 @@ static int32_t S_CalcDistAndAng(int32_t i, int32_t num, int32_t camsect, int32_t
int32_t sndang = 0, sndist = 0;
int32_t explosion = 0;
if (PN == APLAYER && P_Get(i) == screenpeek)
if (PN(i) == APLAYER && P_Get(i) == screenpeek)
goto sound_further_processing;
sndang = S_GetAngle(camang, cam, pos);
@ -453,7 +453,7 @@ static int32_t S_CalcDistAndAng(int32_t i, int32_t num, int32_t camsect, int32_t
// HACK for splitscreen mod: take the min of sound distances
// to 1st and 2nd player.
if (PN == APLAYER && P_Get(i) == 1)
if (PN(i) == APLAYER && P_Get(i) == 1)
{
sndist = sndang = 0;
goto sound_further_processing;
@ -476,16 +476,16 @@ static int32_t S_CalcDistAndAng(int32_t i, int32_t num, int32_t camsect, int32_t
}
#endif
if ((g_sounds[num].m & SF_GLOBAL) == 0 && S_IsAmbientSFX(i) && (sector[SECT].lotag&0xff) < 9) // ST_9_SLIDING_ST_DOOR
sndist = divscale14(sndist, SHT+1);
if ((g_sounds[num].m & SF_GLOBAL) == 0 && S_IsAmbientSFX(i) && (sector[SECT(i)].lotag&0xff) < 9) // ST_9_SLIDING_ST_DOOR
sndist = divscale14(sndist, SHT(i)+1);
sound_further_processing:
sndist += g_sounds[num].vo;
if (sndist < 0)
sndist = 0;
if (camsect > -1 && sndist && PN != MUSICANDSFX &&
!cansee(cam->x,cam->y,cam->z-(24<<8),camsect, SX,SY,SZ-(24<<8),SECT))
if (camsect > -1 && sndist && PN(i) != MUSICANDSFX &&
!cansee(cam->x,cam->y,cam->z-(24<<8),camsect, SX(i),SY(i),SZ(i)-(24<<8),SECT(i)))
sndist += sndist>>5;
switch (DYNAMICSOUNDMAP(num))
@ -549,7 +549,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
// Duke talk
if (g_sounds[num].m & SF_TALK)
{
if ((g_netServer || ud.multimode > 1) && PN == APLAYER && P_Get(i) != screenpeek) // other player sound
if ((g_netServer || ud.multimode > 1) && PN(i) == APLAYER && P_Get(i) != screenpeek) // other player sound
{
if (!(ud.config.VoiceToggle&4))
return -1;
@ -587,7 +587,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
}
else
{
if (sndist > 32767 && PN != MUSICANDSFX && (g_sounds[num].m & (SF_LOOP|SF_MSFX)) == 0)
if (sndist > 32767 && PN(i) != MUSICANDSFX && (g_sounds[num].m & (SF_LOOP|SF_MSFX)) == 0)
return -1;
if (peekps->cursectnum > -1 && sector[peekps->cursectnum].lotag == ST_2_UNDERWATER
@ -595,7 +595,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
pitch = -768;
}
if (g_sounds[num].num > 0 && PN != MUSICANDSFX)
if (g_sounds[num].num > 0 && PN(i) != MUSICANDSFX)
S_StopEnvSound(num, i);
if (g_sounds[num].ptr == 0)

View file

@ -187,8 +187,8 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
sndist = FindDistance3D((cx-pos->x),(cy-pos->y),(cz-pos->z));
if (i >= 0 && (g_sounds[num].m & SF_GLOBAL) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9)
sndist = divscale14(sndist,(SHT+1));
if (i >= 0 && (g_sounds[num].m & SF_GLOBAL) == 0 && PN(i) == MUSICANDSFX && SLT(i) < 999 && (sector[SECT(i)].lotag&0xff) < 9)
sndist = divscale14(sndist,(SHT(i)+1));
pitchs = g_sounds[num].ps;
pitche = g_sounds[num].pe;
@ -204,7 +204,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
sndist += g_sounds[num].vo;
if (sndist < 0) sndist = 0;
if (cs > -1 && sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,SX,SY,SZ-(24<<8),SECT))
if (cs > -1 && sndist && PN(i) != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,SX(i),SY(i),SZ(i)-(24<<8),SECT(i)))
sndist += sndist>>5;
/*
switch (num)
@ -221,12 +221,12 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
*/
if (cursectnum > -1 && sector[cursectnum].lotag == 2 && (g_sounds[num].m & SF_TALK) == 0)
pitch = -768;
if (sndist > 31444 && PN != MUSICANDSFX)
if (sndist > 31444 && PN(i) != MUSICANDSFX)
return -1;
// break;
// }
if (g_sounds[num].num > 0 && PN != MUSICANDSFX)
if (g_sounds[num].num > 0 && PN(i) != MUSICANDSFX)
{
if (g_sounds[num].SoundOwner[0].ow == i) S_StopSound(num);
else if (g_sounds[num].num > 1) S_StopSound(num);
@ -399,16 +399,16 @@ void S_Update(void)
sndang = 2048 + ca - getangle(cx-sx,cy-sy);
sndang &= 2047;
sndist = FindDistance3D((cx-sx),(cy-sy),(cz-sz));
if (i >= 0 && (g_sounds[j].m & SF_GLOBAL) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9)
sndist = divscale14(sndist,(SHT+1));
if (i >= 0 && (g_sounds[j].m & SF_GLOBAL) == 0 && PN(i) == MUSICANDSFX && SLT(i) < 999 && (sector[SECT(i)].lotag&0xff) < 9)
sndist = divscale14(sndist,(SHT(i)+1));
sndist += g_sounds[j].vo;
if (sndist < 0) sndist = 0;
if (cs > -1 && sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,sx,sy,sz-(24<<8),SECT))
if (cs > -1 && sndist && PN(i) != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,sx,sy,sz-(24<<8),SECT(i)))
sndist += sndist>>5;
if (PN == MUSICANDSFX && SLT < 999)
if (PN(i) == MUSICANDSFX && SLT(i) < 999)
g_numEnvSoundsPlaying++;
/*
switch (j)
@ -420,7 +420,7 @@ void S_Update(void)
break;
default:
*/
if (sndist > 31444 && PN != MUSICANDSFX)
if (sndist > 31444 && PN(i) != MUSICANDSFX)
{
S_StopSound(j);
continue;