Jump to content

Making JA single player scripts work in JA multiplayer


violaboy13

Recommended Posts

I'm sure others have worked on making the single player levels work in multiplayer, especially those interested in co-op mode,  However, I'm new to this discussion and OpenJK and am very interested in co-op.  What would have to happen to the multiplayer code to allow the single player scripts to work in multiplayer?  I know Icarus files control scripting, but I also know that I can't just add or replace Icarus files from the singleplayer code into the multiplayer code.  In fact, any attempt I've made to add a file from singleplayer code to multiplayer code (e.g. AI_AssassinDroid.cpp) results in compilation errors from q_shared.h.  Does anyone have thoughts as to how to merge (at least on some level) files from singleplayer JA into multiplayer JA?  Do the singleplayer files have to be significantly rewritten to conform to the multiplayer code?  Thanks for anyone's help.  As you might have guessed, I'm new to C++ and OpenJK coding.  On the other hand I'm very persistent and am willing to learn.

Link to comment

Open Jedi Project is 6 years out-of-date and well before we had access to the singleplayer code from Raven.  Because of this, their attempt at co-op was hacked together as they wrote their own scripts and tried to handle the camera cues etc.  Most of the single players levels only kind of worked in OJP.  I'm more interested in a deeper merging of singleplayer elements into the multiplayer framework.

Link to comment

OJP had access to parts of the single player code.

 

This is no task for someone who is too new to programming general honestly.

 

The reasons for your errors is because the MP sdk is only C, not C++.  Plus there are tons of differences of course in the AI files themselves that wouldn't be compatible with MP out of the box.

Link to comment

Why is the MP sdk written in C instead of C++?  Is it faster code / more portable?  What's the point?  Could some of the single player code be rewritten in C (at least by an experienced programmer)?  Or could the MP sdk be rewritten to accommodate c++.  I can imagine both of those approaches being massive projects and well beyond most people's time/abilities.  However, it's useful to know what the practical limits are.  Thanks for your input.

Link to comment

Because the original codebase was all C (Quake 3 Arena).  And because the SDK in Q3A and JK2MP were only using "Quake Virtual Machine" which only supports "C".  The decision to drop QVM support for JKA MP was done later on in development but it retains C.  Mind you most of the rest of the codebase is still C or C-like even though it is .cpp.  There are differences in how C++ handles some things which is why it fails to work out of the box.  For example you cannot cast a void pointer (void *) to any old type in C++ like you can in C.  And enums are more strong typed in C++ than in C as opposed to being simply integers. Among other things.

Link to comment

It's in C because the Quake 3 .qvms were written in C. You can convert the SDK code to run on C++ since there's no more .qvms, but it's no small task. Single player is really just a heavily modified MP with vestigial multiplayer stuff remaining (it still sends data from server<->client using a UDP connection).

 

You have three ways to proceed:

1. Alter MP to run using C++ and then port the code over. Both actions are no easy task, but you can maximize SP emulation.

2. Code back in the SP features manually using C. Frankly the easiest to do, but you really need to know what you're doing.

3. Change SP code to run MP. The game was simply not designed to do this, but you have the benefit of one EXE/program instead of separate executables for SP/MP, AND that would fix the issues with Steam. Easily the hardest of the three options, but the most to gain.

Link to comment

Open Jedi Project is 6 years out-of-date and well before we had access to the singleplayer code from Raven.  Because of this, their attempt at co-op was hacked together as they wrote their own scripts and tried to handle the camera cues etc.  Most of the single players levels only kind of worked in OJP.  I'm more interested in a deeper merging of singleplayer elements into the multiplayer framework.

I noticed, strangely enough, there was some recent activity on the project over here: http://www.lucasforums.com/forumdisplay.php?f=542

 

Someone should get them to come over to Jkhub.

JKG Developer

Link to comment

Thanks ensiform and eezstreet for your knowledgable comments.  As far as converting C++ to C would something like LLVM be useful or would you definitely have to manually rewrite the cpp files into c?

LLVM is not relevant at all, don't know where you decided to pull that out of.

 

You do realize that C++ is a subset of C right?  The issues you need to solve are the differences between the codebases mostly.  Some of the files may not even contain any C++ as it is.

 

I think you should probably wait until someone with experience decides to take up the task of bringing SP to MP engine for coop.

Link to comment

Thanks ensiform and eezstreet for your knowledgable comments.  As far as converting C++ to C would something like LLVM be useful or would you definitely have to manually rewrite the cpp files into c?

You could do that but it would be a lot more work than just converting manually by hand. As far as I know, the only C++ features they used is classes which can be transformed very easily into regular C structs:

 

 

class Foo {
public:
  int x, y, z;
  void DoTheThing(int n);
  int DoTheOtherThing(int a);
};

 

Becomes:

 

struct Foo {
  int x, y, z;
};
 
void FooDoTheThing(Foo *this, int n);
int FooToTheOtherThing(Foo *this, int a);

 

You do realize that C++ is a subset of C right?  The issues you need to solve are the differences between the codebases mostly.  Some of the files may not even contain any C++ as it is.

I think you mean C++ is a superset of C (though even that isn't strictly correct either :P)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...