[Scummvm-git-logs] scummvm master -> 2f677c25297b15c6bb236cde3a0eb5a3284072ff

digitall noreply at scummvm.org
Tue May 2 20:34:17 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2f677c2529 WATCHMAKER: Fix Likely Incorrect Code Causing GCC Compiler Warnings


Commit: 2f677c25297b15c6bb236cde3a0eb5a3284072ff
    https://github.com/scummvm/scummvm/commit/2f677c25297b15c6bb236cde3a0eb5a3284072ff
Author: D G Turner (digitall at scummvm.org)
Date: 2023-05-02T21:31:56+01:00

Commit Message:
WATCHMAKER: Fix Likely Incorrect Code Causing GCC Compiler Warnings

This will need to be checked for correct operation, but the original
code looks like an oversight.

Changed paths:
    engines/watchmaker/3d/render/opengl_3d.cpp
    engines/watchmaker/3d/t3d_body.cpp
    engines/watchmaker/classes/do_dialog.cpp
    engines/watchmaker/ll/ll_mesh.cpp
    engines/watchmaker/message.h
    engines/watchmaker/renderer.cpp
    engines/watchmaker/saveload.cpp
    engines/watchmaker/t2d/expr.cpp
    engines/watchmaker/t2d/t2d.cpp
    engines/watchmaker/walk/act.cpp
    engines/watchmaker/walk/walk.cpp
    engines/watchmaker/walk/walkutil.cpp


diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 2f9f38c4fb3..3cbcb73c9e4 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -576,8 +576,9 @@ Common::SharedPtr<TextureData> createTextureFromSurface(Graphics::Surface &surfa
 }
 
 //*********************************************************************************************
-gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int LoaderFlags) {
-	bool        bAlpha = FALSE, bUseAlternate = FALSE;
+gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int _LoaderFlags) {
+	//bool        bAlpha = FALSE
+	bool bUseAlternate = FALSE;
 	gTexture    *texture = nullptr;
 	int32      pos = 0;
 	char        AlternateName[500] {};
@@ -761,7 +762,7 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
 	texture->RealDimX = dwWidth;
 	texture->RealDimY = dwHeight;
 
-	if (LoaderFlags & rSURFACEHALF) {
+	if (_LoaderFlags & rSURFACEHALF) {
 		warning("Half-res loading not implemented");
 #if 0
 		LPDIRECTDRAWSURFACE7    surf;
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index 26af7c987b8..2d131d7919c 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -122,7 +122,7 @@ void t3dBODY::allocateNormals() {
 }
 
 void t3dBODY::initNormals(Common::SeekableReadStream &stream) {
-	int nListSize = this->NumNormals + this->NumVerticesNormals;
+	uint nListSize = this->NumNormals + this->NumVerticesNormals;
 	assert(this->NList.size() == nListSize);
 	for (uint16 normal = 0; normal < this->NList.size(); normal++) {                // Legge normali globali
 		*this->NList[normal] = t3dNORMAL(stream);
@@ -179,11 +179,11 @@ void t3dBODY::populatePortalLists() {
 		t3dBODY *rez = nullptr;
 		if (((rez = _vm->_roomManager->checkIfAlreadyLoaded(Name)) == nullptr) && (!(LoaderFlags & T3D_NORECURSION))) { // Controlla se lo ha gia' caricato
 			if (Name.equalsIgnoreCase("rxt.t3d"))
-				_vm->_roomManager->addToLoadList(&Mesh[mesh], Name, (uint16)(LoaderFlags | T3D_NORECURSION & ~T3D_RECURSIONLEVEL1));    // aggiunge e leva la ricorsione
+				_vm->_roomManager->addToLoadList(&Mesh[mesh], Name, (uint16)((LoaderFlags | T3D_NORECURSION) & ~T3D_RECURSIONLEVEL1));    // aggiunge e leva la ricorsione
 //				Mesh[mesh].Flags|=T3D_MESH_NOPORTALCHECK;
 			else {
 				if (LoaderFlags & T3D_RECURSIONLEVEL1)
-					_vm->_roomManager->addToLoadList(&Mesh[mesh], Name, (uint16)(LoaderFlags | T3D_NORECURSION & ~T3D_RECURSIONLEVEL1));    // aggiunge e leva la ricorsione
+					_vm->_roomManager->addToLoadList(&Mesh[mesh], Name, (uint16)((LoaderFlags | T3D_NORECURSION) & ~T3D_RECURSIONLEVEL1));    // aggiunge e leva la ricorsione
 				else
 					_vm->_roomManager->addToLoadList(&Mesh[mesh], Name, (uint16)(LoaderFlags));                         // altrimenti lo agggiunge alla lista
 			}
@@ -486,7 +486,6 @@ t3dBODY *t3dBODY::loadFromStream(WGame &game, const Common::String &pname, Commo
 	//char /*t3dU8*/   Name[255];
 
 	uint16  light;
-	t3dPLIGHT   *PLight;
 	t3dF32  minx, miny, minz, maxx, maxy, maxz;
 
 	WorkDirs &workdirs = game.workDirs;
diff --git a/engines/watchmaker/classes/do_dialog.cpp b/engines/watchmaker/classes/do_dialog.cpp
index 985b926fa55..9fcea2ae89d 100644
--- a/engines/watchmaker/classes/do_dialog.cpp
+++ b/engines/watchmaker/classes/do_dialog.cpp
@@ -19,9 +19,6 @@
  *
  */
 
-#define FORBIDDEN_SYMBOL_EXCEPTION_sprintf
-#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
-
 #include "watchmaker/classes/do_dialog.h"
 #include "watchmaker/globvar.h"
 #include "watchmaker/define.h"
@@ -80,7 +77,7 @@ void doDialog(WGame &game) {
 		//faccio apparire la scritta di descrizione della stanza di Darrell
 		if ((TheMessage->wparam1 == dR000) && bShowRoomDescriptions) {
 			t3dCurTime = 240;
-			strcpy(RoomInfo.name, "");
+			RoomInfo.name[0] = '\0';
 			UpdateRoomInfo(game);
 		}
 
@@ -187,7 +184,7 @@ void doDialog(WGame &game) {
 				Character[ic->param1]->Flags &= ~T3D_CHARACTER_HIDE;
 				break;
 			case IC_CHANGE_ROOM:
-				sprintf(str, "%s.t3d", init.Room[ic->param1].name);
+				snprintf(str, T3D_NAMELEN, "%s.t3d", init.Room[ic->param1].name);
 				ChangeRoom(game, str, 0, aNULL);
 				break;
 			case IC_EXPRESSION:
diff --git a/engines/watchmaker/ll/ll_mesh.cpp b/engines/watchmaker/ll/ll_mesh.cpp
index b48fd401eef..464a887a8d7 100644
--- a/engines/watchmaker/ll/ll_mesh.cpp
+++ b/engines/watchmaker/ll/ll_mesh.cpp
@@ -93,7 +93,8 @@ void t3dLightRoom(Init &init, t3dBODY *b, t3dV3F *p, t3dF32 NearRange, t3dF32 Fa
 			if (!(SavedBodyLight[j] = (uint32 *)t3dMalloc(sizeof(uint32) * m->NumVerts * 4)))
 				continue;
 
-			gv = m->VBptr = m->VBptr = m->VertexBuffer;
+			gv = m->VBptr;
+			m->VBptr = m->VertexBuffer;
 			for (i = 0; i < m->NumVerts; i++, gv++) {
 				SavedBodyLight[j][i * 4 + 0] = RGBA_GETRED(gv->diffuse);
 				SavedBodyLight[j][i * 4 + 1] = RGBA_GETGREEN(gv->diffuse);
@@ -123,7 +124,8 @@ void t3dLightRoom(Init &init, t3dBODY *b, t3dV3F *p, t3dF32 NearRange, t3dF32 Fa
 			        m->name.equalsIgnoreCase("p50-sentierini04") || m->name.equalsIgnoreCase("p50-sentierini05") || m->name.equalsIgnoreCase("p50-sentierini06")) {
 				tmp.x = m->Pos.x - p->x;
 				tmp.z = m->Pos.z - p->z;
-				gv = m->VBptr = m->VBptr = m->VertexBuffer;
+				gv = m->VBptr;
+				m->VBptr = m->VertexBuffer;
 				if ((dist = tmp.x * tmp.x + tmp.z * tmp.z) > (FarRange + m->Radius * m->Radius * 1.3f)) {
 					if ((bGolfMode == 0) || (bGolfMode == 1))
 						if (dist > (FarRange + m->Radius * m->Radius) * 2.5f) m->Flags |= T3D_MESH_HIDDEN;
diff --git a/engines/watchmaker/message.h b/engines/watchmaker/message.h
index cb9a91c3506..fc1353aa931 100644
--- a/engines/watchmaker/message.h
+++ b/engines/watchmaker/message.h
@@ -57,7 +57,7 @@ namespace Watchmaker {
 #define ME_MRIGHTPRESSED        7
 
 // SYSTEM
-enum class EventClass {
+enum EventClass {
 	MC_IDLE = 0,
 	MC_MOUSE = 1,
 	MC_SYSTEM = 2,
diff --git a/engines/watchmaker/renderer.cpp b/engines/watchmaker/renderer.cpp
index 4c411dc2acf..bde53450c06 100644
--- a/engines/watchmaker/renderer.cpp
+++ b/engines/watchmaker/renderer.cpp
@@ -96,7 +96,7 @@ WindowInfo Renderer::getScreenInfos() const {
 }
 
 bool Renderer::createScreenBuffer() {
-	auto windowSize = getScreenInfos();
+	//auto windowSize = getScreenInfos();
 	_viewport.left = _viewport.top = 0;
 	_viewport.right = 800;
 	_viewport.bottom = 600;
diff --git a/engines/watchmaker/saveload.cpp b/engines/watchmaker/saveload.cpp
index 5ac9d41a80b..e87d2c33c7f 100644
--- a/engines/watchmaker/saveload.cpp
+++ b/engines/watchmaker/saveload.cpp
@@ -117,9 +117,9 @@ void loadAll(WorkDirs &workDirs, Init &init) {
  * --------------------------------------------------*/
 // NOTA: se slot==255 forza il save (salva senza controllare le condizioni)
 bool DataSave(const char *SaveName, uint8 slot) {
-	char str[T3D_NAMELEN];
 	warning("STUBBED: DataSave");
 #if 0
+	char str[T3D_NAMELEN];
 	FILE *fhs;
 	int32 i, j;
 	uint16 WmVer;
diff --git a/engines/watchmaker/t2d/expr.cpp b/engines/watchmaker/t2d/expr.cpp
index b017f5cf966..995b6eba04a 100644
--- a/engines/watchmaker/t2d/expr.cpp
+++ b/engines/watchmaker/t2d/expr.cpp
@@ -751,22 +751,20 @@ int VisemaRecon(int32 n) {
 
 //Restituisce il visema corrispondente a un determinato tempo
 int32 VisemaTimeRecon(int32 Time) {
-	int i;
-	static bool Partito = FALSE;
-
 	if (Time < 0) return 0;
 	if (!VisemaInitialized) return 0;
 
+#ifdef PROVAMODE
+	static bool Partito = FALSE;
 	if (Time == 0) Partito = FALSE;
 
-#ifdef PROVAMODE
 	if ((!Partito) && (Time > 0)) {
 		Partito = TRUE;
 		StartSound(wPROVA);
 	}
 #endif
 
-	for (i = 0; i < NumVis; i++) {
+	for (int i = 0; i < NumVis; i++) {
 		if ((Time >= VisemaBufTimeLeng(VisemaBuf, i)) && (Time < VisemaBufTimeLeng(VisemaBuf, i + 1)))
 			return VisemaBuf[i].Visema;
 	}
diff --git a/engines/watchmaker/t2d/t2d.cpp b/engines/watchmaker/t2d/t2d.cpp
index eea8b2465a1..246a4444f0f 100644
--- a/engines/watchmaker/t2d/t2d.cpp
+++ b/engines/watchmaker/t2d/t2d.cpp
@@ -281,11 +281,10 @@ void RefreshUpdate(Init &init) {
 }
 
 void ScrollLog(Init &init, int Add) {
-	int LastPos, Sign, i;
+	int Sign, i;
 
 	if (Add == 0) return;
 
-	LastPos = CurrentLogPos;
 	Sign = abs(Add) / Add;
 
 	for (i = 0; i < abs(Add); i++) {
@@ -314,12 +313,12 @@ void ScrollLog(Init &init, int Add) {
 }
 
 
-void WriteLog(Init &init, int i, int *CurDate, int *CurLine, int *RealLine, int PDAScrollLine, int IndentX) {
+void WriteLog(Init &init, int i, int *CurDate, int *CurLine, int *RealLine, int _PDAScrollLine, int IndentX) {
 	t2dWINDOW *w = &t2dWin[T2D_WIN_PDA_LOG];
 	int j;
 
 	//Data
-	if ((!(init.PDALog[i].flags & PDA_MENU)) && ((i != CurrentLogPos) || (PDAScrollLine == 0))) {
+	if ((!(init.PDALog[i].flags & PDA_MENU)) && ((i != CurrentLogPos) || (_PDAScrollLine == 0))) {
 		strcpy(w->text[T2D_TEXT_PDA_LOG_DATA_START + (*CurDate)].text, init.PDALog[i].info.c_str());
 		w->bm[T2D_BM_PDA_LOG_DATA_START + (*CurDate)].py = T2D_PDA_LOG_YI + (*RealLine) * 15;
 		w->bm[T2D_BM_PDA_LOG_DATA_START + (*CurDate)].tnum &= ~T2D_BM_OFF;
@@ -328,7 +327,7 @@ void WriteLog(Init &init, int i, int *CurDate, int *CurLine, int *RealLine, int
 
 	//Testo
 	for (j = 0; j <= init.PDALog[i].lines; j++) {
-		if ((i == CurrentLogPos) && (j < PDAScrollLine)) continue;
+		if ((i == CurrentLogPos) && (j < _PDAScrollLine)) continue;
 
 		if (j == init.PDALog[i].lines) {
 			(*RealLine)++;
@@ -363,7 +362,7 @@ void WriteLog(Init &init, int i, int *CurDate, int *CurLine, int *RealLine, int
 #define PDA_LAST_LINE   2
 
 
-int RefreshLogMenu(Init &init, int *Log, int *NumLog, int PDAScrollLine) {
+int RefreshLogMenu(Init &init, int *Log, int *NumLog, int _PDAScrollLine) {
 	int i;
 	int CurDate = 0, CurLine = 0, RealLine = 0;
 	t2dWINDOW *w = &t2dWin[T2D_WIN_PDA_LOG];
@@ -373,7 +372,7 @@ int RefreshLogMenu(Init &init, int *Log, int *NumLog, int PDAScrollLine) {
 
 		CurrentPDALogs[(*NumLog)++] = &init.PDALog[PDALogSorted[*Log].PDALogInd];
 
-		WriteLog(init, PDALogSorted[*Log].PDALogInd, &CurDate, &CurLine, &RealLine, PDAScrollLine, PDALogSorted[*Log].IndentX);
+		WriteLog(init, PDALogSorted[*Log].PDALogInd, &CurDate, &CurLine, &RealLine, _PDAScrollLine, PDALogSorted[*Log].IndentX);
 
 		if (!(init.PDALog[PDALogSorted[*Log].PDALogInd].flags & PDA_MENU)) init.PDALog[PDALogSorted[*Log].PDALogInd].flags &= ~PDA_UPDATE;
 
diff --git a/engines/watchmaker/walk/act.cpp b/engines/watchmaker/walk/act.cpp
index cdf6386f9c7..5bbabef4236 100644
--- a/engines/watchmaker/walk/act.cpp
+++ b/engines/watchmaker/walk/act.cpp
@@ -207,7 +207,6 @@ void CharStop(int32 oc) {
  * --------------------------------------------------*/
 void CharSetPosition(int32 oc, uint8 pos, const char *room) {
 	t3dBODY *OldCurRoom = t3dCurRoom;
-	int32 i;
 	t3dCHARACTER *Char = Character[oc];
 	t3dV3F tmp;
 
diff --git a/engines/watchmaker/walk/walk.cpp b/engines/watchmaker/walk/walk.cpp
index 1d8b48d8c2e..22e16ecbced 100644
--- a/engines/watchmaker/walk/walk.cpp
+++ b/engines/watchmaker/walk/walk.cpp
@@ -644,7 +644,7 @@ void FindPath(int32 oc, t3dCAMERA *Camera) {
 
 		if (((inters   & 1) && (w->CurPanel < 0) && (w->OldPanel < 0)) ||
 		        ((w->CurPanel < 0) && (w->NumPathNodes >= 1) && (PointInside(oc, w->PathNode[w->NumPathNodes - 1].curp, (double)w->CurX, (double)w->CurZ))) ||
-		        ((inters - 1 & 1) && (w->CurPanel < 0) && (w->NumPathNodes >= 2) &&
+		        (((inters - 1) & 1) && (w->CurPanel < 0) && (w->NumPathNodes >= 2) &&
 		         (!(FindAttachedPanel(oc, w->PathNode[w->NumPathNodes - 2].curp, w->PathNode[w->NumPathNodes - 1].curp)) ||
 		          (PointInside(oc, w->PathNode[w->NumPathNodes - 1].curp, (double)w->CurX, (double)w->CurZ))))) {
 			w->CurPanel = w->PathNode[w->NumPathNodes - 1].curp;
diff --git a/engines/watchmaker/walk/walkutil.cpp b/engines/watchmaker/walk/walkutil.cpp
index c45e6adae55..4161e2784b5 100644
--- a/engines/watchmaker/walk/walkutil.cpp
+++ b/engines/watchmaker/walk/walkutil.cpp
@@ -116,6 +116,7 @@ int PointInside(int32 oc, int32 pan, double x, double z) {
 float DistF(float x1, float y1, float x2, float y2) {
 	float d1 = (float)fabs(x1 - x2);
 	float d2 = (float)fabs(y1 - y2);
+#if 0
 	float minimum;
 
 	if (d1 >= d2)
@@ -123,7 +124,8 @@ float DistF(float x1, float y1, float x2, float y2) {
 	else
 		minimum = d1;
 
-//    return d1+d2 - ( minimum / 2.0 );
+	return d1+d2 - ( minimum / 2.0 );
+#endif
 	return (float)(sqrt(d1 * d1 + d2 * d2));
 }
 /*-----------------07/10/96 11.21-------------------




More information about the Scummvm-git-logs mailing list