C client: Fix skins using all 64 characters not working

This commit is contained in:
UnknownShadow200 2018-09-10 14:00:32 +10:00
parent 446098e82c
commit 5f12a5b869
6 changed files with 99 additions and 100 deletions

View File

@ -309,7 +309,6 @@ namespace ClassicalSharp.Gui.Widgets {
struct Portion { public int Beg, Len, LineBeg, LineLen; }
unsafe int Reduce(char* chars, int target, Portion* portions) {
Portion* start = portions;
int charsLen = 0, count = 0;
int* begs = stackalloc int[lines.Length];
int* ends = stackalloc int[lines.Length];

View File

@ -18,10 +18,7 @@ namespace ClassicalSharp.Map {
public WorldEnv Env;
public Guid Uuid;
public string TextureUrl = null;
public World(Game game) {
Env = new WorldEnv(game);
}
public World(Game game) { Env = new WorldEnv(); }
public void Reset() {
Env.Reset();

View File

@ -54,12 +54,7 @@ namespace ClassicalSharp.Map {
public float SkyboxHorSpeed, SkyboxVerSpeed;
public bool ExpFog;
Game game;
public WorldEnv(Game game) {
this.game = game;
ResetLight();
}
public WorldEnv() { ResetLight(); }
public void Reset() {
EdgeHeight = -1; SidesOffset = -2; CloudHeight = -1;

View File

@ -15,8 +15,6 @@ namespace ClassicalSharp.Textures {
/// <summary> Extracts resources from a .zip texture pack. </summary>
public sealed class TexturePack {
static Game game;
public static void ExtractDefault(Game game) {
ExtractZip(game.DefaultTexturePack, game);
game.World.TextureUrl = null;
@ -46,7 +44,6 @@ namespace ClassicalSharp.Textures {
}
static void ExtractZip(Stream stream, Game game) {
TexturePack.game = game;
Events.RaiseTexturePackChanged();
if (game.Graphics.LostContext) return;

View File

@ -28,7 +28,7 @@ struct AsyncRequest {
UInt32 ResultSize;
UInt64 LastModified; /* Time item cached at (if at all) */
UInt8 Etag[STRING_SIZE]; /* ETag of cached item (if any) */
char Etag[STRING_SIZE]; /* ETag of cached item (if any) */
UInt8 RequestType;
};

View File

@ -897,8 +897,11 @@ void Http_Init(void) {
static ReturnCode Http_Make(struct AsyncRequest* req, HINTERNET* handle) {
String url = String_FromRawArray(req->URL);
WCHAR urlStr[300]; Platform_ConvertString(urlStr, &url);
char headersBuffer[STRING_SIZE * 2] = { 0 };
String headers = String_FromArray(headersBuffer);
WCHAR headersStr[STRING_SIZE * 2 + 1];
/* https://stackoverflow.com/questions/25308488/c-wininet-custom-http-headers */
if (req->Etag[0] || req->LastModified) {
@ -917,7 +920,13 @@ static ReturnCode Http_Make(struct AsyncRequest* req, HINTERNET* handle) {
String_AppendConst(&headers, "\r\n\r\n");
} else { headers.buffer = NULL; }
*handle = InternetOpenUrlA(hInternet, url.buffer, headers.buffer, headers.length,
Int32 i;
for (i = 0; i < headers.length; i++) {
headersStr[i] = headers.buffer[i];
}
headersStr[headers.length] = '\0';
*handle = InternetOpenUrlW(hInternet, urlStr, headersStr, headers.length,
INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_UI | INTERNET_FLAG_RELOAD, 0);
return Win_Return(*handle);
}
@ -1080,10 +1089,12 @@ static size_t Http_GetData(char *buffer, size_t size, size_t nitems, struct Asyn
ReturnCode Http_Do(struct AsyncRequest* req, volatile Int32* progress) {
curl_easy_reset(curl);
String url = String_FromRawArray(req->URL);
char urlStr[600]; Platform_ConvertString(urlStr, &url);
struct curl_slist* list = Http_Make(req);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
curl_easy_setopt(curl, CURLOPT_URL, url.buffer);
curl_easy_setopt(curl, CURLOPT_URL, urlStr);
curl_easy_setopt(curl, CURLOPT_USERAGENT, PROGRAM_APP_NAME);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);