From ffe5c80117468e917a917d63d905cd1c31c867d4 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Mon, 24 Aug 2015 14:32:54 +1000 Subject: [PATCH] Comment tweaks, build tweaks, bugfixes I've also disabled the "screen trick". It was ugly as hell. --- client/base_scene.hpp | 2 +- client/client_application.cpp | 3 +- client/client_application.hpp | 2 +- client/client_utilities/text_util.cpp | 45 --------------------- client/client_utilities/text_util.hpp | 33 --------------- client/entities/base_character.cpp | 2 +- client/entities/entity.hpp | 2 +- client/entities/local_character.cpp | 2 +- client/gameplay_scenes/world_characters.cpp | 3 +- client/gameplay_scenes/world_map.cpp | 3 +- client/menu_scenes/lobby_menu.cpp | 2 +- client/menu_scenes/main_menu.cpp | 2 +- client/menu_scenes/splash_screen.cpp | 13 +++--- common | 2 +- makefile | 3 +- rsc/config.cfg | 3 +- server/characters/character_manager.cpp | 2 +- todo.txt | 3 -- 18 files changed, 22 insertions(+), 105 deletions(-) delete mode 100644 client/client_utilities/text_util.cpp delete mode 100644 client/client_utilities/text_util.hpp diff --git a/client/base_scene.hpp b/client/base_scene.hpp index 0a7b225..20e4872 100644 --- a/client/base_scene.hpp +++ b/client/base_scene.hpp @@ -48,7 +48,7 @@ public: virtual void KeyDown(SDL_KeyboardEvent const& event); virtual void KeyUp(SDL_KeyboardEvent const& event); - //TODO: joystick and controller events + //TODO: (9) joystick and controller events protected: //control diff --git a/client/client_application.cpp b/client/client_application.cpp index d0ee094..9d273ae 100644 --- a/client/client_application.cpp +++ b/client/client_application.cpp @@ -84,7 +84,6 @@ void ClientApplication::Init(int argc, char* argv[]) { //get the info switch(windowInfo.subsystem) { case SDL_SYSWM_WINDOWS: - //TODO: ensure that this works platform = "Microsoft Windows"; fontPath = "C:/Windows/Fonts/arialbd.ttf"; break; @@ -296,7 +295,7 @@ void ClientApplication::ProcessEvents() { activeScene->KeyUp(event.key); break; - //TODO: joystick and controller events + //TODO: (9) joystick and controller events //window events are handled internally case SDL_WINDOWEVENT: diff --git a/client/client_application.hpp b/client/client_application.hpp index af59b14..ea560fe 100644 --- a/client/client_application.hpp +++ b/client/client_application.hpp @@ -49,7 +49,7 @@ private: BaseScene* activeScene = nullptr; - //TODO: build a "window" class? + //TODO: (9) build a "window" class? SDL_Window* window = nullptr; SDL_Renderer* renderer = nullptr; diff --git a/client/client_utilities/text_util.cpp b/client/client_utilities/text_util.cpp deleted file mode 100644 index 6094d20..0000000 --- a/client/client_utilities/text_util.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "text_util.hpp" - -#include - -SDL_Texture* renderPlainText(SDL_Renderer* renderer, TTF_Font* font, std::string str, SDL_Color color) { - //make the surface (from SDL_ttf) - SDL_Surface* surface = TTF_RenderText_Solid(font, str.c_str(), color); - if (!surface) { - throw(std::runtime_error("Failed to create a TTF surface")); - } - - //convert to texture - SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface); - if (!texture) { - SDL_FreeSurface(surface); - throw(std::runtime_error("Failed to create a TTF texture")); - } - - //cleanup - SDL_FreeSurface(surface); - - //NOTE: free the texture yourself - return texture; -} \ No newline at end of file diff --git a/client/client_utilities/text_util.hpp b/client/client_utilities/text_util.hpp deleted file mode 100644 index db62286..0000000 --- a/client/client_utilities/text_util.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#pragma once - -#include "SDL2/SDL.h" -#include "SDL2/SDL_ttf.h" - -#include - -constexpr SDL_Color COLOR_WHITE = {255, 255, 255, 255}; - -//TODO: some kind of persistent display widget -//TODO: I need a full suite of widgets -SDL_Texture* renderPlainText(SDL_Renderer*, TTF_Font*, std::string, SDL_Color color); \ No newline at end of file diff --git a/client/entities/base_character.cpp b/client/entities/base_character.cpp index 7ecc275..eb348c0 100644 --- a/client/entities/base_character.cpp +++ b/client/entities/base_character.cpp @@ -21,7 +21,7 @@ */ #include "base_character.hpp" -//TODO: remove this +//TODO: (3) remove this #include "config_utility.hpp" //------------------------- diff --git a/client/entities/entity.hpp b/client/entities/entity.hpp index 1b6ef16..fb0c653 100644 --- a/client/entities/entity.hpp +++ b/client/entities/entity.hpp @@ -26,7 +26,7 @@ #include "vector2.hpp" //The base class for all objects in the world -//TODO: write a better hierarchy +//TODO: (9) write a better hierarchy class Entity { public: virtual void Update(); diff --git a/client/entities/local_character.cpp b/client/entities/local_character.cpp index 013af5f..283488d 100644 --- a/client/entities/local_character.cpp +++ b/client/entities/local_character.cpp @@ -26,7 +26,7 @@ bool LocalCharacter::ProcessCollisionGrid(std::list boxList) { for(auto& box : boxList) { if (box.CheckOverlap(origin + bounds)) { - //TODO: write a better collision system + //TODO: (9) write a better collision system origin -= motion; motion = {0, 0}; return true; diff --git a/client/gameplay_scenes/world_characters.cpp b/client/gameplay_scenes/world_characters.cpp index 20ebd5c..fc42df4 100644 --- a/client/gameplay_scenes/world_characters.cpp +++ b/client/gameplay_scenes/world_characters.cpp @@ -223,8 +223,7 @@ std::list World::GenerateCollisionGrid(Entity* ptr, int tileWidth, //inner loop wallBounds.y = snapToBase((double)wallBounds.h, ptr->GetOrigin().y); while(wallBounds.y < (ptr->GetOrigin() + ptr->GetBounds()).y + ptr->GetBounds().h) { - //BUG: #45 this is the culprit; it's pulling regions into existance - //check to see if this tile is solid + //check to see if this tile is solid (non-existant tiles are always false) if (regionPager.GetSolid(wallBounds.x / wallBounds.w, wallBounds.y / wallBounds.h)) { //push onto the box set boxList.push_front(wallBounds); diff --git a/client/gameplay_scenes/world_map.cpp b/client/gameplay_scenes/world_map.cpp index f023ea8..d2ec6d1 100644 --- a/client/gameplay_scenes/world_map.cpp +++ b/client/gameplay_scenes/world_map.cpp @@ -29,7 +29,7 @@ //static functions //------------------------- -//TODO: proper checksum +//TODO: (3) proper checksum static int regionChecksum(Region* const region) { int sum = 0; for(int i = 0; i < REGION_WIDTH; i++) { @@ -104,7 +104,6 @@ void World::UpdateMap() { } else if (regionChecksum(region) == 0) { //checksum failed - //BUG: #45 Regions occasionally lose their tile data; this patches the issue, but does not resolve it regionPager.UnloadIf([region](Region const& ref) -> bool { //remove the erroneous region return region == &ref; diff --git a/client/menu_scenes/lobby_menu.cpp b/client/menu_scenes/lobby_menu.cpp index 6740dc1..bd28e51 100644 --- a/client/menu_scenes/lobby_menu.cpp +++ b/client/menu_scenes/lobby_menu.cpp @@ -304,7 +304,7 @@ void LobbyMenu::SendJoinRequest() { void LobbyMenu::SendLoginRequest() { //NOTE: high cohesion - //TODO: have a separate login screen + //TODO: (9) have a separate login screen ClientPacket packet; packet.type = SerialPacketType::LOGIN_REQUEST; packet.clientIndex = clientIndex; diff --git a/client/menu_scenes/main_menu.cpp b/client/menu_scenes/main_menu.cpp index ef153e8..aff31b8 100644 --- a/client/menu_scenes/main_menu.cpp +++ b/client/menu_scenes/main_menu.cpp @@ -63,7 +63,7 @@ MainMenu::MainMenu() { //text box textBox.PushLine(GetRenderer(), font, "Thanks for playing!", {255, 255, 255, 255}); textBox.PushLine(GetRenderer(), font, "You can get the latest version at: ", {255, 255, 255, 255}); - textBox.PushLine(GetRenderer(), font, "krgamestudios.com", {255, 255, 255, 255}); //TODO: click to open the website/update + textBox.PushLine(GetRenderer(), font, "krgamestudios.com", {255, 255, 255, 255}); //TODO: (9) click to open the website/update //debug // diff --git a/client/menu_scenes/splash_screen.cpp b/client/menu_scenes/splash_screen.cpp index fbadeb6..8be6a34 100644 --- a/client/menu_scenes/splash_screen.cpp +++ b/client/menu_scenes/splash_screen.cpp @@ -29,21 +29,21 @@ SplashScreen::SplashScreen(SDL_Window* w) { //fit the screen to the logo - //TODO: refactor the code for this window trick + //NOTE: not using this window trick window = w; SDL_GetWindowSize(window, &windowWidth, &windowHeight); logo.Load(GetRenderer(), ConfigUtility::GetSingleton()["dir.logos"] + "krstudios.png"); - SDL_SetWindowSize(window, logo.GetClipW(), logo.GetClipH()); - SDL_RenderSetLogicalSize(GetRenderer(), logo.GetClipW(), logo.GetClipH()); +// SDL_SetWindowSize(window, logo.GetClipW(), logo.GetClipH()); +// SDL_RenderSetLogicalSize(GetRenderer(), logo.GetClipW(), logo.GetClipH()); startTick = std::chrono::steady_clock::now(); } SplashScreen::~SplashScreen() { - SDL_SetWindowSize(window, windowWidth, windowHeight); - SDL_RenderSetLogicalSize(GetRenderer(), windowWidth, windowHeight); +// SDL_SetWindowSize(window, windowWidth, windowHeight); +// SDL_RenderSetLogicalSize(GetRenderer(), windowWidth, windowHeight); } //------------------------- @@ -51,7 +51,7 @@ SplashScreen::~SplashScreen() { //------------------------- void SplashScreen::FrameStart() { - //TODO: config flag to change the delay + //TODO: (0) config flag to change the delay if (std::chrono::steady_clock::now() - startTick > std::chrono::duration(3)) { SetSceneSignal(SceneSignal::MAINMENU); } @@ -60,6 +60,5 @@ void SplashScreen::FrameStart() { void SplashScreen::RenderFrame(SDL_Renderer* renderer) { int w = 0, h = 0; SDL_RenderGetLogicalSize(renderer, &w, &h); - //TODO: fix logo position logo.DrawTo(renderer, (w - logo.GetClipW()) / 2, (h - logo.GetClipH()) / 2); } diff --git a/common b/common index 0c1232a..a083cce 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 0c1232ae3bfa2eeebd53699eca1d800254334add +Subproject commit a083cce5da91dd48ad4670108c0139894b0a823b diff --git a/makefile b/makefile index 474136f..c259aac 100644 --- a/makefile +++ b/makefile @@ -38,10 +38,11 @@ $(OUTDIR): clean: ifeq ($(OS),Windows_NT) del /s *.o *.a *.exe $(OUTDIR)\*.dll + rmdir $(OUTDIR) else ifeq ($(shell uname), Linux) find . -type f -name '*.o' -exec rm -f -r -v {} \; find . -type f -name '*.a' -exec rm -f -r -v {} \; - rm -f -v $(OUTDIR) + rm $(OUTDIR)/* -f find . -empty -type d -delete endif diff --git a/rsc/config.cfg b/rsc/config.cfg index 2f9e46c..d14ea1c 100644 --- a/rsc/config.cfg +++ b/rsc/config.cfg @@ -1,4 +1,5 @@ #configuration of the programs +#TODO: (9) split this file in two, one for each program #server specific settings server.host = 255.255.255.255 @@ -10,7 +11,7 @@ server.dbname = database.db #client specific settings #client.screen.w = 800 #client.screen.h = 600 -client.screen.f = false +#client.screen.f = false #NOTE: fullscreen option is currently disabled #set this to overwrite the default fonts (platform issues) #client.font = /path/to/font/file.ttf diff --git a/server/characters/character_manager.cpp b/server/characters/character_manager.cpp index 0108b43..b4a613f 100644 --- a/server/characters/character_manager.cpp +++ b/server/characters/character_manager.cpp @@ -244,7 +244,7 @@ void CharacterManager::Unload(int uid) { } void CharacterManager::Delete(int uid) { - //TODO: when deleting a character, move it to an archive table + //TODO: (9) when deleting a character, move it to an archive table //delete this character from the database, then remove it from memory sqlite3_stmt* statement = nullptr; diff --git a/todo.txt b/todo.txt index 3bbb4dd..ebabc4c 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,3 @@ -TODO: upgrade to lua 5.3 -TODO: upgrade to SDL 2.0 -TODO: Split config.cfg in two, one for the server and the client TODO: Consistency for bounds names TODO: Account passwords (list)