Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Release Forum » [CODE] cScTextObj class definition
Re: [CODE] cScTextObj class definition [message #465704 is a reply to message #465642] Sat, 07 April 2012 11:57 Go to previous messageGo to previous message
ThisLittleGirl is currently offline  ThisLittleGirl
Messages: 11
Registered: April 2012
Location: germany
Karma:
Recruit
Just wondering, there's probably good reasons you do it this way and I may be missing something badly but...

iRANian wrote on Fri, 06 April 2012 06:14

RENEGADE_FUNCTION
cScTextObj* __thiscall cScTextObj::Constructor() 
AT2(0x004B9140, 0x004B9140);
//AT2(0x004B5AA0, 0x004B5AA0);


Why not just declare the constructor as such instead of as a member function, like so:
RENEGADE_FUNCTION
cScTextObj::cScTextObj() 
AT2(0x004B9140, 0x004B9140);
Wouldn't that work? The __thiscall should be redundant anyway because it's the default for member functions on MSVC++. And what exactly does the RENEGADE_FUNCTION macro do?

iRANian wrote on Fri, 06 April 2012 06:14


		// Create a new cScTextObj
		cScTextObj* TextObj = (cScTextObj*)operator new(sizeof(cScTextObj));
		TextObj = TextObj->Constructor();
		// ...
		delete TextObj;



Also you could just put the thing on the stack instead of that tedious allocation. And isn't what the Constructor function would return the this pointer that you passed in (implicitly via ecx (thiscall)) anyways? In that case the assignment is redundant. If it wasn't the case you'd certainly fuck up yourself later by deleting a bogus pointer.

So, to sum it up. If you declare the constructor as such, you could just do:
cScTextObj text_obj;

Just curious, haha. ;p
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [SSGM 4.0 Plugin] No Reload Snipers
Next Topic: [CODE] SCAnnouncement class definition
Goto Forum:
  


Current Time: Sun Dec 22 13:05:06 MST 2024

Total time taken to generate the page: 0.00908 seconds