Skip to content

Commit

Permalink
Try to fix purecsqc map loading issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shpoike committed Apr 17, 2023
1 parent f2d54f3 commit e104d6c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ qboolean CL_MayLerp(void);
//
#ifdef CSQC_DAT
qboolean CSQC_Inited(void);
void CSQC_RendererRestarted(void);
void CSQC_RendererRestarted(qboolean initing);
qboolean CSQC_UnconnectedOkay(qboolean inprinciple);
qboolean CSQC_UnconnectedInit(void);
qboolean CSQC_CheckDownload(const char *name, unsigned int checksum, size_t checksize); //reports whether we already have a usable csprogs.dat
Expand Down
36 changes: 28 additions & 8 deletions engine/client/pr_csqc.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ static model_t *CSQC_GetModelForIndex(int index)
else if (index < 0 && index > -MAX_CSMODELS)
{
if (!cl.model_csqcprecache[-index])
cl.model_csqcprecache[-index] = Mod_ForName(Mod_FixName(cl.model_csqcname[-index], csqc_world.worldmodel->publicname), MLV_WARN);
cl.model_csqcprecache[-index] = Mod_ForName(Mod_FixName(cl.model_csqcname[-index], csqc_world.worldmodel?csqc_world.worldmodel->publicname:NULL), MLV_WARN);
return cl.model_csqcprecache[-index];
}
else
Expand Down Expand Up @@ -2770,7 +2770,8 @@ static void QCBUILTIN PF_R_RenderScene(pubprogfuncs_t *prinst, struct globalvars
{
csqc_worldchanged = false;
cl.worldmodel = r_worldentity.model = csqc_world.worldmodel;
FS_LoadMapPackFile(cl.worldmodel->name, cl.worldmodel->archive);
if (cl.worldmodel)
FS_LoadMapPackFile(cl.worldmodel->name, cl.worldmodel->archive);
Surf_NewMap(csqc_world.worldmodel);
CL_UpdateWindowTitle();

Expand Down Expand Up @@ -8552,7 +8553,7 @@ qboolean CSQC_Init (qboolean anycsqc, const char *csprogsname, unsigned int chec

csqc_world.physicstime = 0.1;

CSQC_RendererRestarted();
CSQC_RendererRestarted(true);

if (cls.state == ca_disconnected)
CSQC_WorldLoaded();
Expand All @@ -8561,17 +8562,36 @@ qboolean CSQC_Init (qboolean anycsqc, const char *csprogsname, unsigned int chec
return true; //success!
}

void CSQC_RendererRestarted(void)
void CSQC_RendererRestarted(qboolean initing)
{
int i;
if (!csqcprogs)
return;

csqc_world.worldmodel = cl.worldmodel;

for (i = 0; i < MAX_CSMODELS; i++)
if (initing)
{
cl.model_csqcprecache[i] = NULL;
//called at startup
if (csqc_worldchanged)
{
csqc_worldchanged = false;
cl.worldmodel = r_worldentity.model = csqc_world.worldmodel;
if (cl.worldmodel)
FS_LoadMapPackFile(cl.worldmodel->name, cl.worldmodel->archive);
Surf_NewMap(csqc_world.worldmodel);
CL_UpdateWindowTitle();

World_RBE_Shutdown(&csqc_world);
World_RBE_Start(&csqc_world);
}
}
else
{ //FIXME: this might be awkward in the purecsqc case.
csqc_world.worldmodel = cl.worldmodel;

for (i = 0; i < MAX_CSMODELS; i++)
{
cl.model_csqcprecache[i] = NULL;
}
}

//FIXME: registered shaders
Expand Down
2 changes: 1 addition & 1 deletion engine/client/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@ TRACE(("dbg: R_ApplyRenderer: efrags\n"));
#endif
#ifdef CSQC_DAT
Shader_DoReload();
CSQC_RendererRestarted();
CSQC_RendererRestarted(false);
#endif
#ifdef MENU_DAT
MP_RendererRestarted();
Expand Down

0 comments on commit e104d6c

Please sign in to comment.