소스 검색

Pruned warnings and make format because it's good for everyone.

Eiyeron Fulmincendii 10 년 전
부모
커밋
c39d869b57
9개의 변경된 파일95개의 추가작업 그리고 82개의 파일을 삭제
  1. 3 1
      platform/include/Graphics.h
  2. 25 17
      platform/nspire/Graphics.cpp
  3. 3 2
      platform/nspire/Quirks.cpp
  4. 26 19
      platform/sfml/Graphics.cpp
  5. 12 12
      src/engine/StateMachine.cpp
  6. 9 14
      src/input/Input.cpp
  7. 6 4
      src/piaf/Archive.cpp
  8. 4 5
      src/piaf/Archive.h
  9. 7 8
      src/piaf/Exceptions.cpp

+ 3 - 1
platform/include/Graphics.h

@@ -36,7 +36,9 @@ namespace WalrusRPG
         void put_sprite(const WalrusRPG::Graphics::Texture &sheet, int x, int y,
                         const WalrusRPG::Utils::Rect &window);
 
-        void put_sprite_clipping(const Texture &sheet, int x, int y, const WalrusRPG::Utils::Rect &sprite_window, const WalrusRPG::Utils::Rect &clipping_window);
+        void put_sprite_clipping(const Texture &sheet, int x, int y,
+                                 const WalrusRPG::Utils::Rect &sprite_window,
+                                 const WalrusRPG::Utils::Rect &clipping_window);
         /*
          * Draws a sprite with clipping given as window and color
          * tinting.

+ 25 - 17
platform/nspire/Graphics.cpp

@@ -40,40 +40,48 @@ void Graphics::put_sprite_tint(const Texture &sheet, int x, int y, const Rect &w
     CXfb::draw_sprite_sheet_tint(sheet.data, x, y, window, color.value);
 }
 
-void Graphics::put_sprite_clipping(const Texture &sheet, int x, int y, const Rect &sprite_window, const Rect &clipping_window)
+void Graphics::put_sprite_clipping(const Texture &sheet, int x, int y,
+                                   const Rect &sprite_window, const Rect &clipping_window)
 {
     const signed &ss_x = sprite_window.x, ss_y = sprite_window.y;
     const signed &ss_w = sprite_window.width, &ss_h = sprite_window.height;
-    const signed &cx = clipping_window.x, &cy = clipping_window.y; 
-    const signed &cw = clipping_window.width, &ch = clipping_window.height; 
+    const signed &cx = clipping_window.x, &cy = clipping_window.y;
+    const signed &cw = clipping_window.width, &ch = clipping_window.height;
     const signed lx = x - cx, ly = y - cy;
-   
-    if(lx < -ss_w || lx > cw) return;
-    if(ly < -ss_h || ly > ch) return;
+
+    if (lx < -ss_w || lx > cw)
+        return;
+    if (ly < -ss_h || ly > ch)
+        return;
 
     signed fx = x, fy = y;
-    signed fssx = ss_x, fssy = ss_y, fssw = ss_w, fssh = ss_h;
-   
-    if(lx < 0) {
-        fssw = ss_w+lx;
+    unsigned fssx = ss_x, fssy = ss_y;
+    signed fssw = ss_w, fssh = ss_h;
+
+    if (lx < 0)
+    {
+        fssw = ss_w + lx;
         fssx = -lx;
         fx = cx;
     }
 
-    if(lx > cw - ss_w) {
-        fssw -= lx-(cw - ss_w);
+    if (lx > cw - ss_w)
+    {
+        fssw -= lx - (cw - ss_w);
     }
 
-    if(ly > ch - ss_h) {
-        fssh -= ly-(ch - ss_h);
+    if (ly > ch - ss_h)
+    {
+        fssh -= ly - (ch - ss_h);
     }
 
-    if(ly < 0) {
-        fssh = ss_h+ly;
+    if (ly < 0)
+    {
+        fssh = ss_h + ly;
         fssy = -ly;
         fy = cy;
     }
-    
+
     CXfb::draw_sprite_sheet(sheet.data, fx, fy, {fssx, fssy, fssw, fssh});
 }
 

+ 3 - 2
platform/nspire/Quirks.cpp

@@ -45,10 +45,11 @@ void Quirks::deinit()
 std::unique_ptr<char> Quirks::solve_absolute_path(const char *path)
 {
     const char nspire_suffix[] = ".tns";
-    std::unique_ptr<char> result(new char[strlen(base_path) + strlen(path) + strlen(nspire_suffix)+1]);
+    std::unique_ptr<char> result(
+        new char[strlen(base_path) + strlen(path) + strlen(nspire_suffix) + 1]);
     strcpy(result.get(), base_path);
     strcpy(&result.get()[strlen(base_path)], path);
-    strcpy(&result.get()[strlen(base_path)+strlen(path)], nspire_suffix);
+    strcpy(&result.get()[strlen(base_path) + strlen(path)], nspire_suffix);
     result.get()[strlen(base_path) + strlen(path) + strlen(nspire_suffix)] = '\0';
     return result;
 }

+ 26 - 19
platform/sfml/Graphics.cpp

@@ -74,36 +74,43 @@ void Graphics::put_sprite_tint(const WalrusRPG::Graphics::Texture &sheet, int x,
     buffer.draw(sprite);
 }
 
-void Graphics::put_sprite_clipping(const Texture &sheet, int x, int y, const Rect &sprite_window, const Rect &clipping_window)
+void Graphics::put_sprite_clipping(const Texture &sheet, int x, int y,
+                                   const Rect &sprite_window, const Rect &clipping_window)
 {
     const signed &ss_x = sprite_window.x, ss_y = sprite_window.y;
     const signed &ss_w = sprite_window.width, &ss_h = sprite_window.height;
-    const signed &cx = clipping_window.x, &cy = clipping_window.y; 
-    const signed &cw = clipping_window.width, &ch = clipping_window.height; 
+    const signed &cx = clipping_window.x, &cy = clipping_window.y;
+    const signed &cw = clipping_window.width, &ch = clipping_window.height;
     const signed lx = x - cx, ly = y - cy;
-   
-    if(lx < -ss_w || lx > cw) return;
-    if(ly < -ss_h || ly > ch) return;
+
+    if (lx < -ss_w || lx > cw)
+        return;
+    if (ly < -ss_h || ly > ch)
+        return;
 
     signed fx = x, fy = y;
     signed fssx = ss_x, fssy = ss_y, fssw = ss_w, fssh = ss_h;
-   
-    if(lx < 0) {
-        fssw = ss_w+lx;
+
+    if (lx < 0)
+    {
+        fssw = ss_w + lx;
         fssx = -lx;
         fx = cx;
     }
 
-    if(lx > cw - ss_w) {
-        fssw -= lx-(cw - ss_w);
+    if (lx > cw - ss_w)
+    {
+        fssw -= lx - (cw - ss_w);
     }
 
-    if(ly > ch - ss_h) {
-        fssh -= ly-(ch - ss_h);
+    if (ly > ch - ss_h)
+    {
+        fssh -= ly - (ch - ss_h);
     }
 
-    if(ly < 0) {
-        fssh = ss_h+ly;
+    if (ly < 0)
+    {
+        fssh = ss_h + ly;
         fssy = -ly;
         fy = cy;
     }
@@ -115,7 +122,7 @@ void Graphics::put_sprite_clipping(const Texture &sheet, int x, int y, const Rec
     buffer.draw(sprite);
 }
 
-    
+
 void Graphics::fill(const Pixel &color)
 {
     buffer.clear(sf::Color(color.r << 3, color.g << 2, color.b << 3, 255));
@@ -133,12 +140,12 @@ void Graphics::put_pixel(uint16_t x, uint16_t y, const Pixel &color)
 void Graphics::put_horizontal_line(uint16_t x, uint16_t x2, uint16_t y,
                                    const Pixel &color)
 {
-    put_rectangle({x,y,x2-x+1, 1}, color);
+    put_rectangle({x, y, x2 - x + 1, 1}, color);
 }
 
 void Graphics::put_vertical_line(uint16_t x, uint16_t y, uint16_t y2, const Pixel &color)
 {
-    put_rectangle({x,y, 1, y2-y+1}, color);
+    put_rectangle({x, y, 1, y2 - y + 1}, color);
 }
 
 void Graphics::put_line(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2,
@@ -146,7 +153,7 @@ void Graphics::put_line(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2,
 {
     sf::Color lineColor(color.r << 3, color.g << 2, color.b << 3, 255);
     sf::Vertex line[] = {sf::Vertex(sf::Vector2f(x, y), lineColor),
-                         sf::Vertex(sf::Vector2f(x2+1, y2+1), lineColor)};
+                         sf::Vertex(sf::Vector2f(x2 + 1, y2 + 1), lineColor)};
 
     buffer.draw(line, 2, sf::Lines);
 }

+ 12 - 12
src/engine/StateMachine.cpp

@@ -14,26 +14,27 @@ using WalrusRPG::Input::KeyState;
 
 #define STATEMACHINE WalrusRPG::StateMachine
 
-namespace  {
+namespace
+{
     void draw_button(unsigned x, unsigned y, KeyState state)
     {
-        put_horizontal_line(x+1, x+5, y, Gray);
-        put_horizontal_line(x+1, x+5, y+6, Gray);
-        put_vertical_line(x, y+1, y+5, Gray);
-        put_vertical_line(x+6, y+1, y+5, Gray);
-        switch(state)
+        put_horizontal_line(x + 1, x + 5, y, Gray);
+        put_horizontal_line(x + 1, x + 5, y + 6, Gray);
+        put_vertical_line(x, y + 1, y + 5, Gray);
+        put_vertical_line(x + 6, y + 1, y + 5, Gray);
+        switch (state)
         {
             case KeyState::KS_RELEASED:
-                put_rectangle({x+1, y+1, 5, 5}, White);
+                put_rectangle({x + 1, y + 1, 5, 5}, White);
                 break;
             case KeyState::KS_JUST_RELEASED:
-                put_rectangle({x+1, y+1, 5, 5}, Magenta);
+                put_rectangle({x + 1, y + 1, 5, 5}, Magenta);
                 break;
             case KeyState::KS_JUST_PRESSED:
-                put_rectangle({x+1, y+1, 5, 5}, Cyan);
+                put_rectangle({x + 1, y + 1, 5, 5}, Cyan);
                 break;
             case KeyState::KS_PRESSED:
-                put_rectangle({x+1, y+1, 5, 5}, Black);
+                put_rectangle({x + 1, y + 1, 5, 5}, Black);
                 break;
         }
     }
@@ -52,7 +53,6 @@ namespace  {
 
         draw_button(48, 44, key_get_state(Key::K_B));
         draw_button(56, 36, key_get_state(Key::K_A));
-
     }
 } /* namespace  */
 
@@ -101,7 +101,7 @@ void STATEMACHINE::run()
             stack.back()->render(100 * frame_time / TIMER_FREQ);
             last_frame = frame_stamp;
 
-            Text::print_format(0, 0,"WalrusRPG test build %s", git_version);
+            Text::print_format(0, 0, "WalrusRPG test build %s", git_version);
             if (frame_time != 0 && update_time != 0)
             {
                 Text::print_format(0, 240 - 8, "%ufps, %uups", TIMER_FREQ / frame_time,

+ 9 - 14
src/input/Input.cpp

@@ -23,27 +23,22 @@ struct KeyBuffer key_states[Key::K_SIZE] = {{false, false}};
 #ifdef SFML
 using sf::Keyboard;
 InputMap key_map[] = {
-    {Key::K_A, Keyboard::W},
-    {Key::K_B, Keyboard::X},
-    {Key::K_L, Keyboard::Q},
-    {Key::K_R, Keyboard::S},
+    {Key::K_A, Keyboard::W},          {Key::K_B, Keyboard::X},
+    {Key::K_L, Keyboard::Q},          {Key::K_R, Keyboard::S},
 
-    {Key::K_UP, Keyboard::Up},
-    {Key::K_DOWN, Keyboard::Down},
-    {Key::K_LEFT, Keyboard::Left},
-    {Key::K_RIGHT, Keyboard::Right},
+    {Key::K_UP, Keyboard::Up},        {Key::K_DOWN, Keyboard::Down},
+    {Key::K_LEFT, Keyboard::Left},    {Key::K_RIGHT, Keyboard::Right},
 
-    {Key::K_START, Keyboard::Return},
-    {Key::K_SELECT, Keyboard::BackSpace},
+    {Key::K_START, Keyboard::Return}, {Key::K_SELECT, Keyboard::BackSpace},
 };
 #endif
 #ifdef NSPIRE
 static InputMap key_map[] = {
-    {Key::K_A, KEY_NSPIRE_CTRL},     {Key::K_B, KEY_NSPIRE_SHIFT},
-    {Key::K_L, KEY_NSPIRE_TAB},      {Key::K_R, KEY_NSPIRE_MENU},
+    {Key::K_A, KEY_NSPIRE_CTRL},    {Key::K_B, KEY_NSPIRE_SHIFT},
+    {Key::K_L, KEY_NSPIRE_TAB},     {Key::K_R, KEY_NSPIRE_MENU},
 
-    {Key::K_UP, KEY_NSPIRE_8},       {Key::K_DOWN, KEY_NSPIRE_5},
-    {Key::K_LEFT, KEY_NSPIRE_4},     {Key::K_RIGHT, KEY_NSPIRE_6},
+    {Key::K_UP, KEY_NSPIRE_8},      {Key::K_DOWN, KEY_NSPIRE_5},
+    {Key::K_LEFT, KEY_NSPIRE_4},    {Key::K_RIGHT, KEY_NSPIRE_6},
 
     {Key::K_START, KEY_NSPIRE_DOC}, {Key::K_SELECT, KEY_NSPIRE_ESC},
 };

+ 6 - 4
src/piaf/Archive.cpp

@@ -96,7 +96,8 @@ Archive::Archive(const char *filepath)
     // File to small exception trigger
     if (filesize < 32)
     {
-        throw PIAF::PIAFException("%s: File too small (%s): %d", __FILE__, filepath, filesize);
+        throw PIAF::PIAFException("%s: File too small (%s): %d", __FILE__, filepath,
+                                  filesize);
     }
 
     // Tempoary buffer to contain the header.
@@ -131,7 +132,8 @@ Archive::Archive(const char *filepath)
     {
         // std::exception up;
         // throw up; // haha
-        throw PIAF::PIAFException("%s: Wrong(%s) : %08x is not supported by %08x", __FILE__, filepath, version, ARCHIVE_VERSION);
+        throw PIAF::PIAFException("%s: Wrong(%s) : %08x is not supported by %08x",
+                                  __FILE__, filepath, version, ARCHIVE_VERSION);
     }
 
 
@@ -189,7 +191,6 @@ Archive::Archive(const char *filepath)
 #if NSPIRE
     Interrupts::init();
 #endif
-
 }
 
 Archive::~Archive()
@@ -242,7 +243,8 @@ File Archive::get(const char *filename)
                 if (fread(data, sizeof(uint8_t), entries[index].file_size, file) !=
                     entries[index].file_size)
                 {
-                    throw PIAF::PIAFException("%s: couldn't load %s from an archive.", filename);
+                    throw PIAF::PIAFException("%s: couldn't load %s from an archive.",
+                                              filename);
                 }
                 else
                 {

+ 4 - 5
src/piaf/Archive.h

@@ -72,16 +72,15 @@ namespace WalrusRPG
 
         class PIAFException : public std::exception
         {
-            private:
-                char msg[1024];
+          private:
+            char msg[1024];
 
-            public:
+          public:
             PIAFException(const char *format, ...);
             virtual ~PIAFException();
 
-            const char* what() const throw();
+            const char *what() const throw();
         };
-
     }
 }
 

+ 7 - 8
src/piaf/Exceptions.cpp

@@ -6,20 +6,19 @@
 using WalrusRPG::PIAF::PIAFException;
 using namespace WalrusRPG::PIAF;
 
-PIAFException::PIAFException(const char *format, ...)
-	: msg("")
+PIAFException::PIAFException(const char *format, ...) : msg("")
 {
-	va_list list;
-	va_start(list, format);
-	vsnprintf(msg, 1024, format, list);
-	va_end(list);
+    va_list list;
+    va_start(list, format);
+    vsnprintf(msg, 1024, format, list);
+    va_end(list);
 }
 
 PIAFException::~PIAFException()
 {
 }
 
-const char* PIAFException::what() const throw()
+const char *PIAFException::what() const throw()
 {
-	return msg;
+    return msg;
 }