Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » EncyclopediaMgrClass
EncyclopediaMgrClass [message #492628] Wed, 01 November 2017 06:08 Go to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
While working on something else to set my mind of singleplayer code, I needed access to EncyclopediaMgrClass. I found out that you guys do not have the source for that since you are jumping to the function in game2.exe.

So here's the complete code to make EncyclopediaMgrClass work (Commented out some stuff I don't have source for, but you guys do):

vector.h
Toggle Spoiler


vector.cpp
Toggle Spoiler


encyclopedia.h
Toggle Spoiler


encyclopedia.cpp
Toggle Spoiler
Re: EncyclopediaMgrClass [message #492636 is a reply to message #492628] Fri, 03 November 2017 01:07 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
Some extra comment:

- I believe init in BooleanVectorClass has another version of the function where array is not a constant. (I forgot to add this, but exact same function body though)

- I know Get_Bit/Set_Bit/First_True_Bit/First_False_Bit are not actually inside BooleanVectorClass, but they aren't used anywhere else and it seems like more sense to put them in the class. In-fact, First_True_Bit and First_False_Bit aren't used at all. (What I mean by not being used: nowhere in the entire binary is there a reference to it).

I hope TT gets their environment up again, so this might be added to the tt binary.

[Updated on: Fri, 03 November 2017 01:08]

Report message to a moderator

Re: EncyclopediaMgrClass [message #492637 is a reply to message #492628] Fri, 03 November 2017 01:27 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

What exactly are you doing with EncyclopediaMgrClass and what bits of it do you need? Do you just need to be able to call into it or do you need to actually make changes to how it works?


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: EncyclopediaMgrClass [message #492638 is a reply to message #492637] Fri, 03 November 2017 02:24 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
jonwil wrote on Fri, 03 November 2017 01:27

What exactly are you doing with EncyclopediaMgrClass and what bits of it do you need? Do you just need to be able to call into it or do you need to actually make changes to how it works?



Neither, I need to know when Reveal_Object(TYPE type, int classId) is called. And apparently the compiler optimized it sometimes to not actually call it. So I needed direct access to KnownObjectVector and the layout of that array is basically the entire workings of EncyclopediaMgrClass. So I was like: Might as well reverse engineer the entire thing while I'm at it.
Re: EncyclopediaMgrClass [message #492639 is a reply to message #492628] Fri, 03 November 2017 02:41 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

Any reason you cant just use EncyclopediaMgrClass::Is_Object_Revealed instead of doing all that stuff with direct access to KnownObjectVector etc?

As for the inlined copies of Reveal_Object(TYPE,int), there is only one and its inlined into EncyclopediaMgrClass::Reveal_Object(DamageableGameObj *) so you could hook that alongside Reveal_Object(TYPE,int) if you wanted to.

Either option would be much easier than messing with the entire EncyclopediaMgrClass source (and BooleanVectorClass and etc)


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: EncyclopediaMgrClass [message #492640 is a reply to message #492628] Fri, 03 November 2017 02:45 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

And in case it helps, here is a clone of Reveal_Object(DamageableGameObj *)

bool EncyclopediaMgrClass::Reveal_Object(DamageableGameObj *object)
{
	bool b = false;
	if (object)
	{
		if (cGameType::GameType == 1)
		{
			int type = object->Get_Definition().Get_Encyclopedia_Type();
			int id = object->Get_Definition().Get_Encyclopedia_ID();
			if (type != -1)
			{
				if (!Is_Object_Revealed((TYPE)type,id))
				{
					Display_Event_UI();
				}
				b = Reveal_Object((TYPE)type,id);
			}
		}
	}
	return b;
}


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: EncyclopediaMgrClass [message #492641 is a reply to message #492639] Fri, 03 November 2017 02:47 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
jonwil wrote on Fri, 03 November 2017 02:41

Any reason you cant just use EncyclopediaMgrClass::Is_Object_Revealed instead of doing all that stuff with direct access to KnownObjectVector etc?

As for the inlined copies of Reveal_Object(TYPE,int), there is only one and its inlined into EncyclopediaMgrClass::Reveal_Object(DamageableGameObj *) so you could hook that alongside Reveal_Object(TYPE,int) if you wanted to.

Either option would be much easier than messing with the entire EncyclopediaMgrClass source (and BooleanVectorClass and etc)



Well I need to know if any object is revealed. And yes I could hook both and I am going to. But i realized that after I did all this.
Re: EncyclopediaMgrClass [message #492642 is a reply to message #492640] Fri, 03 November 2017 02:48 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
jonwil wrote on Fri, 03 November 2017 02:45

And in case it helps, here is a clone of Reveal_Object(DamageableGameObj *)

bool EncyclopediaMgrClass::Reveal_Object(DamageableGameObj *object)
{
	bool b = false;
	if (object)
	{
		if (cGameType::GameType == 1)
		{
			int type = object->Get_Definition().Get_Encyclopedia_Type();
			int id = object->Get_Definition().Get_Encyclopedia_ID();
			if (type != -1)
			{
				if (!Is_Object_Revealed((TYPE)type,id))
				{
					Display_Event_UI();
				}
				b = Reveal_Object((TYPE)type,id);
			}
		}
	}
	return b;
}



Thats pretty much copy paste of what I have posted in my first post Smile
Re: EncyclopediaMgrClass [message #492643 is a reply to message #492628] Fri, 03 November 2017 03:08 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

Its actually a copy & paste of our clone of that function that we have elsewhere in our codebase Smile


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: EncyclopediaMgrClass [message #492644 is a reply to message #492643] Fri, 03 November 2017 03:12 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
jonwil wrote on Fri, 03 November 2017 03:08

Its actually a copy & paste of our clone of that function that we have elsewhere in our codebase Smile



Oh so you do have the code reverse engineered already elsewhere? Or just that function? Im curious how I did on the BooleanVectorClass. It should be proper
Re: EncyclopediaMgrClass [message #492645 is a reply to message #492636] Fri, 03 November 2017 12:02 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Neijwiert wrote on Fri, 03 November 2017 01:07

Some
(What I mean by not being used: nowhere in the entire binary is there a reference to it).


Probably means its inlined.


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: EncyclopediaMgrClass [message #492646 is a reply to message #492645] Fri, 03 November 2017 13:18 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
iRANian wrote on Fri, 03 November 2017 12:02

Neijwiert wrote on Fri, 03 November 2017 01:07

Some
(What I mean by not being used: nowhere in the entire binary is there a reference to it).


Probably means its inlined.


No, I'm using the linux binary to verify that. And that one has debug information. I don't think it inlines anything if theres a function for it. I have not seen it do that yet.
Re: EncyclopediaMgrClass [message #492647 is a reply to message #492628] Fri, 03 November 2017 13:32 Go to previous message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

We have a bunch of stuff reverse engineered for our "5.0" branch (the one that we use for RA:APB, RA2:AR and TSR over on w3dhub) but that branch isn't really suitable for normal renegade since we yanked out a lot of things normal renegade needs rather than reverse engineer all that code.

For all sorts of reasons I am not going to just share all that code (or bits of it) but where there are things we have (in 5.0 or 4.x) that people have a genuine use for and where the code isn't sensitive (i.e. sharing it wont be a risk) I may choose to share it with people.

No I will not be sharing the entire code to BooleanVectorClass or EncyclopediaMgrClass.

I can however confirm that BooleanVectorClass has member functions called First_False and First_True that use First_False_Bit and First_True_Bit (although neither of those member functions is used anywhere). As far as I am aware there are no inlined copies of First_False_Bit or First_True_Bit anywhere.

And no I wont be adding this stuff to the 4.x codebase, its not something where its beneficial to do so and its easier for Neijwiert to just write his own code for his own needs.


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

[Updated on: Fri, 03 November 2017 13:41]

Report message to a moderator

Previous Topic: Weird walking glitch
Next Topic: Crashed while leaving server
Goto Forum:
  


Current Time: Fri Nov 08 19:22:59 MST 2024

Total time taken to generate the page: 0.00917 seconds