Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Flyff > Flyff Private Server
You last visited: Today at 13:32

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Replace Part of an string

Discussion on Replace Part of an string within the Flyff Private Server forum part of the Flyff category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
Replace Part of an string

Hi elitepvpers,

I am working on reducing some file sizes so i removed all II_PART_F etc
and altered mdldyna.inc

however in Spec_Item it will load only the Male Icons.

Now what i have in mind is to make an function to replace the male icon with female if you are an female char.

For the first test i have left the sex of the char out.

Code:
void CItemBase::SetTexture()
{
#ifdef __CLIENT
	ItemProp* pProp = GetProp();
	if (!pProp)
	{
		LPCTSTR szErr = Error("CItemBase::SetTexture GetProp() NULL Return %d", m_dwItemId);
		ADDERRORMSG(szErr);
	}


	//if(g_pPlayer->GetSex() == SEX_FEMALE)
	//{
		switch (pProp->dwItemKind3)
		{
		case IK3_HELMET:
		case IK3_SUIT:
		case IK3_GAUNTLET:
		case IK3_BOOTS:
		//	std::string strIcon = pProp->szIcon;
		//	size_t f = strIcon.find("Itm_m");
		//	strIcon.replace(f, std::string("Itm_m").length(), "Itm_f");
		//	m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, _T("strIcon")), 0xffff00ff);
		//	break;
			std::string strIcon = pProp->szIcon;
			ReplaceStringInPlace(strIcon, "Itm_m", "Itm_f");
			m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
			break;
		}
	//}
	
	//m_pTexture = CWndBase::m_textureMng.AddTexture( g_Neuz.m_pd3dDevice, MakePath( DIR_ITEM, strIcon ), 0xffff00ff );

#endif
}
I know its an mess but i am still testing

Now take an look into this line
Code:
m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
Its located underneath ReplaceStringInPlace

Now its giving me an error
No instance of overloaded function "MakePath" matches the arguments list argument types are (const char[6], std::string)

But is strIcon not an string? even it an part of the string is getting replaced?

With kind regards
raventh1984 is offline  
Old 01/05/2016, 23:16   #2
 
elite*gold: 0
Join Date: Mar 2008
Posts: 665
Received Thanks: 227
You are converting std::string to CString.

CString strIcon;
strIcon.Replace("Itm_m", "Itm_f");
alfredico is offline  
Old 01/05/2016, 23:27   #3
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
does strIcon.replace replaces an part of the string? so it looks for that part in lets say

itm_mVag01Upper.dds?

Lol Nevermind ofcourse it does. Pfffff i was overthinking at at this point.

Thank you Alfredico.

Edit2:
Next problem is if i put if(g_pPlayer->GetSex() == SEX_FEMALE) rest of the code
It crashes on BYTE GetSex() inside Mover.h

i also have tryd
CMover* pMover;
if(pMover->GetSex() but the result is the same.


("You never are to old to learn haha")
raventh1984 is offline  
Old 01/06/2016, 00:12   #4
 
elite*gold: 0
Join Date: Mar 2008
Posts: 665
Received Thanks: 227
g_pPlayer is null?
alfredico is offline  
Old 01/06/2016, 00:22   #5
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
I have tested it and indeed g_pPlayer is null.

i thought that if you logged in that g_pPlayer will had an value.
Seems i still have an lot to learn.

EDIT:

So if(g_pPlayer->GetSex() != NULL)
{
rest of the code

why is g_pPlayer null? Could you explain it? how this is happening so i can understand what to do?
raventh1984 is offline  
Old 01/06/2016, 00:47   #6
 
elite*gold: 0
Join Date: Mar 2008
Posts: 665
Received Thanks: 227
CItemBase class is just for items.

I don't know what are you trying to do. Oh and g_pPlayer is CMover class, so it doesn't matter if you do CMover* pMover or CMover* g_pPlayer, would still return null.
alfredico is offline  
Old 01/06/2016, 07:13   #7
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
I removed all double lines from Spec_Item

So II_ARM_M_STORMB_HELMET_SET_KAL and II_ARM_F_STORMB_HELMET_SET_KAL

is now just II_ARM_STORMB_HELMET_SET_KAL.

So now i need to have an check otherwise it will load only the szIcons from the male char. instead of female if the char is female.
raventh1984 is offline  
Old 01/06/2016, 10:03   #8
 
elite*gold: 0
Join Date: Mar 2008
Posts: 665
Received Thanks: 227
CMover* pMover = g_pPlayer;

CMover* pMover = CMover::GetActiveMover();

CObj* pObj;
CMover* pMover = (CMover*)pObj;

Or g_Neuz.m_apPlayer


Try and maybe there is one which works.
alfredico is offline  
Thanks
1 User
Old 01/06/2016, 11:11   #9
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
Only g_Neuz.m_apPlayer is working
I did it like so for testing

Code:
if (g_Neuz.m_apPlayer != NULL)
	{
		m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
	}
Its showing the icon now. So thank you for that.
Now i need to figure out how to set the *** of the char

i have it now like this
Code:
for (int i = 0; i < 3; i++)
	{
		if (g_Neuz.m_apPlayer[i] != NULL)
		{
			if (g_Neuz.m_apPlayer[i]->GetSex() == SEX_FEMALE)
			{
				m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
			}
			else
			{

			}
		}
	}
But its showing the icons for both Female as Male.
And if i read it correct its saying if GetSex == Female then only show the icons.

Thank you for the help so far
raventh1984 is offline  
Old 01/06/2016, 18:05   #10
 
elite*gold: 0
Join Date: Mar 2008
Posts: 665
Received Thanks: 227
That's because you are loading textures for all characters you have created. The i should be replaced by the character slot.

You only need this, the rest is not needed.
if (g_Neuz.m_apPlayer[slot]->GetSex() == SEX_FEMALE)
alfredico is offline  
Old 01/06/2016, 18:59   #11
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
Well i have tried that one before.

Result is this

Code:
if (g_Neuz.m_apPlayer[1]->GetSex() == SEX_FEMALE)
	{
		strIcon.Replace("Itm_m", "Itm_f");
		m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
	}
	else
	{
		m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
	}
[1] is the slot of the character
So what it does now is checking if slot 1 is an female if so then replace the string.
However my male char is char slot 0 and you guessed it its also female icons.

If i change the [1] to [0] then all icons are male since char slot 0 is an male char.

So i need to check witch char is loaded and get the *** from that one.


Is it possible to include WndSelectChar inside item.cpp and work with that class to?
raventh1984 is offline  
Old 01/06/2016, 19:08   #12
 
elite*gold: 0
Join Date: Mar 2008
Posts: 665
Received Thanks: 227
Correct. I would take m_nSlot from CDPLoginClient.
#include "DPLoginClient.h"
extern CDPLoginClient g_dpLoginClient;
if (g_Neuz.m_apPlayer[g_dpLoginClient.m_nSlot]->GetSex() == SEX_FEMALE)

And tbh, I think there could be a cleaner way to do all this.
alfredico is offline  
Thanks
1 User
Old 01/06/2016, 19:32   #13
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
Thank you that worked.

i really can't say about an cleaner way. Except to add them to Spec_Item again.
This is an quick solution atm.

before i added the above code i had this

Code:
CWndSelectChar* SelectChar;
	if (SelectChar->m_nSelectCharacter == 0 && g_Neuz.m_apPlayer[0]->GetSex() == SEX_FEMALE)
	{
		strIcon.Replace("Itm_m", "Itm_f");
		m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
	}
	else if (SelectChar->m_nSelectCharacter == 0 && g_Neuz.m_apPlayer[0]->GetSex() == SEX_MALE)
	{
		//strIcon.Replace("Itm_m", "Itm_f");
		m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
	}
	
	if (SelectChar->m_nSelectCharacter == 1 && g_Neuz.m_apPlayer[1]->GetSex() == SEX_FEMALE)
	{
		strIcon.Replace("Itm_m", "Itm_f");
		m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
	}
	else if (SelectChar->m_nSelectCharacter == 1 && g_Neuz.m_apPlayer[1]->GetSex() == SEX_MALE)
	{
		//strIcon.Replace("Itm_m", "Itm_f");
		m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
	}
That worked to but your solution is cleaner.

Thank you for your big help in this
raventh1984 is offline  
Old 01/10/2016, 18:20   #14
 
elite*gold: 0
Join Date: Jan 2016
Posts: 81
Received Thanks: 14
Quote:
Originally Posted by raventh1984 View Post
does strIcon.replace replaces an part of the string? so it looks for that part in lets say

itm_mVag01Upper.dds?

Lol Nevermind ofcourse it does. Pfffff i was overthinking at at this point.

Thank you Alfredico.

Edit2:
Next problem is if i put if(g_pPlayer->GetSex() == SEX_FEMALE) rest of the code
It crashes on BYTE GetSex() inside Mover.h

i also have tryd
CMover* pMover;
if(pMover->GetSex() but the result is the same.


("You never are to old to learn haha")

replace the string with a loop
KazumiTanuki is offline  
Old 01/10/2016, 21:49   #15
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
It's already solved.
It still was crashing so i removed to code and altered it inside WndItemCtrl.cpp
Code:
ItemProp* pItemProp = pItemElem->GetProp();
			CString strIcon = pItemProp->szIcon;
			switch (pItemProp->dwItemKind3)
			{
			case IK3_HELMET:
			case IK3_SUIT:
			case IK3_GAUNTLET:
			case IK3_BOOTS:
				switch (g_pPlayer->GetSex())
				{
				case SEX_MALE:
					m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
					m_pTexture->Render(p2DRender, CPoint(x, y), nalpha);
					break;
				case SEX_FEMALE:
					strIcon.Replace("Itm_m", "Itm_f");
					m_pTexture = CWndBase::m_textureMng.AddTexture(g_Neuz.m_pd3dDevice, MakePath(DIR_ITEM, strIcon), 0xffff00ff);
					m_pTexture->Render(p2DRender, CPoint(x, y), nalpha);
					break;
				}
				break;
			default:
				pItemElem->GetTexture()->Render(p2DRender, CPoint(x, y), nalpha);
				break;
			}
raventh1984 is offline  
Reply


Similar Threads Similar Threads
" durch string.Replace ersetzen
09/30/2013 - .NET Languages - 9 Replies
Hallo, ich habe folgendes Problem: Ich möchte string.Replace in einem String alle Anführungszeichen mit " & Chr(34) & " ersetzen. Mein Code sieht jetzt so aus: input.Replace(Chr(34), Chr(34) & " Chr(34) " & Chr(34)) Nur funktioniert das jetzt nicht so, wie ich das will. Hat einer eine Idee, wie ich das umsetzen kann? MfG Edit: Funktioniert doch so, wie oben geschrieben. Keine Ahnung wo der Fehler lag.
Brauche hilfe string replace :S
06/13/2013 - C/C++ - 9 Replies
Hi, unzwar habe ich eine Aufgabe, Legen Sie nun in Ihrem Projekt zwei weitere Dateien an: "stringOperations.h" und "stringOperations.cpp". In diesen Dateien deklarieren bzw. definieren Sie Funktionen, die den Umgang mit Strings und der Standard-Library <string> einüben. a) Erweitern Sie ihr Projekt um eine Funktion mit der Deklaration int myreplace(string & text, const string &findString, const string &replaceString); welche in einem String text alle Vorkommen des Strings findString...
[Visual Basic] [Problem] String auslesen/String zufällig wählen
05/06/2012 - General Coding - 4 Replies
Code: #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Name Generator", 236, 299, 815, 246) $Input1 = GUICtrlCreateInput("Username", 24, 72, 185, 21) $Input2 = GUICtrlCreateInput("Username", 24, 104, 185, 21) $Input3 = GUICtrlCreateInput("Username", 24, 136, 185, 21) $Input4 = GUICtrlCreateInput("Username", 24, 168, 185, 21) $Input5 = GUICtrlCreateInput("Username", 24, 200, 185, 21)



All times are GMT +2. The time now is 13:32.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.