• Welcome to Valhalla Legends Archive.
 
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - option

#1
So I've been writing C++ code for a long time, yet there are some things I've realized recently (after a long, long fling with c) that I don't quite get.

Why the hell is everything preceeded with underscores in C++?? I.e. ___int32 or something like that. What the hell is the point of that

Also, anytime I've needed to cast something, I've now realized that I was doing it c-style? I.e.

struct Arg *arg = (struct Arg *) malloc(sizeof(struct Arg));

void *ptr;

ptr = (struct Arg *) arg;


Now that I'm coming back to C++ and considering using it for more advanced programming (worker threads, thread classes, etc.), I've seen a lot of that underscore shit and weird casts that I'm not familiar with, though I used (basic) C++ for quite some time.

I.e. c++ casting:
const char *c = "text";
char *str = const_cast<char *> (c);
cout << str << '\n';


I feel like there's just something I'm not getting about C++, now that I've been using C for so long (because of college, I'm a junior and a CS major).

However, when I took my second data structures course (which was a C++ course), I didn't ever see any of that underscore shit or super weird casting.

Also, what the hell is a "typedef"?

Thanks!
#2
Why would I take an OO approach using C, when I can have classes and all of the other "way more OO" conventions that C++ offers? I've been using C quite often because that's what they taught us posix threads in. How can I write OO code in C? For class, I've been creating variables (that would be class variables), and using them in functions (defined in other files), that would be the class functions. Is that what you mean?

What's a "managed library" btw, saw it in your sig.

I develop on Windows, but I have a ported posix thread library that I use on windows for my school projects and stuff. Would it be weird to develop my threaded functions using pthreads, even though I'm developing on Windows?

Like - if I said fuck it right now, and started coding my chatbot in c/c++ and it used pthreads - would such be "unconventional"? What sort of thread library do you use in your work?

EDIT:

Also, I don't want to use winsock. I'd optimally like my bnet chat client to run on the UNIX architecture as well. Is C++ and ACE my best bet?
#3
as I would have said in the d2 days


pwnt
#4
Damn, and here I am thinking I'm an innovator. (Jk)

I'm still torn on whether to write my bot in c, or take an oo approach and write it in c++. If I were to write this in c++, would it make sense to code a thread spawner object (which stored pointers to various functions as parameters as its local vars? (A built in jump-table, so to speak).

In school, I'm learning multithreading with posix threads. Are they optimal for coding multithreaded apps, or is there a better c/c++ convention?
#5
I've been learning how to code multithreaded apps in school, and it got me thinking about my plans of creating a chatbot.

Would there be any sense in doing something like this? I was thinking about creating an option to spawn a number of different connection sequences, opening up one thread per sequence?

Or maybe one thread per major function in my program?

What do you guys think :o
#6
General Discussion / Re: Hi Guys
April 17, 2011, 10:36 AM
Thanks buddy :) how helpful. I figured it out, no thanks to you!!
#7
General Discussion / Hi Guys
April 14, 2011, 12:32 AM
Been awhile. I still want to create a chatbot, damnit. I have a more than sufficient knowledge of C, C++, and Java now so I think I should give it a go. I'm just so damn busy with school and work, it's hard to find the time.

So anyways, I was smoking a bowl frustrated about something, when I got an email earlier saying the forums were back up. I never knew they were down, but I realized that maybe you guys could help me with my frustrations.

It requires knowledge of visual studio (my version is 2005). It seems trivial, but it's frustrating the hell out of me!

Any attempts? I made a separate thread for it.
http://forum.valhallalegends.com/index.php/topic,18265.0.html

Have it it, pros
#8
Hey guys,

I have a problem. I'm currently learning how to program multithreaded apps using the posix thread library on unix (in c). I was getting tired of ssh'ing to my CS department's remote PC to run my code, so I looked into a Win32 alternative to pthreads.

Sure enough: http://sourceware.org/pthreads-win32/

Anyways, I can't install this thing to save my life. And in-depth explanation of the problem I'm experiencing is here:

http://stackoverflow.com/questions/5654073/how-do-i-install-pthread-win32-windows-pthread-posix-thread-library-for-visua

Please reply in this thread (as opposed to there) if you think you can help me out.

-Sam
#9
Even though the packet buffer aspect of bnet dev is pretty simple for the experienced guys here, i have noticed that there seems to be a few different ways to approach it.

The first I've noticed is with byte shifting, and "padding", using stuff like RtlZeroMemory and stuff, it seemed pretty simple, I lost the code though.

The other which seems a bit more complicated is using a huge chunk of data and just using a buffer variable to copy the data of what you are trying to add, to the address of the location you are currently at in the packet.

Why are their different ways to do it, which is the most straightforward (easier to understand, to the point, etc.), and what is the most popular way of going about making this class (in-case there is some method I haven't seen yet)?
#10
It will most definitely be updated soon, it's at another host at the time being.

And yes I am back, school takes up a good amount of time, but i finished a few more programming courses and am armed with even more knowledge now so I am looking forward to getting back in the swing of things here!
#11
hahah yeahhh well I just learned a lot about bytes, words, dwords, binary, hex, and just wanted to make sure I could actually do the conversion, so instead of just calculating it I tested my knowledge at the same time haha
#12
Oh man that's sweet to know.

Alright, now I need a C++ packet buffer so I can pick apart and learn how it works, can't create one myself at the moment because of lack of concept knowledge, all tutorials I've found through search are down (domains), and there seems to be like 4354354 C# ones, but no C++ ones.

:(

PS even though  these questions are rather newb, at least I'm giving you something to do :P
#13
Damn andy, you weren't kidding:



Took forever haha

Yeah Hdx I am working in VC++, so the point is, I could just put IX86 into a DWORD, as is, without reversing it, and then send the packet?
#14
Quote from: Andy on June 20, 2008, 02:37 PM
Convert 1230518326 to hexadecimal and you get 0x49583836

Do I need to do that before I send the packet?
#15
Alright, so just for my reference, this is what I just did - just to see if I was on the same page as you guys.

putting 'IX86' into an unsigned long int, is the same as putting in 0x49583836, which I understand.

#include <iostream>

const unsigned long int IX86 = 'IX86';

using namespace std;

int main () {
cout << IX86 << endl;

return 0;
}


My program returns 1230518326.

That isn't IX86 the string in ASCII, HEX, or octal. What is it?