SAGA2: Fix MSVC warnings

This commit is contained in:
Eugene Sandulenko 2021-06-30 07:31:22 +02:00
parent 3c14a99f7c
commit e9671a73eb
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
10 changed files with 52 additions and 121 deletions

View File

@ -656,7 +656,7 @@ bool ActorProto::acceptInsertionAtAction(
heldInRightHand,
worn
} inUseType;
int wornWhere;
int wornWhere = 0;
assert(isActor(dObj));
assert(isObject(item));
@ -1378,7 +1378,7 @@ Actor *Actor::newActor(
uint8 factionNum,
uint8 initFlags) {
GameObject *limbo = objectAddress(ActorLimbo);
Actor *a;
Actor *a = nullptr;
debugC(2, kDebugActors, "Actor::newActor(protoNum = %d, nameIndex = %d, scriptIndex = %d, appearanceNum = %d, colorSchemeIndex = %d, factionNum = %d, initFlags = %d)",
protoNum, nameIndex, scriptIndex, appearanceNum, colorSchemeIndex, factionNum, initFlags);
@ -1399,12 +1399,16 @@ Actor *Actor::newActor(
// REM: If things start getting really tight, we can
// start recycling common objects...
if (i >= actorCount) return NULL;
if (i >= actorCount)
return nullptr;
} else {
actorLimboCount--;
a = (Actor *)limbo->child();
}
if (!a)
return nullptr;
a->setLocation(Location(0, 0, 0, Nothing));
a->init(
protoNum,

View File

@ -2574,7 +2574,7 @@ APPFUNC(cmdManaInd) {
int manaType = -1;
int numManaRegions = ManaIndicator->getNumManaRegions();
int i;
int curMana, baseMana;
int curMana = 0, baseMana = 0;
PlayerActor *player = &playerList[getCenterActorPlayerID()];
ActorAttributes *stats = player->getEffStats();
ActorAttributes baseStatsRef = player->getBaseStats();
@ -2598,46 +2598,28 @@ APPFUNC(cmdManaInd) {
}
switch (manaType) {
#define RED_MANA "Red Mana:"
#define ORANGE_MANA "Orange Mana:"
#define YELLOW_MANA "Yellow Mana:"
#define GREEN_MANA "Green Mana:"
#define BLUE_MANA "Blue Mana:"
#define VIOLET_MANA "Purple Mana:"
case 0:
sprintf(textBuffer, "%s %d/%d", RED_MANA, curMana, baseMana);
sprintf(textBuffer, "%s %d/%d", "Red Mana:", curMana, baseMana);
break;
case 1:
sprintf(textBuffer, "%s %d/%d", ORANGE_MANA, curMana, baseMana);
sprintf(textBuffer, "%s %d/%d", "Orange Mana:", curMana, baseMana);
break;
case 2:
sprintf(textBuffer, "%s %d/%d", YELLOW_MANA, curMana, baseMana);
sprintf(textBuffer, "%s %d/%d", "Yellow Mana:", curMana, baseMana);
break;
case 3:
sprintf(textBuffer, "%s %d/%d", GREEN_MANA, curMana, baseMana);
sprintf(textBuffer, "%s %d/%d", "Green Mana:", curMana, baseMana);
break;
case 4:
sprintf(textBuffer, "%s %d/%d", BLUE_MANA, curMana, baseMana);
sprintf(textBuffer, "%s %d/%d", "Blue Mana:", curMana, baseMana);
break;
case 5:
sprintf(textBuffer, "%s %d/%d", VIOLET_MANA, curMana, baseMana);
sprintf(textBuffer, "%s %d/%d", "Purple Mana:", curMana, baseMana);
break;
case -1:

View File

@ -2491,12 +2491,12 @@ void MotionTask::walkAction(void) {
TilePoint immediateTarget = getImmediateTarget(),
newPos,
targetVector;
int16 targetDist;
int16 targetDist = 0;
int16 movementDirection,
directionAngle;
int16 moveBlocked,
speed,
speedScale;
speed = walkSpeed,
speedScale = 2;
Actor *a;
ActorAppearance *aa;
StandingTileInfo sti;

View File

@ -1167,7 +1167,7 @@ ObjectID GameObject::makeAlias(const Location &l) {
// return it's address
GameObject *GameObject::newObject(void) { // get a newly created object
GameObject *limbo = objectAddress(ObjectLimbo),
*obj;
*obj = nullptr;
if (limbo->_data.childID == Nothing) {
int16 i;
@ -1185,7 +1185,8 @@ GameObject *GameObject::newObject(void) { // get a newly created object
// REM: If things start getting really tight, we can
// start recycling common objects...
if (i >= objectCount) return nullptr;
if (i >= objectCount)
return nullptr;
} else {
objectLimboCount--;
obj = limbo->child();
@ -3453,19 +3454,19 @@ ObjectID RadialObjectIterator::first(GameObject **obj, int16 *dist) {
// Return the next object within the specified region
ObjectID RadialObjectIterator::next(GameObject **obj, int16 *dist) {
GameObject *currentObject;
GameObject *currentObject = nullptr;
ObjectID currentObjectID;
int16 currentDist;
int16 currentDist = 0;
do {
currentObjectID = SectorRegionObjectIterator::next(&currentObject);
} while (currentObjectID != Nothing
&& (currentDist =
computeDist(currentObject->getLocation()))
> radius);
&& (currentDist = computeDist(currentObject->getLocation())) > radius);
if (dist != nullptr) *dist = currentDist;
if (obj != nullptr) *obj = currentObject;
if (dist != nullptr)
*dist = currentDist;
if (obj != nullptr)
*obj = currentObject;
return currentObjectID;
}

View File

@ -182,9 +182,10 @@ void gPanel::invalidate(Rect16 *) {
void gPanel::drawTitle(enum text_positions placement) {
gPort &port = window.windowPort;
Rect16 r = extent;
const gPixelMap *img;
const gPixelMap *img = nullptr;
if (title == NULL) return;
if (title == NULL)
return;
if (imageLabel) {
img = (const gPixelMap *)title;

View File

@ -124,6 +124,8 @@ static StaticTilePoint tDirTable3[8] = {
struct PathTileInfo {
TileInfo *surfaceTile;
int16 surfaceHeight;
PathTileInfo() : surfaceTile(nullptr), surfaceHeight(0) {}
};
typedef PathTileInfo PathTilePosInfo[maxPlatforms];
@ -1582,7 +1584,7 @@ big_break:
void PathRequest::finish(void) {
Direction prevDir;
int16 prevHeight;
int16 prevHeight = 0;
StaticTilePoint *resultSteps = path,
coords;
int16 stepCount = 0;

View File

@ -90,7 +90,7 @@ void deleteSensor(Sensor *p) {
void *constructSensor(int16 ctr, void *buf) {
int16 type;
Sensor *sensor;
Sensor *sensor = nullptr;
SensorList *sl;
// Get the sensor type
@ -123,12 +123,12 @@ void *constructSensor(int16 ctr, void *buf) {
break;
}
assert(sensor != NULL);
assert(sensor != nullptr);
// Get the sensor list
sl = fetchSensorList(sensor->getObject());
assert(sl != NULL);
assert(sl != nullptr);
// Append this Sensor to the sensor list
sl->_list.push_back(sensor);

View File

@ -622,7 +622,7 @@ int16 TextWrap(
int16 i, // loop counter
line_start, // start of current line
last_space, // last space encountered
last_space_pixels, // pixel pos of last space
last_space_pixels = 0, // pixel pos of last space
pixel_len, // pixel length of line
line_count = 0; // number of lines
@ -688,7 +688,7 @@ int16 buttonWrap(
int16 i, // loop counter
line_start, // start of current line
last_space, // last space encountered
last_space_pixels, // pixel pos of last space
last_space_pixels = 0, // pixel pos of last space
charPixels, // pixel length of character
linePixels, // pixels in current line
buttonPixels, // pixels in current button

View File

@ -98,7 +98,7 @@ void SpellStuff::setupFromResource(ResourceSpellItem *rsi) {
// add spell internal effect
void SpellStuff::addEffect(ResourceSpellEffect *rse) {
ProtoEffect *pe;
ProtoEffect *pe = nullptr;
assert(rse && rse->spell == master);
switch (rse->effectGroup) {
case effectNone :
@ -197,11 +197,10 @@ void SpellStuff::addEffect(ResourceSpellEffect *rse) {
break;
}
}
if (pe == NULL)
if (pe == nullptr)
error("failed to alloc protoEffect");
if (effects == NULL)
if (effects == nullptr)
effects = pe;
else {
ProtoEffect *tail;

View File

@ -2646,7 +2646,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
pos.x += kMetaTileWidth
) {
TilePoint clipCoords;
int16 mtile;
int16 mtile = 0;
MetaTilePtr metaPtr;
clipCoords.u = (uint16)coords.u % curMap->mapSize;
@ -3283,7 +3283,7 @@ void maskMetaRow(
pos.x += kMetaTileWidth
) {
TilePoint clipCoords;
int16 mtile;
int16 mtile = 0;
MetaTilePtr metaPtr;
clipCoords.u = (uint16)coords.u % curMap->mapSize;
@ -3311,9 +3311,11 @@ void maskMetaRow(
mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
break;
}
} else mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
} else
mtile = mapData[clipCoords.u * curMap->mapSize + clipCoords.v] & ~metaTileVisited;
if (mtile >= curMap->metaCount) mtile = curMap->metaCount - 1;
if (mtile >= curMap->metaCount)
mtile = curMap->metaCount - 1;
metaPtr = metaArray[mtile];
put = drawList;
@ -4071,7 +4073,7 @@ TilePoint pickTile(Point32 pos,
testCoords,
deltaP;
MetaTile *mt;
ActiveItemPtr bestTileTAI;
ActiveItemPtr bestTileTAI = nullptr;
TileInfo *ti,
*bestTile = nullptr;
uint8 *imageData;
@ -4190,36 +4192,21 @@ TilePoint pickTile(Point32 pos,
if (sti.surfaceTAG == nullptr) {
if (surface != surfaceHoriz
&& pointOnHiddenSurface(
tCoords + origin,
pCoords,
surface)) {
surface = surface == surfaceVertU
? surfaceVertV
: surfaceVertU;
&& pointOnHiddenSurface(tCoords + origin, pCoords, surface)) {
surface = surface == surfaceVertU ? surfaceVertV : surfaceVertU;
}
// If pick point is on vertical surface
// not facing protaganist, reject tile
if (surface == surfaceVertU
&& pCoords.v < protagPos.v)
if (surface == surfaceVertU && pCoords.v < protagPos.v)
continue;
if (surface == surfaceVertV
&& pCoords.u < protagPos.u)
if (surface == surfaceVertV && pCoords.u < protagPos.u)
continue;
/* // Make sure surface is exposed, else reject it
if ( surface != surfaceHoriz
&& !validSurface( tCoords + origin, pCoords ) )
continue;*/
}
pickCoords = pCoords;
floorCoords = fCoords;
bestTile = ti;
#ifdef DAVIDR
bestTP = tCoords + origin;
bestTP.z = sti.surfaceHeight;
#endif
bestTileTAI = sti.surfaceTAG;
}
}
@ -4263,51 +4250,6 @@ TilePoint pickTile(Point32 pos,
return pickCoords;
}
#ifdef DAVIDR
if (showTile) {
if (bestTile) {
bestTP.u <<= kTileUVShift;
bestTP.v <<= kTileUVShift;
showAbstractTile(bestTP, bestTile);
TilePoint pt1, pt2;
pt1 = pt2 = pickCoords;
pt1.u += 3;
pt2.u -= 3;
TPLine(pt1, pt2);
pt1 = pt2 = pickCoords;
pt1.v += 3;
pt2.v -= 3;
TPLine(pt1, pt2);
pt1 = pt2 = floorCoords;
pt1.u += 2;
pt1.v += 2;
pt2.u -= 2;
pt2.v -= 2;
TPLine(pt1, pt2);
pt1 = pt2 = floorCoords;
pt1.u += 2;
pt1.v -= 2;
pt2.u -= 2;
pt2.v += 2;
TPLine(pt1, pt2);
pt1 = pt2 = pickCoords;
pt1.z = bestTP.z;
TPLine(pt1, pt2);
pt2.z = bestTP.z;
pt2.u = pt1.u & 0xFFF0;
TPLine(pt1, pt2);
pt2.u = pt1.u;
pt2.v = pt1.v & 0xFFF0;
TPLine(pt1, pt2);
WriteStatusF(8, "%4.4x:%4.4x:%4.4x", pickCoords.u, pickCoords.v, pickCoords.z);
}
}
#endif
if (floorResult) *floorResult = floorCoords;
if (pickTAI) *pickTAI = bestTileTAI;
return pickCoords;