Well... as you can see.. there is alot going on here.. But I will try my best...
To start off.. on the server portion of it all.. I am using EasyPHP 5.3.0... really only for the apache web server portion of it tho.. server is running Win XP SP3. I have Jabaco and MSVB 6.0 Enterprise installed. The server still is not converted to Jabaco.. as that is a whole new can of worms I have not yet opened up for several reasons. The 'server' has 3GB ram, and 2x 2.00GHZ for processor.
Basically.. the client uses one of the 'commands' ... named .. CORD... to say to the server... Im at this xy position, on this frame, in this direction, my username is this... etc...
The server knows who you are.. and where your information is supposed to go... everybodys info is held in a user defined type.. and it looks like this:
In VB6/server:
Public Type UserTracking
MapNum As Integer
x As Integer
y As Integer
charType As Integer
charDir As Integer
charFrame As Integer
Username As String
lvlExp As Long
lvlMag As Long
lvlMoney As Integer
End Type
Public Userdata(0 To 500) As UserTracking
(Also, there is a winsock control.. that duplicates itself if enough sockets dont already exists.. named sckServer(), and Userdata(value) and sckServer(value) correspond to each other on server side, always.
When you log into the server.. it reads thats users copy/index of the user defined type [userdata(index)] from binary file from disk.. and saved when you disconnect or logout in the exact same manner.
On the client (in jabaco).. the same user defined type is declared.. and used.. also in an array... only.. 'yours' is always userdata(0).... everybody else's is sent from the server in the same CORD command.. its just verified first.. and throws each users index into the string before it actually sends it out to everybody else...
On the server:
CORD XX YY D CCC MMM III F NAME----> 'outgoing (to clients) format
CORD XX YY D CCC MMM F NAME----> 'incoming (from clients) format
On the client in jabaco:
CORD XX YY D CCC MMM III F NAME----> 'from server
CORD XX YY D CCC MMM F NAME----> 'to server
Whenever any of your values are changed, the client sends all the new values to the server to assure consistancy on all screens, its verified.. and resent to everybody connected.
The map drawing works in a similar manner..
MAPD command... which is sent to each client.. when you send same command 'MAPD <mapnumber_here>', only with one value to declare, what map # you want.
it sends back all the information about the map... as soon as it receives the first 'section' of this giant string.. the client knows to pause the animation loop (on timer1 i believe), then clear the map buffers and start over, then as each section of the map (individual tile information) is received, it draws it into the corresponding buffers, and when the last section of the big 'MAPD' string is received... it unpauses the animation loop.. and the new map is there..
Example to draw one tile (2 strings):
MAPD L2XS 10, 8 6|
MAPD L2YS 10, 8 4|
L2XS means .. draw it on Layer2 (walled objects)... its XS (xsource in the tileset), for position x10, y8 on the map.. eqauls 6
L2YS means .. draw it on Layer2 (walled objects)... its YS (ysource in the tileset), for position x10, y8 on the map.. eqauls 4
So.. at position 10,8 on the map... were going to draw a 32x32 pixel tile ..extracted from position 6,4 in the tileset... 10,8 would mean pixels 320,256 .. and its width and height are 32 pixels.
There are 4 layers, a background tile layer, which is the floor, and the floor tile layer holds two values, the x and y src in the tileset of what one single tile is the floor.
Layer 1, is objects that are on the floor..
Layer 2 is objects you or NPC's cant walk thru..
Layer 3 is translucent items the appear ontop of you..
Also I would like to note.. with the packets going back and forth./that current Const Delimeter = "|".. thats because a pipe (|) is what tells the client the whole packet has been received and is there, go ahead and process it, any new information thats received will go into the new packet... If you change this.. you must also change it on the server.
There is actually a limit of 450 sockets to be allow to be used.. this is because the last 50 index out of the defined 500 in userdata()... dont exist.. but instead refer to a similar user defined type for the NPC's.. 50 of them per server right now.. but the client sees NPC's as index 450 to 500 when using the CORD command... real users belong in 1 to 449.. 0 isnt used on the server.. because you always refer to yourself as 0 in the client.. AND the Winsock on the serverside.. [ sckServer(0) ] .. is always the listening socket.
I have used port 21 for the server so that when the client is ran as an applet, it thinks its connected to an FTP server and doesnt idle out (that i have noticed at least), and there is no need for ping ponging each other constantly or wasting bandwidth. Also.. port 21 and 80 (for serving) is not blocked by my ISP.. TW cable.. but all others seem to be.. =P
The VB6 server portion.. spits out a few .htm files that hold user data that is displayed when loading the applet from my website.. and the 'server console log' too.. and all of it is meshed together with another html file.. and some javascript was used to make those stat htm files reload every 15 seconds or so... the 'Logout' link also used javascript to close the window.
The reason I have not included the server, even as an executable yet.. is because i still have a few more things I want to do to it before releasing it... especially the source..
Eventually.. I want to sit down and comment the end of every line in both the server and the client.. but my time is limited right now, and hopefully I will get around to it here soon.
I think the best way to start this is for anyone to ask they're question now and Ill do my best to explain any part of it I have missed (which is a lot, i know.. i kind of just dont know where to start to be honest)..
Until later,
Jason