diff --git a/ClassicalSharp/Entities/Model/CreeperModel.cs b/ClassicalSharp/Entities/Model/CreeperModel.cs
index 28ee5f7ce..a3f6d4a37 100644
--- a/ClassicalSharp/Entities/Model/CreeperModel.cs
+++ b/ClassicalSharp/Entities/Model/CreeperModel.cs
@@ -10,7 +10,6 @@ namespace ClassicalSharp.Model {
public CreeperModel(Game window) : base(window) { SurivalScore = 200; }
- ///
public override void CreateParts() {
vertices = new ModelVertex[boxVertices * 6];
Head = BuildBox(MakeBoxBounds(-4, 18, -4, 4, 26, 4)
diff --git a/ClassicalSharp/Entities/Model/PigModel.cs b/ClassicalSharp/Entities/Model/PigModel.cs
index 10de8afad..844bfbfee 100644
--- a/ClassicalSharp/Entities/Model/PigModel.cs
+++ b/ClassicalSharp/Entities/Model/PigModel.cs
@@ -31,23 +31,18 @@ namespace ClassicalSharp.Model {
.RotOrigin(0, 6, 7));
}
- ///
public override float NameYOffset { get { return 1.075f; } }
- ///
public override float GetEyeY(Entity entity) { return 12/16f; }
- ///
public override Vector3 CollisionSize {
get { return new Vector3(14/16f, 14/16f, 14/16f); }
}
- ///
public override AABB PickingBounds {
get { return new AABB(-5/16f, 0, -14/16f, 5/16f, 16/16f, 9/16f); }
}
-
- ///
+
public override void DrawModel(Entity p) {
game.Graphics.BindTexture(GetTexture(p));
DrawRotate(-p.HeadXRadians, 0, 0, Head, true);
diff --git a/ClassicalSharp/Entities/Model/SheepModel.cs b/ClassicalSharp/Entities/Model/SheepModel.cs
index 5522a69c5..d834fbaca 100644
--- a/ClassicalSharp/Entities/Model/SheepModel.cs
+++ b/ClassicalSharp/Entities/Model/SheepModel.cs
@@ -17,7 +17,6 @@ namespace ClassicalSharp.Model {
furIndex = game.ModelCache.GetTextureIndex("sheep_fur.png");
}
- ///
public override void CreateParts() {
vertices = new ModelVertex[boxVertices * 6 * 2];
MakeBaseModel();
diff --git a/ClassicalSharp/Entities/Model/SpiderModel.cs b/ClassicalSharp/Entities/Model/SpiderModel.cs
index 9a17f539f..269e58fc6 100644
--- a/ClassicalSharp/Entities/Model/SpiderModel.cs
+++ b/ClassicalSharp/Entities/Model/SpiderModel.cs
@@ -10,7 +10,6 @@ namespace ClassicalSharp.Model {
public SpiderModel(Game window) : base(window) { SurivalScore = 105; }
- ///
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);
- ///
public override void DrawModel(Entity p) {
game.Graphics.BindTexture(GetTexture(p));
DrawRotate(-p.HeadXRadians, 0, 0, Head, true);
diff --git a/ClassicalSharp/Game/Game.Properties.cs b/ClassicalSharp/Game/Game.Properties.cs
index c269d987b..bacfc2aa4 100644
--- a/ClassicalSharp/Game/Game.Properties.cs
+++ b/ClassicalSharp/Game/Game.Properties.cs
@@ -50,41 +50,24 @@ namespace ClassicalSharp {
public partial class Game {
- /// Abstracts the underlying 3D graphics rendering API.
public IGraphicsApi Graphics;
-
- /// Handles game mode specific functionality.
public IGameMode Mode;
-
- /// Contains the block data and metadata/properties for the player's current world.
- public World World;
-
- /// Represents a connection to a multiplayer or a singleplayer server.
+ public World World;
public IServerConnection Server;
- /// List of all entities in the current map, including the player.
public EntityList Entities;
-
- /// Entity representing the player.
public LocalPlayer LocalPlayer;
-
- /// Contains information for each player in the current world
- /// (or for whole server if supported).
public TabList TabList;
-
- /// Current camera the player is using to view the world.
+
public Camera Camera;
- /// List of all cameras the user can use to view the world.
public List Cameras = new List();
/// Total rendering time(in seconds) elapsed since the client was started.
public double accumulator;
public SkinType DefaultPlayerSkinType;
- /// Accumulator for the number of chunk updates performed. Reset every second.
public int ChunkUpdates;
- /// Whether the third person camera should have their camera position clipped so as to not intersect blocks.
public bool CameraClipping = true;
public bool SkipClear = false;
@@ -124,39 +107,29 @@ namespace ClassicalSharp {
/// Whether x to stone brick tiles should be used.
public bool SupportsCPEBlocks = false;
- /// Account username of the player.
public string Username;
-
- /// Verification key used for multiplayer, unique for the username and individual server.
public string Mppass;
-
- /// IP address of multiplayer server connected to, null if singleplayer.
+
public IPAddress IPAddress;
-
- /// Port of multiplayer server connected to, 0 if singleplayer.
public int Port;
/// Radius of the sphere the player can see around the position of the current camera.
public int ViewDistance = 512;
internal int MaxViewDistance = 32768, UserViewDistance = 512;
- /// Field of view for the current camera in degrees.
public int Fov = 70;
internal int DefaultFov, ZoomFov;
- /// Strategy used to limit how many frames should be displayed at most each second.
public FpsLimitMethod FpsLimit;
- /// Whether lines should be rendered for each axis.
public bool ShowAxisLines;
-
+
/// Whether players should animate using simple swinging parallel to their bodies.
public bool SimpleArmsAnim;
/// Whether the arm model should use the classic position.
public bool ClassicArmModel;
-
- /// Whether mouse rotation on the y axis should be inverted.
+
public bool InvertMouse;
public int Vertices;
diff --git a/ClassicalSharp/Generator/IMapGenerator.cs b/ClassicalSharp/Generator/IMapGenerator.cs
index e9e0fbe43..d2766a899 100644
--- a/ClassicalSharp/Generator/IMapGenerator.cs
+++ b/ClassicalSharp/Generator/IMapGenerator.cs
@@ -10,23 +10,17 @@ namespace ClassicalSharp.Generator {
public abstract class IMapGenerator {
public abstract string GeneratorName { get; }
-
- /// Generates the raw blocks within the map, using the given seed.
+
public abstract BlockRaw[] Generate();
-
- /// Applies environment settings (if required) to the newly generated world.
+
public virtual void ApplyEnv(World world) { }
-
- /// The current operation being performed (current stage).
+
public string CurrentState;
-
- /// Progress towards completion of the current operation. (raises from 0 to 1)
+
public float CurrentProgress;
-
- /// Whether the generation has completed all operations.
+
public bool Done = false;
-
- /// Blocks of the map generated.
+
public volatile BlockRaw[] Blocks;
public int Width, Height, Length, Seed;
diff --git a/ClassicalSharp/Map/WorldEnv.cs b/ClassicalSharp/Map/WorldEnv.cs
index 69cc03d1e..7e4b5cb9b 100644
--- a/ClassicalSharp/Map/WorldEnv.cs
+++ b/ClassicalSharp/Map/WorldEnv.cs
@@ -87,7 +87,6 @@ namespace ClassicalSharp.Map {
ResetLight();
}
- /// Resets all of the environment properties to their defaults.
public void Reset() {
EdgeHeight = -1; SidesOffset = -2; CloudHeight = -1;
EdgeBlock = Block.StillWater; SidesBlock = Block.Bedrock;
@@ -113,9 +112,7 @@ namespace ClassicalSharp.Map {
FastColour.GetShaded(Sunlight, out SunXSide,
out SunZSide, out SunYBottom);
}
-
- /// Sets sides block to the given block, and raises
- /// EnvVariableChanged event with variable 'SidesBlock'.
+
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,74 +120,37 @@ namespace ClassicalSharp.Map {
game.WorldEvents.RaiseEnvVariableChanged(EnvVar.SidesBlock);
}
- /// Sets edge block to the given block, and raises
- /// EnvVariableChanged event with variable 'EdgeBlock'.
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;
EdgeBlock = block;
game.WorldEvents.RaiseEnvVariableChanged(EnvVar.EdgeBlock);
}
-
- /// Sets clouds height in world space, and raises
- /// EnvVariableChanged event with variable 'CloudsLevel'.
+
public void SetCloudsLevel(int level) { Set(level, ref CloudHeight, EnvVar.CloudsLevel); }
-
- /// Sets clouds speed, and raises EnvVariableChanged
- /// event with variable 'CloudsSpeed'.
public void SetCloudsSpeed(float speed) { Set(speed, ref CloudsSpeed, EnvVar.CloudsSpeed); }
-
- /// Sets weather speed, and raises EnvVariableChanged
- /// event with variable 'WeatherSpeed'.
+
public void SetWeatherSpeed(float speed) { Set(speed, ref WeatherSpeed, EnvVar.WeatherSpeed); }
-
- /// Sets weather fade rate, and raises EnvVariableChanged
- /// event with variable 'WeatherFade'.
public void SetWeatherFade(float rate) { Set(rate, ref WeatherFade, EnvVar.WeatherFade); }
-
- /// Sets height of the map edges in world space, and raises
- /// EnvVariableChanged event with variable 'EdgeLevel'.
+
public void SetEdgeLevel(int level) { Set(level, ref EdgeHeight, EnvVar.EdgeLevel); }
-
- /// Sets offset of the height of the map sides from map edges in world space, and raises
- /// EnvVariableChanged event with variable 'SidesLevel'.
public void SetSidesOffset(int level) { Set(level, ref SidesOffset, EnvVar.SidesOffset); }
- /// Sets whether exponential fog is used, and raises
- /// EnvVariableChanged event with variable 'ExpFog'.
public void SetExpFog(bool expFog) { Set(expFog, ref ExpFog, EnvVar.ExpFog); }
- /// Sets horizontal speed of skybox rotation, and raises
- /// EnvVariableChanged event with variable 'SkyboxHorSpeed'.
public void SetSkyboxHorSpeed(float speed) { Set(speed, ref SkyboxHorSpeed, EnvVar.SkyboxHorSpeed); }
-
- /// Sets vertical speed of skybox rotation, and raises
- /// EnvVariableChanged event with variable 'SkyboxVerSpeed'.
public void SetSkyboxVerSpeed(float speed) { Set(speed, ref SkyboxVerSpeed, EnvVar.SkyboxVerSpeed); }
- /// Sets weather, and raises
- /// EnvVariableChanged event with variable 'Weather'.
public void SetWeather(Weather weather) {
if (weather == Weather) return;
Weather = weather;
game.WorldEvents.RaiseEnvVariableChanged(EnvVar.Weather);
}
-
- /// Sets tsky colour, and raises
- /// EnvVariableChanged event with variable 'SkyColour'.
public void SetSkyColour(FastColour col) { Set(col, ref SkyCol, EnvVar.SkyColour); }
-
- /// Sets fog colour, and raises
- /// EnvVariableChanged event with variable 'FogColour'.
public void SetFogColour(FastColour col) { Set(col, ref FogCol, EnvVar.FogColour); }
-
- /// Sets clouds colour, and raises
- /// EnvVariableChanged event with variable 'CloudsColour'.
public void SetCloudsColour(FastColour col) { Set(col, ref CloudsCol, EnvVar.CloudsColour); }
-
- /// Sets sunlight colour, and raises
- /// EnvVariableChanged event with variable 'SunlightColour'.
+
public void SetSunlight(FastColour col) {
if (col == Sunlight) return;
@@ -200,9 +160,7 @@ namespace ClassicalSharp.Map {
Sun = Sunlight.Pack();
game.WorldEvents.RaiseEnvVariableChanged(EnvVar.SunlightColour);
}
-
- /// Sets current shadowlight colour, and raises
- /// EnvVariableChanged event with variable 'ShadowlightColour'.
+
public void SetShadowlight(FastColour col) {
if (col == Shadowlight) return;
diff --git a/ClassicalSharp/Network/IServerConnection.cs b/ClassicalSharp/Network/IServerConnection.cs
index 9bd2330bd..3466a09aa 100644
--- a/ClassicalSharp/Network/IServerConnection.cs
+++ b/ClassicalSharp/Network/IServerConnection.cs
@@ -36,7 +36,7 @@ namespace ClassicalSharp {
public abstract void Tick(ScheduledTask task);
public virtual void Init(Game game) { }
- public virtual void Ready(Game game) { }
+ public virtual void Ready(Game game) { }
public virtual void OnNewMapLoaded(Game game) { }
public abstract void Reset(Game game);
@@ -69,14 +69,16 @@ 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 {
DownloadTexturePack(url);
}
}
-
+
internal void DownloadTexturePack(string url) {
if (TextureCache.HasDenied(url)) return;
string etag = null;
@@ -98,10 +100,32 @@ namespace ClassicalSharp {
protected void CheckAsyncResources() {
Request item;
if (game.Downloader.TryGetItem("terrain", out item)) {
- TexturePack.ExtractTerrainPng(game, item);
+ if (item.Data != null) {
+ TexturePack.ExtractTerrainPng(game, item);
+ } else {
+ LogResourceFail(item);
+ }
}
+
if (game.Downloader.TryGetItem("texturePack", out item)) {
- TexturePack.ExtractTexturePack(game, 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
diff --git a/ClassicalSharp/Network/Utils/AsyncDownloader.cs b/ClassicalSharp/Network/Utils/AsyncDownloader.cs
index 2f0f6a7dd..f915c959d 100644
--- a/ClassicalSharp/Network/Utils/AsyncDownloader.cs
+++ b/ClassicalSharp/Network/Utils/AsyncDownloader.cs
@@ -59,7 +59,6 @@ namespace ClassicalSharp.Network {
#if !LAUNCHER
/// 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
- /// Identifier is skin_'skinName'.
public void AsyncGetSkin(string identifier, string skinName) {
string url = Utils.IsUrlPrefix(skinName, 0) ? skinName
: skinServer + Utils.StripColours(skinName) + ".png";
diff --git a/ClassicalSharp/TexturePack/TexturePack.cs b/ClassicalSharp/TexturePack/TexturePack.cs
index bcf8099b9..f212ab009 100644
--- a/ClassicalSharp/TexturePack/TexturePack.cs
+++ b/ClassicalSharp/TexturePack/TexturePack.cs
@@ -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;
diff --git a/ClassicalSharp/Utils/Utils.Math.cs b/ClassicalSharp/Utils/Utils.Math.cs
index 135fe801b..3b07a2798 100644
--- a/ClassicalSharp/Utils/Utils.Math.cs
+++ b/ClassicalSharp/Utils/Utils.Math.cs
@@ -58,25 +58,21 @@ namespace ClassicalSharp {
}
- /// Rotates the given 3D coordinates around the x axis.
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);
}
- /// Rotates the given 3D coordinates around the y axis.
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);
}
- /// Rotates the given 3D coordinates around the y axis.
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);
}
- /// Rotates the given 3D coordinates around the z axis.
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);
diff --git a/src/Client/Animations.c b/src/Client/Animations.c
index 713b844e0..479b9ca0e 100644
--- a/src/Client/Animations.c
+++ b/src/Client/Animations.c
@@ -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;
diff --git a/src/Client/AsyncDownloader.c b/src/Client/AsyncDownloader.c
index 8e03db82a..707e37cec 100644
--- a/src/Client/AsyncDownloader.c
+++ b/src/Client/AsyncDownloader.c
@@ -90,7 +90,7 @@ static void AsyncDownloader_Add(String* url, bool priority, String* id, UInt8 ty
{
AsyncRequest req = { 0 };
String reqUrl = String_FromEmptyArray(req.URL); String_Set(&reqUrl, url);
- String reqID = String_FromEmptyArray(req.ID); String_Set(&reqID, id);
+ String reqID = String_FromEmptyArray(req.ID); String_Set(&reqID, id);
req.RequestType = type;
Platform_Log2("Adding %s (type %b)", &reqUrl, &type);
@@ -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);
{
diff --git a/src/Client/Builder.c b/src/Client/Builder.c
index 4ea36e9f1..719c89dbb 100644
--- a/src/Client/Builder.c
+++ b/src/Client/Builder.c
@@ -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;
diff --git a/src/Client/ChunkUpdater.c b/src/Client/ChunkUpdater.c
index b4a9dcda1..797cdd357 100644
--- a/src/Client/ChunkUpdater.c
+++ b/src/Client/ChunkUpdater.c
@@ -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;
}
diff --git a/src/Client/MapRenderer.h b/src/Client/MapRenderer.h
index 9d3ec8837..ebef75265 100644
--- a/src/Client/MapRenderer.h
+++ b/src/Client/MapRenderer.h
@@ -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;
diff --git a/src/Client/Particle.c b/src/Client/Particle.c
index 5f575908a..b5ac79b29 100644
--- a/src/Client/Particle.c
+++ b/src/Client/Particle.c
@@ -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);
diff --git a/src/Client/Program.c b/src/Client/Program.c
index 3eb43dfe4..5b37eb2ac 100644
--- a/src/Client/Program.c
+++ b/src/Client/Program.c
@@ -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);
diff --git a/src/Client/ServerConnection.c b/src/Client/ServerConnection.c
index ed824cdba..0c385909f 100644
--- a/src/Client/ServerConnection.c
+++ b/src/Client/ServerConnection.c
@@ -70,17 +70,35 @@ void ServerConnection_DownloadTexturePack(STRING_PURE String* url) {
}
}
+void ServerConnection_LogResourceFail(AsyncRequest* item) {
+ Int32 status = item->StatusCode;
+ if (status == 0 || status == 304) return;
+
+ 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)) {
- TexturePack_ExtractTerrainPng_Req(&item);
+ if (item.ResultBitmap.Scan0 != NULL) {
+ TexturePack_ExtractTerrainPng_Req(&item);
+ } else {
+ ServerConnection_LogResourceFail(&item);
+ }
}
- String texPack = String_FromConst("texturePack");
if (AsyncDownloader_Get(&texPack, &item)) {
- TexturePack_ExtractTexturePack_Req(&item);
+ if (item.ResultData.Ptr != NULL) {
+ TexturePack_ExtractTexturePack_Req(&item);
+ } else {
+ ServerConnection_LogResourceFail(&item);
+ }
}
}
diff --git a/src/Client/TerrainAtlas.h b/src/Client/TerrainAtlas.h
index b6717a708..15282c98b 100644
--- a/src/Client/TerrainAtlas.h
+++ b/src/Client/TerrainAtlas.h
@@ -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. */
diff --git a/src/Client/TexturePack.c b/src/Client/TexturePack.c
index 1417723fb..c0e3df30d 100644
--- a/src/Client/TexturePack.c
+++ b/src/Client/TexturePack.c
@@ -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;