• Welcome to Valhalla Legends Archive.
 

Hey all need some help.

Started by Final, September 29, 2006, 06:15 PM

Previous topic - Next topic

Spilled

use memchr() for your getstrings method, its very helpful

Final

how would that work out? I read how it works but ? yah.

Spilled

Quote from: Final on October 02, 2006, 05:26 PM
how would that work out? I read how it works but ? yah.


hrmm.... well lets see....

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_crt_memchr.asp

First parameter would be a pointer to the actual buffer which in this case is the packet, Next parameter is the character to look for, for example 'c'., and the final parameter is the size of the buffer. Return value is the location.... what don't you get? you can find an example on that link. Just use the return value and strcpy() to copy the string and return.....

Final

#48
wy would i be looking for a character?

thats wy i said i didnt understand the use for this?

Hdx

'\x0'
Thats why, you get the position of the null, and then use strcpy() to copy out the string.
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Final

#50
Is their a problem with this because it sorta crashes my program?

char* debuff::getstring(){
char* p;
if(memchr(packet+ps, '\x0',strlen(packet)-ps)) {
strcpy(p, packet+ps);
ps += strlen(p) + 1;
} else {
memcpy(p, packet+ps,strlen(packet)-ps);
p[strlen(packet) - ps] = '\x0';
ps = strlen(packet);
}
return p;
}

UserLoser

Can't use strlen for binary streams of data, like Battle.net messages, for example. strlen ends when it finds a null character, the server gives you the length of the message.

Final


UserLoser

Quote from: Final on October 03, 2006, 08:28 AM
so then sizeof() ??

No, not at all.  It really helps to learn the language first for simple stream manipulation and learn the proper use of operators such as sizeof...

Final

#54
dude i understand the language its header files you should say.?w/e thats besides the point i was in math class and thinking the function over all day cuz im bored so i just like doing that. So what im doing is getting the null ending of the string its location then thats my end? and i start were my position is on the packet correct?

sizeof() works by getting the size of the arguement without stoping at 0x00
strlen does the the same but stops when it meets one of those.

UserLoser

Quote from: Final on October 03, 2006, 05:15 PM
dude i understand the language its header files you should say.?w/e thats besides the point i was in math class and thinking the function over all day cuz im bored so i just like doing that. So what im doing is getting the null ending of the string its location then thats my end? and i start were my position is on the packet correct?

sizeof() works by getting the size of the arguement without stoping at 0x00
strlen does the the same but stops when it meets one of those.

Something like that, but sizeof won't ever be what you need here.

Final

#56
oh no i understand the use of it dont worry i just thout you  were suggesting it for some reason im stupid EVERYONE in valhalla hates me.

UserLoser

We don't hate you, we are not going to hold your hand down the correct path--instead we will lead you to it so you can carry on on your own.

Final

#58
its not that i always get yelled at for mispelling sniff. Once i got dist cuz i was mexican sniff. And i understand if you spoon feed i cant learn ANYTHING. common knoledge yet so many do it.

Need to make this post meaningfull cuz this is way off topic.

Ok ive been doing this.

memcpy(packet,packet+ps,sizeof(packet+ps)+1);

So it deletes what i just used.

UserLoser

Again, youu can't use sizeof for this.  Look at the structure of the packet header and think what useful information is inside of it for correctly handling packets from the server

|