]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Merge branch 'Mario/dpk_support' of gitlab.com:xonotic/darkplaces
authorCloudwalk <cloudwalk009@gmail.com>
Thu, 22 Jul 2021 01:47:14 +0000 (21:47 -0400)
committerCloudwalk <cloudwalk009@gmail.com>
Thu, 22 Jul 2021 01:47:14 +0000 (21:47 -0400)
1  2 
cl_parse.c
fs.c
sv_main.c

diff --combined cl_parse.c
index 5cbcb8b269c27b7d4563d3f3ac3138d61f5ec04e,2a4b29e2c95a8a5d7ca949d192b266b83cb014da..326c1fc0eff4e2a6ce8eb15c43eacfd9642c2e3f
@@@ -35,7 -35,7 +35,7 @@@ const char *svc_strings[128] 
  {
        "svc_bad",
        "svc_nop",
 -      "svc_disconnect",
 +      "svc_disconnect",       // (DP8) [string] null terminated parting message
        "svc_updatestat",
        "svc_version",          // [int] server version
        "svc_setview",          // [short] entity number
@@@ -1448,7 -1448,7 +1448,7 @@@ static void CL_StopDownload(int size, i
                                Con_Printf("Downloaded \"%s\" (%i bytes, %i CRC)\n", cls.qw_downloadname, size, crc);
                                FS_WriteFile(cls.qw_downloadname, cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
                                extension = FS_FileExtension(cls.qw_downloadname);
-                               if (!strcasecmp(extension, "pak") || !strcasecmp(extension, "pk3"))
+                               if (!strcasecmp(extension, "pak") || !strcasecmp(extension, "pk3") || !strcasecmp(extension, "dpk"))
                                        FS_Rescan();
                        }
                }
@@@ -3391,10 -3391,8 +3391,10 @@@ static void CL_NetworkTimeReceived(doub
        // update the csqc's server timestamps, critical for proper sync
        CSQC_UpdateNetworkTimes(cl.mtime[0], cl.mtime[1]);
  
 +#ifdef USEODE
        if (cl.mtime[0] > cl.mtime[1])
                World_Physics_Frame(&cl.world, cl.mtime[0] - cl.mtime[1], cl.movevars_gravity);
 +#endif
  
        // only lerp entities that also get an update in this frame, when lerp excess is used
        if(cl_lerpexcess.value > 0)
@@@ -3531,7 -3529,7 +3531,7 @@@ void CL_ParseServerMessage(void
                                if (cls.demonum != -1)
                                        CL_NextDemo();
                                else
 -                                      CL_Disconnect();
 +                                      CL_Disconnect(true, NULL);
                                break;
  
                        case qw_svc_print:
                                if (cls.demonum != -1)
                                        CL_NextDemo();
                                else
 -                                      CL_Disconnect();
 +                                      CL_Disconnect(true, cls.protocol == PROTOCOL_DARKPLACES8 ? MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)) : NULL);
                                break;
  
                        case svc_print:
diff --combined fs.c
index 97259f722eb73534781b23c7e3d835cc3733ec06,f8266c71a2a7e7e10b4ee3c21f1d533f6e657010..f5f4d6b917f0d458fc89065ccc9f8bae626b64fd
--- 1/fs.c
--- 2/fs.c
+++ b/fs.c
@@@ -1138,11 -1138,11 +1138,11 @@@ static qbool FS_AddPack_Fullpath(const 
        if(already_loaded)
                *already_loaded = false;
  
-       if(!strcasecmp(ext, "pk3dir"))
+       if(!strcasecmp(ext, "pk3dir") || !strcasecmp(ext, "dpkdir"))
                pak = FS_LoadPackVirtual (pakfile);
        else if(!strcasecmp(ext, "pak"))
                pak = FS_LoadPackPAK (pakfile);
-       else if(!strcasecmp(ext, "pk3"))
+       else if(!strcasecmp(ext, "pk3") || !strcasecmp(ext, "dpk"))
                pak = FS_LoadPackPK3 (pakfile);
        else if(!strcasecmp(ext, "obb")) // android apk expansion
                pak = FS_LoadPackPK3 (pakfile);
                if(pak->vpack)
                {
                        dpsnprintf(search->filename, sizeof(search->filename), "%s/", pakfile);
-                       // if shortname ends with "pk3dir", strip that suffix to make it just "pk3"
+                       // if shortname ends with "pk3dir" or "dpkdir", strip that suffix to make it just "pk3" or "dpk"
                        // same goes for the name inside the pack structure
                        l = strlen(pak->shortname);
                        if(l >= 7)
-                               if(!strcasecmp(pak->shortname + l - 7, ".pk3dir"))
+                               if(!strcasecmp(pak->shortname + l - 7, ".pk3dir") || !strcasecmp(pak->shortname + l - 7, ".dpkdir"))
                                        pak->shortname[l - 3] = 0;
                        l = strlen(pak->filename);
                        if(l >= 7)
-                               if(!strcasecmp(pak->filename + l - 7, ".pk3dir"))
+                               if(!strcasecmp(pak->filename + l - 7, ".pk3dir") || !strcasecmp(pak->filename + l - 7, ".dpkdir"))
                                        pak->filename[l - 3] = 0;
                }
                return true;
@@@ -1287,7 -1287,8 +1287,8 @@@ static void FS_AddGameDirectory (const 
        // add any PK3 package in the directory
        for (i = 0;i < list.numstrings;i++)
        {
-               if (!strcasecmp(FS_FileExtension(list.strings[i]), "pk3") || !strcasecmp(FS_FileExtension(list.strings[i]), "obb") || !strcasecmp(FS_FileExtension(list.strings[i]), "pk3dir"))
+               if (!strcasecmp(FS_FileExtension(list.strings[i]), "pk3") || !strcasecmp(FS_FileExtension(list.strings[i]), "obb") || !strcasecmp(FS_FileExtension(list.strings[i]), "pk3dir")
+                       || !strcasecmp(FS_FileExtension(list.strings[i]), "dpk") || !strcasecmp(FS_FileExtension(list.strings[i]), "dpkdir"))
                {
                        FS_AddPack_Fullpath(list.strings[i], list.strings[i] + strlen(dir), NULL, false);
                }
@@@ -1577,7 -1578,7 +1578,7 @@@ qbool FS_ChangeGameDirs(int numgamedirs
  
        if (cls.demoplayback)
        {
 -              CL_Disconnect();
 +              CL_Disconnect(false, NULL);
                cls.demonum = 0;
        }
  
@@@ -1628,7 -1629,7 +1629,7 @@@ static void FS_GameDir_f(cmd_state_t *c
        }
  
        // halt demo playback to close the file
 -      CL_Disconnect();
 +      CL_Disconnect(false, NULL);
  
        FS_ChangeGameDirs(numgamedirs, gamedirs, true, true);
  }
diff --combined sv_main.c
index 777d3e577959ff730fbaa2ce4a53a34f46d1dce6,7754a35272c742cd698d35be3efef2f3374e552b..4479a30e6a77ad4e2eb0a46cee9bd8f4751cb243
+++ b/sv_main.c
@@@ -526,8 -526,8 +526,8 @@@ void SV_Init (void
        Cvar_RegisterVariable (&skill);
        Cvar_RegisterVariable (&host_timescale);
        Cvar_RegisterCallback (&host_timescale, Host_Timescale_c);
 -      Cvar_RegisterAlias (&host_timescale, "slowmo");
 -      Cvar_RegisterAlias (&host_timescale, "timescale");
 +      Cvar_RegisterVirtual (&host_timescale, "slowmo");
 +      Cvar_RegisterVirtual (&host_timescale, "timescale");
        Cvar_RegisterVariable (&sv_accelerate);
        Cvar_RegisterVariable (&sv_aim);
        Cvar_RegisterVariable (&sv_airaccel_qw);
        Cvar_RegisterVariable (&sv_protocolname);
        Cvar_RegisterVariable (&sv_random_seed);
        Cvar_RegisterVariable (&host_limitlocal);
 -      Cvar_RegisterAlias(&host_limitlocal, "sv_ratelimitlocalplayer");
 +      Cvar_RegisterVirtual(&host_limitlocal, "sv_ratelimitlocalplayer");
        Cvar_RegisterVariable (&sv_sound_land);
        Cvar_RegisterVariable (&sv_sound_watersplash);
        Cvar_RegisterVariable (&sv_stepheight);
@@@ -984,31 -984,14 +984,31 @@@ void SV_ConnectClient (int clientnum, n
  SV_DropClient
  
  Called when the player is getting totally kicked off the host
 -if (crash = true), don't bother sending signofs
 +if (leaving = true), don't bother sending signofs
  =====================
  */
 -void SV_DropClient(qbool crash)
 +void SV_DropClient(qbool leaving, const char *fmt, ... )
  {
        prvm_prog_t *prog = SVVM_prog;
        int i;
 -      Con_Printf("Client \"%s\" dropped\n", host_client->name);
 +
 +      va_list argptr;
 +      char reason[512] = "";
 +
 +      Con_Printf("Client \"%s\" dropped", host_client->name);
 +
 +      if(fmt)
 +      {
 +              va_start(argptr, fmt);
 +              dpvsnprintf(reason, sizeof(reason), fmt, argptr);
 +              va_end(argptr);
 +
 +              Con_Printf(" (%s)\n", reason);
 +      }
 +      else
 +      {
 +              Con_Printf(" \n");
 +      }
  
        SV_StopDemoRecording(host_client);
  
        if (host_client->netconnection)
        {
                // tell the client to be gone
 -              if (!crash)
 +              if (!leaving)
                {
                        // LadyHavoc: no opportunity for resending, so use unreliable 3 times
 -                      unsigned char bufdata[8];
 +                      unsigned char bufdata[520]; // Disconnect reason string can be 512 characters
                        sizebuf_t buf;
                        memset(&buf, 0, sizeof(buf));
                        buf.data = bufdata;
                        buf.maxsize = sizeof(bufdata);
                        MSG_WriteByte(&buf, svc_disconnect);
 +                      if(fmt)
 +                      {
 +                              if(sv.protocol == PROTOCOL_DARKPLACES8)
 +                                      MSG_WriteString(&buf, reason);
 +                              else
 +                                      SV_ClientPrintf("%s\n", reason);
 +                      }
                        NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, 0, false);
                        NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, 0, false);
                        NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, 0, false);
                NetConn_Close(host_client->netconnection);
                host_client->netconnection = NULL;
        }
 +      if(fmt)
 +              SV_BroadcastPrintf("\003^3%s left the game (%s)\n", host_client->name, reason);
 +      else
 +              SV_BroadcastPrintf("\003^3%s left the game\n", host_client->name);
  
        // if a download is active, close it
        if (host_client->download_file)
@@@ -1302,7 -1274,7 +1302,7 @@@ static void SV_Download_f(cmd_state_t *
  
        if (!sv_allowdownloads_archive.integer)
        {
-               if (!strcasecmp(extension, "pak") || !strcasecmp(extension, "pk3"))
+               if (!strcasecmp(extension, "pak") || !strcasecmp(extension, "pk3") || !strcasecmp(extension, "dpk"))
                {
                        SV_ClientPrintf("Download rejected: file \"%s\" is an archive\nYou must separately download or purchase the data archives for this game/mod to get this file\n", host_client->download_name);
                        SV_ClientCommands("\nstopdownload\n");
@@@ -1584,7 -1556,7 +1584,7 @@@ model_t *SV_GetModelFromEdict(prvm_edic
  {
        prvm_prog_t *prog = SVVM_prog;
        int modelindex;
 -      if (!ed || ed->priv.server->free)
 +      if (!ed || ed->free)
                return NULL;
        modelindex = (int)PRVM_serveredictfloat(ed, modelindex);
        return (modelindex > 0 && modelindex < MAX_MODELS) ? sv.models[modelindex] : NULL;
@@@ -1611,7 -1583,7 +1611,7 @@@ static void SV_CreateBaseline (void
                // LadyHavoc: always clear state values, whether the entity is in use or not
                svent->priv.server->baseline = defaultstate;
  
 -              if (svent->priv.server->free)
 +              if (svent->free)
                        continue;
                if (entnum > svs.maxclients && !PRVM_serveredictfloat(svent, modelindex))
                        continue;
@@@ -1965,7 -1937,7 +1965,7 @@@ void SV_SpawnServer (const char *map
        // AK possible hack since num_edicts is still 0
        ent = PRVM_EDICT_NUM(0);
        memset (ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
 -      ent->priv.server->free = false;
 +      ent->free = false;
        PRVM_serveredictstring(ent, model) = PRVM_SetEngineString(prog, sv.worldname);
        PRVM_serveredictfloat(ent, modelindex) = 1;             // world model
        PRVM_serveredictfloat(ent, solid) = SOLID_BSP;
@@@ -2111,7 -2083,7 +2111,7 @@@ void SV_Shutdown(void
        }
        for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
                if (host_client->active)
 -                      SV_DropClient(false); // server shutdown
 +                      SV_DropClient(false, "Server shutting down"); // server shutdown
  
        NetConn_CloseServerPorts();
  
@@@ -2141,7 -2113,7 +2141,7 @@@ static void SVVM_end_increase_edicts(pr
  
        // link every entity except world
        for (i = 1, ent = prog->edicts;i < prog->num_edicts;i++, ent++)
 -              if (!ent->priv.server->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax)))
 +              if (!ent->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax)))
                        SV_LinkEdict(ent);
  }
  
@@@ -2217,10 -2189,9 +2217,10 @@@ static void SVVM_free_edict(prvm_prog_
        PRVM_serveredictfloat(ed, solid) = 0;
  
        VM_RemoveEdictSkeleton(prog, ed);
 +#ifdef USEODE
        World_Physics_RemoveFromEntity(&sv.world, ed);
        World_Physics_RemoveJointFromEntity(&sv.world, ed);
 -
 +#endif
        // make sure csqc networking is aware of the removed entity
        e = PRVM_NUM_FOR_EDICT(ed);
        sv.csqcentityversion[e] = 0;
@@@ -2238,7 -2209,7 +2238,7 @@@ static void SVVM_count_edicts(prvm_prog
        for (i=0 ; i<prog->num_edicts ; i++)
        {
                ent = PRVM_EDICT_NUM(i);
 -              if (ent->priv.server->free)
 +              if (ent->free)
                        continue;
                active++;
                if (PRVM_serveredictfloat(ent, solid))
@@@ -2474,8 -2445,17 +2474,8 @@@ static void SV_CheckTimeouts(void
  
        // never timeout loopback connections
        for (i = (host_isclient.integer ? 1 : 0), host_client = &svs.clients[i]; i < svs.maxclients; i++, host_client++)
 -      {
                if (host_client->netconnection && host.realtime > host_client->netconnection->timeout)
 -              {
 -                      if (host_client->begun)
 -                              SV_BroadcastPrintf("Client \"%s\" connection timed out\n", host_client->name);
 -                      else
 -                              Con_Printf("Client \"%s\" connection timed out\n", host_client->name);
 -
 -                      SV_DropClient(false);
 -              }
 -      }
 +                      SV_DropClient(false, "Timed out");
  }
  
  /*