Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » Syncing or changing BuildingGameObj 'IsDetroyed' state for clients
Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482894] Wed, 31 July 2013 17:00 Go to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Could support or a function be added to sync or change the IsDestroyed flag of a BuildingGameObj via the server? It's the only issue with properly working building revival. Of course this would only be supported by 4.0 clients.

[20:33:10] <iran> I was fixing up my building revival plugin and I got everything working now for maps without duplicate structures, one issue though:
[20:33:40] <iran> after reviving a building on the server the IsDestroyed flag is still set to true on clients unless they restart
[20:34:59] <iran> i ran the client under a debugger and I set BuildingGameObj offset 0x778 (which contains a IsDestroyed bool flag) to false on the hand after reviving it
[20:35:44] <iran> this allowed me to buy infantry again, but there is no way to set the IsDestroyed flag for clients via the server
[20:36:47] <iran> *hand of nod after reviving it
[20:37:14] <iran> the IsDestroyed flag not syncing with the server affects the follow things I've seen:
[20:37:32] <iran> 1. Can't buy from revived production facilities
 2. no death announcement is made for revived building (damage announcements still work)


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Wed, 31 July 2013 17:03]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482895 is a reply to message #482894] Thu, 01 August 2013 03:02 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
It has been a really long time since I did something with W3D coding but I was able to dig up some very old code:

void Set_Object_Dirty_Bit_All(BaseControllerClass *Base, DIRTY_BIT Bit, bool Set)
{
    for (int i = 1; i < 0x80; i++)
    {
        if (Set)
        {
            Base->DirtyBits[i] |= Bit;
        }
        else
        {
            Base->DirtyBits[i] &= ~Bit;
        }
    }
}

void Restore_Building(GameObject *obj)
{
    if (!Commands->Get_ID(obj) || !obj)
    {
        return;
    }
    GameObject *o = As_BuildingGameObj(obj);
    if (!o)
    {
        return;
    }
    char *c = (char *)obj;
    c += 0x778;
    bool *x = (bool *)c; //Is building destroyed bool
    *x = false; //Make it false

    BaseControllerClass *b = BaseControllerClass::Find_Base(Get_Object_Type(o));
    if (b && !Is_Building_Dead(obj)) 
    {
        if (Is_SoldierFactory(o))
        {
            b->CanGenerateSoldiers = true;
        }
        else if (Is_WarFactory(o) || Is_Airstrip(o))
        {
            b->CanGenerateVehicles = true;
        }
        else if(Is_PowerPlant(o))
        {
            b->IsPowered = true;
        }
        Set_Object_Dirty_Bit_All(b, DB_RARE, true);

        float max = Commands->Get_Max_Health(o);
        Commands->Set_Health(obj, max);
    }
}


I have no idea if this is still valid code for 4.0. The part that should sync the clients is the Set_Object_Dirty_Bit_All if I recall all of this correctly (and I didn't just dig up old broken code xD)


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Thu, 01 August 2013 03:07]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482896 is a reply to message #482894] Thu, 01 August 2013 05:04 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Did that work properly, e.g. could clients buy advanced infantry if they were in-game before say the Barracks was revived? With what I currently have after the barracks is revived players can't buy advanced infantry because the clients still think the Barracks is destroyed (unless they restart).

Can't say I've tried modifying the BaseControllerClass object.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Thu, 01 August 2013 05:05]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482897 is a reply to message #482894] Thu, 01 August 2013 05:35 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
This is what makes you able to purchase infantry and vehicles again. It used to anyway; as I said I don't know if this code still works with 4.0.

It worked with 3.4.4. You could just try it with 4.0 Big Ups

PS. If you do, let me know if the code still works Wink


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Thu, 01 August 2013 05:37]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482898 is a reply to message #482894] Thu, 01 August 2013 07:04 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
I tried it, doesn't seem to work. I'm using:

void Revive_Building(GameObject *Building)
{
	if (Building == nullptr ) return;
	if ( Is_Building_Dead(Building) == false ) return;

	int Team = ((DamageableGameObj*)Building)->Get_Player_Type();

	Restore_Building(Building);

	Building->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_CREATION, true);
	Update_Network_Object(Building);

	float max = Commands->Get_Max_Health(Building);
	Commands->Set_Health(Building, max);

	// This is needed to update the state of a building from 'dead' to 'alive on the client
	Update_Network_Object(Building);
	Commands->Apply_Damage(Building, 1.0f, "Explosive", 0);
	Update_Network_Object(Building);

	Commands->Apply_Damage(Building, 1.0f, "Explosive", 0); 
	Update_Network_Object(Building);

	if (Is_Base_Powered(Team)) { Commands->Set_Building_Power(Building, true); }
	else { Commands->Set_Building_Power(Building, false); }

	GameObject *Ref = Find_Refinery(Team);
	bool RefDead = Commands->Get_Health(Ref) == 0.0f;
	bool HarvDead = Commands->Get_Health(Find_Harvester(Team)) == 0.0f;

//	Console_Output("HarvDead = %d, HarvHealth = %f, RefDead = %d, Ref = %x, Harv = %x", HarvDead,  Commands->Get_Health(Find_Harvester(Team)),
//		RefDead, Ref, Find_Harvester(Team)); // DEBUG CRAP

	// Build a new Harvester if needed
	if ( HarvDead && !RefDead )
	{
		Request_New_Harvester(Team);
	}

	// Needed for re-initialisation and also updating the state of the buidling
	((BuildingGameObj*)Building)->Collect_Building_Components();
	Update_Network_Object(Building);

	Update_Building_State(Building, false);
	Update_Network_Object(Building);

	Initialize_Building(Building);
	Update_Network_Object(Building);

	auto c = BaseControllerClass::Find_Base(Team);
	c->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE, true);
	Update_Network_Object(c);
}


I call Restore_Building() which is a scripts 4.0 API function which does the following:

void SCRIPTS_API Restore_Building(GameObject* obj) 
{
	if (!obj) return;
	
	BuildingGameObj* building = obj->As_BuildingGameObj();
	if (!building || !building->Is_Destroyed())
		return;

	building->Set_Is_Destroyed(false);

	BaseControllerClass* base = BaseControllerClass::Find_Base(Get_Object_Type(building));
	if (base) 
	{
		if (building->As_SoldierFactoryGameObj())
			base->Set_Can_Generate_Soldiers(true);
		
		if (building->As_VehicleFactoryGameObj())
			base->Set_Can_Generate_Vehicles(true);
		
		base->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE, true);
	}
}



Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482899 is a reply to message #482894] Thu, 01 August 2013 08:24 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
Hmm it actually seems the restore building 4.0 function kinda does what I had in mine.
Sadly I'm seeing a lot of new functions in your code from which I have no idea what it does aside from an educated guess.

PS. I believe you should delete the BIT_CREATION. The Restore_Building already sets the BIT_RARE.
PSPS. I've never had to damage a building for it to sync with a client...

As I said it has been a very long time but based on my old code I would think it would be something like this in 4.0... :/
void Revive_Building(GameObject *Building)
{
	if (Building == nullptr || !Is_Building_Dead(Building)) return;

	Restore_Building(Building); //Scripts API call already sets BIT_RARE and I assume Set_Is_Destroyed does the 0x778 offset bool or something similar.

	float max = Commands->Get_Max_Health(Building);
	Commands->Set_Health(Building, max);

	//The remaining stuff; restore power, harvester, w/e
}


But I really have no idea why that wouldn't work tbh, sorry Huh
I'm almost 100% sure that old code I dug up used to work under 3.4.4. (I may have my files organized/archived but that doesn't mean I remember if it all worked for a 100% xD )


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Thu, 01 August 2013 08:27]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482903 is a reply to message #482894] Thu, 01 August 2013 09:24 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Yeah I should probably remove that BIT_CREATION, still working on the code.

I checked the Import_XXXX functions for BaseControllerClass and they only affect BaseControllerClass data members like "CanGenerateVehicles". This might have worked on 3.4.4 but I'm not sure. The PT code is a mess.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482912 is a reply to message #482894] Thu, 01 August 2013 18:32 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

In 4.0, I can state 2 things:
1.The PT code (for the standard stock PT at least) will NOT let you purchase an object unless the barracks/vehicle factory is still alive.
and 2.The building netcode will NOT let you toggle the "IsDestroyed" flag from "false" to "true" over the network at all no matter what you do.

So basically there is NO WAY to bring back vehicle/infantry purchasing in the stock logic.
As for making changes to scripts so it is possible, the answer is no, its NOT going to happen.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482913 is a reply to message #482894] Fri, 02 August 2013 00:17 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Why not make it possible? Should be easy right?

Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482914 is a reply to message #482894] Fri, 02 August 2013 00:30 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
I mean it's just a manual function to send a netcode command to clients telling them the network ID of the building and whether the IsDetroyed flag should be set to 'true' or 'false'. I don't really see the issue with that.

Why add support for building revival with the scripts.dll API command Restore_Building() when it doesn't work properly because of a tiny bug on the client? You could probably fix the bug on the client side too by setting IsDetroyed to false if the building health isn't 0.0f, somewhere in a Import_XXX function for the building, because the client still updates the health of the building even when the IsDestroyed flag is set.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482915 is a reply to message #482894] Fri, 02 August 2013 00:42 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Restore_Building is probably intended for use with the APB/AR/TSR stuff that disables the functionality of buildings without destroying them.

http://steamsignature.com/card/1/76561197975867233.png
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482916 is a reply to message #482894] Fri, 02 August 2013 02:04 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
I checked the game's code and saw it exports and imports the IsDstroyed flag in BuildingGameObj::Import_Rare() and BuildingGameobj::Export_Rare(). However when importing it only calls BuildingGameObj::On_Destroyed() when the servers sends that the BuildingGameObj IsDetroyed is true and when on the client it's still alive (IsDetroyed set to false). I fixed the issue with building revival by setting the IsDestroyed on the client to what the server sends after that code (at the end of the function).

Here's my memory patched client code for TT's BuildingGameObj::Import_Rare(), using the space for alignment to add my patch:

561A8A63   84DB             TEST BL,BL // contains IsDestroyed sent by server
561A8A65   74 17            JE SHORT tt.561A8A7E // if false jump past this code to Out
561A8A67   80BE 70070000 00 CMP BYTE PTR DS:[ESI+770],0 // Check client IsDetroyed
561A8A6E   75 0E            JNZ SHORT tt.561A8A7E // if IsDestroyed is true jump to Out, only execute the below call if false
561A8A70   8B56 F8          MOV EDX,DWORD PTR DS:[ESI-8]
561A8A73   8B82 94000000    MOV EAX,DWORD PTR DS:[EDX+94]
561A8A79   8D4E F8          LEA ECX,DWORD PTR DS:[ESI-8]
561A8A7C   FFD0             CALL EAX // call BuildingGameObj::On_Destroyed()

// Out:
561A8A7E   889E 70070000    MOV BYTE PTR DS:[ESI+770],BL // I memory patched this in, this sets client IsDetroyed with what server sends
561A8A84   90               NOP
561A8A85   90               NOP
561A8A86   90               NOP
561A8A87   5F               POP EDI // Normal epilogue
561A8A88   5E               POP ESI
561A8A89   5B               POP EBX
561A8A8A   8BE5             MOV ESP,EBP
561A8A8C   5D               POP EBP
561A8A8D   C2 0400          RETN 4



So the issue can be fixed by 4.0 by patching BuildingGameObj::Import_Rare() to set the client IsDestroyed flag with what the server sends at the end of the function.

Note that the IsDestroyed offset is BuildingGameObj + 0x770, NOT 0x778 like I previously thought. The offset seems to be diffeerent between server versions and they handle Import_Rare() and Export_Rare() a bit differently.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Fri, 02 August 2013 02:08]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482917 is a reply to message #482894] Fri, 02 August 2013 02:27 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Okay so apparently jonwil doesn't want to add this fix cause it fixes the bug and would cause the state of the client to be different from players without this fix. Even though this fix is the equivalent of rejoining a server after a building has been revived. And even though stuff like vlimit and Commands->Enable_Stealth() are also fixed for scripts clients and so have a different state from stock clients.

Neutral


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482923 is a reply to message #482894] Fri, 02 August 2013 05:02 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
D:

I think it's time to get 4.0 to become an official/required patch for everyone. How are the possibilities of making it an official patch like 1.037?
If we're limiting fixes because the client states would become different it is time to make it so tbh.


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Fri, 02 August 2013 05:06]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #482932 is a reply to message #482923] Sat, 03 August 2013 01:00 Go to previous messageGo to next message
EvilWhiteDragon is currently offline  EvilWhiteDragon
Messages: 3751
Registered: October 2005
Location: The Netherlands
Karma: 0
General (3 Stars)

Omar007 wrote on Fri, 02 August 2013 14:02

D:

I think it's time to get 4.0 to become an official/required patch for everyone. How are the possibilities of making it an official patch like 1.037?
If we're limiting fixes because the client states would become different it is time to make it so tbh.

Trust me, we're trying.


http://www.blackintel.org/usr/evilwhitedragon/pointfix.gif
BlackIntel admin/founder/PR dude (not a coder)
Please visit http://www.blackintel.org/

V, V for Vendetta

People should not be afraid of their governments.
Governments should be afraid of their people.
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #484531 is a reply to message #482932] Thu, 21 November 2013 15:05 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
EvilWhiteDragon wrote on Sat, 03 August 2013 02:00

Omar007 wrote on Fri, 02 August 2013 14:02

D:

I think it's time to get 4.0 to become an official/required patch for everyone. How are the possibilities of making it an official patch like 1.037?
If we're limiting fixes because the client states would become different it is time to make it so tbh.

Trust me, we're trying.


Try harder D:


http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #484532 is a reply to message #482894] Thu, 21 November 2013 15:21 Go to previous messageGo to next message
BAGUETTE is currently offline  BAGUETTE
Messages: 620
Registered: June 2010
Karma: 0
Colonel
Yea get DJ on behalf of the renegade community to put forward the idea!

Quote:

Ramb8(to RamBonerUpAss) fuk u big ashole u a big jakass i stick my ramboner up u as

http://i97.photobucket.com/albums/l234/Vultima/hue.png

Crush gives away med tanks like he gives away handjobs, everyday and as much as possible
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #487477 is a reply to message #482894] Sat, 03 May 2014 13:38 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
I know this has been a while since this topic was active but I strongly feel that the next maintenance patch needs to address this. While the reasons for not patching it was that it would make the clients destroyed state different for those running scripts and those that don't, at the moment it is actually far more fragmented. Clients that join after the restore have the destroyed flag set to false while those who were ingame prior will have the destroyed flag set to true, even those on the latest scripts, which on many servers is the vast majority, especially ones that make use of the advanced features like building restores where 4.0 and above is actually mandatory. Overall this would fix a ton of issues regarding building restores such as proper factory restores, but also fix the broken death announcements that happen on all buildings. Fixing this client side would ensure that all clients running the latest scripts would have the same building state, where as today even players on the same scripts versions can have differing building states. Being able to properly restore factories would also encourage those who are on old versions of scripts to upgrade as well reducing the number of cheaters who use old versions of scripts that are still susceptible to hacks. I see this as a win for all players. I'd much rather see 98% or so percent of the clients have the same building destroyed state than the current mishmash of destroyed states that the current situation has.

[Updated on: Sat, 03 May 2014 13:50]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #487481 is a reply to message #482894] Sat, 03 May 2014 16:46 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
We have never supported nor had plans to support building controllers transitioning from dead back to alive, the engine is not designed to support it and anyone attempting to jury rig it on their own servers are on their own as far as support is concerned...

http://steamsignature.com/card/1/76561197975867233.png
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #487482 is a reply to message #487481] Sat, 03 May 2014 17:46 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
Except it has been proven again and again that it does work with very minimal modifications. There are a lot of things that the engine didn't support originally that were added by scripts both client and server side. I don't understand the resistance to this idea. Its not like we don't know how to fix it. We do. That parts all done. The only thing needed is to merge it and send it out as part of an upcoming patch.

[Updated on: Sat, 03 May 2014 17:49]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #487483 is a reply to message #487482] Sat, 03 May 2014 17:56 Go to previous messageGo to next message
Ethenal is currently offline  Ethenal
Messages: 2532
Registered: January 2007
Location: US of A
Karma: 0
General (2 Stars)

dblaney1 wrote on Sat, 03 May 2014 19:46

Except it has been proven again and again that it does work with very minimal modifications.

Where? I don't know about you, but I've never seen any proof of this.


-TLS-DJ-EYE-K wrote on Mon, 18 March 2013 07:29

Instead of showing us that u aren't more inteligent than a Toast, maybe you should start becomming good in renegade Thumbs Up

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #487484 is a reply to message #487483] Sat, 03 May 2014 18:02 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
The Original poster of this thread released tweaked client side dll's that synced the destroyed flag as described in this thread. The method of how to patch it is also described in this thread. I just don't see a reason to not add support for this. It would add a lot of possibilities for modders and server operators alike. I don't see any downside to having more consistent clients states either. Hopefully Iranian sees this and can provide you with a 4.1 patched version. The one I found was for 4.0. If someone can tell me where the function mentioned about half way down this page has moved to in 4.1 i'll gladly patch it myself and show you that way. If we had this response to every change made by scripts so far we wouldn't have higher vehicle limits, commands->enable_stealth, and many other things. I am thankful for everything this community has done.

[Updated on: Sat, 03 May 2014 18:08]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #487485 is a reply to message #482894] Sun, 04 May 2014 02:25 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
To find the function epilogue to patch open Renegade and attach OllyDbg, make sure Renegade is already in the main menu. in OllyDbg go to 0x006843E0 then follow the jump at the location. The new scripts 4.1 uses SSE heavily so the instructions for functions look kinda weird. Scroll up to find this kind of pattern at a function prologue:

ORIGINAL RENEGADE CODE AS EXAMPLE, THE TT CODE LOOKS DIFFERENT BUT ACTS THE SAME:

mov     al, [esp+20h+var_11]
test    al, al
jz      short loc_68431E
mov     al, [ebx+770h]
test    al, al
jnz     short loc_68431E
mov     edx, [ebx-8]
lea     ecx, [ebx-8]
call    dword ptr [edx+94h]


pop     edi
pop     esi
pop     ebx
add     esp, 14h
retn    4


All you really need is to find the check with 0x770 and a virtual function call to edx+0x94. Patch the epilogue so offset 0x770 is given the content of the byte stack variable that is tested for zero before the test for 0x770 being tested for zero in the code above. In this case:

mov     al, [esp+20h+var_11]
test    al, al


Happens before:

jz      short loc_68431E
mov     al, [ebx+770h]


So the epilogue needs to be patched so that offset 0x770 is updated with the content of [esp+20h+var_11].

Use OllyDbg to patch the epilogue in memory. then select and copy the patched instructions and save them somewhere. Undo these memory patches (select the patches and right click -> Undo Selection) then open bandtest.dll with a hex editor, then find the epilogue in of the function in your hex editor by searching for the instruction bytes for the original epilogue (obviously make sure you find the correct one so check if there are multiple matches in the hex editor), replace the original epilogue instruction bytes with the instruction bytes have written down for your modified one. It might also be possible to just memory patch with OllyDbg and use the 'copy to executable' command.

Instruction bytes look like this:

64E016C9   8B7424 14        MOV ESI,DWORD PTR SS:[ESP+14]
64E016CD   8A46 0B          MOV AL,BYTE PTR DS:[ESI+B]
64E016D0   8886 70070000    MOV BYTE PTR DS:[ESI+770],AL
64E016D6   5F               POP EDI
64E016D7   5E               POP ESI
64E016D8   5B               POP EBX
64E016D9   83C4 14          ADD ESP,14
64E016DC   C2 0400          RETN 4
64E016DD   CC               INT3


The "8B7424 14" on the first line are 4 bytes for the instruction on the right of the line, "8A46 0B" on the second line are 3 bytes for the instruction on the right of that line etc.

Once done load up the game with the hex edited bandtest.dll and find the epilogue for the BuildingClass::Import_Rare() function again and check if your hex edits match the patched code your wrote down earlier, the code patches you applied with a hex editor.


I've attached a patched bandtest.dll, I have NOT checked if it works correctly with building revival. If the game crashes during startup or just after joining a server the file is incompatible with your version of 4.1.


  • Attachment: bandtest.zip
    (Size: 1.26MB, Downloaded 127 times)


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Sun, 04 May 2014 02:27]

Report message to a moderator

Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #487486 is a reply to message #482894] Sun, 04 May 2014 06:30 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
The thing is that the tt is just worried it will cause more problems than it will solve, due to the fact that working with netcode is bug sensitive. I think...
Re: Syncing or changing BuildingGameObj 'IsDetroyed' state for clients [message #487487 is a reply to message #482894] Sun, 04 May 2014 09:02 Go to previous messageGo to previous message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Breaking the lifecycle contract of a GameObject is incredibly dangerous and, whilst it might work in limited test cases, you fail to see the wider implications.

All GameObjects have a guarunteed lifecycle whereby they transition from Created -> Destroyed, usually via Killed unless removed from the level by a script or other event. Scripts attached to that object are free to make the assumption that they can clean up resources once Killed or Destroyed are called. Subsequently causing that GameObject to be alive again and triggering Damaged events or another Killed / Destroyed event in this case would cause that script to be in an invalid state and could result in a crash.

This is one of many resons why transitioning ANY object from Destroyed back to a "live" state will NEVER be officially supported.

The only valid way to do this is to instantiate an entirely new GameObject instance... and it is not possible to create building controllers at run time because they are part of the level static data.


http://steamsignature.com/card/1/76561197975867233.png
Previous Topic: Trouble downloading scripts
Next Topic: Can't see player names anymore?
Goto Forum:
  


Current Time: Tue Nov 26 23:28:44 MST 2024

Total time taken to generate the page: 0.01311 seconds