Fix ezhud images not loading.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6271 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-06-19 15:18:23 +00:00
parent c715171416
commit 758f47ffc3
11 changed files with 107 additions and 21 deletions

View File

@ -627,7 +627,7 @@ static size_t QDECL Plug_GetLocalPlayerNumbers(size_t first, size_t count, int *
return count;
}
static void QDECL Plug_GetServerInfo(char *outptr, size_t outlen)
static void QDECL Plug_GetServerInfoRaw(char *outptr, size_t outlen)
{
extern float demtime;
@ -664,11 +664,88 @@ static void QDECL Plug_GetServerInfo(char *outptr, size_t outlen)
#endif
Q_strncatz(outptr, va("\\matchstart\\%f", cl.matchgametimestart), outlen);
}
static size_t QDECL Plug_GetServerInfoBlob(const char *key, void *outptr, size_t outsize)
{
char tmp[32];
size_t blobsize;
const char *blob = InfoBuf_BlobForKey(&cl.serverinfo, key, &blobsize, NULL);
if (!blob)
{ //inescapable hacks
if (!strcmp(key, "matchstart"))
snprintf(tmp, sizeof(tmp), "%f", cl.playerview[0].statsf[STAT_MATCHSTARTTIME]?cl.playerview[0].statsf[STAT_MATCHSTARTTIME]/1000:cl.matchgametimestart), blob=tmp;
else if (!strcmp(key, "demotime"))
{
extern float demtime;
snprintf(tmp, sizeof(tmp), "%f", demtime-cls.demostarttime), blob=tmp;
}
else if (!strcmp(key, "demotype"))
{
switch(cls.demoplayback)
{
case DPB_NONE:
break;
case DPB_MVD:
case DPB_EZTV:
blob = "mvd";
break;
case DPB_QUAKEWORLD:
blob = "qw";
break;
#ifdef NQPROT
case DPB_NETQUAKE:
blob = "nq";
break;
#endif
#ifdef Q2CLIENT
case DPB_QUAKE2:
blob = "q2";
break;
#endif
}
}
else if (!strcmp(key, "intermission"))
snprintf(tmp, sizeof(tmp), "%i", cl.intermissionmode), blob=tmp;
if (blob)
blobsize = strlen(blob);
}
if (outptr)
{
if (blobsize > outsize)
return 0; //error
memcpy(outptr, blob, blobsize);
return blobsize;
}
else
return blobsize;
}
static void QDECL Plug_SetUserInfo(int seat, const char *key, const char *value)
{
CL_SetInfo(seat, key, value);
}
static void QDECL Plug_SetUserInfoBlob(int seat, const char *key, const void *value, size_t size)
{
CL_SetInfoBlob(seat, key, value, size);
}
static size_t QDECL Plug_GetUserInfoBlob(int seat, const char *key, void *outptr, size_t outsize)
{
size_t blobsize;
const char *blob;
if (seat >= countof(cls.userinfo))
blob = NULL, blobsize = 0;
else
blob = InfoBuf_BlobForKey(&cls.userinfo[seat], key, &blobsize, NULL);
if (outptr)
{
if (blobsize > outsize)
return 0; //error
memcpy(outptr, blob, blobsize);
return blobsize;
}
else
return blobsize;
}
void QDECL Plug_CL_ClearState(void)
{

View File

@ -549,7 +549,7 @@ void Plug_DrawReloadImages(void);
void Plug_Initialise(qboolean fromgamedir);
void Plug_Shutdown(qboolean preliminary);
qboolean Plug_Menu_Event(int eventtype, int keyparam, int unicodeparam);
void Plug_ResChanged(void);
void Plug_ResChanged(qboolean restarted);
void Plug_SBar(playerview_t *pv);
qboolean Plug_ServerMessage(char *buffer, int messagelevel);
void Plug_Tick(void);

View File

@ -1253,7 +1253,7 @@ void R2D_Font_Changed(void)
mn_entry->Init(MI_RESOLUTION, vid.width, vid.height, vid.rotpixelwidth, vid.rotpixelheight);
#endif
#ifdef PLUGINS
Plug_ResChanged();
Plug_ResChanged(false);
#endif
}

View File

@ -1761,7 +1761,7 @@ TRACE(("dbg: R_ApplyRenderer: clearing world\n"));
}
#endif
#ifdef PLUGINS
Plug_ResChanged();
Plug_ResChanged(true);
#endif
Cvar_ForceCallback(&r_particlesystem);
#ifdef MENU_NATIVECODE

View File

@ -108,7 +108,7 @@ typedef struct plugin_s {
int (QDECL *conexecutecommand)(qboolean isinsecure);
qboolean (QDECL *menufunction)(int eventtype, int keyparam, int unicodeparm, float mousecursor_x, float mousecursor_y, float vidwidth, float vidheight);
int (QDECL *sbarlevel[3])(int seat, float x, float y, float w, float h, unsigned int showscores); //0 - main sbar, 1 - supplementry sbar sections (make sure these can be switched off), 2 - overlays (scoreboard). menus kill all.
void (QDECL *reschange)(int width, int height);
void (QDECL *reschange)(int width, int height, qboolean restarted);
//protocol-in-a-plugin
int (QDECL *connectionlessclientpacket)(const char *buffer, size_t size, netadr_t *from);
@ -283,7 +283,7 @@ static plugin_t *Plug_Load(const char *file)
#ifndef SERVERONLY
if (newplug->reschange)
newplug->reschange(vid.width, vid.height);
newplug->reschange(vid.width, vid.height, false);
#endif
currentplug = NULL;
@ -1285,13 +1285,13 @@ void Plug_Tick(void)
}
#ifndef SERVERONLY
void Plug_ResChanged(void)
void Plug_ResChanged(qboolean restarted)
{
plugin_t *oldplug = currentplug;
for (currentplug = plugs; currentplug; currentplug = currentplug->next)
{
if (currentplug->reschange)
currentplug->reschange(vid.width, vid.height);
currentplug->reschange(vid.width, vid.height, restarted);
}
currentplug = oldplug;
}
@ -2111,8 +2111,11 @@ static void *QDECL PlugBI_GetEngineInterface(const char *interfacename, size_t s
Plug_GetLocalPlayerNumbers,
Plug_GetLocationName,
Plug_GetLastInputFrame,
Plug_GetServerInfo,
Plug_GetServerInfoRaw,
Plug_GetServerInfoBlob,
Plug_SetUserInfo,
Plug_SetUserInfoBlob,
Plug_GetUserInfoBlob,
#if defined(HAVE_SERVER) && defined(HAVE_CLIENT)
Plug_MapLog_Query,
#else

View File

@ -358,7 +358,7 @@ static qboolean browser_handle_query(const char *req, char *buffer, size_t buffe
{
char serverinfo[4096];
char *e = buffer;
clientfuncs->GetServerInfo(serverinfo, sizeof(serverinfo));
clientfuncs->GetServerInfoRaw(serverinfo, sizeof(serverinfo));
e = Info_JSONify(serverinfo, e, buffer + buffersize - e-1);
if (e == buffer) e++;
*buffer = '{';

View File

@ -21,10 +21,14 @@ float alphamul;
cvar_t *scr_newHud;
static void QDECL EZHud_UpdateVideo(int width, int height)
void HUD_InitSbarImages(void);
static void QDECL EZHud_UpdateVideo(int width, int height, qboolean restarted)
{
vid.width = width;
vid.height = height;
if (restarted)
HUD_InitSbarImages();
}
char *Cmd_Argv(int arg)
@ -88,14 +92,14 @@ char *TP_LocationName (const vec3_t location)
void Draw_SPic(float x, float y, mpic_t *pic, float scale)
{
qhandle_t image = (intptr_t)pic;
float w, h;
float w=64, h=64;
drawfuncs->ImageSize(image, &w, &h);
drawfuncs->Image(x, y, w*scale, h*scale, 0, 0, 1, 1, image);
}
void Draw_SSubPic(float x, float y, mpic_t *pic, float s1, float t1, float s2, float t2, float scale)
{
qhandle_t image = (intptr_t)pic;
float w, h;
float w=64, h=64;
drawfuncs->ImageSize(image, &w, &h);
drawfuncs->Image(x, y, (s2-s1)*scale, (t2-t1)*scale, s1/w, t1/h, s2/w, t2/h, image);
}
@ -125,7 +129,7 @@ void SCR_DrawWadString(float x, float y, float scale, char *str)
void Draw_SAlphaSubPic2(float x, float y, mpic_t *pic, float s1, float t1, float s2, float t2, float sw, float sh, float alpha)
{
qhandle_t image = (intptr_t)pic;
float w, h;
float w=64, h=64;
drawfuncs->ImageSize(image, &w, &h);
drawfuncs->Colour4f(1, 1, 1, alpha * alphamul);
drawfuncs->Image(x, y, (s2-s1)*sw, (t2-t1)*sh, s1/w, t1/h, s2/w, t2/h, image);
@ -617,7 +621,7 @@ int EZHud_Draw(int seat, float viewx, float viewy, float viewwidth, float viewhe
clientfuncs->GetPlayerInfo(i, &cl.players[i]);
clientfuncs->GetLocalPlayerNumbers(cl.splitscreenview, 1, &cl.playernum, &cl.tracknum);
clientfuncs->GetServerInfo(cl.serverinfo, sizeof(serverinfo));
clientfuncs->GetServerInfoRaw(cl.serverinfo, sizeof(serverinfo));
cl.deathmatch = infofloat(cl.serverinfo, "deathmatch", 0);
cl.teamplay = infofloat(cl.serverinfo, "teamplay", 0);
cl.intermission = infofloat(cl.serverinfo, "intermission", 0);

View File

@ -63,7 +63,7 @@ static struct
int width;
int height;
} pvid;
static void QDECL IRC_UpdateVideo(int width, int height)
static void QDECL IRC_UpdateVideo(int width, int height, qboolean restarted)
{
pvid.width = width;
pvid.height = height;

View File

@ -891,7 +891,7 @@ int JCL_ConExecuteCommand(qboolean isinsecure);
void JCL_Frame(double realtime, double gametime);
void JCL_Shutdown(void);
static void QDECL JCL_UpdateVideo(int width, int height)
static void QDECL JCL_UpdateVideo(int width, int height, qboolean restarted)
{
pvid.width = width;
pvid.height = height;

View File

@ -297,9 +297,11 @@ typedef struct //q1 client/network info
F(size_t, GetLocalPlayerNumbers,(size_t firstseat, size_t numseats, int *playernums, int *spectracks));
F(void, GetLocationName, (const float *pos, char *outbuffer, size_t bufferlen));
F(qboolean, GetLastInputFrame, (int seat, usercmd_t *outcmd));
F(void, GetServerInfo, (char *info, size_t infolen));
F(void, GetServerInfoRaw, (char *info, size_t infolen));
F(size_t, GetServerInfoBlob, (const char *keyname, void *buf, size_t bufsize)); //pass null buf to query size, returns 0 if it would truncate. does not null terminate.
F(void, SetUserInfo, (int seat, const char *key, const char *value));
F(void, SetUserInfoBlob, (int seat, const char *key, const void *value, size_t size));
F(size_t, GetUserInfoBlob, (int seat, const char *key, void *buf, size_t bufsize)); //pass null buf to query size, returns 0 if it would truncate. does not null terminate.
//EBUILTIN(void, SCR_CenterPrint, (const char *s));
//FIXME: does this belong here?
@ -319,7 +321,7 @@ typedef struct //q1 client/network info
qboolean (*DownloadBegun)(qdownload_t *dl);
void (*DownloadFinished)(qdownload_t *dl);
downloadlist_t *(*DownloadFailed)(const char *name, qdownload_t *qdl, enum dlfailreason_e failreason);
#define plugclientfuncs_name "Client"
#define plugclientfuncs_name "Client2"
} plugclientfuncs_t;
struct menu_s;

View File

@ -48,7 +48,7 @@ static struct
int width;
int height;
} pvid;
static void QDECL QI_UpdateVideo(int width, int height)
static void QDECL QI_UpdateVideo(int width, int height, qboolean restarted)
{
pvid.width = width;
pvid.height = height;