Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heretic: Map Marker #1287

Merged
merged 22 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
44acf12
Heretic: Enable Mapmarkers
Noseey Mar 20, 2025
94a0d9b
Heretic: Add extsaveg storing mapmarkers.
Noseey Mar 22, 2025
91ccf4a
Heretic: Remove commented out savemaplumpinfo
Noseey Mar 22, 2025
04e7e12
Heretic: Draw map marks before player
Noseey Mar 22, 2025
4bfb67e
Heretic: Enable map marker totation
Noseey Mar 23, 2025
613b800
Heretic: Whitespace fixes
Noseey Mar 23, 2025
5d403d4
Heretic: Copy logic for addMark function from Doom.
Noseey Mar 23, 2025
6dbd1e5
Heretic: Use M_snprintf consistently.
Noseey Mar 23, 2025
07e9c32
Heretic: Enable Automap crosshair
Noseey Mar 23, 2025
73489bd
Heretic: Don't clear marks when reinit
Noseey Mar 23, 2025
289e27c
Heretic: Comment out first pass of P_ReadExtendedSaveGameData
Noseey Mar 23, 2025
c984450
Heretic: Close DoLoadGame stream.
Noseey Mar 23, 2025
da1b6e3
Merge branch 'fabiangreffrath:master' into Heretic_MapMarkers
Noseey Mar 23, 2025
994fcdc
Heretic: am_map.c add newline at EOF
Noseey Mar 24, 2025
a4ca757
Heretic: Rework P_ReadExtendedSaveGameData to only use second pass
Noseey Mar 24, 2025
61a16c3
Heretic: remove fclose from DoLoadGame
Noseey Mar 24, 2025
790dd7d
Merge branch 'fabiangreffrath:master' into Heretic_MapMarkers
Noseey Mar 26, 2025
f2d8afb
Merge branch 'master' into Heretic_MapMarkers
Noseey Mar 26, 2025
2460375
Heretic: Remove unwanted duplication of SV_WriteSaveGameEOF
Noseey Mar 26, 2025
e027a2d
Heretic: update AM pseudo frame-buffer on AM_LevelInit
Noseey Mar 28, 2025
e557de8
Heretic: Whitespaces Fixes
Noseey Mar 29, 2025
47e2ada
Heretic: remove unused and commented out variables in extsaveg
Noseey Mar 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/heretic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ add_library(heretic STATIC
p_doors.c
p_enemy.c
p_extnodes.c p_extnodes.h
p_extsaveg.c p_extsaveg.h
p_floor.c
p_inter.c
p_lights.c
Expand Down
1 change: 1 addition & 0 deletions src/heretic/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ p_mobj.c \
p_plats.c \
p_pspr.c \
p_saveg.c \
p_extsaveg.c p_extsaveg.h \
p_setup.c \
p_sight.c \
p_spec.c p_spec.h \
Expand Down
198 changes: 146 additions & 52 deletions src/heretic/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "doomkeys.h"
#include "v_video.h"
#include "m_misc.h" // [crispy]

vertex_t KeyPoints[NUM_KEY_TYPES];

Expand Down Expand Up @@ -142,9 +143,10 @@ static int m_zoomin_mouse;
static int m_zoomout_mouse;
static boolean mousewheelzoom;

//static patch_t *marknums[10]; // numbers used for marking by the automap
//static mpoint_t markpoints[AM_NUMMARKPOINTS]; // where the points are
//static int markpointnum = 0; // next point to be assigned
// [crispy] restore mapmarker functionality
static patch_t *marknums[10]; // numbers used for marking by the automap
static mpoint_t markpoints[AM_NUMMARKPOINTS]; // where the points are
static int markpointnum = 0; // next point to be assigned

static int followplayer = 1; // specifies whether to follow the player around

Expand Down Expand Up @@ -185,6 +187,7 @@ static short next_mapxstart, next_mapystart; // [crispy] for interpolation
// [crispy] automap rotate
void AM_rotate(fixed_t* x, fixed_t* y, angle_t a);
static void AM_rotatePoint(mpoint_t *pt);
static void AM_drawCrosshair(int color, boolean force); // [crispy] restore crosshair
static mpoint_t mapcenter;
static angle_t mapangle;

Expand Down Expand Up @@ -264,15 +267,24 @@ void AM_restoreScaleAndLoc(void)

// adds a marker at the current location

/*
// [crispy] restore mapmarker functionality
void AM_addMark(void)
{
markpoints[markpointnum].x = m_x + m_w/2;
markpoints[markpointnum].y = m_y + m_h/2;
markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS;

// [crispy] keep the map static in overlay mode
// if not following the player
if (!(!followplayer && crispy->automapoverlay))
{
markpoints[markpointnum].x = m_x + m_w/2;
markpoints[markpointnum].y = m_y + m_h/2;
}
else
{
markpoints[markpointnum].x = plr->mo->x >> FRACTOMAPBITS;
markpoints[markpointnum].y = plr->mo->y >> FRACTOMAPBITS;
}
markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS;
}
*/

void AM_findMinMaxBoundaries(void)
{
int i;
Expand Down Expand Up @@ -504,33 +516,42 @@ void AM_initVariables(void)
//c ST_Responder(&st_notify);
}

// [crispy] restore mapmarker functionality
void AM_loadPics(void)
{
//int i;
//char namebuf[9];
/* for (i=0;i<10;i++)
{
M_snprintf(namebuf, sizeof(namebuf), "AMMNUM%d", i);
marknums[i] = W_CacheLumpName(namebuf, PU_STATIC);
}*/
int i;
char namebuf[9];
for (i=0;i<10;i++)
{
M_snprintf(namebuf, sizeof(namebuf), "SMALLIN%d", i);
marknums[i] = W_CacheLumpName(namebuf, PU_STATIC);
}
maplump = W_CacheLumpName(DEH_String("AUTOPAGE"), PU_STATIC);
}

/*void AM_unloadPics(void)
// [crispy] restore mapmarker functionality
void AM_unloadPics(void)
{
int i;
for (i=0;i<10;i++) Z_ChangeTag(marknums[i], PU_CACHE);

}*/
int i;
char namebuf[9];

for (i=0;i<10;i++)
{
M_snprintf(namebuf, 9, "SMALLIN%d", i);
W_ReleaseLumpName(namebuf);
}
}

/*
// [crispy] restore mapmarker functionality
void AM_clearMarks(void)
{
int i;
for (i=0;i<AM_NUMMARKPOINTS;i++) markpoints[i].x = -1; // means empty
markpointnum = 0;
int i;

for (i=0;i<AM_NUMMARKPOINTS;i++)
markpoints[i].x = -1; // means empty
markpointnum = 0;
}
*/


// should be called at the start of every level
// right now, i figure it out myself
Expand All @@ -546,16 +567,19 @@ void AM_LevelInit(boolean reinit)
f_w = finit_width;
f_h = finit_height;
next_mapxstart = next_mapystart = mapxstart = mapystart = 0;
fb = I_VideoBuffer; // [crispy] to consider highres toggle


// AM_clearMarks();
// [crispy] restore mapmarker functionality
if (!reinit)
AM_clearMarks();

AM_findMinMaxBoundaries();

// [crispy] preserve map scale when re-initializing
if (reinit && f_h_old)
{
scale_mtof = scale_mtof * f_h / f_h_old;
AM_drawCrosshair(XHAIRCOLORS, true);
}
else
{
Expand All @@ -578,17 +602,17 @@ void AM_Stop(void)
{
//static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED };

// AM_unloadPics();
AM_unloadPics(); // [crispy] restore mapmarker functionality
automapactive = false;
// ST_Responder(&st_notify);
stopped = true;
BorderNeedRefresh = true;
}

// [crispy] moved here for extended savegames
static int lastlevel = -1, lastepisode = -1;
void AM_Start(void)
{
static int lastlevel = -1, lastepisode = -1;

if (!stopped)
AM_Stop();
stopped = false;
Expand Down Expand Up @@ -630,6 +654,7 @@ boolean AM_Responder(event_t * ev)
int key;
static int bigstate = 0;
static int joywait = 0;
static char buffer[20]; // [crispy] to store mapmarkers
extern boolean speedkeydown (void);

// [crispy] toggleable pan/zoom speed
Expand Down Expand Up @@ -801,20 +826,19 @@ boolean AM_Responder(event_t * ev)
grid ? AMSTR_GRIDON : AMSTR_GRIDOFF,
true);
}
/*
// [crispy] restore mapmarker functionality
else if (key == key_map_mark)
{
M_snprintf(buffer, sizeof(buffer), "%s %d",
AMSTR_MARKEDSPOT, markpointnum);
plr->message = buffer;
P_SetMessage(plr, buffer, true);
AM_addMark();
}
else if (key == key_map_clearmark)
{
AM_clearMarks();
plr->message = AMSTR_MARKSCLEARED;
P_SetMessage(plr, AMSTR_MARKSCLEARED, true);
}
*/
else if (key == key_map_overlay)
{
// [crispy] force redraw status bar
Expand Down Expand Up @@ -1866,25 +1890,34 @@ void AM_drawThings(int colors, int colorrange)
}
}

/*
// [crispy] restore mapmarker functionality
void AM_drawMarks(void)
{
int i, fx, fy, w, h;
int i, fx, fy, w, h;
mpoint_t pt;

for (i=0;i<AM_NUMMARKPOINTS;i++)
{
if (markpoints[i].x != -1)
for (i=0;i<AM_NUMMARKPOINTS;i++)
{
w = SHORT(marknums[i]->width);
h = SHORT(marknums[i]->height);
fx = CXMTOF(markpoints[i].x);
fy = CYMTOF(markpoints[i].y);
if (fx >= f_x && fx <= f_w - w && fy >= f_y && fy <= f_h - h)
V_DrawPatch(fx, fy, marknums[i]);
if (markpoints[i].x != -1)
{
// w = SHORT(marknums[i]->width);
// h = SHORT(marknums[i]->height);
w = 6; // [crispy] based on doom +1 for increased size
h = 7; // [crispy] based on doom +1 for increased size
// [crispy] center marks around player
pt.x = markpoints[i].x;
pt.y = markpoints[i].y;
if (crispy->automaprotate)
{
AM_rotatePoint(&pt);
}
fx = (CXMTOF(pt.x) >> crispy->hires) - 1;
fy = (CYMTOF(pt.y) >> crispy->hires) - 2;
if (fx >= f_x && fx <= (f_w >> crispy->hires) - w && fy >= f_y && fy <= (f_h >> crispy->hires) - h)
V_DrawPatch(fx - WIDESCREENDELTA, fy, marknums[i]);
}
}
}
}
*/

void AM_drawkeys(void)
{
Expand Down Expand Up @@ -1925,9 +1958,34 @@ void AM_drawkeys(void)
}
}

void AM_drawCrosshair(int color)
static void AM_drawCrosshair(int color, boolean force)
{
fb[(f_w * (f_h + 1)) / 2] = color; // single point for now
// [crispy] draw an actual crosshair
if (!followplayer || force)
{
static fline_t h, v;

if (!h.a.x || force)
{
h.a.x = h.b.x = v.a.x = v.b.x = f_x + f_w / 2;
h.a.y = h.b.y = v.a.y = v.b.y = f_y + f_h / 2;
h.a.x -= 2; h.b.x += 2;
v.a.y -= 2; v.b.y += 2;
}

AM_drawFline(&h, color);
AM_drawFline(&v, color);
}
// [crispy] do not draw the useless dot on the player arrow
/*
else
#ifndef CRISPY_TRUECOLOR
fb[(f_w*(f_h+1))/2] = color; // single point for now
#else
fb[(f_w*(f_h+1))/2] = pal_color[color]; // single point for now
#endif
*/

}

void AM_Drawer(void)
Expand Down Expand Up @@ -1971,12 +2029,12 @@ void AM_Drawer(void)
if (grid)
AM_drawGrid(GRIDCOLORS);
AM_drawWalls();
AM_drawMarks(); // [crispy] restore mapmarker functionality
AM_drawPlayers();
if (cheating == 2)
AM_drawThings(THINGCOLORS, THINGRANGE);
// AM_drawCrosshair(XHAIRCOLORS);
AM_drawCrosshair(XHAIRCOLORS, false);

// AM_drawMarks();
if (gameskill == sk_baby || crispy->keysloc)
{
AM_drawkeys();
Expand All @@ -2002,3 +2060,39 @@ void AM_Drawer(void)
// I_Update();
// V_MarkRect(f_x, f_y, f_w, f_h);
}

// [crispy] extended savegames
void AM_GetMarkPoints (int *n, long *p)
{
int i;

*n = markpointnum;
*p = -1L;

// [crispy] prevent saving markpoints from previous map
if (lastlevel == gamemap && lastepisode == gameepisode)
{
for (i = 0; i < AM_NUMMARKPOINTS; i++)
{
*p++ = (long)markpoints[i].x;
*p++ = (markpoints[i].x == -1) ? 0L : (long)markpoints[i].y;
}
}
}

void AM_SetMarkPoints (int n, long *p)
{
int i;

AM_LevelInit(false);
lastlevel = gamemap;
lastepisode = gameepisode;

markpointnum = n;

for (i = 0; i < AM_NUMMARKPOINTS; i++)
{
markpoints[i].x = (int64_t)*p++;
markpoints[i].y = (int64_t)*p++;
}
}
2 changes: 1 addition & 1 deletion src/heretic/am_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#define SECRETWALLRANGE WALLRANGE
#define GRIDCOLORS (GRAYS + GRAYSRANGE/2)
#define GRIDRANGE 0
#define XHAIRCOLORS GRAYS
#define XHAIRCOLORS WHITE

// drawing stuff
#define FB 0
Expand Down
2 changes: 2 additions & 0 deletions src/heretic/doomdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ extern int testcontrols_mousespeed;
extern int vanilla_savegame_limit;
extern int vanilla_demo_limit;

extern FILE *SaveGameFP; // [crispy] for usage in extsavg

/*
===============================================================================

Expand Down
Loading
Loading