Add attributes to printf-like functions and functions which don't return. diff --git a/src/battle.cpp b/src/battle.cpp --- a/src/battle.cpp +++ b/src/battle.cpp @@ -477,7 +477,7 @@ int mainBattleLoop() { String banner = mission->missionName.getText(); banner.toLowerCase(); - missionBanner = graphics->getGLString(banner.getText()); + missionBanner = graphics->getGLString("%s", banner.getText()); } textureManager->removeTexture("MissionBanner"); diff --git a/src/common/CString.cpp b/src/common/CString.cpp --- a/src/common/CString.cpp +++ b/src/common/CString.cpp @@ -198,8 +198,12 @@ void String::operator= (char *text) void String::operator= (String string) { - printf("DO NOT USE (Buggy) - String::operator= %s\n", string.getText()); - exit(1); + if (this->text != NULL) + { + delete[] this->text; + this->text = NULL; + } + *this = string.text; } bool String::operator== (char *text) diff --git a/src/common/CString.h b/src/common/CString.h --- a/src/common/CString.h +++ b/src/common/CString.h @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place - Suit Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "../attributes.h" class String : public Linkable { @@ -46,7 +48,7 @@ class String : public Linkable { void toUpperCase(); void captialise(); - void setText(char *text, ...); + void setText(char *text, ...) GCC_PRINTF(2,3); char *getText(); int getLength(); diff --git a/src/cutscene.cpp b/src/cutscene.cpp --- a/src/cutscene.cpp +++ b/src/cutscene.cpp @@ -381,7 +381,7 @@ Texture *buildCutsceneNarrative(char *lo graphics->setTransparent(s); graphics->setFont(FONT_NORMAL); graphics->setFontColor(255, 255, 255, 0, 0, 0); - graphics->writeWrappedText(s, true, localeToken); + graphics->writeWrappedText(s, true, "%s", localeToken); Texture *instructions = graphics->createTexture(s); diff --git a/src/entities/items.cpp b/src/entities/items.cpp --- a/src/entities/items.cpp +++ b/src/entities/items.cpp @@ -301,7 +301,7 @@ int handleExplosiveWeapon(Weapon *weapon audio->playSound(SND_PICKUP_WEAPON, CH_PICKUP, 128); - game->setInfoMessage(INFO_PICKUP, _("Picked up some Grenades"), weaponDef->getName()); + game->setInfoMessage(INFO_PICKUP, _("Picked up some %s"), weaponDef->getName()); rtn = ITEM_CONSUME; } @@ -328,7 +328,7 @@ int handleExplosiveWeapon(Weapon *weapon audio->playSound(SND_PICKUP_WEAPON, CH_PICKUP, 128); - game->setInfoMessage(INFO_PICKUP, _("Picked up some Grenades"), weaponDef->getName()); + game->setInfoMessage(INFO_PICKUP, _("Picked up some %s"), weaponDef->getName()); rtn = ITEM_CONSUME; } @@ -471,7 +471,7 @@ int handleNormalWeapon(Weapon *weapon, b } else { - game->setInfoMessage(INFO_PICKUP, _("Picked up some Grenades"), weaponDef->getName()); + game->setInfoMessage(INFO_PICKUP, _("Picked up some %s"), weaponDef->getName()); } game->alterStat(_("Weapons Picked Up"), 1); diff --git a/src/game/CGame.h b/src/game/CGame.h --- a/src/game/CGame.h +++ b/src/game/CGame.h @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place - Suit Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "../attributes.h" typedef struct InfoMessage { @@ -146,9 +148,9 @@ class Game { void setMissionStatus(int status); - void setInfoMessage(int type, char *message, ...); - void setGamePlayMessage(int type, char *message, ...); - void setGamePlayMessage(int type, int time, char *message, ...); + void setInfoMessage(int type, char *message, ...) GCC_PRINTF(3,4); + void setGamePlayMessage(int type, char *message, ...) GCC_PRINTF(3,4); + void setGamePlayMessage(int type, int time, char *message, ...) GCC_PRINTF(4,5); int getFreeInventorySlot(); int getItemSlot(char *name); diff --git a/src/gui/CButton.h b/src/gui/CButton.h --- a/src/gui/CButton.h +++ b/src/gui/CButton.h @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place - Suit Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "../attributes.h" class Button : public BaseWidget { @@ -39,7 +41,7 @@ class Button : public BaseWidget { void use(int x, int y); - void setLabel(char *label, ...); + void setLabel(char *label, ...) GCC_PRINTF(2,3); void setProperties(Properties *properties); void mousePressed(SDL_MouseButtonEvent mouse); diff --git a/src/gui/CComboBox.cpp b/src/gui/CComboBox.cpp --- a/src/gui/CComboBox.cpp +++ b/src/gui/CComboBox.cpp @@ -57,7 +57,7 @@ void ComboBox::addItem(char *text) void ComboBox::addItem(char *text) { String *item = new String(); - item->setText(text); + item->setText("%s", text); itemList.add(item); diff --git a/src/hud/controlPanel.cpp b/src/hud/controlPanel.cpp --- a/src/hud/controlPanel.cpp +++ b/src/hud/controlPanel.cpp @@ -119,7 +119,7 @@ void drawBlobHealthShieldInfo() if ((t = textureManager->getTexture(s.getText())) == NULL) { - t = graphics->getGLString(unit->getName()); + t = graphics->getGLString("%s", unit->getName()); textureManager->addTexture(s.getText(), t); } @@ -231,7 +231,7 @@ void drawBlobHealthShieldInfo() if ((t = textureManager->getTexture(s.getText())) == NULL) { - t = graphics->getGLString(boss->getName()); + t = graphics->getGLString("%s", boss->getName()); textureManager->addTexture(s.getText(), t); } @@ -372,7 +372,7 @@ void drawWeaponsAndItems() { if (weaponDef->unlimited) { - t = graphics->getGLString(game->weapon[i]->definition->getName()); + t = graphics->getGLString("%s", game->weapon[i]->definition->getName()); } else { @@ -541,7 +541,7 @@ void drawMessages() if ((t = textureManager->getTexture(s.getText())) == NULL) { - t = graphics->getGLString(game->infoMessage[i].message.getText()); + t = graphics->getGLString("%s", game->infoMessage[i].message.getText()); textureManager->addTexture(s.getText(), t); } @@ -564,7 +564,7 @@ void drawMessages() if ((t = textureManager->getTexture(s.getText())) == NULL) { - t = graphics->getGLString(game->gameplayMessage.message.getText()); + t = graphics->getGLString("%s", game->gameplayMessage.message.getText()); textureManager->addTexture(s.getText(), t); } diff --git a/src/hud/dialogs.cpp b/src/hud/dialogs.cpp --- a/src/hud/dialogs.cpp +++ b/src/hud/dialogs.cpp @@ -77,7 +77,7 @@ SDL_Surface *buildMainDialog(char *messa graphics->setTransparent(scratch); graphics->setFont(FONT_NORMAL); graphics->setFontColor(255, 255, 255, 0, 0, 0); - graphics->writeWrappedText(scratch, true, message); + graphics->writeWrappedText(scratch, true, "%s", message); int width = max(graphics->textWidth + 20, 250); diff --git a/src/hud/status.cpp b/src/hud/status.cpp --- a/src/hud/status.cpp +++ b/src/hud/status.cpp @@ -65,17 +65,17 @@ void drawObjectiveStatus(Objective *obje break; } - graphics->drawString(ax + 120, y, TXT_LEFT, GLColor::white, true, objective->description.getText()); - - graphics->drawString(ax + 450, y, TXT_LEFT, GLColor::white, true, objective->getProgress()); - - graphics->drawString(ax + 685, y, TXT_RIGHT, c, true, objective->getStatus()); + graphics->drawString(ax + 120, y, TXT_LEFT, GLColor::white, true, "%s", objective->description.getText()); + + graphics->drawString(ax + 450, y, TXT_LEFT, GLColor::white, true, "%s", objective->getProgress()); + + graphics->drawString(ax + 685, y, TXT_RIGHT, c, true, "%s", objective->getStatus()); } void drawObjectiveTabTitle(char *title, int ax, int ay) { graphics->setFont(FONT_LARGE); - graphics->drawString(graphics->screen-> w / 2, ay + 90, TXT_CENTERED, GLColor::white, true, title); + graphics->drawString(graphics->screen-> w / 2, ay + 90, TXT_CENTERED, GLColor::white, true, "%s", title); graphics->drawRect(ax + 60, ay + 125, 680, 1, GLColor::white, false); graphics->setFont(FONT_NORMAL); } @@ -174,22 +174,22 @@ void drawUnitDebriefTab(int ax, int ay) lineColor = GLColor::grey; } - graphics->drawString(ax + 60, y, TXT_LEFT, lineColor, true, unit->getName()); + graphics->drawString(ax + 60, y, TXT_LEFT, lineColor, true, "%s", unit->getName()); graphics->drawString(ax + 200, y, TXT_LEFT, lineColor, true, "%d / %d", (int)unit->health, (int)unit->maxHealth); graphics->drawString(ax + 350, y, TXT_LEFT, lineColor, true, "%d / %d", (int)unit->shield, (int)unit->maxShield); graphics->drawString(ax + 450, y, TXT_LEFT, lineColor, true, "%s", getBlobJob(unit)); if (unit->definition->type == BLOB_BOB) { - graphics->drawString(ax + 650, y, TXT_LEFT, lineColor, true, game->selectedWeapon->definition->getName()); + graphics->drawString(ax + 650, y, TXT_LEFT, lineColor, true, "%s", game->selectedWeapon->definition->getName()); } else if (unit->definition->type == BLOB_TEEKA) { - graphics->drawString(ax + 650, y, TXT_LEFT, lineColor, true, findTeeka()->currentWeapon->getName()); + graphics->drawString(ax + 650, y, TXT_LEFT, lineColor, true, "%s", findTeeka()->currentWeapon->getName()); } else { - graphics->drawString(ax + 650, y, TXT_LEFT, lineColor, true, unit->currentWeapon->getName()); + graphics->drawString(ax + 650, y, TXT_LEFT, lineColor, true, "%s", unit->currentWeapon->getName()); } y += 25; diff --git a/src/hud/widgets.cpp b/src/hud/widgets.cpp --- a/src/hud/widgets.cpp +++ b/src/hud/widgets.cpp @@ -177,7 +177,7 @@ void drawComboBox(ComboBox *comboBox) { graphics->setFont(FONT_NORMAL); - graphics->drawString((comboBox->x + comboBox->width / 2), comboBox->y, TXT_CENTERED, GLColor::white, true, comboBox->currentItemText.getText()); + graphics->drawString((comboBox->x + comboBox->width / 2), comboBox->y, TXT_CENTERED, GLColor::white, true, "%s", comboBox->currentItemText.getText()); (comboBox->selectedItem != 0) ? glColor3f(1.0, 1.0, 1.0) : glColor4f(1.0, 1.0, 1.0, 0.25); @@ -255,7 +255,7 @@ void drawInputWidget(InputWidget *inputW delete inputWidget->normalImage; } - inputWidget->normalImage = graphics->getGLString(renderString.getText()); + inputWidget->normalImage = graphics->getGLString("%s", renderString.getText()); glEnable(GL_BLEND); @@ -327,11 +327,11 @@ BaseWidget *createButtonWidget(Propertie graphics->setFontColor(0xff, 0xff, 0xaa, 0x00, 0x00, 0x00); graphics->setFont(button->fontSize); - SDL_Surface *labelImage = graphics->getString(true, button->label.getText()); + SDL_Surface *labelImage = graphics->getString(true, "%s", button->label.getText()); graphics->setFontColor(0x88, 0x88, 0x88, 0x00, 0x00, 0x00); graphics->setFont(button->fontSize); - SDL_Surface *disabledLabelImage = graphics->getString(true, button->label.getText()); + SDL_Surface *disabledLabelImage = graphics->getString(true, "%s", button->label.getText()); int colSpan = props->getInt("colSpan", 1); @@ -465,7 +465,7 @@ BaseWidget *createLabelWidget(Properties graphics->setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00); - label->currentImage = graphics->getGLString(label->text.getText()); + label->currentImage = graphics->getGLString("%s", label->text.getText()); return label; } diff --git a/src/io/save.cpp b/src/io/save.cpp --- a/src/io/save.cpp +++ b/src/io/save.cpp @@ -30,7 +30,7 @@ void showSaveGameProgess(char *progress, graphics->drawRect(0, (graphics->screen->h / 2) - 10, graphics->screen->w, 1, GLColor::white, false); graphics->drawRect(0, (graphics->screen->h / 2) + 24, graphics->screen->w, 1, GLColor::white, false); - graphics->drawString(graphics->screenMidX, graphics->screenMidY, TXT_CENTERED, GLColor::white, true, progress); + graphics->drawString(graphics->screenMidX, graphics->screenMidY, TXT_CENTERED, GLColor::white, true, "%s", progress); graphics->delay(1, false); } diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -18,9 +18,10 @@ Foundation, Inc., 59 Temple Place - Suit */ +#include "attributes.h" #include "main.h" -void showHelp() +void GCC_NORETURN showHelp() { SDL_Init(SDL_INIT_VIDEO); @@ -65,7 +66,7 @@ void showHelp() exit(0); } -void showVersion() +void GCC_NORETURN showVersion() { printf("\n"); printf("Blob Wars, Episode II - Blob And Conquer (Version %.2f, Release %d)\n", VERSION, RELEASE); diff --git a/src/misc.cpp b/src/misc.cpp --- a/src/misc.cpp +++ b/src/misc.cpp @@ -29,7 +29,7 @@ void addStatToList(ListView *listView, c textSurface = graphics->createSurface(listView->width, 16); graphics->setTransparent(textSurface); - graphics->drawString(25, 0, TXT_LEFT, textSurface, string); + graphics->drawString(25, 0, TXT_LEFT, textSurface, "%s", string); graphics->drawString(listView->width - position, 0, TXT_RIGHT, textSurface, "%d", (int)value); item = new ListViewItem(); @@ -62,7 +62,7 @@ void addStatToList(ListView *listView, c graphics->setTransparent(textSurface); graphics->drawString(25, 0, TXT_LEFT, textSurface, _("Total Game Time")); - graphics->drawString(listView->width - position, 0, TXT_RIGHT, textSurface, time.getText()); + graphics->drawString(listView->width - position, 0, TXT_RIGHT, textSurface, "%s", time.getText()); item = new ListViewItem(); item->texture = graphics->createTexture(textSurface); @@ -84,7 +84,7 @@ void addStringToList(ListView *listView, textSurface = graphics->createSurface(listView->width, 16); graphics->setTransparent(textSurface); - graphics->drawString(25, 0, TXT_LEFT, textSurface, string); + graphics->drawString(25, 0, TXT_LEFT, textSurface, "%s", string); item = new ListViewItem(); item->texture = graphics->createTexture(textSurface); @@ -137,7 +137,7 @@ void addSaveHeaderToList(ListView *listV else { graphics->setFontColor(0xff, 0xff, 0xff, 0, 0, 0); - graphics->drawString(5, 0, TXT_LEFT, textSurface, header->description.getText()); + graphics->drawString(5, 0, TXT_LEFT, textSurface, "%s", header->description.getText()); graphics->drawString(textSurface->w - 5, 0, TXT_RIGHT, textSurface, "%s, %s", header->date.getText(), header->time.getText()); } diff --git a/src/puzzles/laserGrid.cpp b/src/puzzles/laserGrid.cpp --- a/src/puzzles/laserGrid.cpp +++ b/src/puzzles/laserGrid.cpp @@ -37,7 +37,7 @@ Texture *buildLaserGridInstructions() graphics->setTransparent(s); graphics->setFont(FONT_NORMAL); graphics->setFontColor(255, 255, 255, 0, 0, 0); - graphics->writeWrappedText(s, true, (char*)engine->dataBuffer); + graphics->writeWrappedText(s, true, "%s", (char*)engine->dataBuffer); Texture *instructions = graphics->createTexture(s); @@ -144,7 +144,7 @@ bool doLaserGridPuzzle(int seed) String banner; graphics->setFont(FONT_DIGITAL); banner.setText("%d remaining", assignedPairs); - Texture *pairsRemaining = graphics->getGLString(banner.getText()); + Texture *pairsRemaining = graphics->getGLString("%s", banner.getText()); textureManager->removeTexture("PairsRemaining"); textureManager->addTexture("PairsRemaining", pairsRemaining); graphics->setFont(FONT_NORMAL); @@ -253,7 +253,7 @@ bool doLaserGridPuzzle(int seed) graphics->setFont(FONT_DIGITAL); banner.setText("%d remaining", assignedPairs); - pairsRemaining = graphics->getGLString(banner.getText()); + pairsRemaining = graphics->getGLString("%s", banner.getText()); textureManager->removeTexture("PairsRemaining"); textureManager->addTexture("PairsRemaining", pairsRemaining); graphics->setFont(FONT_NORMAL); diff --git a/src/puzzles/mastermind.cpp b/src/puzzles/mastermind.cpp --- a/src/puzzles/mastermind.cpp +++ b/src/puzzles/mastermind.cpp @@ -39,7 +39,7 @@ Texture *buildMasterMindInstructions() graphics->setTransparent(s); graphics->setFont(FONT_NORMAL); graphics->setFontColor(255, 255, 255, 0, 0, 0); - graphics->writeWrappedText(s, true, (char*)engine->dataBuffer); + graphics->writeWrappedText(s, true, "%s", (char*)engine->dataBuffer); Texture *instructions = graphics->createTexture(s); diff --git a/src/system/CGraphics.cpp b/src/system/CGraphics.cpp --- a/src/system/CGraphics.cpp +++ b/src/system/CGraphics.cpp @@ -237,7 +237,7 @@ void Graphics::drawFPSCount(int y) frames = 0; } - drawString(screen->w - 5, y, TXT_RIGHT, GLColor::white, true, fps.getText()); + drawString(screen->w - 5, y, TXT_RIGHT, GLColor::white, true, "%s", fps.getText()); } void Graphics::showLoadingProgress(char *status) @@ -246,7 +246,7 @@ void Graphics::showLoadingProgress(char drawRect(0, 0, screen->w, screen->h, GLColor::black, false); - drawString(5, screen->h - 20, TXT_LEFT, GLColor::white, true, status); + drawString(5, screen->h - 20, TXT_LEFT, GLColor::white, true, "%s", status); updateScreen(); } @@ -760,7 +760,6 @@ void Graphics::writeWrappedText(SDL_Surf textHeight = 0; char *word = strtok(tmpString, " "); - char wordWithSpace[100]; int x = 0; int y = 0; @@ -769,9 +768,7 @@ void Graphics::writeWrappedText(SDL_Surf while (word) { - sprintf(wordWithSpace, "%s ", word); - - wordSurface = getString(transparent, wordWithSpace); + wordSurface = getString(transparent, "%s ", word); if (x + wordSurface->w > surface->w) { @@ -1283,7 +1280,7 @@ void Graphics::showErrorAndExit(char *er glEnable(GL_BLEND); drawString(400 + adjustX, y + adjustY, TXT_CENTERED, GLColor::red, true, "An unforseen error has occurred"); - drawString(400 + adjustX, (y += 30) + adjustY, TXT_CENTERED, GLColor::red, true, tmpString); + drawString(400 + adjustX, (y += 30) + adjustY, TXT_CENTERED, GLColor::red, true, "%s", tmpString); drawString(50 + adjustX, (y += 50) + adjustY, TXT_LEFT, GLColor::white, true, "You may wish to try the following,"); diff --git a/src/system/CGraphics.h b/src/system/CGraphics.h --- a/src/system/CGraphics.h +++ b/src/system/CGraphics.h @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place - Suit Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "../attributes.h" class Graphics { @@ -135,9 +137,9 @@ class Graphics { void createRaisedBorder(GLColor light, GLColor shade); void createLoweredBorder(GLColor light, GLColor shade); void drawGradient(GLColor color1, GLColor color2, bool vertical); - Texture *getGLString(char *text, ...); - void drawString(int x, int y, int alignment, GLColor color, bool transparent, char *text, ...); - void drawString(int x, int y, int alignment, SDL_Surface *dest, char *text, ...); + Texture *getGLString(char *text, ...) GCC_PRINTF(2,3); + void drawString(int x, int y, int alignment, GLColor color, bool transparent, char *text, ...) GCC_PRINTF(7,8); + void drawString(int x, int y, int alignment, SDL_Surface *dest, char *text, ...) GCC_PRINTF(6,7); // SDL Functions void putPixel(int x, int y, Uint32 pixel, SDL_Surface *dest); @@ -145,7 +147,7 @@ class Graphics { void drawLine(int startX, int startY, int endX, int endY, int color, SDL_Surface *dest); void drawCircle(int x, int y, int radius, SDL_Surface *dest, int color); void blit(SDL_Surface *image, int x, int y, SDL_Surface *dest, bool centered); - SDL_Surface *getString(bool transparent, char *text, ...); + SDL_Surface *getString(bool transparent, char *text, ...) GCC_PRINTF(3,4); void drawRect(int x, int y, int w, int h, int color, SDL_Surface *dest); void drawRect(int x, int y, int w, int h, int color, int borderColor, SDL_Surface *dest); void createLineBorder(SDL_Surface *surface, int color); @@ -156,9 +158,9 @@ class Graphics { void unlock(SDL_Surface *surface); void setFontColor(int red, int green, int blue, int red2, int green2, int blue2); SDL_Surface *createSurface(int width, int height); - void writeWrappedText(SDL_Surface *dest, bool transparent, char *text, ...); + void writeWrappedText(SDL_Surface *dest, bool transparent, char *text, ...) GCC_PRINTF(4,5); - void showErrorAndExit(char *error, ...); - void showLicenseErrorAndExit(); + void showErrorAndExit(char *error, ...) GCC_PRINTF(2,3) GCC_NORETURN; + void showLicenseErrorAndExit() GCC_NORETURN; }; diff --git a/src/system/CPak.h b/src/system/CPak.h --- a/src/system/CPak.h +++ b/src/system/CPak.h @@ -37,7 +37,7 @@ class Pak { char filename[PAK_MAX_FILENAME]; Pak(); - void showPakErrorAndExit(); + void showPakErrorAndExit() GCC_NORETURN; bool fileExistsInPak(char *filename); bool fileExistsInFS(char *filename); diff --git a/src/world/bsp.cpp b/src/world/bsp.cpp --- a/src/world/bsp.cpp +++ b/src/world/bsp.cpp @@ -99,7 +99,7 @@ int tesselate(BSPBiQuadraticPatch *quadP if (quadPatch->verts == NULL) { - graphics->showErrorAndExit("BSP - Failed to allocate %d bytes for tesselation", (bsp->tesselation + 1) * (bsp->tesselation + 1) * sizeof(BSPVertex)); + graphics->showErrorAndExit("BSP - Failed to allocate %ld bytes for tesselation", (bsp->tesselation + 1) * (bsp->tesselation + 1) * sizeof(BSPVertex)); } for (v=0;v<=bsp->tesselation;v++) @@ -191,7 +191,7 @@ int tesselate(BSPBiQuadraticPatch *quadP if (quadPatch->indices == NULL) { - graphics->showErrorAndExit("BSP - Failed to allocate %d bytes for indices", bsp->tesselation * (bsp->tesselation + 1) * 2 * sizeof(unsigned int)); + graphics->showErrorAndExit("BSP - Failed to allocate %ld bytes for indices", bsp->tesselation * (bsp->tesselation + 1) * 2 * sizeof(unsigned int)); } for (row=0;rowtesselation;row++) @@ -209,12 +209,12 @@ int tesselate(BSPBiQuadraticPatch *quadP if (quadPatch->trianglesPerRow == NULL) { - graphics->showErrorAndExit("BSP - Failed to allocate %d bytes for trianglesPerRow", bsp->tesselation * sizeof(int)); + graphics->showErrorAndExit("BSP - Failed to allocate %ld bytes for trianglesPerRow", bsp->tesselation * sizeof(int)); } if (quadPatch->rowIndexPointers == NULL) { - graphics->showErrorAndExit("BSP - Failed to allocate %d bytes for rowIndexPointers", bsp->tesselation * sizeof(unsigned int)); + graphics->showErrorAndExit("BSP - Failed to allocate %ld bytes for rowIndexPointers", bsp->tesselation * sizeof(unsigned int)); } for (row=0;rowtesselation;row++) @@ -367,7 +367,7 @@ int loadTextures(FILE *fp, BSPLump *lump if (bsp->textures == NULL) { fclose(fp); - graphics->showErrorAndExit("BSP - Failed to allocate %d bytes for textures", bsp->numOfTextures * sizeof(BSPTexture)); + graphics->showErrorAndExit("BSP - Failed to allocate %ld bytes for textures", bsp->numOfTextures * sizeof(BSPTexture)); } bsp->textureSpec = (TextureSpec **)malloc(bsp->numOfTextures * sizeof(TextureSpec *)); @@ -375,7 +375,7 @@ int loadTextures(FILE *fp, BSPLump *lump if (bsp->textureSpec == NULL) { fclose(fp); - graphics->showErrorAndExit("BSP - Failed to allocate %d bytes for texture validation", bsp->numOfTextures * sizeof(TextureSpec)); + graphics->showErrorAndExit("BSP - Failed to allocate %ld bytes for texture validation", bsp->numOfTextures * sizeof(TextureSpec)); } fseek(fp, lumps[kTextures].offset, SEEK_SET); @@ -828,7 +828,7 @@ int loadPatches(FILE *fp, BSPLump *lumps if (bsp->patches == NULL) { - printf("Failed to allocate %d bytes for patches\n", bsp->numOfPatches * sizeof(BSPPatch)); + printf("Failed to allocate %ld bytes for patches\n", bsp->numOfPatches * sizeof(BSPPatch)); fclose(fp); exit(1); }