Skip to content

Commit

Permalink
Fix for incorrect usage of standart ints
Browse files Browse the repository at this point in the history
Wrong code that did compile on a Windows but stopped compiling on a mac
  • Loading branch information
madwareru committed Jan 12, 2020
1 parent 75afee3 commit ffa5815
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 18 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ set (INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/include
)

find_package(OpenGL REQUIRED)

set(glew-cmake_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(glew-cmake_BUILD_MULTI_CONTEXT OFF CACHE BOOL "" FORCE)
set(glew-cmake_BUILD_STATIC ON CACHE BOOL "" FORCE)
Expand All @@ -41,8 +39,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
target_link_libraries(${PROJECT_NAME}
glfw
libglew_static
kaitai_struct_cpp_stl_runtime
opengl32)
kaitai_struct_cpp_stl_runtime)

set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
Expand Down
3 changes: 2 additions & 1 deletion include/graphics/Sprite16.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef SPRITE_16_H_
#define SPRITE_16_H_

#include <cinttypes>
#include <inttypes.h>
#include <stddef.h>
#include <vector>
#include <tuple>

Expand Down
3 changes: 2 additions & 1 deletion include/graphics/Sprite16a.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef SPRITE_16A_H_
#define SPRITE_16A_H_

#include <cinttypes>
#include <inttypes.h>
#include <stddef.h>
#include <loaders/ksy/rage_of_mages_1_16a.h>

struct SOASpriteRGB;
Expand Down
3 changes: 2 additions & 1 deletion include/graphics/Sprite256.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef SPRITE_256_H__
#define SPRITE_256_H__

#include <cinttypes>
#include <inttypes.h>
#include <stddef.h>
#include <loaders/ksy/rage_of_mages_1_256.h>

struct SOASpriteRGB;
Expand Down
3 changes: 2 additions & 1 deletion include/graphics/soaspritergb.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef SOASPRITERGB_H
#define SOASPRITERGB_H

#include <cinttypes>
#include <inttypes.h>
#include <stddef.h>

struct FrameBuffer;

Expand Down
3 changes: 2 additions & 1 deletion include/graphics/soaspritergba.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef SOASPRITERGBA_H
#define SOASPRITERGBA_H

#include <cinttypes>
#include <inttypes.h>
#include <stddef.h>

struct SOASpriteRGB;

Expand Down
3 changes: 2 additions & 1 deletion include/graphics/tilemap/tilemap_chunk.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef TILEMAP_CHUNK_H
#define TILEMAP_CHUNK_H

#include <cstdint>
#include <inttypes.h>
#include <stddef.h>

struct TileCorners {
uint8_t top_left_height;
Expand Down
8 changes: 4 additions & 4 deletions src/graphics/soaspritergb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

SOASpritePal::SOASpritePal(size_t w, size_t h): width_{w}, height_{h} {
buffer_raw_ = new uint8_t[w * h + 8 + 0x3000];
buffer_ = (reinterpret_cast<int32_t>(&buffer_raw_[0]) % 16 == 0)
buffer_ = (reinterpret_cast<int64_t>(&buffer_raw_[0]) % 16 == 0)
? &buffer_raw_[0]
: &buffer_raw_[8];
pal_r_ = buffer_ + w*h;
Expand Down Expand Up @@ -33,15 +33,15 @@ SOASpriteRGB::SOASpriteRGB(size_t w, size_t h): width_{w}, height_{h} {
g_buffer_raw_ = new uint8_t[w * h + 8];
b_buffer_raw_ = new uint8_t[w * h + 8];

r_buffer_ = (reinterpret_cast<int32_t>(&r_buffer_raw_[0]) % 16 == 0)
r_buffer_ = (reinterpret_cast<int64_t>(&r_buffer_raw_[0]) % 16 == 0)
? &r_buffer_raw_[0]
: &r_buffer_raw_[8];

g_buffer_ = (reinterpret_cast<int32_t>(&g_buffer_raw_[0]) % 16 == 0)
g_buffer_ = (reinterpret_cast<int64_t>(&g_buffer_raw_[0]) % 16 == 0)
? &g_buffer_raw_[0]
: &g_buffer_raw_[8];

b_buffer_ = (reinterpret_cast<int32_t>(&b_buffer_raw_[0]) % 16 == 0)
b_buffer_ = (reinterpret_cast<int64_t>(&b_buffer_raw_[0]) % 16 == 0)
? &b_buffer_raw_[0]
: &b_buffer_raw_[8];
}
Expand Down
8 changes: 4 additions & 4 deletions src/graphics/soaspritergba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ SOASpriteRGBA::SOASpriteRGBA(size_t w, size_t h): width_{w}, height_{h} {
b_buffer_raw_ = new uint8_t[w * h + 8];
a_buffer_raw_ = new uint8_t[w * h + 8];

r_buffer_ = (reinterpret_cast<int32_t>(&r_buffer_raw_[0]) % 16 == 0)
r_buffer_ = (reinterpret_cast<int64_t>(&r_buffer_raw_[0]) % 16 == 0)
? &r_buffer_raw_[0]
: &r_buffer_raw_[8];

g_buffer_ = (reinterpret_cast<int32_t>(&g_buffer_raw_[0]) % 16 == 0)
g_buffer_ = (reinterpret_cast<int64_t>(&g_buffer_raw_[0]) % 16 == 0)
? &g_buffer_raw_[0]
: &g_buffer_raw_[8];

b_buffer_ = (reinterpret_cast<int32_t>(&b_buffer_raw_[0]) % 16 == 0)
b_buffer_ = (reinterpret_cast<int64_t>(&b_buffer_raw_[0]) % 16 == 0)
? &b_buffer_raw_[0]
: &b_buffer_raw_[8];

a_buffer_ = (reinterpret_cast<int32_t>(&a_buffer_raw_[0]) % 16 == 0)
a_buffer_ = (reinterpret_cast<int64_t>(&a_buffer_raw_[0]) % 16 == 0)
? &a_buffer_raw_[0]
: &a_buffer_raw_[8];
}
Expand Down

0 comments on commit ffa5815

Please sign in to comment.