mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 14:41:55 +00:00
- took automap code out of Exhumed's game module and added handling for cleaning movement in automap follow mode.
I cannot say I was surprised when discovering that this game had no handling for that at all...
This commit is contained in:
parent
d947cc4765
commit
df6d480519
3 changed files with 16 additions and 404 deletions
|
@ -106,7 +106,6 @@ extern short nPalDiff;
|
|||
|
||||
extern short bShowTowers;
|
||||
extern int ldMapZoom;
|
||||
extern int lMapZoom;
|
||||
|
||||
void InitMap();
|
||||
void GrabMap();
|
||||
|
|
|
@ -91,8 +91,6 @@ void SendInput()
|
|||
|
||||
void CheckKeys2()
|
||||
{
|
||||
lMapZoom = GetAutomapZoom(lMapZoom);
|
||||
|
||||
if (PlayerList[nLocalPlayer].nHealth <= 0)
|
||||
{
|
||||
SetAirFrame();
|
||||
|
@ -222,10 +220,19 @@ void PlayerInterruptKeys(bool after)
|
|||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
tempinput.fvel += -keyMove;
|
||||
|
||||
localInput.fvel = clamp(localInput.fvel + tempinput.fvel, -12, 12);
|
||||
localInput.svel = clamp(localInput.svel + tempinput.svel, -12, 12);
|
||||
|
||||
localInput.q16avel += input_angle;
|
||||
if ((automapFollow && automapMode != am_off))
|
||||
{
|
||||
// neutralize all movement when in automap follow mode
|
||||
localInput.fvel = localInput.svel = 0;
|
||||
localInput.q16avel = localInput.q16horz = 0;
|
||||
input_angle = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
localInput.fvel = clamp(localInput.fvel + tempinput.fvel, -12, 12);
|
||||
localInput.svel = clamp(localInput.svel + tempinput.svel, -12, 12);
|
||||
localInput.q16avel += input_angle;
|
||||
}
|
||||
|
||||
if (!nFreeze)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,6 @@ BEGIN_PS_NS
|
|||
|
||||
short bShowTowers = false;
|
||||
int ldMapZoom;
|
||||
int lMapZoom;
|
||||
|
||||
void MarkSectorSeen(short nSector);
|
||||
|
||||
|
@ -40,7 +39,6 @@ void InitMap()
|
|||
memset(show2dsprite, 0, sizeof(show2dsprite));
|
||||
|
||||
ldMapZoom = 64;
|
||||
lMapZoom = 1000;
|
||||
}
|
||||
|
||||
void GrabMap()
|
||||
|
@ -68,393 +66,6 @@ void MarkSectorSeen(short nSector)
|
|||
}
|
||||
}
|
||||
|
||||
void drawoverheadmap(int cposx, int cposy, int czoom, short cang)
|
||||
{
|
||||
#ifndef __WATCOMC__ // FIXME - Won't compile on Watcom
|
||||
int xvect = sintable[(2048 - cang) & 2047] * czoom;
|
||||
int yvect = sintable[(1536 - cang) & 2047] * czoom;
|
||||
int xvect2 = mulscale(xvect, yxaspect, 16);
|
||||
int yvect2 = mulscale(yvect, yxaspect, 16);
|
||||
|
||||
// draw player position arrow
|
||||
renderDrawLine(xdim << 11, (ydim << 11) - 20480, xdim << 11, (ydim << 11) + 20480, 24);
|
||||
renderDrawLine((xdim << 11) - 20480, ydim << 11, xdim << 11, (ydim << 11) - 20480, 24);
|
||||
renderDrawLine((xdim << 11) + 20480, ydim << 11, xdim << 11, (ydim << 11) - 20480, 24);
|
||||
|
||||
short nPlayerSprite = PlayerList[nLocalPlayer].nSprite;
|
||||
|
||||
int nPlayerZ = sprite[nPlayerSprite].z;
|
||||
|
||||
for (int nSector = 0; nSector < numsectors; nSector++)
|
||||
{
|
||||
short startwall = sector[nSector].wallptr;
|
||||
short nWalls = sector[nSector].wallnum;
|
||||
short endwall = startwall + nWalls - 1;
|
||||
|
||||
int nCeilZ = sector[nSector].ceilingz;
|
||||
int nFloorZ = sector[nSector].floorz;
|
||||
|
||||
int nZVal = nFloorZ - nPlayerZ;
|
||||
if (nZVal < 0) {
|
||||
nZVal = -nZVal;
|
||||
}
|
||||
|
||||
int var_10 = nZVal >> 13;
|
||||
if (var_10 > 12) {
|
||||
var_10 = 12;
|
||||
}
|
||||
|
||||
var_10 = 111 - var_10;
|
||||
|
||||
// int startwallB = startwall;
|
||||
|
||||
for (int nWall = startwall; nWall <= endwall; nWall++)
|
||||
{
|
||||
short nextwall = wall[nWall].nextwall;
|
||||
|
||||
if (nextwall >= 0)
|
||||
{
|
||||
if (show2dwall[nWall >> 3] & (1 << (nWall & 7)))
|
||||
{
|
||||
if (nextwall <= nWall || (show2dwall[nextwall >> 3] & (1 << (nextwall & 7))) <= 0)
|
||||
{
|
||||
if (nCeilZ != sector[wall[nWall].nextsector].ceilingz ||
|
||||
nFloorZ != sector[wall[nWall].nextsector].floorz ||
|
||||
((wall[nextwall].cstat | wall[nWall].cstat) & 0x30))
|
||||
{
|
||||
int ox = wall[nWall].x - cposx;
|
||||
int oy = wall[nWall].y - cposy;
|
||||
|
||||
int x1 = mulscale(ox, xvect, 16) - mulscale(oy, yvect, 16);
|
||||
int y1 = mulscale(oy, xvect2, 16) + mulscale(ox, yvect2, 16);
|
||||
|
||||
int nWall2 = wall[nWall].point2;
|
||||
ox = wall[nWall2].x - cposx;
|
||||
oy = wall[nWall2].y - cposy;
|
||||
int x2 = mulscale(ox, xvect, 16) - mulscale(oy, yvect, 16);
|
||||
int y2 = mulscale(oy, xvect2, 16) + mulscale(ox, yvect2, 16);
|
||||
|
||||
renderDrawLine(x1 + (xdim << 11), y1 + (ydim << 11), x2 + (xdim << 11), y2 + (ydim << 11), var_10);
|
||||
|
||||
/*
|
||||
drawline256(
|
||||
((unsigned __int64)(v4 * (signed __int64)v12) >> 16)
|
||||
- ((unsigned __int64)(v5 * (signed __int64)v13) >> 16)
|
||||
+ (xdim << 11),
|
||||
((unsigned __int64)(v42 * (signed __int64)v12) >> 16)
|
||||
+ ((unsigned __int64)(v43 * (signed __int64)v13) >> 16)
|
||||
+ (ydim << 11),
|
||||
(build_xdim << 11)
|
||||
+ ((unsigned __int64)(v4 * (signed __int64)(*v14 - v31)) >> 16)
|
||||
- ((unsigned __int64)(v5 * (signed __int64)(v14[1] - v30)) >> 16),
|
||||
ydim << 11)
|
||||
+ ((unsigned __int64)(v43 * (signed __int64)(v14[1] - v30)) >> 16)
|
||||
+ ((unsigned __int64)(v42 * (signed __int64)(*v14 - v31)) >> 16),
|
||||
v48);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// int var_4C = 0;
|
||||
// int var_48 = 0;
|
||||
|
||||
for (int nSector = 0; nSector < numsectors; nSector++)
|
||||
{
|
||||
int startwall = sector[nSector].wallptr;
|
||||
int nWalls = sector[nSector].wallnum;
|
||||
int endwall = startwall + nWalls - 1;
|
||||
|
||||
int nFloorZ = sector[nSector].floorz;
|
||||
|
||||
int nVal = nFloorZ - nPlayerZ;
|
||||
if (nVal < 0) {
|
||||
nVal = -nVal;
|
||||
}
|
||||
|
||||
int var_14 = nVal >> 13;
|
||||
|
||||
if (var_14 <= 15)
|
||||
{
|
||||
var_14 = 111 - var_14;
|
||||
|
||||
for (int nWall = startwall; nWall <= endwall; nWall++)
|
||||
{
|
||||
if (wall[nWall].nextwall < 0)
|
||||
{
|
||||
if (show2dwall[nWall >> 3] & (1 << (nWall & 7)))
|
||||
{
|
||||
if (tilesiz[wall[nWall].picnum].x && tilesiz[wall[nWall].picnum].y)
|
||||
{
|
||||
int ox = wall[nWall].x - cposx;
|
||||
int oy = wall[nWall].y - cposy;
|
||||
int x1 = mulscale(ox, xvect, 16) - mulscale(oy, yvect, 16);
|
||||
int y1 = mulscale(oy, xvect2, 16) + mulscale(ox, yvect2, 16);
|
||||
|
||||
int nWall2 = wall[nWall].point2;
|
||||
ox = wall[nWall2].x - cposx;
|
||||
oy = wall[nWall2].y - cposy;
|
||||
int x2 = mulscale(ox, xvect, 16) - mulscale(oy, yvect, 16);
|
||||
int y2 = mulscale(oy, xvect2, 16) + mulscale(ox, yvect2, 16);
|
||||
|
||||
renderDrawLine(x1 + (xdim << 11), y1 + (ydim << 11), x2 + (xdim << 11), y2 + (ydim << 11), 24);
|
||||
|
||||
/*
|
||||
|
||||
v19 = *v17 - v31;
|
||||
v20 = v17[1] - v30;
|
||||
v21 = &wall[8 * *((_WORD *)v17 + 4)];
|
||||
|
||||
build_drawline256(
|
||||
(build_xdim << 11)
|
||||
+ ((unsigned __int64)(v4 * (signed __int64)v19) >> 16)
|
||||
- ((unsigned __int64)(v5 * (signed __int64)v20) >> 16),
|
||||
(build_ydim << 11)
|
||||
+ ((unsigned __int64)(v42 * (signed __int64)v19) >> 16)
|
||||
+ ((unsigned __int64)(v43 * (signed __int64)v20) >> 16),
|
||||
(build_xdim << 11)
|
||||
+ ((unsigned __int64)(v4 * (signed __int64)(*v21 - v31)) >> 16)
|
||||
- ((unsigned __int64)(v5 * (signed __int64)(v21[1] - v30)) >> 16),
|
||||
(build_ydim << 11)
|
||||
+ ((unsigned __int64)(v42 * (signed __int64)(*v21 - v31)) >> 16)
|
||||
+ ((unsigned __int64)(v43 * (signed __int64)(v21[1] - v30)) >> 16),
|
||||
v46);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bShowTowers)
|
||||
{
|
||||
for (int nSprite = headspritestat[406]; nSprite != -1; nSprite = nextspritestat[nSprite])
|
||||
{
|
||||
int ox = sprite[nSprite].x - cposx; // var_64
|
||||
int oy = sprite[nSprite].y - cposx; // var_68
|
||||
|
||||
// int var_58 = mulscale(var_64, xvect, 16) - mulscale(var_68, yvect, 16);
|
||||
int x1 = mulscale(ox, xvect, 16) - mulscale(oy, yvect, 16);
|
||||
int y1 = mulscale(oy, xvect2, 16) + mulscale(ox, yvect2, 16);
|
||||
|
||||
//int var_58 = mulscale(var_64, xvect, 16) - mulscale(var_68, yvect, 16);
|
||||
//int esi = mulscale(var_68, xvect2, 16) + mulscale(var_65, yvect2, 16)
|
||||
|
||||
//v25 = ((unsigned __int64)(v4 * (signed __int64)ox) >> 16)
|
||||
// - ((unsigned __int64)(v5 * (signed __int64)oy) >> 16);
|
||||
|
||||
//v26 = ((unsigned __int64)(v42 * (signed __int64)ox) >> 16)
|
||||
// + ((unsigned __int64)(v43 * (signed __int64)oy) >> 16);
|
||||
|
||||
//v27 = v26 + 2048;
|
||||
//v28 = v26 + 2048 + (ydim << 11);
|
||||
//v26 -= 2048;
|
||||
|
||||
// v25 is x1
|
||||
// v26 is y1
|
||||
// v27 is y1 + 2048
|
||||
// v28 is y1 + 2048 + (ydim << 1);
|
||||
|
||||
renderDrawLine(
|
||||
x1 - 2048 + (xdim << 11),
|
||||
y1 - 2048 + (ydim << 11),
|
||||
x1 - 2048 + (xdim << 11),
|
||||
y1 + 2048 + (ydim << 1),
|
||||
170);
|
||||
|
||||
renderDrawLine(
|
||||
x1 + (xdim << 11),
|
||||
y1 + (ydim << 11),
|
||||
x1 + (xdim << 11),
|
||||
y1 + 2048 + (ydim << 11),
|
||||
170);
|
||||
|
||||
renderDrawLine(
|
||||
x1 + 2048 + (xdim << 11),
|
||||
y1 + (ydim << 11),
|
||||
x1 + 2048 + (xdim << 11),
|
||||
y1 + 2048 + (ydim << 11),
|
||||
170);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4101) // this function produces a little bit too much noise
|
||||
#endif
|
||||
|
||||
static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16_t cang)
|
||||
{
|
||||
int32_t i, j, k, x1, y1, x2=0, y2=0, ox, oy;
|
||||
int32_t z1, z2, startwall, endwall;
|
||||
int32_t xvect, yvect, xvect2, yvect2;
|
||||
char col;
|
||||
uwallptr_t wal, wal2;
|
||||
|
||||
int32_t tmpydim = (xdim*5)/8;
|
||||
|
||||
renderSetAspect(65536, divscale16(tmpydim*320, xdim*200));
|
||||
|
||||
xvect = sintable[(-cang)&2047] * czoom;
|
||||
yvect = sintable[(1536-cang)&2047] * czoom;
|
||||
xvect2 = mulscale16(xvect, yxaspect);
|
||||
yvect2 = mulscale16(yvect, yxaspect);
|
||||
|
||||
//renderDisableFog();
|
||||
|
||||
// draw player position arrow
|
||||
renderDrawLine(xdim << 11, (ydim << 11) - 20480, xdim << 11, (ydim << 11) + 20480, 24);
|
||||
renderDrawLine((xdim << 11) - 20480, ydim << 11, xdim << 11, (ydim << 11) - 20480, 24);
|
||||
renderDrawLine((xdim << 11) + 20480, ydim << 11, xdim << 11, (ydim << 11) - 20480, 24);
|
||||
|
||||
short nPlayerSprite = PlayerList[nLocalPlayer].nSprite;
|
||||
|
||||
int nPlayerZ = sprite[nPlayerSprite].z;
|
||||
|
||||
//Draw red lines
|
||||
for (i=numsectors-1; i>=0; i--)
|
||||
{
|
||||
if (!gFullMap && !show2dsector[i]) continue;
|
||||
|
||||
startwall = sector[i].wallptr;
|
||||
endwall = sector[i].wallptr + sector[i].wallnum;
|
||||
|
||||
z1 = sector[i].ceilingz;
|
||||
z2 = sector[i].floorz;
|
||||
|
||||
for (j=startwall, wal=(uwallptr_t)&wall[startwall]; j<endwall; j++, wal++)
|
||||
{
|
||||
k = wal->nextwall;
|
||||
if (k < 0) continue;
|
||||
|
||||
if (sector[wal->nextsector].ceilingz == z1 && sector[wal->nextsector].floorz == z2)
|
||||
if (((wal->cstat|wall[wal->nextwall].cstat)&(16+32)) == 0) continue;
|
||||
|
||||
if (automapMode == am_full)
|
||||
col = 111;
|
||||
else
|
||||
col = 111 - min(klabs(z2 - nPlayerZ) >> 13, 12);
|
||||
|
||||
ox = wal->x-cposx;
|
||||
oy = wal->y-cposy;
|
||||
x1 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11);
|
||||
y1 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11);
|
||||
|
||||
wal2 = (uwallptr_t)&wall[wal->point2];
|
||||
ox = wal2->x-cposx;
|
||||
oy = wal2->y-cposy;
|
||||
x2 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11);
|
||||
y2 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11);
|
||||
|
||||
renderDrawLine(x1, y1, x2, y2, col);
|
||||
}
|
||||
}
|
||||
|
||||
//Draw white lines
|
||||
for (i=numsectors-1; i>=0; i--)
|
||||
{
|
||||
if (!gFullMap && !show2dsector[i]) continue;
|
||||
|
||||
startwall = sector[i].wallptr;
|
||||
endwall = sector[i].wallptr + sector[i].wallnum;
|
||||
z2 = sector[i].floorz;
|
||||
|
||||
if (automapMode == am_full)
|
||||
{
|
||||
col = 111;
|
||||
}
|
||||
else
|
||||
{
|
||||
col = klabs(z2 - nPlayerZ) >> 13;
|
||||
if (col > 15)
|
||||
continue;
|
||||
col = 111 - col;
|
||||
}
|
||||
|
||||
k = -1;
|
||||
for (j=startwall, wal=(uwallptr_t)&wall[startwall]; j<endwall; j++, wal++)
|
||||
{
|
||||
if (wal->nextwall >= 0) continue;
|
||||
|
||||
if (!tileGetTexture(wal->picnum)->isValid()) continue;
|
||||
|
||||
if (j == k)
|
||||
{
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
ox = wal->x-cposx;
|
||||
oy = wal->y-cposy;
|
||||
x1 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11);
|
||||
y1 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11);
|
||||
}
|
||||
|
||||
k = wal->point2;
|
||||
wal2 = (uwallptr_t)&wall[k];
|
||||
ox = wal2->x-cposx;
|
||||
oy = wal2->y-cposy;
|
||||
x2 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11);
|
||||
y2 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11);
|
||||
|
||||
renderDrawLine(x1, y1, x2, y2, col);
|
||||
}
|
||||
}
|
||||
|
||||
//renderEnableFog();
|
||||
|
||||
videoSetCorrectedAspect();
|
||||
|
||||
#if 0
|
||||
for (TRAVERSE_CONNECT(p))
|
||||
{
|
||||
if (automapFollow && p == screenpeek) continue;
|
||||
|
||||
auto const pPlayer = &ps[p];
|
||||
auto const pSprite = (uspriteptr_t)&sprite[pPlayer->i];
|
||||
|
||||
ox = pSprite->x - cposx;
|
||||
oy = pSprite->y - cposy;
|
||||
daang = (pSprite->ang - cang) & 2047;
|
||||
if (p == screenpeek)
|
||||
{
|
||||
ox = 0;
|
||||
oy = 0;
|
||||
daang = 0;
|
||||
}
|
||||
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
||||
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
||||
|
||||
if (p == screenpeek || GTFLAGS(GAMETYPE_OTHERPLAYERSINMAP))
|
||||
{
|
||||
if (pSprite->xvel > 16 && pPlayer->on_ground)
|
||||
i = APLAYERTOP+(((int32_t) leveltime>>4)&3);
|
||||
else
|
||||
i = APLAYERTOP;
|
||||
|
||||
i = VM_OnEventWithReturn(EVENT_DISPLAYOVERHEADMAPPLAYER, pPlayer->i, p, i);
|
||||
|
||||
if (i < 0)
|
||||
continue;
|
||||
|
||||
j = klabs(pPlayer->truefz - pPlayer->pos.z) >> 8;
|
||||
j = mulscale16(czoom * (pSprite->yrepeat + j), yxaspect);
|
||||
|
||||
if (j < 22000) j = 22000;
|
||||
else if (j > (65536<<1)) j = (65536<<1);
|
||||
|
||||
rotatesprite_win((x1<<4)+(xdim<<15), (y1<<4)+(ydim<<15), j, daang, i, pSprite->shade,
|
||||
P_GetOverheadPal(pPlayer), 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UpdateMap()
|
||||
{
|
||||
|
@ -465,14 +76,9 @@ void UpdateMap()
|
|||
|
||||
void DrawMap()
|
||||
{
|
||||
if (!nFreeze && automapMode != am_off) {
|
||||
//drawoverheadmap(initx, inity, lMapZoom, inita);
|
||||
if (automapMode == am_full)
|
||||
{
|
||||
twod->ClearScreen();
|
||||
renderDrawMapView(initx, inity, lMapZoom, inita);
|
||||
}
|
||||
G_DrawOverheadMap(initx, inity, lMapZoom, inita);
|
||||
if (!nFreeze && automapMode != am_off)
|
||||
{
|
||||
DrawOverheadMap(initx, inity, inita);
|
||||
}
|
||||
}
|
||||
END_PS_NS
|
||||
|
|
Loading…
Reference in a new issue