From 5f4fe5e624c68d26b7c4c97023bca38156478237 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Fri, 14 Sep 2018 22:27:04 +0500 Subject: [PATCH] Other parts work just fine --- game_objects.cpp | 5 +++-- gl_camera.cpp | 2 -- gl_screen.cpp | 2 +- gl_texturecache.cpp | 8 ++++++-- util/image_loader.cpp | 18 ------------------ util/key_handler.cpp | 2 -- viewer.cpp | 42 +++++++++++++++++++++++++++--------------- 7 files changed, 37 insertions(+), 42 deletions(-) mode change 100644 => 100755 gl_texturecache.cpp diff --git a/game_objects.cpp b/game_objects.cpp index e94290c..130a384 100755 --- a/game_objects.cpp +++ b/game_objects.cpp @@ -30,6 +30,8 @@ #include "ai.h" #include "localplayer.h" +#include "log.h" + #define INT2FLOAT_WRLD(c) (float(c >> 6) + float(c % 64) / 64.0f) #define INT2F_DIV64(v) (float(v) / 64.0f) @@ -515,8 +517,7 @@ activeWeapon = chooseWeapon; void CarSprite::setSirenAnim(bool on) { if (!(assertDeltaById(15) && assertDeltaById(16))) { - //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com - //ERROR << "Trying to set siren anim on car-sprite that has no such delta!" << std::endl; + WARN << "Trying to set siren anim on car-sprite that has no such delta!" << std::endl; return; } animState.set_item(10, on); diff --git a/gl_camera.cpp b/gl_camera.cpp index 1af95e4..15fed4b 100755 --- a/gl_camera.cpp +++ b/gl_camera.cpp @@ -234,8 +234,6 @@ namespace OpenGL { int mx, my; SDL_GetMouseState(&mx, &my); - //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com - //SDL_WarpMouse(w, h); SDL_WarpMouseInWindow(screen.surface, w, h); if ((mx == w) && (my == h)) diff --git a/gl_screen.cpp b/gl_screen.cpp index 0036a2d..1de37ed 100755 --- a/gl_screen.cpp +++ b/gl_screen.cpp @@ -284,7 +284,7 @@ namespace OpenGL { h = 1; surface = SDL_CreateWindow( - "SDL2/OpenGL Demo", 0, 0, w, h, + "OpenGTA", 0, 0, w, h, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); // Create an OpenGL context associated with the window. diff --git a/gl_texturecache.cpp b/gl_texturecache.cpp old mode 100644 new mode 100755 index 32a61eb..6a38144 --- a/gl_texturecache.cpp +++ b/gl_texturecache.cpp @@ -110,10 +110,14 @@ namespace OpenGL { GLuint tid = (i->second->texId); glDeleteTextures(1, &tid); delete i->second; - cached.erase(i); + cached.erase(i++); numCleared++; } - i++; + else + { + ++i; + } + } INFO << m_name << " " << numCleared << " textures recycled" << std::endl; } diff --git a/util/image_loader.cpp b/util/image_loader.cpp index d0d4528..583b11d 100755 --- a/util/image_loader.cpp +++ b/util/image_loader.cpp @@ -30,8 +30,6 @@ #include "opengta.h" #include "physfsrwops.h" -//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com -//#include "SDL_image.h" #include "m_exceptions.h" namespace ImageUtil { @@ -172,28 +170,12 @@ using OpenGL::PagedTexture; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com - if (rgba) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); } else { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); } - /* - if (rgba) { - if (mipmapTextures) - gluBuild2DMipmaps(GL_TEXTURE_2D, 4, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - } - else { - if (mipmapTextures) - gluBuild2DMipmaps(GL_TEXTURE_2D, 3, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels); - else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); - }*/ - if (supportedMaxAnisoDegree > 1.0f) diff --git a/util/key_handler.cpp b/util/key_handler.cpp index 2c7e12f..4e8aeb1 100755 --- a/util/key_handler.cpp +++ b/util/key_handler.cpp @@ -21,8 +21,6 @@ * distribution. * ************************************************************************/ -//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com -//#include #include "key_handler.h" #include "log.h" diff --git a/viewer.cpp b/viewer.cpp index cf5ebac..ad7a64a 100755 --- a/viewer.cpp +++ b/viewer.cpp @@ -52,6 +52,9 @@ #include "font_cache.h" #include "ai.h" + +#include + #define getPedById getPed #define removePedById removePed #define addPed add @@ -456,9 +459,6 @@ void run_init(const char* prg_name) { screen.activate(arg_screen_w, arg_screen_h); - //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com - //SDL_EnableKeyRepeat( 0, 0 ); - // more setup; that requires an active screen #ifdef WITH_LUA OpenGTA::Script::LuaVM & vm = OpenGTA::Script::LuaVMHolder::Instance(); @@ -535,8 +535,8 @@ void print_position() { } -/* -void handleKeyUp( SDL_keysym *keysym) { + +void handleKeyUp(SDL_Keysym* keysym) { switch ( keysym->sym ) { case 'j': OpenGTA::LocalPlayer::Instance().getCtrl().releaseTurnLeft(); @@ -564,7 +564,7 @@ void handleKeyUp( SDL_keysym *keysym) { default: break; } -}*/ +} void draw_mapmode(); @@ -742,11 +742,12 @@ void car_toggle() { } -/* -void handleKeyPress( SDL_keysym *keysym ) { + +void handleKeyPress( SDL_Keysym *keysym ) { GLfloat* cp = city->getCamPos(); mapPos[0] = cp[0]; mapPos[1] = cp[1]; mapPos[2] = cp[2]; OpenGL::Camera & cam = OpenGL::CameraHolder::Instance(); + switch ( keysym->sym ) { case SDLK_ESCAPE: global_Done = 1; @@ -792,6 +793,10 @@ void handleKeyPress( SDL_keysym *keysym ) { texsprite_toggle = (texsprite_toggle ? 0 : 1); OpenGTA::SpriteManagerHolder::Instance().setDrawTexBorder(texsprite_toggle); break; + + + //Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com + /* case SDLK_F4: follow_toggle = (follow_toggle ? 0 : 1); if (follow_toggle) { @@ -813,7 +818,7 @@ void handleKeyPress( SDL_keysym *keysym ) { OpenGTA::SpriteManagerHolder::Instance().removeDeadStuff(); GUI::remove_ingame_gui(); } - break; + break;*/ case SDLK_RETURN: car_toggle(); break; @@ -954,7 +959,7 @@ void handleKeyPress( SDL_keysym *keysym ) { city->setVisibleRange(city->getVisibleRange()+1); INFO << " new visible range " << city->getVisibleRange() << std::endl; break; - case SDLK_PRINT: + case SDLK_PRINTSCREEN: OpenGL::ScreenHolder::Instance().makeScreenshot("screenshot.bmp"); break; default: @@ -962,7 +967,7 @@ void handleKeyPress( SDL_keysym *keysym ) { } city->setPosition(mapPos[0], mapPos[1], mapPos[2]); -}*/ +} void drawScene(Uint32 ticks) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -1172,14 +1177,21 @@ void run_main() { paused = 1; else paused = 0; - break; + break;*/ case SDL_KEYDOWN: - handleKeyPress(&event.key.keysym); + if (event.key.repeat == 0) + { + handleKeyPress(&event.key.keysym); + } + break; case SDL_KEYUP: - handleKeyUp(&event.key.keysym); + if (event.key.repeat == 0) + { + handleKeyUp(&event.key.keysym); + } break; - case SDL_VIDEORESIZE: + /* case SDL_VIDEORESIZE: OpenGL::ScreenHolder::Instance().resize(event.resize.w, event.resize.h); break;*/ case SDL_QUIT: