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()) {
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());
}
}

View File

@ -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;

View File

@ -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;

View File

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

View File

@ -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();

View File

@ -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<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
* 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);

View File

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

View File

@ -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;
};

View File

@ -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);

View File

@ -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

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;
}
unsigned int fileSize;
unsigned char *textureFileData = g_resources.loadFile(textureFile, &fileSize);
uint fileSize;
uchar *textureFileData = g_resources.loadFile(textureFile, &fileSize);
if(!textureFileData)
return texture;

View File

@ -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);
}

View File

@ -63,7 +63,7 @@ struct X11PlatformPrivate {
int x;
int y;
std::string clipboardText;
std::map<int, unsigned char> keyMap;
std::map<int, uchar> 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,