rename int types

This commit is contained in:
Eduardo Bart 2011-04-06 17:18:00 -03:00
parent 12cdefff38
commit 5ab943ce13
15 changed files with 38 additions and 87 deletions

View File

@ -67,7 +67,7 @@ void Configs::save()
if(!m_fileName.empty()) { if(!m_fileName.empty()) {
YAML::Emitter out; YAML::Emitter out;
out << m_confsMap; 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());
} }
} }

View File

@ -54,8 +54,8 @@ void Engine::terminate()
void Engine::run() void Engine::run()
{ {
unsigned long ticks; ulong ticks;
static unsigned long lastFrameTicks; static ulong lastFrameTicks;
m_running = true; m_running = true;

View File

@ -43,8 +43,8 @@ public:
void draw(int x, int y, int width, int height); void draw(int x, int y, int width, int height);
private: private:
unsigned int m_fboTexture; uint m_fboTexture;
unsigned int m_fbo; uint m_fbo;
bool m_fallbackOldImp; bool m_fallbackOldImp;
int m_width; int m_width;
int m_height; int m_height;

View File

@ -190,7 +190,7 @@ enum EEvent {
struct KeyEvent { struct KeyEvent {
char keychar; char keychar;
unsigned char keycode; uchar keycode;
bool ctrl; bool ctrl;
bool shift; bool shift;
bool alt; bool alt;

View File

@ -38,7 +38,7 @@ namespace Platform
/// Get current time in milliseconds since init /// Get current time in milliseconds since init
int getTicks(); int getTicks();
/// Sleep in current thread /// 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); bool createWindow(int x, int y, int width, int height, int minWidth, int minHeight, bool maximized);
void destroyWindow(); void destroyWindow();

View File

@ -61,7 +61,7 @@ bool Resources::fileExists(const std::string& filePath)
return PHYSFS_exists(filePath.c_str()); 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()); PHYSFS_file *file = PHYSFS_openRead(fileName.c_str());
if(!file) { if(!file) {
@ -71,7 +71,7 @@ unsigned char *Resources::loadFile(const std::string& fileName, unsigned int *fi
} }
*fileSize = PHYSFS_fileLength(file); *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); PHYSFS_read(file, (void*)buffer, 1, *fileSize);
buffer[*fileSize] = 0; buffer[*fileSize] = 0;
PHYSFS_close(file); 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 Resources::loadTextFile(const std::string& fileName)
{ {
std::string text; std::string text;
unsigned int fileSize; uint fileSize;
char *buffer = (char *)loadFile(fileName, &fileSize); char *buffer = (char *)loadFile(fileName, &fileSize);
if(buffer) { if(buffer) {
text.assign(buffer); text.assign(buffer);
@ -90,7 +90,7 @@ std::string Resources::loadTextFile(const std::string& fileName)
return text; 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()); PHYSFS_file *file = PHYSFS_openWrite(fileName.c_str());
if(!file) { 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) 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<std::string> Resources::getDirectoryFiles(const std::string& directory) std::list<std::string> Resources::getDirectoryFiles(const std::string& directory)

View File

@ -52,13 +52,13 @@ public:
/** Load a file by allocating a buffer and filling it with the file contents /** Load a file by allocating a buffer and filling it with the file contents
* where fileSize will be set to the file size. * where fileSize will be set to the file size.
* The returned buffer must be freed with delete[]. */ * 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 /// Loads a text file into a std::string
std::string loadTextFile(const std::string &fileName); std::string loadTextFile(const std::string &fileName);
/// Save a file into write directory /// 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 /// Save a text file into write directory
bool saveTextFile(const std::string &fileName, std::string text); bool saveTextFile(const std::string &fileName, std::string text);

View File

@ -27,7 +27,7 @@
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glext.h> #include <GL/glext.h>
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.setWidth(width);
m_size.setHeight(height); m_size.setHeight(height);

View File

@ -34,17 +34,17 @@ class Texture
{ {
public: public:
/// Create a texture, width and height must be a multiple of 2 /// 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(); virtual ~Texture();
/// Enable texture bilinear filter (smooth scaled textures) /// Enable texture bilinear filter (smooth scaled textures)
void enableBilinearFilter(); void enableBilinearFilter();
const Size& getSize() const { return m_size; } const Size& getSize() const { return m_size; }
unsigned int getTextureId() const { return m_textureId; } uint getTextureId() const { return m_textureId; }
private: private:
unsigned int m_textureId; uint m_textureId;
Size m_size; Size m_size;
}; };

View File

@ -33,8 +33,8 @@ struct File
offset = 0; offset = 0;
} }
unsigned char *data; uchar *data;
unsigned int offset; uint offset;
}; };
void png_read_from_mem(png_structp png_ptr, png_bytep data, png_size_t size) 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; file->offset += size;
} }
Texture *TextureLoader::loadPNG(unsigned char *fileData) Texture *TextureLoader::loadPNG(uchar *fileData)
{ {
File file; File file;
file.data = fileData; file.data = fileData;
@ -119,10 +119,10 @@ Texture *TextureLoader::loadPNG(unsigned char *fileData)
return NULL; 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]; 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)); row_pointers[i] = (png_bytep)(pixels + (i * width * components));
png_read_image(png_ptr, row_pointers); png_read_image(png_ptr, row_pointers);

View File

@ -32,7 +32,7 @@ class Texture;
namespace TextureLoader namespace TextureLoader
{ {
/// Load a png textures using libpng /// Load a png textures using libpng
Texture *loadPNG(unsigned char *fileData); Texture *loadPNG(uchar *fileData);
} }
#endif // TEXTURELOADER_H #endif // TEXTURELOADER_H

View File

@ -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<Texture> 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<std::string, TextureWeakPtr > TexturesMap;
TexturesMap m_texturesMap;
};
extern TextureManager g_textures;
#endif // TEXTUREMANAGER_H

View File

@ -48,8 +48,8 @@ TexturePtr Textures::get(const std::string& textureFile)
return texture; return texture;
} }
unsigned int fileSize; uint fileSize;
unsigned char *textureFileData = g_resources.loadFile(textureFile, &fileSize); uchar *textureFileData = g_resources.loadFile(textureFile, &fileSize);
if(!textureFileData) if(!textureFileData)
return texture; return texture;

View File

@ -96,14 +96,14 @@ void Platform::poll()
int Platform::getTicks() int Platform::getTicks()
{ {
static unsigned long firstTick = 0; static ulong firstTick = 0;
if(!firstTick) if(!firstTick)
firstTick = GetTickCount(); firstTick = GetTickCount();
return (uint32_t)(GetTickCount() - firstTick); return (uint32_t)(GetTickCount() - firstTick);
} }
void Platform::sleep(unsigned long miliseconds) void Platform::sleep(ulong miliseconds)
{ {
Sleep(miliseconds); Sleep(miliseconds);
} }

View File

@ -63,7 +63,7 @@ struct X11PlatformPrivate {
int x; int x;
int y; int y;
std::string clipboardText; std::string clipboardText;
std::map<int, unsigned char> keyMap; std::map<int, uchar> keyMap;
} x11; } x11;
void Platform::init(const char *appName) void Platform::init(const char *appName)
@ -346,7 +346,7 @@ void Platform::poll()
keysym != XK_Delete && keysym != XK_Delete &&
keysym != XK_Escape 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.type = EV_TEXT_ENTER;
inputEvent.key.keychar = buf[0]; inputEvent.key.keychar = buf[0];
inputEvent.key.keycode = KC_UNKNOWN; inputEvent.key.keycode = KC_UNKNOWN;
@ -424,7 +424,7 @@ void Platform::poll()
XChangeProperty(x11.display, req->requestor, XChangeProperty(x11.display, req->requestor,
req->property, req->target, req->property, req->target,
8, PropModeReplace, 8, PropModeReplace,
(unsigned char *) &typeList, (uchar *) &typeList,
sizeof(typeList)); sizeof(typeList));
respond.xselection.property = req->property; respond.xselection.property = req->property;
} else { } else {
@ -433,7 +433,7 @@ void Platform::poll()
req->property, req->target, req->property, req->target,
8, 8,
PropModeReplace, PropModeReplace,
(unsigned char*) x11.clipboardText.c_str(), (uchar*) x11.clipboardText.c_str(),
x11.clipboardText.size()); x11.clipboardText.size());
respond.xselection.property = req->property; respond.xselection.property = req->property;
} }
@ -462,7 +462,7 @@ void Platform::poll()
int Platform::getTicks() int Platform::getTicks()
{ {
static timeval tv; static timeval tv;
static unsigned long firstTick = 0; static ulong firstTick = 0;
gettimeofday(&tv, 0); gettimeofday(&tv, 0);
if(!firstTick) if(!firstTick)
@ -471,7 +471,7 @@ int Platform::getTicks()
return ((tv.tv_sec - firstTick) * 1000) + (tv.tv_usec / 1000); return ((tv.tv_sec - firstTick) * 1000) + (tv.tv_usec / 1000);
} }
void Platform::sleep(unsigned long miliseconds) void Platform::sleep(ulong miliseconds)
{ {
timespec tv; timespec tv;
tv.tv_sec = miliseconds / 1000; tv.tv_sec = miliseconds / 1000;
@ -671,8 +671,8 @@ const char *Platform::getClipboardText()
// check for data // check for data
Atom type; Atom type;
int format; int format;
unsigned long numItems, bytesLeft, dummy; ulong numItems, bytesLeft, dummy;
unsigned char *data; uchar *data;
XGetWindowProperty(x11.display, ownerWindow, XGetWindowProperty(x11.display, ownerWindow,
XA_STRING, XA_STRING,
0, 0, 0, 0, 0, 0,
@ -797,8 +797,8 @@ bool Platform::isWindowMaximized()
bool ret = false; bool ret = false;
Atom actualType; Atom actualType;
int actualFormat; int actualFormat;
unsigned long i, numItems, bytesAfter; ulong i, numItems, bytesAfter;
unsigned char *propertyValue = NULL; uchar *propertyValue = NULL;
long maxLength = 1024; long maxLength = 1024;
if(XGetWindowProperty(x11.display, x11.window, x11.atomWindowState, if(XGetWindowProperty(x11.display, x11.window, x11.atomWindowState,