Skip to content

Commit

Permalink
Fix async download progress not working in C client
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Jun 10, 2018
1 parent ea712c6 commit 47a2ee0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
32 changes: 16 additions & 16 deletions src/Client/Block.c
Expand Up @@ -263,17 +263,17 @@ void Block_RecalculateSpriteBB(void) {
}
}

static Real32 Block_GetSpriteBB_MaxY(Int32 size, Int32 tileX, Int32 tileY, Bitmap* bmp) {
static Real32 Block_GetSpriteBB_MinX(Int32 size, Int32 tileX, Int32 tileY, Bitmap* bmp) {
Int32 x, y;
for (y = 0; y < size; y++) {
UInt32* row = Bitmap_GetRow(bmp, tileY * size + y) + (tileX * size);
for (x = 0; x < size; x++) {
for (x = 0; x < size; x++) {
for (y = 0; y < size; y++) {
UInt32* row = Bitmap_GetRow(bmp, tileY * size + y) + (tileX * size);
if (PackedCol_ARGB_A(row[x]) != 0) {
return 1 - (Real32)y / size;
return (Real32)x / size;
}
}
}
return 0;
return 1;
}

static Real32 Block_GetSpriteBB_MinY(Int32 size, Int32 tileX, Int32 tileY, Bitmap* bmp) {
Expand All @@ -289,26 +289,26 @@ static Real32 Block_GetSpriteBB_MinY(Int32 size, Int32 tileX, Int32 tileY, Bitma
return 1;
}

static Real32 Block_GetSpriteBB_MinX(Int32 size, Int32 tileX, Int32 tileY, Bitmap* bmp) {
static Real32 Block_GetSpriteBB_MaxX(Int32 size, Int32 tileX, Int32 tileY, Bitmap* bmp) {
Int32 x, y;
for (x = 0; x < size; x++) {
for (x = size - 1; x >= 0; x--) {
for (y = 0; y < size; y++) {
UInt32* row = Bitmap_GetRow(bmp, tileY * size + y) + (tileX * size);
if (PackedCol_ARGB_A(row[x]) != 0) {
return (Real32)x / size;
return (Real32)(x + 1) / size;
}
}
}
return 1;
return 0;
}

static Real32 Block_GetSpriteBB_MaxX(Int32 size, Int32 tileX, Int32 tileY, Bitmap* bmp) {
static Real32 Block_GetSpriteBB_MaxY(Int32 size, Int32 tileX, Int32 tileY, Bitmap* bmp) {
Int32 x, y;
for (x = size - 1; x >= 0; x--) {
for (y = 0; y < size; y++) {
UInt32* row = Bitmap_GetRow(bmp, tileY * size + y) + (tileX * size);
for (y = 0; y < size; y++) {
UInt32* row = Bitmap_GetRow(bmp, tileY * size + y) + (tileX * size);
for (x = 0; x < size; x++) {
if (PackedCol_ARGB_A(row[x]) != 0) {
return (Real32)(x + 1) / size;
return 1 - (Real32)y / size;
}
}
}
Expand All @@ -323,7 +323,7 @@ void Block_RecalculateBB(BlockID block) {

Real32 minX = Block_GetSpriteBB_MinX(tileSize, x, y, bmp);
Real32 minY = Block_GetSpriteBB_MinY(tileSize, x, y, bmp);
Real32 maxX = Block_GetSpriteBB_RaxX(tileSize, x, y, bmp);
Real32 maxX = Block_GetSpriteBB_MaxX(tileSize, x, y, bmp);
Real32 maxY = Block_GetSpriteBB_MaxY(tileSize, x, y, bmp);

Vector3 centre = VECTOR3_CONST(0.5f, 0.0f, 0.5f);
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Program.c
Expand Up @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions src/Client/WinPlatform.c
Expand Up @@ -680,10 +680,13 @@ ReturnCode Platform_HttpGetRequestData(AsyncRequest* request, void* handle, void
UInt32 left = size, read, totalRead = 0;

while (left > 0) {
//UInt32 toRead = min(4096, left);
//UInt32 avail = 0;
//InternetQueryDataAvailable(handle, &avail, 0, NULL);
bool success = InternetReadFile(handle, buffer, left, &read);
UInt32 toRead = left, avail = 0;
/* only read as much data that is pending */
if (InternetQueryDataAvailable(handle, &avail, 0, NULL)) {
toRead = min(toRead, avail);
}

bool success = InternetReadFile(handle, buffer, toRead, &read);
if (!success) { Platform_MemFree(data); return GetLastError(); }

if (read == 0) break;
Expand Down

0 comments on commit 47a2ee0

Please sign in to comment.