mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 09:34:35 -05:00
unify HttpComponent, start renaming col to color
This commit is contained in:
parent
0d42e6f48c
commit
d17b91ea1a
12 changed files with 64 additions and 71 deletions
|
@ -19,7 +19,7 @@ void AxisLinesRenderer_Render(void) {
|
|||
1,2,2, 1,2,4, 3,2,4, 3,2,2, /* Z arrow */
|
||||
1,2,3, 1,4,3, 3,4,1, 3,2,1, /* Y arrow */
|
||||
};
|
||||
static const PackedCol cols[3] = {
|
||||
static const PackedCol colors[3] = {
|
||||
PackedCol_Make(255, 0, 0, 255), /* Red */
|
||||
PackedCol_Make( 0, 0, 255, 255), /* Blue */
|
||||
PackedCol_Make( 0, 255, 0, 255), /* Green */
|
||||
|
@ -51,7 +51,7 @@ void AxisLinesRenderer_Render(void) {
|
|||
v->X = coords[indices[i*3 + 0]].X;
|
||||
v->Y = coords[indices[i*3 + 1]].Y;
|
||||
v->Z = coords[indices[i*3 + 2]].Z;
|
||||
v->Col = cols[i >> 2];
|
||||
v->Col = colors[i >> 2];
|
||||
}
|
||||
|
||||
Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED);
|
||||
|
|
12
src/Block.c
12
src/Block.c
|
@ -36,12 +36,12 @@ static float DefaultSet_FogDensity(BlockID b) {
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
static PackedCol DefaultSet_FogColour(BlockID b) {
|
||||
PackedCol colWater = PackedCol_Make( 5, 5, 51, 255);
|
||||
PackedCol colLava = PackedCol_Make(153, 25, 0, 255);
|
||||
static PackedCol DefaultSet_FogColor(BlockID b) {
|
||||
PackedCol colorWater = PackedCol_Make( 5, 5, 51, 255);
|
||||
PackedCol colorLava = PackedCol_Make(153, 25, 0, 255);
|
||||
|
||||
if (b == BLOCK_WATER || b == BLOCK_STILL_WATER) return colWater;
|
||||
if (b == BLOCK_LAVA || b == BLOCK_STILL_LAVA) return colLava;
|
||||
if (b == BLOCK_WATER || b == BLOCK_STILL_WATER) return colorWater;
|
||||
if (b == BLOCK_LAVA || b == BLOCK_STILL_LAVA) return colorLava;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ void Block_ResetProps(BlockID block) {
|
|||
|
||||
Blocks.BlocksLight[block] = DefaultSet_BlocksLight(block);
|
||||
Blocks.FullBright[block] = DefaultSet_FullBright(block);
|
||||
Blocks.FogCol[block] = DefaultSet_FogColour(block);
|
||||
Blocks.FogCol[block] = DefaultSet_FogColor(block);
|
||||
Blocks.FogDensity[block] = DefaultSet_FogDensity(block);
|
||||
Block_SetCollide(block, DefaultSet_Collide(block));
|
||||
Blocks.DigSounds[block] = DefaultSet_DigSound(block);
|
||||
|
|
|
@ -250,5 +250,5 @@ void Gfx_RestoreAlphaState(cc_uint8 draw);
|
|||
/* Binds then renders the given texture. */
|
||||
void Texture_Render(const struct Texture* tex);
|
||||
/* Binds then renders the given texture. */
|
||||
void Texture_RenderShaded(const struct Texture* tex, PackedCol shadeCol);
|
||||
void Texture_RenderShaded(const struct Texture* tex, PackedCol shadeColor);
|
||||
#endif
|
||||
|
|
|
@ -376,7 +376,7 @@ void Gfx_DisableMipmaps(void) {
|
|||
static D3DFOGMODE gfx_fogMode = D3DFOG_NONE;
|
||||
static cc_bool gfx_alphaTesting, gfx_alphaBlending;
|
||||
static cc_bool gfx_depthTesting, gfx_depthWriting;
|
||||
static PackedCol gfx_clearCol, gfx_fogCol;
|
||||
static PackedCol gfx_clearColor, gfx_fogColor;
|
||||
static float gfx_fogEnd = -1.0f, gfx_fogDensity = -1.0f;
|
||||
|
||||
/* NOTE: Although SetRenderState is okay to call on a lost device, it's also possible */
|
||||
|
@ -398,11 +398,11 @@ void Gfx_SetFog(cc_bool enabled) {
|
|||
}
|
||||
|
||||
void Gfx_SetFogCol(PackedCol col) {
|
||||
if (col == gfx_fogCol) return;
|
||||
gfx_fogCol = col;
|
||||
if (col == gfx_fogColor) return;
|
||||
gfx_fogColor = col;
|
||||
|
||||
if (Gfx.LostContext) return;
|
||||
IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, gfx_fogCol);
|
||||
IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, gfx_fogColor);
|
||||
}
|
||||
|
||||
void Gfx_SetFogDensity(float value) {
|
||||
|
@ -457,7 +457,7 @@ void Gfx_SetAlphaArgBlend(cc_bool enabled) {
|
|||
IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, op);
|
||||
}
|
||||
|
||||
void Gfx_ClearCol(PackedCol col) { gfx_clearCol = col; }
|
||||
void Gfx_ClearCol(PackedCol col) { gfx_clearColor = col; }
|
||||
void Gfx_SetColWriteMask(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
||||
DWORD channels = (r ? 1u : 0u) | (g ? 2u : 0u) | (b ? 4u : 0u) | (a ? 8u : 0u);
|
||||
if (Gfx.LostContext) return;
|
||||
|
@ -482,7 +482,7 @@ static void D3D9_RestoreRenderStates(void) {
|
|||
IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, gfx_alphaBlending);
|
||||
|
||||
IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, gfx_fogEnabled);
|
||||
IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, gfx_fogCol);
|
||||
IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, gfx_fogColor);
|
||||
raw.f = gfx_fogDensity;
|
||||
IDirect3DDevice9_SetRenderState(device, D3DRS_FOGDENSITY, raw.u);
|
||||
raw.f = gfx_fogEnd;
|
||||
|
@ -748,7 +748,7 @@ void Gfx_BeginFrame(void) {
|
|||
|
||||
void Gfx_Clear(void) {
|
||||
DWORD flags = D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER;
|
||||
cc_result res = IDirect3DDevice9_Clear(device, 0, NULL, flags, gfx_clearCol, 0.0f, 0);
|
||||
cc_result res = IDirect3DDevice9_Clear(device, 0, NULL, flags, gfx_clearColor, 0.0f, 0);
|
||||
if (res) Logger_Abort2(res, "D3D9_Clear");
|
||||
}
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ void Gfx_DisableMipmaps(void) { }
|
|||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------State management----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static PackedCol gfx_clearCol, gfx_fogCol;
|
||||
static PackedCol gfx_clearColor, gfx_fogColor;
|
||||
static float gfx_fogEnd = -1.0f, gfx_fogDensity = -1.0f;
|
||||
static int gfx_fogMode = -1;
|
||||
|
||||
|
@ -246,9 +246,9 @@ static void GL_ClearCol(PackedCol col) {
|
|||
PackedCol_B(col) / 255.0f, PackedCol_A(col) / 255.0f);
|
||||
}
|
||||
void Gfx_ClearCol(PackedCol col) {
|
||||
if (col == gfx_clearCol) return;
|
||||
if (col == gfx_clearColor) return;
|
||||
GL_ClearCol(col);
|
||||
gfx_clearCol = col;
|
||||
gfx_clearColor = col;
|
||||
}
|
||||
|
||||
void Gfx_SetColWriteMask(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
||||
|
@ -734,8 +734,8 @@ static void ReloadUniforms(void) {
|
|||
s->uniforms &= ~UNI_TEX_OFFSET;
|
||||
}
|
||||
if ((s->uniforms & UNI_FOG_COL) && (s->features & FTR_HASANY_FOG)) {
|
||||
glUniform3f(s->locations[2], PackedCol_R(gfx_fogCol) / 255.0f, PackedCol_G(gfx_fogCol) / 255.0f,
|
||||
PackedCol_B(gfx_fogCol) / 255.0f);
|
||||
glUniform3f(s->locations[2], PackedCol_R(gfx_fogColor) / 255.0f, PackedCol_G(gfx_fogColor) / 255.0f,
|
||||
PackedCol_B(gfx_fogColor) / 255.0f);
|
||||
s->uniforms &= ~UNI_FOG_COL;
|
||||
}
|
||||
if ((s->uniforms & UNI_FOG_END) && (s->features & FTR_LINEAR_FOG)) {
|
||||
|
@ -776,8 +776,8 @@ static void SwitchProgram(void) {
|
|||
|
||||
void Gfx_SetFog(cc_bool enabled) { gfx_fogEnabled = enabled; SwitchProgram(); }
|
||||
void Gfx_SetFogCol(PackedCol col) {
|
||||
if (col == gfx_fogCol) return;
|
||||
gfx_fogCol = col;
|
||||
if (col == gfx_fogColor) return;
|
||||
gfx_fogColor = col;
|
||||
DirtyUniform(UNI_FOG_COL);
|
||||
ReloadUniforms();
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ static void Gfx_RestoreState(void) {
|
|||
gfx_format = -1;
|
||||
|
||||
DirtyUniform(UNI_MASK_ALL);
|
||||
GL_ClearCol(gfx_clearCol);
|
||||
GL_ClearCol(gfx_clearColor);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
}
|
||||
|
@ -944,13 +944,13 @@ void Gfx_SetFog(cc_bool enabled) {
|
|||
|
||||
void Gfx_SetFogCol(PackedCol col) {
|
||||
float rgba[4];
|
||||
if (col == gfx_fogCol) return;
|
||||
if (col == gfx_fogColor) return;
|
||||
|
||||
rgba[0] = PackedCol_R(col) / 255.0f; rgba[1] = PackedCol_G(col) / 255.0f;
|
||||
rgba[2] = PackedCol_B(col) / 255.0f; rgba[3] = PackedCol_A(col) / 255.0f;
|
||||
|
||||
glFogfv(GL_FOG_COLOR, rgba);
|
||||
gfx_fogCol = col;
|
||||
gfx_fogColor = col;
|
||||
}
|
||||
|
||||
void Gfx_SetFogDensity(float value) {
|
||||
|
|
|
@ -112,7 +112,7 @@ static void Http_BackendAdd(struct HttpRequest* req, cc_bool priority) {
|
|||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Http component------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void OnInit(void) {
|
||||
static void Http_Init(void) {
|
||||
ScheduledTask_Add(30, Http_CleanCacheTask);
|
||||
/* If this webpage is https://, browsers deny any http:// downloading */
|
||||
httpsOnly = interop_IsHttpsOnly();
|
||||
|
@ -121,17 +121,4 @@ static void OnInit(void) {
|
|||
RequestList_Init(&workingReqs);
|
||||
RequestList_Init(&processedReqs);
|
||||
}
|
||||
|
||||
static void OnFree(void) {
|
||||
Http_ClearPending();
|
||||
RequestList_Free(&queuedReqs);
|
||||
RequestList_Free(&workingReqs);
|
||||
RequestList_Free(&processedReqs);
|
||||
}
|
||||
|
||||
struct IGameComponent Http_Component = {
|
||||
OnInit, /* Init */
|
||||
OnFree, /* Free */
|
||||
Http_ClearPending /* Reset */
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -757,7 +757,7 @@ static void WorkerLoop(void) {
|
|||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Http component------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void OnInit(void) {
|
||||
static void Http_Init(void) {
|
||||
httpOnly = Options_GetBool(OPT_HTTP_ONLY, false);
|
||||
ScheduledTask_Add(30, Http_CleanCacheTask);
|
||||
if (workerThread) return;
|
||||
|
@ -772,10 +772,4 @@ static void OnInit(void) {
|
|||
curRequestMutex = Mutex_Create();
|
||||
workerThread = Thread_Start(WorkerLoop);
|
||||
}
|
||||
|
||||
struct IGameComponent Http_Component = {
|
||||
OnInit, /* Init */
|
||||
Http_ClearPending,/* Free */
|
||||
Http_ClearPending /* Reset */
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -256,9 +256,9 @@ static void WoM_CheckSendWomID(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static PackedCol WoM_ParseCol(const cc_string* value, PackedCol defaultCol) {
|
||||
static PackedCol WoM_ParseCol(const cc_string* value, PackedCol defaultColor) {
|
||||
int argb;
|
||||
if (!Convert_ParseInt(value, &argb)) return defaultCol;
|
||||
if (!Convert_ParseInt(value, &argb)) return defaultColor;
|
||||
return PackedCol_Make(argb >> 16, argb >> 8, argb, 255);
|
||||
}
|
||||
|
||||
|
|
28
src/World.c
28
src/World.c
|
@ -225,26 +225,26 @@ void Env_SetSkyboxVerSpeed(float speed) {
|
|||
Env_Set(speed, Env.SkyboxVerSpeed, ENV_VAR_SKYBOX_VER_SPEED);
|
||||
}
|
||||
|
||||
void Env_SetSkyCol(PackedCol col) {
|
||||
Env_Set(col, Env.SkyCol, ENV_VAR_SKY_COL);
|
||||
void Env_SetSkyCol(PackedCol color) {
|
||||
Env_Set(color, Env.SkyCol, ENV_VAR_SKY_COL);
|
||||
}
|
||||
void Env_SetFogCol(PackedCol col) {
|
||||
Env_Set(col, Env.FogCol, ENV_VAR_FOG_COL);
|
||||
void Env_SetFogCol(PackedCol color) {
|
||||
Env_Set(color, Env.FogCol, ENV_VAR_FOG_COL);
|
||||
}
|
||||
void Env_SetCloudsCol(PackedCol col) {
|
||||
Env_Set(col, Env.CloudsCol, ENV_VAR_CLOUDS_COL);
|
||||
void Env_SetCloudsCol(PackedCol color) {
|
||||
Env_Set(color, Env.CloudsCol, ENV_VAR_CLOUDS_COL);
|
||||
}
|
||||
void Env_SetSkyboxCol(PackedCol col) {
|
||||
Env_Set(col, Env.SkyboxCol, ENV_VAR_SKYBOX_COL);
|
||||
void Env_SetSkyboxCol(PackedCol color) {
|
||||
Env_Set(color, Env.SkyboxCol, ENV_VAR_SKYBOX_COL);
|
||||
}
|
||||
|
||||
void Env_SetSunCol(PackedCol col) {
|
||||
PackedCol_GetShaded(col, &Env.SunXSide, &Env.SunZSide, &Env.SunYMin);
|
||||
Env_Set(col, Env.SunCol, ENV_VAR_SUN_COL);
|
||||
void Env_SetSunCol(PackedCol color) {
|
||||
PackedCol_GetShaded(color, &Env.SunXSide, &Env.SunZSide, &Env.SunYMin);
|
||||
Env_Set(color, Env.SunCol, ENV_VAR_SUN_COL);
|
||||
}
|
||||
void Env_SetShadowCol(PackedCol col) {
|
||||
PackedCol_GetShaded(col, &Env.ShadowXSide, &Env.ShadowZSide, &Env.ShadowYMin);
|
||||
Env_Set(col, Env.ShadowCol, ENV_VAR_SHADOW_COL);
|
||||
void Env_SetShadowCol(PackedCol color) {
|
||||
PackedCol_GetShaded(color, &Env.ShadowXSide, &Env.ShadowZSide, &Env.ShadowYMin);
|
||||
Env_Set(color, Env.ShadowCol, ENV_VAR_SHADOW_COL);
|
||||
}
|
||||
|
||||
|
||||
|
|
12
src/World.h
12
src/World.h
|
@ -168,20 +168,20 @@ CC_API void Env_SetSkyboxHorSpeed(float speed);
|
|||
CC_API void Env_SetSkyboxVerSpeed(float speed);
|
||||
|
||||
/* Sets colour of the sky above clouds. (default #99CCFF) */
|
||||
CC_API void Env_SetSkyCol(PackedCol col);
|
||||
CC_API void Env_SetSkyCol(PackedCol color);
|
||||
/* Sets base colour of the horizon fog. (default #FFFFFF) */
|
||||
/* Actual fog colour is blended between sky and fog colours, based on view distance. */
|
||||
CC_API void Env_SetFogCol(PackedCol col);
|
||||
CC_API void Env_SetFogCol(PackedCol color);
|
||||
/* Sets colour of clouds. (default #FFFFFF) */
|
||||
CC_API void Env_SetCloudsCol(PackedCol col);
|
||||
CC_API void Env_SetCloudsCol(PackedCol color);
|
||||
/* Sets colour of the skybox. (default #FFFFFF) */
|
||||
CC_API void Env_SetSkyboxCol(PackedCol col);
|
||||
CC_API void Env_SetSkyboxCol(PackedCol color);
|
||||
/* Sets colour of sunlight. (default #FFFFFF) */
|
||||
/* This is the colour used for lighting when not underground. */
|
||||
CC_API void Env_SetSunCol(PackedCol col);
|
||||
CC_API void Env_SetSunCol(PackedCol color);
|
||||
/* Sets colour of shadow. (default #9B9B9B) */
|
||||
/* This is the colour used for lighting when underground. */
|
||||
CC_API void Env_SetShadowCol(PackedCol col);
|
||||
CC_API void Env_SetShadowCol(PackedCol color);
|
||||
|
||||
#define RESPAWN_NOT_FOUND -100000.0f
|
||||
/* Finds the highest Y coordinate of any solid block that intersects the given bounding box */
|
||||
|
|
|
@ -286,9 +286,9 @@ void Texture_Render(const struct Texture* tex) {
|
|||
Gfx_Draw2DTexture(tex, PACKEDCOL_WHITE);
|
||||
}
|
||||
|
||||
void Texture_RenderShaded(const struct Texture* tex, PackedCol shadeCol) {
|
||||
void Texture_RenderShaded(const struct Texture* tex, PackedCol shadeColor) {
|
||||
Gfx_BindTexture(tex->ID);
|
||||
Gfx_Draw2DTexture(tex, shadeCol);
|
||||
Gfx_Draw2DTexture(tex, shadeColor);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -258,3 +258,15 @@ void Http_UrlEncodeUtf8(cc_string* dst, const cc_string* src) {
|
|||
Http_UrlEncode(dst, data, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Http component------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void Http_Init(void);
|
||||
|
||||
struct IGameComponent Http_Component = {
|
||||
Http_Init, /* Init */
|
||||
Http_ClearPending,/* Free */
|
||||
Http_ClearPending /* Reset */
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue