More conversion

This commit is contained in:
iikorni
2026-08-29 19:17:46 -05:00
parent 0404d430dc
commit 70e5c02355
72 changed files with 13308 additions and 14309 deletions
+55 -46
View File
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//gl_sky.c
#include <sstream>
#include "quakedef.hpp"
#define MAX_CLIP_VERTS 64
@@ -40,11 +42,11 @@ static char skybox_name[1024]; //name of current skybox, or "" if no skybox
static gltexture_t *skybox_textures[6];
static gltexture_t *solidskytexture, *alphaskytexture;
extern cvar_t gl_farclip;
static cvar_t r_fastsky = {"r_fastsky", "0", CVAR_NONE};
static cvar_t r_sky_quality = {"r_sky_quality", "12", CVAR_NONE};
static cvar_t r_skyalpha = {"r_skyalpha", "1", CVAR_NONE};
static cvar_t r_skyfog = {"r_skyfog","0.5",CVAR_NONE};
extern convar gl_farclip;
static convar r_fastsky{"r_fastsky", "0"};
static convar r_sky_quality{"r_sky_quality", "12"};
static convar r_skyalpha{"r_skyalpha", "1"};
static convar r_skyfog{"r_skyfog","0.5"};
static const int skytexorder[6] = {0,2,1,3,4,5}; //for skybox
@@ -298,53 +300,60 @@ Sky_NewMap
*/
void Sky_NewMap (void)
{
char key[128], value[4096];
const char *data;
skyfog = r_skyfog.value;
std::string key{};
std::string value{};
//
// read worldspawn (this is so ugly, and shouldn't it be done on the server?)
//
data = cl.worldmodel->entities;
if (!data)
std::istringstream ss{cl.worldmodel->entities};
if (ss.eof())
return; //FIXME: how could this possibly ever happen? -- if there's no
// worldspawn then the sever wouldn't send the loadmap message to the client
data = COM_Parse(data);
if (!data) //should never happen
auto token = common::parse_token(ss);
if (!token.has_value()) {
//should never happen
return; // error
if (com_token[0] != '{') //should never happen
}
if (token->front() != '{') {
//should never happen
return; // error
while (1)
}
while (true)
{
data = COM_Parse(data);
if (!data)
token = common::parse_token(ss);
if (!token.has_value()) {
return; // error
if (com_token[0] == '}')
}
if (token->front() == '}') {
break; // end of worldspawn
if (com_token[0] == '_')
q_strlcpy(key, com_token + 1, sizeof(key));
else
q_strlcpy(key, com_token, sizeof(key));
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
data = COM_ParseEx(data, CPE_ALLOWTRUNC);
if (!data)
}
if (token->front() == '_') {
key = token->substr(1);
}
else {
key = token.value();
}
while (!key.empty() && key.back() == ' ') {
key.pop_back();
}
token = common::parse_token(ss);
if (!token.has_value()) {
return; // error
q_strlcpy(value, com_token, sizeof(value));
}
value = token.value();
if (!strcmp("sky", key))
Sky_LoadSkyBox(value);
if (key == "sky" || key == "skyname" || key == "qlsky") {
Sky_LoadSkyBox(value.c_str());
}
if (!strcmp("skyfog", key))
skyfog = atof(value);
#if 1 /* also accept non-standard keys */
else if (!strcmp("skyname", key)) //half-life
Sky_LoadSkyBox(value);
else if (!strcmp("qlsky", key)) //quake lives
Sky_LoadSkyBox(value);
#endif
if (key == "skyfog") {
skyfog = std::strtof(value.c_str(), nullptr);
}
}
}
@@ -355,13 +364,13 @@ Sky_SkyCommand_f
*/
void Sky_SkyCommand_f (void)
{
switch (Cmd_Argc())
switch (command::argc())
{
case 1:
Con_Printf("\"sky\" is \"%s\"\n", skybox_name);
break;
case 2:
Sky_LoadSkyBox(Cmd_Argv(1));
Sky_LoadSkyBox(command::argv(1)->c_str());
break;
default:
Con_Printf("usage: sky <skyname>\n");
@@ -373,7 +382,7 @@ void Sky_SkyCommand_f (void)
R_SetSkyfog_f -- ericw
====================
*/
static void R_SetSkyfog_f (cvar_t *var)
static void R_SetSkyfog_f (convar *var)
{
// clear any skyfog setting from worldspawn
skyfog = var->value;
@@ -388,13 +397,13 @@ void Sky_Init (void)
{
int i;
Cvar_RegisterVariable (&r_fastsky);
Cvar_RegisterVariable (&r_sky_quality);
Cvar_RegisterVariable (&r_skyalpha);
Cvar_RegisterVariable (&r_skyfog);
Cvar_SetCallback (&r_skyfog, R_SetSkyfog_f);
r_fastsky.inscribe();
r_sky_quality.inscribe();
r_skyalpha.inscribe();
r_skyfog.inscribe();
r_skyfog.set_callback(R_SetSkyfog_f);
Cmd_AddCommand ("sky",Sky_SkyCommand_f);
command::add ("sky",Sky_SkyCommand_f);
skybox_name[0] = 0;
for (i=0; i<6; i++)
@@ -1020,7 +1029,7 @@ void Sky_DrawFace (int axis)
VectorSubtract(verts[2],verts[3],up);
VectorSubtract(verts[2],verts[1],right);
di = q_max((int)r_sky_quality.value, 1);
di = std::max((int)r_sky_quality.value, 1);
qi = 1.0 / di;
dj = (axis < 4) ? di*2 : di; //subdivide vertically more than horizontally on skybox sides
qj = 1.0 / dj;