mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
Show a error message in chat when texture pack fails to download (e.g. 401, 404, other), instead of just silently failing.
This commit is contained in:
parent
7d2e4f3a6a
commit
7e33e1b984
@ -10,7 +10,6 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
public CreeperModel(Game window) : base(window) { SurivalScore = 200; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void CreateParts() {
|
||||
vertices = new ModelVertex[boxVertices * 6];
|
||||
Head = BuildBox(MakeBoxBounds(-4, 18, -4, 4, 26, 4)
|
||||
|
@ -31,23 +31,18 @@ namespace ClassicalSharp.Model {
|
||||
.RotOrigin(0, 6, 7));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override float NameYOffset { get { return 1.075f; } }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override float GetEyeY(Entity entity) { return 12/16f; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Vector3 CollisionSize {
|
||||
get { return new Vector3(14/16f, 14/16f, 14/16f); }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override AABB PickingBounds {
|
||||
get { return new AABB(-5/16f, 0, -14/16f, 5/16f, 16/16f, 9/16f); }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void DrawModel(Entity p) {
|
||||
game.Graphics.BindTexture(GetTexture(p));
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, Head, true);
|
||||
|
@ -17,7 +17,6 @@ namespace ClassicalSharp.Model {
|
||||
furIndex = game.ModelCache.GetTextureIndex("sheep_fur.png");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void CreateParts() {
|
||||
vertices = new ModelVertex[boxVertices * 6 * 2];
|
||||
MakeBaseModel();
|
||||
|
@ -10,7 +10,6 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
public SpiderModel(Game window) : base(window) { SurivalScore = 105; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void CreateParts() {
|
||||
vertices = new ModelVertex[boxVertices * 5];
|
||||
Head = BuildBox(MakeBoxBounds(-4, 4, -11, 4, 12, -3)
|
||||
@ -43,7 +42,6 @@ namespace ClassicalSharp.Model {
|
||||
const float quarterPi = (float)(Math.PI / 4);
|
||||
const float eighthPi = (float)(Math.PI / 8);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void DrawModel(Entity p) {
|
||||
game.Graphics.BindTexture(GetTexture(p));
|
||||
DrawRotate(-p.HeadXRadians, 0, 0, Head, true);
|
||||
|
@ -50,41 +50,24 @@ namespace ClassicalSharp {
|
||||
|
||||
public partial class Game {
|
||||
|
||||
/// <summary> Abstracts the underlying 3D graphics rendering API. </summary>
|
||||
public IGraphicsApi Graphics;
|
||||
|
||||
/// <summary> Handles game mode specific functionality. </summary>
|
||||
public IGameMode Mode;
|
||||
|
||||
/// <summary> Contains the block data and metadata/properties for the player's current world. </summary>
|
||||
public World World;
|
||||
|
||||
/// <summary> Represents a connection to a multiplayer or a singleplayer server. </summary>
|
||||
public IServerConnection Server;
|
||||
|
||||
/// <summary> List of all entities in the current map, including the player. </summary>
|
||||
public EntityList Entities;
|
||||
|
||||
/// <summary> Entity representing the player. </summary>
|
||||
public LocalPlayer LocalPlayer;
|
||||
|
||||
/// <summary> Contains information for each player in the current world
|
||||
/// (or for whole server if supported). </summary>
|
||||
public TabList TabList;
|
||||
|
||||
/// <summary> Current camera the player is using to view the world. </summary>
|
||||
public Camera Camera;
|
||||
/// <summary> List of all cameras the user can use to view the world. </summary>
|
||||
public List<Camera> Cameras = new List<Camera>();
|
||||
|
||||
/// <summary> Total rendering time(in seconds) elapsed since the client was started. </summary>
|
||||
public double accumulator;
|
||||
public SkinType DefaultPlayerSkinType;
|
||||
|
||||
/// <summary> Accumulator for the number of chunk updates performed. Reset every second. </summary>
|
||||
public int ChunkUpdates;
|
||||
|
||||
/// <summary> Whether the third person camera should have their camera position clipped so as to not intersect blocks. </summary>
|
||||
public bool CameraClipping = true;
|
||||
|
||||
public bool SkipClear = false;
|
||||
@ -124,30 +107,21 @@ namespace ClassicalSharp {
|
||||
/// <summary> Whether x to stone brick tiles should be used. </summary>
|
||||
public bool SupportsCPEBlocks = false;
|
||||
|
||||
/// <summary> Account username of the player. </summary>
|
||||
public string Username;
|
||||
|
||||
/// <summary> Verification key used for multiplayer, unique for the username and individual server. </summary>
|
||||
public string Mppass;
|
||||
|
||||
/// <summary> IP address of multiplayer server connected to, null if singleplayer. </summary>
|
||||
public IPAddress IPAddress;
|
||||
|
||||
/// <summary> Port of multiplayer server connected to, 0 if singleplayer. </summary>
|
||||
public int Port;
|
||||
|
||||
/// <summary> Radius of the sphere the player can see around the position of the current camera. </summary>
|
||||
public int ViewDistance = 512;
|
||||
internal int MaxViewDistance = 32768, UserViewDistance = 512;
|
||||
|
||||
/// <summary> Field of view for the current camera in degrees. </summary>
|
||||
public int Fov = 70;
|
||||
internal int DefaultFov, ZoomFov;
|
||||
|
||||
/// <summary> Strategy used to limit how many frames should be displayed at most each second. </summary>
|
||||
public FpsLimitMethod FpsLimit;
|
||||
|
||||
/// <summary> Whether lines should be rendered for each axis. </summary>
|
||||
public bool ShowAxisLines;
|
||||
|
||||
/// <summary> Whether players should animate using simple swinging parallel to their bodies. </summary>
|
||||
@ -156,7 +130,6 @@ namespace ClassicalSharp {
|
||||
/// <summary> Whether the arm model should use the classic position. </summary>
|
||||
public bool ClassicArmModel;
|
||||
|
||||
/// <summary> Whether mouse rotation on the y axis should be inverted. </summary>
|
||||
public bool InvertMouse;
|
||||
|
||||
public int Vertices;
|
||||
|
@ -11,22 +11,16 @@ namespace ClassicalSharp.Generator {
|
||||
|
||||
public abstract string GeneratorName { get; }
|
||||
|
||||
/// <summary> Generates the raw blocks within the map, using the given seed. </summary>
|
||||
public abstract BlockRaw[] Generate();
|
||||
|
||||
/// <summary> Applies environment settings (if required) to the newly generated world. </summary>
|
||||
public virtual void ApplyEnv(World world) { }
|
||||
|
||||
/// <summary> The current operation being performed (current stage). </summary>
|
||||
public string CurrentState;
|
||||
|
||||
/// <summary> Progress towards completion of the current operation. (raises from 0 to 1) </summary>
|
||||
public float CurrentProgress;
|
||||
|
||||
/// <summary> Whether the generation has completed all operations. </summary>
|
||||
public bool Done = false;
|
||||
|
||||
/// <summary> Blocks of the map generated. </summary>
|
||||
public volatile BlockRaw[] Blocks;
|
||||
|
||||
public int Width, Height, Length, Seed;
|
||||
|
@ -87,7 +87,6 @@ namespace ClassicalSharp.Map {
|
||||
ResetLight();
|
||||
}
|
||||
|
||||
/// <summary> Resets all of the environment properties to their defaults. </summary>
|
||||
public void Reset() {
|
||||
EdgeHeight = -1; SidesOffset = -2; CloudHeight = -1;
|
||||
EdgeBlock = Block.StillWater; SidesBlock = Block.Bedrock;
|
||||
@ -114,8 +113,6 @@ namespace ClassicalSharp.Map {
|
||||
out SunZSide, out SunYBottom);
|
||||
}
|
||||
|
||||
/// <summary> Sets sides block to the given block, and raises
|
||||
/// EnvVariableChanged event with variable 'SidesBlock'. </summary>
|
||||
public void SetSidesBlock(BlockID block) {
|
||||
if (block == 255 && !BlockInfo.IsCustomDefined(255)) block = Block.Bedrock; // some server software wrongly uses this value
|
||||
if (block == SidesBlock) return;
|
||||
@ -123,8 +120,6 @@ namespace ClassicalSharp.Map {
|
||||
game.WorldEvents.RaiseEnvVariableChanged(EnvVar.SidesBlock);
|
||||
}
|
||||
|
||||
/// <summary> Sets edge block to the given block, and raises
|
||||
/// EnvVariableChanged event with variable 'EdgeBlock'. </summary>
|
||||
public void SetEdgeBlock(BlockID block) {
|
||||
if (block == 255 && !BlockInfo.IsCustomDefined(255)) block = Block.StillWater; // some server software wrongly uses this value
|
||||
if (block == EdgeBlock) return;
|
||||
@ -132,65 +127,30 @@ namespace ClassicalSharp.Map {
|
||||
game.WorldEvents.RaiseEnvVariableChanged(EnvVar.EdgeBlock);
|
||||
}
|
||||
|
||||
/// <summary> Sets clouds height in world space, and raises
|
||||
/// EnvVariableChanged event with variable 'CloudsLevel'. </summary>
|
||||
public void SetCloudsLevel(int level) { Set(level, ref CloudHeight, EnvVar.CloudsLevel); }
|
||||
|
||||
/// <summary> Sets clouds speed, and raises EnvVariableChanged
|
||||
/// event with variable 'CloudsSpeed'. </summary>
|
||||
public void SetCloudsSpeed(float speed) { Set(speed, ref CloudsSpeed, EnvVar.CloudsSpeed); }
|
||||
|
||||
/// <summary> Sets weather speed, and raises EnvVariableChanged
|
||||
/// event with variable 'WeatherSpeed'. </summary>
|
||||
public void SetWeatherSpeed(float speed) { Set(speed, ref WeatherSpeed, EnvVar.WeatherSpeed); }
|
||||
|
||||
/// <summary> Sets weather fade rate, and raises EnvVariableChanged
|
||||
/// event with variable 'WeatherFade'. </summary>
|
||||
public void SetWeatherFade(float rate) { Set(rate, ref WeatherFade, EnvVar.WeatherFade); }
|
||||
|
||||
/// <summary> Sets height of the map edges in world space, and raises
|
||||
/// EnvVariableChanged event with variable 'EdgeLevel'. </summary>
|
||||
public void SetEdgeLevel(int level) { Set(level, ref EdgeHeight, EnvVar.EdgeLevel); }
|
||||
|
||||
/// <summary> Sets offset of the height of the map sides from map edges in world space, and raises
|
||||
/// EnvVariableChanged event with variable 'SidesLevel'. </summary>
|
||||
public void SetSidesOffset(int level) { Set(level, ref SidesOffset, EnvVar.SidesOffset); }
|
||||
|
||||
/// <summary> Sets whether exponential fog is used, and raises
|
||||
/// EnvVariableChanged event with variable 'ExpFog'. </summary>
|
||||
public void SetExpFog(bool expFog) { Set(expFog, ref ExpFog, EnvVar.ExpFog); }
|
||||
|
||||
/// <summary> Sets horizontal speed of skybox rotation, and raises
|
||||
/// EnvVariableChanged event with variable 'SkyboxHorSpeed'. </summary>
|
||||
public void SetSkyboxHorSpeed(float speed) { Set(speed, ref SkyboxHorSpeed, EnvVar.SkyboxHorSpeed); }
|
||||
|
||||
/// <summary> Sets vertical speed of skybox rotation, and raises
|
||||
/// EnvVariableChanged event with variable 'SkyboxVerSpeed'. </summary>
|
||||
public void SetSkyboxVerSpeed(float speed) { Set(speed, ref SkyboxVerSpeed, EnvVar.SkyboxVerSpeed); }
|
||||
|
||||
/// <summary> Sets weather, and raises
|
||||
/// EnvVariableChanged event with variable 'Weather'. </summary>
|
||||
public void SetWeather(Weather weather) {
|
||||
if (weather == Weather) return;
|
||||
Weather = weather;
|
||||
game.WorldEvents.RaiseEnvVariableChanged(EnvVar.Weather);
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Sets tsky colour, and raises
|
||||
/// EnvVariableChanged event with variable 'SkyColour'. </summary>
|
||||
public void SetSkyColour(FastColour col) { Set(col, ref SkyCol, EnvVar.SkyColour); }
|
||||
|
||||
/// <summary> Sets fog colour, and raises
|
||||
/// EnvVariableChanged event with variable 'FogColour'. </summary>
|
||||
public void SetFogColour(FastColour col) { Set(col, ref FogCol, EnvVar.FogColour); }
|
||||
|
||||
/// <summary> Sets clouds colour, and raises
|
||||
/// EnvVariableChanged event with variable 'CloudsColour'. </summary>
|
||||
public void SetCloudsColour(FastColour col) { Set(col, ref CloudsCol, EnvVar.CloudsColour); }
|
||||
|
||||
/// <summary> Sets sunlight colour, and raises
|
||||
/// EnvVariableChanged event with variable 'SunlightColour'. </summary>
|
||||
public void SetSunlight(FastColour col) {
|
||||
if (col == Sunlight) return;
|
||||
|
||||
@ -201,8 +161,6 @@ namespace ClassicalSharp.Map {
|
||||
game.WorldEvents.RaiseEnvVariableChanged(EnvVar.SunlightColour);
|
||||
}
|
||||
|
||||
/// <summary> Sets current shadowlight colour, and raises
|
||||
/// EnvVariableChanged event with variable 'ShadowlightColour'. </summary>
|
||||
public void SetShadowlight(FastColour col) {
|
||||
if (col == Shadowlight) return;
|
||||
|
||||
|
@ -69,7 +69,9 @@ namespace ClassicalSharp {
|
||||
protected int netTicks;
|
||||
|
||||
protected internal void RetrieveTexturePack(string url) {
|
||||
if (!TextureCache.HasAccepted(url) && !TextureCache.HasDenied(url)) {
|
||||
if (TextureCache.HasDenied(url)) {
|
||||
// nothing to do here
|
||||
} else if (!TextureCache.HasAccepted(url)) {
|
||||
Overlay warning = new TexPackOverlay(game, url);
|
||||
game.Gui.ShowOverlay(warning, false);
|
||||
} else {
|
||||
@ -98,10 +100,32 @@ namespace ClassicalSharp {
|
||||
protected void CheckAsyncResources() {
|
||||
Request item;
|
||||
if (game.Downloader.TryGetItem("terrain", out item)) {
|
||||
if (item.Data != null) {
|
||||
TexturePack.ExtractTerrainPng(game, item);
|
||||
} else {
|
||||
LogResourceFail(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (game.Downloader.TryGetItem("texturePack", out item)) {
|
||||
if (item.Data != null) {
|
||||
TexturePack.ExtractTexturePack(game, item);
|
||||
} else {
|
||||
LogResourceFail(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LogResourceFail(Request item) {
|
||||
WebException ex = item.WebEx;
|
||||
if (ex == null) return;
|
||||
|
||||
if (ex.Response != null) {
|
||||
int status = (int)((HttpWebResponse)ex.Response).StatusCode;
|
||||
if (status == 304); // Not an error if no data when "Not modified" status
|
||||
game.Chat.Add("&c" + status + " error when trying to download texture pack");
|
||||
} else {
|
||||
game.Chat.Add("&c" + ex.Status + " when trying to download texture pack");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -59,7 +59,6 @@ namespace ClassicalSharp.Network {
|
||||
#if !LAUNCHER
|
||||
/// <summary> Asynchronously downloads a skin. If 'skinName' points to the url then the skin is
|
||||
/// downloaded from that url, otherwise it is downloaded from the url 'defaultSkinServer'/'skinName'.png </summary>
|
||||
/// <remarks> Identifier is skin_'skinName'.</remarks>
|
||||
public void AsyncGetSkin(string identifier, string skinName) {
|
||||
string url = Utils.IsUrlPrefix(skinName, 0) ? skinName
|
||||
: skinServer + Utils.StripColours(skinName) + ".png";
|
||||
|
@ -83,7 +83,6 @@ namespace ClassicalSharp.Textures {
|
||||
|
||||
|
||||
internal static void ExtractTerrainPng(Game game, Request item) {
|
||||
if (item.Data == null) return;
|
||||
game.World.TextureUrl = item.Url;
|
||||
game.Events.RaiseTexturePackChanged();
|
||||
|
||||
@ -96,7 +95,6 @@ namespace ClassicalSharp.Textures {
|
||||
}
|
||||
|
||||
internal static void ExtractTexturePack(Game game, Request item) {
|
||||
if (item.Data == null) return;
|
||||
game.World.TextureUrl = item.Url;
|
||||
byte[] data = (byte[])item.Data;
|
||||
|
||||
|
@ -58,25 +58,21 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Rotates the given 3D coordinates around the x axis. </summary>
|
||||
public static Vector3 RotateX(Vector3 v, float angle) {
|
||||
float cosA = (float)Math.Cos(angle), sinA = (float)Math.Sin(angle);
|
||||
return new Vector3(v.X, cosA * v.Y + sinA * v.Z, -sinA * v.Y + cosA * v.Z);
|
||||
}
|
||||
|
||||
/// <summary> Rotates the given 3D coordinates around the y axis. </summary>
|
||||
public static Vector3 RotateY(Vector3 v, float angle) {
|
||||
float cosA = (float)Math.Cos(angle), sinA = (float)Math.Sin(angle);
|
||||
return new Vector3(cosA * v.X - sinA * v.Z, v.Y, sinA * v.X + cosA * v.Z);
|
||||
}
|
||||
|
||||
/// <summary> Rotates the given 3D coordinates around the y axis. </summary>
|
||||
public static Vector3 RotateY(float x, float y, float z, float angle) {
|
||||
float cosA = (float)Math.Cos(angle), sinA = (float)Math.Sin(angle);
|
||||
return new Vector3(cosA * x - sinA * z, y, sinA * x + cosA * z);
|
||||
}
|
||||
|
||||
/// <summary> Rotates the given 3D coordinates around the z axis. </summary>
|
||||
public static Vector3 RotateZ(Vector3 v, float angle) {
|
||||
float cosA = (float)Math.Cos(angle), sinA = (float)Math.Sin(angle);
|
||||
return new Vector3(cosA * v.X + sinA * v.Y, -sinA * v.X + cosA * v.Y, v.Z);
|
||||
|
@ -135,7 +135,7 @@ typedef struct AnimationData_ {
|
||||
} AnimationData;
|
||||
|
||||
Bitmap anims_bmp;
|
||||
AnimationData anims_list[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
AnimationData anims_list[ATLAS1D_MAX_ATLASES];
|
||||
UInt32 anims_count;
|
||||
bool anims_validated, anims_useLavaAnim, anims_useWaterAnim;
|
||||
|
||||
|
@ -267,7 +267,9 @@ static void AsyncDownloader_ProcessRequest(AsyncRequest* request) {
|
||||
request->ResultContentLength = size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void AsyncDownloader_CompleteResult(AsyncRequest* request) {
|
||||
Platform_CurrentUTCTime(&request->TimeDownloaded);
|
||||
Platform_MutexLock(async_processedMutex);
|
||||
{
|
||||
@ -318,6 +320,7 @@ static void AsyncDownloader_WorkerFunc(void) {
|
||||
|
||||
Platform_LogConst("Doing it");
|
||||
AsyncDownloader_ProcessRequest(&request);
|
||||
AsyncDownloader_CompleteResult(&request);
|
||||
|
||||
Platform_MutexLock(async_curRequestMutex);
|
||||
{
|
||||
|
@ -43,8 +43,8 @@ typedef struct Builder1DPart_ {
|
||||
} Builder1DPart;
|
||||
|
||||
/* Part builder data, for both normal and translucent parts.
|
||||
The first ATLAS1D_MAX_ATLASES_COUNT parts are for normal parts, remainder are for translucent parts. */
|
||||
Builder1DPart Builder_Parts[ATLAS1D_MAX_ATLASES_COUNT * 2];
|
||||
The first ATLAS1D_MAX_ATLASES parts are for normal parts, remainder are for translucent parts. */
|
||||
Builder1DPart Builder_Parts[ATLAS1D_MAX_ATLASES * 2];
|
||||
VertexP3fT2fC4b* Builder_Vertices;
|
||||
Int32 Builder_VerticesElems;
|
||||
|
||||
@ -69,7 +69,7 @@ static void Builder1DPart_CalcOffsets(Builder1DPart* part, Int32* offset) {
|
||||
|
||||
static Int32 Builder_TotalVerticesCount(void) {
|
||||
Int32 i, count = 0;
|
||||
for (i = 0; i < ATLAS1D_MAX_ATLASES_COUNT * 2; i++) {
|
||||
for (i = 0; i < ATLAS1D_MAX_ATLASES * 2; i++) {
|
||||
count += Builder1DPart_VerticesCount(&Builder_Parts[i]);
|
||||
}
|
||||
return count;
|
||||
@ -83,7 +83,7 @@ static void Builder_AddSpriteVertices(BlockID block) {
|
||||
}
|
||||
|
||||
static void Builder_AddVertices(BlockID block, Face face) {
|
||||
Int32 baseOffset = (Block_Draw[block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES_COUNT;
|
||||
Int32 baseOffset = (Block_Draw[block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES;
|
||||
Int32 i = Atlas1D_Index(Block_GetTexLoc(block, face));
|
||||
Builder1DPart* part = &Builder_Parts[baseOffset + i];
|
||||
part->fCount[face] += 4;
|
||||
@ -329,7 +329,7 @@ void Builder_MakeChunk(ChunkInfo* info) {
|
||||
bool hasNormal = false, hasTranslucent = false;
|
||||
|
||||
for (i = 0; i < MapRenderer_1DUsedCount; i++) {
|
||||
Int32 j = i + ATLAS1D_MAX_ATLASES_COUNT;
|
||||
Int32 j = i + ATLAS1D_MAX_ATLASES;
|
||||
Int32 curIdx = partsIndex + i * MapRenderer_ChunksCount;
|
||||
|
||||
Builder_SetPartInfo(&Builder_Parts[i], &offset, &MapRenderer_PartsNormal[curIdx], &hasNormal);
|
||||
@ -377,8 +377,8 @@ static void Builder_DefaultPostStretchTiles(Int32 x1, Int32 y1, Int32 z1) {
|
||||
}
|
||||
|
||||
vertsCount = 0;
|
||||
for (i = 0; i < ATLAS1D_MAX_ATLASES_COUNT; i++) {
|
||||
Int32 j = i + ATLAS1D_MAX_ATLASES_COUNT;
|
||||
for (i = 0; i < ATLAS1D_MAX_ATLASES; i++) {
|
||||
Int32 j = i + ATLAS1D_MAX_ATLASES;
|
||||
Builder1DPart_CalcOffsets(&Builder_Parts[i], &vertsCount);
|
||||
Builder1DPart_CalcOffsets(&Builder_Parts[j], &vertsCount);
|
||||
}
|
||||
@ -575,7 +575,7 @@ static void NormalBuilder_RenderBlock(Int32 index) {
|
||||
|
||||
|
||||
bool fullBright = Block_FullBright[Builder_Block];
|
||||
Int32 partOffset = (Block_Draw[Builder_Block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES_COUNT;
|
||||
Int32 partOffset = (Block_Draw[Builder_Block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES;
|
||||
Int32 lightFlags = Block_LightOffset[Builder_Block];
|
||||
|
||||
Drawer_MinBB = Block_MinBB[Builder_Block]; Drawer_MinBB.Y = 1.0f - Drawer_MinBB.Y;
|
||||
|
@ -290,7 +290,7 @@ void ChunkUpdater_UpdateChunks(Real64 delta) {
|
||||
|
||||
void ChunkUpdater_ResetPartFlags(void) {
|
||||
Int32 i;
|
||||
for (i = 0; i < ATLAS1D_MAX_ATLASES_COUNT; i++) {
|
||||
for (i = 0; i < ATLAS1D_MAX_ATLASES; i++) {
|
||||
MapRenderer_CheckingNormalParts[i] = true;
|
||||
MapRenderer_HasNormalParts[i] = false;
|
||||
MapRenderer_CheckingTranslucentParts[i] = true;
|
||||
@ -300,7 +300,7 @@ void ChunkUpdater_ResetPartFlags(void) {
|
||||
|
||||
void ChunkUpdater_ResetPartCounts(void) {
|
||||
Int32 i;
|
||||
for (i = 0; i < ATLAS1D_MAX_ATLASES_COUNT; i++) {
|
||||
for (i = 0; i < ATLAS1D_MAX_ATLASES; i++) {
|
||||
MapRenderer_NormalPartsCount[i] = 0;
|
||||
MapRenderer_TranslucentPartsCount[i] = 0;
|
||||
}
|
||||
|
@ -14,20 +14,20 @@ Int32 MapRenderer_ChunksX, MapRenderer_ChunksY, MapRenderer_ChunksZ;
|
||||
Int32 MapRenderer_1DUsedCount;
|
||||
/* The number of non-empty Normal ChunkPartInfos (across entire world) for each 1D atlas batch.
|
||||
1D atlas batches that do not have any ChunkPartInfos can be entirely skipped. */
|
||||
Int32 MapRenderer_NormalPartsCount[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
Int32 MapRenderer_NormalPartsCount[ATLAS1D_MAX_ATLASES];
|
||||
/* The number of non-empty Translucent ChunkPartInfos (across entire world) for each 1D atlas batch.
|
||||
1D atlas batches that do not have any ChunkPartInfos can be entirely skipped. */
|
||||
Int32 MapRenderer_TranslucentPartsCount[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
Int32 MapRenderer_TranslucentPartsCount[ATLAS1D_MAX_ATLASES];
|
||||
/* Whether there are any visible Translucent ChunkPartInfos for each 1D atlas batch.
|
||||
1D atlas batches that do not have any visible translucent ChunkPartInfos can be skipped. */
|
||||
bool MapRenderer_HasTranslucentParts[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
bool MapRenderer_HasTranslucentParts[ATLAS1D_MAX_ATLASES];
|
||||
/* Whether there are any visible Normal ChunkPartInfos for each 1D atlas batch.
|
||||
1D atlas batches that do not have any visible normal ChunkPartInfos can be skipped. */
|
||||
bool MapRenderer_HasNormalParts[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
bool MapRenderer_HasNormalParts[ATLAS1D_MAX_ATLASES];
|
||||
/* Whether renderer should check if there are any visible Translucent ChunkPartInfos for each 1D atlas batch. */
|
||||
bool MapRenderer_CheckingTranslucentParts[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
bool MapRenderer_CheckingTranslucentParts[ATLAS1D_MAX_ATLASES];
|
||||
/* Whether renderer should check if there are any visible Normal ChunkPartInfos for each 1D atlas batch. */
|
||||
bool MapRenderer_CheckingNormalParts[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
bool MapRenderer_CheckingNormalParts[ATLAS1D_MAX_ATLASES];
|
||||
|
||||
/* Render info for all chunks in the world. Unsorted.*/
|
||||
ChunkInfo* MapRenderer_Chunks;
|
||||
|
@ -198,8 +198,8 @@ typedef struct TerrainParticle_ {
|
||||
|
||||
TerrainParticle Terrain_Particles[PARTICLES_MAX];
|
||||
Int32 Terrain_Count;
|
||||
UInt16 Terrain_1DCount[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
UInt16 Terrain_1DIndices[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
UInt16 Terrain_1DCount[ATLAS1D_MAX_ATLASES];
|
||||
UInt16 Terrain_1DIndices[ATLAS1D_MAX_ATLASES];
|
||||
|
||||
static bool TerrainParticle_Tick(TerrainParticle* p, Real64 delta) {
|
||||
return Particle_PhysicsTick(&p->Base, 5.4f, true, delta);
|
||||
|
@ -69,7 +69,7 @@ int main(void) {
|
||||
|
||||
String title = String_FromConst(PROGRAM_APP_NAME);
|
||||
String rawArgs = Platform_GetCommandLineArgs();
|
||||
//rawArgs = String_FromReadonly("UnknownShadow200 fff 127.0.0.1 25566");
|
||||
rawArgs = String_FromReadonly("UnknownShadow200 fff 127.0.0.1 25566");
|
||||
|
||||
String args[5]; UInt32 argsCount = Array_Elems(args);
|
||||
String_UNSAFE_Split(&rawArgs, ' ', args, &argsCount);
|
||||
|
@ -70,17 +70,35 @@ void ServerConnection_DownloadTexturePack(STRING_PURE String* url) {
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConnection_CheckAsyncResources(void) {
|
||||
AsyncRequest item;
|
||||
void ServerConnection_LogResourceFail(AsyncRequest* item) {
|
||||
Int32 status = item->StatusCode;
|
||||
if (status == 0 || status == 304) return;
|
||||
|
||||
String terrain = String_FromConst("terrain");
|
||||
if (AsyncDownloader_Get(&terrain, &item)) {
|
||||
TexturePack_ExtractTerrainPng_Req(&item);
|
||||
UInt8 msgBuffer[String_BufferSize(STRING_SIZE)];
|
||||
String msg = String_InitAndClearArray(msgBuffer);
|
||||
String_Format1(&msg, "&c%i error when trying to download texture pack", &status);
|
||||
Chat_Add(&msg);
|
||||
}
|
||||
|
||||
void ServerConnection_CheckAsyncResources(void) {
|
||||
AsyncRequest item;
|
||||
String terrain = String_FromConst("terrain");
|
||||
String texPack = String_FromConst("texturePack");
|
||||
|
||||
if (AsyncDownloader_Get(&terrain, &item)) {
|
||||
if (item.ResultBitmap.Scan0 != NULL) {
|
||||
TexturePack_ExtractTerrainPng_Req(&item);
|
||||
} else {
|
||||
ServerConnection_LogResourceFail(&item);
|
||||
}
|
||||
}
|
||||
|
||||
if (AsyncDownloader_Get(&texPack, &item)) {
|
||||
if (item.ResultData.Ptr != NULL) {
|
||||
TexturePack_ExtractTexturePack_Req(&item);
|
||||
} else {
|
||||
ServerConnection_LogResourceFail(&item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,13 @@ GfxResourceID Atlas2D_LoadTile(TextureLoc texLoc);
|
||||
void Atlas2D_Free(void);
|
||||
|
||||
/* The theoretical largest number of 1D atlases that a 2D atlas can be broken down into. */
|
||||
#define ATLAS1D_MAX_ATLASES_COUNT (ATLAS2D_TILES_PER_ROW * ATLAS2D_ROWS_COUNT)
|
||||
#define ATLAS1D_MAX_ATLASES (ATLAS2D_TILES_PER_ROW * ATLAS2D_ROWS_COUNT)
|
||||
/* The number of tiles each 1D atlas contains. */
|
||||
Int32 Atlas1D_TilesPerAtlas;
|
||||
/* Size of a texture V coord V for an tile in a 1D atlas. */
|
||||
Real32 Atlas1D_InvTileSize;
|
||||
/* Native texture ID for each 1D atlas. */
|
||||
GfxResourceID Atlas1D_TexIds[ATLAS1D_MAX_ATLASES_COUNT];
|
||||
GfxResourceID Atlas1D_TexIds[ATLAS1D_MAX_ATLASES];
|
||||
/* Number of 1D atlases that actually have textures / are used. */
|
||||
Int32 Atlas1D_Count;
|
||||
/* Retrieves the 1D texture rectangle and 1D atlas index of the given texture. */
|
||||
|
@ -507,7 +507,6 @@ void TexturePack_ExtractCurrent(STRING_PURE String* url) {
|
||||
}
|
||||
|
||||
void TexturePack_ExtractTerrainPng_Req(AsyncRequest* item) {
|
||||
if (item->ResultBitmap.Scan0 == NULL) return;
|
||||
String url = String_FromRawArray(item->URL);
|
||||
String_Set(&World_TextureUrl, &url);
|
||||
Bitmap bmp = item->ResultBitmap;
|
||||
@ -522,7 +521,6 @@ void TexturePack_ExtractTerrainPng_Req(AsyncRequest* item) {
|
||||
}
|
||||
|
||||
void TexturePack_ExtractTexturePack_Req(AsyncRequest* item) {
|
||||
if (item->ResultData.Ptr == NULL) return;
|
||||
String url = String_FromRawArray(item->URL);
|
||||
String_Set(&World_TextureUrl, &url);
|
||||
void* data = item->ResultData.Ptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user