Crystal Space
Welcome, Guest. Please login or register.
October 31, 2014, 06:38:57 am

Login with username, password and session length
Search:     Advanced search
9011 Posts in 2044 Topics by 8896 Members
Latest Member: Msenglcarl03
* Home Help Search Login Register
  Show Posts
Pages: 1 ... 5 6 [7]
91  Crystal Space Development / Support / Eventhandling on: February 15, 2005, 01:49:42 pm
I am writing networking-support for my application:

o My server is waiting for incoming data (type: char*).
o When data arrives, the servercode fires an event.
o This event is caught by my networkingmodule which has an eventqueue and computes the received data.

Now I have some questions:

1) My server inherits from iEventOutlet and does the following:

Quote
this->netevent = CreateEvent();
this->netevent->Add(XXX);
Post(this->netevent);


what do I have to insert into "XXX"?
I guess I have to use
Code:
virtual bool iEvent::Add   (   const char *   name,
  const char *   v
  )

-> "const char* v" will be my my received data?
what shall "const char* name" be?

2) My networking-module inherits from csBaseEventHandler.
I know I will use one of the several methods to compute my event-data but how do I catch events from the server-code?
There should be a "link" in the code between server and netmodule, but how can I establish it?

3) What is the difference between broadcasts and commands?
92  Crystal Space Project Development / Bug Reports / CS buildsystem has some issues... on: February 15, 2005, 02:06:36 am
There are some issues I found in the snaphsot 2005.01.25.
I didn't find changes in the mailinglists so these issues surely are in the latest cvs-version too.

1) "jam install" compiles csapps and plugins before installing - why??
When I want to make "jam libs && jam install" only I don't need plugins and I really don't need apps. It's a huge waste of time and energy.
2) "jam install" does not copy libs to prefix-dir when used configure --enable-shared
3) After "jam install" none of the apps works. All apps only work when they are left in the CS directory or they won't find their config (e.g. vfs.cfg) or data (e.g. mapfiles).
The config-files will be installed to prefix/etc but CS expects them in prefix/lib/crystalspace.

Setting $CRYSTAL doesn't help in any case.

=> configure --prefix doesn't work
=> jam install doesn't work
93  Crystal Space Development / Support / Linker Error when I try to compile my CS-app... on: February 10, 2005, 01:49:46 am
waaaah! Damned cr*p sh*t! After FOURTEEN HOURS (today and several hours this week) I have found the error!
This SHOULD have been documented somewehere.... evil

All class members that are created by me must be pointers.
They must be instanciated in a *separate* method that is called from within Application()

Quote
class Server : public csApplicationFramework {
private:
    iObjectRegistry* objectRegistry;
    csRef<iEngine> engine;
    csRef<iLoader> loader;
    csRef<iVirtualClock> virtualClock;
    csRef<iReporter> reporter;
    csRef<iStandardReporterListener> reporterListener;
    csRef<iCelPlLayer> physiclayer;
    csRef<iCelBlLayer> behavelayer;
 
    Network* net; //this was not a pointer before
 
public:
    Server();
    virtual bool OnInitialize(int argc, char* argv[]);
   void doThisCrap(); // yes, do it!
    virtual bool Application();
};

-------------Server.cpp:------------

void Server::doThisCrap() {
  net = new Network();
  net->foo();
}

Server::Application() {
...
Open();
doThisCrap();  // I had net = new Network() here before
Run();
}


I'm crazy now, this is nuts....
94  Crystal Space Development / Support / Linker Error when I try to compile my CS-app... on: February 10, 2005, 12:37:21 am
I created a CS-app based on csApplicationFramework.
Everything worked fine some time ago but now I get linker errors when I try to compile my applicaton.

This is my main-class:
Code:
class Server : public csApplicationFramework {
private:
    iObjectRegistry* objectRegistry;
    csRef<iEngine> engine;
    csRef<iLoader> loader;
    csRef<iVirtualClock> virtualClock;
    csRef<iReporter> reporter;
    csRef<iStandardReporterListener> reporterListener;
    csRef<iCelPlLayer> physiclayer;
    csRef<iCelBlLayer> behavelayer;

    static Network net;

public:
    Server();
    virtual bool OnInitialize(int argc, char* argv[]);
    virtual bool Application();
};


I want to initialize my networking code within Application() between Open() and Run(), but I get the following error:

Code:
g++ -o out/bin/Server src/server/Server.o src/server/network/Network.o  -Lout/lib/crystalspace -Lout/lib/cel -lcstool -lcsgeom -lcsutil -lceltool -lptypes
src/server/Server.o(.text+0xb02): In function `Server::Application()':
: undefined reference to `Server::net'
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L15' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L16' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L18' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L20' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L21' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

collect2: ld returned 1 exit status


but why? This is crazy, I tried it with and without pointers, I had rewritten 80% of my code to get rid of this error.
Why is it impossible to create a class or use a method in my csApplicationFramework?
I tried OnInitialize() too but then I get the same error.
I *must* be able to create some classes but where?
I hope I don't need to write every class I want to use as a plugin or with SCF...
95  Miscellaneous / Article/Tutorial Requests / Creating a CS-Project... on: January 24, 2005, 09:34:21 am
I guess that's impossible with jam, mostly because of it's crappy documentation.
I found "scons" and the docs there are great. It can do exactly what I want and has an example for everything.

jam go home!
96  Miscellaneous / Article/Tutorial Requests / Creating a CS-Project... on: January 20, 2005, 08:03:03 pm
no, what I want is a doc how to create a jam-project file for a cs-app.
But this jamfile has to take care about CS and external libs that are needed in the cs-app.
For example:
"jam mycs-app" has to compile my cs-app but in this case, CS isn't compiled yet, so jam compiles CS first (and other apps that are included in that project too).

All these apps are included in the mycs-app project because mycs-app ships all it's needed (not common) libs with it, e.g. python 2.3.4, sqlite 3.0.8, CS 0.99CVS2005xxxx, CEL...

That's purpose #1 for this project-file.
Purpose #2 is that "jam mycs-app install" creates a tree which includes all the mycs-app binaries, libs and all other libs like CS, sqlite, python, foo... like this:
/mycs-app
|-bin
|-lib
... (as I wrote above)

A good example is a game like UnrealTournament that has a special directory structure and ships everything with it.
You can move the files to a directory wherever you want and when you delete the unreal-dir, everything is as clean as before.

The background is: we don't want our gamers to download each lib in a special version from several places, untar it, compile it, install it deep into their system (where they will never find and uninstall it) to be able to use our game.
Instead we have just one package, everything works fine, play it and when /mycs-app is deleted, then everything from us is history on that machine.
A package like this is userfriendly (one click and ready to go) and developerfriendly (we know where our files are, we know that they work together, we know that we don't depend on anything on the gamers machine)

An installer is different from that, it copies the files interactively to some place, creates configfiles and maybe even an uninstaller, but that's not what I need.
97  Miscellaneous / Article/Tutorial Requests / Tut-request for game-scripting on: January 20, 2005, 01:00:07 pm
Quote from: dirkk
Hmm, I didn't deal with CEL at all at this moment. It seems, I should look at it more closer, this much I understood. When are people supposed to take plain CS, CEL or the PlaneShift code base?

I guess, plain CS is good when you need it as a comfortable OS-independent class-library for developing other software than games.
(Maybe you don't like the STL and cannot use QT or another lib like that)

CEL is a great help for every game based on CS, it implements many many mechanisms you need to design, code and test by yourself when you do not use CEL. It is more high-level so you will have more sparetime when you use it Cheesy (once you have understood it, of course ... Sad)
My game-project did not use CEL but we saw that CEL takes care of all those tricky things we planned for months. It is really helpful, when you use objects and their graphical representation, events+communication, scripting, etc in your app.

And using planeshift... hmm, I guess this only makes sense when you're a planeshift-developer Cheesy
Any other project should use CS or CS+CEL, because planeshift is no development kit. (but you can peek how they solved a special problem Cheesy)

Quote
Concerning the tutorial, I admit that I didn't understand too much, mostly of course because I don't know CEL. Also, I prefer tutorials with a more 'hands on' over a theoretical approach. But hopefully it is of use for someone who is more into CS/CEL than me.

The purpose of my tut is to give the reader a basic understanding about the relationships between PL, PC, BL and Behaves from CEL.
When someone reads the available docs, he only gets an idea about CEL's techniques but this is too vague to understand CEL itself and how to use it in a CS-app.
Imagine CEL as a box of Lego-stones:
The available docs only describe the simple stones in that box.
You have to find out how to build complex objects without knowing how to combine the stones.
My tut wants to tell how to combine the stones (assuming you already know them). Creating a complex object should be easy (or at least easier) then.
98  Miscellaneous / Article/Tutorial Requests / Tut-request for game-scripting on: January 19, 2005, 11:37:54 pm
woah, I think I've got it!

I have written this tutorial in german for my team, I hope the translation ist usable:

---------------8<---------------
Scripting with CS+CEL
We have (exactly) one PhysicalLayer (PL). The game-server creates it on startup.
The PL creates Entities, for example a cow, whenever we desire this.
We can attach PropertyClasses (PC) to our cow, we do this with the PL (and PL-Factories, but that's not important for python-scripting).
Which PCs an Entity needs must be thought of, we could give our cow a iPcTooltip to show her hitpoints in a tooltip.
(btw: cow does not inherit from the class entity)

ok, let's celebrate:
We didn't mention the BehaviourLayer (BL) yet. That's the thing we will code in C++ or script with python!
Until now we have created a class named "cow" which shall get a tooltip attached.

So we write a class "cowTooltip". This will inherit from BehaviourLayer.

Let's take a look into the API-docs from CEL. There are two classes: iCelBlLayer and iCelBehaviour.
The first one is the BL itself, we create only one BL in the game, just like the PL. (I had to notice that there is a difference between BehaviourLayer and Behave!)

iCelBehaviour * CreateBehaviour (iCelEntity *entity, const char *name)

is a method from the BL.
That means that our BL can attach something (a string) to an entity and this  "product" is a Behaviour.
It's possible to call this method more than once, so the entity can get more Behaviours.
This string is the name we choose for our Behaviour, in our example "cowTooltip".
So let's take a look at iCelBehaviour.

The most important method from this class is:
bool SendMessage (const char *msg_id, celData &ret, iCelParameterBlock *params,...)

I wrote that cowTooltip inherits from the BL, so it gets this method which apparently is for communication-purpose.

Every PC posesses one or more message-types we can handle in this method.
For example "pcmeshsel_up" is being sent when the mouse is being moved over a mesh (we can assign a mesh to our cow, that is the 3D-representation we can see on the screen).
In this case the message_id-parameter in the SendMessage()-method is "pcmeshsel_up". Other events may send other message-types, for example "pctimer_wakeup" or "pcinventory_added", ... (you can see a list in the CEL design document and maybe somewhere in the API-docs).
Additional a list of parameters can be delivered too.

So our SendMessage()-method could do something like this when the message-type is "pcmeshsel_up":

...
pctooltip->SetText(entity->GetName() + " has 20 Hitpoints!");
pctooltip->Show(50,50);
...

This will open the tooltip over the cow at position 50/50 and it will show the text "cow has 20 Hitpoints!" (of course you shouldn't hardcode the number 20 *g*)

So:
Entity-creation will be handled by the game-server but the Behaviours can be written in Python.

You may take a look at the files in cel/plugins/behaviourlayer/test, especially behave.cpp and behave.h.
These files contain a general behaviour-class and some behaviours (actor, box, room, printer).
The othere files there are the interface-definition for the CEL-plugin "test"

In the directory cel/plugins/behaviourlayer/python lies the python-plugin. It's partly created by SWIG, an interface-compiler to connect different programming/scripting languages.
In it's interface file blcel.i you can see all the methods that can be used for python-scripting (and that should be allmost everything dealing with PL, BL end PCs)

Oh, and you should have read
http://cel.sourceforge.net/design.html
http://cel.sourceforge.net/docs/online/api/
http://www.once.net.nz/wiki/moin.cgi/DevelopersFAQ?action=show
http://planeshift.sourceforge.net/celtut/cel.html
to understand CEL.
---------------8<---------------

What do you think about this tutorial? It's still pure theoretical and not tested with code, but I think that is it.
99  Miscellaneous / Article/Tutorial Requests / Creating a CS-Project... on: January 19, 2005, 04:40:40 pm
The documentation lacks an important topic: "How to create a CS-project"

The docs only talk about how to compile a CS-app, but when CS shall not be installed into the system-tree and when external libs (that shall not be installed too) are needed for this app, then we have a very complex task.

This tutorial should give answers to the following questions:
- how to create a "good" project tree with CS and external libraries (e.g. python, a network-lib, a database, <what a project may need>...).
- how to create a jamfile that handles compiling of these external libs (by invoking their makefiles)
- how to create files with gamedata with jam (e.g. zipfiles with sounds or pictures, or databases, ...)
- how to create binaries that can be installed everywhere (without dependency of absolute pathnames)
- how to handle those env. variables $CRYSTAL and $CEL in a smart way (e.g. with a configfile that is created by an installer). Setting these variables sucks and many windows-dummies don't know how to set an env-variable...

example:
A CS-app with a 3rd-party network-lib shall be created. How to include the netlib into the project?
How to create a compile-output-directory for that CS-app like
/CS-app
|-bin
|-libs
|  |-netlib
|  |-CEL
|  `-CS
`data
  |-soundfiles
  `graphics
so that "/CS-app" can be installed everywhere in the path? (=How to include everything needed into the game's distribution).
It shouldn't matter when a user wants to install the app into /usr/games oder /opt or on a windows-machine into c:\games\CS-app oder c:\program files\CS-app

I know that this is mostly jam-related, but the jam-docs aren't easy to understand. I needed some weeks to find out how to modify the jamfiles created by CS's jamtemplate-script (is it mentioned somewhere in the CS-docs?) for my needs and I'm still not satisfied because all those external libs are not yet integrated, depend on an absolute path and are compiled with a shellscript instead of jam...
100  Miscellaneous / Article/Tutorial Requests / Tut-request for game-scripting on: January 19, 2005, 12:42:27 pm
yes, taking a look into the examples is fine when you know the basics, but learning a new mechanism/technique only by examples isn't easy.
And scanning a complete project like planeshift for some basic CS-coding answers is impossible, you have to learn everything about this project first (structures, classes, project-tree, ...) and then you may find what you are searching for.
Learning CS is difficult enough wink

For example: I want that an AI-Player goes to position x/y/z in a map when event e happens.
This behaviour shall be scriptable with python.
But how to invoke this script from a CS-app?
And how to bind this script to this AI-Player? (with a CEL-PropertyClass, when AI-Player is an Entity?)
What can someone do with scripting? Which methods/classes from CS/CEL are usable (and how)?
(How) Can own methods/classes be made usable for scripting?
Pages: 1 ... 5 6 [7]
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 9.228 seconds with 16 queries.