diff --git a/src/framework/configs.cpp b/src/framework/configs.cpp index 6e679ce4..3aa7c085 100644 --- a/src/framework/configs.cpp +++ b/src/framework/configs.cpp @@ -67,7 +67,7 @@ void Configs::save() if(!m_fileName.empty()) { YAML::Emitter out; out << m_confsMap; - g_resources.saveFile(m_fileName, (const unsigned char*)out.c_str(), out.size()); + g_resources.saveFile(m_fileName, (const uchar*)out.c_str(), out.size()); } } diff --git a/src/framework/engine.cpp b/src/framework/engine.cpp index f562f8d3..93839b43 100644 --- a/src/framework/engine.cpp +++ b/src/framework/engine.cpp @@ -54,8 +54,8 @@ void Engine::terminate() void Engine::run() { - unsigned long ticks; - static unsigned long lastFrameTicks; + ulong ticks; + static ulong lastFrameTicks; m_running = true; diff --git a/src/framework/framebuffer.h b/src/framework/framebuffer.h index 061218f8..65f3064f 100644 --- a/src/framework/framebuffer.h +++ b/src/framework/framebuffer.h @@ -43,8 +43,8 @@ public: void draw(int x, int y, int width, int height); private: - unsigned int m_fboTexture; - unsigned int m_fbo; + uint m_fboTexture; + uint m_fbo; bool m_fallbackOldImp; int m_width; int m_height; diff --git a/src/framework/input.h b/src/framework/input.h index a6083273..0090852d 100644 --- a/src/framework/input.h +++ b/src/framework/input.h @@ -190,7 +190,7 @@ enum EEvent { struct KeyEvent { char keychar; - unsigned char keycode; + uchar keycode; bool ctrl; bool shift; bool alt; diff --git a/src/framework/platform.h b/src/framework/platform.h index 809b3dd5..2e2f1d5e 100644 --- a/src/framework/platform.h +++ b/src/framework/platform.h @@ -38,7 +38,7 @@ namespace Platform /// Get current time in milliseconds since init int getTicks(); /// Sleep in current thread - void sleep(unsigned long miliseconds); + void sleep(ulong miliseconds); bool createWindow(int x, int y, int width, int height, int minWidth, int minHeight, bool maximized); void destroyWindow(); diff --git a/src/framework/resources.cpp b/src/framework/resources.cpp index 4e8589ac..558e1305 100644 --- a/src/framework/resources.cpp +++ b/src/framework/resources.cpp @@ -61,7 +61,7 @@ bool Resources::fileExists(const std::string& filePath) return PHYSFS_exists(filePath.c_str()); } -unsigned char *Resources::loadFile(const std::string& fileName, unsigned int *fileSize) +uchar *Resources::loadFile(const std::string& fileName, uint *fileSize) { PHYSFS_file *file = PHYSFS_openRead(fileName.c_str()); if(!file) { @@ -71,7 +71,7 @@ unsigned char *Resources::loadFile(const std::string& fileName, unsigned int *fi } *fileSize = PHYSFS_fileLength(file); - unsigned char *buffer = new unsigned char[*fileSize + 1]; + uchar *buffer = new uchar[*fileSize + 1]; PHYSFS_read(file, (void*)buffer, 1, *fileSize); buffer[*fileSize] = 0; PHYSFS_close(file); @@ -81,7 +81,7 @@ unsigned char *Resources::loadFile(const std::string& fileName, unsigned int *fi std::string Resources::loadTextFile(const std::string& fileName) { std::string text; - unsigned int fileSize; + uint fileSize; char *buffer = (char *)loadFile(fileName, &fileSize); if(buffer) { text.assign(buffer); @@ -90,7 +90,7 @@ std::string Resources::loadTextFile(const std::string& fileName) return text; } -bool Resources::saveFile(const std::string &fileName, const unsigned char *data, unsigned int size) +bool Resources::saveFile(const std::string &fileName, const uchar *data, uint size) { PHYSFS_file *file = PHYSFS_openWrite(fileName.c_str()); if(!file) { @@ -105,7 +105,7 @@ bool Resources::saveFile(const std::string &fileName, const unsigned char *data, bool Resources::saveTextFile(const std::string &fileName, std::string text) { - return saveFile(fileName, (const unsigned char*)text.c_str(), text.size()); + return saveFile(fileName, (const uchar*)text.c_str(), text.size()); } std::list Resources::getDirectoryFiles(const std::string& directory) diff --git a/src/framework/resources.h b/src/framework/resources.h index 061c4440..011c8cb2 100644 --- a/src/framework/resources.h +++ b/src/framework/resources.h @@ -52,13 +52,13 @@ public: /** Load a file by allocating a buffer and filling it with the file contents * where fileSize will be set to the file size. * The returned buffer must be freed with delete[]. */ - unsigned char *loadFile(const std::string &fileName, unsigned int *fileSize); + uchar *loadFile(const std::string &fileName, uint *fileSize); /// Loads a text file into a std::string std::string loadTextFile(const std::string &fileName); /// Save a file into write directory - bool saveFile(const std::string &fileName, const unsigned char *data, unsigned int size); + bool saveFile(const std::string &fileName, const uchar *data, uint size); /// Save a text file into write directory bool saveTextFile(const std::string &fileName, std::string text); diff --git a/src/framework/texture.cpp b/src/framework/texture.cpp index 64d85c95..3da954a3 100644 --- a/src/framework/texture.cpp +++ b/src/framework/texture.cpp @@ -27,7 +27,7 @@ #include #include -Texture::Texture(int width, int height, int components, unsigned char *pixels) +Texture::Texture(int width, int height, int components, uchar *pixels) { m_size.setWidth(width); m_size.setHeight(height); diff --git a/src/framework/texture.h b/src/framework/texture.h index c88cf2cb..495baedb 100644 --- a/src/framework/texture.h +++ b/src/framework/texture.h @@ -34,17 +34,17 @@ class Texture { public: /// Create a texture, width and height must be a multiple of 2 - Texture(int width, int height, int components, unsigned char *pixels = NULL); + Texture(int width, int height, int components, uchar *pixels = NULL); virtual ~Texture(); /// Enable texture bilinear filter (smooth scaled textures) void enableBilinearFilter(); const Size& getSize() const { return m_size; } - unsigned int getTextureId() const { return m_textureId; } + uint getTextureId() const { return m_textureId; } private: - unsigned int m_textureId; + uint m_textureId; Size m_size; }; diff --git a/src/framework/textureloader.cpp b/src/framework/textureloader.cpp index 0e1163cf..367afcee 100644 --- a/src/framework/textureloader.cpp +++ b/src/framework/textureloader.cpp @@ -33,8 +33,8 @@ struct File offset = 0; } - unsigned char *data; - unsigned int offset; + uchar *data; + uint offset; }; void png_read_from_mem(png_structp png_ptr, png_bytep data, png_size_t size) @@ -48,7 +48,7 @@ void png_read_from_mem(png_structp png_ptr, png_bytep data, png_size_t size) file->offset += size; } -Texture *TextureLoader::loadPNG(unsigned char *fileData) +Texture *TextureLoader::loadPNG(uchar *fileData) { File file; file.data = fileData; @@ -119,10 +119,10 @@ Texture *TextureLoader::loadPNG(unsigned char *fileData) return NULL; }; - unsigned char *pixels = new unsigned char[width * height * components]; + uchar *pixels = new uchar[width * height * components]; png_bytep *row_pointers = new png_bytep[height]; - for(unsigned int i = 0; i < height; ++i) + for(uint i = 0; i < height; ++i) row_pointers[i] = (png_bytep)(pixels + (i * width * components)); png_read_image(png_ptr, row_pointers); diff --git a/src/framework/textureloader.h b/src/framework/textureloader.h index a4c72414..082ebf6e 100644 --- a/src/framework/textureloader.h +++ b/src/framework/textureloader.h @@ -32,7 +32,7 @@ class Texture; namespace TextureLoader { /// Load a png textures using libpng - Texture *loadPNG(unsigned char *fileData); + Texture *loadPNG(uchar *fileData); } #endif // TEXTURELOADER_H diff --git a/src/framework/texturemanager.h b/src/framework/texturemanager.h deleted file mode 100644 index 8b64f362..00000000 --- a/src/framework/texturemanager.h +++ /dev/null @@ -1,49 +0,0 @@ -/* The MIT License - * - * Copyright (c) 2010 OTClient, https://github.com/edubart/otclient - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#ifndef TEXTUREMANAGER_H -#define TEXTUREMANAGER_H - -#include "prerequisites.h" -#include "texture.h" - -typedef std::weak_ptr TextureWeakPtr; - -class TextureManager -{ -public: - TextureManager(); - ~TextureManager(); - - /// Load a texture from file, if it was already loaded it will be retrieved from cache - TexturePtr get(const std::string& textureFile); - -private: - typedef std::map TexturesMap; - TexturesMap m_texturesMap; -}; - -extern TextureManager g_textures; - -#endif // TEXTUREMANAGER_H diff --git a/src/framework/textures.cpp b/src/framework/textures.cpp index cb911706..ae612b61 100644 --- a/src/framework/textures.cpp +++ b/src/framework/textures.cpp @@ -48,8 +48,8 @@ TexturePtr Textures::get(const std::string& textureFile) return texture; } - unsigned int fileSize; - unsigned char *textureFileData = g_resources.loadFile(textureFile, &fileSize); + uint fileSize; + uchar *textureFileData = g_resources.loadFile(textureFile, &fileSize); if(!textureFileData) return texture; diff --git a/src/framework/win32platform.cpp b/src/framework/win32platform.cpp index 79ae6808..0c328009 100644 --- a/src/framework/win32platform.cpp +++ b/src/framework/win32platform.cpp @@ -96,14 +96,14 @@ void Platform::poll() int Platform::getTicks() { - static unsigned long firstTick = 0; + static ulong firstTick = 0; if(!firstTick) firstTick = GetTickCount(); return (uint32_t)(GetTickCount() - firstTick); } -void Platform::sleep(unsigned long miliseconds) +void Platform::sleep(ulong miliseconds) { Sleep(miliseconds); } diff --git a/src/framework/x11platform.cpp b/src/framework/x11platform.cpp index f0ad5dde..cfbc79f8 100644 --- a/src/framework/x11platform.cpp +++ b/src/framework/x11platform.cpp @@ -63,7 +63,7 @@ struct X11PlatformPrivate { int x; int y; std::string clipboardText; - std::map keyMap; + std::map keyMap; } x11; void Platform::init(const char *appName) @@ -346,7 +346,7 @@ void Platform::poll() keysym != XK_Delete && keysym != XK_Escape ) { - //debug("char: %c code: %d", buf[0], (unsigned char)buf[0]); + //debug("char: %c code: %d", buf[0], (uchar)buf[0]); inputEvent.type = EV_TEXT_ENTER; inputEvent.key.keychar = buf[0]; inputEvent.key.keycode = KC_UNKNOWN; @@ -424,7 +424,7 @@ void Platform::poll() XChangeProperty(x11.display, req->requestor, req->property, req->target, 8, PropModeReplace, - (unsigned char *) &typeList, + (uchar *) &typeList, sizeof(typeList)); respond.xselection.property = req->property; } else { @@ -433,7 +433,7 @@ void Platform::poll() req->property, req->target, 8, PropModeReplace, - (unsigned char*) x11.clipboardText.c_str(), + (uchar*) x11.clipboardText.c_str(), x11.clipboardText.size()); respond.xselection.property = req->property; } @@ -462,7 +462,7 @@ void Platform::poll() int Platform::getTicks() { static timeval tv; - static unsigned long firstTick = 0; + static ulong firstTick = 0; gettimeofday(&tv, 0); if(!firstTick) @@ -471,7 +471,7 @@ int Platform::getTicks() return ((tv.tv_sec - firstTick) * 1000) + (tv.tv_usec / 1000); } -void Platform::sleep(unsigned long miliseconds) +void Platform::sleep(ulong miliseconds) { timespec tv; tv.tv_sec = miliseconds / 1000; @@ -671,8 +671,8 @@ const char *Platform::getClipboardText() // check for data Atom type; int format; - unsigned long numItems, bytesLeft, dummy; - unsigned char *data; + ulong numItems, bytesLeft, dummy; + uchar *data; XGetWindowProperty(x11.display, ownerWindow, XA_STRING, 0, 0, 0, @@ -797,8 +797,8 @@ bool Platform::isWindowMaximized() bool ret = false; Atom actualType; int actualFormat; - unsigned long i, numItems, bytesAfter; - unsigned char *propertyValue = NULL; + ulong i, numItems, bytesAfter; + uchar *propertyValue = NULL; long maxLength = 1024; if(XGetWindowProperty(x11.display, x11.window, x11.atomWindowState,