An interesting design question (portable)

Moderator
Posts: 370
Joined: 2006.08
Post: #1
Hello everyone Smile
I'm currently working on the structure for an MMORPG. (And yes, I can hear many of you scoffing as you read this, perhaps especially the people who have read some of my other posts Rasp ).
In all truth, I don't really expect to make a successful MMORPG, but I thought that I would go ahead and try because working on a tough project is often the best way to learn essential things about game programming.
Anyway, enough background and excuses, I'm now ready to lay out my problem; When I started this project, I knew that my code would have to be portable, and I would have to find a way to be able to make fairly large changes to gameplay while having minimal file upload size for the update. To this end, I've created a rather slow 3D object/texture loader that controls certain things in the game. Basically, I have these objects:

A game object. The game object reads a text file to find out what gameManager objects there are, and loads the templates for them. Then I have the gameManager object, which loads 3D object templates (like the 3D object for a monster). Each 'object' object has shape objects, which are essentially the shapes that the object mesh is made out of.
This works quite well for loading a pre-defined template, and so I have completed stage one of my project. Now what I need to do is to have some code in a different file that uses this to actually make objects. If I need three ogres, I'll have the object class load the template for the ogres, then I'll have this seperate program actually make the ogres in their respective locations.
I'm not quite sure how to do this (especially on a Mac!). On Windows, I was planning on using a DLL file, I haven't started this because I wanted to get input from the Mac side of things first.
Is there an equivalent to DLL files for the Mac? How do you normally have code in a seperate file that is used in your main program? Perhaps I am looking in the wrong direction, but it's the only way that I see it...
Thanks in advance for the advice Smile
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Linux calls DLLs "shared objects" (.so); Mac OS X calls them "bundles" (.bundle). Same concept.

The main difference is, they work on Mac OS X and Linux, and cause much grief on Windows. Good luck with that.
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #3
so...I can just copy and paste code from a windows .dll to a mac .bundle, or is it going to take some modification?
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
If you've managed to make your architecture work on Windows, chances are it'll work on the other two OSes, but the way you load function pointers from your bundle will of course be different, and the way you compile the code will of course be different.
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #5
ok, thank you for your help Smile
I suppose that it is possible to just have the IDE link the .bundle s so that you don't have dynamically load it or keep track of the function pointers and such?
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
If you're going to do that, you don't need DLLs or bundles at all... just use regular static libraries... or even just object files.
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #7
hmmm...
Well, the whole point of breaking up the project into seperate programs and DLL (or bundle) files was to make it so that when I updated the game, the player wouldn't have to download a very large file from the webserver. For instance: adding a new monster to the game wouldn't affect the graphics loading code, nor would it force me to change the code that connects and deals with the server, therefore I have a DLL for the graphics loading code, I have a DLL for the server connection code, and I have a DLL for the actual gameplay code. I then have a program that is somewhat of a shell, all it does is accept input and feed it to the DLL files. Can I accomplish the same thing using static libraries or object files? I really don't know..in fact, I have no knowledge of creating static libraries.
Here's an example of the code that I have in a DLL:
objectManager.hpp
Code:
#ifndef OBJECTMANAGER_HPP
#define OBJECTMANAGER_HPP

#import <gl\gl.h>            // Header File For The OpenGL32 Library
#import <gl\glu.h>            // Header File For The GLu32 Library

#include "object.hpp"
#include <fstream>

class __declspec(dllexport) objectManager
{
      public:

      object* objects;
      int numberOfObjects;
      double offsetX;
      double offsetY;
      double offsetZ;
            
      objectManager();
      void copyConstructor(objectManager* copiedObjectManager);
      ~objectManager();
      
      void loadObjects(const char* theManagerName);
      void moveX(double addX);
      void moveY(double addY);
      void moveZ(double addZ);
      void draw();
      
};

#endif
and in objectManager.cpp

Code:
#include "objectManager.hpp"

using namespace std;

objectManager::objectManager()
{
numberOfObjects = 0;
offsetX = 0.0;
offsetY = 0.0;
offsetZ = 0.0;
}

void objectManager::copyConstructor(objectManager* copiedObjectManager)
{
offsetX = copiedObjectManager->offsetX;
offsetY = copiedObjectManager->offsetY;
offsetZ = copiedObjectManager->offsetZ;
numberOfObjects = copiedObjectManager->numberOfObjects;
objects = new object[numberOfObjects+1];

for(int i=0; i<=numberOfObjects; i++)
{
objects[i].copyConstructor(&copiedObjectManager->objects[i]);
}
}

objectManager::~objectManager()
{
delete [] objects;
}

void objectManager::loadObjects(const char* theManagerName)
{
    
    FILE * readFile;
    
    std::string temporaryFileName = std::string("Objects/") + theManagerName + std::string("/meshList.txt");
    char parameterFile[temporaryFileName.length()];
    for(int x=0;x<=temporaryFileName.length();x++)
    {
    parameterFile[x] = temporaryFileName[x];
    }
    
    
    readFile = fopen(parameterFile,"r+t");
    if(readFile)
    {
    fscanf(readFile, "%d", &numberOfObjects);
    
    objects = new object[numberOfObjects+1];
    char tempObjectName[20];
    
    for(int i=0; i<=numberOfObjects; i++)
    {
    fscanf(readFile, "%s", &tempObjectName);
    objects[i].loadShapes(theManagerName, tempObjectName);
    }

    fclose(readFile);
    }

}

void objectManager::moveX(double addX)
{
//offsetX = offsetX + addX;
/*
for(int i=0; i<=numberOfObjects; i++)
{
objects[i].moveX(addX);
}
*/
}

void objectManager::moveY(double addY)
{
//offsetY = offsetY + addY;
/*
for(int i=0; i<=numberOfObjects; i++)
{
objects[i].moveY(addY);
}
*/
}

void objectManager::moveZ(double addZ)
{
//offsetZ = offsetZ + addZ;
/*
for(int i=0; i<=numberOfObjects; i++)
{
objects[i].moveZ(addZ);
}
*/
}

void objectManager::draw()
{
     //glTranslatef(offsetX, offsetY, offsetZ);
     for(int i=0;i<=numberOfObjects;i++)
     {
     objects[i].draw();
     }
     //glTranslatef((-1*offsetX),(-1*offsetY),(-1*offsetZ));
}

If I can do this in an easier fashion, that would be great...I'm already getting sick of copying and pasting header files/DLL files back and forth every time I need to make a change >.<
Thanks for the help ^_^
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
Saving the user 2MB of download when you update the program is not worth the hassle.

If you want to dynamically load stuff, as plug-ins, that's something else entirely, and an appropriate use of loadable bundles. If not, stay well away.
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #9
ok. Thanks for the advice man Smile As always, you've been more helpful than any tutorial I could find on the subject Rasp
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  orentation and interface design question paulidis 3 3,843 Jan 4, 2012 03:56 PM
Last Post: paulidis
  An interesting concept kraftwurx 3 3,874 Jan 4, 2012 02:40 PM
Last Post: olivianewton
  Interesting PDFs on Game Design Leisure Suit Lurie 11 8,615 Jan 20, 2005 07:37 AM
Last Post: ravuya