Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Technical Support » Other » i need urgent help
i need urgent help [message #212347] Tue, 08 August 2006 15:20 Go to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
i am getting pretty anoyed at this, im using FDSTalk.dll to talk to FDS and i had it working but now it doesn't work why? here is the code i am using:(C++)

long IP2Long(std::string &ipString) //function from drichards (experts-exchange)
{
    long result = 0;									
    size_t startPos = 0;
    for ( int ii = 0; ii < 4; ii++ )
    {
        size_t dot = ipString.find('.', startPos);
        int num = ::atoi(ipString.substr(startPos, dot-startPos).c_str());
        result *= 256;
        result += num;
        startPos = dot+1;
    }
    return result;
}


int _tmain(int argc, _TCHAR* argv[])
{
	if(Init(1234, "password"))
	{
                cout << "Init";
		Send_Message("password", IP2Long((string)"127.0.0.1"), 4849);
		Send_Message("msg hello", IP2Long((string)"127.0.0.1"), 4849);
		Shutdown();
	}
	system("pause");
	return 0;
}



it will compile and run with no errors but nothing apperes in FDS, why!

[Updated on: Tue, 08 August 2006 15:22]

Report message to a moderator

Re: i need urgent help [message #212352 is a reply to message #212347] Tue, 08 August 2006 15:57 Go to previous messageGo to next message
Nightma12 is currently offline  Nightma12
Messages: 2593
Registered: August 2003
Karma: 0
General (2 Stars)
Category Moderator
long IP2Long(std::string &ipString)
{
    long result = 0;
    size_t startPos = 0;
    for ( int ii = 0; ii < 4; ii++ )
    {
        size_t dot = ipString.find('.', startPos);
        int num = ::atoi(ipString.substr(startPos, dot-startPos).c_str());
        result *= 256;
        result += num;
        startPos = dot+1;
    }
    return ::htonl(result);
}



heres my IP2LONG


if you going to close the connection to the FDS, its also good practice to send off

Send_Message("bye", IP2Long((string)"127.0.0.1"), 4849);



you could also try hard codeing the IP2LONG value for 127.0.0.1, which is what i do on NR Smile, it is: 16777343
Re: i need urgent help [message #212370 is a reply to message #212347] Tue, 08 August 2006 18:24 Go to previous message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
Thanks you so much! it turns out that i need ::htonl, but i coulnt get it to compile so i removed it.

btw: how is your NR going in c++, i saw your thread at experts exchange.
Previous Topic: Computer Overheating.
Next Topic: just a quick question...
Goto Forum:
  


Current Time: Sat Apr 27 07:26:01 MST 2024

Total time taken to generate the page: 0.00773 seconds