From a44540462145212f7f2cc3ea2690308c58f60358 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 21 Dec 2016 21:29:59 -0500 Subject: kinda big: texture redo, main cleanup --- main.cpp | 409 +++++++++++++++++++++++---------------------------------------- 1 file changed, 147 insertions(+), 262 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index a3901a3..8579707 100644 --- a/main.cpp +++ b/main.cpp @@ -1,81 +1,66 @@ -/* ---------------------------------------------------------------------------- -** The main file, home of the main loop. -** --------------------------------------------------------------------------*/ -// ... -/* ---------------------------------------------------------------------------- -** Includes section -** --------------------------------------------------------------------------*/ - -#include - -#include +/** + * @file main.cpp + * The main file, where it all happens. + */ -#include -#include -#include +// standard library includes +#include +#include +#include +using namespace std::literals::chrono_literals; // local library includes +#include #include using namespace tinyxml2; -// local game includes -#include +// our own includes +#include #include -#include -#include +#include +#include #include #include +#include +#include +#include +#include -#include -#include -#include - -using namespace std::literals::chrono_literals; - -/* ---------------------------------------------------------------------------- -** Variables section -** --------------------------------------------------------------------------*/ - -// the currently used folder to grab XML files +/** + * The currently used folder to look for XML files in. + */ std::string xmlFolder; -// the current menu +/** + * The current menu, if any are open (TODO why is this here) + */ Menu *currentMenu; -// keeps a simple palette of colors for single-color draws -GLuint colorIndex; - -// the mouse's texture -GLuint mouseTex; - -// the center of the screen +/** + * The current center of the screen, updated in main render. + */ vec2 offset; -/* - * fps contains the game's current FPS, debugY contains the player's - * y coordinates, updated at a certain interval. These are used in - * the debug menu (see below). +/** + * The current FPS of the game. */ +static unsigned int fps = 0; -static unsigned int fps=0; -//static float debugY=0; - -// handles all logic operations -void logic(void); - -// handles all rendering operations void render(void); -/******************************************************************************* -** MAIN ************************************************************************ -********************************************************************************/ - +/** + * The main program. + * Init, load, run. Die. + */ int main(int argc, char *argv[]) { static bool worldReset = false, worldDontReallyRun = false; std::string worldActuallyUseThisXMLFile; - // handle command line arguments + // + // get command line arguments, if any + // + if (argc > 1) { for (int i = 1; i < argc; i++) { std::string s = argv[i]; @@ -89,49 +74,67 @@ int main(int argc, char *argv[]) } } + // + // init the main game engine + // + game::engine.init(); + // used three times below + auto worldSys = game::engine.getSystem(); + // // initialize GLEW + // + #ifndef __WIN32__ glewExperimental = GL_TRUE; #endif - GLenum err; - if ((err = glewInit()) != GLEW_OK) - UserError(std::string("GLEW was not able to initialize! Error: ") + reinterpret_cast(glewGetErrorString(err))); + auto glewError = glewInit(); + if (glewError != GLEW_OK) + UserError(std::string("GLEW was not able to initialize! Error: ") + + reinterpret_cast(glewGetErrorString(glewError))); + + // + // start the random number generator (TODO our own?) + // - // start the random number generator randInit(millis()); - // 'basic' OpenGL setup + // + // some basic OpenGL setup stuff + // + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetSwapInterval(1); // v-sync - SDL_ShowCursor(SDL_DISABLE); // hide the mouse + // enable v-sync (TODO but 1000 fps?) + SDL_GL_SetSwapInterval(1); + // hide the cursor + SDL_ShowCursor(SDL_DISABLE); + // switch to pixel grid glViewport(0, 0, game::SCREEN_WIDTH, game::SCREEN_HEIGHT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glClearColor(1,1,1,1); - - // TODO - Texture::initColorIndex(); + glClearColor(1, 1, 1, 1); + // // initialize shaders - std::cout << "Initializing shaders!\n"; + // - // create shaders + std::cout << "Initializing shaders!\n"; Render::initShaders(); + Colors::init(); + + // + // load some saved data + // - // load up some fresh hot brice game::briceLoad(); game::briceUpdate(); - // load sprites used in the inventory menu. See src/inventory.cpp - //initInventorySprites(); - - // load mouse texture, and other inventory textures - mouseTex = Texture::loadTexture("assets/mouse.png"); - + // // get a world + // + if (xmlFolder.empty()) xmlFolder = "xml/"; @@ -143,69 +146,57 @@ int main(int argc, char *argv[]) // alphabetically sort files strVectorSortAlpha(&xmlFiles); + // kill the world if needed if (worldReset) { - for (const auto &xf : xmlFiles) { - if (xf[0] != '.') { - XMLDocument xmld; - auto file = xmlFolder + xf; - xmld.LoadFile(file.c_str()); - - auto xmle = xmld.FirstChildElement("World"); - - if (xmle == nullptr) { - xmle = xmld.FirstChildElement("IndoorWorld"); - - if (xmle == nullptr) - continue; - } - - xmle = xmle->FirstChildElement(); - while (xmle) { - xmle->DeleteAttribute("x"); - xmle->DeleteAttribute("y"); - xmle->DeleteAttribute("health"); - xmle->DeleteAttribute("alive"); - xmle->DeleteAttribute("dindex"); - xmle = xmle->NextSiblingElement(); - } - - xmld.SaveFile(file.c_str(), false); - } - } - + // TODO TODO TODO we do xml/*.dat now... game::briceClear(); - - std::ofstream pdat ("xml/.main.dat", std::ios::out); - pdat.close(); } + // either load the given XML, or find one if (!worldActuallyUseThisXMLFile.empty()) { - game::engine.getSystem()->load(worldActuallyUseThisXMLFile); + worldSys->load(worldActuallyUseThisXMLFile); } else { // load the first valid XML file for the world for (const auto &xf : xmlFiles) { if (xf[0] != '.') { // read it in std::cout << "File to load: " << xf << '\n'; - game::engine.getSystem()->load(xf); + worldSys->load(xf); break; } } } + // + // initialize ui + // + ui::menu::init(); + ///////////////////////////// + // // + // actually start the game // + // // + ///////////////////////////// if (!worldDontReallyRun) { - // the main loop, in all of its gloriousness.. + // the main loop, in all of its gloriousness... std::thread thMain ([&] { const bool &run = game::engine.shouldRun; while (run) { game::time::mainLoopHandler(); - if (game::time::tickHasPassed()) - logic(); + if (game::time::tickHasPassed()) { + // calculate the world shading value + worldShade = 50 * sin((game::time::getTickCount() + (DAY_CYCLE / 2)) / (DAY_CYCLE / PI)); + + // update fades + ui::fadeUpdate(); + + // increment game ticker + game::time::tick(); + } game::engine.update(game::time::getDeltaTime()); @@ -217,74 +208,88 @@ int main(int argc, char *argv[]) std::thread thDebug ([&] { const bool &run = game::engine.shouldRun; while (run) { - fps = 1000 / game::time::getDeltaTime(); -// debugY = player->loc.y; - + fps = 1000 / game::time::getDeltaTime(); // TODO really? std::this_thread::sleep_for(1s); } }); + // thre render loop, renders const bool &run = game::engine.shouldRun; while (run) { render(); game::engine.render(0); } + // on game end, get back together thMain.join(); thDebug.join(); - //game::engine.getSystem()->thAmbient.join(); + //game::engine.getSystem()->thAmbient.join(); // segfault or something } - // put away the brice for later + // + // put away the brice for later, save world + // + game::briceSave(); + worldSys->save(); + + // + // close things, free stuff, yada yada + // - // free library resources Mix_HaltMusic(); Mix_CloseAudio(); -// destroyInventory(); ui::destroyFonts(); - Texture::freeTextures(); - - // close up the game stuff - game::engine.getSystem()->save(); + unloadTextures(); game::engine.getSystem()->die(); + // + // goodbye + // + return 0; // Calls everything passed to atexit } void render() { - const auto SCREEN_WIDTH = game::SCREEN_WIDTH; - const auto SCREEN_HEIGHT = game::SCREEN_HEIGHT; + static const Texture mouseTex ("assets/mouse.png"); + static const glm::mat4 view = glm::lookAt( + glm::vec3(0.0f, 0.0f, 0.0f), // pos + glm::vec3(0.0f, 0.0f, -10.0f), // looking at + glm::vec3(0.0f, 1.0f, 0.0f) // up vector + ); + + static const auto& SCREEN_WIDTH2 = game::SCREEN_WIDTH / 2.0f; + static const auto& SCREEN_HEIGHT2 = game::SCREEN_HEIGHT / 2.0f; + + // + // set the ortho + // auto ps = game::engine.getSystem(); auto ploc = ps->getPosition(); offset.x = ploc.x + ps->getWidth() / 2; const auto& worldWidth = game::engine.getSystem()->getWidth(); - if (worldWidth < (int)SCREEN_WIDTH) + if (worldWidth < (int)SCREEN_WIDTH2 * 2) offset.x = 0; - else if (offset.x - SCREEN_WIDTH / 2 < worldWidth * -0.5f) - offset.x = ((worldWidth * -0.5f) + SCREEN_WIDTH / 2); - else if (offset.x + SCREEN_WIDTH / 2 > worldWidth * 0.5f) - offset.x = ((worldWidth * 0.5f) - SCREEN_WIDTH / 2); + else if (offset.x - SCREEN_WIDTH2 < worldWidth * -0.5f) + offset.x = ((worldWidth * -0.5f) + SCREEN_WIDTH2); + else if (offset.x + SCREEN_WIDTH2 > worldWidth * 0.5f) + offset.x = ((worldWidth * 0.5f) - SCREEN_WIDTH2); // ortho y snapping - offset.y = std::max(ploc.y /*+ player->height / 2*/, SCREEN_HEIGHT / 2.0f); + offset.y = std::max(ploc.y /*+ player->height / 2*/, SCREEN_HEIGHT2); // "setup" - glm::mat4 projection = glm::ortho(floor(offset.x - SCREEN_WIDTH / 2), // left - floor(offset.x + SCREEN_WIDTH / 2), // right - floor(offset.y - SCREEN_HEIGHT / 2), // bottom - floor(offset.y + SCREEN_HEIGHT / 2), // top + glm::mat4 projection = glm::ortho(floor(offset.x - SCREEN_WIDTH2), // left + floor(offset.x + SCREEN_WIDTH2), // right + floor(offset.y - SCREEN_HEIGHT2), // bottom + floor(offset.y + SCREEN_HEIGHT2), // top static_cast(10.0), // near static_cast(-10.0)); // far - glm::mat4 view = glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), // pos - glm::vec3(0.0f, 0.0f, -10.0f), // looking at - glm::vec3(0.0f, 1.0f, 0.0f)); // up vector - glm::mat4 ortho = projection * view; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -316,30 +321,10 @@ void render() { // draw the debug overlay if desired if (ui::debug) { auto pos = game::engine.getSystem()->getPosition(); - ui::putText(offset.x - SCREEN_WIDTH / 2, (offset.y + SCREEN_HEIGHT / 2) - ui::fontSize, - "loc: (%+.2f, %+.2f)\noffset: (%+.2f, %+.2f)\nfps: %d\nticks: %d\nxml: %s", - pos.x, - pos.y, - offset.x, - offset.y, - fps, - game::time::getTickCount(), - game::engine.getSystem()->getXMLFile().c_str() - ); - /*ui::putText(offset.x-SCREEN_WIDTH/2, (offset.y+SCREEN_HEIGHT/2)-ui::fontSize, - "fps: %d\ngrounded:%d\nresolution: %ux%u\nentity cnt: %d\nloc: (%+.2f, %+.2f)\nticks: %u\nvolume: %f\nweather: %s\nxml: %s", - fps, - 0,//player->ground, - SCREEN_WIDTH, // Window dimensions - SCREEN_HEIGHT, // - 0,//currentWorld->entity.size(),// Size of entity array - 0,//player->loc.x, // The player's x coordinate - debugY, // The player's y coordinate - game::time::getTickCount(), - game::config::VOLUME_MASTER, - game::engine.getSystem()->getWeatherStr().c_str(), - ""//currentXML.c_str() - );*/ + ui::putText(offset.x - SCREEN_WIDTH2, (offset.y + SCREEN_HEIGHT2) - ui::fontSize, + "loc: %s\noffset: %s\nfps: %d\nticks: %d\nxml: %s", + pos.toString().c_str(), offset.toString().c_str(), fps, + game::time::getTickCount(), game::engine.getSystem()->getXMLFile().c_str()); } // draw the menu @@ -349,108 +334,8 @@ void render() { // draw the mouse Render::textShader.use(); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, mouseTex); + mouseTex.use(); Render::useShader(&Render::textShader); Render::drawRect(ui::mouse, ui::mouse + 15, -9.9); Render::textShader.unuse(); } - -void logic(){ -// static bool NPCSelected = false; -// static bool ObjectSelected = false; - - // exit the game if the player falls out of the world - /*if (player->loc.y < 0) - game::endGame();*/ - - /*if (player->inv->usingi) { - for (auto &e : currentWorld->entity) { - if (player->inv->usingi && !e->isHit() && - player->inv->detectCollision(vec2 { e->loc.x, e->loc.y }, vec2 { e->loc.x + e->width, e->loc.y + e->height})) { - e->takeHit(25, 10); - break; - } - } - player->inv->usingi = false; - }*/ - - /*for (auto &e : currentWorld->entity) { - if (e->isAlive() && ((e->type == NPCT) || (e->type == MERCHT) || (e->type == OBJECTT))) { - if (e->type == OBJECTT && ObjectSelected) { - e->near = false; - continue; - } else if (e->canMove) { - if (!currentWorld->goWorldLeft(dynamic_cast(e))) - currentWorld->goWorldRight(dynamic_cast(e)); - e->wander((rand() % 120 + 30)); - if (NPCSelected) { - e->near = false; - continue; - } - } - - if(e->isInside(ui::mouse) && player->isNear(e)) { - e->near = true; - if (e->type == OBJECTT) - ObjectSelected = true; - else - NPCSelected = true; - - if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)) && !ui::dialogBoxExists) { - if (ui::mouse.x < player->loc.x && player->right) - player->left = true, player->right = false; - else if(ui::mouse.x > player->loc.x && player->left) - player->right = true, player->left = false; - e->interact(); - } - } else { - e->near = false; - } - } else if (e->type == MOBT) { - e->near = player->isNear(e); - e->wander(); - } - }*/ - - // calculate the world shading value - worldShade = 50 * sin((game::time::getTickCount() + (DAY_CYCLE / 2)) / (DAY_CYCLE / PI)); - - // update fades - ui::fadeUpdate(); - - // create weather particles if necessary - /*auto weather = game::engine.getSystem()->getWeatherId(); - auto worldWidth = game::engine.getSystem()->getWidth(); - if (weather == WorldWeather::Rain) { - for (unsigned int r = (randGet() % 25) + 11; r--;) { - currentWorld->addParticle(randGet() % worldWidth - (worldWidth / 2), - offset.y + game::SCREEN_HEIGHT / 2, - HLINES(1.25), // width - HLINES(1.25), // height - randGet() % 7 * .01 * (randGet() % 2 == 0 ? -1 : 1), // vel.x - (4 + randGet() % 6) * .05, // vel.y - { 0, 0, 255 }, // RGB color - 2500, // duration (ms) - (1 << 0) | (1 << 1) // gravity and bounce - ); - } - } else if (weather == WorldWeather::Snowy) { - for (unsigned int r = (randGet() % 25) + 11; r--;) { - currentWorld->addParticle(randGet() % worldWidth - (worldWidth / 2), - offset.y + game::SCREEN_HEIGHT / 2, - HLINES(1.25), // width - HLINES(1.25), // height - .0001 + randGet() % 7 * .01 * (randGet() % 2 == 0 ? -1 : 1), // vel.x - (4 + randGet() % 6) * -.03, // vel.y - { 255, 255, 255 }, // RGB color - 5000, // duration (ms) - 0 // no gravity, no bounce - ); - } - }*/ - - // increment game ticker - game::time::tick(); - //NPCSelected = false; - //ObjectSelected = false; -} -- cgit v1.2.3 From 6dd6d03bb1af3c1c482a67355446998eccc3288c Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 22 Dec 2016 10:49:33 -0500 Subject: fade fix, other stuff too --- include/common.hpp | 17 ----------------- include/config.hpp | 2 +- include/shader_utils.hpp | 14 +++++++------- include/world.hpp | 7 ------- main.cpp | 1 + src/brice.cpp | 6 ++---- src/common.cpp | 39 +-------------------------------------- src/ui.cpp | 13 ++++--------- src/world.cpp | 16 ++++++---------- 9 files changed, 22 insertions(+), 93 deletions(-) (limited to 'main.cpp') diff --git a/include/common.hpp b/include/common.hpp index 7028296..56928b5 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -43,11 +43,8 @@ // game library includes #include - - // windows stuff #ifdef __WIN32__ -typedef unsigned int uint; #undef near #endif @@ -192,8 +189,6 @@ public: } }; -extern GLuint colorIndex; - /** * The amount of game ticks that should occur each second. */ @@ -259,17 +254,6 @@ extern vec2 offset; */ void DEBUG_prints(const char* file, int line, const char *s,...); -// TODO make sure we don't use these. Then burn them. -/** - * Sets color using glColor3ub(), but handles potential overflow. - */ -void safeSetColor(int r,int g,int b); - -/** - * Sets color using glColor4ub(), but handles potential overflow. - */ -void safeSetColorA(int r,int g,int b,int a); - unsigned int millis(void); // reads the names of files in a directory into the given string vector @@ -279,7 +263,6 @@ int getdir(std::string dir, std::vector &files); void strVectorSortAlpha(std::vector *v); // reads the given file into a buffer and returns a pointer to the buffer -const char *readFile(const char *path); std::string readFile(const std::string& path); std::vector readFileA(const std::string& path); diff --git a/include/config.hpp b/include/config.hpp index 908c376..e17df24 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -29,7 +29,7 @@ namespace game { /** * The window is fullscreen if this is true. */ - extern bool FULLSCREEN; + extern bool FULLSCREEN; namespace config { /** diff --git a/include/shader_utils.hpp b/include/shader_utils.hpp index 08ca7b3..06ac318 100644 --- a/include/shader_utils.hpp +++ b/include/shader_utils.hpp @@ -14,12 +14,12 @@ #include -extern char* file_read(const char* filename); -extern void print_log(GLuint object); -extern GLuint create_shader(const char* filename, GLenum type); -extern GLuint create_program(const char* vertexfile, const char *fragmentfile); -extern GLint get_attrib(GLuint program, const char *name); -extern GLint get_uniform(GLuint program, const char *name); -extern void print_opengl_info(); +char* file_read(const char* filename); +void print_log(GLuint object); +GLuint create_shader(const char* filename, GLenum type); +GLuint create_program(const char* vertexfile, const char *fragmentfile); +GLint get_attrib(GLuint program, const char *name); +GLint get_uniform(GLuint program, const char *name); +void print_opengl_info(); #endif diff --git a/include/world.hpp b/include/world.hpp index 8b24987..8864d30 100644 --- a/include/world.hpp +++ b/include/world.hpp @@ -59,13 +59,6 @@ typedef struct { unsigned char groundColor; /**< a value that affects the ground's color */ } WorldData; -/** - * Alters how bright world elements are drawn. - * This value is based off of the current time of day (tick count), set in - * main.cpp. - */ -extern int worldShade; - /** * Defines how many game ticks it takes to go from day to night or vice versa. * Technically a half day cycle... diff --git a/main.cpp b/main.cpp index 8579707..7fc1658 100644 --- a/main.cpp +++ b/main.cpp @@ -189,6 +189,7 @@ int main(int argc, char *argv[]) if (game::time::tickHasPassed()) { // calculate the world shading value + extern int worldShade; // TODO kill worldShade = 50 * sin((game::time::getTickCount() + (DAY_CYCLE / 2)) / (DAY_CYCLE / PI)); // update fades diff --git a/src/brice.cpp b/src/brice.cpp index 5e7237f..53b1431 100644 --- a/src/brice.cpp +++ b/src/brice.cpp @@ -58,9 +58,9 @@ namespace game { } void briceLoad(void) { - const char *data = readFile("brice.dat"); + auto data = readFile("brice.dat"); - if (data == nullptr) { + if (data.empty()) { briceClear(); data = readFile("brice.dat"); } @@ -74,8 +74,6 @@ namespace game { brice.emplace(std::make_pair(datas[i], datas[i + 1])); } } - - delete[] data; } void briceUpdate(void) { diff --git a/src/common.cpp b/src/common.cpp index 01a7db8..706bc3c 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -43,22 +43,6 @@ void DEBUG_prints(const char* file, int line, const char *s,...) va_end(args); } -void safeSetColor(int r, int g, int b) -{ - r = static_cast(fmax(fmin(r, 255), 0)); - g = static_cast(fmax(fmin(g, 255), 0)); - b = static_cast(fmax(fmin(b, 255), 0)); - glColor3ub(r, g, b); -} - -void safeSetColorA(int r,int g,int b,int a) { - r = static_cast(fmax(fmin(r, 255), 0)); - g = static_cast(fmax(fmin(g, 255), 0)); - b = static_cast(fmax(fmin(b, 255), 0)); - a = static_cast(fmax(fmin(a, 255), 0)); - glColor4ub(r, g, b, a); -} - int getdir(std::string dir, std::vector &files) { #ifndef __WIN32__ @@ -111,27 +95,6 @@ void strVectorSortAlpha(std::vector *v) } while (change); } -const char *readFile(const char *path) -{ - std::ifstream in (path,std::ios::in); - unsigned int size; - GLchar *buf; - - if (!in.is_open()) { -// UserError("Error reading file " + (std::string)path + "!"); - return nullptr; - } - - in.seekg(0,in.end); - buf = new GLchar[(size = in.tellg()) + 1]; - in.seekg(0,in.beg); - in.read(buf,size); - buf[size] = '\0'; - - in.close(); - return buf; -} - std::string readFile(const std::string& path) { std::ifstream in (path, std::ios::in); @@ -141,7 +104,7 @@ std::string readFile(const std::string& path) UserError("Error reading file " + path); in.seekg(0, in.end); - buffer.reserve(in.tellg()); + buffer.resize(in.tellg()); in.seekg(0, in.beg); in.read(&buffer[0], buffer.size()); diff --git a/src/ui.cpp b/src/ui.cpp index a154d7e..9f0e014 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -1014,8 +1014,8 @@ namespace ui { } void drawFade(void) { - auto SCREEN_WIDTH2 = game::SCREEN_WIDTH / 2; - auto SCREEN_HEIGHT2 = game::SCREEN_HEIGHT / 2; + static const auto SCREEN_WIDTH2 = game::SCREEN_WIDTH / 2; + static const auto SCREEN_HEIGHT2 = game::SCREEN_HEIGHT / 2; if (!fadeIntensity) { if (fontSize != 16) @@ -1023,9 +1023,6 @@ namespace ui { return; } - ColorTex fadeTex (fadeWhite ? Color(255, 255, 255, fadeIntensity) : - Color(0, 0, 0, fadeIntensity)); - static const GLfloat tex[] = { 0.0, 0.0, 1.0, 0.0, @@ -1045,8 +1042,8 @@ namespace ui { Render::textShader.use(); Render::textShader.enable(); - - fadeTex.use(); + Colors::black.use(); + glUniform4f(Render::textShader.uniform[WU_tex_color], 1.0f, 1.0f, 1.0f, fadeIntensity / 255.0f); glVertexAttribPointer(Render::textShader.coord, 3, GL_FLOAT, GL_FALSE, 0, backdrop); glVertexAttribPointer(Render::textShader.tex, 2, GL_FLOAT, GL_FALSE, 0, tex); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -1055,8 +1052,6 @@ namespace ui { Render::textShader.unuse(); setFontZ(-8.0); - - fadeTex.destroy(); } void fadeUpdate(void) { diff --git a/src/world.cpp b/src/world.cpp index c458ab0..d0727e2 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -196,9 +196,7 @@ void WorldSystem::load(const std::string& file) // load file data to string auto xmlPath = xmlFolder + file; - auto xmlRawData = readFile(xmlPath.c_str()); - std::string xmlRaw = xmlRawData; - delete[] xmlRawData; + auto xmlRaw = readFile(xmlPath); // let tinyxml parse the file if (xmlDoc.Parse(xmlRaw.data()) != XML_NO_ERROR) @@ -211,9 +209,7 @@ void WorldSystem::load(const std::string& file) if (file != nullptr) { DEBUG_printf("Including file: %s\n", file); - auto include = readFile((xmlFolder + file).c_str()); - xmlRaw.append(include); - delete[] include; + xmlRaw.append(readFile(xmlFolder + file)); } else { UserError("XML Error: tag file not given"); } @@ -936,11 +932,11 @@ void WorldSystem::render(void) GLfloat *dirtp = &dirt[0]; for (int i = iStart; i < iEnd; i++) { - if (world.data[i].groundHeight <= 0) { // TODO holes (andy) + if (world.data[i].groundHeight <= 0) { // TODO holes (andy) TODO TODO TODO world.data[i].groundHeight = GROUND_HEIGHT_MINIMUM - 1; - glColor4ub(0, 0, 0, 255); + //glColor4ub(0, 0, 0, 255); } else { - safeSetColorA(150, 150, 150, 255); + //safeSetColorA(150, 150, 150, 255); } int ty = world.data[i].groundHeight / 64 + world.data[i].groundColor; @@ -978,7 +974,7 @@ void WorldSystem::render(void) if (!world.indoor) { bgTex++; - safeSetColorA(255, 255, 255, 255); + //safeSetColorA(255, 255, 255, 255); TODO TODO TODO static std::vector grass; if (grass.size() != world.data.size() * 60) { -- cgit v1.2.3