Java System

Posted By: Damocles

Java System - 08/10/06 19:45

I am currenly playing around with a Multiplayer System on Java basis,
so that the connection and datatransmission is handled by the Java Client/Server
and the Java client communicates with the 3dGS enviroment.

This gives me a lot more in flexibility than the native Gamstudio Multiplayer
commands. (no entity-handeling overhead, no session connect problems, or
client limitations)

it is not a serious development for a certain game, more like a testrun, if
all the concepts work together.

The datatransmission will be not fast enough for a shooter, but sufficient for
Online Roleplaying or RTS.

The first step is to get a decent Java client/server, that works on the internet,
and transmits data-packages and chatstrings.

the next step is to bind the Java client to 3dGS (in a very crude -but functioning- way currently,
for a more eloquent approch I need the help of a C++ programmer)


The gameserver could be linked to a 3dGS enviorment, or handled fully by a Java instance.
(this way it is possible to run the server on common Linux online hosts)
Java has got a good database connectivity too.


The reason why i use Java, is bacause I am trained in it, and dont have a good
knowledge on C++. Java is very flexible for large programs, that dont require
a 3D rendering.


I will posts some stuff, whenever I have a Java Client/Server (Chat), to test
the online connectivity, and amount/speed of datatransmissions.

3dgs does not need to run in the faulty multiplayer mode,
which enhances the development.


Does anyone have experiences with Java (Socket programming), and how
it handles online? The hard thing will be to tackle the router-issue.
Posted By: EpsiloN

Re: Java System - 08/10/06 21:17

I was thinking about that , about making the server a completely diffrent program. My first thought was about mIRC sockets , databases...whatever you wish , and its fast. It doesnt render anything...the only problem that I thought about was that mIRC doesnt have wait functions.
But I didnt even tested this , because I remembered the 'dedicated server' command isnt this the same ?
Posted By: Damocles

Re: Java System - 08/10/06 21:25

The difference is, that 3dgs does not control the multiplayer connection.

This gives more flixibility.
Though, the collision detection needs to be calculated in Java then.
But this can be done for less complex RPG Levels.
Java gives you more options for really complicated Ai and Gamecalculations
(Object oriented).
It is not trivial to program though.
Posted By: Damocles

Re: Java System - 08/12/06 12:36

Ok, the chatserver works over the net with my router...

good starting point to test more complex datatrasmission
Posted By: TWO

Re: Java System - 08/14/06 20:40

Any news an this thing? I would like how you handle the vars (so, how you define for which var you sent the value) and if you use the IDs of A6 or another system to sent entity skills and params;

Thanks for advice,
Bloodline
Posted By: Damocles

Re: Java System - 08/14/06 22:28

Since I dont have a dll plugin currently, I have to use a very crude method to
communicate with the Javaclient.
CScript Basically encodes the information to be send into a specific format,
and reads it out that way.
The Javaclient on the other end does the same, and transmits the data to the server.

Variables cant be written directly into the communication link between Java and 3dgs.
There is a function written in c-script, that saves the ID of the variable and the value.

the same goes for strings, altough strings are mainly used for the chat channel, so
it is handled a bit different.

the variables have an defined ID number. Such that var is_raining for example
gets the predefined ID 445.

so sending "445 1" can be read out as, variable is_raining = true, by the javaclient.

Entityskills, need to get the id of the entity and the skillnumber, and the value.

The java-client can transmit these values, and the Java-server can asign them to the
related object-instance.

So the Java-Server could handle the whole Gamelogic on Java-Basis.
With all the advantages (like object oriented programming, SQL Connection,
Useful GUI for presenting the current server-data, AI based on objects, Linux compatibility)

Stuff like collision-detection needs to be calculated by Java itself though.
But this is managable whenever the gameworld is designed more abstract, without
detailed collision detection.


Curretly I can send variables and Strings to the clients, and by them to the server, and return
the data to specific or all clients.
Its still just a test ot mehtods and not for a specific game. Maybe one wants to take
up the system to transform it into a MMO game system.
Posted By: TWO

Re: Java System - 08/15/06 09:30

Nice, I know that all things in C-Script have IDs, and I know how to read it from an entity but how do you get the IDs of the vars?

Bloodline
Posted By: Damocles

Re: Java System - 08/15/06 15:53

Im Augenblick ist das alles sehr primitiv gehalten.

Fest definierte variable werden in der Sende und Emfange version direkt ausgelesen.

read_id -> id aus dem Datenstrom
read_value -> zugehöriger wert

zB, abfragen aller möglichen cases:
...
if(read_id==13){is_raining=read_value;return;}
...


beim schreiben:

...
if(move_forward!=move_forward_old)
{
move_forward_old=move_forward;
send_id=13;
send_var=move_forward;add_to_sendlist(send_id,send_var);
}
...

so ist erstmal das prinzip,

es gibt sicherlich die möglichkeit variablen "direkter" auszulesen,
aber das ist dann eher ne performancesache.

Die Menge der Daten auf der Clientseite, die gesendet werden ist ja auch sehr
viel geringer als die empfangenen werte in einem MMOG.
Posted By: TWO

Re: Java System - 08/15/06 16:25

Hmm, also für Entitys gibbet die interne A6 ID, die auch per handle(entity) ausgelesen werden: http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/679739/an/0/page/0#Post679739

Für die Variablen müsste es au sowas geben, ich frag mal JCL
Posted By: Damocles

Re: Java System - 08/15/06 19:59

Wichtiger als die performance ist allerdings, das der code gut lesbar und leicht nachvollziehbar ist.
Deswegen würde ich eher die langsame aber intuitive methode mit dem auslesen über
variablen-namen benutzen.
Wenn der Code sehr groß wird, ist er so leichter zu debuggen und zu verändern.
Bei einem Multiplayerspiel liegt das größte Performanceproblem bei der Netzwerkverbindung,
und den damit zusammenhängenden Datenstrom, und weniger beim Code der auf dem Client berechnet wird.
Posted By: TWO

Re: Java System - 08/15/06 20:46

Hehe, ich hab jetzt (per RakNet) mit dem mit Variablennamen, ohne dass man was vordefinieren muss. Ich weiß nich obs dir was hilft, aber hier maln stück source:

Code:

DLLFUNC void Sv_SentVar(STRING* varname)
{
g_Server.SendVar(_CHR(varname));
}

DLLFUNC void Sv_SentVar(STRING* stringname)
{
g_Server.SendString(_CHR(stringname));
}



//===========================================================================//
// Methoden: Send Var
//===========================================================================//

void A6Server::SendVar(char* name)
{
int value = (int)engine_getobj(name);

StaticServerPacket_Var packet;

packet.packetID=61;
packet.Var_name=(char)name;
packet.Var_value=value;

server->Send((char*) &packet, sizeof(StaticServerPacket_Var),HIGH_PRIORITY, RELIABLE_ORDERED, 0,UNASSIGNED_PLAYER_ID, true);
}

//===========================================================================//
// Methoden: Send String
//===========================================================================//

void A6Server::SendString(char* name)
{
char value = (char)engine_getobj(name);

StaticServerPacket_String packet;

packet.packetID=62;
packet.String_name=(char)name;
packet.String_value=value;

server->Send((char*) &packet, sizeof(StaticServerPacket_String),HIGH_PRIORITY, RELIABLE_ORDERED, 0,UNASSIGNED_PLAYER_ID, true);
}


Posted By: Damocles

Re: Java System - 08/15/06 23:28

Danke für die Codezeilen,
wenn ich mich mit der "eleganteren" Verbindung zwischen 3dgs und dem Java
Client befasse, werd ich darauf zurückkommen.
Ich kann allerdings noch nicht mit C++ dlls umgehen... Dazu werd ich denn eventuell
einen erfahrenen C++ Programmierer ansprechen.


Here, check this paper:

A Distributed Architecture for Massive Multiplayer Online Role Playing Games (PDF)
© 2024 lite-C Forums