download uop.cc
Language: C++
LOC: 131
Project Info
Ultima Online Project(uop)
Server: SourceForge
Type: cvs
SourceForge\u\uop\uop\uop\
   acinclude.m4
   aclocal.m4
   action.cc
   action.h
   animation.cc
   animation.h
   artexport.cc
   artfactory.cc
   artfactory.h
   audio.cc
   audio.h
   btree.cc
   btree.h
   cache.h
   cliloc.cc
   cliloc.h
   config.h.in
   configure.in
   cvs2cl.pl
   entity.cc
   entity.h
   gumps.cc
   gumps.h
   interface.cc
   interface.h
   interfacegumps.cc
   interfacegumps.h
   interfacehandler.cc
   interfacehandler.h
   intrface.def
   Makefile.am
   Makefile.in
   message.cc
   message.h
   musicmap.def
   network.cc
   network.h
   patchhandler.cc
   patchhandler.h
   readable.pl
   serverhandler.cc
   serverhandler.h
   sprite.cc
   sprite.h
   stamp-h.in
   texthandler.cc
   texthandler.h
   tiledata.cc
   tiledata.h
   unreadable.pl
   uop.cc
   uop.cfg
   uop.dox
   uop.h
   uopconfig.cc
   uopconfig.h
   uosprite.h
   uostub.pl
   world.cc
   world.h

// vim:ts=2 sw=2
#include "uop.h"
#include <SDL/SDL.h>
#include <sstream>
#include <string>
#include <fstream>
#include <iostream>
#include "audio.h"
#include "gumps.h"
#include "interface.h"
#include "cliloc.h"
#include "texthandler.h"
#include "tiledata.h"
#include "uopconfig.h"
#include "network.h"
#include "action.h"
#include "animation.h"
#include "serverhandler.h"
#include "interfacehandler.h"
#include "patchhandler.h"
#include "message.h"
#include "world.h"

SDL_Surface *screen;

Audio *audio;
Gumps *gumps;
Interface *intrface;
vector<Cliloc *>intlocs;
vector<Cliloc *>clilocs;
Cliloc *profession;
TextHandler *textHandler;
TileData *tileData;
UOPConfig *config;
Network *network;
Action *action;
ServerHandler *serverHandler;
InterfaceHandler *interfaceHandler;
PatchHandler *patchHandler;
World *world;
Animations *anims;

void onExit();

int main(int argc,char **argv)
{
	ifstream f;
	//Uint32 offset,object;
	//SDL_Event event;
	Uint32 ticks,lastUpdate=0;
	Uint8 act[1];
	bool updateAction;

	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER))
	  {
	    cerr << "Unable to initialize SDL: " << SDL_GetError() << endl;
	    exit(1);
	  }

	atexit(&onExit);

	screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE);
	if (screen == NULL)
	  {
	    cerr << "Unable to set video mode: " << SDL_GetError() << endl;
	    exit(2);
	  }

	SDL_WM_SetCaption("Ultima Online Project", NULL);

#ifdef WIN32
	config = new WindowsConfig;
#else
	config = new TextConfig;
#endif
	config->loadKeys();

	network=new Network();
	serverHandler=new ServerHandler();
	action=new Action();
	tileData=new TileData();
	audio=new Audio();
	gumps=new Gumps();
	anims=new Animations();

	int i;
	for (i=0;i<=10;i++)
	{
		string name="intloc";
		if (i<10) name+='0'; else name+=('0'+(i/10));
		name+=('0'+(i%10));
		intlocs.push_back(new Cliloc(name));
	}
	for (i=0;i<=52;i++)
	{
		string name="cliloc";
		if (i<10) name+='0'; else name+=('0'+(i/10));
		name+=('0'+(i%10));
		clilocs.push_back(new Cliloc(name));
	}
	profession=new Cliloc("professn");

	textHandler=new TextHandler();
	intrface=new Interface();
	interfaceHandler=new InterfaceHandler();
	patchHandler=new PatchHandler();
	world=new World();

	patchHandler->load();

	intrface->loadDef();
	audio->start();

	interfaceHandler->addGump("accountlogin");
	updateAction=true;

	try{	
		while (true)
		{
			updateAction=interfaceHandler->handleEvents();
			ticks=SDL_GetTicks();
			if (ticks-lastUpdate>50 || updateAction)
			{
				updateAction=false;
				lastUpdate=ticks;
				SDL_LockSurface(screen);
				interfaceHandler->draw();
				Message::drawMessageStack();
				SDL_UnlockSurface(screen);
				SDL_UpdateRect(screen,0,0,640,480);
			}
			SDL_Delay(10);
			if (network->ready())
			{
				if (network->read(act,1)!=-1)
					serverHandler->handlePacket(act[0]);
			}
		}
	}catch (string s){
		cerr << "Unexpected exception:" << endl;
		cerr << s << endl;
		throw;
		//exit(1);
	}
}

void onExit()
{
	if (config)
		config->saveKeys();
	SDL_Quit();
}

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us