ref: cd9df8ec47aa0dcda02632a2427199bc64399ada
parent: 08d9ca4ad8fe0d274e900545d1b26fd1cab4902e
parent: 2453c456afd41d933382fa1d5f66430a271987b8
author: Cucky <44537737+cuckydev@users.noreply.github.com>
date: Wed Feb 13 10:54:08 EST 2019
Merge pull request #65 from Clownacy/master Shut up some warnings
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@
* RELEASE=1 to compile a release build (optimised, stripped, etc.)
* STATIC=1 to produce a statically-linked executable (good for Windows builds)
* JAPANESE=1 to enable the Japanese-language build (instead of the unofficial Aeon Genesis English translation)
-* FIX_BUGS=1 to fix certain bugs (see [src/Bug Fixes.txt](https://github.com/cuckydev/Cave-Story-Engine-2/blob/master/src/Bug%20Fixes.txt))
+* FIX_BUGS=1 to fix certain bugs (see [src/Bug Fixes.txt](src/Bug%20Fixes.txt))
* WINDOWS=1 to enable Windows-only features like a unique file/taskbar icon, and system font loading (needed for the font setting in Config.dat to do anything)
## Running
--- a/src/Back.cpp
+++ b/src/Back.cpp
@@ -167,11 +167,11 @@
if (gBack.type == 3)
{
int x_1 = fx / 0x4000;
- int x_2 = fx / 0x4000 + (((WINDOW_WIDTH + 31) >> 5) + 1);
+ int x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1);
int y_1 = 0;
- int y_2 = 32;
+ int y_2 = y_1 + 32;
- for (int y = 0; y < y_2; y++)
+ for (int y = y_1; y < y_2; y++)
{
int ypos = (y << 14) / 0x200 - fy / 0x200 + gWaterY / 0x200;
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -187,21 +187,21 @@
int pitch;
SDL_LockTexture(surf[surf_no].texture, NULL, (void**)&raw_pixels, &pitch);
- unsigned char (*src_pixels)[surf[surf_no].surface->pitch / 4][4] = (unsigned char (*)[surf[surf_no].surface->pitch/ 4][4])surf[surf_no].surface->pixels;
- unsigned char (*dst_pixels)[pitch / 4][4] = (unsigned char (*)[pitch/ 4][4])raw_pixels;
-
for (int h = 0; h < surf[surf_no].surface->h; ++h)
{
for (int w = 0; w < surf[surf_no].surface->w; ++w)
{
- dst_pixels[h][w][0] = src_pixels[h][w][0];
- dst_pixels[h][w][1] = src_pixels[h][w][1];
- dst_pixels[h][w][2] = src_pixels[h][w][2];
+ unsigned char *src_pixel = (unsigned char*)surf[surf_no].surface->pixels + (h * surf[surf_no].surface->pitch) + (w * 4);
+ unsigned char *dst_pixel = (unsigned char*)raw_pixels + (h * pitch) + (w * 4);
- if (src_pixels[h][w][0] || src_pixels[h][w][1] || src_pixels[h][w][2]) // Colour-key
- dst_pixels[h][w][3] = 0xFF;
+ dst_pixel[0] = src_pixel[0];
+ dst_pixel[1] = src_pixel[1];
+ dst_pixel[2] = src_pixel[2];
+
+ if (src_pixel[0] || src_pixel[1] || src_pixel[2]) // Colour-key
+ dst_pixel[3] = 0xFF;
else
- dst_pixels[h][w][3] = 0;
+ dst_pixel[3] = 0;
}
}
@@ -254,24 +254,24 @@
else
{
// Upscale the bitmap to the game's native resolution (SDL_BlitScaled is buggy, so we have to do it on our own)
- const unsigned char (*src_pixels)[converted_surface->pitch] = (unsigned char(*)[converted_surface->pitch])converted_surface->pixels;
- unsigned char (*dst_pixels)[surf[surf_no].surface->pitch] = (unsigned char(*)[surf[surf_no].surface->pitch])surf[surf_no].surface->pixels;
-
for (int h = 0; h < converted_surface->h; ++h)
{
- const unsigned long *src_row = (unsigned long*)src_pixels[h];
- unsigned long *dst_row = (unsigned long*)dst_pixels[h * magnification];
+ const unsigned char *src_row = (unsigned char*)converted_surface->pixels + h * converted_surface->pitch;
+ unsigned char *dst_row = (unsigned char*)surf[surf_no].surface->pixels + h * surf[surf_no].surface->pitch * magnification;
+ const unsigned long *src_ptr = (unsigned long*)src_row;
+ unsigned long *dst_ptr = (unsigned long*)dst_row;
+
for (int w = 0; w < converted_surface->w; ++w)
{
- const unsigned long src_pixel = *src_row++;
+ const unsigned long src_pixel = *src_ptr++;
for (int i = 0; i < magnification; ++i)
- *dst_row++ = src_pixel;
+ *dst_ptr++ = src_pixel;
}
for (int i = 1; i < magnification; ++i)
- memcpy(dst_pixels[(h * magnification) + i], dst_pixels[h * magnification], surf[surf_no].surface->w * sizeof(unsigned long));
+ memcpy(dst_row + i * surf[surf_no].surface->pitch, dst_row, surf[surf_no].surface->w * sizeof(unsigned long));
}
SDL_FreeSurface(converted_surface);
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -58,7 +58,7 @@
case 3:
case 4:
length = zero_bit;
- charcode = string[0] & ((1 << (8 - zero_bit))) - 1;
+ charcode = string[0] & ((1 << (8 - zero_bit)) - 1);
for (unsigned int i = 1; i < zero_bit; ++i)
{
@@ -181,8 +181,6 @@
{
const unsigned char colours[3] = {(unsigned char)(colour >> 16), (unsigned char)(colour >> 8), (unsigned char)colour};
- unsigned char (*surface_buffer)[surface->pitch / 4][4] = (unsigned char (*)[surface->pitch / 4][4])surface->pixels;
-
FT_Face face = font_object->face;
unsigned int pen_x = 0;
@@ -236,11 +234,9 @@
{
for (int ix = MAX(-letter_x, 0); letter_x + ix < MIN(letter_x + (int)converted.width / 3, surface->w); ++ix)
{
- const unsigned char (*font_buffer)[converted.pitch / 3][3] = (unsigned char (*)[converted.pitch / 3][3])converted.buffer;
+ const unsigned char *font_pixel = converted.buffer + iy * converted.pitch + ix * 3;
+ unsigned char *surface_pixel = (unsigned char*)surface->pixels + (letter_y + iy) * surface->pitch + (letter_x + ix) * 4;
- const unsigned char *font_pixel = font_buffer[iy][ix];
- unsigned char *surface_pixel = surface_buffer[letter_y + iy][letter_x + ix];
-
if (font_pixel[0] || font_pixel[1] || font_pixel[2])
{
for (unsigned int j = 0; j < 3; ++j)
@@ -257,11 +253,11 @@
{
for (int ix = MAX(-letter_x, 0); letter_x + ix < MIN(letter_x + (int)converted.width, surface->w); ++ix)
{
- unsigned char (*font_buffer)[converted.pitch] = (unsigned char (*)[converted.pitch])converted.buffer;
+ const unsigned char font_pixel = converted.buffer[iy * converted.pitch + ix];
- const double alpha = pow((double)font_buffer[iy][ix] / (converted.num_grays - 1), 1.0 / 1.8); // Gamma-corrected
+ const double alpha = pow((double)font_pixel / (converted.num_grays - 1), 1.0 / 1.8); // Gamma-corrected
- unsigned char *surface_pixel = surface_buffer[letter_y + iy][letter_x + ix];
+ unsigned char *surface_pixel = (unsigned char*)surface->pixels + (letter_y + iy) * surface->pitch + (letter_x + ix) * 4;
if (alpha)
{
@@ -276,11 +272,11 @@
{
for (int ix = MAX(-letter_x, 0); letter_x + ix < MIN(letter_x + (int)converted.width, surface->w); ++ix)
{
- unsigned char (*font_buffer)[converted.pitch] = (unsigned char (*)[converted.pitch])converted.buffer;
+ const unsigned char font_pixel = converted.buffer[iy * converted.pitch + ix];
- unsigned char *surface_pixel = surface_buffer[letter_y + iy][letter_x + ix];
+ unsigned char *surface_pixel = (unsigned char*)surface->pixels + (letter_y + iy) * surface->pitch + (letter_x + ix) * 4;
- if (font_buffer[iy][ix])
+ if (font_pixel)
{
for (unsigned int j = 0; j < 3; ++j)
surface_pixel[j] = colours[j];
--- a/src/NpcAct160.cpp
+++ b/src/NpcAct160.cpp
@@ -1178,7 +1178,7 @@
if (npc->ym > 0x5FF)
npc->ym = 0x5FF;
- if ( npc->ym < -0x5FFu )
+ if (npc->ym < -0x5FF)
npc->ym = 0x5FF;
npc->x += npc->xm;
--- a/src/NpcAct180.cpp
+++ b/src/NpcAct180.cpp
@@ -564,6 +564,7 @@
npc->ani_no = 1;
npc->act_wait = 0;
npc->bits |= npc_ignoreSolid;
+ // Fallthrough
case 11:
switch (npc->direct)
{
@@ -960,11 +961,6 @@
//Water level
void ActNpc191(NPCHAR *npc)
{
- int v1; // edx
- int v2; // edx
- int v3; // edx
- int v4; // edx
-
switch ( npc->act_no )
{
case 0:
--- a/src/NpcAct320.cpp
+++ b/src/NpcAct320.cpp
@@ -515,7 +515,7 @@
npc->act_no = 41;
npc->act_wait = 0;
npc->ani_no = 0;
- //Fallthorugh
+ //Fallthrough
case 41:
if (++npc->act_wait == 30)
npc->ani_no = 1;