community attempt at multiplayer

Programming Reality Factory and Genesis3D.
Post Reply
User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas »

Are you replacing mfc's with widgets? I've never gotten to play around with mfc's so I have no clue what they even are. :lol: But I can give it a shot, and see what happends. :?
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

MFC = MicrosoftFoundationClasses - a set of classes that work together building a windows programm similar like a game engine which has many classes that work together as a game.

The interesting part about MFC is that you don't need ANY main()/WinMain()-function for your program to work because this is all written inside the mfc. I found this rather confusing because i didn't know what my program was doing so i have ended to use them - when i program for windows, i normally just use the normal windows API, which i find much more logical.
Everyone can see the difficult, but only the wise can see the simple.
-----
User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas »

ah so we can replace mfc's with widgets possibly. With a whole lot of work ;-).


[edit sorry about the double post evidentually when posting it I didn't press stop fast enough so It ended up making a double post out of my change :oops: and now it won't let me delete it.
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack
Lord_Garfield
Posts: 2
Joined: Thu Nov 16, 2006 7:39 am

Networking classes

Post by Lord_Garfield »

hi all,

Are you guys trying to create a networking class for RF?

Maybe you should try one of the existing onces.

http://www.gillius.org/gne/

partily uses
hawknl http://www.hawksoft.com/hawknl/

Maybe it can help a bit.

good luck
User avatar
scott
Posts: 1151
Joined: Tue Jul 05, 2005 1:59 am
Location: United Kingdom

Post by scott »

as there are alot of posts for this topic i understand if you didnt read them all, we have multiplayer working to an extent, we can connect to each other and see each other, the size of oponents arnt right, other entities are not working to well yet and we dont have a damage system in operation to damage the oponents, but what we do have is we can see each other move around so implemntation of the network is in place and seems to be stable, i dont belive that when jonas tested it he didnt disconect from each other due to problems, but keep in mind this was over a network so the 'ping' (time to transmit data to a computer and get it returned) would be very low with very high bandwidth due to the nature of networks.

and just a thought, i dont know if any one still talks on the genesis forum at all but sins the network i belive was created in genesis and was just moved to reality factory, is there anyone on that forum who have succesfuly got multiplayer going that we could have?just a thought.
*GD*
User avatar
scott
Posts: 1151
Joined: Tue Jul 05, 2005 1:59 am
Location: United Kingdom

Post by scott »

quote from federico
I think I could implement multiplayer of my old chess game using these numbers...).
would you be able to use this test to do what u suggest, i cant think of much we have missed, may be a little more complicated that implementing network chess code but woud you be able to help?

as with your water tutorial i think that this could become an exelent engine despite its age.
*GD*
User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas »

scott wrote: i dont belive that when jonas tested it he didnt disconect from each other due to problems, but keep in mind this was over a network so the 'ping' (time to transmit data to a computer and get it returned) would be very low with very high bandwidth due to the nature of networks.
I did try disconnecting each machine, neither pc detected it. I must have forgot to mention that.

I'm wondering if it would be possible to make an external program that would sync data. Just as sort of a work around intill Quest get finished since we can't modify the code.
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack
revolutiongames2004
Posts: 75
Joined: Tue Jul 05, 2005 4:29 pm

Post by revolutiongames2004 »

is the system confusing the variables? ex. health = health, but health!=health?
User avatar
scott
Posts: 1151
Joined: Tue Jul 05, 2005 1:59 am
Location: United Kingdom

Post by scott »

thats a good point... i dont know how RF calculates the projectiles, im thinking its collision detection, meaining a projectile has to have mass, to colide with something, or is it when the trigger is pressed teh thing it was aiming at is hit with no actual bullet?

if it is a projectile with its mass hitting an object, can each other see the projectiles. the easisest way to find this out i would belive is to get a flame thrower or a grenade launcher and see if both computers can see the flames/explosion

this is just a shot in the dark as i dont know exactly how RF uses the weapons, i would of thought it was a projectile hitting an object but then i have herd nothing of needing to make a projectile for a gun.
*GD*
User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas »

scott wrote:thats a good point... i dont know how RF calculates the projectiles, im thinking its collision detection, meaining a projectile has to have mass, to colide with something, or is it when the trigger is pressed teh thing it was aiming at is hit with no actual bullet?

if it is a projectile with its mass hitting an object, can each other see the projectiles. the easisest way to find this out i would belive is to get a flame thrower or a grenade launcher and see if both computers can see the flames/explosion

this is just a shot in the dark as i dont know exactly how RF uses the weapons, i would of thought it was a projectile hitting an object but then i have herd nothing of needing to make a projectile for a gun.
In my test I was unable to see any gun's projectile or flame.

From this Code it looks like its a model file. (to bad phpbb forums don't include the expandable and collapsing code feature.)

Code: Select all

void CWeapon::Add_Projectile(const geVec3d &Pos, const geVec3d &Front, const geVec3d &Orient, 
							 char *Projectile, char *PAttribute, char *PAltAttribute)
{
	Proj *d;
	int Type = -1;	

	for(int i=0; i<MAX_PROJD; i++)
	{
		if(ProjD[i].active)
		{
			if(!stricmp(ProjD[i].Name, Projectile))
			{
				Type = i;
				break;
			}
		}
	}
	
	if(Type == -1)
		return;

	if(ProjD[Type].active)
	{
		geXForm3d XForm;
		d = new Proj;
		
		d->Rotation = ProjD[Type].Rotation;
		d->Angles = Orient;
		d->Pos = Pos;
		d->Gravity = ProjD[Type].Gravity;
		d->LifeTime = ProjD[Type].LifeTime;
		d->Bounce = ProjD[Type].Bounce;
		d->BounceSoundDef = NULL;
		
		if(!EffectC_IsStringNull(ProjD[Type].BounceSound))
			d->BounceSoundDef = SPool_Sound(ProjD[Type].BounceSound);
		
		d->MoveSoundDef = NULL;
		
		if(!EffectC_IsStringNull(ProjD[Type].MoveSound))
			d->MoveSoundDef = SPool_Sound(ProjD[Type].MoveSound);
		
		d->ImpactSoundDef = NULL;
		
		if(!EffectC_IsStringNull(ProjD[Type].ImpactSound))
			d->ImpactSoundDef = SPool_Sound(ProjD[Type].ImpactSound);
		
		d->MoveSoundEffect = PlaySound(d->MoveSoundDef, d->Pos, true);
		d->Decal = ProjD[Type].Decal;
		d->Explosion = ProjD[Type].Explosion;
		d->ActorExplosion = ProjD[Type].ActorExplosion;
// changed RF064
		d->ShowBoth = ProjD[Type].ShowBoth;
		d->AttachActor = ProjD[Type].AttachActor;
		d->BoneLevel = ProjD[Type].BoneLevel;
// end change RF064
		d->ShakeAmt = ProjD[Type].ShakeAmt;
		d->ShakeDecay = ProjD[Type].ShakeDecay;
		d->Damage = ProjD[Type].Damage;
// changed RF063
		d->AltDamage = ProjD[Type].AltDamage;
		d->AltAttribute = PAltAttribute;
// end change RF063
		d->RadiusDamage = ProjD[Type].RadiusDamage;
		d->Radius = ProjD[Type].Radius;
		d->Attribute = PAttribute;
		d->Name = ProjD[Type].Name;

		// changed QD 12/15/05
		//geXForm3d_SetIdentity(&XForm);
		//geXForm3d_RotateZ(&XForm, Orient.Z);
		geXForm3d_SetZRotation(&XForm, Orient.Z);
		geXForm3d_RotateX(&XForm, Orient.X);
		geXForm3d_RotateY(&XForm, Orient.Y);		
		//geVec3d_Set(&XForm.Translation, Pos.X, Pos.Y, Pos.Z);

		geXForm3d_GetIn(&XForm, &(d->Direction));
		geVec3d_Scale(&(d->Direction), ProjD[Type].Speed, &(d->Direction));
		
		//geXForm3d_SetIdentity(&XForm);
		// geXForm3d_RotateX(&XForm, 0.0f);  
		// geXForm3d_RotateY(&XForm, (-90.0f) / 57.3f);  
		geXForm3d_SetYRotation(&XForm, -GE_PIOVER2); 
		// geXForm3d_RotateZ(&XForm, 0.0f); 
		// end change
		geXForm3d_GetIn(&XForm, &(d->In));
		geVec3d_Inverse(&(d->In));
		
		d->Actor = CCD->ActorManager()->SpawnActor(ProjD[Type].Actorfile, 
			d->Pos, d->Rotation, ProjD[Type].ActorAnimation, ProjD[Type].ActorAnimation, NULL);
		
		CCD->ActorManager()->Rotate(d->Actor, d->Angles);
		CCD->ActorManager()->SetType(d->Actor, ENTITY_PROJECTILE);
		CCD->ActorManager()->SetScale(d->Actor, ProjD[Type].Scale);
		CCD->ActorManager()->SetBoxChange(d->Actor, false);
		CCD->ActorManager()->SetNoCollide(d->Actor);
		CCD->ActorManager()->SetBBox(d->Actor, ProjD[Type].BoxSize, ProjD[Type].BoxSize, ProjD[Type].BoxSize);
		CCD->ActorManager()->GetBoundingBox(d->Actor, &d->ExtBox);
		CCD->ActorManager()->SetStepHeight(d->Actor, -1.0f);
// changed RF064
		CCD->ActorManager()->SetHideRadar(d->Actor, true);
// end change RF064

		if(d->Gravity)
			CCD->ActorManager()->SetGravity(d->Actor, CCD->Player()->GetGravity());
		
		GE_Collision	Collision;
		CCD->Collision()->IgnoreContents(false);
		CCD->Collision()->CheckLevel(RGF_COLLISIONLEVEL_1);
		char BoneHit[64];
		BoneHit[0] = '\0';
	
		if(CCD->Collision()->CheckForBoneCollision(&d->ExtBox.Min, &d->ExtBox.Max,
				Front, d->Pos, &Collision, d->Actor, BoneHit, d->BoneLevel))
		{
			int nHitType = CCD->Collision()->ProcessCollision(Collision, d->Actor, false);

			if(nHitType != kNoCollision)
			{
				if(d->MoveSoundEffect != -1)
					CCD->EffectManager()->Item_Delete(EFF_SND, d->MoveSoundEffect);
				
				PlaySound(d->ImpactSoundDef, d->Pos, false);
				
				// inflict damage
// changed RF063				
				if(Collision.Actor)
					CCD->Damage()->DamageActor(Collision.Actor, d->Damage, d->Attribute, d->AltDamage, d->AltAttribute, d->Name);
				
				if(Collision.Model)
					CCD->Damage()->DamageModel(Collision.Model, d->Damage, d->Attribute, d->AltDamage, d->AltAttribute);
// end change RF063				
				
				// create explosion here
// changed RF063				
				CCD->Explosions()->AddExplosion(d->Explosion, d->Pos);

				if(d->ShakeAmt>0.0f)
					CCD->CameraManager()->SetShake(d->ShakeAmt, d->ShakeDecay, d->Pos);
				
				if(Collision.Actor)
// changed RF063
					CCD->Explosions()->AddExplosion(d->ActorExplosion, d->Pos);
								
				// Handle explosion damage here
				if(d->RadiusDamage > 0.0f)
				{
// changed RF063
					CCD->Damage()->DamageActorInRange(d->Pos, d->Radius, d->RadiusDamage, d->Attribute, d->RadiusDamage, d->AltAttribute, "Explosion");
					CCD->Damage()->DamageModelInRange(d->Pos, d->Radius, d->RadiusDamage, d->Attribute, d->RadiusDamage, d->AltAttribute);
// end change RF063
				}

				CCD->ActorManager()->RemoveActor(d->Actor);
				geActor_Destroy(&d->Actor);
				delete d;
				return;
			}
		}
		
		for(int i=0; i<5; i++)
		{
			d->Effect[i] = -1;
			geXForm3d thePosition;
	
			if(EffectC_IsStringNull(ProjD[Type].EffectBone[i]))
				geActor_GetBoneTransform(d->Actor, RootBoneName(d->Actor), &(thePosition));
			else
			{
				if(!geActor_GetBoneTransform(d->Actor, ProjD[Type].EffectBone[i], &(thePosition)))
					geActor_GetBoneTransform(d->Actor, RootBoneName(d->Actor), &(thePosition));
			}
			
			if(ProjD[Type].Effect[i][0] != '\0')
			{
				for(int k=0; k<MAXEXPITEM; k++)
				{
					if(CCD->Effect()->EffectActive(k))
					{
						if(!stricmp(ProjD[Type].Effect[i], CCD->Effect()->EffectName(k)))
						{
							geVec3d Zero = {0.0f, 0.0f, 0.0f};
							d->Effect[i] = CCD->Effect()->AddEffect(k, thePosition.Translation, Zero);
							d->EffectType[i] = CCD->Effect()->EffectType(k);
							d->EffectBone[i] = ProjD[Type].EffectBone[i];
							break;
						}
					}
				}
			}
		}
		
		d->next = NULL;
		d->prev = Bottom;

		if(Bottom != NULL)
			Bottom->next = d;
		
		Bottom = d;
		return;
	}
}
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack
User avatar
AndyCR
Posts: 1449
Joined: Wed Jul 06, 2005 5:08 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

yes, it is an actor. by default it is proj.act with most of the guns that ship with rf, i -think-.
User avatar
scott
Posts: 1151
Joined: Tue Jul 05, 2005 1:59 am
Location: United Kingdom

Post by scott »

i went through the multiplayer code last night, got one question within the code it has ' CCD-> ' what does that mean exactly

i think i have found out the problem, im not sure as i am no programmer but just using a bit of logic.

Code: Select all

BuildPlayer
//
//	put player info into buffer
/* ------------------------------------------------------------------------------------ */
void NetPlayerMgr::BuildPlayer(NetBuffer *Buff, int index, int Id)
{
	Buff->Add(Id);
	Buff->AddString(Player[index]->ActorName, strlen(Player[index]->ActorName));
	Buff->Add(Player[index]->BaseRotation);
	Buff->Add(Player[index]->localRotation);
	Buff->Add(Player[index]->localTranslation);
	Buff->AddString(Player[index]->Animation, strlen(Player[index]->Animation));
	Buff->Add(Player[index]->AnimTime);
	Buff->AddLen();
thats the only thing going into the players buffer, these are the only thing sthat are updated

another problem i can see is as RF is expanding all the while with new entities and such, and this is where the other actors such as the enemy arnt shown is that the list of things that are global needs updating to

Code: Select all

SendWorldInfo
//
//	send info about current world to socket
/* ------------------------------------------------------------------------------------ */
void NetPlayerMgr::SendWorldInfo(NetBuffer *Buff, NLsocket sock)
{
	int j = 0;

	// send info about clients
	Buff->PosBack(0);
	Buff->Add(1);
	Buff->Add((unsigned char)CLIENTLIST);

	for(int i=0; i<MAXPLAYERS; i++)
	{
		if(Player[i])
		{
			BuildPlayer(Buff, i, Player[i]->GetId());
			j++;
		}
	}

	Buff->Add(-1);
	Buff->AddLen();
	nlWrite(sock, Buff->Data, Buff->Size);

	// send info about rest of world here
	outbuffer->PosBack(0);
	outbuffer->Add(1);
	outbuffer->Add((unsigned char)WORLDLIST1);

	CCD->Doors()->SaveTo(NULL, true);
	CCD->Platforms()->SaveTo(NULL, true);
	CCD->Props()->SaveTo(NULL, true);
	CCD->Teleporters()->SaveTo(NULL, true);
	CCD->Triggers()->SaveTo(NULL, true);
	CCD->Logic()->SaveTo(NULL, true);
	
	outbuffer->AddLen();
	
	nlWrite(sock, outbuffer->Data, outbuffer->Size);

	outbuffer->PosBack(0);
	outbuffer->Add(1);
	outbuffer->Add((unsigned char)WORLDLIST2);
	
	CCD->Attributes()->SaveTo(NULL, true);
	CCD->Damage()->SaveTo(NULL, true);
	CCD->ElectricEffects()->SaveTo(NULL, true);
	CCD->ModelManager()->SaveTo(NULL, true);
	
	outbuffer->AddLen();
	nlWrite(sock, outbuffer->Data, outbuffer->Size);

	// total # of packets sent is defined by CONNECTIONPACKETS
	// currently is 4

	// send done connecting command
	Buff->PosBack(0);
	Buff->Add(1);
	Buff->Add((unsigned char)DONECONNECT);
	Buff->AddLen();
	nlWrite(sock, Buff->Data, Buff->Size);
}
these are the global things that it updates, thus no actors.

im no programmer but from this i belive that if someone was to spend a little time updating it, this would work
*GD*
User avatar
federico
RF Dev Team
Posts: 443
Joined: Tue Jul 05, 2005 3:14 pm
Contact:

Post by federico »

"CCD->" means "CCommonData", I think.
User avatar
scott
Posts: 1151
Joined: Tue Jul 05, 2005 1:59 am
Location: United Kingdom

Post by scott »

ok thank you, what do you think federico? am i correct in identifying the code, could a programmer like you add a few more feilds to this or is it more complicated?
*GD*
User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas »

Yes your right its not sending the data for projectiles over the net.
I don't believe this would be all that hard we are just missing the required tools. Just have it gather and send a little more info over the net, and multiplayer would be pretty close to complete.
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack
Post Reply