Dangerous looking code

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Shiit

Shiit
Dec 19, 2000
168
0
0
I had some trouble using the Spawnnotify class to work right, because it totally screwed up in network games. Anyway, I've made the SpawnNotification function a simulated one, and it seemed to have fixed the problem. Now, I was wondering whether this code is safe to use, as it seems rather dangerous to me to replace objects client-side.
PHP:
simulated event Actor SpawnNotification(Actor A)
{
	local Actor B;

   if ( A.IsA('Translocator') && BLOwner.bATranslo && !A.IsA('BLTranslocator') )
   {
		B=Spawn(class'BLTranslocator',A.Owner,A.tag,A.Location, A.Rotation);
		if (B!=None)
			A.Destroy();
	}
   B=ReplaceWith(A, "WBalance.BLTranslocator");

	if (B!=None)
	{
		return B;
	}
	return A;
}

I've tested the code for a few seconds, and it seems fine, but I fear it might mess up when there's a weapon the client doesn't know about... Is this safe?
 

Papapishu

我是康
Jun 18, 2001
2,043
0
0
43
void
www.vovoid.com
Please, don't use the PHP hiliting... I cant see sheize...

I'm wondering about:
B=ReplaceWith(A, "WBalance.BLTranslocator");
Does it really work?
I thought the ReplaceWith was a function in the mutator class..


I would do like this:
Code:
simulated event Actor SpawnNotification( Actor A ) 
{
local BLTranslocator MyTL;
    
if ( A.IsA('Translocator') && !A.IsA('BLTranslocator') )
{
MyTL= Spawn(class'Project.BLTranslocator', A.Owner, A.Tag, A.Location, A.Rotation);

A.Destroy();
A = MyTL;
}
return A;
}

defaultproperties
{
     ActorClass=Class'Botpack.Translocator'
}

The actorclass defines a 'filter' for the classes processed, in this case only translocators...

Why don't you just use a mutator?
 

Shiit

Shiit
Dec 19, 2000
168
0
0
Oops! The ReplaceWith function wasn't supposed to be there at all. It is a function that I added for cleanness of code (in the real class there are lot of replaces) but wasn't necessary to show up here. I planned to remove it before copying and pasting it, but I forgot to.
Quite precisely, my class already does what you suggested. I suppose it's safe anyway, as I didn't encounter any problems... And if it isn't, it'll show up when I, or someone else does some heavier beta-testing.
BTW, I ám using a mutator, but replacing a translocator doesn't work in there like it should. It also won't work for any weapon/item that is given directly to the player (those items are spawned at location (0,0,0), and a mutator would delete it, check out the ReplaceWith function of the mutator)