Skip to content

Commit

Permalink
Remaster merge commit '808f748f'
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Nov 27, 2024
2 parents a3aaa30 + 808f748 commit e25b3f1
Show file tree
Hide file tree
Showing 18 changed files with 510 additions and 202 deletions.
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ option(CURL_SUPPORT "cURL support" ON)
option(OPENAL_SUPPORT "OpenAL support" ON)
option(SYSTEMWIDE_SUPPORT "Enable systemwide installation of game assets" OFF)
option(SDL3_SUPPORT "Build against SDL 3 instead of SDL2" OFF)
option(GL1_RENDERER "Build the GL3 renderer" ON)
option(GL1_RENDERER "Build the GL1 renderer" ON)
option(GL3_RENDERER "Build the GL3 renderer" ON)
option(GLES1_RENDERER "Build the GLES1 renderer" OFF)
option(GLES3_RENDERER "Build the GLES3 renderer" ON)
Expand Down Expand Up @@ -169,10 +169,10 @@ unset(cpu)

# Systemwide installation of game assets.
if(${SYSTEMWIDE_SUPPORT})
add_definitions(-DSYSTEMWIDE)
if(NOT ${SYSTEMDIR} STREQUAL "")
add_definitions(-DSYSTEMDIR="${SYSTEMDIR}")
endif()
add_definitions(-DSYSTEMWIDE)
if(NOT ${SYSTEMDIR} STREQUAL "")
add_definitions(-DSYSTEMDIR="${SYSTEMDIR}")
endif()
endif()

# We need to pass some options to minizip / unzip.
Expand All @@ -195,11 +195,11 @@ else()
endif()

if(GL1_RENDERER)
# We need an OpenGL implementation.
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
list(APPEND yquake2IncludeDirectories ${OPENGL_INCLUDE_DIR})
list(APPEND yquake2OpenGLLinkerFlags ${OPENGL_LIBRARIES})
# We need an OpenGL implementation.
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
list(APPEND yquake2IncludeDirectories ${OPENGL_INCLUDE_DIR})
list(APPEND yquake2OpenGLLinkerFlags ${OPENGL_LIBRARIES})
endif()

# backtrace lookup
Expand Down Expand Up @@ -260,7 +260,7 @@ else()
list(APPEND yquake2LinkerFlags "-rdynamic")
else()
list(APPEND yquake2LinkerFlags "-lnetwork")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
list(APPEND yquake2LinkerFlags "-lsocket -lnsl")
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Goals:
* [ ] Rearange surfaces in vulkan render before render,
* [ ] Fully implement `target_camera`,
* [ ] Fully implement `misc_flare`,
* [x] Fix player height with enabled flashlight,
* [ ] Single player ReRelease support,
* [ ] Support effects and additional flags for ReRelease when possible.
* [ ] Use shared model cache in client code insted reimplemnet in each render,
Expand Down
2 changes: 2 additions & 0 deletions doc/040_cvarlist.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
or other source of `localization/loc_english.txt` like file.
Defaults to `english`.

* **g_itemsbobeffect**: Bob effect of items like in ReRelease. Defaults to `0`.

* **g_swap_speed**: Sets the speed of the "changing weapon" animation.
Default is `1`. If set to `2`, it will be double the speed, `3` is
the triple... up until the max of `8`, since there are at least 2
Expand Down
28 changes: 25 additions & 3 deletions src/client/cl_entities.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ CL_AddPacketEntities(frame_t *frame)
{
entity_t ent = {0};
entity_state_t *s1;
float autorotate;
float autorotate, autobob;
int i;
int pnum;
centity_t *cent;
int autoanim;
clientinfo_t *ci;
unsigned int effects, renderfx;

/* To distinguish baseq2, xatrix and rogue. */
cvar_t *gametype = Cvar_Get("gametype", "", CVAR_LATCH | CVAR_SERVERINFO);
Expand All @@ -57,15 +56,19 @@ CL_AddPacketEntities(frame_t *frame)

/* brush models can auto animate their frames */
autoanim = 2 * cl.time / 1000;
autobob = 5 * sinf(cl.time / 400.0f);

for (pnum = 0; pnum < frame->num_entities; pnum++)
{
unsigned int effects, renderfx, rr_effects;

s1 = &cl_parse_entities[(frame->parse_entities +
pnum) & (MAX_PARSE_ENTITIES - 1)];

cent = &cl_entities[s1->number];

effects = s1->effects;
rr_effects = s1->rr_effects;
renderfx = s1->renderfx;

/* set frame */
Expand Down Expand Up @@ -139,10 +142,15 @@ CL_AddPacketEntities(frame_t *frame)
for (i = 0; i < 3; i++)
{
ent.origin[i] = ent.oldorigin[i] = cent->prev.origin[i] + cl.lerpfrac *
(cent->current.origin[i] - cent->prev.origin[i]);
(cent->current.origin[i] - cent->prev.origin[i]);
}
}

if (effects & EF_BOB) {
ent.origin[2] += autobob;
ent.oldorigin[2] += autobob;
}

/* tweak the color of beams */
if (renderfx & RF_BEAM)
{
Expand Down Expand Up @@ -261,6 +269,20 @@ CL_AddPacketEntities(frame_t *frame)
}
}

if (rr_effects & EF_FLASHLIGHT) {
vec3_t forward, start, end;
trace_t trace;
int mask = CONTENTS_SOLID | CONTENTS_MONSTER;

AngleVectors(ent.angles, forward, NULL, NULL);
VectorMA(ent.origin, 1024, forward, end);
VectorCopy(ent.origin, start);

trace = CM_BoxTrace(start, end, vec3_origin, vec3_origin, 0, mask);

V_AddLight(trace.endpos, 128, 1, 1, 1);
}

if (s1->number == cl.playernum + 1)
{
ent.flags |= RF_VIEWERMODEL;
Expand Down
21 changes: 21 additions & 0 deletions src/client/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,27 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits)
to->effects = MSG_ReadShort(&net_message);
}

/* ReRelease effects */
if (cls.serverProtocol != PROTOCOL_VERSION)
{
to->rr_effects = 0;
}
else
{
if ((bits & (U_EFFECTS8 | U_EFFECTS16)) == (U_EFFECTS8 | U_EFFECTS16))
{
to->rr_effects = MSG_ReadLong(&net_message);
}
else if (bits & U_EFFECTS8)
{
to->rr_effects = MSG_ReadByte(&net_message);
}
else if (bits & U_EFFECTS16)
{
to->rr_effects = MSG_ReadShort(&net_message);
}
}

if ((bits & (U_RENDERFX8 | U_RENDERFX16)) == (U_RENDERFX8 | U_RENDERFX16))
{
to->renderfx = MSG_ReadLong(&net_message);
Expand Down
20 changes: 10 additions & 10 deletions src/client/refresh/soft/sw_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1854,9 +1854,9 @@ GetRefAPI(refimport_t imp)
refexport.EndWorldRenderpass = RE_EndWorldRenderpass;
refexport.EndFrame = RE_EndFrame;

// Tell the client that we're unsing the
// Tell the client that we're unsing the
// new renderer restart API.
ri.Vid_RequestRestart(RESTART_NO);
ri.Vid_RequestRestart(RESTART_NO);

Swap_Init ();

Expand Down Expand Up @@ -1909,10 +1909,10 @@ RE_InitContext(void *win)
SDL_SetRenderVSync(renderer, 1);
#else
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if(!renderer)
{
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE | SDL_RENDERER_PRESENTVSYNC);
}
if(!renderer)
{
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE | SDL_RENDERER_PRESENTVSYNC);
}
#endif
}
else
Expand All @@ -1921,10 +1921,10 @@ RE_InitContext(void *win)
renderer = SDL_CreateRenderer(window, NULL);
#else
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if(!renderer)
{
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
}
if(!renderer)
{
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
}
#endif
}
if(!renderer) {
Expand Down
5 changes: 2 additions & 3 deletions src/client/vid/glimp_sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ ShutdownGraphics(void)
}
else {
SDL_GetWindowPosition(window,
&last_position_x, &last_position_y);
&last_position_x, &last_position_y);
}

/* cleanly ungrab input (needs window) */
Expand Down Expand Up @@ -640,8 +640,7 @@ GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
Com_Printf("Real display mode: %ix%i@%i\n", mode.w, mode.h, mode.refresh_rate);
}


/* Initialize rendering context. */
/* Initialize rendering context. */
if (!re.InitContext(window))
{
/* InitContext() should have logged an error. */
Expand Down
8 changes: 7 additions & 1 deletion src/common/header/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ typedef struct
* it has a zero index model. */
#define EF_ROTATE 0x00000001 /* rotate (bonus items) */
#define EF_GIB 0x00000002 /* leave a trail */
#define EF_BOB 0x00000004 /* ReRelease BoB effect */
#define EF_BLASTER 0x00000008 /* redlight + trail */
#define EF_ROCKET 0x00000010 /* redlight + trail */
#define EF_GRENADE 0x00000020
Expand Down Expand Up @@ -817,6 +818,10 @@ typedef struct
#define EF_CHICKEN 0x00400000 // The flag that tells the system that the player is
// a chicken, and not corvus.

/* entity_state_t->rr_effects
* ReRelease flags, values are diffeent to quake 2 RR code */
#define EF_FLASHLIGHT 0x00000001 /* project flashlight, only for players */

/* entity_state_t->renderfx flags */
#define RF_MINLIGHT 1 /* allways have some light (viewmodel) */
#define RF_VIEWERMODEL 2 /* don't draw through eyes, only mirrors */
Expand Down Expand Up @@ -1437,7 +1442,8 @@ typedef struct entity_state_s
/* events only go out for a single frame, they */
/* are automatically cleared each frame */
/* New protocol fields */
vec3_t scale;
vec3_t scale; /* model scale */
unsigned int rr_effects;

short clientnum; // In Quake 2, the client num was passed in skinnum. We need this value, however.

Expand Down
25 changes: 22 additions & 3 deletions src/common/movemsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,14 @@ MSG_WriteDeltaEntity(entity_state_t *from,
}
}

if (to->effects != from->effects)
if ((to->effects != from->effects) || (to->rr_effects != from->rr_effects))
{
if (to->effects < 256)
if ((to->effects < 256) && (to->rr_effects < 256))
{
bits |= U_EFFECTS8;
}

else if (to->effects < 0x8000)
else if ((to->effects < 0x8000) && (to->rr_effects < 0x8000))
{
bits |= U_EFFECTS16;
}
Expand Down Expand Up @@ -770,6 +770,25 @@ MSG_WriteDeltaEntity(entity_state_t *from,
MSG_WriteShort(msg, to->effects);
}

/* ReRelease effects */
if (protocol == PROTOCOL_VERSION)
{
if ((bits & (U_EFFECTS8 | U_EFFECTS16)) == (U_EFFECTS8 | U_EFFECTS16))
{
MSG_WriteLong(msg, to->rr_effects);
}

else if (bits & U_EFFECTS8)
{
MSG_WriteByte(msg, to->rr_effects);
}

else if (bits & U_EFFECTS16)
{
MSG_WriteShort(msg, to->rr_effects);
}
}

if ((bits & (U_RENDERFX8 | U_RENDERFX16)) == (U_RENDERFX8 | U_RENDERFX16))
{
MSG_WriteLong(msg, to->renderfx);
Expand Down
Loading

0 comments on commit e25b3f1

Please sign in to comment.