Skip to content

Commit

Permalink
Replace Qt types in tex.cpp (and related)
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed May 12, 2018
1 parent 3251b53 commit 9928744
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
13 changes: 6 additions & 7 deletions lib/ivis_opengl/tex.cpp
Expand Up @@ -26,7 +26,6 @@
#include "lib/ivis_opengl/piepalette.h"
#include "lib/ivis_opengl/png_util.h"

#include <QtCore/QList>
#include "screen.h"

//*************************************************************************
Expand Down Expand Up @@ -224,27 +223,27 @@ int iV_GetTexture(const char *filename, bool compression)
return pie_AddTexPage(&sSprite, path, compression);
}

bool replaceTexture(const QString &oldfile, const QString &newfile)
bool replaceTexture(const WzString &oldfile, const WzString &newfile)
{
char tmpname[iV_TEXNAME_MAX];

// Load new one to replace it
iV_Image image;
if (!iV_loadImage_PNG(QString("texpages/" + newfile).toUtf8().constData(), &image))
if (!iV_loadImage_PNG(WzString("texpages/" + newfile).toUtf8().c_str(), &image))
{
debug(LOG_ERROR, "Failed to load image: %s", newfile.toUtf8().constData());
debug(LOG_ERROR, "Failed to load image: %s", newfile.toUtf8().c_str());
return false;
}
sstrcpy(tmpname, oldfile.toUtf8().constData());
sstrcpy(tmpname, oldfile.toUtf8().c_str());
pie_MakeTexPageName(tmpname);
// Have we already loaded this one?
for (int i = 0; i < _TEX_PAGE.size(); i++)
{
if (strcmp(tmpname, _TEX_PAGE[i].name) == 0)
{
GL_DEBUG("Replacing texture");
debug(LOG_TEXTURE, "Replacing texture %s with %s from index %d (tex id %u)", _TEX_PAGE[i].name, newfile.toUtf8().constData(), i, _TEX_PAGE[i].id->id());
sstrcpy(tmpname, newfile.toUtf8().constData());
debug(LOG_TEXTURE, "Replacing texture %s with %s from index %d (tex id %u)", _TEX_PAGE[i].name, newfile.toUtf8().c_str(), i, _TEX_PAGE[i].id->id());
sstrcpy(tmpname, newfile.toUtf8().c_str());
pie_MakeTexPageName(tmpname);
pie_AddTexPage(&image, tmpname, true, i);
iV_unloadImage(&image);
Expand Down
3 changes: 2 additions & 1 deletion lib/ivis_opengl/tex.h
Expand Up @@ -20,6 +20,7 @@
#ifndef _tex_
#define _tex_

#include "lib/framework/wzstring.h"
#include "gfx_api.h"
#include "png_util.h"

Expand All @@ -41,7 +42,7 @@ int iV_GetTexture(const char *filename, bool compression = true);
void iV_unloadImage(iV_Image *image);
gfx_api::pixel_format iV_getPixelFormat(const iV_Image *image);

bool replaceTexture(const QString &oldfile, const QString &newfile);
bool replaceTexture(const WzString &oldfile, const WzString &newfile);
int pie_AddTexPage(iV_Image *s, const char *filename, bool gameTexture, int page = -1);
void pie_TexInit();

Expand Down
2 changes: 1 addition & 1 deletion src/qtscriptfuncs.cpp
Expand Up @@ -4747,7 +4747,7 @@ static QScriptValue js_replaceTexture(QScriptContext *context, QScriptEngine *)
{
QString oldfile = context->argument(0).toString();
QString newfile = context->argument(1).toString();
replaceTexture(oldfile, newfile);
replaceTexture(WzString::fromUtf8(oldfile.toUtf8().constData()), WzString::fromUtf8(newfile.toUtf8().constData()));
return QScriptValue();
}

Expand Down

0 comments on commit 9928744

Please sign in to comment.