Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


std::string Issue

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Apr 24, 2008 7:42 am    Post subject: std::string Issue Reply with quote

Firstly, want to say that I'm not looking for elitest posts saying std::string sucks and I should use <input any other lib here>. I'm using it and I'm not changing. So if you have nothing to input that will help, don't post.

Anyway, the issue is, when I turn full optimization on, the first two strings that I have using std::string to print text to a DC work, but any other strings after that are gone. As if their values are nulled out without reason.

Turning off full optimization works fine. All the strings are printed fine.

Screenshots of what I mean:

Normal compile with no optimization. (Can achieve the effect with custom optimization but not with full.)


Full optimization.


Other parts of the project use std::string but all work fine later on, only the ones drawn to the screen are being "corrupted" if you will.

Anyone else seen this before, or have a fix? (I really wish to use full optimization so looking for a solution to be able to use it.)

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Estx
Expert Cheater
Reputation: 0

Joined: 04 Mar 2008
Posts: 172

PostPosted: Thu Apr 24, 2008 9:35 am    Post subject: Reply with quote

Haven't come across that before and I use std::string a fair bit, strange..

Mind posting the snippet of code that renders the strings? Or a replicate of it.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Apr 24, 2008 9:44 am    Post subject: Reply with quote

The code that paints the text is an ASM static lib. Which I use because:
1.) I can't convert it to C++ (Uses MMX functions and such.)
2.) It creates alpha blended text for other methods of drawing.
3.) Various other small reasons that aren't important.

Theres not really anything I can post it though, as the project is a dynamically driven GDI engine. The text objects are a single reusable class that is vectored for each string object thats loaded into the GUI.

(And no PaintText is not an API.)
Code:
void CText::Draw()
{
   PaintText( this->m_dcText, this->m_dibText, cEngine->m_dcMemory, cEngine->m_vFrame->m_dibFrame, m_vString.c_str(), m_vRect.left, m_vRect.top );
}


Code:
void CWindow::DrawTexts()
{
   // Draw Text Objects
   for( int iIndex=0; iIndex<static_cast<int>(m_vTextObjects.size()); iIndex++ )
      m_vTextObjects[ iIndex ]->Draw();
}


Like I said, the code isn't going to help much for anyone to actually understand the purpose. Either way, the code isn't the issue as it works with all the other optimization settings, just not 'Full Optimization'.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Estx
Expert Cheater
Reputation: 0

Joined: 04 Mar 2008
Posts: 172

PostPosted: Thu Apr 24, 2008 10:00 am    Post subject: Reply with quote

I see what you mean. The code doesn't help at all in this case lol.

The only thing that I can think of that would be remotely relevant is that the for loop isn't indexing the entire m_vTextObjects size. I'm guessing you've already checked to see if the size is different between optimization modes?

Other than that, I'm quite stumped. :\ Sorry I couldn't be of much help. If something pops into mind, I'll post it as soon as I can.
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Thu Apr 24, 2008 1:14 pm    Post subject: Reply with quote

Are you using -02 or -03 for full optimization? I've heard -03 can do wonky things and generally isn't that helpful.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Apr 24, 2008 5:33 pm    Post subject: Reply with quote

HalfPrime wrote:
Are you using -02 or -03 for full optimization? I've heard -03 can do wonky things and generally isn't that helpful.


Full Optimization is its own setting.
http://msdn2.microsoft.com/en-us/library/59a3b321(VS.71).aspx

Currently, I am using:
/Ob2 /Oi /Ot /Oy /GT /GL via Custom optimization but as I said would really prefer using Full as it helps a lot with speed and size.

Yes, I have tested the size of the text object vector as well, it is the correct size and does loop the full vector when being told to draw.


:: EDIT ::

Turns out it was the drawing function that I am using to draw the text which is inside an ASM static lib. The compiler, when fully optimized, didn't save registers over the call so things were being overwritten which fucked the vector after the first call was made to draw the first text object. Fixed by embracing the call with pushad/popad:

Code:

_asm pushad
PrintText( ... );
_asm popad


Guess you could say compiler fault for this but meh... just happy to at least figure this out. x.x

Another quick edit, to avoid using inline I fixed this by adding the following to the proto:

Quote:
PaintText PROC C uses ebx esi edi ...

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites