[Scummvm-cvs-logs] CVS: scummvm scumm.h,1.22,1.23 scummvm.cpp,1.22,1.23 gfx.cpp,1.16,1.17 resource.cpp,1.16,1.17 saveload.cpp,1.12,1.13 actor.cpp,1.10,1.11 script_v2.cpp,1.7,1.8 debug.cpp,1.6,1.7 gui.h,1.1,1.2

Ludvig Strigeus strigeus at users.sourceforge.net
Sat Nov 10 11:13:02 CET 2001


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv14559

Modified Files:
	scumm.h scummvm.cpp gfx.cpp resource.cpp saveload.cpp 
	actor.cpp script_v2.cpp debug.cpp gui.h 
Log Message:
fixed hardcoded number -> constant stuff (patches by janssen)

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** scumm.h	2001/11/09 18:54:14	1.22
--- scumm.h	2001/11/10 19:12:32	1.23
***************
*** 30,33 ****
--- 30,34 ----
  
  #define NUM_SCRIPT_SLOT 25
+ #define NUM_ACTORS 13
  
  #pragma START_PACK_STRUCTS
***************
*** 290,293 ****
--- 291,295 ----
  
  enum ResTypes {
+ 	rtFirst = 1,
  	rtRoom = 1,
  	rtScript = 2,
***************
*** 306,310 ****
--- 308,315 ----
  	rtBox = 15,
  	rtObjectName = 16,
+ 	rtLast = 16,
  
+ 	rtNumTypes = 17,
+ 
  };
  
***************
*** 760,771 ****
  
  	struct {
! 		byte mode[17];
! 		uint16 num[17];
! 		uint32 tags[17];
! 		const char *name[17];
! 		byte **address[17];
! 		byte *flags[17];
! 		byte *roomno[17];
! 		uint32 *roomoffs[17];
  	} res;
  
--- 765,776 ----
  
  	struct {
! 		byte mode[rtNumTypes];
! 		uint16 num[rtNumTypes];
! 		uint32 tags[rtNumTypes];
! 		const char *name[rtNumTypes];
! 		byte **address[rtNumTypes];
! 		byte *flags[rtNumTypes];
! 		byte *roomno[rtNumTypes];
! 		uint32 *roomoffs[rtNumTypes];
  	} res;
  
***************
*** 785,789 ****
  	} mouse;
  
! 	Actor actor[13];
  
  	uint16 actorDrawBits[200];
--- 790,794 ----
  	} mouse;
  
! 	Actor actor[NUM_ACTORS];
  
  	uint16 actorDrawBits[200];
***************
*** 1669,1671 ****
  byte *findResource(uint32 id, byte *searchin, int index);
  void playSfxSound(void *sound, uint32 size, uint rate);
! bool isSfxFinished();
\ No newline at end of file
--- 1674,1676 ----
  byte *findResource(uint32 id, byte *searchin, int index);
  void playSfxSound(void *sound, uint32 size, uint rate);
! bool isSfxFinished();

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** scummvm.cpp	2001/11/09 18:54:15	1.22
--- scummvm.cpp	2001/11/10 19:12:32	1.23
***************
*** 73,77 ****
  	setupCursor();
  
! 	for (i=1,a=getFirstActor(); ++a,i<13; i++) {
  		a->number = i;
  		initActor(a, 1);
--- 73,77 ----
  	setupCursor();
  
! 	for (i=1,a=getFirstActor(); ++a,i<NUM_ACTORS; i++) {
  		a->number = i;
  		initActor(a, 1);
***************
*** 288,292 ****
  		redrawVerbs();
  		_fullRedraw = true;
! 		for (i=0,a=getFirstActor(); i<13; i++,a++)
  			a->needRedraw = 1;
  	}
--- 288,292 ----
  		redrawVerbs();
  		_fullRedraw = true;
! 		for (i=0,a=getFirstActor(); i<NUM_ACTORS; i++,a++)
  			a->needRedraw = 1;
  	}
***************
*** 485,489 ****
  	stopCycle(0);
  	
! 	for(i=1,at=getFirstActor(); ++at,i<13; i++) {
  		if (at->visible)
  			hideActor(at);
--- 485,489 ----
  	stopCycle(0);
  	
! 	for(i=1,at=getFirstActor(); ++at,i<NUM_ACTORS; i++) {
  		if (at->visible)
  			hideActor(at);
***************
*** 837,841 ****
  
  Actor *Scumm::derefActorSafe(int id, const char *errmsg) {
! 	if (id<1 || id>=13)
  		error("Invalid actor %d in %s", id, errmsg);
  	return derefActor(id);
--- 837,841 ----
  
  Actor *Scumm::derefActorSafe(int id, const char *errmsg) {
! 	if (id<1 || id>=NUM_ACTORS)
  		error("Invalid actor %d in %s", id, errmsg);
  	return derefActor(id);

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gfx.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** gfx.cpp	2001/11/09 18:54:14	1.16
--- gfx.cpp	2001/11/10 19:12:32	1.17
***************
*** 296,300 ****
  		setCameraAt(a->x);
  
! 	for (i=1,a=getFirstActor(); ++a,i<13; i++) {
  		if (a->room==_currentRoom)
  			a->needRedraw = true;
--- 296,300 ----
  		setCameraAt(a->x);
  
! 	for (i=1,a=getFirstActor(); ++a,i<NUM_ACTORS; i++) {
  		if (a->room==_currentRoom)
  			a->needRedraw = true;
***************
*** 1633,1637 ****
  	}
  
! 	for(i=1,a=getFirstActor(); ++a,i<13; i++) {
  		a->needBgReset = false;
  	}
--- 1633,1637 ----
  	}
  
! 	for(i=1,a=getFirstActor(); ++a,i<NUM_ACTORS; i++) {
  		a->needBgReset = false;
  	}

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/resource.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** resource.cpp	2001/11/09 22:45:19	1.16
--- resource.cpp	2001/11/10 19:12:32	1.17
***************
*** 176,180 ****
  		switch(blocktype) {
  		case MKID('DCHR'):
! 			readResTypeList(6,MKID('CHAR'),"charset");
  			break;
  
--- 176,180 ----
  		switch(blocktype) {
  		case MKID('DCHR'):
! 			readResTypeList(rtCharset,MKID('CHAR'),"charset");
  			break;
  
***************
*** 201,213 ****
  
  		case MKID('DROO'):
! 			readResTypeList(1,MKID('ROOM'),"room");
  			break;
  
  		case MKID('DSCR'):
! 			readResTypeList(2,MKID('SCRP'),"script");
  			break;
  
  		case MKID('DCOS'):
! 			readResTypeList(3,MKID('COST'),"costume");
  			break;
  
--- 201,213 ----
  
  		case MKID('DROO'):
! 			readResTypeList(rtRoom,MKID('ROOM'),"room");
  			break;
  
  		case MKID('DSCR'):
! 			readResTypeList(rtScript,MKID('SCRP'),"script");
  			break;
  
  		case MKID('DCOS'):
! 			readResTypeList(rtCostume,MKID('COST'),"costume");
  			break;
  
***************
*** 225,229 ****
  
  		case MKID('DSOU'):
! 			readResTypeList(4,MKID('SOUN'),"sound");
  			break;
  
--- 225,229 ----
  
  		case MKID('DSOU'):
! 			readResTypeList(rtSound,MKID('SOUN'),"sound");
  			break;
  
***************
*** 266,270 ****
  			switch(blocktype) {
  		case MKID('DCHR'):
! 			readResTypeList(6,MKID('CHAR'),"charset");
  			break;
  
--- 266,270 ----
  			switch(blocktype) {
  		case MKID('DCHR'):
! 			readResTypeList(rtCharset,MKID('CHAR'),"charset");
  			break;
  
***************
*** 285,297 ****
  
  		case MKID('DROO'):
! 			readResTypeList(1,MKID('ROOM'),"room");
  			break;
  
  		case MKID('DSCR'):
! 			readResTypeList(2,MKID('SCRP'),"script");
  			break;
  
  		case MKID('DCOS'):
! 			readResTypeList(3,MKID('COST'),"costume");
  			break;
  
--- 285,297 ----
  
  		case MKID('DROO'):
! 			readResTypeList(rtRoom,MKID('ROOM'),"room");
  			break;
  
  		case MKID('DSCR'):
! 			readResTypeList(rtScript,MKID('SCRP'),"script");
  			break;
  
  		case MKID('DCOS'):
! 			readResTypeList(rtCostume,MKID('COST'),"costume");
  			break;
  
***************
*** 301,305 ****
  
  		case MKID('DSOU'):
! 			readResTypeList(4,MKID('SOUN'),"sound");
  			break;
  
--- 301,305 ----
  
  		case MKID('DSOU'):
! 			readResTypeList(rtSound,MKID('SOUN'),"sound");
  			break;
  
***************
*** 413,417 ****
  	debug(9, "ensureResourceLoaded(%d,%d)", type, i);
  
! 	if (type==1 && i>127) {
  		i = _resourceMapper[i&127];
  	}
--- 413,417 ----
  	debug(9, "ensureResourceLoaded(%d,%d)", type, i);
  
! 	if (type==rtRoom && i>127) {
  		i = _resourceMapper[i&127];
  	}
***************
*** 426,430 ****
  	loadResource(type, i);
  
! 	if (type==1 && i==_roomResource)
  		_vars[VAR_ROOM_FLAG] = 1;
  }
--- 426,430 ----
  	loadResource(type, i);
  
! 	if (type==rtRoom && i==_roomResource)
  		_vars[VAR_ROOM_FLAG] = 1;
  }
***************
*** 443,447 ****
  	}
  
! 	if (type==1) {
  		fileOffs = 0;
  	} else {
--- 443,447 ----
  	}
  
! 	if (type==rtRoom) {
  		fileOffs = 0;
  	} else {
***************
*** 456,460 ****
  
  			fileSeek(_fileHandle, fileOffs + _fileOffset, SEEK_SET);
! 			if (type==4) {
  				fileReadDwordLE();
  				fileReadDwordLE();
--- 456,460 ----
  
  			fileSeek(_fileHandle, fileOffs + _fileOffset, SEEK_SET);
! 			if (type==rtSound) {
  				fileReadDwordLE();
  				fileReadDwordLE();
***************
*** 476,480 ****
  			/* dump the resource */
  #ifdef DUMP_SCRIPTS
! 			if(type==2) {
  				dumpResource("script-", index, getResourceAddress(rtScript, index));
  			}
--- 476,480 ----
  			/* dump the resource */
  #ifdef DUMP_SCRIPTS
! 			if(type==rtScript) {
  				dumpResource("script-", index, getResourceAddress(rtScript, index));
  			}
***************
*** 527,531 ****
  
  int Scumm::getResourceRoomNr(int type, int index) {
! 	if (type==1)
  		return index;
  	return res.roomno[type][index];
--- 527,531 ----
  
  int Scumm::getResourceRoomNr(int type, int index) {
! 	if (type==rtRoom)
  		return index;
  	return res.roomno[type][index];
***************
*** 603,607 ****
  
  void Scumm::validateResource(const char *str, int type, int index) {
! 	if (type<1 || type>16 || index<0 || index >= res.num[type]) {
  		error("%d Illegal Glob type %d num %d", str, type, index);
  	}
--- 603,607 ----
  
  void Scumm::validateResource(const char *str, int type, int index) {
! 	if (type<rtFirst || type>rtLast || (uint)index >= (uint)res.num[type]) {
  		error("%d Illegal Glob type %d num %d", str, type, index);
  	}
***************
*** 687,691 ****
  	byte counter;
  
! 	for (i=1; i<=16; i++) {
  		for(j=res.num[i]; --j>=0;) {
  			counter = res.flags[i][j] & 0x7F;
--- 687,691 ----
  	byte counter;
  
! 	for (i=rtFirst; i<=rtLast; i++) {
  		for(j=res.num[i]; --j>=0;) {
  			counter = res.flags[i][j] & 0x7F;
***************
*** 718,722 ****
  		best_counter = 2;
  
! 		for (i=1; i<=16; i++)
  			if (res.mode[i]) {
  				for(j=res.num[i]; --j>=0;) {
--- 718,722 ----
  		best_counter = 2;
  
! 		for (i=rtFirst; i<=rtLast; i++)
  			if (res.mode[i]) {
  				for(j=res.num[i]; --j>=0;) {
***************
*** 742,746 ****
  void Scumm::freeResources() {
  	int i,j;
! 	for (i=1; i<=16; i++) {
  		for(j=res.num[i]; --j>=0;) {
  			if (isResourceLoaded(i,j))
--- 742,746 ----
  void Scumm::freeResources() {
  	int i,j;
! 	for (i=rtFirst; i<=rtLast; i++) {
  		for(j=res.num[i]; --j>=0;) {
  			if (isResourceLoaded(i,j))
***************
*** 787,791 ****
  	byte flag;
  	
! 	for (i=1; i<=16; i++)
  		for(j=res.num[i]; --j>=0;) {
  			flag = res.flags[i][j];
--- 787,791 ----
  	byte flag;
  	
! 	for (i=rtFirst; i<=rtLast; i++)
  		for(j=res.num[i]; --j>=0;) {
  			flag = res.flags[i][j];

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saveload.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** saveload.cpp	2001/11/09 22:44:26	1.12
--- saveload.cpp	2001/11/10 19:12:32	1.13
***************
*** 96,100 ****
  
  	/* Nuke all resources */
! 	for (i=1; i<=16; i++)
  		if (i!=rtTemp && i!=rtBuffer)
  			for(j=0; j<res.num[i]; j++) {
--- 96,100 ----
  
  	/* Nuke all resources */
! 	for (i=rtFirst; i<=rtLast; i++)
  		if (i!=rtTemp && i!=rtBuffer)
  			for(j=0; j<res.num[i]; j++) {
***************
*** 453,457 ****
  	s->saveLoadArrayOf(_colorCycle, 16, sizeof(_colorCycle[0]), colorCycleEntries);
  
! 	for (i=1; i<=16; i++)
  		if (res.mode[i]==0)
  			for(j=1; j<res.num[i]; j++)
--- 453,457 ----
  	s->saveLoadArrayOf(_colorCycle, 16, sizeof(_colorCycle[0]), colorCycleEntries);
  
! 	for (i=rtFirst; i<=rtLast; i++)
  		if (res.mode[i]==0)
  			for(j=1; j<res.num[i]; j++)
***************
*** 465,469 ****
  	/* Save or load a list of the locked objects */
  	if (s->isSaving()) {
! 		for (i=1; i<=16; i++)
  			for(j=1; j<res.num[i]; j++) {
  				if (res.flags[i][j]&0x80) {
--- 465,469 ----
  	/* Save or load a list of the locked objects */
  	if (s->isSaving()) {
! 		for (i=rtFirst; i<=rtLast; i++)
  			for(j=1; j<res.num[i]; j++) {
  				if (res.flags[i][j]&0x80) {
***************
*** 487,491 ****
  
  	/* don't save/load these resource types */
! 	if (type==13 || type==12 || type==10 || res.mode[type])
  		return;
  
--- 487,491 ----
  
  	/* don't save/load these resource types */
! 	if (type==rtFlObject || type==rtTemp || type==rtBuffer || res.mode[type])
  		return;
  
***************
*** 502,506 ****
  		ser->saveLoadBytes(ptr+sizeof(ResHeader),size);
  
! 		if (type==5) {
  			ser->saveWord(_inventory[index]);
  		}
--- 502,506 ----
  		ser->saveLoadBytes(ptr+sizeof(ResHeader),size);
  
! 		if (type==rtInventory) {
  			ser->saveWord(_inventory[index]);
  		}
***************
*** 510,514 ****
  			createResource(type, index, size);
  			ser->saveLoadBytes(getResourceAddress(type, index), size);
! 			if (type==5) {
  				_inventory[index] = ser->loadWord();
  			}
--- 510,514 ----
  			createResource(type, index, size);
  			ser->saveLoadBytes(getResourceAddress(type, index), size);
! 			if (type==rtInventory) {
  				_inventory[index] = ser->loadWord();
  			}

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** actor.cpp	2001/11/07 18:10:52	1.10
--- actor.cpp	2001/11/10 19:12:32	1.11
***************
*** 575,579 ****
  	Actor *a;
  	
! 	for (i=1; i<13; i++) {
  		a = derefActor(i);
  		if (a->room == _currentRoom)
--- 575,579 ----
  	Actor *a;
  	
! 	for (i=1; i<NUM_ACTORS; i++) {
  		a = derefActor(i);
  		if (a->room == _currentRoom)
***************
*** 609,613 ****
  	int i;
  	Actor *a;
! 	for (i=1; i<13; i++) {
  		a = derefActor(i);	
  		if (a->room==_currentRoom)
--- 609,613 ----
  	int i;
  	Actor *a;
! 	for (i=1; i<NUM_ACTORS; i++) {
  		a = derefActor(i);	
  		if (a->room==_currentRoom)
***************
*** 621,630 ****
  	Actor *a;
  	
! 	for (i=1; i<13; i++) {
  		a = derefActor(i);
  		if (a->cost.animCounter2 && a->room==_currentRoom && a->sound) {
  			_currentScript = 0xFF;
  			addSoundToQueue(a->sound[0]);
! 			for (i=1; i<13; i++) {
  				a = derefActor(i);
  				a->cost.animCounter2 = 0;
--- 621,630 ----
  	Actor *a;
  	
! 	for (i=1; i<NUM_ACTORS; i++) {
  		a = derefActor(i);
  		if (a->cost.animCounter2 && a->room==_currentRoom && a->sound) {
  			_currentScript = 0xFF;
  			addSoundToQueue(a->sound[0]);
! 			for (i=1; i<NUM_ACTORS; i++) {
  				a = derefActor(i);
  				a->cost.animCounter2 = 0;
***************
*** 709,716 ****
  void Scumm::processActors() {
  	int i;
! 	Actor *actors[13],*a,**ac,**ac2,*tmp;
  	int numactors = 0, cnt,cnt2;
  
! 	for (i=1; i<13; i++) {
  		a = derefActor(i);
  		if (a->room == _currentRoom)
--- 709,716 ----
  void Scumm::processActors() {
  	int i;
! 	Actor *actors[NUM_ACTORS],*a,**ac,**ac2,*tmp;
  	int numactors = 0, cnt,cnt2;
  
! 	for (i=1; i<NUM_ACTORS; i++) {
  		a = derefActor(i);
  		if (a->room == _currentRoom)
***************
*** 815,819 ****
  		bits = actorDrawBits[_screenStartStrip+i];
  		if (bits&0x3FFF) {
! 			for(j=0; j<13; j++) {
  				if ((bits&(1<<j)) && bits!=(1<<j)) {
  					Actor *a = derefActor(j);
--- 815,819 ----
  		bits = actorDrawBits[_screenStartStrip+i];
  		if (bits&0x3FFF) {
! 			for(j=0; j<NUM_ACTORS; j++) {
  				if ((bits&(1<<j)) && bits!=(1<<j)) {
  					Actor *a = derefActor(j);
***************
*** 833,837 ****
  	if (!(drawbits & 0x3FFF))
  		return 0;
! 	for (i=1; i<13; i++) {
  		Actor *a = derefActor(i);
  		if (drawbits&(1<<i) && !getClass(i, 32) && y >= a->top && y <= a->bottom) {
--- 833,837 ----
  	if (!(drawbits & 0x3FFF))
  		return 0;
! 	for (i=1; i<NUM_ACTORS; i++) {
  		Actor *a = derefActor(i);
  		if (drawbits&(1<<i) && !getClass(i, 32) && y >= a->top && y <= a->bottom) {
***************
*** 967,971 ****
  
  	if (_roomResource!=0)
! 		for (i=1; i<13; i++) {
  			a = derefActor(i);
  			if (a->room == _currentRoom && a->costume == cost)
--- 967,971 ----
  
  	if (_roomResource!=0)
! 		for (i=1; i<NUM_ACTORS; i++) {
  			a = derefActor(i);
  			if (a->room == _currentRoom && a->costume == cost)

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v2.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** script_v2.cpp	2001/11/07 18:10:51	1.7
--- script_v2.cpp	2001/11/10 19:12:32	1.8
***************
*** 2005,2009 ****
  		_fullRedraw = 1;
  		redrawBGAreas();
! 		for (i=0; i<13; i++)
  			derefActor(i)->needRedraw = true;
  		processActors();
--- 2005,2009 ----
  		_fullRedraw = 1;
  		redrawBGAreas();
! 		for (i=0; i<NUM_ACTORS; i++)
  			derefActor(i)->needRedraw = true;
  		processActors();

Index: debug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/debug.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** debug.cpp	2001/11/07 18:10:52	1.6
--- debug.cpp	2001/11/10 19:12:32	1.7
***************
*** 166,170 ****
  	printf("|# |room|  x y   |elev|cos|width|box|mov|zp|frame|scale|spd|dir|\n");
  	printf("+--+----+--------+----+---+-----+---+---+--+-----+-----+---+---+\n");
! 	for(i=1; i<13; i++) {
  		if (act==-1 || act==i) {
  			a = &_s->actor[i];
--- 166,170 ----
  	printf("|# |room|  x y   |elev|cos|width|box|mov|zp|frame|scale|spd|dir|\n");
  	printf("+--+----+--------+----+---+-----+---+---+--+-----+-----+---+---+\n");
! 	for(i=1; i<NUM_ACTORS; i++) {
  		if (act==-1 || act==i) {
  			a = &_s->actor[i];

Index: gui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** gui.h	2001/11/09 18:56:27	1.1
--- gui.h	2001/11/10 19:12:32	1.2
***************
*** 1,2 ****
--- 1,5 ----
+ #if !defined(gui_h)
+ #define gui_h
+ 
  enum {
  	GUI_NONE = 0,
***************
*** 74,75 ****
--- 77,80 ----
  	byte getDefaultColor(int color);
  };
+ 
+ #endif
\ No newline at end of file





More information about the Scummvm-git-logs mailing list