Merge branch SRB2:next into next

This commit is contained in:
Alam Ed Arias 2025-01-10 06:03:52 +00:00
commit 286466db27
29 changed files with 385 additions and 306 deletions

View file

@ -1076,6 +1076,9 @@ static inline void AM_drawPlayers(void)
if (!playeringame[i] || players[i].spectator) if (!playeringame[i] || players[i].spectator)
continue; continue;
if (!players[i].mo)
continue;
p = &players[i]; p = &players[i];
if (p->skincolor > 0) if (p->skincolor > 0)
color = R_GetTranslationColormap(TC_DEFAULT, p->skincolor, GTC_CACHE)[GREENS + 8]; color = R_GetTranslationColormap(TC_DEFAULT, p->skincolor, GTC_CACHE)[GREENS + 8];

View file

@ -1600,7 +1600,7 @@ void D_SRB2Main(void)
{ {
if (!M_IsNextParm()) if (!M_IsNextParm())
I_Error("usage: -room <room_id>\nCheck the Master Server's webpage for room ID numbers.\n"); I_Error("usage: -room <room_id>\nCheck the Master Server's webpage for room ID numbers.\n");
ms_RoomId = atoi(M_GetNextParm()); CV_SetValue(&cv_masterserver_room_id, atoi(M_GetNextParm()));
#ifdef UPDATE_ALERT #ifdef UPDATE_ALERT
GetMODVersion_Console(); GetMODVersion_Console();

View file

@ -705,10 +705,9 @@ typedef struct
static feild_t tty_con; static feild_t tty_con;
// when printing general stuff to stdout stderr (Sys_Printf) // lock to prevent clearing partial lines, since not everything
// we need to disable the tty console stuff // printed ends on a newline.
// this increments so we can recursively disable static boolean ttycon_ateol = true;
static INT32 ttycon_hide = 0;
// some key codes that the terminal may be using // some key codes that the terminal may be using
// TTimo NOTE: I'm not sure how relevant this is // TTimo NOTE: I'm not sure how relevant this is
static INT32 tty_erase; static INT32 tty_erase;
@ -736,63 +735,31 @@ static inline void tty_FlushIn(void)
// TTimo NOTE: it seems on some terminals just sending '\b' is not enough // TTimo NOTE: it seems on some terminals just sending '\b' is not enough
// so for now, in any case we send "\b \b" .. yeah well .. // so for now, in any case we send "\b \b" .. yeah well ..
// (there may be a way to find out if '\b' alone would work though) // (there may be a way to find out if '\b' alone would work though)
// Hanicef NOTE: using \b this way is unreliable because of terminal state,
// it's better to use \r to reset the cursor to the beginning of the
// line and clear from there.
static void tty_Back(void) static void tty_Back(void)
{ {
char key; write(STDOUT_FILENO, "\r", 1);
ssize_t d; if (tty_con.cursor>0)
key = '\b'; {
d = write(STDOUT_FILENO, &key, 1); write(STDOUT_FILENO, tty_con.buffer, tty_con.cursor);
key = ' '; }
d = write(STDOUT_FILENO, &key, 1); write(STDOUT_FILENO, " \b", 2);
key = '\b';
d = write(STDOUT_FILENO, &key, 1);
(void)d;
} }
static void tty_Clear(void) static void tty_Clear(void)
{ {
size_t i; size_t i;
write(STDOUT_FILENO, "\r", 1);
if (tty_con.cursor>0) if (tty_con.cursor>0)
{ {
for (i=0; i<tty_con.cursor; i++) for (i=0; i<tty_con.cursor; i++)
{ {
tty_Back(); write(STDOUT_FILENO, " ", 1);
} }
write(STDOUT_FILENO, "\r", 1);
} }
}
// clear the display of the line currently edited
// bring cursor back to beginning of line
static inline void tty_Hide(void)
{
//I_Assert(consolevent);
if (ttycon_hide)
{
ttycon_hide++;
return;
}
tty_Clear();
ttycon_hide++;
}
// show the current line
// FIXME TTimo need to position the cursor if needed??
static inline void tty_Show(void)
{
size_t i;
ssize_t d;
//I_Assert(consolevent);
I_Assert(ttycon_hide>0);
ttycon_hide--;
if (ttycon_hide == 0 && tty_con.cursor)
{
for (i=0; i<tty_con.cursor; i++)
{
d = write(STDOUT_FILENO, tty_con.buffer+i, 1);
}
}
(void)d;
} }
// never exit without calling this, or your terminal will be left in a pretty bad state // never exit without calling this, or your terminal will be left in a pretty bad state
@ -900,6 +867,11 @@ static void I_GetConsoleEvents(void)
tty_con.cursor = 0; tty_con.cursor = 0;
ev.key = KEY_ENTER; ev.key = KEY_ENTER;
} }
else if (key == 0x4) // ^D, aka EOF
{
// shut down, most unix programs behave this way
I_Quit();
}
else continue; else continue;
} }
else if (tty_con.cursor < sizeof(tty_con.buffer)) else if (tty_con.cursor < sizeof(tty_con.buffer))
@ -1046,6 +1018,9 @@ void I_OutputMsg(const char *fmt, ...)
va_start(argptr,fmt); va_start(argptr,fmt);
len = vsnprintf(NULL, 0, fmt, argptr); len = vsnprintf(NULL, 0, fmt, argptr);
va_end(argptr); va_end(argptr);
if (len == 0)
return;
txt = malloc(len+1); txt = malloc(len+1);
va_start(argptr,fmt); va_start(argptr,fmt);
vsprintf(txt, fmt, argptr); vsprintf(txt, fmt, argptr);
@ -1135,18 +1110,20 @@ void I_OutputMsg(const char *fmt, ...)
} }
#else #else
#ifdef HAVE_TERMIOS #ifdef HAVE_TERMIOS
if (consolevent) if (consolevent && ttycon_ateol)
{ {
tty_Hide(); tty_Clear();
ttycon_ateol = false;
} }
#endif #endif
if (!framebuffer) if (!framebuffer)
fprintf(stderr, "%s", txt); fprintf(stderr, "%s", txt);
#ifdef HAVE_TERMIOS #ifdef HAVE_TERMIOS
if (consolevent) if (consolevent && txt[len-1] == '\n')
{ {
tty_Show(); write(STDOUT_FILENO, tty_con.buffer, tty_con.cursor);
ttycon_ateol = true;
} }
#endif #endif
@ -1453,8 +1430,10 @@ const char *I_LocateWad(void)
{ {
// change to the directory where we found srb2.pk3 // change to the directory where we found srb2.pk3
#if defined (_WIN32) #if defined (_WIN32)
waddir = _fullpath(NULL, waddir, MAX_PATH);
SetCurrentDirectoryA(waddir); SetCurrentDirectoryA(waddir);
#else #else
waddir = realpath(waddir, NULL);
if (chdir(waddir) == -1) if (chdir(waddir) == -1)
I_OutputMsg("Couldn't change working directory\n"); I_OutputMsg("Couldn't change working directory\n");
#endif #endif

View file

@ -3925,6 +3925,7 @@ void readmaincfg(MYFILE *f)
value = get_number(word2); value = get_number(word2);
bootmap = (INT16)value; bootmap = (INT16)value;
bootmapchanged = true;
//titlechanged = true; //titlechanged = true;
} }
else if (fastcmp(word, "STARTCHAR")) else if (fastcmp(word, "STARTCHAR"))

View file

@ -20,6 +20,7 @@ boolean deh_loaded = false;
boolean gamedataadded = false; boolean gamedataadded = false;
boolean titlechanged = false; boolean titlechanged = false;
boolean introchanged = false; boolean introchanged = false;
boolean bootmapchanged = false;
static int dbg_line; static int dbg_line;
static INT32 deh_num_warning = 0; static INT32 deh_num_warning = 0;
@ -199,7 +200,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
deh_num_warning = 0; deh_num_warning = 0;
gamedataadded = titlechanged = introchanged = false; gamedataadded = titlechanged = introchanged = bootmapchanged = false;
// it doesn't test the version of SRB2 and version of dehacked file // it doesn't test the version of SRB2 and version of dehacked file
dbg_line = -1; // start at -1 so the first line is 0. dbg_line = -1; // start at -1 so the first line is 0.
@ -590,7 +591,12 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
if (gamestate == GS_TITLESCREEN) if (gamestate == GS_TITLESCREEN)
{ {
if (introchanged) if (bootmapchanged && bootmap)
{
menuactive = false;
D_MapChange(bootmap, gametype, ultimatemode, true, 0, false, false);
}
else if (introchanged)
{ {
menuactive = false; menuactive = false;
I_UpdateMouseGrab(); I_UpdateMouseGrab();

View file

@ -39,6 +39,7 @@ extern boolean deh_loaded;
extern boolean gamedataadded; extern boolean gamedataadded;
extern boolean titlechanged; extern boolean titlechanged;
extern boolean introchanged; extern boolean introchanged;
extern boolean bootmapchanged;
#define MAX_ACTION_RECURSION 30 #define MAX_ACTION_RECURSION 30
extern const char *luaactions[MAX_ACTION_RECURSION]; extern const char *luaactions[MAX_ACTION_RECURSION];

View file

@ -1384,7 +1384,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
if (PLAYERINPUTDOWN(ssplayer, GC_SPIN) || (usejoystick && axis > 0)) if (PLAYERINPUTDOWN(ssplayer, GC_SPIN) || (usejoystick && axis > 0))
cmd->buttons |= BT_SPIN; cmd->buttons |= BT_SPIN;
if (gamestate != GS_LEVEL) // not in a level, don't build anything else if (gamestate == GS_INTRO) // prevent crash in intro
{ {
cmd->angleturn = ticcmd_oldangleturn[forplayer]; cmd->angleturn = ticcmd_oldangleturn[forplayer];
cmd->aiming = G_ClipAimingPitch(myaiming); cmd->aiming = G_ClipAimingPitch(myaiming);
@ -1722,7 +1722,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// At this point, cmd doesn't contain the final angle yet, // At this point, cmd doesn't contain the final angle yet,
// So we need to temporarily transform it so Lua scripters // So we need to temporarily transform it so Lua scripters
// don't need to handle it differently than in other hooks. // don't need to handle it differently than in other hooks.
if (addedtogame) if (addedtogame && gamestate == GS_LEVEL)
{ {
INT16 extra = ticcmd_oldangleturn[forplayer] - player->oldrelangleturn; INT16 extra = ticcmd_oldangleturn[forplayer] - player->oldrelangleturn;
INT16 origangle = cmd->angleturn; INT16 origangle = cmd->angleturn;

View file

@ -1193,6 +1193,90 @@ static void adjustTextureCoords(model_t *model, patch_t *patch)
model->max_t = gpatch->max_t; model->max_t = gpatch->max_t;
} }
static INT32 GetAnimDuration(mobj_t *mobj) //part of p_mobj's setplayermobjstate logic, used to make sure that anim durations are actually correct when the speed gets adjusted on players
{
player_t *player = mobj->player;
INT32 tics = mobj->state->tics;
if (!(mobj->frame & FF_ANIMATE) && mobj->anim_duration) //set manually by something through lua
return mobj->anim_duration;
if (!player && mobj->type == MT_TAILSOVERLAY && mobj->tracer) //so tails overlays interpolate properly
player = mobj->tracer->player;
if (player)
{
if (player->panim == PA_EDGE && (player->charflags & SF_FASTEDGE))
tics = 2;
else if (player->powers[pw_tailsfly] && (!(player->mo->eflags & MFE_UNDERWATER) || (mobj->type == MT_PLAYER))) //tailsoverlay does not get adjusted from these rules when underwater
{
if (player->fly1 > 0)
tics = 1;
else if (!(player->mo->eflags & MFE_UNDERWATER))
tics = 2;
else
tics = 4;
}
else if (!(disableSpeedAdjust || player->charflags & SF_NOSPEEDADJUST))
{
fixed_t speed;// = FixedDiv(player->speed, FixedMul(mobj->scale, player->mo->movefactor));
if (player->panim == PA_FALL)
{
speed = FixedDiv(abs(mobj->momz), mobj->scale);
if (speed < 10<<FRACBITS)
tics = 4;
else if (speed < 20<<FRACBITS)
tics = 3;
else if (speed < 30<<FRACBITS)
tics = 2;
else
tics = 1;
}
else if (player->panim == PA_ABILITY2 && player->charability2 == CA2_SPINDASH)
{
fixed_t step = (player->maxdash - player->mindash)/4;
speed = (player->dashspeed - player->mindash);
if (speed > 3*step)
tics = 1;
else if (speed > step)
tics = 2;
else
tics = 3;
}
else
{
speed = FixedDiv(player->speed, FixedMul(mobj->scale, player->mo->movefactor));
if (player->panim == PA_ROLL || player->panim == PA_JUMP)
{
if (speed > 16<<FRACBITS)
tics = 1;
else
tics = 2;
}
else if (P_IsObjectOnGround(mobj) || ((player->charability == CA_FLOAT || player->charability == CA_SLOWFALL) && player->secondjump == 1) || player->powers[pw_super]) // Only if on the ground or superflying.
{
if (player->panim == PA_WALK)
{
if (speed > 12<<FRACBITS)
tics = 2;
else if (speed > 6<<FRACBITS)
tics = 3;
else
tics = 4;
}
else if ((player->panim == PA_RUN) || (player->panim == PA_DASH))
{
if (speed > 52<<FRACBITS)
tics = 1;
else
tics = 2;
}
}
}
}
}
return tics;
}
// //
// HWR_DrawModel // HWR_DrawModel
// //
@ -1266,7 +1350,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
{ {
patch_t *gpatch, *blendgpatch; patch_t *gpatch, *blendgpatch;
GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL;
float durs = (float)spr->mobj->state->tics; float durs = GetAnimDuration(spr->mobj);
float tics = (float)spr->mobj->tics; float tics = (float)spr->mobj->tics;
const boolean papersprite = (R_ThingIsPaperSprite(spr->mobj) && !R_ThingIsFloorSprite(spr->mobj)); const boolean papersprite = (R_ThingIsPaperSprite(spr->mobj) && !R_ThingIsFloorSprite(spr->mobj));
const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(spr->mobj)); const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(spr->mobj));
@ -1287,8 +1371,8 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
} }
// Apparently people don't like jump frames like that, so back it goes // Apparently people don't like jump frames like that, so back it goes
//if (tics > durs) if (tics > durs)
//durs = tics; durs = tics;
// Make linkdraw objects use their tracer's alpha value // Make linkdraw objects use their tracer's alpha value
fixed_t newalpha = spr->mobj->alpha; fixed_t newalpha = spr->mobj->alpha;
@ -1607,7 +1691,6 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, hflip, &Surf); HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, hflip, &Surf);
} }
} }
return true; return true;
} }

View file

@ -117,7 +117,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module
#define pwglDeleteContext wglDeleteContext; #define pwglDeleteContext wglDeleteContext;
#define pwglMakeCurrent wglMakeCurrent; #define pwglMakeCurrent wglMakeCurrent;
#else #else
static HMODULE OGL32, GLU32; static HMODULE OGL32;
typedef void *(WINAPI *PFNwglGetProcAddress) (const char *); typedef void *(WINAPI *PFNwglGetProcAddress) (const char *);
static PFNwglGetProcAddress pwglGetProcAddress; static PFNwglGetProcAddress pwglGetProcAddress;
typedef HGLRC (WINAPI *PFNwglCreateContext) (HDC hdc); typedef HGLRC (WINAPI *PFNwglCreateContext) (HDC hdc);
@ -132,13 +132,6 @@ static PFNwglMakeCurrent pwglMakeCurrent;
void *GetGLFunc(const char *proc) void *GetGLFunc(const char *proc)
{ {
void *func = NULL; void *func = NULL;
if (strncmp(proc, "glu", 3) == 0)
{
if (GLU32)
func = GetProcAddress(GLU32, proc);
else
return NULL;
}
if (pwglGetProcAddress) if (pwglGetProcAddress)
func = pwglGetProcAddress(proc); func = pwglGetProcAddress(proc);
if (!func) if (!func)
@ -155,8 +148,6 @@ boolean LoadGL(void)
if (!OGL32) if (!OGL32)
return 0; return 0;
GLU32 = LoadLibrary("GLU32.DLL");
pwglGetProcAddress = GetGLFunc("wglGetProcAddress"); pwglGetProcAddress = GetGLFunc("wglGetProcAddress");
pwglCreateContext = GetGLFunc("wglCreateContext"); pwglCreateContext = GetGLFunc("wglCreateContext");
pwglDeleteContext = GetGLFunc("wglDeleteContext"); pwglDeleteContext = GetGLFunc("wglDeleteContext");
@ -528,7 +519,6 @@ EXPORT void HWRAPI(Shutdown) (void)
ReleaseDC(hWnd, hDC); ReleaseDC(hWnd, hDC);
hDC = NULL; hDC = NULL;
} }
FreeLibrary(GLU32);
FreeLibrary(OGL32); FreeLibrary(OGL32);
GL_DBG_Printf ("HWRAPI Shutdown(DONE)\n"); GL_DBG_Printf ("HWRAPI Shutdown(DONE)\n");
} }

View file

@ -96,6 +96,7 @@ static GLint min_filter = GL_LINEAR;
static GLint mag_filter = GL_LINEAR; static GLint mag_filter = GL_LINEAR;
static GLint anisotropic_filter = 0; static GLint anisotropic_filter = 0;
static boolean model_lighting = false; static boolean model_lighting = false;
boolean supportMipMap = false;
const GLubyte *gl_version = NULL; const GLubyte *gl_version = NULL;
const GLubyte *gl_renderer = NULL; const GLubyte *gl_renderer = NULL;
@ -417,9 +418,6 @@ static PFNglCopyTexImage2D pglCopyTexImage2D;
typedef void (APIENTRY * PFNglCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRY * PFNglCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
static PFNglCopyTexSubImage2D pglCopyTexSubImage2D; static PFNglCopyTexSubImage2D pglCopyTexSubImage2D;
#endif #endif
/* GLU functions */
typedef GLint (APIENTRY * PFNgluBuild2DMipmaps) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
static PFNgluBuild2DMipmaps pgluBuild2DMipmaps;
/* 1.2 functions for 3D textures */ /* 1.2 functions for 3D textures */
typedef void (APIENTRY * PFNglTexImage3D) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRY * PFNglTexImage3D) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
@ -708,9 +706,6 @@ void SetupGLFunc4(void)
pglUniform3fv = GetGLFunc("glUniform3fv"); pglUniform3fv = GetGLFunc("glUniform3fv");
pglGetUniformLocation = GetGLFunc("glGetUniformLocation"); pglGetUniformLocation = GetGLFunc("glGetUniformLocation");
#endif #endif
// GLU
pgluBuild2DMipmaps = GetGLFunc("gluBuild2DMipmaps");
} }
EXPORT boolean HWRAPI(InitShaders) (void) EXPORT boolean HWRAPI(InitShaders) (void)
@ -1617,7 +1612,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
if (MipMap) if (MipMap)
{ {
pgluBuild2DMipmaps(GL_TEXTURE_2D, GL_LUMINANCE_ALPHA, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0);
if (pTexInfo->flags & TF_TRANSPARENT) if (pTexInfo->flags & TF_TRANSPARENT)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff
@ -1638,7 +1634,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
if (MipMap) if (MipMap)
{ {
pgluBuild2DMipmaps(GL_TEXTURE_2D, GL_ALPHA, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0);
if (pTexInfo->flags & TF_TRANSPARENT) if (pTexInfo->flags & TF_TRANSPARENT)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff
@ -1658,7 +1655,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
{ {
if (MipMap) if (MipMap)
{ {
pgluBuild2DMipmaps(GL_TEXTURE_2D, textureformatGL, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
pglTexImage2D(GL_TEXTURE_2D, 0, textureformatGL, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
// Control the mipmap level of detail // Control the mipmap level of detail
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); // the lower the number, the higer the detail pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); // the lower the number, the higer the detail
if (pTexInfo->flags & TF_TRANSPARENT) if (pTexInfo->flags & TF_TRANSPARENT)
@ -2241,7 +2239,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
mag_filter = GL_LINEAR; mag_filter = GL_LINEAR;
min_filter = GL_NEAREST; min_filter = GL_NEAREST;
} }
if (!pgluBuild2DMipmaps) if (!supportMipMap)
{ {
MipMap = GL_FALSE; MipMap = GL_FALSE;
min_filter = GL_LINEAR; min_filter = GL_LINEAR;

View file

@ -35,7 +35,6 @@
#else #else
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h>
#ifdef STATIC_OPENGL // Because of the 1.3 functions, you'll need GLext to compile it if static #ifdef STATIC_OPENGL // Because of the 1.3 functions, you'll need GLext to compile it if static
#define GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES
@ -127,6 +126,7 @@ extern GLint screen_width;
extern GLint screen_height; extern GLint screen_height;
extern GLbyte screen_depth; extern GLbyte screen_depth;
extern GLint maximumAnisotropy; extern GLint maximumAnisotropy;
extern boolean supportMipMap;
/** \brief OpenGL flags for video driver /** \brief OpenGL flags for video driver
*/ */

View file

@ -3181,17 +3181,25 @@ static int lib_rTextureNumForName(lua_State *L)
static int lib_rCheckTextureNameForNum(lua_State *L) static int lib_rCheckTextureNameForNum(lua_State *L)
{ {
char s[9];
INT32 num = (INT32)luaL_checkinteger(L, 1); INT32 num = (INT32)luaL_checkinteger(L, 1);
//HUDSAFE //HUDSAFE
lua_pushstring(L, R_CheckTextureNameForNum(num));
M_Memcpy(s, R_CheckTextureNameForNum(num), 8);
s[8] = '\0';
lua_pushstring(L, s);
return 1; return 1;
} }
static int lib_rTextureNameForNum(lua_State *L) static int lib_rTextureNameForNum(lua_State *L)
{ {
char s[9];
INT32 num = (INT32)luaL_checkinteger(L, 1); INT32 num = (INT32)luaL_checkinteger(L, 1);
//HUDSAFE //HUDSAFE
lua_pushstring(L, R_TextureNameForNum(num));
M_Memcpy(s, R_TextureNameForNum(num), 8);
s[8] = '\0';
lua_pushstring(L, s);
return 1; return 1;
} }

View file

@ -3318,7 +3318,7 @@ boolean M_Responder(event_t *ev)
if (ch == -1) if (ch == -1)
return false; return false;
else if (ch == gamecontrol[GC_SYSTEMMENU][0] || ch == gamecontrol[GC_SYSTEMMENU][1]) // allow remappable ESC key else if (ev->type != ev_text && (ch == gamecontrol[GC_SYSTEMMENU][0] || ch == gamecontrol[GC_SYSTEMMENU][1])) // allow remappable ESC key
ch = KEY_ESCAPE; ch = KEY_ESCAPE;
// F-Keys // F-Keys
@ -3399,6 +3399,13 @@ boolean M_Responder(event_t *ev)
// Handle menuitems which need a specific key handling // Handle menuitems which need a specific key handling
if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER) if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER)
{ {
// block text input if ctrl is held, to allow using ctrl+c ctrl+v and ctrl+x
if (ctrldown)
{
routine(ch);
return true;
}
// ignore ev_keydown events if the key maps to a character, since // ignore ev_keydown events if the key maps to a character, since
// the ev_text event will follow immediately after in that case. // the ev_text event will follow immediately after in that case.
if (ev->type == ev_keydown && ((ch >= 32 && ch <= 127) || (ch >= KEY_KEYPAD7 && ch <= KEY_KPADDEL))) if (ev->type == ev_keydown && ((ch >= 32 && ch <= 127) || (ch >= KEY_KEYPAD7 && ch <= KEY_KPADDEL)))
@ -3429,7 +3436,7 @@ boolean M_Responder(event_t *ev)
{ {
// dirty hack: for customising controls, I want only buttons/keys, not moves // dirty hack: for customising controls, I want only buttons/keys, not moves
if (ev->type == ev_mouse || ev->type == ev_mouse2 || ev->type == ev_joystick if (ev->type == ev_mouse || ev->type == ev_mouse2 || ev->type == ev_joystick
|| ev->type == ev_joystick2) || ev->type == ev_joystick2 || ev->type == ev_text)
return true; return true;
if (routine) if (routine)
{ {
@ -8511,6 +8518,7 @@ static void M_StartTutorial(INT32 choice)
gamecomplete = 0; gamecomplete = 0;
cursaveslot = 0; cursaveslot = 0;
maplistoption = 0; maplistoption = 0;
CV_StealthSet(&cv_skin, DEFAULTSKIN); // tutorial accounts for sonic only
G_DeferedInitNew(false, G_BuildMapName(tutorialmap), 0, false, false); G_DeferedInitNew(false, G_BuildMapName(tutorialmap), 0, false, false);
} }
@ -11775,10 +11783,10 @@ static void M_ChooseRoom(INT32 choice)
#endif #endif
if (choice == 0) if (choice == 0)
ms_RoomId = -1; CV_SetValue(&cv_masterserver_room_id, 0);
else else
{ {
ms_RoomId = roomIds[choice-1]; CV_SetValue(&cv_masterserver_room_id, roomIds[choice-1]);
menuRoomIndex = choice - 1; menuRoomIndex = choice - 1;
} }
@ -12115,8 +12123,7 @@ static void M_HandleConnectIP(INT32 choice)
if ( ctrldown ) { if ( ctrldown ) {
switch (choice) { switch (choice) {
case 'v': case 'v': // ctrl+v, pasting
case 'V': // ctrl+v, pasting
{ {
const char *paste = I_ClipboardPaste(); const char *paste = I_ClipboardPaste();
@ -12129,8 +12136,7 @@ static void M_HandleConnectIP(INT32 choice)
break; break;
} }
case KEY_INS: case KEY_INS:
case 'c': case 'c': // ctrl+c, ctrl+insert, copying
case 'C': // ctrl+c, ctrl+insert, copying
if (l != 0) // Don't replace the clipboard without any text if (l != 0) // Don't replace the clipboard without any text
{ {
I_ClipboardCopy(setupm_ip, l); I_ClipboardCopy(setupm_ip, l);
@ -12138,8 +12144,7 @@ static void M_HandleConnectIP(INT32 choice)
} }
break; break;
case 'x': case 'x': // ctrl+x, cutting
case 'X': // ctrl+x, cutting
if (l != 0) // Don't replace the clipboard without any text if (l != 0) // Don't replace the clipboard without any text
{ {
I_ClipboardCopy(setupm_ip, l); I_ClipboardCopy(setupm_ip, l);

View file

@ -453,7 +453,7 @@ static int PS_DrawPerfRows(int x, int y, int color, perfstatrow_t *rows)
return draw_y; return draw_y;
} }
static void PS_UpdateMetricHistory(ps_metric_t *metric, boolean time_metric, boolean frame_metric, boolean set_user) static void PS_UpdateMetricHistory(ps_metric_t *metric, boolean time_metric, boolean frame_metric)
{ {
int index = frame_metric ? ps_frame_index : ps_tick_index; int index = frame_metric ? ps_frame_index : ps_tick_index;
@ -461,7 +461,7 @@ static void PS_UpdateMetricHistory(ps_metric_t *metric, boolean time_metric, boo
{ {
// allocate history table // allocate history table
int value_size = time_metric ? sizeof(precise_t) : sizeof(INT32); int value_size = time_metric ? sizeof(precise_t) : sizeof(INT32);
void** memory_user = set_user ? &metric->history : NULL; void** memory_user = &metric->history;
metric->history = Z_Calloc(value_size * cv_ps_samplesize.value, PU_PERFSTATS, metric->history = Z_Calloc(value_size * cv_ps_samplesize.value, PU_PERFSTATS,
memory_user); memory_user);
@ -491,7 +491,7 @@ static void PS_UpdateRowHistories(perfstatrow_t *rows, boolean frame_metric)
for (row = rows; row->lores_label; row++) for (row = rows; row->lores_label; row++)
{ {
if (PS_IsRowValid(row)) if (PS_IsRowValid(row))
PS_UpdateMetricHistory(row->metric, !!(row->flags & PS_TIME), frame_metric, true); PS_UpdateMetricHistory(row->metric, !!(row->flags & PS_TIME), frame_metric);
} }
} }
@ -649,17 +649,17 @@ void PS_UpdateTickStats(void)
if (cv_perfstats.value == 3) if (cv_perfstats.value == 3)
{ {
for (i = 0; i < thinkframe_hooks_length; i++) for (i = 0; i < thinkframe_hooks_length; i++)
PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false, false); PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false);
} }
else if (cv_perfstats.value == 4) else if (cv_perfstats.value == 4)
{ {
for (i = 0; i < prethinkframe_hooks_length; i++) for (i = 0; i < prethinkframe_hooks_length; i++)
PS_UpdateMetricHistory(&prethinkframe_hooks[i].time_taken, true, false, false); PS_UpdateMetricHistory(&prethinkframe_hooks[i].time_taken, true, false);
} }
else if (cv_perfstats.value == 5) else if (cv_perfstats.value == 5)
{ {
for (i = 0; i < postthinkframe_hooks_length; i++) for (i = 0; i < postthinkframe_hooks_length; i++)
PS_UpdateMetricHistory(&postthinkframe_hooks[i].time_taken, true, false, false); PS_UpdateMetricHistory(&postthinkframe_hooks[i].time_taken, true, false);
} }
} }
if (cv_perfstats.value) if (cv_perfstats.value)

View file

@ -546,6 +546,7 @@ static void AbortConnection(void)
{ {
Snake_Free(&snake); Snake_Free(&snake);
CURLAbortFile();
D_QuitNetGame(); D_QuitNetGame();
CL_Reset(); CL_Reset();
D_StartTitle(); D_StartTitle();
@ -1062,10 +1063,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
} }
} }
// Rusty TODO: multithread
if (filedownload.http_running)
CURLGetFile();
if (waitmore) if (waitmore)
break; // exit the case break; // exit the case

View file

@ -391,7 +391,7 @@ static CV_PossibleValue_t perfstats_cons_t[] = {
consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", CV_CALL, perfstats_cons_t, PS_PerfStats_OnChange); consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", CV_CALL, perfstats_cons_t, PS_PerfStats_OnChange);
static CV_PossibleValue_t ps_samplesize_cons_t[] = { static CV_PossibleValue_t ps_samplesize_cons_t[] = {
{1, "MIN"}, {1000, "MAX"}, {0, NULL}}; {1, "MIN"}, {1000, "MAX"}, {0, NULL}};
consvar_t cv_ps_samplesize = CVAR_INIT ("ps_samplesize", "1", CV_CALL, ps_samplesize_cons_t, PS_SampleSize_OnChange); consvar_t cv_ps_samplesize = CVAR_INIT ("ps_samplesize", "175", CV_CALL, ps_samplesize_cons_t, PS_SampleSize_OnChange);
static CV_PossibleValue_t ps_descriptor_cons_t[] = { static CV_PossibleValue_t ps_descriptor_cons_t[] = {
{1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}}; {1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}};
consvar_t cv_ps_descriptor = CVAR_INIT ("ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL); consvar_t cv_ps_descriptor = CVAR_INIT ("ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL);

View file

@ -95,6 +95,7 @@ static filetran_t transfer[MAXNETNODES];
INT32 fileneedednum; // Number of files needed to join the server INT32 fileneedednum; // Number of files needed to join the server
fileneeded_t *fileneeded; // List of needed files fileneeded_t *fileneeded; // List of needed files
static tic_t lasttimeackpacketsent = 0; static tic_t lasttimeackpacketsent = 0;
static I_mutex downloadmutex;
char downloaddir[512] = "DOWNLOAD"; char downloaddir[512] = "DOWNLOAD";
// For resuming failed downloads // For resuming failed downloads
@ -606,7 +607,7 @@ void AddLuaFileTransfer(const char *filename, const char *mode)
prevnext = &((*prevnext)->next); prevnext = &((*prevnext)->next);
// Allocate file transfer information and append it to the transfer list // Allocate file transfer information and append it to the transfer list
filetransfer = malloc(sizeof(luafiletransfer_t)); filetransfer = calloc(1, sizeof(luafiletransfer_t));
if (!filetransfer) if (!filetransfer)
I_Error("AddLuaFileTransfer: Out of memory\n"); I_Error("AddLuaFileTransfer: Out of memory\n");
*prevnext = filetransfer; *prevnext = filetransfer;
@ -1609,11 +1610,13 @@ boolean CURLPrepareFile(const char* url, int dfilenum)
I_Error("Attempted to download files in -nodownload mode"); I_Error("Attempted to download files in -nodownload mode");
#endif #endif
curl_global_init(CURL_GLOBAL_ALL); if (!multi_handle)
{
curl_global_init(CURL_GLOBAL_ALL);
multi_handle = curl_multi_init();
}
http_handle = curl_easy_init(); http_handle = curl_easy_init();
multi_handle = curl_multi_init();
if (http_handle && multi_handle) if (http_handle && multi_handle)
{ {
I_mkdir(downloaddir, 0755); I_mkdir(downloaddir, 0755);
@ -1672,6 +1675,8 @@ boolean CURLPrepareFile(const char* url, int dfilenum)
filedownload.current = dfilenum; filedownload.current = dfilenum;
filedownload.http_running = true; filedownload.http_running = true;
I_spawn_thread("http-download", (I_thread_fn)CURLGetFile, NULL);
return true; return true;
} }
@ -1680,103 +1685,119 @@ boolean CURLPrepareFile(const char* url, int dfilenum)
return false; return false;
} }
void CURLAbortFile(void)
{
filedownload.http_running = false;
// lock and unlock to wait for the download thread to exit
I_lock_mutex(&downloadmutex);
I_unlock_mutex(downloadmutex);
}
void CURLGetFile(void) void CURLGetFile(void)
{ {
I_lock_mutex(&downloadmutex);
CURLMcode mc; /* return code used by curl_multi_wait() */ CURLMcode mc; /* return code used by curl_multi_wait() */
CURLcode easyres; /* Return from easy interface */ CURLcode easyres; /* Return from easy interface */
int numfds;
CURLMsg *m; /* for picking up messages with the transfer status */ CURLMsg *m; /* for picking up messages with the transfer status */
CURL *e; CURL *e;
int msgs_left; /* how many messages are left */ int msgs_left; /* how many messages are left */
const char *easy_handle_error; const char *easy_handle_error;
boolean running = true;
if (curl_runninghandles) while (running && filedownload.http_running)
{ {
curl_multi_perform(multi_handle, &curl_runninghandles); if (curl_runninghandles)
/* wait for activity, timeout or "nothing" */
mc = curl_multi_wait(multi_handle, NULL, 0, 1000, &numfds);
if (mc != CURLM_OK)
{ {
CONS_Alert(CONS_WARNING, "curl_multi_wait() failed, code %d.\n", mc); curl_multi_perform(multi_handle, &curl_runninghandles);
return;
}
curl_curfile->currentsize = curl_dlnow;
curl_curfile->totalsize = curl_dltotal;
}
/* See how the transfers went */ /* wait for activity, timeout or "nothing" */
while ((m = curl_multi_info_read(multi_handle, &msgs_left))) mc = curl_multi_wait(multi_handle, NULL, 0, 1000, NULL);
{
if (m && (m->msg == CURLMSG_DONE))
{
e = m->easy_handle;
easyres = m->data.result;
char *filename = Z_StrDup(curl_realname); if (mc != CURLM_OK)
nameonly(filename);
if (easyres != CURLE_OK)
{ {
long response_code = 0; CONS_Alert(CONS_WARNING, "curl_multi_wait() failed, code %d.\n", mc);
continue;
if (easyres == CURLE_HTTP_RETURNED_ERROR)
curl_easy_getinfo(e, CURLINFO_RESPONSE_CODE, &response_code);
if (response_code == 404)
curl_curfile->failed = FDOWNLOAD_FAIL_NOTFOUND;
else
curl_curfile->failed = FDOWNLOAD_FAIL_OTHER;
easy_handle_error = (response_code) ? va("HTTP response code %ld", response_code) : curl_easy_strerror(easyres);
curl_curfile->status = FS_FALLBACK;
curl_curfile->currentsize = curl_origfilesize;
curl_curfile->totalsize = curl_origtotalfilesize;
filedownload.http_failed = true;
fclose(curl_curfile->file);
remove(curl_curfile->filename);
CONS_Alert(CONS_ERROR, M_GetText("Failed to download addon \"%s\" (%s)\n"), filename, easy_handle_error);
} }
else curl_curfile->currentsize = curl_dlnow;
curl_curfile->totalsize = curl_dltotal;
}
/* See how the transfers went */
while ((m = curl_multi_info_read(multi_handle, &msgs_left)))
{
if (m && (m->msg == CURLMSG_DONE))
{ {
fclose(curl_curfile->file); running = false;
e = m->easy_handle;
easyres = m->data.result;
CONS_Printf(M_GetText("Finished download of \"%s\"\n"), filename); char *filename = Z_StrDup(curl_realname);
nameonly(filename);
if (checkfilemd5(curl_curfile->filename, curl_curfile->md5sum) == FS_MD5SUMBAD) if (easyres != CURLE_OK)
{ {
CONS_Alert(CONS_WARNING, M_GetText("File \"%s\" does not match the version used by the server\n"), filename); long response_code = 0;
if (easyres == CURLE_HTTP_RETURNED_ERROR)
curl_easy_getinfo(e, CURLINFO_RESPONSE_CODE, &response_code);
if (response_code == 404)
curl_curfile->failed = FDOWNLOAD_FAIL_NOTFOUND;
else
curl_curfile->failed = FDOWNLOAD_FAIL_OTHER;
easy_handle_error = (response_code) ? va("HTTP response code %ld", response_code) : curl_easy_strerror(easyres);
curl_curfile->status = FS_FALLBACK; curl_curfile->status = FS_FALLBACK;
curl_curfile->failed = FDOWNLOAD_FAIL_MD5SUMBAD; curl_curfile->currentsize = curl_origfilesize;
curl_curfile->totalsize = curl_origtotalfilesize;
filedownload.http_failed = true; filedownload.http_failed = true;
fclose(curl_curfile->file);
remove(curl_curfile->filename);
CONS_Alert(CONS_ERROR, M_GetText("Failed to download addon \"%s\" (%s)\n"), filename, easy_handle_error);
} }
else else
{ {
filedownload.completednum++; fclose(curl_curfile->file);
filedownload.completedsize += curl_curfile->totalsize;
curl_curfile->status = FS_FOUND; CONS_Printf(M_GetText("Finished download of \"%s\"\n"), filename);
if (checkfilemd5(curl_curfile->filename, curl_curfile->md5sum) == FS_MD5SUMBAD)
{
CONS_Alert(CONS_WARNING, M_GetText("File \"%s\" does not match the version used by the server\n"), filename);
curl_curfile->status = FS_FALLBACK;
curl_curfile->failed = FDOWNLOAD_FAIL_MD5SUMBAD;
filedownload.http_failed = true;
}
else
{
filedownload.completednum++;
filedownload.completedsize += curl_curfile->totalsize;
curl_curfile->status = FS_FOUND;
}
} }
Z_Free(filename);
curl_curfile->file = NULL;
filedownload.remaining--;
curl_multi_remove_handle(multi_handle, e);
curl_easy_cleanup(e);
if (!filedownload.remaining)
break;
} }
Z_Free(filename);
curl_curfile->file = NULL;
filedownload.http_running = false;
filedownload.remaining--;
curl_multi_remove_handle(multi_handle, e);
curl_easy_cleanup(e);
if (!filedownload.remaining)
break;
} }
} }
if (!filedownload.remaining) if (!filedownload.remaining || !filedownload.http_running)
{ {
curl_multi_cleanup(multi_handle); curl_multi_cleanup(multi_handle);
curl_global_cleanup(); curl_global_cleanup();
multi_handle = NULL;
} }
filedownload.http_running = false;
I_unlock_mutex(downloadmutex);
} }
HTTP_login * HTTP_login *

View file

@ -140,6 +140,7 @@ boolean CL_SendFileRequest(void);
void PT_RequestFile(SINT8 node); void PT_RequestFile(SINT8 node);
boolean CURLPrepareFile(const char* url, int dfilenum); boolean CURLPrepareFile(const char* url, int dfilenum);
void CURLAbortFile(void);
void CURLGetFile(void); void CURLGetFile(void);
HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next); HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next);

View file

@ -55,6 +55,7 @@ static boolean ServerName_CanChange (const char*);
static void Update_parameters (void); static void Update_parameters (void);
static void MasterServer_OnChange(void); static void MasterServer_OnChange(void);
static void RoomId_OnChange(void);
static CV_PossibleValue_t masterserver_update_rate_cons_t[] = { static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
{2, "MIN"}, {2, "MIN"},
@ -66,8 +67,9 @@ consvar_t cv_masterserver = CVAR_INIT ("masterserver", "https://ds.ms.srb2.org/M
consvar_t cv_servername = CVAR_INIT_WITH_CALLBACKS ("servername", "SRB2 server", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT|CV_ALLOWLUA, NULL, Update_parameters, ServerName_CanChange); consvar_t cv_servername = CVAR_INIT_WITH_CALLBACKS ("servername", "SRB2 server", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT|CV_ALLOWLUA, NULL, Update_parameters, ServerName_CanChange);
consvar_t cv_masterserver_update_rate = CVAR_INIT ("masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters); consvar_t cv_masterserver_update_rate = CVAR_INIT ("masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters);
consvar_t cv_masterserver_room_id = CVAR_INIT ("masterserver_room_id", "0", CV_CALL, CV_Unsigned, RoomId_OnChange);
INT16 ms_RoomId = -1; INT16 ms_RoomId = 0;
#if defined (MASTERSERVER) && defined (HAVE_THREADS) #if defined (MASTERSERVER) && defined (HAVE_THREADS)
int ms_QueryId; int ms_QueryId;
@ -92,6 +94,7 @@ void AddMServCommands(void)
{ {
CV_RegisterVar(&cv_masterserver); CV_RegisterVar(&cv_masterserver);
CV_RegisterVar(&cv_masterserver_update_rate); CV_RegisterVar(&cv_masterserver_update_rate);
CV_RegisterVar(&cv_masterserver_room_id);
CV_RegisterVar(&cv_masterserver_timeout); CV_RegisterVar(&cv_masterserver_timeout);
CV_RegisterVar(&cv_masterserver_debug); CV_RegisterVar(&cv_masterserver_debug);
CV_RegisterVar(&cv_masterserver_token); CV_RegisterVar(&cv_masterserver_token);
@ -534,6 +537,17 @@ Update_parameters (void)
#endif/*MASTERSERVER*/ #endif/*MASTERSERVER*/
} }
static void RoomId_OnChange(void)
{
if (ms_RoomId != cv_masterserver_room_id.value)
{
UnregisterServer();
ms_RoomId = cv_masterserver_room_id.value;
if (Online())
RegisterServer();
}
}
static void MasterServer_OnChange(void) static void MasterServer_OnChange(void)
{ {
#ifdef MASTERSERVER #ifdef MASTERSERVER

View file

@ -66,6 +66,7 @@ typedef struct
extern consvar_t cv_masterserver, cv_servername; extern consvar_t cv_masterserver, cv_servername;
extern consvar_t cv_masterserver_update_rate; extern consvar_t cv_masterserver_update_rate;
extern consvar_t cv_masterserver_room_id;
extern consvar_t cv_masterserver_timeout; extern consvar_t cv_masterserver_timeout;
extern consvar_t cv_masterserver_debug; extern consvar_t cv_masterserver_debug;
extern consvar_t cv_masterserver_token; extern consvar_t cv_masterserver_token;

View file

@ -96,11 +96,15 @@ static void P_SetupStateAnimation(mobj_t *mobj, state_t *st)
animlength = st->var1; animlength = st->var1;
if (!(st->frame & FF_ANIMATE)) if (!(st->frame & FF_ANIMATE))
{
mobj->anim_duration = 0;
return; return;
}
if (animlength <= 0 || st->var2 == 0) if (animlength <= 0 || st->var2 == 0)
{ {
mobj->frame &= ~FF_ANIMATE; mobj->frame &= ~FF_ANIMATE;
mobj->anim_duration = 0;
return; // Crash/stupidity prevention return; // Crash/stupidity prevention
} }

View file

@ -7853,6 +7853,10 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
maptol = mapheaderinfo[gamemap-1]->typeoflevel; maptol = mapheaderinfo[gamemap-1]->typeoflevel;
gametyperules = gametypedefaultrules[gametype]; gametyperules = gametypedefaultrules[gametype];
// clear the target on map change, since the object will be invalidated
P_SetTarget(&ticcmd_ztargetfocus[0], NULL);
P_SetTarget(&ticcmd_ztargetfocus[1], NULL);
CON_Drawer(); // let the user know what we are going to do CON_Drawer(); // let the user know what we are going to do
I_FinishUpdate(); // page flip or blit buffer I_FinishUpdate(); // page flip or blit buffer

View file

@ -83,7 +83,7 @@ static fixed_t planeheight;
fixed_t yslopetab[MAXVIDHEIGHT*16]; fixed_t yslopetab[MAXVIDHEIGHT*16];
fixed_t *yslope; fixed_t *yslope;
static fixed_t xoffs, yoffs; static INT64 xoffs, yoffs;
static dvector3_t slope_origin, slope_u, slope_v; static dvector3_t slope_origin, slope_u, slope_v;
static dvector3_t slope_lightu, slope_lightv; static dvector3_t slope_lightu, slope_lightv;
@ -376,19 +376,25 @@ visplane_t *R_FindPlane(sector_t *sector, fixed_t height, INT32 picnum, INT32 li
visplane_t *check; visplane_t *check;
unsigned hash; unsigned hash;
float offset_xd = FixedToFloat(xoff) / FixedToFloat(xscale ? xscale : 1);
float offset_yd = FixedToFloat(yoff) / FixedToFloat(yscale ? yscale : 1);
INT64 offset_x = offset_xd * FRACUNIT;
INT64 offset_y = offset_yd * FRACUNIT;
if (!slope) // Don't mess with this right now if a slope is involved if (!slope) // Don't mess with this right now if a slope is involved
{ {
xoff += FixedMul(viewx, xscale); offset_x += viewx;
yoff -= FixedMul(viewy, yscale); offset_y -= viewy;
if (plangle != 0) if (plangle != 0)
{ {
// Add the view offset, rotated by the plane angle. // Add the view offset, rotated by the plane angle.
float ang = ANG2RAD(plangle); float ang = ANG2RAD(plangle);
float x = FixedToFloat(xoff); float x = offset_x / (float)FRACUNIT;
float y = FixedToFloat(yoff); float y = offset_y / (float)FRACUNIT;
xoff = FloatToFixed(x * cos(ang) + y * sin(ang)); offset_x = (x * cos(ang) + y * sin(ang)) * FRACUNIT;
yoff = FloatToFixed(-x * sin(ang) + y * cos(ang)); offset_y = (-x * sin(ang) + y * cos(ang)) * FRACUNIT;
} }
} }
@ -399,16 +405,19 @@ visplane_t *R_FindPlane(sector_t *sector, fixed_t height, INT32 picnum, INT32 li
float ang = ANG2RAD(polyobj->angle); float ang = ANG2RAD(polyobj->angle);
float x = FixedToFloat(polyobj->centerPt.x); float x = FixedToFloat(polyobj->centerPt.x);
float y = FixedToFloat(polyobj->centerPt.y); float y = FixedToFloat(polyobj->centerPt.y);
xoff -= FloatToFixed(x * cos(ang) + y * sin(ang)); offset_x -= (x * cos(ang) + y * sin(ang)) * FRACUNIT;
yoff -= FloatToFixed(x * sin(ang) - y * cos(ang)); offset_y -= (x * sin(ang) - y * cos(ang)) * FRACUNIT;
} }
else else
{ {
xoff -= polyobj->centerPt.x; offset_x -= polyobj->centerPt.x;
yoff += polyobj->centerPt.y; offset_y += polyobj->centerPt.y;
} }
} }
offset_x = ((INT64)offset_x * xscale) / FRACUNIT;
offset_y = ((INT64)offset_y * yscale) / FRACUNIT;
// This appears to fix the Nimbus Ruins sky bug. // This appears to fix the Nimbus Ruins sky bug.
if (picnum == skyflatnum && pfloor) if (picnum == skyflatnum && pfloor)
{ {
@ -423,7 +432,7 @@ visplane_t *R_FindPlane(sector_t *sector, fixed_t height, INT32 picnum, INT32 li
{ {
if (height == check->height && picnum == check->picnum if (height == check->height && picnum == check->picnum
&& lightlevel == check->lightlevel && lightlevel == check->lightlevel
&& xoff == check->xoffs && yoff == check->yoffs && offset_x == check->xoffs && offset_y == check->yoffs
&& xscale == check->xscale && yscale == check->yscale && xscale == check->xscale && yscale == check->yscale
&& planecolormap == check->extra_colormap && planecolormap == check->extra_colormap
&& check->viewx == viewx && check->viewy == viewy && check->viewz == viewz && check->viewx == viewx && check->viewy == viewy && check->viewz == viewz
@ -449,8 +458,8 @@ visplane_t *R_FindPlane(sector_t *sector, fixed_t height, INT32 picnum, INT32 li
check->lightlevel = lightlevel; check->lightlevel = lightlevel;
check->minx = vid.width; check->minx = vid.width;
check->maxx = -1; check->maxx = -1;
check->xoffs = xoff; check->xoffs = offset_x;
check->yoffs = yoff; check->yoffs = offset_y;
check->xscale = xscale; check->xscale = xscale;
check->yscale = yscale; check->yscale = yscale;
check->extra_colormap = planecolormap; check->extra_colormap = planecolormap;
@ -658,13 +667,13 @@ static void R_DrawSkyPlane(visplane_t *pl)
} }
// Returns the height of the sloped plane at (x, y) as a double // Returns the height of the sloped plane at (x, y) as a double
static double R_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y) static double R_GetSlopeZAt(const pslope_t *slope, INT64 x, INT64 y)
{ {
// If you want to reimplement this using just the equation constants, use this instead: // If you want to reimplement this using just the equation constants, use this instead:
// (d + a*x + b*y) * -(1.0 / c) // (d + a*x + b*y) * -(1.0 / c)
double px = FixedToDouble(x) - slope->dorigin.x; double px = (x / (double)FRACUNIT) - slope->dorigin.x;
double py = FixedToDouble(y) - slope->dorigin.y; double py = (y / (double)FRACUNIT) - slope->dorigin.y;
double dist = (px * slope->dnormdir.x) + (py * slope->dnormdir.y); double dist = (px * slope->dnormdir.x) + (py * slope->dnormdir.y);
@ -672,10 +681,10 @@ static double R_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y)
} }
// Sets the texture origin vector of the sloped plane. // Sets the texture origin vector of the sloped plane.
static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, fixed_t angle) static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, INT64 xoff, INT64 yoff, fixed_t angle)
{ {
INT64 vx = (INT64)xpos + (INT64)xoff; INT64 vx = (INT64)xpos + xoff;
INT64 vy = (INT64)ypos - (INT64)yoff; INT64 vy = (INT64)ypos - yoff;
float vxf = vx / (float)FRACUNIT; float vxf = vx / (float)FRACUNIT;
float vyf = vy / (float)FRACUNIT; float vyf = vy / (float)FRACUNIT;
@ -702,7 +711,7 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos,
slope->moved = false; slope->moved = false;
} }
R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, xoff, yoff, angle); R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, (INT64)xoff, (INT64)yoff, angle);
height = R_GetSlopeZAt(slope, xpos, ypos); height = R_GetSlopeZAt(slope, xpos, ypos);
zeroheight = height - FixedToDouble(zpos); zeroheight = height - FixedToDouble(zpos);
@ -735,7 +744,7 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos,
} }
// This function calculates all of the vectors necessary for drawing a sloped and scaled plane. // This function calculates all of the vectors necessary for drawing a sloped and scaled plane.
void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle) void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, INT64 xoff, INT64 yoff, angle_t angle, angle_t plangle)
{ {
double height, z_at_xy; double height, z_at_xy;
float ang; float ang;
@ -836,9 +845,11 @@ static void CalcSlopePlaneVectors(visplane_t *pl, fixed_t xoff, fixed_t yoff)
{ {
if (!ds_fog && (pl->xscale != FRACUNIT || pl->yscale != FRACUNIT)) if (!ds_fog && (pl->xscale != FRACUNIT || pl->yscale != FRACUNIT))
{ {
float offset_x = FixedToFloat(xoff) / FixedToFloat(pl->xscale ? pl->xscale : 1);
float offset_y = FixedToFloat(yoff) / FixedToFloat(pl->yscale ? pl->yscale : 1);
R_SetScaledSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz, R_SetScaledSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz,
FixedDiv(FRACUNIT, pl->xscale), FixedDiv(FRACUNIT, pl->yscale), FixedDiv(FRACUNIT, pl->xscale), FixedDiv(FRACUNIT, pl->yscale),
FixedDiv(xoff, pl->xscale), FixedDiv(yoff, pl->yscale), pl->viewangle, pl->plangle); (INT64)(offset_x * FRACUNIT), (INT64)(offset_y * FRACUNIT), pl->viewangle, pl->plangle);
} }
else else
R_SetSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz, xoff, yoff, pl->viewangle, pl->plangle); R_SetSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz, xoff, yoff, pl->viewangle, pl->plangle);

View file

@ -48,7 +48,7 @@ typedef struct visplane_s
UINT16 padbottomstart, bottom[MAXVIDWIDTH], padbottomend; UINT16 padbottomstart, bottom[MAXVIDWIDTH], padbottomend;
INT32 high, low; // R_PlaneBounds should set these. INT32 high, low; // R_PlaneBounds should set these.
fixed_t xoffs, yoffs; // Scrolling flats. INT64 xoffs, yoffs; // Scrolling flats.
fixed_t xscale, yscale; fixed_t xscale, yscale;
sector_t *sector; sector_t *sector;
@ -85,7 +85,7 @@ void R_DrawSinglePlane(visplane_t *pl);
// Calculates the slope vectors needed for tilted span drawing. // Calculates the slope vectors needed for tilted span drawing.
void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle); void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle);
void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle); void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, INT64 xoff, INT64 yoff, angle_t angle, angle_t plangle);
typedef struct planemgr_s typedef struct planemgr_s
{ {

View file

@ -381,7 +381,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
if (pSplat->slope) if (pSplat->slope)
{ {
R_SetScaledSlopePlane(pSplat->slope, vis->viewpoint.x, vis->viewpoint.y, vis->viewpoint.z, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewpoint.angle, pSplat->angle); R_SetScaledSlopePlane(pSplat->slope, vis->viewpoint.x, vis->viewpoint.y, vis->viewpoint.z, (INT64)pSplat->xscale, (INT64)pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewpoint.angle, pSplat->angle);
} }
else if (!ds_solidcolor) else if (!ds_solidcolor)
{ {

View file

@ -477,10 +477,9 @@ typedef struct
feild_t tty_con; feild_t tty_con;
// when printing general stuff to stdout stderr (Sys_Printf) // lock to prevent clearing partial lines, since not everything
// we need to disable the tty console stuff // printed ends on a newline.
// this increments so we can recursively disable static boolean ttycon_ateol = true;
static INT32 ttycon_hide = 0;
// some key codes that the terminal may be using // some key codes that the terminal may be using
// TTimo NOTE: I'm not sure how relevant this is // TTimo NOTE: I'm not sure how relevant this is
static INT32 tty_erase; static INT32 tty_erase;
@ -508,63 +507,31 @@ static inline void tty_FlushIn(void)
// TTimo NOTE: it seems on some terminals just sending '\b' is not enough // TTimo NOTE: it seems on some terminals just sending '\b' is not enough
// so for now, in any case we send "\b \b" .. yeah well .. // so for now, in any case we send "\b \b" .. yeah well ..
// (there may be a way to find out if '\b' alone would work though) // (there may be a way to find out if '\b' alone would work though)
// Hanicef NOTE: using \b this way is unreliable because of terminal state,
// it's better to use \r to reset the cursor to the beginning of the
// line and clear from there.
static void tty_Back(void) static void tty_Back(void)
{ {
char key; write(STDOUT_FILENO, "\r", 1);
ssize_t d; if (tty_con.cursor>0)
key = '\b'; {
d = write(STDOUT_FILENO, &key, 1); write(STDOUT_FILENO, tty_con.buffer, tty_con.cursor);
key = ' '; }
d = write(STDOUT_FILENO, &key, 1); write(STDOUT_FILENO, " \b", 2);
key = '\b';
d = write(STDOUT_FILENO, &key, 1);
(void)d;
} }
static void tty_Clear(void) static void tty_Clear(void)
{ {
size_t i; size_t i;
write(STDOUT_FILENO, "\r", 1);
if (tty_con.cursor>0) if (tty_con.cursor>0)
{ {
for (i=0; i<tty_con.cursor; i++) for (i=0; i<tty_con.cursor; i++)
{ {
tty_Back(); write(STDOUT_FILENO, " ", 1);
} }
write(STDOUT_FILENO, "\r", 1);
} }
}
// clear the display of the line currently edited
// bring cursor back to beginning of line
static inline void tty_Hide(void)
{
//I_Assert(consolevent);
if (ttycon_hide)
{
ttycon_hide++;
return;
}
tty_Clear();
ttycon_hide++;
}
// show the current line
// FIXME TTimo need to position the cursor if needed??
static inline void tty_Show(void)
{
size_t i;
ssize_t d;
//I_Assert(consolevent);
I_Assert(ttycon_hide>0);
ttycon_hide--;
if (ttycon_hide == 0 && tty_con.cursor)
{
for (i=0; i<tty_con.cursor; i++)
{
d = write(STDOUT_FILENO, tty_con.buffer+i, 1);
}
}
(void)d;
} }
// never exit without calling this, or your terminal will be left in a pretty bad state // never exit without calling this, or your terminal will be left in a pretty bad state
@ -672,6 +639,11 @@ void I_GetConsoleEvents(void)
tty_con.cursor = 0; tty_con.cursor = 0;
ev.key = KEY_ENTER; ev.key = KEY_ENTER;
} }
else if (key == 0x4) // ^D, aka EOF
{
// shut down, most unix programs behave this way
I_Quit();
}
else continue; else continue;
} }
else if (tty_con.cursor < sizeof (tty_con.buffer)) else if (tty_con.cursor < sizeof (tty_con.buffer))
@ -879,9 +851,16 @@ static void I_RegisterChildSignals(void)
void I_OutputMsg(const char *fmt, ...) void I_OutputMsg(const char *fmt, ...)
{ {
size_t len; size_t len;
char txt[8192]; char *txt;
va_list argptr; va_list argptr;
va_start(argptr,fmt);
len = vsnprintf(NULL, 0, fmt, argptr);
va_end(argptr);
if (len == 0)
return;
txt = malloc(len+1);
va_start(argptr,fmt); va_start(argptr,fmt);
vsprintf(txt, fmt, argptr); vsprintf(txt, fmt, argptr);
va_end(argptr); va_end(argptr);
@ -915,7 +894,10 @@ void I_OutputMsg(const char *fmt, ...)
DWORD bytesWritten; DWORD bytesWritten;
if (co == INVALID_HANDLE_VALUE) if (co == INVALID_HANDLE_VALUE)
{
free(txt);
return; return;
}
if (GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &bytesWritten)) if (GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &bytesWritten))
{ {
@ -931,11 +913,16 @@ void I_OutputMsg(const char *fmt, ...)
if (oldLength > 0) if (oldLength > 0)
{ {
LPVOID blank = malloc(oldLength); LPVOID blank = malloc(oldLength);
if (!blank) return; if (!blank)
{
free(txt);
return;
}
memset(blank, ' ', oldLength); // Blank out. memset(blank, ' ', oldLength); // Blank out.
oldLines = malloc(oldLength*sizeof(TCHAR)); oldLines = malloc(oldLength*sizeof(TCHAR));
if (!oldLines) if (!oldLines)
{ {
free(txt);
free(blank); free(blank);
return; return;
} }
@ -970,18 +957,20 @@ void I_OutputMsg(const char *fmt, ...)
} }
#else #else
#ifdef HAVE_TERMIOS #ifdef HAVE_TERMIOS
if (consolevent) if (consolevent && ttycon_ateol)
{ {
tty_Hide(); tty_Clear();
ttycon_ateol = false;
} }
#endif #endif
if (!framebuffer) if (!framebuffer)
fprintf(stderr, "%s", txt); fprintf(stderr, "%s", txt);
#ifdef HAVE_TERMIOS #ifdef HAVE_TERMIOS
if (consolevent) if (consolevent && txt[len-1] == '\n')
{ {
tty_Show(); write(STDOUT_FILENO, tty_con.buffer, tty_con.cursor);
ttycon_ateol = true;
} }
#endif #endif
@ -990,6 +979,7 @@ void I_OutputMsg(const char *fmt, ...)
fflush(stderr); fflush(stderr);
#endif #endif
free(txt);
} }
// //
@ -3087,8 +3077,10 @@ const char *I_LocateWad(void)
{ {
// change to the directory where we found srb2.pk3 // change to the directory where we found srb2.pk3
#if defined (_WIN32) #if defined (_WIN32)
waddir = _fullpath(NULL, waddir, MAX_PATH);
SetCurrentDirectoryA(waddir); SetCurrentDirectoryA(waddir);
#else #else
waddir = realpath(waddir, NULL);
if (chdir(waddir) == -1) if (chdir(waddir) == -1)
I_OutputMsg("Couldn't change working directory\n"); I_OutputMsg("Couldn't change working directory\n");
#endif #endif

View file

@ -87,7 +87,7 @@
#endif #endif
// maximum number of windowed modes (see windowedModes[][]) // maximum number of windowed modes (see windowedModes[][])
#define MAXWINMODES (18) #define MAXWINMODES (21)
/** \brief /** \brief
*/ */
@ -157,7 +157,9 @@ static INT32 windowedModes[MAXWINMODES][2] =
{1920,1080}, // 1.66 {1920,1080}, // 1.66
{1680,1050}, // 1.60,5.25 {1680,1050}, // 1.60,5.25
{1600,1200}, // 1.33 {1600,1200}, // 1.33
{1600,1000}, // 1.60,5.00
{1600, 900}, // 1.66 {1600, 900}, // 1.66
{1536, 864}, // 1.66,4.80
{1366, 768}, // 1.66 {1366, 768}, // 1.66
{1440, 900}, // 1.60,4.50 {1440, 900}, // 1.60,4.50
{1280,1024}, // 1.33? {1280,1024}, // 1.33?
@ -166,6 +168,7 @@ static INT32 windowedModes[MAXWINMODES][2] =
{1280, 720}, // 1.66 {1280, 720}, // 1.66
{1152, 864}, // 1.33,3.60 {1152, 864}, // 1.33,3.60
{1024, 768}, // 1.33,3.20 {1024, 768}, // 1.33,3.20
{ 960, 600}, // 1.60,3.00
{ 800, 600}, // 1.33,2.50 { 800, 600}, // 1.33,2.50
{ 640, 480}, // 1.33,2.00 { 640, 480}, // 1.33,2.00
{ 640, 400}, // 1.60,2.00 { 640, 400}, // 1.60,2.00
@ -1946,8 +1949,6 @@ void I_ShutdownGraphics(void)
I_OutputMsg("shut down\n"); I_OutputMsg("shut down\n");
#ifdef HWRENDER #ifdef HWRENDER
if (GLUhandle)
hwClose(GLUhandle);
if (sdlglcontext) if (sdlglcontext)
{ {
SDL_GL_DeleteContext(sdlglcontext); SDL_GL_DeleteContext(sdlglcontext);

View file

@ -70,18 +70,10 @@ PFNglGetString pglGetString;
/** \brief SDL video display surface /** \brief SDL video display surface
*/ */
INT32 oglflags = 0; INT32 oglflags = 0;
void *GLUhandle = NULL;
SDL_GLContext sdlglcontext = 0; SDL_GLContext sdlglcontext = 0;
void *GetGLFunc(const char *proc) void *GetGLFunc(const char *proc)
{ {
if (strncmp(proc, "glu", 3) == 0)
{
if (GLUhandle)
return hwSym(proc, GLUhandle);
else
return NULL;
}
return SDL_GL_GetProcAddress(proc); return SDL_GL_GetProcAddress(proc);
} }
@ -89,7 +81,6 @@ boolean LoadGL(void)
{ {
#ifndef STATIC_OPENGL #ifndef STATIC_OPENGL
const char *OGLLibname = NULL; const char *OGLLibname = NULL;
const char *GLULibname = NULL;
if (M_CheckParm("-OGLlib") && M_IsNextParm()) if (M_CheckParm("-OGLlib") && M_IsNextParm())
OGLLibname = M_GetNextParm(); OGLLibname = M_GetNextParm();
@ -102,43 +93,6 @@ boolean LoadGL(void)
CONS_Printf("If you know what is the OpenGL library's name, use -OGLlib\n"); CONS_Printf("If you know what is the OpenGL library's name, use -OGLlib\n");
return 0; return 0;
} }
#if 0
GLULibname = "/proc/self/exe";
#elif defined (_WIN32)
GLULibname = "GLU32.DLL";
#elif defined (__MACH__)
GLULibname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib";
#elif defined (macintos)
GLULibname = "OpenGLLibrary";
#elif defined (__unix__)
GLULibname = "libGLU.so.1";
#elif defined (__HAIKU__)
GLULibname = "libGLU.so";
#else
GLULibname = NULL;
#endif
if (M_CheckParm("-GLUlib") && M_IsNextParm())
GLULibname = M_GetNextParm();
if (GLULibname)
{
GLUhandle = hwOpen(GLULibname);
if (GLUhandle)
return SetupGLfunc();
else
{
CONS_Alert(CONS_ERROR, "Could not load GLU Library: %s\n", GLULibname);
if (!M_CheckParm ("-GLUlib"))
CONS_Alert(CONS_ERROR, "If you know what is the GLU library's name, use -GLUlib\n");
}
}
else
{
CONS_Alert(CONS_ERROR, "Could not load GLU Library\n");
CONS_Alert(CONS_ERROR, "If you know what is the GLU library's name, use -GLUlib\n");
}
#endif #endif
return SetupGLfunc(); return SetupGLfunc();
} }
@ -155,6 +109,7 @@ boolean OglSdlSurface(INT32 w, INT32 h)
{ {
INT32 cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value; INT32 cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
static boolean first_init = false; static boolean first_init = false;
static int majorGL = 0, minorGL = 0;
oglflags = 0; oglflags = 0;
@ -189,6 +144,12 @@ boolean OglSdlSurface(INT32 w, INT32 h)
else else
maximumAnisotropy = 1; maximumAnisotropy = 1;
if (sscanf((const char*)gl_version, "%d.%d", &majorGL, &minorGL)
&& (!(majorGL == 1 && minorGL <= 3)))
supportMipMap = true;
else
supportMipMap = false;
SetupGLFunc4(); SetupGLFunc4();
glanisotropicmode_cons_t[1].value = maximumAnisotropy; glanisotropicmode_cons_t[1].value = maximumAnisotropy;

View file

@ -19,8 +19,6 @@
#include "../v_video.h" #include "../v_video.h"
extern void *GLUhandle;
boolean OglSdlSurface(INT32 w, INT32 h); boolean OglSdlSurface(INT32 w, INT32 h);
void OglSdlFinishUpdate(boolean vidwait); void OglSdlFinishUpdate(boolean vidwait);