AGS: gcc compilation fixes

This commit is contained in:
Paul Gilbert 2021-01-24 22:23:09 -08:00
parent a11cab9a50
commit 8bc249b99f
10 changed files with 118 additions and 108 deletions

View File

@ -31,6 +31,7 @@
#ifndef AGS_ENGINE_PLUGIN_AGSPLUGIN_H
#define AGS_ENGINE_PLUGIN_AGSPLUGIN_H
#include "ags/shared/core/types.h"
#include "common/array.h"
namespace AGS3 {

View File

@ -126,41 +126,41 @@ void AGSFlashlight::AGS_EngineStartup(IAGSEngine *engine) {
if (_engine->version < 13)
_engine->AbortGame("Engine interface is too old, need newer version of AGS.");
SCRIPT_METHOD("SetFlashlightTint");
SCRIPT_METHOD("GetFlashlightTintRed");
SCRIPT_METHOD("GetFlashlightTintGreen");
SCRIPT_METHOD("GetFlashlightTintBlue");
SCRIPT_METHOD(SetFlashlightTint);
SCRIPT_METHOD(GetFlashlightTintRed);
SCRIPT_METHOD(GetFlashlightTintGreen);
SCRIPT_METHOD(GetFlashlightTintBlue);
SCRIPT_METHOD("GetFlashlightMinLightLevel");
SCRIPT_METHOD("GetFlashlightMaxLightLevel");
SCRIPT_METHOD(GetFlashlightMinLightLevel);
SCRIPT_METHOD(GetFlashlightMaxLightLevel);
SCRIPT_METHOD("SetFlashlightDarkness");
SCRIPT_METHOD("GetFlashlightDarkness");
SCRIPT_METHOD("SetFlashlightDarknessSize");
SCRIPT_METHOD("GetFlashlightDarknessSize");
SCRIPT_METHOD(SetFlashlightDarkness);
SCRIPT_METHOD(GetFlashlightDarkness);
SCRIPT_METHOD(SetFlashlightDarknessSize);
SCRIPT_METHOD(GetFlashlightDarknessSize);
SCRIPT_METHOD("SetFlashlightBrightness");
SCRIPT_METHOD("GetFlashlightBrightness");
SCRIPT_METHOD("SetFlashlightBrightnessSize");
SCRIPT_METHOD("GetFlashlightBrightnessSize");
SCRIPT_METHOD(SetFlashlightBrightness);
SCRIPT_METHOD(GetFlashlightBrightness);
SCRIPT_METHOD(SetFlashlightBrightnessSize);
SCRIPT_METHOD(GetFlashlightBrightnessSize);
SCRIPT_METHOD("SetFlashlightPosition");
SCRIPT_METHOD("GetFlashlightPositionX");
SCRIPT_METHOD("GetFlashlightPositionY");
SCRIPT_METHOD(SetFlashlightPosition);
SCRIPT_METHOD(GetFlashlightPositionX);
SCRIPT_METHOD(GetFlashlightPositionY);
SCRIPT_METHOD("SetFlashlightFollowMouse");
SCRIPT_METHOD("GetFlashlightFollowMouse");
SCRIPT_METHOD(SetFlashlightFollowMouse);
SCRIPT_METHOD(GetFlashlightFollowMouse);
SCRIPT_METHOD("SetFlashlightFollowCharacter");
SCRIPT_METHOD("GetFlashlightFollowCharacter");
SCRIPT_METHOD("GetFlashlightCharacterDX");
SCRIPT_METHOD("GetFlashlightCharacterDY");
SCRIPT_METHOD("GetFlashlightCharacterHorz");
SCRIPT_METHOD("GetFlashlightCharacterVert");
SCRIPT_METHOD(SetFlashlightFollowCharacter);
SCRIPT_METHOD(GetFlashlightFollowCharacter);
SCRIPT_METHOD(GetFlashlightCharacterDX);
SCRIPT_METHOD(GetFlashlightCharacterDY);
SCRIPT_METHOD(GetFlashlightCharacterHorz);
SCRIPT_METHOD(GetFlashlightCharacterVert);
SCRIPT_METHOD("SetFlashlightMask");
SCRIPT_METHOD("GetFlashlightMask");
SCRIPT_METHOD(SetFlashlightMask);
SCRIPT_METHOD(GetFlashlightMask);
_engine->RequestEventHook(AGSE_PREGUIDRAW);
_engine->RequestEventHook(AGSE_PRESCREENDRAW);

View File

@ -1068,14 +1068,18 @@ int GetTranslucentOverlayAlpha(int id) {
}
int SetTranslucentOverlayAlpha(int id, int alpha) {
if (alpha >= 0 && alpha < 256) overlay[id].trans = alpha;
else engine->AbortGame("CreateTranslucentOverlay: Invalid alpha selected.");
if (alpha >= 0 && alpha < 256)
overlay[id].trans = alpha;
else
engine->AbortGame("CreateTranslucentOverlay: Invalid alpha selected.");
return 0;
}
int SetTranslucentOverlayEnabled(int id, int toggle) {
if (toggle > 0) overlay[id].enabled = true;
else overlay[id].enabled = false;
if (toggle > 0)
overlay[id].enabled = true;
else
overlay[id].enabled = false;
return 0;
}
@ -1085,16 +1089,18 @@ void SetCharacterReflected(int id, int refl) {
}
void SetObjectReflected(int id, int refl) {
if (refl > 0) Reflection.Objects[id].reflect = 1;
else Reflection.Objects[id].reflect = 0;
if (refl > 0)
Reflection.Objects[id].reflect = 1;
else
Reflection.Objects[id].reflect = 0;
}
int GetCharacterReflected(int id) {
return Reflection.Characters[id].reflect;
}
void GetObjectReflected(int id) {
Reflection.Objects[id].reflect;
int GetObjectReflected(int id) {
return Reflection.Objects[id].reflect;
}
void ReplaceCharacterReflectionView(int id, int view) {
@ -1131,9 +1137,10 @@ int DrawReflections(int id, int charobj = 0) {
//Get character, and their sprite.
if (charobj == 0) {
currchar = engine->GetCharacter(id);
int view = 0;
/*int view = 0;
if (Reflection.Characters[id].replaceview == 0) view = currchar->view + 1;
else view = Reflection.Characters[id].replaceview;
*/
AGSViewFrame *vf = engine->GetViewFrame(currchar->view + 1, currchar->loop, currchar->frame);
charsprite = engine->GetSpriteGraphic(vf->pic);
long scaling = currchar->flags & CHF_NOSCALING;
@ -1270,8 +1277,7 @@ int DrawTransSprite(int spriteId, int bg, int translevel, int mask = 0, int blen
if (mask > 0) maskspr = engine->GetSpriteGraphic(mask);
if (!maskspr && mask > 0) {
char maskerr [100];
int cx;
cx = snprintf(maskerr, 100, "DrawTransSprite: Can't load mask from slot %d.", mask);
snprintf(maskerr, 100, "DrawTransSprite: Can't load mask from slot %d.", mask);
engine->AbortGame(maskerr);
}
// Get a reference to the screen we'll draw onto

View File

@ -111,21 +111,21 @@ int Ray_GetNoClip() {
}
void Ray_DrawTile(int spr, int tile) {
BITMAP *sprite = engine->GetSpriteGraphic(spr);
unsigned char **sprarray = engine->GetRawBitmapSurface(sprite);
BITMAP *img = engine->GetSpriteGraphic(spr);
unsigned char **sprarray = engine->GetRawBitmapSurface(img);
for (int y = 0; y < 64; ++y)
for (int x = 0; x < 64; ++x)
sprarray [y][x] = texture [tile][(texWidth * y) + x];
engine->ReleaseBitmapSurface(sprite);
engine->ReleaseBitmapSurface(img);
}
void Ray_DrawOntoTile(int spr, int tile) {
BITMAP *sprite = engine->GetSpriteGraphic(spr);
unsigned char **sprarray = engine->GetRawBitmapSurface(sprite);
BITMAP *img = engine->GetSpriteGraphic(spr);
unsigned char **sprarray = engine->GetRawBitmapSurface(img);
for (int y = 0; y < 64; ++y)
for (int x = 0; x < 64; ++x)
texture [tile][(texWidth * y) + x] = sprarray [y][x];
engine->ReleaseBitmapSurface(sprite);
engine->ReleaseBitmapSurface(img);
}
int Ray_GetTileX_At(int x, int y) {
@ -351,14 +351,14 @@ void LoadHeightMap(int heightmapSlot) {
void LoadMap(int worldmapSlot, int lightmapSlot, int ceilingmapSlot, int floormapSlot) {
int tempw = engine->GetSpriteWidth(worldmapSlot);
int temph = engine->GetSpriteHeight(worldmapSlot);
BITMAP *worldmapBm;
BITMAP *lightmapBm;
BITMAP *floormapBm;
BITMAP *ceilingmapBm;
unsigned char **wmArray;
unsigned char **lmArray;
unsigned char **fmArray;
unsigned char **cmArray;
BITMAP *worldmapBm = nullptr;
BITMAP *lightmapBm = nullptr;
BITMAP *floormapBm = nullptr;
BITMAP *ceilingmapBm = nullptr;
unsigned char **wmArray = nullptr;
unsigned char **lmArray = nullptr;
unsigned char **fmArray = nullptr;
unsigned char **cmArray = nullptr;
worldmapBm = engine->GetSpriteGraphic(worldmapSlot);
if (!worldmapBm) engine->AbortGame("LoadMap: Couldn't load worldmap sprite into memory.");
wmArray = engine->GetRawBitmapSurface(worldmapBm);
@ -533,7 +533,7 @@ void MakeTextures(int slot) {
unsigned char **texbuffer = engine->GetRawBitmapSurface(texspr);
int numTilesX = sourceWidth / texWidth;
int numTilesY = sourceHeight / texHeight;
int totaltiles = numTilesX * numTilesY;
//int totaltiles = numTilesX * numTilesY;
for (int numX = 0; numX < numTilesX; ++numX) {
for (int numY = 0; numY < numTilesY; ++numY) {
for (int x = 0; x < texWidth; ++x)
@ -648,8 +648,9 @@ FLOAT_RETURN_TYPE Ray_GetDistanceAt(int x, int y) {
}
void Init_Raycaster() {
if (ZBuffer) return;
if (!worldMap) return;
if (ZBuffer)
return;
//if (!worldMap) return;
transcolorbuffer = new unsigned char *[sWidth];
transalphabuffer = new unsigned char *[sWidth];
transslicedrawn = new bool[sWidth]();
@ -683,7 +684,7 @@ void Raycast_Render(int slot) {
BITMAP *sbBm = engine->GetSpriteGraphic(skybox);
if (!sbBm) engine->AbortGame("Raycast_Render: No valid skybox sprite.");
if (skybox > 0) {
int bgdeg = (int)((playerrad / PI) * 180.0) + 180;
//int bgdeg = (int)((playerrad / PI) * 180.0) + 180;
int xoffset = (int)(playerrad * 320.0);
BITMAP *virtsc = engine->GetVirtualScreen();
engine->SetVirtualScreen(screen);
@ -702,7 +703,7 @@ void Raycast_Render(int slot) {
ZBuffer[x][y] = 0;
}
}
int multiplier = mapWidth;
//int multiplier = mapWidth;
memset(interactionmap, 0, sizeof(short) * (sHeight * sWidth));
//start the main loop
for (int x = 0; x < w; x++) {
@ -725,7 +726,7 @@ void Raycast_Render(int slot) {
//length of ray from one x or y-side to next x or y-side
double deltaDistX = fsqrt(1 + (rayDirY * rayDirY) / (rayDirX * rayDirX));
double deltaDistY = fsqrt(1 + (rayDirX * rayDirX) / (rayDirY * rayDirY));
double perpWallDist;
double perpWallDist = 0.0;
//what direction to step in x or y-direction (either +1 or -1)
int stepX;
@ -733,7 +734,7 @@ void Raycast_Render(int slot) {
int prevmapX = 0;
int prevmapY = 0;
int hit = 0; //was there a wall hit?
int side; //was a NS or a EW wall hit?
int side = 0; //was a NS or a EW wall hit?
//calculate step and initial sideDist
if (rayDirX < 0) {
@ -750,13 +751,13 @@ void Raycast_Render(int slot) {
stepY = 1;
sideDistY = (mapY + 1.0 - rayPosY) * deltaDistY;
}
//perform DDA
// Perform DDA
bool deeper = true;
bool opposite = true;
bool oppositedrawn = false;
double wallX; //where exactly the wall was hit
double wallX = 0; // Where exactly the wall was hit
int drawStart;
int drawEnd;
int drawEnd = 0;
while (hit == 0 && deeper == true) {
if (opposite) {
rayDirX = -rayDirX;
@ -765,7 +766,7 @@ void Raycast_Render(int slot) {
stepY = -stepY;
if (sideDistX < sideDistY) side = 0;
else side = 1;
} else if (sideDistX < sideDistY) { //jump to next map square, OR in x-direction, OR in y-direction
} else if (sideDistX < sideDistY) { // jump to next map square, OR in x-direction, OR in y-direction
sideDistX += deltaDistX;
mapX += stepX;
mapX = abs(mapX) % mapHeight;
@ -802,7 +803,7 @@ void Raycast_Render(int slot) {
opposite = false;
}
}
int texside;
int texside = 0;
if (rayDirX > 0 && side == 0) texside = 0;
if (rayDirX < 0 && side == 0) texside = 1;
if (rayDirY > 0 && side == 1) texside = 2;
@ -976,6 +977,10 @@ void Raycast_Render(int slot) {
//End of loop.
}
// Unused variables
(void)prevmapX;
(void)prevmapY;
//FLOOR CASTING
double floorXWall, floorYWall; //x, y position of the floor texel at the bottom of the wall
@ -1002,7 +1007,8 @@ void Raycast_Render(int slot) {
distWall = perpWallDist;
distPlayer = 0.0;
if (drawEnd < 0) drawEnd = h - 1; //becomes < 0 when the integer overflows
if (drawEnd < 0)
drawEnd = h - 1; //becomes < 0 when the integer overflows
//draw the floor from drawEnd to the bottom of the screen
int drawdist = h;
int expandeddraw = h >> 1;
@ -1010,7 +1016,7 @@ void Raycast_Render(int slot) {
//currentDist = h / (2.0 * y - h); //you could make a small lookup table for this instead
currentDist = distTable[y];
if (y > h - 1) {
if (!heightMap) break;
//if (!heightMap) break;
double weight = (currentDist - distPlayer) / (distWall - distPlayer);
double currentFloorX = weight * floorXWall + (1.0 - weight) * posX;
@ -1045,7 +1051,7 @@ void Raycast_Render(int slot) {
if (floorcolor) floorcolor = Mix::MixColorLightLevel(floorcolor, lighting);
}
if (heightMap && floorcolor > 0) {
if (/*heightMap &&*/ floorcolor > 0) {
if (heightMap[cmapX][cmapY] - 1 > 0) {
int raisedfloorstart = y - (int)(texture[heightMap[cmapX][cmapY] - 1][texpos] / currentDist);
if (raisedfloorstart > h - 1) continue;
@ -1093,7 +1099,7 @@ void Raycast_Render(int slot) {
if (ceilingcolor) ceilingcolor = Mix::MixColorLightLevel(ceilingcolor, lighting);
}
if (heightMap && floorcolor > 0 && (currentDist < ZBuffer[x][y] || ZBuffer[x][y] == 0)) {
if (/*heightMap &&*/ floorcolor > 0 && (currentDist < ZBuffer[x][y] || ZBuffer[x][y] == 0)) {
if (heightMap[cmapX][cmapY] - 1 > 0) {
int raisedfloorstart = y - (int)(texture[heightMap[cmapX][cmapY] - 1][texWidth * floorTexY + floorTexX] / currentDist);
if (raisedfloorstart > h - 1) continue;
@ -1210,8 +1216,8 @@ void Raycast_Render(int slot) {
// [ planeY dirY ] [ -planeY planeX ]
//double invDet = 1.0 / (planeX * dirY - dirX * planeY); //required for correct matrix multiplication
double spriteX = sprite[spriteOrder[i]].x - posX;
double spriteY = sprite[spriteOrder[i]].y - posY;
//double spriteX = sprite[spriteOrder[i]].x - posX;
//double spriteY = sprite[spriteOrder[i]].y - posY;
//double transformX = invDet * (dirY * spriteX - dirX * spriteY);
//double transformY = invDet * (-planeY * spriteX + planeX * spriteY); //this is actually the depth inside the screen, that what Z is in 3D

View File

@ -62,8 +62,8 @@ void AGSParallax::AGS_EngineStartup(IAGSEngine *engine) {
if (_engine->version < 13)
_engine->AbortGame("Engine interface is too old, need newer version of AGS.");
SCRIPT_METHOD("pxDrawSprite");
SCRIPT_METHOD("pxDeleteSprite");
SCRIPT_METHOD(pxDrawSprite);
SCRIPT_METHOD(pxDeleteSprite);
_engine->RequestEventHook(AGSE_PREGUIDRAW);
_engine->RequestEventHook(AGSE_PRESCREENDRAW);
@ -107,7 +107,7 @@ void AGSParallax::clear() {
void AGSParallax::SyncGame(Serializer &s) {
int saveVersion = SaveMagic;
s.syncAsInt(saveVersion);
if (saveVersion != SaveMagic) {
if ((uint)saveVersion != SaveMagic) {
_engine->AbortGame("ags_parallax: bad save.");
return;
}

View File

@ -57,30 +57,30 @@ void AGSSnowRain::AGS_EngineStartup(IAGSEngine *engine) {
if (_engine->version < 13)
_engine->AbortGame("Engine interface is too old, need newer version of AGS.");
SCRIPT_METHOD("srSetSnowDriftRange");
SCRIPT_METHOD("srSetSnowDriftSpeed");
SCRIPT_METHOD("srSetSnowFallSpeed");
SCRIPT_METHOD("srChangeSnowAmount");
SCRIPT_METHOD("srSetSnowBaseline");
SCRIPT_METHOD("srSetSnowTransparency");
SCRIPT_METHOD("srSetSnowDefaultView");
SCRIPT_METHOD("srSetSnowWindSpeed");
SCRIPT_METHOD("srSetSnowAmount");
SCRIPT_METHOD("srSetSnowView");
SCRIPT_METHOD(srSetSnowDriftRange);
SCRIPT_METHOD(srSetSnowDriftSpeed);
SCRIPT_METHOD(srSetSnowFallSpeed);
SCRIPT_METHOD(srChangeSnowAmount);
SCRIPT_METHOD(srSetSnowBaseline);
SCRIPT_METHOD(srSetSnowTransparency);
SCRIPT_METHOD(srSetSnowDefaultView);
SCRIPT_METHOD(srSetSnowWindSpeed);
SCRIPT_METHOD(srSetSnowAmount);
SCRIPT_METHOD(srSetSnowView);
SCRIPT_METHOD("srSetRainDriftRange");
SCRIPT_METHOD("srSetRainDriftSpeed");
SCRIPT_METHOD("srSetRainFallSpeed");
SCRIPT_METHOD("srChangeRainAmount");
SCRIPT_METHOD("srSetRainBaseline");
SCRIPT_METHOD("srSetRainTransparency");
SCRIPT_METHOD("srSetRainDefaultView");
SCRIPT_METHOD("srSetRainWindSpeed");
SCRIPT_METHOD("srSetRainAmount");
SCRIPT_METHOD("srSetRainView");
SCRIPT_METHOD(srSetRainDriftRange);
SCRIPT_METHOD(srSetRainDriftSpeed);
SCRIPT_METHOD(srSetRainFallSpeed);
SCRIPT_METHOD(srChangeRainAmount);
SCRIPT_METHOD(srSetRainBaseline);
SCRIPT_METHOD(srSetRainTransparency);
SCRIPT_METHOD(srSetRainDefaultView);
SCRIPT_METHOD(srSetRainWindSpeed);
SCRIPT_METHOD(srSetRainAmount);
SCRIPT_METHOD(srSetRainView);
SCRIPT_METHOD("srSetWindSpeed");
SCRIPT_METHOD("srSetBaseline");
SCRIPT_METHOD(srSetWindSpeed);
SCRIPT_METHOD(srSetBaseline);
_engine->RequestEventHook(AGSE_PREGUIDRAW);
_engine->RequestEventHook(AGSE_PRESCREENDRAW);

View File

@ -137,7 +137,7 @@ void Weather::SyncGame(Serializer &s) {
int saveVersion = SaveMagic;
s.syncAsInt(saveVersion);
if (s.isLoading() && saveVersion != SaveMagic) {
if (s.isLoading() && (uint)saveVersion != SaveMagic) {
_engine->AbortGame("ags_snowrain: bad save.");
return;
}

View File

@ -49,7 +49,7 @@ void SpriteFontRenderer::SetSpriteFont(int fontNum, int sprite, int rows, int co
void SpriteFontRenderer::EnsureTextValidForFont(char *text, int fontNumber) {
SpriteFont *font = getFontFor(fontNumber);
for (int i = 0; i < strlen(text); i++) {
for (int i = 0; i < (int)strlen(text); i++) {
if (text[i] < font->MinChar || text[i] > font->MaxChar) {
if (font->MinChar < 63 || font->MaxChar > 63) text[i] = 63;
else text[i] = font->MinChar;
@ -65,7 +65,7 @@ bool SpriteFontRenderer::SupportsExtendedCharacters(int fontNumber) {
int SpriteFontRenderer::GetTextWidth(const char *text, int fontNumber) {
SpriteFont *font = getFontFor(fontNumber);
int len = strlen(text);
int len = (int)strlen(text);
return font->CharWidth * len;
}
@ -77,7 +77,7 @@ int SpriteFontRenderer::GetTextHeight(const char *text, int fontNumber) {
SpriteFont *SpriteFontRenderer::getFontFor(int fontNum) {
SpriteFont *font;
for (int i = 0; i < _fonts.size(); i ++) {
for (int i = 0; i < (int)_fonts.size(); i ++) {
font = _fonts.at(i);
if (font->FontReplaced == fontNum) return font;
}
@ -91,13 +91,12 @@ SpriteFont *SpriteFontRenderer::getFontFor(int fontNum) {
void SpriteFontRenderer::RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) {
SpriteFont *font = getFontFor(fontNumber);
BITMAP *vScreen = _engine->GetVirtualScreen();
//BITMAP *vScreen = _engine->GetVirtualScreen();
//_engine->SetVirtualScreen(destination);
for (int i = 0; i < strlen(text); i++) {
for (int i = 0; i < (int)strlen(text); i++) {
char c = text[i];
c -= font->MinChar;
int row = c / font->Columns;

View File

@ -31,11 +31,10 @@ namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class SpriteFontRenderer :
public IAGSFontRenderer {
class SpriteFontRenderer : public IAGSFontRenderer {
public:
SpriteFontRenderer(IAGSEngine *engine);
~SpriteFontRenderer(void);
virtual ~SpriteFontRenderer(void);
bool LoadFromDisk(int fontNumber, int fontSize) override {
return true;
}

View File

@ -32,11 +32,10 @@ namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class VariableWidthSpriteFontRenderer :
public IAGSFontRenderer {
class VariableWidthSpriteFontRenderer : public IAGSFontRenderer {
public:
VariableWidthSpriteFontRenderer(IAGSEngine *engine);
~VariableWidthSpriteFontRenderer(void);
virtual ~VariableWidthSpriteFontRenderer();
bool LoadFromDisk(int fontNumber, int fontSize) override {
return true;
}