Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

OIL! OIL! WE FOUND OIL!!!!! (bug: exponential oil drum growth) #2174

Closed
wzdev-ci opened this issue Sep 16, 2010 · 5 comments
Closed

OIL! OIL! WE FOUND OIL!!!!! (bug: exponential oil drum growth) #2174

wzdev-ci opened this issue Sep 16, 2010 · 5 comments

Comments

@wzdev-ci
Copy link
Contributor

keyword_oil_drum_spree resolution_fixed type_bug | by CorvusCorax


In a multiplayer game, once the game is created, multiGameInit() will call campInit(), where the host will place PLAYER_COUNT *2 oil drums randomly on the map:

multiopt.c: #568:
	if (NetPlay.isHost)	// add oil drums
	{
		addOilDrum(NetPlay.playercount * 2);
	}

if such a drum (or in fact any oil drum on the map) gets picked up, a new oil drum will be randomly placed on the map

move.c: #2912
static void checkLocalFeatures(DROID *psDroid)
{
	SDWORD			i;
	BASE_OBJECT		*psObj;

	// only do for players droids.
	if(psDroid->player != selectedPlayer)
	{
		return;
	}

	droidGetNaybors(psDroid);// update naybor list.

	// scan the neighbours
	for(i=0; i<(SDWORD)numNaybors; i++)
	{
#define DROIDDIST (((TILE_UNITS*5)/2) * ((TILE_UNITS*5)/2))
		psObj = asDroidNaybors[i].psObj;
		if (   psObj->type != OBJ_FEATURE
			|| ((FEATURE *)psObj)->psStats->subType != FEAT_OIL_DRUM
			|| asDroidNaybors[i].distSqr >= DROIDDIST )
		{
			// object too far away to worry about
			continue;
		}


		if(bMultiPlayer && (psObj->player == ANYPLAYER))
		{
			giftPower(ANYPLAYER,selectedPlayer,true);			// give power
			CONPRINTF(ConsoleString,(ConsoleString,_("You found %u power in an oil drum."),OILDRUM_POWER));
			addOilDrum(1);
		}
		else

		{
			addPower(selectedPlayer,OILDRUM_POWER);
			CONPRINTF(ConsoleString,(ConsoleString,_("You found %u power in an oil drum"),OILDRUM_POWER));
		}
		removeFeature((FEATURE*)psObj);							// remove artifact+ send multiplay info.

	}
}

checkLocalFeatures() gets called any time a droid moved, so if any droid moves near an oil drum it gets picked up, a destroy message is sent on the network, but before that addOilDrum(1) is called which will place one new oildrum on the map, too. And inform all other players about it.

Now imagine the beforementioned cramped map. Theres almost no free space on the map, except in the middle, where 8 players armies are battling it out.

Right in the middle of a battlefield is a bad place for an oil drum to magically appear though!

Why?

Because the next cycle after it appeared, multiple players might have droids near it.

(it doesn't matter if they are on the same team or not)

Each of them will claim it the next cycle after they received that notification, since the droids are moving. Then subsequently send an obj removal notification to all the others, as well as place one new oil drum on the map.

So For each nearby player, one new oildrum is placed on the map.

But remember, we said the map was cramped, so at least one of these oil drums ends up in the midst of a pulk of units again!

And gets magically duplicated...

This is almost like sharing movies on PirateBay. I can have it, and you can have it too, and then we give copies to others!

It didn't take long with 8 players on the attached map, and we couldn't build a single building anymore because everything was full of oil drums. And that was at the time when we barely had reached ripples. Oil drums spawned faster than we could pick them up and I got these errors galore:

error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (15,14)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (7,39)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (9,11)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (6,12)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (16,23)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (8,12)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (15,24)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (16,22)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (16,25)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (15,22)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (15,25)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (16,26)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (15,14)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (15,26)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (20,12)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (16,27)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (15,27)!
error   |08:07:43: [recvMultiPlayerRandomArtifacts] Already something at (15,25)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (15,23)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (16,24)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (16,23)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (16,21)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (16,25)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (15,23)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (15,24)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (15,25)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (8,11)!
error   |08:07:44: [recvMultiPlayerRandomArtifacts] Already something at (16,26)!
...

In a single player game (as in against AI) this is not reproducable, since AI doesn't pick up oil drums. So the exponential growth never gets started.

Note, the exact resoning to why the oildrums multiply is a guess. I might have it wrong. All I know is,

we reached peak oil!

;)
scnr


Issue migrated from trac:2174 at 2022-04-16 06:37:44 -0700

@wzdev-ci
Copy link
Contributor Author

CorvusCorax uploaded file 8c-CanyonHaos.wz (3.7 KiB)

cramped small crazy map that will likely trigger the oil drum bug aftre a while, when played 8 vs 8

@wzdev-ci
Copy link
Contributor Author

Buginator commented


(In [11675]) As a temporary solution, don't spawn more oil drums when you pick one up.

Will apply the patch that fixes the issue when I find it.

refs #2174

@wzdev-ci
Copy link
Contributor Author

Buginator changed status from new to closed

@wzdev-ci
Copy link
Contributor Author

Buginator changed resolution from `` to fixed

@wzdev-ci
Copy link
Contributor Author

Buginator commented


(In [11692]) Change spawning of oil drums to be host side, and also add a timer between spawn periods.

Fixes #2174

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant