Jump to content


Photo

Net39 DLL


  • Please log in to reply
251 replies to this topic

#1 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 15 October 2010 - 11:36 AM

**BETA** v0.1.3
http://www.host-a.net/u/sabriath/net39_lic.zip

**BETA** v0.1.4 (not compatible with v0.1.3)
http://www.host-a.net/u/sabriath/net39.zip

Mods: If this is in the wrong place, my apologies. I am currently in the middle of making hopefully the best network library. Although this is in a non-working order, it is a work-in-progress and would like help from the community if they are able. I have asked the mods to move this to the DLL extension forum section, as this has reached a stage where it mostly works, but still needs thorough testing and I am still adding more and more features. Thank you

Written in Code::Blocks targetting vsc++2008

{2011:1-1}
http://www.host-a.net/u/sabriath/net39_lic.zip

A new year, and a new plan for the format of this topic. I will begin striking out old "journal" type updates and deleting them over time, no need looking to the past anymore. I will however keep 3 lists inside spoiler tags, 1 will contain a revision log (with as little description of changes for each build) and the others will contain the full list of functions and constants. There is no point in explaining each function, I will write a tutorial specifically designed for that purpose, I don't want to bog down this topic with it. The package contains the license, revision log, source code, dll (debug build), gex extension file, and an example gmk file. Eventually even this journal log will be absorbed into the new order of things, and only important items will be left....


Please feel free to post comments, suggestions, questions, help, bugs, etc. Thank you!

Last File Push: 2011-01-19
Revision:
Spoiler


Constants v0.1.4 (note: not all are actually used):
Spoiler


Constants v0.1.3:
Spoiler


Functions v0.1.4:
Spoiler


Functions v0.1.3:
Spoiler

Edited by sabriath, 19 January 2011 - 11:12 PM.

  • 9

#2 NYS

NYS

    GMC Member

  • GMC Member
  • 435 posts
  • Version:GM:Studio

Posted 15 October 2010 - 11:44 AM

Great your taking your time to do this :)

I would use it, but I have already used many 39dll scripts so renaming isn't so fun, if I want to keep the old scripts too.
  • 0

#3 slayer 64

slayer 64

    GMC Member

  • GMC Member
  • 3300 posts
  • Version:GM8.1

Posted 16 October 2010 - 08:05 PM

i'm not sure what all the changes are going to do for me. looks like 39dll is pretty much the same, but more efficient internally i guess?
you must be pretty good at c++.
if you're going to re work 39dll, maybe you should use GMAPI and have objects automatically keep track of themselves on all machines connected to each other a server.

the end user would use scripts like this:
objControl create event
init(0,"www.aGameServer.com")//1=server 0=client
objControl
if lostConnection() game_end()
if machinesConnected()>10 removeLastMachine()
objPlayer create event
keepVariableUpToDate("x")
keepVariableUpToDate("y")
keepVariableUpToDate("z")
the scripts and dll would automatically trade messages to keep variables and objects in sync.
ideally the end user wouldn't need sockets.

obviously there's a lot of details and i'm not an expert on 39dll. lol
  • 2

#4 2DLuis

2DLuis

    Graphic Designer

  • GMC Member
  • 2493 posts
  • Version:GM8

Posted 16 October 2010 - 11:40 PM

A quick question,

Did you fix the 39DLL glitch where in C++ if you received more than 1 string in a message, the data turned all screwy? And therefore you had to receive the data in one variable char array, and then pass it on to another normal char* variable. I could not quite determine from your post if you had addressed this.

Looks good,
-Luis
  • 0

#5 ash47

ash47

    O_o

  • GMC Member
  • 1326 posts

Posted 17 October 2010 - 12:21 AM

perhaps a different title / description?

otherwise, awesome :P
  • 0

#6 Revel

Revel

    ɹǝqɯǝɯ ɔɯƃ

  • GMC Member
  • 4873 posts
  • Version:GM8

Posted 17 October 2010 - 12:32 AM

Nice, it's about time someone provided a 39dll alternative. I've been using RakNet, and I've noticed on thing that might be good for your DLL. A high resolution timer built into the DLL. It's great for quick timestamping of messages and that way you don't need to use another DLL like Yourself's DLL.
  • 0

#7 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 17 October 2010 - 08:52 AM

@NYS: most of the functions will offer the same abilities as 39dll, so renaming would merely be for the scripts themselves. Your main code should not be effected unless you did a lot of extra work (and I may provide other scripts for crossover maintenance).

looks like 39dll is pretty much the same, but more efficient internally i guess?

Well the primary #1 reason for me doing this is because:
a = createbuffer();
b = createbuffer();
c = createbuffer();

freebuffer(b);

'c' now points to a NULL indexed address as far as 39dll is concerned, and whatever you "wrote" in 'c' buffer, will now be in addressed by 'b' even though it was freed.

have objects automatically keep track of themselves on all machines connected to each other a server.

Those are later plans I had in mind, but I want to just get all the direct internals done first. The thought had crossed my mind to make a network dll that did 99% of the work for you (even dead reckoning), but that's going to take me awhile...baby steps.

Did you fix the 39DLL glitch where in C++ if you received more than 1 string in a message, the data turned all screwy? And therefore you had to receive the data in one variable char array, and then pass it on to another normal char* variable. I could not quite determine from your post if you had addressed this.

I did not know this was a problem, can you explain in more detail about this?

If you mean something like:
writestring("this"+ chr(0) + "and this");
That's because c++ "strlen" automatically returns the 'size' of the string ending with the chr(0) command, so instead you would do this:
writestring("this"); //automatically adds '\0'
writestring("and this");

chr(0) is finnicky in C-type languages because they don't store the size of the string as a 2 byte short like other languages do, and as you know, it takes up 1 of the 256 ascii code designations. This sucks, but you cannot do anything about it directly. However, what I can offer is a "size" argument optional (already somewhat implemented), which would allow you to override 'strlen' check (a size=0 will cause a 'strlen' check). So you would do this (as an example):
writestring("this" + chr(0) + "and this" + chr(0), 14);

If this isn't what you mean, let me know so I can see if I can fix whatever it is.

perhaps a different title / description?

Suggestions?

Nice, it's about time someone provided a 39dll alternative. I've been using RakNet, and I've noticed on thing that might be good for your DLL. A high resolution timer built into the DLL. It's great for quick timestamping of messages and that way you don't need to use another DLL like Yourself's DLL.

I will be adding in that ability once I've fleshed out all of the direct access areas first.

Thanks everyone for the support, hopefully I'll have a demo out this week or the following (my anniversary was a couple days ago, so I wasn't able to program). Keep those ideas comin'!!
  • 0

#8 csscom

csscom

    GMC Member

  • New Member
  • 74 posts

Posted 17 October 2010 - 05:05 PM

Cool stuff, I always assumed everything in 39dll was in perfect working order since it was on version 2.5.

I see your upgrading somethings and one sections says 39dll can cause disjointing with gm.
what does this mean? and can you provide and example of how it can causes problems for a GMMMO.
  • 0

#9 Revel

Revel

    ɹǝqɯǝɯ ɔɯƃ

  • GMC Member
  • 4873 posts
  • Version:GM8

Posted 17 October 2010 - 05:50 PM

I see your upgrading somethings and one sections says 39dll can cause disjointing with gm.
what does this mean? and can you provide and example of how it can causes problems for a GMMMO.


Well the primary #1 reason for me doing this is because:

a = createbuffer();
b = createbuffer();
c = createbuffer();

freebuffer(B);

'c' now points to a NULL indexed address as far as 39dll is concerned, and whatever you "wrote" in 'c' buffer, will now be in addressed by 'b' even though it was freed.


  • 0

#10 True Valhalla

True Valhalla

    ಠ_ಠ

  • Retired Staff
  • 4938 posts
  • Version:GM:Studio

Posted 18 October 2010 - 02:50 AM

I am glad that you are refining the 39dll, but as a "heavy user" of the 39dll, I can't say I have a sudden urge to change to this DLL. I'll explain why, just don't take any of it negatively. It's constructive criticism only =)

Firstly, the obvious complaint that has already come up, is the new names for the basic functions. Not only does it mean I would have a lot (LOT) of code to search through and change, it also is kind of annoying having to write mp_ every time I want to use a networking function. I've always liked that the 39dll doesn't require this; It just makes using it simpler. Call me lazy or whatnot, but that little tag alone is enough to stop me from upgrading.

Secondly, and somewhat ironically, I would prefer the main parts of a function name to be fully self-explanatory. Prime case is the mp_recv function. It's used only a few times in a networking setup, so would benefit from being mp_receive for the sake of understanding. That alone isn't enough to stop me upgrading, but it's a little detail that the user benefits from.

Finally, I am naturally skeptical that there may be bugs with this DLL. 39dll has some flaws, perhaps, but none that have directly or noticeably caused any problems. It has also been around for many years, and gone through several revisions, and people have released their online games with no troubles (in regard to the DLL itself). This DLL would need time to grow on m. I'm unlikely to upgrade to this DLL until the public has had it's chance to scrutinize any possible flaws, etc.

That said, I still look forward to this DLL, and will be sure to keep my eye on it. I am happy to upgrade to a better DLL as long as the transition is simple and worth the effort. Fix the flaws in the 39dll but maintain the ease of use.

Good luck =)

-Tv
  • 0

#11 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 18 October 2010 - 02:16 PM

@TV: thank you for your overview, however I had already thought of doing backward compatibility, so no need to rename/rework any of your game's code (you would just take out 39sters version and plug mine right in). But mine will have added features obviously, if you need/want to use them.

Finally, I am naturally skeptical that there may be bugs with this DLL.

Quite disheartening to see, but that's ok, my c++ is rusty. I'm hoping the community can help squash the bugs when I put this in beta stage.

39dll has some flaws, perhaps, but none that have directly or noticeably caused any problems.

Not many people use the buffer system, they just write/read the default buffer and clear it when done, so they wouldn't notice the problem at all. However, I do use the buffers greatly, so not only is my library broken from it, but some of my personal scripts are as well....and everyone who relies on them are screwed. It's no biggy though, the extensions I have planned alone will hopefully put this at the top :)

@All: I have updated my original post, as well as the dll. I somewhat finished the socket class, but I have to get to bed. I still hope to have a demo within a week or 2...fingers crossed!
  • 0

#12 Marchal_Mig12

Marchal_Mig12

    The Rhouan

  • GMC Member
  • 1153 posts

Posted 18 October 2010 - 04:52 PM

I am glad someone is finally taking over 39ster work :). Could you add up some more distinct benefits on top of the features you're adding to 39dll. Also, as someone suggested before, it is no so funny to add mp_ before each script. If you could get rid of those, it would be perfect.

Finally, I believe this topic belongs to the DLL one instead ;).

Mig
  • 0

#13 2DLuis

2DLuis

    Graphic Designer

  • GMC Member
  • 2493 posts
  • Version:GM8

Posted 18 October 2010 - 07:36 PM

I did not know this was a problem, can you explain in more detail about this?


Sure. Say in your GM client, you structure a message like so:
clearbuffer();
writebyte(MSG_ID);
writestring(global.user);
writestring(global.pass);
sendmessage(global._tcpsock);

When you receive said message in a c++ server, you have to do something like below:
                            sbuffer = readstring(0);  
                            strcpy(Players[i].Username, sbuffer);
                            sbuffer = readstring(0); 
                            strcpy(Players[i].Password, sbuffer); 

That is assuming you initialized your variables as follows:
// Though this is not too pertinent to the problem
// Player class
class Player
{
    public:
        double Sock;
        char Username[255];
        char Password[255];
        char* FileName;
        short AccID;
        short PlayerID;
        char* IPAddress;
        bool InUse;
};

And initializing the buffer variable as follows:
//39DLL Fix (global variable)
char* sbuffer;

And if you were to not do this, you would receive the first string just fine, yet the second one would become enmeshed with random data.

That is just cut paste from my c++ engine, so it may be somewhat sloppy,

Edited by 2DLuis, 18 October 2010 - 07:40 PM.

  • 0

#14 True Valhalla

True Valhalla

    ಠ_ಠ

  • Retired Staff
  • 4938 posts
  • Version:GM:Studio

Posted 18 October 2010 - 10:24 PM

Finally, I am naturally skeptical that there may be bugs with this DLL.

Quite disheartening to see, but that's ok, my c++ is rusty. I'm hoping the community can help squash the bugs when I put this in beta stage.


Haha, I have no doubt you are a very skilled programmer, my point is simply that everyone makes mistakes. 39dll has had years to be refined and has been used in many projects. I'm sure the community will be able to iron out any flaws (if any!) :D
  • 0

#15 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 18 October 2010 - 10:56 PM

When you receive said message in a c++ server, you have to do something like below:

That looks like how it is suppose to be done, so I'm not sure I follow. What have you tried to do and it failed to work?

In my opinion, here is an easier way, but bypasses the buffer class altogether:
char* buff = new char[5000];
int len;

size = recv(s->sockid, buff, 5000, 0);
if (size > 0)
{
  len = strlen(buff) + 1; //get location of second string
  strcpy(Players[i].Username, buff);
  strcpy(Players[i].Password, buff + len);
}
delete(buff);

"buff" can be pre-initialized in a more public manner so that it doesn't have to keep being allocated and freed for each call.

The other issue, but is not a 39dll problem, is that TCP is a stream protocol, which means that you may very well receive the first string but not the second one....so the "strcpy" of the buffer at the second string's position will be garbled RAM data rather than from the buffer.

You can circumvent this by sending a 1 or 2 byte integer denoting the size of the total message being sent (or use 39dll's currently built-in feature using format=0). When you start receiving information, just append it to the buffer until the size of the buffer correlates with this value, then call your function, shift the buffer down, and you're ready to continue with the next message.

As it looks right now, my upgrades to 39dll will help both GM and c++ programmers, while the original was intended primarily for GM use...although it will be nothing like RakNet.
  • 0

#16 LoopStan

LoopStan

    North-See Developer

  • GMC Member
  • 1398 posts

Posted 18 October 2010 - 11:44 PM

Yes 2Dluis, you have to have a buffer variable. I am really to lazy to post the stuff I used on here, but you shouldn't be using 39dll in a c++ app anyway, you should be making it so you can use it on linux and get super fast server speeds and more up time :)
  • 0

#17 Revel

Revel

    ɹǝqɯǝɯ ɔɯƃ

  • GMC Member
  • 4873 posts
  • Version:GM8

Posted 19 October 2010 - 12:30 AM

you should be making it so you can use it on linux and get super fast server speeds and more up time

RakNet *cough* :chikin
  • 0

#18 lasttea999

lasttea999

    GMC Member

  • GMC Member
  • 290 posts

Posted 19 October 2010 - 01:28 AM

This all sounds great... but only vaguely! I think that there are many GM users who, like myself, are using 39dll with only the bare minimum of required knowledge. I wish I could comprehend all that goes on within the DLL, but, alas, I am as yet unfamiliar with C++... You could argue that this demonstrates some degree of irresponsibility, but on the other hand 39dll seems to have opened up many new possibilities among GM users, and besides, how useful can an extension be if you have to know how to make it to use it?

Would it be possible, then, to provide a tutorial on this upgrade at some point, detailing, in particular, the changes between this and the original and the improvements it has incorporated?

Thank you to all of you diligent programmers for your efforts!

Edited by lasttea999, 19 October 2010 - 01:31 AM.

  • 0

#19 Revel

Revel

    ɹǝqɯǝɯ ɔɯƃ

  • GMC Member
  • 4873 posts
  • Version:GM8

Posted 19 October 2010 - 03:41 AM

Would it be possible, then, to provide a tutorial on this upgrade at some point, detailing, in particular, the changes between this and the original and the improvements it has incorporated?


It will be basically identical to 39dll, but more efficient back-end, some bugs fixed, and will have some more features which you don't necessarily have to learn.

Edited by Revel, 19 October 2010 - 03:41 AM.

  • 0

#20 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 19 October 2010 - 08:42 AM

Would it be possible, then, to provide a tutorial on this upgrade at some point, detailing, in particular, the changes between this and the original and the improvements it has incorporated?


It will be basically identical to 39dll, but more efficient back-end, some bugs fixed, and will have some more features which you don't necessarily have to learn.

And I will also be writing a new tutorial for all aspects of networking when I'm finished. I only ask for patience while I juggle work/life/hobby.


Edit: Didn't want to double post, although most will probably oversee this considering it's not going to bump the topic, but I figured I'd put it here just in case.

I have updated the file, it now contains the main.h/main.cpp files situated with a backbone structure. I decided to clean up a few things and redid DList class since creating/freeing memory just for an integer seemed a bit overkill, instead it uses a loop to search for a NULL in the list and assigns it (which the original 39dll did the same thing, but mine doesn't push the list down).

After cleaning up as much as I could, I accidentally hit the build key and the error list hit me like a ton of bricks. I knocked all of them out of the park except for 3 (which is actually 1, just done 3 times). I will be asking a few friends, but I'll post it here too just in case someone can help...

sprintf(&Digest + i * 2, "%02X", (char*)(&Ret[i]));

That kicks back an error saying:

"Ret: cannot change 'char (*_w64)[65]' to 'char*'" or something

I have tried every means possible, turning the pointers inside and out and I just cannot get the darn program to understand that I want to pass a UINT32[8] array byte for byte to get the hex digits. The "Ret[i]" code is wrong already because it needs to be casted as a "char*" so that it can go 1 byte increments, but somehow this doesn't work either (which I originally had):

(char*)Ret[i]

I figured since Ret[] was a static member of the class, it didn't have a pointer association, so that's why I switched to &Ret...then I thought:

((char*)&Ret) + i

But that doesn't work either....or did I try that? I'm tired now, I'll hit this up tomorrow after work.

Edited by sabriath, 19 October 2010 - 01:35 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users