Results 1 to 7 of 7
  1. #1
    |-|3|_][({}PT3R12's Avatar
    Join Date
    Nov 2008
    Gender
    male
    Location
    UnkwOwnS
    Posts
    449
    Reputation
    12
    Thanks
    472
    My Mood
    Twisted

    Angry Font Controller?



    With the problem being one of those that is always reoccurring, I was hoping someone would explain a new method or old method to me..

    I've done this plenty of ways, one being just a simple creation method (In Present or EndScene)
    Code:
    if(MyFont == NULL || !MyFont)
    {
        if(!IsBadReadPtr((void*)MyFont, sizeof(MyFont))
             MyFont->Release();
    
        Created = false;
    }
    if(!Created)
    {
        D3DXCreateFont(....&MyFont);
        Created = true;
    }
    I have also looked around the forum and talked to some friends and they said to use something that I believe originated from Gellin (Didn't work either)

    With pDeviceFontBuffer being defined as: LPDIRECT3DDEVICE9 pDeviceFontBuffer;
    Code:
    if(pFont == NULL || TabFont == NULL)
    	{
    		D3DXCreateFontA(.......&pFont);
    		D3DXCreateFontA(.......&TabFont);
    	}
    	else
    	{
    		if(pDeviceFontBuffer != pDevice)
    		{
    			pDeviceFontBuffer = pDevice;
    
    			try
    			{
    				if(pFont != 0 || TabFont != 0){ pFont->Release(); TabFont->Release(); }
    
    			} catch (...) {}
    
    			pFont = 0, TabFont = 0;
    			D3DXCreateFontA(......&pFont);
    			D3DXCreateFontA(......&TabFont);
    		}
    	}
    After going through these and a few more things I put together off the top of my head, I thought of something that made sense, but still failed. Maybe my logic is wrong here, but I figured that since my text worked perfectly until I joined a game, there was a problem with my Device. Maybe my device changed or was lost somehow (and yes I have Reset hooked). So I figured if I save what ever pDevice is returned in my Reset, i could make a new font from it and it should produce visible text. For some reason it didn't work, maybe me logic is flawed... But give it a look:

    Reset: (Setting "Buff" to the reset pDevice, so i can make a font off it)
    Code:
    HRESULT WINAPI nReset( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* PresentationParameters )
    {
    	__asm pushad;
    	pFont->OnLostDevice();
    	TabFont->OnLostDevice();
    
    	HRESULT rCSetRet = oReset(pDevice, PresentationParameters);
    
    	if(SUCCEEDED(rCSetRet)) pFont->OnResetDevice(), TabFont->OnLostDevice(), Buff = pDevice;
    	__asm popad;
        return rCSetRet;
    }
    EndScene:
    Code:
    if(pFont)
    	{
    		pFont->Release();
    		TabFont->Release();
    		pFont = 0;
    		TabFont = 0;
    		font = false;
    	}
    	if(!font)
    	{
    		if(Buff){
    			D3DXCreateFont(Buff...... &TabFont);
    			D3DXCreateFont(Buff.......&pFont); 
    		}else{
    			D3DXCreateFont(pDevice.......&TabFont);
    			D3DXCreateFont(pDevice.......&pFont); 
    		}
    		font = true;
    	}
    It seems like its not my font going bad, its some other issue that wont show my text... I'v also tried just using a hot-key to re-create the font ingame, but it still refused to show!

    Any help or additions would be appreciated! Thank you in advanced.
    Last edited by |-|3|_][({}PT3R12; 01-06-2013 at 08:09 PM.

  2. #2
    Ch40zz-C0d3r's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    839
    Reputation
    44
    Thanks
    400
    My Mood
    Twisted
    LOL
    This is very easy to fix...
    Just check if your font is invalid ( == NULL ) in present, and in reset set it to NULL.
    Also use "gellins" method LOL which is used by me without knowing gellin should make it -.-
    You simply have 2 devices, if the actual one has been chnaged this means font should get invalid, so recreate the font.

    Progress with my game - "Disbanded"
    • Fixed FPS lag on spawning entities due to the ent_preload buffer!
    • Edit the AI code to get some better pathfinding
    • Fixed the view bug within the sniper scope view. The mirror entity is invisible now!
    • Added a new silencer for ALL weapons. Also fixed the rotation bugs
    • Added a ton of new weapons and the choice to choose a silencer for every weapon
    • Created a simple AntiCheat, noobs will cry like hell xD
    • The name will be Disbanded, the alpha starts on the 18th august 2014



    Some new physics fun (Serversided, works on every client)



    My new AI
    http://www.youtube.com/watch?v=EMSB1GbBVl8

    And for sure my 8 months old gameplay with 2 friends
    http://www.youtube.com/watch?v=Na2kUdu4d_k

  3. The Following User Says Thank You to Ch40zz-C0d3r For This Useful Post:

    [MPGH]Flengo (01-07-2013)

  4. #3
    |-|3|_][({}PT3R12's Avatar
    Join Date
    Nov 2008
    Gender
    male
    Location
    UnkwOwnS
    Posts
    449
    Reputation
    12
    Thanks
    472
    My Mood
    Twisted
    Lol, very easy to fix? I've tried everything you just said, plenty of times. I just tried it again and did exactly what you said to do, still disappears. Seems like my font is valid, it's just something else with the game, I don't expect you to know, thanks for the help anyway!

  5. #4
    Ch40zz-C0d3r's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    839
    Reputation
    44
    Thanks
    400
    My Mood
    Twisted
    This method works 200% for me.
    Also, what font are you using?

    Edit: Try to draw the font and getting its size by a rect pointer.
    Check if size is same or 0
    Last edited by Ch40zz-C0d3r; 01-07-2013 at 05:56 PM.

    Progress with my game - "Disbanded"
    • Fixed FPS lag on spawning entities due to the ent_preload buffer!
    • Edit the AI code to get some better pathfinding
    • Fixed the view bug within the sniper scope view. The mirror entity is invisible now!
    • Added a new silencer for ALL weapons. Also fixed the rotation bugs
    • Added a ton of new weapons and the choice to choose a silencer for every weapon
    • Created a simple AntiCheat, noobs will cry like hell xD
    • The name will be Disbanded, the alpha starts on the 18th august 2014



    Some new physics fun (Serversided, works on every client)



    My new AI
    http://www.youtube.com/watch?v=EMSB1GbBVl8

    And for sure my 8 months old gameplay with 2 friends
    http://www.youtube.com/watch?v=Na2kUdu4d_k

  6. #5
    |-|3|_][({}PT3R12's Avatar
    Join Date
    Nov 2008
    Gender
    male
    Location
    UnkwOwnS
    Posts
    449
    Reputation
    12
    Thanks
    472
    My Mood
    Twisted
    I'm using Calbria and Arial
    Code:
    D3DXCreateFont(Buff, 20, 0, FW_BOLD, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,  ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Calbria", &TabFont);
    D3DXCreateFont(Buff, 14, 0, FW_BOLD, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,  ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial", &pFont);
    I've also tried drawing it differently also,
    Code:
    void PrintText(int x, int y, D3DCOLOR col, ID3DXFont *font, char pString[])
    {
         RECT FontRect = { x, y, x+sizeof(pString), y+30 }; //30, font size varies
         font->DrawText( NULL, pString, -1, &FontRect, DT_LEFT | DT_WORDBREAK, col);
    }
    and of course the whole MPGH Copy + Pasted DrawString Function,

    Code:
    void DrawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt, ...)
    {
    	RECT FontPos = { x, y, x + 1000, y + 1000 };
    	char buf[1024] = {'\0'};
    	va_list va_alist;
    
    	va_start(va_alist, fmt);
    	vsprintf_s(buf, fmt, va_alist);
    	va_end(va_alist);
    
    	g_pFont->DrawText(NULL, buf, -1, &FontPos, DT_NOCLIP, color);
    }
    nothing has worked, and you want me to compare the sizes of the font? (I don't get what your asking)

  7. #6
    -Bl00d-'s Avatar
    Join Date
    Sep 2011
    Gender
    female
    Location
    Imma girl what about it?
    Posts
    481
    Reputation
    10
    Thanks
    53
    My Mood
    Twisted
    ive made this mistake once for Crossfire.
    probably not whats wrong with yours cuz you seem good at it.
    but my problem was i was drawing the text right in lobby
    but in game i was drawing my menu on top of the text.
    so i could click the boxes and hacks still worked
    i just couldnt read which was which,
    Successful buys: 20
    Successful sells: 4
    Successful trades: 9
    Scammed: 4

     
    http://www.mpgh.net/forum/490-vouches/560562-vouches.html

    ^^^^^^^^^^^
    vouche for me?

  8. #7
    |-|3|_][({}PT3R12's Avatar
    Join Date
    Nov 2008
    Gender
    male
    Location
    UnkwOwnS
    Posts
    449
    Reputation
    12
    Thanks
    472
    My Mood
    Twisted
    Quote Originally Posted by -Bl00d- View Post
    ive made this mistake once for Crossfire.
    probably not whats wrong with yours cuz you seem good at it.
    but my problem was i was drawing the text right in lobby
    but in game i was drawing my menu on top of the text.
    so i could click the boxes and hacks still worked
    i just couldnt read which was which,
    I am drawing my menu first, and then my text. I don't believe that is the problem, but hey I'll do some tests to be sure! Thanks for the input! Will post my results soon!

Similar Threads

  1. [TUT] How to add Oriental/Korean Fonts
    By Cadelaf in forum WarRock Korea Hacks
    Replies: 2
    Last Post: 05-06-2007, 12:08 PM
  2. Download fonts to where?
    By acepwnage in forum Art & Graphic Design
    Replies: 3
    Last Post: 07-13-2006, 02:55 AM
  3. [TUTORIAL]How to control an airplane :p and ofcourse insert it
    By System79 in forum WarRock - International Hacks
    Replies: 8
    Last Post: 07-09-2006, 04:44 PM
  4. how do you add fonts in PS
    By darkone1149 in forum Art & Graphic Design
    Replies: 2
    Last Post: 02-06-2006, 06:32 PM
  5. CBS Controls StarTrek
    By Dave84311 in forum SCI-FI
    Replies: 5
    Last Post: 01-23-2006, 12:18 AM