[Scummvm-cvs-logs] SF.net SVN: scummvm: [29478] scummvm/trunk/engines/cruise

yazoo at users.sourceforge.net yazoo at users.sourceforge.net
Sun Nov 11 20:33:25 CET 2007


Revision: 29478
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29478&view=rev
Author:   yazoo
Date:     2007-11-11 11:33:25 -0800 (Sun, 11 Nov 2007)

Log Message:
-----------
Menu display fix
Linked objects implementation (barman)
The gameplay is now kind of working and it is possible to play at least the first part of the game

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/cell.cpp
    scummvm/trunk/engines/cruise/cell.h
    scummvm/trunk/engines/cruise/cruise_main.cpp
    scummvm/trunk/engines/cruise/dataLoader.cpp
    scummvm/trunk/engines/cruise/function.cpp
    scummvm/trunk/engines/cruise/mainDraw.cpp
    scummvm/trunk/engines/cruise/menu.cpp
    scummvm/trunk/engines/cruise/object.cpp
    scummvm/trunk/engines/cruise/perso.h

Modified: scummvm/trunk/engines/cruise/cell.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cell.cpp	2007-11-11 18:12:55 UTC (rev 29477)
+++ scummvm/trunk/engines/cruise/cell.cpp	2007-11-11 19:33:25 UTC (rev 29478)
@@ -279,6 +279,21 @@
 	}
 }
 
+void linkCell(cellStruct *pHead, int ovl, int obj, int type, int ovl2, int obj2) {
+	while (pHead) {
+		if ((pHead->overlay == ovl) || (ovl == -1)) {
+			if ((pHead->idx == obj) || (obj == -1)) {
+				if ((pHead->type == type) || (type == -1)) {
+					pHead->followObjectIdx = obj2;
+					pHead->followObjectOverlayIdx = ovl2;
+				}
+			}
+		}
+
+		pHead = pHead->next;
+	}
+}
+
 void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, int backgroundPlane, int oldFreeze, int newFreeze ) {
 	while (pObject) {
 		if ((pObject->overlay == overlayIdx) || (overlayIdx == -1)) {

Modified: scummvm/trunk/engines/cruise/cell.h
===================================================================
--- scummvm/trunk/engines/cruise/cell.h	2007-11-11 18:12:55 UTC (rev 29477)
+++ scummvm/trunk/engines/cruise/cell.h	2007-11-11 19:33:25 UTC (rev 29478)
@@ -71,7 +71,9 @@
 void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, int backgroundPlane );
 void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, int backgroundPlane, int oldFreeze, int newFreeze );
 void sortCells(int16 param1, int16 param2, cellStruct *objPtr);
+void linkCell(cellStruct *pHead, int ovl, int obj, int type, int ovl2, int obj2);
 
+
 } // End of namespace Cruise
 
 #endif

Modified: scummvm/trunk/engines/cruise/cruise_main.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.cpp	2007-11-11 18:12:55 UTC (rev 29477)
+++ scummvm/trunk/engines/cruise/cruise_main.cpp	2007-11-11 19:33:25 UTC (rev 29478)
@@ -644,11 +644,12 @@
 				int j2 = 0;
 
 				if ((objOvl != linkedObjOvl) || (objIdx != linkedObjIdx)) {
-					getMultipleObjectParam(linkedObjOvl, linkedObjIdx, &params);
+					objectParamsQuery params2;
+					getMultipleObjectParam(linkedObjOvl, linkedObjIdx, &params2);
 
-					x2 = params.X;
-					y2 = params.Y;
-					j2 = params.fileIdx;
+					x2 = params2.X;
+					y2 = params2.Y;
+					j2 = params2.fileIdx;
 				}
 
 				if (params.var5 >= 0 && params.fileIdx >= 0) {
@@ -696,8 +697,8 @@
 							}
 
 							if (dataPtr && findPoly((char*)dataPtr, x, y, zoom, mouseX, mouseY)) {
-								*outObjOvl = objOvl;
-								*outObjIdx = objIdx;
+								*outObjOvl = linkedObjOvl;
+								*outObjIdx = linkedObjIdx;
 
 								return (currentObject->type);
 							}
@@ -715,8 +716,8 @@
 
 							if ((offsetX >= 0) && (offsetX < nWidth) && (offsetY >= 0) && (offsetY <= nHeight) && filesDatabase[j].subData.ptr) {
 								if(testMask(offsetX, offsetY, filesDatabase[j].subData.ptrMask, filesDatabase[j].width/8)) {
-									*outObjOvl = objOvl;
-									*outObjIdx = objIdx;
+									*outObjOvl = linkedObjOvl;
+									*outObjIdx = linkedObjIdx;
 									return currentObject->type;
 								}
 							}
@@ -728,8 +729,8 @@
 						int height = params.scale;
 
 						if ((mouseX >= x) && (mouseX <= x+width) && (mouseY >= y) && (mouseY <= y+height)) {
-							*outObjOvl = objOvl;
-							*outObjIdx = objIdx;
+							*outObjOvl = linkedObjOvl;
+							*outObjIdx = linkedObjIdx;
 
 							return (currentObject->type);
 						}
@@ -990,6 +991,8 @@
 					thisOvl = j;
 				}
 
+				const char* pName = getObjectName(ptrHead->obj1Number, overlayTable[thisOvl].ovlData->arrayNameObj);
+
 				objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number);
 
 				if ((thisOvl == objOvl) && (objIdx == ptrHead->obj1Number) && pObject && (pObject->_class != THEME)) {
@@ -1116,9 +1119,41 @@
 				getMultipleObjectParam(obj2Ovl, pHeader->obj2Number, &params);
 			}
 
-			if ((pHeader->obj2OldState != -1) || (params.scale == pHeader->obj2OldState)) {
-				if (pHeader->type == 30) {
-					ASSERT(0);
+			if ((pHeader->obj2OldState == -1) || (params.scale == pHeader->obj2OldState)) {
+				if (pHeader->type == 30) { // REL
+				attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL);
+
+				if ((narratorOvl > 0) && (pHeader->trackX != -1) && (pHeader->trackY != -1)) {
+					actorStruct* pTrack = findActor(&actorHead, narratorOvl, narratorIdx, 0);
+
+					if (pTrack) {
+						animationStart = false;
+
+						if (pHeader->trackDirection == 9999) {
+							objectParamsQuery naratorParams;
+							getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams);
+							pTrack->x_dest = naratorParams.X;
+							pTrack->y_dest = naratorParams.Y;
+							pTrack->endDirection = direction(naratorParams.X, naratorParams.Y, pTrack->x_dest, pTrack->y_dest, 0, 0);
+						} else if ((pHeader->trackX == 9999) && (pHeader->trackY == 9999)) {
+							objectParamsQuery naratorParams;
+							getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams);
+							pTrack->x_dest = naratorParams.X;
+							pTrack->y_dest = naratorParams.Y;
+							pTrack->endDirection = pHeader->trackDirection;
+						} else {
+							pTrack->x_dest = pHeader->trackX;
+							pTrack->y_dest = pHeader->trackY;
+							pTrack->endDirection = pHeader->trackDirection;
+						}
+
+						pTrack->flag = 1;
+
+						autoTrack = true;
+						userEnabled = 0;
+						changeScriptParamInList(ovlIdx, pHeader->id, &relHead, 0, 9998);
+					}
+				}
 				} else if (pHeader->type == 50) {
 					ASSERT(0);
 				}
@@ -1158,7 +1193,11 @@
 						animationStart = false;
 
 						if (pHeader->trackDirection == 9999) {
-							ASSERT(0);
+							objectParamsQuery naratorParams;
+							getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams);
+							pTrack->x_dest = naratorParams.X;
+							pTrack->y_dest = naratorParams.Y;
+							pTrack->endDirection = direction(naratorParams.X, naratorParams.Y, pTrack->x_dest, pTrack->y_dest, 0, 0);
 						} else if ((pHeader->trackX == 9999) && (pHeader->trackY == 9999)) {
 							objectParamsQuery naratorParams;
 							getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams);
@@ -1222,7 +1261,11 @@
 						animationStart = false;
 
 						if (pHeader->trackDirection == 9999) {
-							ASSERT(0);
+							objectParamsQuery naratorParams;
+							getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams);
+							pTrack->x_dest = naratorParams.X;
+							pTrack->y_dest = naratorParams.Y;
+							pTrack->endDirection = direction(naratorParams.X, naratorParams.Y, pTrack->x_dest, pTrack->y_dest, 0, 0);
 						} else if ((pHeader->trackX == 9999) && (pHeader->trackY == 9999)) {
 							objectParamsQuery naratorParams;
 							getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams);
@@ -1389,14 +1432,21 @@
 				}
 
 				if (linkedMsgList) {
-					ASSERT(0);
 //					freeMsgList(linkedMsgList);
 				}
 				linkedMsgList = NULL;
 				linkedRelation = NULL;
 				changeCursor(CURSOR_NORMAL);
 			} else { // call sub relation when clicking in inventory
-				ASSERT(0);
+				if(menuTable[0] && menuTable[1]) {
+					menuElementSubStruct * p0 = getSelectedEntryInMenu(menuTable[1]);
+
+					if(p0)
+						callSubRelation(linkedRelation, p0->ovlIdx, p0->header);
+
+					closeAllMenu();
+					changeCursor(CURSOR_NORMAL);
+				}
 			}
 			selectDown = 0;
 			menuDown = 0;

Modified: scummvm/trunk/engines/cruise/dataLoader.cpp
===================================================================
--- scummvm/trunk/engines/cruise/dataLoader.cpp	2007-11-11 18:12:55 UTC (rev 29477)
+++ scummvm/trunk/engines/cruise/dataLoader.cpp	2007-11-11 19:33:25 UTC (rev 29478)
@@ -505,8 +505,8 @@
 			{
 				if (sec == 0) {
 					// TODO sec type 5 needs special conversion. cut out 2 bytes at every width/5 position.
-					ASSERT(0);
-					return -1;
+//					ASSERT(0);
+//					return -1;
 				}
 				
 				filesDatabase[fileIndex].subData.resourceType = 4;

Modified: scummvm/trunk/engines/cruise/function.cpp
===================================================================
--- scummvm/trunk/engines/cruise/function.cpp	2007-11-11 18:12:55 UTC (rev 29477)
+++ scummvm/trunk/engines/cruise/function.cpp	2007-11-11 19:33:25 UTC (rev 29478)
@@ -1533,6 +1533,23 @@
 	return 0;
 }
 
+int16 Op_LinkObjects(void) {
+	int type = popVar();
+	int obj2 = popVar();
+	int ovl2 = popVar();
+	int obj = popVar();
+	int ovl = popVar();
+
+	if(!ovl)
+		ovl = currentScriptPtr->overlayNumber;
+	if(!ovl2)
+		ovl2 = currentScriptPtr->overlayNumber;
+
+	linkCell(&cellHead, ovl, obj, type, ovl2, obj2);
+
+	return 0;
+}
+
 void setupOpcodeTable(void) {
 	int i;
 
@@ -1600,6 +1617,7 @@
 	opcodeTablePtr[0x41] = Op_isFileLoaded2;
 	opcodeTablePtr[0x43] = Op_songExist;
 	opcodeTablePtr[0x45] = Op_45;
+	opcodeTablePtr[0x4B] = Op_LinkObjects;
 	opcodeTablePtr[0x54] = Op_SetFontFileIndex;
 	opcodeTablePtr[0x56] = Op_changeCutSceneState;
 	opcodeTablePtr[0x57] = Op_GetMouseX;

Modified: scummvm/trunk/engines/cruise/mainDraw.cpp
===================================================================
--- scummvm/trunk/engines/cruise/mainDraw.cpp	2007-11-11 18:12:55 UTC (rev 29477)
+++ scummvm/trunk/engines/cruise/mainDraw.cpp	2007-11-11 19:33:25 UTC (rev 29478)
@@ -1097,7 +1097,7 @@
 	buildPolyModel(newX, newY, newScale, (char*)polygonMask, destBuffer, newFrame);
 }
 
-void mainSprite(int globalX, int globalY, gfxEntryStruct *pGfxPtr, uint8 *ouputPtr, int newColor, int idx) {
+void drawMessage(gfxEntryStruct *pGfxPtr, int globalX, int globalY, int idx, int newColor, uint8 *ouputPtr) {
 	// this is used for font only
 
 	if (pGfxPtr) {
@@ -1231,101 +1231,83 @@
 #endif
 
 void drawMenu(menuStruct *pMenu) {
-	if (pMenu && pMenu->numElements) {
-		int height;
-		int x;
-		int y;
-		int var_10;
-		int bx;
-		int newX;
-		int var_6;
-		int currentY;
-		int var_8;
-		int di;
-		menuElementStruct *si;
+	if (pMenu == NULL)
+		return;
+	
+	if(pMenu->numElements == 0)
+		return;
 
-		height = pMenu->gfx->height;
-		x = pMenu->x;
-		y = pMenu->y;
+	int hline = pMenu->gfx->height;
+	int x = pMenu->x;
+	int y = pMenu->y + hline;
 
-		var_10 = pMenu->gfx->width / (199 - (pMenu->gfx->width * 2));
+	int numItemByLine = (199 - hline * 2) / hline;
+	int nbcol = pMenu->numElements / numItemByLine;
 
-		bx = var_10 / (pMenu->numElements + 1);	// rustine...
+	if (!nbcol) {
+		nbcol++;
 
-		if (!bx) {
-			bx++;
-
-			if ((pMenu->numElements * height) + y > 199 - height) {
-				y = ((-1 - pMenu->numElements) * height) + 200;
-			}
-		} else {
-			if (var_10 % pMenu->numElements) {
-				bx++;
-			}
-
-			y = height;
+		if (y+pMenu->numElements*hline > 199-hline) {
+			y = 200 - (pMenu->numElements * hline) - hline;
 		}
-
-		newX = 320 * (2 - bx);
-
-		if (newX < x) {
-			x = newX;
+	} else {
+		if (pMenu->numElements % numItemByLine) {
+			nbcol++;
 		}
 
-		if (x < 0) {
-			x = 0;
-		}
+		y = hline;
+	}
 
-		var_6 = (80 * (bx - 1)) + x;
+	if (x > (320-(nbcol*160)))
+		x = 320-(nbcol*160);
 
-		if (var_6 <= 320) {
-			mainSprite(var_6, y - height, pMenu->gfx,
-			    gfxModuleData.pPage10, video4, 320);
-		}
+	if (x < 0)
+		x = 0;
 
-		currentY = y;
-		var_8 = 0;
-		di = x;
+	int wx = x + (nbcol - 1) * (160/2);
 
-		si = pMenu->ptrNextElement;
+	if (wx <= 320 - 160) {
+		drawMessage(pMenu->gfx, wx, y - hline, 160, video4, gfxModuleData.pPage10);
+	}
 
-		if (si) {
-			do {
-				int color;
+	wx = x;
+	int wy = y;
+	int wc = 0;
+	menuElementStruct* p1 = pMenu->ptrNextElement;
 
-				gfxEntryStruct *var_2 = si->gfx;
+	while(p1) {
+		gfxEntryStruct *p2 = p1->gfx;
 
-				si->x = di;
-				si->y = currentY;
-				si->varA = 320;
+		p1->x = wx;
+		p1->y = wy;
+		p1->varA = 160;
 
-				if (si->varC) {
-					color = video3;
-				} else {
-					if (si->color != 255) {
-						color = si->color;
-					} else {
-						color = video2;
-					}
-				}
+		int color;
 
-				if (di < 320) {
-					mainSprite(di, currentY, var_2,
-					    gfxModuleData.pPage10, color, 320);
-				}
+		if (p1->varC) {
+			color = video3;
+		} else {
+			if (p1->color != 255) {
+				color = p1->color;
+			} else {
+				color = video2;
+			}
+		}
 
-				currentY += height;
-				var_8++;
+		if (wx <= (320-160)) {
+			drawMessage(p2, wx, wy, 160, color, gfxModuleData.pPage10);
+		}
 
-				if (var_8 == var_10) {
-					var_8 = 0;
-					di += 320;
-					currentY = y;
-				}
+		wy += hline;
+		wc ++;
 
-				si = si->next;
-			} while (si);
+		if (wc == numItemByLine) {
+			wc = 0;
+			wx += 160;
+			wy = y;
 		}
+
+		p1 = p1->next;
 	}
 }
 
@@ -1361,9 +1343,9 @@
 	int16 objX1 = 0;
 	int16 objY1 = 0;
 	int16 objZ1 = 0;
-	int16 objX2;
-	int16 objY2;
-	int16 objZ2;
+	int16 objX2 = 0;
+	int16 objY2 = 0;
+	int16 objZ2 = 0;
 	int16 spriteHeight;
 
 	if (fadeVar) {
@@ -1524,7 +1506,7 @@
 
 	while (currentObjPtr) {
 		if (currentObjPtr->type == OBJ_TYPE_MSG && currentObjPtr->freeze == 0) {
-			mainSprite(currentObjPtr->x, currentObjPtr->field_C, currentObjPtr->gfxPtr, gfxModuleData.pPage10, currentObjPtr->color, currentObjPtr->spriteIdx);
+			drawMessage(currentObjPtr->gfxPtr, currentObjPtr->x, currentObjPtr->field_C, currentObjPtr->spriteIdx, currentObjPtr->color, gfxModuleData.pPage10);
 			var20 = 1;
 		}
 		currentObjPtr = currentObjPtr->next;
@@ -1538,8 +1520,15 @@
 			return;
 		}
 	} else if ((linkedRelation) && (linkedMsgList)) {
-		ASSERT(0);
-		// TODO: draw mouse here
+		int16 mouseX;
+		int16 mouseY;
+		int16 button;
+		getMouseStatus(&main10, &mouseX, &button, &mouseY);
+
+		if(mouseY>(linkedMsgList->height)*2)
+			drawMessage(linkedMsgList, 0, 0, 320, findHighColor(), gfxModuleData.pPage10);
+		else
+			drawMessage(linkedMsgList, 0, 200, 320, findHighColor(), gfxModuleData.pPage10);
 	}
 }
 

Modified: scummvm/trunk/engines/cruise/menu.cpp
===================================================================
--- scummvm/trunk/engines/cruise/menu.cpp	2007-11-11 18:12:55 UTC (rev 29477)
+++ scummvm/trunk/engines/cruise/menu.cpp	2007-11-11 19:33:25 UTC (rev 29478)
@@ -35,7 +35,7 @@
 	entry = (menuStruct *) malloc(sizeof(menuStruct));
 	ASSERT(entry);
 
-	entry->x = X - 80;
+	entry->x = X - 160/2;
 	entry->y = Y;
 	entry->stringPtr = menuName;
 	entry->numElements = 0;
@@ -62,38 +62,27 @@
 				if (param2) {
 					if (!strcmp(var_6->string, menuText)) {
 						pNewElement = var_6;
-						pSubStruct =
-						    (menuElementSubStruct *)
-						    allocAndZero(sizeof
-						    (menuElementSubStruct));
+						pSubStruct = (menuElementSubStruct *)allocAndZero(sizeof(menuElementSubStruct));
 						ASSERT(pSubStruct);
 
 						pSubStruct->pNext = NULL;
 						pSubStruct->ovlIdx = ovlIdx;
 						pSubStruct->header = headerIdx;
 
-						pSubStructCurrent =
-						    pNewElement->ptrSub;
+						pSubStructCurrent = pNewElement->ptrSub;
 
 						if (!pSubStructCurrent) {
-							pNewElement->ptrSub =
-							    pSubStruct;
+							pNewElement->ptrSub = pSubStruct;
 							return;
 						}
 
 						if (pSubStructCurrent->pNext) {
 							do {
-								pSubStructCurrent
-								    =
-								    pSubStructCurrent->
-								    pNext;
-							} while
-							    (pSubStructCurrent->
-							    pNext);
+								pSubStructCurrent = pSubStructCurrent->pNext;
+							} while(pSubStructCurrent->pNext);
 						}
 
-						pSubStructCurrent->pNext =
-						    pSubStruct;
+						pSubStructCurrent->pNext = pSubStruct;
 						return;
 					}
 				}
@@ -104,13 +93,9 @@
 			var_6 = di;
 		}
 
-		pNewElement =
-		    (menuElementStruct *)
-		    allocAndZero(sizeof(menuElementStruct));
+		pNewElement = (menuElementStruct *)allocAndZero(sizeof(menuElementStruct));
 		ASSERT(pNewElement);
-		pSubStruct =
-		    (menuElementSubStruct *)
-		    allocAndZero(sizeof(menuElementSubStruct));
+		pSubStruct = (menuElementSubStruct *)allocAndZero(sizeof(menuElementSubStruct));
 		ASSERT(pSubStruct);
 
 		pNewElement->string = menuText;

Modified: scummvm/trunk/engines/cruise/object.cpp
===================================================================
--- scummvm/trunk/engines/cruise/object.cpp	2007-11-11 18:12:55 UTC (rev 29477)
+++ scummvm/trunk/engines/cruise/object.cpp	2007-11-11 19:33:25 UTC (rev 29478)
@@ -128,8 +128,19 @@
 	//overlayTable[param1].ovlData
 
 	switch (ptr->_class) {
-	case 1:
+	case THEME:
+	case MULTIPLE:
 		{
+			if(param3 != 5)
+				return;
+			globalVars[overlayTable[ovlIdx].state + ptr->_stateTableIdx] = param4;
+			sortCells(ovlIdx, objIdx, &cellHead);
+			break;
+		}
+	case UNIQUE:
+		return;
+	case VARIABLE:
+		{
 			ptr2 =  &overlayTable[ovlIdx].ovlData->arrayObjVar[ptr->_varTableIdx];
 
 			switch (param3) {

Modified: scummvm/trunk/engines/cruise/perso.h
===================================================================
--- scummvm/trunk/engines/cruise/perso.h	2007-11-11 18:12:55 UTC (rev 29477)
+++ scummvm/trunk/engines/cruise/perso.h	2007-11-11 19:33:25 UTC (rev 29478)
@@ -51,6 +51,7 @@
 void freePerso(int persoIdx);
 void freeAllPerso(void);
 void affiche_chemin(int16 persoIdx, int16 * returnVar);
+int direction(int x1, int y1, int x2, int y2, int inc_jo1, int inc_jo2);
 
 } // End of namespace Cruise
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list