diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index 7ff978397..0816c5a03 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -66,7 +66,7 @@ endif gcc_versions:=\ 152 151 150 15\ 142 141 140 14\ - 132 131 130 13\ + 133 132 131 130 13\ 123 122 121 120 12\ 114 113 112 111 110 11\ 105 104 103 102 101 100 10\ diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index e57119fb9..c3989bb4f 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,10 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference -Wzero-as-null-pointer-constant +WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +ifdef GCC152 +WFLAGS+=-Wzero-as-null-pointer-constant +endif ifndef GCC295 #WFLAGS+=-Wno-packed endif diff --git a/src/d_main.c b/src/d_main.c index 3e474cec3..81fd3d830 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -946,6 +946,9 @@ void D_ClearState(void) // void D_StartTitle(void) { + if (dedicated) + I_Error("D_StartTitle is called on dedicated server"); + D_ClearState(); multiplayer = netgame = false; // title menu shouldnt be a netgame or multiplayer lmao F_StartTitleScreen(); diff --git a/src/d_netfil.c b/src/d_netfil.c index 12f19dde2..67fd28a82 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -131,6 +131,8 @@ static UINT32 curl_origtotalfilesize; static char *curl_realname = NULL; fileneeded_t *curl_curfile = NULL; HTTP_login *curl_logins = NULL; + +static void CURLGetFile(void); #endif /** Fills a serverinfo packet with information about wad files loaded. @@ -1305,6 +1307,7 @@ void CURLPrepareFile(const char* url, int dfilenum) if (!multi_handle) { cc = curl_global_init(CURL_GLOBAL_ALL); + if (cc < 0) { I_OutputMsg("libcurl: curl_global_init() returned %d\n", cc); @@ -1313,6 +1316,7 @@ void CURLPrepareFile(const char* url, int dfilenum) { multi_handle = curl_multi_init(); } + if (!multi_handle) { I_OutputMsg("libcurl: curl_multi_init() failed\n"); @@ -1441,7 +1445,7 @@ void CURLAbortFile(void) #endif } -void CURLGetFile(void) +static void CURLGetFile(void) { #ifdef HAVE_THREADS I_lock_mutex(&downloadmutex); @@ -1483,7 +1487,8 @@ void CURLGetFile(void) e = m->easy_handle; easyres = m->data.result; - char *filename = Z_StrDup(curl_realname); + char *filename = malloc(strlen(curl_realname)+1); + strcpy(filename, curl_realname); nameonly(filename); if (easyres != CURLE_OK) @@ -1521,7 +1526,7 @@ void CURLGetFile(void) } } - Z_Free(filename); + free(filename); curl_curfile->file = NULL; filedownload.remaining--; mc = curl_multi_remove_handle(multi_handle, e); diff --git a/src/d_netfil.h b/src/d_netfil.h index 3c7502451..268cd80be 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -119,7 +119,6 @@ size_t nameonlylength(const char *s); #ifdef HAVE_CURL void CURLPrepareFile(const char* url, int dfilenum); void CURLAbortFile(void); -void CURLGetFile(void); HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next); size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); #endif diff --git a/src/hardware/hw_gl.h b/src/hardware/hw_gl.h index 7e167485e..de5ac6338 100644 --- a/src/hardware/hw_gl.h +++ b/src/hardware/hw_gl.h @@ -80,6 +80,9 @@ UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable); void GL_ClearLightTables(void); void GL_SetScreenPalette(RGBA_t *palette); +void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, + FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index e45a56cda..0a79ba6ec 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1475,4 +1475,116 @@ void HWR_DrawMD2(gl_vissprite_t *spr) } } +// mostly copy paste of HWR_DrawMD2 +// very ugly but our model code kinda sucks +void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t color, const UINT8 *colormap, fixed_t scale, INT32 frame, angle_t angle) +{ + patch_t *gpatch, *blendgpatch; + GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; + FTransform p; + FSurfaceInfo Surf; + + if (!md2->model) + { + char filename[64]; + CONS_Debug(DBG_RENDER, "Loading model... (%s)\n", md2->filename); + sprintf(filename, "mdls/%s", md2->filename); + md2->model = md2_readModel(filename); + + if (md2->model) + { + md2_printModelInfo(md2->model); + GL_CreateModelVBOs(md2->model); + } + else + { + md2->error = true; + return; + } + } + + if (md2->model->meshes[0].numFrames > 0) + frame = frame % md2->model->meshes[0].numFrames; + else + frame = 0; + + gpatch = (patch_t *)(md2->glpatch); + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); + + if (!gpatch || !hwrPatch || + ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile)) + md2_loadTexture(md2); + + gpatch = (patch_t*)(md2->glpatch); + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); + + blendgpatch = (patch_t*)(md2->blendglpatch); + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + + if ((gpatch && hwrPatch && hwrPatch->mipmap->format) && + (!blendgpatch || !hwrBlendPatch || + ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile))) + md2_loadBlendTexture(md2); + + blendgpatch = (patch_t*)(md2->blendglpatch); + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + + memset(&Surf, 0x00, sizeof(FSurfaceInfo)); + Surf.PolyColor.rgba = 0xFFFFFFFF; + Surf.PolyFlags = PF_Occlude | PF_Modulated; + + Surf.LightInfo.light_level = 255; + Surf.LightInfo.fade_start = 0; + Surf.LightInfo.fade_end = 31; + + if (color != SKINCOLOR_NONE && + blendgpatch && hwrBlendPatch->mipmap->format && + gpatch->width == blendgpatch->width && gpatch->height == blendgpatch->height) + { + INT32 tcskinnum = TC_DEFAULT; + + if (color) + tcskinnum = skinnum; + + HWR_GetBlendedTexture(gpatch, blendgpatch, tcskinnum, colormap, color); + } + else if (hwrPatch && hwrPatch->mipmap->format) + { + GL_SetTexture(hwrPatch->mipmap); + } + + memset(&p, 0x00, sizeof(FTransform)); + + p.x = x*vid.dup + (float)(vid.width - BASEVIDWIDTH*vid.dup)/2.f; + p.y = -420.f; // push it back to prevent wonky culling, idk lul + p.z = y*vid.dup + (float)(vid.height - BASEVIDHEIGHT*vid.dup)/2.f; + + p.angley = FixedToFloat(AngleFixed(angle)); + p.anglex = 0.f; + p.anglez = 0.f; + + p.roll = false; + p.fliptype = TRANSFORM_NONE; + + const float fscale = FixedToFloat(scale*vid.dup); + + GL_Draw2DModel( + md2->model, + frame, + 0.f, + 0.f, + -1, + &p, + fscale, + fscale, + true, // flip it vertically lul + false, + &Surf + ); +} + #endif //HWRENDER diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 62de1f35e..0f8bd5342 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -45,6 +45,9 @@ void HWR_InitMD2(void); void HWR_DrawMD2(gl_vissprite_t *spr); void HWR_AddPlayerMD2(INT32 skin, boolean local); void HWR_AddSpriteMD2(size_t spritenum); +void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, + skincolors_t color, const UINT8 *colormap, + fixed_t scale, INT32 frame, angle_t angle); #ifdef __cplusplus } // extern "C" diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index fab0a8a6d..2d1f8e255 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -404,6 +404,14 @@ static PFNglEnableClientState pglEnableClientState; typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap); static PFNglDisableClientState pglDisableClientState; +typedef void (APIENTRY * PFNglOrtho) (GLdouble left, + GLdouble right, + GLdouble bottom, + GLdouble top, + GLdouble nearVal, + GLdouble farVal); +static PFNglOrtho pglOrtho; + /* Lighting */ typedef void (APIENTRY * PFNglShadeModel) (GLenum mode); static PFNglShadeModel pglShadeModel; @@ -858,6 +866,8 @@ void SetupGLFunc4(void) GetGLfunc(glUniform3fv); GetGLfunc(glGetUniformLocation); + GetGLfunc(glOrtho); + #ifdef GLDEBUGMESSAGE GetGLfunc(glDebugMessageCallback); #endif @@ -3090,6 +3100,39 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics pglDisable(GL_NORMALIZE); } +void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, + FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) +{ + // save our matrix´s + pglMatrixMode(GL_PROJECTION); + pglPushMatrix(); + pglMatrixMode(GL_MODELVIEW); + pglPushMatrix(); + + pglMatrixMode(GL_PROJECTION); + pglLoadIdentity(); + + // switch to ortho mode to make our lives easier + // thisll make sure our coords will be remapped to pixel coords + pglOrtho(0.0f, (float)vid.width, (float)vid.height, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); + + pglMatrixMode(GL_MODELVIEW); + pglLoadIdentity(); + + pglEnable(GL_DEPTH_TEST); + pglDepthMask(GL_TRUE); + pglClear(GL_DEPTH_BUFFER_BIT); + + GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, + pos, hscale, vscale, flipped, hflipped, Surface); + + // restore the matrix´s + pglMatrixMode(GL_PROJECTION); + pglPopMatrix(); + pglMatrixMode(GL_MODELVIEW); + pglPopMatrix(); +} + // -----------------+ // SetTransform : // -----------------+ diff --git a/src/m_menu.c b/src/m_menu.c index 27f6ae3a6..16f261ae5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12,6 +12,8 @@ /// \file m_menu.c /// \brief XMOD's extremely revamped menu system. +#include "screen.h" +#include "tables.h" #ifdef __GNUC__ #include #endif @@ -7945,6 +7947,7 @@ static void M_DrawSetupMultiPlayerMenu(void) UINT8 i; UINT8 s, w; const UINT8 *flashcol = V_GetStringColormap(highlightflags); + INT32 skinnum = 0; INT32 statx, staty; UINT32 speenframe; INT32 sltw, actw, hetw; @@ -8520,12 +8523,12 @@ static void M_DrawSetupMultiPlayerMenu(void) break; } - const INT32 skinnum = R_SkinAvailable(skins[skintodisplay].name); + skinnum = R_SkinAvailable(skins[skintodisplay].name); - if (skinnum != -1) - sprdef = &skins[skinnum].spritedef; - else - sprdef = &skins[0].spritedef; + if (skinnum < 0 || skinnum >= MAXSKINS) + skinnum = 0; + + sprdef = &skins[skinnum].spritedef; if (!sprdef->numframes) // No frames ?? return; // Can't render! @@ -8548,23 +8551,43 @@ static void M_DrawSetupMultiPlayerMenu(void) // draw box around guy V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239); +#undef charw // draw player sprite if (setupm_fakecolor) // inverse should never happen { UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE); +#ifdef HWRENDER + md2_t *md2 = &md2_playermodels[skinnum]; - if (skins[skintodisplay].flags & SF_HIRES) + // if we have 3d models enabled and a model exists + // try to show it instead of the sprite + if (rendermode == render_opengl && cv_glmdls.value + && !md2->error && !md2->notfound) { - V_DrawFixedPatch((mx+36)<error && !md2->notfound) { - V_DrawFixedPatch((mx+220)<