Commit 3d610c50 authored by Steven Fuller's avatar Steven Fuller

actorat array changed from objtype * to int. (It was originally used as

both).
parent f17076b7
CC = gcc
#CFLAGS = -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
#CFLAGS = -g -Wall
#CFLAGS = -g -O2 -Wall -pedantic
#CFLAGS = -Wall -pedantic -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
CFLAGS = -g -Wall -pedantic
#CFLAGS = -Os -Wall
#CFLAGS = -Os -Wall -fomit-frame-pointer -ffast-math -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
#CFLAGS = -Os -Wall -peantic
#CFLAGS = -Os -Wall -peantic -fomit-frame-pointer -ffast-math -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
wl_act1.o wl_act2.o wl_act3.o wl_agent.o wl_game.o \
......
......@@ -126,7 +126,7 @@ void SpawnStatic(int tilex, int tiley, int type)
switch (statinfo[type].type)
{
case block:
(unsigned)actorat[tilex][tiley] = 1; // consider it a blocking tile
actorat[tilex][tiley] = 1; // consider it a blocking tile
case dressing:
laststatobj->flags = 0;
break;
......@@ -333,7 +333,7 @@ void SpawnDoor(int tilex, int tiley, boolean vertical, int lock)
lastdoorobj->lock = lock;
lastdoorobj->action = dr_closed;
(unsigned)actorat[tilex][tiley] = doornum | 0x80; // consider it a solid wall
actorat[tilex][tiley] = doornum | 0x80; // consider it a solid wall
//
// make the door tile a special tile, and mark the adjacent tiles
......@@ -384,7 +384,7 @@ void OpenDoor(int door)
void CloseDoor(int door)
{
int tilex,tiley,area;
int tilex, tiley, area;
objtype *check;
//
......@@ -401,18 +401,28 @@ void CloseDoor(int door)
if (doorobjlist[door].vertical)
{
if ( player->tiley == tiley )
if (player->tiley == tiley)
{
if ( ((player->x+MINDIST) >>TILESHIFT) == tilex )
if (((player->x+MINDIST) >>TILESHIFT) == tilex)
return;
if ( ((player->x-MINDIST) >>TILESHIFT) == tilex )
if (((player->x-MINDIST) >>TILESHIFT) == tilex)
return;
}
check = actorat[tilex-1][tiley];
if (check && ((check->x+MINDIST) >> TILESHIFT) == tilex )
if (actorat[tilex-1][tiley] & 0x8000)
check = &objlist[actorat[tilex-1][tiley] & ~0x8000];
else
check = NULL;
if (check && ((check->x+MINDIST) >> TILESHIFT) == tilex)
return;
check = actorat[tilex+1][tiley];
if (check && ((check->x-MINDIST) >> TILESHIFT) == tilex )
if (actorat[tilex+1][tiley] & 0x8000)
check = &objlist[actorat[tilex+1][tiley] & ~0x8000];
else
check = NULL;
if (check && ((check->x-MINDIST) >> TILESHIFT) == tilex)
return;
}
else if (!doorobjlist[door].vertical)
......@@ -424,10 +434,20 @@ void CloseDoor(int door)
if ( ((player->y-MINDIST) >>TILESHIFT) == tiley )
return;
}
check = actorat[tilex][tiley-1];
if (actorat[tilex][tiley-1] & 0x8000)
check = &objlist[actorat[tilex][tiley-1] & ~0x8000];
else
check = NULL;
if (check && ((check->y+MINDIST) >> TILESHIFT) == tiley )
return;
check = actorat[tilex][tiley+1];
if (actorat[tilex][tiley+1] & 0x8000)
check = &objlist[actorat[tilex][tiley+1] & ~0x8000];
else
check = NULL;
if (check && ((check->y-MINDIST) >> TILESHIFT) == tiley )
return;
}
......@@ -447,8 +467,7 @@ void CloseDoor(int door)
//
// make the door space solid
//
(unsigned)actorat[tilex][tiley]
= door | 0x80;
actorat[tilex][tiley] = door | 0x80;
}
/*
......@@ -587,10 +606,10 @@ void DoorClosing(int door)
tilex = doorobjlist[door].tilex;
tiley = doorobjlist[door].tiley;
if ( ((unsigned)actorat[tilex][tiley] != (door | 0x80))
if ((actorat[tilex][tiley] != (door | 0x80))
|| (player->tilex == tilex && player->tiley == tiley) )
{ // something got inside the door
OpenDoor (door);
OpenDoor(door);
return;
};
......@@ -698,7 +717,6 @@ void PushWall(int checkx, int checky, int dir)
if (pwallstate)
return;
oldtile = tilemap[checkx][checky];
if (!oldtile)
return;
......@@ -711,8 +729,7 @@ void PushWall(int checkx, int checky, int dir)
SD_PlaySound(NOWAYSND);
return;
}
(unsigned)actorat[checkx][checky-1] =
tilemap[checkx][checky-1] = oldtile;
actorat[checkx][checky-1] = tilemap[checkx][checky-1] = oldtile;
break;
case di_east:
......@@ -721,8 +738,7 @@ void PushWall(int checkx, int checky, int dir)
SD_PlaySound(NOWAYSND);
return;
}
(unsigned)actorat[checkx+1][checky] =
tilemap[checkx+1][checky] = oldtile;
actorat[checkx+1][checky] = tilemap[checkx+1][checky] = oldtile;
break;
case di_south:
......@@ -731,8 +747,7 @@ void PushWall(int checkx, int checky, int dir)
SD_PlaySound(NOWAYSND);
return;
}
(unsigned)actorat[checkx][checky+1] =
tilemap[checkx][checky+1] = oldtile;
actorat[checkx][checky+1] = tilemap[checkx][checky+1] = oldtile;
break;
case di_west:
......@@ -741,8 +756,7 @@ void PushWall(int checkx, int checky, int dir)
SD_PlaySound(NOWAYSND);
return;
}
(unsigned)actorat[checkx-1][checky] =
tilemap[checkx-1][checky] = oldtile;
actorat[checkx-1][checky] = tilemap[checkx-1][checky] = oldtile;
break;
}
......@@ -788,7 +802,7 @@ void MovePWalls()
// the tile can now be walked into
//
tilemap[pwallx][pwally] = 0;
(unsigned)actorat[pwallx][pwally] = 0;
actorat[pwallx][pwally] = 0;
*(mapsegs[0]+farmapylookup[pwally]+pwallx) = player->areanumber+AREATILE;
//
......@@ -813,7 +827,7 @@ void MovePWalls()
pwallstate = 0;
return;
}
(unsigned)actorat[pwallx][pwally-1] =
actorat[pwallx][pwally-1] =
tilemap[pwallx][pwally-1] = oldtile;
break;
......@@ -824,7 +838,7 @@ void MovePWalls()
pwallstate = 0;
return;
}
(unsigned)actorat[pwallx+1][pwally] =
actorat[pwallx+1][pwally] =
tilemap[pwallx+1][pwally] = oldtile;
break;
......@@ -835,7 +849,7 @@ void MovePWalls()
pwallstate = 0;
return;
}
(unsigned)actorat[pwallx][pwally+1] =
actorat[pwallx][pwally+1] =
tilemap[pwallx][pwally+1] = oldtile;
break;
......@@ -846,7 +860,7 @@ void MovePWalls()
pwallstate = 0;
return;
}
(unsigned)actorat[pwallx-1][pwally] =
actorat[pwallx-1][pwally] =
tilemap[pwallx-1][pwally] = oldtile;
break;
}
......
......@@ -180,7 +180,6 @@ void A_Smoke(objtype *ob)
boolean ProjectileTryMove(objtype *ob)
{
int xl,yl,xh,yh,x,y;
objtype *check;
xl = (ob->x-PROJSIZE) >>TILESHIFT;
yl = (ob->y-PROJSIZE) >>TILESHIFT;
......@@ -191,8 +190,7 @@ boolean ProjectileTryMove(objtype *ob)
/* check for solid walls */
for (y=yl;y<=yh;y++) {
for (x=xl;x<=xh;x++) {
check = actorat[x][y];
if (check && check < objlist)
if (actorat[x][y] && !(actorat[x][y] & 0x8000))
return false;
}
}
......@@ -437,7 +435,7 @@ void SpawnPatrol (enemy_t which, int tilex, int tiley, int dir)
new->flags |= FL_SHOOTABLE;
new->active = true;
actorat[new->tilex][new->tiley] = NULL; // don't use original spot
actorat[new->tilex][new->tiley] = 0; // don't use original spot
switch (dir)
{
......@@ -455,7 +453,7 @@ void SpawnPatrol (enemy_t which, int tilex, int tiley, int dir)
break;
}
actorat[new->tilex][new->tiley] = new;
actorat[new->tilex][new->tiley] = new->id | 0x8000;
}
......@@ -1220,22 +1218,22 @@ moveok:
yl = (ob->y-MINDIST) >> TILESHIFT;
yh = (ob->y+MINDIST) >> TILESHIFT;
for (y=yl ; y<=yh ; y++)
for (x=xl ; x<=xh ; x++)
for (y = yl; y <= yh; y++)
for (x = xl; x <= xh; x++)
{
tile = (unsigned)actorat[x][y];
tile = actorat[x][y];
if (!tile)
continue;
if (tile<256)
if (tile < 256)
return;
if (((objtype *)tile)->flags&FL_SHOOTABLE)
if (objlist[tile & ~0x8000].flags & FL_SHOOTABLE)
return;
}
ob->flags |= FL_AMBUSH | FL_SHOOTABLE;
ob->flags &= ~FL_ATTACKMODE;
ob->dir = nodir;
NewState (ob,s_spectrewait1);
NewState(ob, s_spectrewait1);
}
......@@ -2395,10 +2393,9 @@ void T_BJDone(objtype *ob)
===============
*/
boolean CheckPosition (objtype *ob)
boolean CheckPosition(objtype *ob)
{
int x,y,xl,yl,xh,yh;
objtype *check;
int x, y, xl, yl, xh, yh;
xl = (ob->x-PLAYERSIZE) >>TILESHIFT;
yl = (ob->y-PLAYERSIZE) >>TILESHIFT;
......@@ -2412,8 +2409,7 @@ boolean CheckPosition (objtype *ob)
for (y=yl;y<=yh;y++)
for (x=xl;x<=xh;x++)
{
check = actorat[x][y];
if (check && check<objlist)
if (actorat[x][y] && !(actorat[x][y] & 0x8000))
return false;
}
......
......@@ -25,10 +25,10 @@
//
long thrustspeed;
unsigned plux,pluy; // player coordinates scaled to unsigned
unsigned plux, pluy; // player coordinates scaled to unsigned
int anglefrac;
int gotgatgun; // JR
int gotgatgun;
objtype *LastAttacker;
......@@ -52,9 +52,9 @@ struct atkinf
{ {6,0,1},{6,1,2},{6,4,3},{6,-1,4} },
};
void DrawWeapon (void);
void GiveWeapon (int weapon);
void GiveAmmo (int ammo);
void DrawWeapon();
void GiveWeapon(int weapon);
void GiveAmmo(int ammo);
/*
=============================================================================
......@@ -81,11 +81,11 @@ void CheckWeaponChange()
if (!gamestate.ammo) // must use knife with no ammo
return;
for (i=wp_knife ; i<=gamestate.bestweapon ; i++)
for (i = wp_knife; i <= gamestate.bestweapon; i++)
if (buttonstate[bt_readyknife+i-wp_knife])
{
gamestate.weapon = gamestate.chosenweapon = i;
DrawWeapon ();
DrawWeapon();
return;
}
}
......@@ -742,8 +742,7 @@ boolean TryMove(objtype *ob)
for (y=yl;y<=yh;y++)
for (x=xl;x<=xh;x++)
{
check = actorat[x][y];
if (check && check<objlist)
if (actorat[x][y] && !(actorat[x][y] & 0x8000))
return false;
}
......@@ -762,9 +761,10 @@ boolean TryMove(objtype *ob)
for (y=yl;y<=yh;y++)
for (x=xl;x<=xh;x++)
{
check = actorat[x][y];
if (check > objlist
&& (check->flags & FL_SHOOTABLE) )
if (actorat[x][y] & 0x8000) {
check = &objlist[actorat[x][y] & ~0x8000];
if (check->flags & FL_SHOOTABLE)
{
deltax = ob->x - check->x;
if (deltax < -MINACTORDIST || deltax > MINACTORDIST)
......@@ -776,6 +776,7 @@ boolean TryMove(objtype *ob)
return false;
}
}
}
return true;
}
......@@ -798,7 +799,7 @@ void ClipMove(objtype *ob, long xmove, long ymove)
ob->x = basex+xmove;
ob->y = basey+ymove;
if (TryMove (ob))
if (TryMove(ob))
return;
if (noclip && ob->x > 2*TILEGLOBAL && ob->y > 2*TILEGLOBAL &&
......@@ -811,12 +812,12 @@ void ClipMove(objtype *ob, long xmove, long ymove)
ob->x = basex+xmove;
ob->y = basey;
if (TryMove (ob))
if (TryMove(ob))
return;
ob->x = basex;
ob->y = basey+ymove;
if (TryMove (ob))
if (TryMove(ob))
return;
ob->x = basex;
......
......@@ -768,7 +768,7 @@ extern unsigned farmapylookup[MAPSIZE];
extern byte tilemap[MAPSIZE][MAPSIZE]; // wall values only
extern byte spotvis[MAPSIZE][MAPSIZE];
extern objtype *actorat[MAPSIZE][MAPSIZE];
extern int actorat[MAPSIZE][MAPSIZE];
extern boolean singlestep,godmode,noclip;
......
......@@ -493,10 +493,10 @@ void SetupGameLevel()
tile = *map++;
if (tile < AREATILE) { /* solid wall */
tilemap[x][y] = tile;
(unsigned)actorat[x][y] = tile;
actorat[x][y] = tile;
} else { /* area floor */
tilemap[x][y] = 0;
actorat[x][y] = NULL;
actorat[x][y] = 0;
}
}
......@@ -553,8 +553,8 @@ void SetupGameLevel()
if (tile == AMBUSHTILE)
{
tilemap[x][y] = 0;
if ((unsigned)actorat[x][y] == AMBUSHTILE)
actorat[x][y] = NULL;
if (actorat[x][y] == AMBUSHTILE)
actorat[x][y] = 0;
if (*map >= AREATILE)
tile = *map;
......
......@@ -23,7 +23,7 @@ boolean singlestep,godmode,noclip;
byte tilemap[MAPSIZE][MAPSIZE]; // wall values only
byte spotvis[MAPSIZE][MAPSIZE];
objtype *actorat[MAPSIZE][MAPSIZE];
int actorat[MAPSIZE][MAPSIZE];
int tics;
......@@ -778,12 +778,17 @@ void InitActorList()
void GetNewActor()
{
int id;
if (!objfreelist)
Quit("GetNewActor: No free spots in objlist!");
new = objfreelist;
id = new->id;
objfreelist = new->prev;
memset(new, 0, sizeof(*new));
new->id = id;
if (lastobj)
lastobj->next = new;
......@@ -817,7 +822,7 @@ static void RemoveObj(objtype *gone)
// fix the next object's back link
//
if (gone == lastobj)
lastobj = (objtype *)gone->prev;
lastobj = gone->prev;
else
gone->next->prev = gone->prev;
......@@ -1113,7 +1118,7 @@ void DoActor(objtype *ob)
if ((ob->flags&FL_NONMARK) && actorat[ob->tilex][ob->tiley])
return;
actorat[ob->tilex][ob->tiley] = ob;
actorat[ob->tilex][ob->tiley] = ob->id | 0x8000;
return;
}
......@@ -1172,7 +1177,7 @@ think:
if ((ob->flags&FL_NONMARK) && actorat[ob->tilex][ob->tiley])
return;
actorat[ob->tilex][ob->tiley] = ob;
actorat[ob->tilex][ob->tiley] = ob->id | 0x8000;
}
//==========================================================================
......
......@@ -58,7 +58,7 @@ void SpawnNewObj(unsigned tilex, unsigned tiley, int state) /* stateenum */
new->y = ((long)tiley<<TILESHIFT)+TILEGLOBAL/2;
new->dir = nodir;
actorat[tilex][tiley] = new;
actorat[tilex][tiley] = new->id | 0x8000;
new->areanumber =
*(mapsegs[0] + farmapylookup[new->tiley]+new->tilex) - AREATILE;
}
......@@ -114,26 +114,26 @@ void NewState(objtype *ob, int state) /* stateenum */
#define CHECKDIAG(x,y) \
{ \
temp=(unsigned)actorat[x][y]; \
temp = actorat[x][y]; \
if (temp) \
{ \
if (temp<256) \
if (temp < 256) \
return false; \
if (((objtype *)temp)->flags&FL_SHOOTABLE) \
if (objlist[temp & ~0x8000].flags & FL_SHOOTABLE) \
return false; \
} \
}
#define CHECKSIDE(x,y) \
{ \
temp=(unsigned)actorat[x][y]; \
temp = actorat[x][y]; \
if (temp) \
{ \
if (temp<128) \
if (temp < 128) \
return false; \
if (temp<256) \
if (temp < 256) \
doornum = temp&63; \
else if (((objtype *)temp)->flags&FL_SHOOTABLE)\
else if (objlist[temp & ~0x8000].flags & FL_SHOOTABLE) \
return false; \
} \
}
......@@ -863,7 +863,7 @@ void KillActor (objtype *ob)
gamestate.killcount++;
ob->flags &= ~FL_SHOOTABLE;
actorat[ob->tilex][ob->tiley] = NULL;
actorat[ob->tilex][ob->tiley] = 0;
ob->flags |= FL_NONMARK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment