X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=cl_main.c;h=4471edd3d4e24f9e6d645e2444bf406f30e75638;hp=b7f26af02e1e126d8869ad12b70f1527d3ad2bb4;hb=de8cab7a1429f923f9015baf2ce95875900cb5e9;hpb=acdd55a695050845def0dce89ea84b06cb990b0a diff --git a/cl_main.c b/cl_main.c index b7f26af0..4471edd3 100644 --- a/cl_main.c +++ b/cl_main.c @@ -147,7 +147,7 @@ void CL_ClearState(void) // tweak these if the game runs out cl.max_csqcrenderentities = 0; - cl.max_entities = MAX_ENITIES_INITIAL; + cl.max_entities = MAX_ENTITIES_INITIAL; cl.max_static_entities = MAX_STATICENTITIES; cl.max_effects = MAX_EFFECTS; cl.max_beams = MAX_BEAMS; @@ -340,6 +340,16 @@ void CL_ExpandCSQCRenderEntities(int num) } } +static void CL_ToggleMenu_Hook(void) +{ +#ifdef CONFIG_MENU + // remove menu + if (key_dest == key_menu || key_dest == key_menu_grabbed) + MR_ToggleMenu(0); +#endif + key_dest = key_game; +} + extern cvar_t rcon_secure; /* @@ -387,7 +397,7 @@ void CL_Disconnect(void) sizebuf_t buf; unsigned char bufdata[8]; if (cls.demorecording) - CL_Stop_f(&cmd_client); + CL_Stop_f(cmd_local); // send disconnect message 3 times to improve chances of server // receiving it (but it still fails sometimes) @@ -418,8 +428,13 @@ void CL_Disconnect(void) cls.demoplayback = cls.timedemo = host.restless = false; cls.signon = 0; + Cvar_Callback(&cl_netport); + // If we're dropped mid-connection attempt, it won't clear otherwise. SCR_ClearLoadingScreen(false); + + if(host.hook.SV_Shutdown) + host.hook.SV_Shutdown(); } /* @@ -430,7 +445,7 @@ This command causes the client to wait for the signon messages again. This is sent just before a server changes levels ================== */ -void CL_Reconnect_f(cmd_state_t *cmd) +static void CL_Reconnect_f(cmd_state_t *cmd) { char temp[128]; // if not connected, reconnect to the most recent server @@ -500,9 +515,7 @@ static void CL_Connect_f(cmd_state_t *cmd) void CL_Disconnect_f(cmd_state_t *cmd) { - CL_Disconnect (); - if (sv.active) - SV_Shutdown (); + CL_Disconnect(); } @@ -529,9 +542,6 @@ void CL_EstablishConnection(const char *address, int firstarg) M_Update_Return_Reason(""); #endif - // Disconnect from the current server, or stop a running demo. - CL_Disconnect(); - // make sure the client ports are open before attempting to connect NetConn_UpdateSockets(); @@ -546,8 +556,8 @@ void CL_EstablishConnection(const char *address, int firstarg) { int i; *cls.connect_userinfo = 0; - for(i = firstarg; i+2 <= Cmd_Argc(&cmd_client); i += 2) - InfoString_SetValue(cls.connect_userinfo, sizeof(cls.connect_userinfo), Cmd_Argv(&cmd_client, i), Cmd_Argv(&cmd_client, i+1)); + for(i = firstarg; i+2 <= Cmd_Argc(cmd_local); i += 2) + InfoString_SetValue(cls.connect_userinfo, sizeof(cls.connect_userinfo), Cmd_Argv(cmd_local, i), Cmd_Argv(cmd_local, i+1)); } else if(firstarg < -1) { @@ -575,6 +585,11 @@ static void CL_EstablishConnection_Local(void) CL_EstablishConnection("local:1", -2); } +static qbool CL_Intermission(void) +{ + return cl.intermission; +} + /* ============== CL_PrintEntities_f @@ -610,7 +625,7 @@ List information on all models in the client modelindex static void CL_ModelIndexList_f(cmd_state_t *cmd) { int i; - dp_model_t *model; + model_t *model; // Print Header Con_Printf("%3s: %-30s %-8s %-8s\n", "ID", "Name", "Type", "Triangles"); @@ -657,7 +672,7 @@ void CL_UpdateRenderEntity(entity_render_t *ent) { vec3_t org; vec_t scale; - dp_model_t *model = ent->model; + model_t *model = ent->model; // update the inverse matrix for the renderer Matrix4x4_Invert_Simple(&ent->inversematrix, &ent->matrix); // update the animation blend state @@ -767,7 +782,7 @@ entity_render_t *CL_NewTempEntity(double shadertime) return render; } -void CL_Effect(vec3_t org, dp_model_t *model, int startframe, int framecount, float framerate) +void CL_Effect(vec3_t org, model_t *model, int startframe, int framecount, float framerate) { int i; cl_effect_t *e; @@ -2464,7 +2479,7 @@ void CL_Locs_Reload_f(cmd_state_t *cmd) } entity_t cl_meshentities[NUM_MESHENTITIES]; -dp_model_t cl_meshentitymodels[NUM_MESHENTITIES]; +model_t cl_meshentitymodels[NUM_MESHENTITIES]; const char *cl_meshentitynames[NUM_MESHENTITIES] = { "MESH_SCENE", @@ -2716,6 +2731,21 @@ void CL_UpdateEntityShading(void) CL_UpdateEntityShading_Entity(r_refdef.scene.entities[i]); } +qbool vid_opened = false; +void CL_StartVideo(void) +{ + if (!vid_opened && cls.state != ca_dedicated) + { + vid_opened = true; +#ifdef WIN32 + // make sure we open sockets before opening video because the Windows Firewall "unblock?" dialog can screw up the graphics context on some graphics drivers + NetConn_UpdateSockets(); +#endif + VID_Start(); + CDAudio_Startup(); + } +} + extern cvar_t host_framerate; extern cvar_t host_speeds; @@ -2724,7 +2754,6 @@ double CL_Frame (double time) static double clframetime; static double cl_timer = 0; static double time1 = 0, time2 = 0, time3 = 0; - static double wait; int pass1, pass2, pass3; CL_VM_PreventInformationLeaks(); @@ -2767,9 +2796,8 @@ double CL_Frame (double time) { clframetime = cl.realframetime = max(cl_timer, 1.0 / cl_maxfps.value); // when running slow, we need to sleep to keep input responsive - wait = bound(0, cl_maxfps_alwayssleep.value * 1000, 100000); - if (wait > 0) - Sys_Sleep((int)wait); + if (cl_maxfps_alwayssleep.value > 0) + Sys_Sleep((int)bound(0, cl_maxfps_alwayssleep.value * 1000, 100000)); } else if (!vid_activewindow && cl_maxidlefps.value >= 1 && !cls.timedemo) clframetime = cl.realframetime = max(cl_timer, 1.0 / cl_maxidlefps.value); @@ -2923,6 +2951,8 @@ void CL_Init (void) { Con_Printf("Initializing client\n"); + Cvar_SetValueQuick(&host_isclient, 1); + R_Modules_Init(); Palette_Init(); #ifdef CONFIG_MENU @@ -3055,6 +3085,11 @@ void CL_Init (void) CL_Video_Init(); + NetConn_UpdateSockets_Client(); + host.hook.ConnectLocal = CL_EstablishConnection_Local; + host.hook.Disconnect = CL_Disconnect; + host.hook.CL_Intermission = CL_Intermission; + host.hook.ToggleMenu = CL_ToggleMenu_Hook; } }