Page 1 of 1

[FIXED 0.78.0] Accessory Bug + fix

Posted: Mon Jan 25, 2010 11:12 am
by Jay
It is possible to add the same accessory twice to a specific pawn. They have the same EntityName, and they have to be detached twice (i think). You will not see any difference in the game since they are at the exact same place (but i think they are rendered twice)

Since they should work like the pawn weapons did, they should only be able to be attached once.

A possible fix would be to replace the ATTACHACCESSORY case in CPawnHigh.cpp with

Code: Select all

case ATTACHACCESSORY:
	{
		geActor *MasterActor = NULL;
		std::string EntityName;
		if(!EffectC_IsStringNull(Object->Index->TriggerName))
		{
			EntityName = Object->Index->TriggerName;
			if(!stricmp(Object->Index->TriggerName, "Player"))
				MasterActor = CCD->Player()->GetActor();
			else
				MasterActor = CCD->ActorManager()->GetByEntityName(Object->Index->TriggerName);
		}
		else
		{
			EntityName = CCD->ActorManager()->GetEntityName(Object->Actor);
			MasterActor = Object->Actor;
		}
			
		if(MasterActor)
		{
			unsigned int keynum = AccessoryCache.size();
			if(keynum>0)
			{
				for(unsigned int i=0; i<keynum; i++)
				{
					if(!strcmp(AccessoryCache[i].Name.c_str(), Object->Index->AnimName))
					{
						EntityName += Object->Index->AnimName;
                    //Look if we already have this accessory
						geActor *SlaveActor = CCD->ActorManager()->GetByEntityName(EntityName.c_str());
						if(SlaveActor) //Pawn already has this accessory, don't add twice
							break;

						SlaveActor = CCD->ActorManager()->SpawnActor(AccessoryCache[i].ActorName, 
							Object->Location, AccessoryCache[i].Rotation, "", "", NULL);

						if(!SlaveActor)
							break;

						CCD->ActorManager()->SetEntityName(SlaveActor, EntityName.c_str());
										
						if(AccessoryCache[i].EnvironmentMapping)
							SetEnvironmentMapping(	SlaveActor, true,
								AccessoryCache[i].AllMaterial,
								AccessoryCache[i].PercentMapping,
								AccessoryCache[i].PercentMaterial);	
						CCD->ActorManager()->ActorAttachBlend(SlaveActor, MasterActor);
						break;
					}
				}
			}
		}
		Object->ActionActive = false;
		runflag = true;
		break;
	}
I could not test this code or even compile it since the c++ express 2008 setup does not work when i tried just now (can't connect to server???) on my 'new' old computer. The fix is about checking if the accessory is already there to not add it twice.

Re: Accessory Bug + fix

Posted: Sun Jul 17, 2011 11:30 am
by QuestOfDreams
Though I consider this to be at the responsibility of the scripter, we can try to make the code fool-proof, of course ... will add a check in next version.