[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.26,1.27 actor.h,1.9,1.10 input.cpp,1.15,1.16 interface.cpp,1.25,1.26 interface.h,1.8,1.9 objectmap.cpp,1.21,1.22 objectmap.h,1.9,1.10 render.cpp,1.34,1.35

Eugene Sandulenko sev at users.sourceforge.net
Thu Oct 7 16:28:05 CEST 2004


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1147

Modified Files:
	actor.cpp actor.h input.cpp interface.cpp interface.h 
	objectmap.cpp objectmap.h render.cpp 
Log Message:
More de-C'fying. Pass Point object instead of direct reference.


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- actor.cpp	7 Oct 2004 22:31:39 -0000	1.26
+++ actor.cpp	7 Oct 2004 23:26:41 -0000	1.27
@@ -1022,9 +1022,9 @@
 	return R_SUCCESS;
 }
 
-int Actor::StoA(Point *actor, const Point *screen) {
-	actor->x = (screen->x * R_ACTOR_LMULT);
-	actor->y = (screen->y * R_ACTOR_LMULT);
+int Actor::StoA(Point *actor, const Point screen) {
+	actor->x = (screen.x * R_ACTOR_LMULT);
+	actor->y = (screen.y * R_ACTOR_LMULT);
 
 	return R_SUCCESS;
 }

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- actor.h	4 Oct 2004 23:09:38 -0000	1.9
+++ actor.h	7 Oct 2004 23:26:41 -0000	1.10
@@ -197,7 +197,7 @@
 
 	int drawList();
 	int AtoS(Point *logical, const Point *actor);
-	int StoA(Point *actor, const Point *screen);
+	int StoA(Point *actor, const Point screen);
 
 	int move(int index, Point *move_pt);
 	int moveRelative(int index, Point *move_pt);

Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/input.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- input.cpp	4 Oct 2004 23:51:23 -0000	1.15
+++ input.cpp	7 Oct 2004 23:26:41 -0000	1.16
@@ -35,7 +35,7 @@
 int SagaEngine::processInput() {
 	OSystem::Event event;
 
-	Point imouse_pt;
+	Point imousePt;
 
 	while (g_system->pollEvent(event)) {
 		int in_char;
@@ -113,13 +113,13 @@
 		case OSystem::EVENT_LBUTTONDOWN:
 			_mousePos.x = event.mouse.x;
 			_mousePos.y = event.mouse.y;
-			imouse_pt = _mousePos;
-			_vm->_interface->update(&imouse_pt, UPDATE_MOUSECLICK);
+			imousePt = _mousePos;
+			_vm->_interface->update(imousePt, UPDATE_MOUSECLICK);
 			break;
 		case OSystem::EVENT_MOUSEMOVE:
 			_mousePos.x = event.mouse.x;
 			_mousePos.y = event.mouse.y;
-			imouse_pt = _mousePos;
+			imousePt = _mousePos;
 			break;
 		case OSystem::EVENT_QUIT:
 			g_system->quit();

Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- interface.cpp	7 Oct 2004 23:02:19 -0000	1.25
+++ interface.cpp	7 Oct 2004 23:26:41 -0000	1.26
@@ -303,21 +303,19 @@
 	return R_SUCCESS;
 }
 
-int Interface::update(Point *imouse_pt, int update_flag) {
+int Interface::update(Point imousePt, int update_flag) {
 	R_GAME_DISPLAYINFO g_di;
 
 	R_SURFACE *back_buf;
 
 	int imouse_x, imouse_y;
 
-	assert(imouse_pt != NULL);
-
 	if (!_active) {
 		return R_SUCCESS;
 	}
 
-	imouse_x = imouse_pt->x;
-	imouse_y = imouse_pt->y;
+	imouse_x = imousePt.x;
+	imouse_y = imousePt.y;
 
 	back_buf = _vm->_gfx->getBackBuffer();
 
@@ -328,17 +326,17 @@
 	if (imouse_y < g_di.scene_h) {
 		// Mouse is in playfield space
 		if (update_flag == UPDATE_MOUSEMOVE) {
-			handlePlayfieldUpdate(back_buf, imouse_pt);
+			handlePlayfieldUpdate(back_buf, imousePt);
 		} else if (update_flag == UPDATE_MOUSECLICK) {
-			handlePlayfieldClick(back_buf, imouse_pt);
+			handlePlayfieldClick(back_buf, imousePt);
 		}
 	}
 
 	// Update command space
 	if (update_flag == UPDATE_MOUSEMOVE) {
-		handleCommandUpdate(back_buf, imouse_pt);
+		handleCommandUpdate(back_buf, imousePt);
 	} else if (update_flag == UPDATE_MOUSECLICK) {
-		handleCommandClick(back_buf, imouse_pt);
+		handleCommandClick(back_buf, imousePt);
 	}
 
 	drawStatusBar(back_buf);
@@ -371,7 +369,7 @@
 	return R_SUCCESS;
 }
 
-int Interface::handleCommandClick(R_SURFACE *ds, Point *imouse_pt) {
+int Interface::handleCommandClick(R_SURFACE *ds, Point imousePt) {
 	int hit_button;
 	int ibutton_num;
 
@@ -384,7 +382,7 @@
 	int old_set_button;
 	int set_button;
 
-	hit_button = hitTest(imouse_pt, &ibutton_num);
+	hit_button = hitTest(imousePt, &ibutton_num);
 	if (hit_button != R_SUCCESS) {
 		// Clicking somewhere other than a button doesn't do anything
 		return R_SUCCESS;
@@ -422,7 +420,7 @@
 	return R_SUCCESS;
 }
 
-int Interface::handleCommandUpdate(R_SURFACE *ds, Point *imouse_pt) {
+int Interface::handleCommandUpdate(R_SURFACE *ds, Point imousePt) {
 	int hit_button;
 	int ibutton_num;
 
@@ -436,7 +434,7 @@
 	int color;
 	int i;
 
-	hit_button = hitTest(imouse_pt, &ibutton_num);
+	hit_button = hitTest(imousePt, &ibutton_num);
 
 	if (hit_button == R_SUCCESS) {
 		// Hovering over a command panel button
@@ -476,27 +474,26 @@
 	return R_SUCCESS;
 }
 
-int Interface::handlePlayfieldClick(R_SURFACE *ds, Point *imouse_pt) {
-	int hit_object;
-	int object_num;
+int Interface::handlePlayfieldClick(R_SURFACE *ds, Point imousePt) {
+	int objectNum;
 	uint16 object_flags = 0;
 
 	int script_num;
 	Point iactor_pt;
 
-	hit_object = _vm->_scene->_objectMap->hitTest(imouse_pt, &object_num);
+	objectNum = _vm->_scene->_objectMap->hitTest(imousePt);
 
-	if (hit_object != R_SUCCESS) {
+	if (objectNum == -1) {
 		// Player clicked on empty spot - walk here regardless of verb
-		_vm->_actor->StoA(&iactor_pt, imouse_pt);
+		_vm->_actor->StoA(&iactor_pt, imousePt);
 		_vm->_actor->walkTo(0, &iactor_pt, 0, NULL);
 		return R_SUCCESS;
 	}
 
-	object_flags = _vm->_scene->_objectMap->getFlags(object_num);
+	object_flags = _vm->_scene->_objectMap->getFlags(objectNum);
 
 	if (object_flags & R_OBJECT_NORMAL) {
-		if ((script_num = _vm->_scene->_objectMap->getEPNum(object_num)) != -1) {
+		if ((script_num = _vm->_scene->_objectMap->getEPNum(objectNum)) != -1) {
 			// Set active verb in script module
 			_vm->_sdata->putWord(4, 4, I_VerbData[_activeVerb].s_verb);
 
@@ -507,35 +504,33 @@
 		}
 	} else {
 		// Not a normal scene object - walk to it as if it weren't there
-		_vm->_actor->StoA(&iactor_pt, imouse_pt);
+		_vm->_actor->StoA(&iactor_pt, imousePt);
 		_vm->_actor->walkTo(0, &iactor_pt, 0, NULL);
 	}
 
 	return R_SUCCESS;
 }
 
-int Interface::handlePlayfieldUpdate(R_SURFACE *ds, Point *imouse_pt) {
+int Interface::handlePlayfieldUpdate(R_SURFACE *ds, Point imousePt) {
 	const char *object_name;
-	int object_num;
+	int objectNum;
 	uint16 object_flags = 0;
 
 	char new_status[R_STATUS_TEXT_LEN];
 
-	int hit_object;
-
 	new_status[0] = 0;
 
-	hit_object = _vm->_scene->_objectMap->hitTest(imouse_pt, &object_num);
+	objectNum = _vm->_scene->_objectMap->hitTest(imousePt);
 
-	if (hit_object != R_SUCCESS) {
+	if (objectNum == -1) {
 		// Cursor over nothing - just display current verb
 		setStatusText(I_VerbData[_activeVerb].verb_str);
 		return R_SUCCESS;
 	}
 
-	object_flags = _vm->_scene->_objectMap->getFlags(object_num);
+	object_flags = _vm->_scene->_objectMap->getFlags(objectNum);
 
-	object_name = _vm->_scene->_objectMap->getName(object_num);
+	object_name = _vm->_scene->_objectMap->getName(objectNum);
 
 	if (object_flags & R_OBJECT_NORMAL) {
 		// Normal scene object - display as subject of verb
@@ -551,7 +546,7 @@
 	return R_SUCCESS;
 }
 
-int Interface::hitTest(Point *imouse_pt, int *ibutton) {
+int Interface::hitTest(Point imousePt, int *ibutton) {
 	R_INTERFACE_BUTTON *buttons;
 
 	int nbuttons;
@@ -567,8 +562,8 @@
 	ybase = _cPanel.y;
 
 	for (i = 0; i < nbuttons; i++) {
-		if ((imouse_pt->x >= (xbase + buttons[i].x1)) && (imouse_pt->x < (xbase + buttons[i].x2)) &&
-			(imouse_pt->y >= (ybase + buttons[i].y1)) && (imouse_pt->y < (ybase + buttons[i].y2))) {
+		if ((imousePt.x >= (xbase + buttons[i].x1)) && (imousePt.x < (xbase + buttons[i].x2)) &&
+			(imousePt.y >= (ybase + buttons[i].y1)) && (imousePt.y < (ybase + buttons[i].y2))) {
 			*ibutton = i;
 			return R_SUCCESS;
 		}

Index: interface.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- interface.h	4 Oct 2004 23:09:38 -0000	1.8
+++ interface.h	7 Oct 2004 23:26:41 -0000	1.9
@@ -160,16 +160,16 @@
 	int deactivate();
 	int setStatusText(const char *new_txt);
 	int draw();
-	int update(Point *imouse_pt, int update_flag);
+	int update(Point imousePt, int update_flag);
 
 
  private:
-	int hitTest(Point *imouse_pt, int *ibutton);
+	int hitTest(Point imousePt, int *ibutton);
 	int drawStatusBar(R_SURFACE *ds);
-	int handleCommandUpdate(R_SURFACE *ds, Point *imouse_pt);
-	int handleCommandClick(R_SURFACE *ds, Point *imouse_pt);
-	int handlePlayfieldUpdate(R_SURFACE *ds, Point *imouse_pt);
-	int handlePlayfieldClick(R_SURFACE *ds, Point *imouse_pt);
+	int handleCommandUpdate(R_SURFACE *ds, Point imousePt);
+	int handleCommandClick(R_SURFACE *ds, Point imousePt);
+	int handlePlayfieldUpdate(R_SURFACE *ds, Point imousePt);
+	int handlePlayfieldClick(R_SURFACE *ds, Point imousePt);
 
  private:
 	SagaEngine *_vm;

Index: objectmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/objectmap.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- objectmap.cpp	7 Oct 2004 23:02:19 -0000	1.21
+++ objectmap.cpp	7 Oct 2004 23:26:41 -0000	1.22
@@ -40,6 +40,7 @@
 ObjectMap::ObjectMap(SagaEngine *vm) : _vm(vm) {
 	_objectsLoaded = false;
 	_namesLoaded = false;
+	_nNames = 0;
 }
 
 // Shuts down the object map module, destroys module allocation context
@@ -213,6 +214,7 @@
 	int i;
 
 	assert(_namesLoaded);
+	debug(0, "object: %d nnames: %d", object, _nNames);
 	assert((object > 0) && (object <= _nNames));
 
 	for (i = 0; i < _nObjects; i++) {
@@ -245,7 +247,7 @@
 
 // Uses Gfx::drawLine to display all clickareas for each object in the 
 // currently loaded object map resource.
-int ObjectMap::draw(R_SURFACE *ds, Point *imouse_pt, int color, int color2) {
+int ObjectMap::draw(R_SURFACE *ds, Point imousePt, int color, int color2) {
 	R_OBJECTMAP_ENTRY *object_map;
 	R_CLICKAREA *clickarea;
 
@@ -254,7 +256,7 @@
 	int draw_color = color;
 	int draw_txt = 0;
 
-	int hit_object = 0;
+	bool hitObject = false;
 	int objectNum = 0;
 
 	int pointcount = 0;
@@ -264,15 +266,13 @@
 		return R_FAILURE;
 	}
 
-	if (imouse_pt != NULL) {
-		if (hitTest(imouse_pt, &objectNum) == R_SUCCESS) {
-			hit_object = 1;
-		}
+	if ((objectNum = hitTest(imousePt)) != -1) {
+		hitObject = true;
 	}
 
 	for (i = 0; i < _nObjects; i++) {
 		draw_color = color;
-		if (hit_object && (objectNum == _objectMaps[i].objectNum)) {
+		if (hitObject && (objectNum == _objectMaps[i].objectNum)) {
 			snprintf(txt_buf, sizeof txt_buf, "obj %d: v %d, f %X",
 					_objectMaps[i].objectNum,
 					_objectMaps[i].defaultVerb,
@@ -329,7 +329,7 @@
 	return inside_flag;
 }
 
-int ObjectMap::hitTest(Point *imouse_pt, int *objectNum) {
+int ObjectMap::hitTest(Point imousePt) {
 	Point imouse;
 	R_OBJECTMAP_ENTRY *object_map;
 	R_CLICKAREA *clickarea;
@@ -338,10 +338,8 @@
 
 	int i, k;
 
-	assert((imouse_pt != NULL) && (objectNum != NULL));
-
-	imouse.x = imouse_pt->x;
-	imouse.y = imouse_pt->y;
+	imouse.x = imousePt.x;
+	imouse.y = imousePt.y;
 
 	// Loop through all scene objects
 	for (i = 0; i < _nObjects; i++) {
@@ -358,22 +356,18 @@
 				if ((imouse.x > points[0].x) && (imouse.x <= points[1].x) &&
 					(imouse.y > points[0].y) &&
 					(imouse.y <= points[1].y)) {
-						*objectNum = object_map->objectNum;
-						return R_SUCCESS;
+						return object_map->objectNum;
 				}
 			} else if (n_points > 2) {
 				// Hit-test a polygon
 				if (MATH_HitTestPoly(points, n_points, imouse)) {
-					*objectNum = object_map->objectNum;
-					return R_SUCCESS;
+					return object_map->objectNum;
 				}
 			}
 		}
 	}
 
-	*objectNum = 0;
-
-	return R_FAILURE;
+	return -1;
 }
 
 void ObjectMap::info(void) {

Index: objectmap.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/objectmap.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- objectmap.h	7 Oct 2004 23:02:19 -0000	1.9
+++ objectmap.h	7 Oct 2004 23:26:41 -0000	1.10
@@ -63,8 +63,8 @@
 	const char *getName(int object);
 	const uint16 getFlags(int object);
 	const int getEPNum(int object);
-	int draw(R_SURFACE *draw_surface, Point *imousePt, int color, int color2);
-	int hitTest(Point *imouse_pt, int *object_num);
+	int draw(R_SURFACE *draw_surface, Point imousePt, int color, int color2);
+	int hitTest(Point imousePt);
 	void info(void);
 
 private:

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- render.cpp	7 Oct 2004 23:02:19 -0000	1.34
+++ render.cpp	7 Oct 2004 23:26:41 -0000	1.35
@@ -134,7 +134,7 @@
 
 	// Display scene maps, if applicable
 	if (getFlags() & RF_OBJECTMAP_TEST) {
-		_vm->_scene->_objectMap->draw(backbuf_surface, &mouse_pt, _vm->_gfx->getWhite(), _vm->_gfx->getBlack());
+		_vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, _vm->_gfx->getWhite(), _vm->_gfx->getBlack());
 		_vm->_scene->_actionMap->draw(backbuf_surface, _vm->_gfx->matchColor(R_RGB_RED));
 	}
 
@@ -167,7 +167,7 @@
 
 	// Update user interface
 
-	_vm->_interface->update(&mouse_pt, UPDATE_MOUSEMOVE);
+	_vm->_interface->update(mouse_pt, UPDATE_MOUSEMOVE);
 
 	// Display text formatting test, if applicable
 	if (_flags & RF_TEXT_TEST) {





More information about the Scummvm-git-logs mailing list