Mercurial > sumwars
changeset 19:2c21cc2d5d5c
=umstrukturierung linux
author | wuha |
---|---|
date | Fri, 03 Oct 2008 21:08:58 +0000 |
parents | 577f1d378d41 |
children | 2917d63a5f91 |
files | src/Makefile src/Makefile.objs src/core/Makefile src/core/Makefile.objs src/core/document.cpp src/core/main.cpp src/core/main_test.cpp src/core/trader.cpp src/core/trader.h src/gl_gui/config src/gui/Makefile src/gui/Makefile.objs src/gui/config src/gui/ogre.cfg src/gui/plugins.cfg src/gui/plugins_win.cfg src/gui/scene.cpp src/plugins.cfg |
diffstat | 18 files changed, 110 insertions(+), 1228 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Makefile Fri Oct 03 21:08:58 2008 +0000 @@ -0,0 +1,48 @@ +# Debug level in build time +# -1 deactivate all log messages +# 0 allow only error messages +# 1 allow also warnings +# 2 allow info messages +# 3 allow debug messages +DEBUG_LEVEL = 5 + +# executable file for project +START = sumwars +RUN = ./$(START) + + +LIBS = OGRE OIS CEGUI CEGUI-OGRE RakNet +LDFLAGS = $(shell pkg-config --libs $(LIBS)) +LOADLIBES = +LDLIBS = $(LDFLAGS) -lm -lrt +CFLAGS = -g +CXXFLAGS = $(shell pkg-config --cflags $(LIBS)) $(CFLAGS) +CXXFLAGS += -I./core -I./gui -I./tinyxml +OBJS = $(shell cat ./Makefile.objs ) +DIRS = $(shell find . -mindepth 1 -maxdepth 1 -type d -not -iname .svn ) + +CXXFLAGS += -DDEBUG_LEVEL=$(DEBUG_LEVEL) + +build: compile $(RUN) + + +compile: $(OBJS) + +link: compile + $(CXX) $(CXXFLAGS) -o $(RUN) $(OBJS) $(LDLIBS) + +$(RUN): link + + +run: $(RUN) + $(RUN) $(HOST) $(PROTOCOL) + + +%.o : %.c + $(CC) $(CFLAGS) -o $@ -c $< + +%.o : %.cpp + $(CXX) $(CXXFLAGS) -o $@ -c $< + +clean : + rm -f $(OBJS) $(RUN)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Makefile.objs Fri Oct 03 21:08:58 2008 +0000 @@ -0,0 +1,46 @@ +./core/trade.o +./core/world.o +./core/objectfactory.o +./core/objectloader.o +./core/itemlist.o +./core/gridunit.o +./core/servernetwork.o +./core/clientnetwork.o +./core/worldobject.o +./core/networkstruct.o +./core/projectile.o +./core/party.o +./core/debug.o +./core/item.o +./core/dropitem.o +./core/dmgprojectile.o +./core/creature.o +./core/pathfind.o +./core/fixedobject.o +./core/serverwobject.o +./core/player.o +./core/warrior.o +./core/monster.o +./core/mage.o +./core/archer.o +./core/priest.o +./core/itemfactory.o +./core/itemloader.o +./core/damage.o +./core/random.o +./core/region.o +./core/spawnpoint.o +./core/document.o +./core/network.o +./core/action.o +./core/command.o + +./tinyxml/tinyxml.o +./tinyxml/tinyxmlparser.o +./tinyxml/tinyxmlerror.o +./tinyxml/tinystr.o + +./gui/main_gui.o +./gui/mainwindow.o +./gui/scene.o +./gui/application.o
--- a/src/core/Makefile Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -# Debug level in build time -# -1 deactivate all log messages -# 0 allow only error messages -# 1 allow also warnings -# 2 allow info messages -# 3 allow debug messages -DEBUG_LEVEL = 5 - -# executable file for project -START = server_app -RUN = ./$(START) - - -LIBS = RakNet OIS -LDFLAGS = $(shell pkg-config --libs $(LIBS)) -LOADLIBES = -LDLIBS = $(LDFLAGS) -lm -lrt -CFLAGS = -g -CXXFLAGS = $(shell pkg-config --cflags $(LIBS)) $(CFLAGS) -OBJS = $(shell cat ./Makefile.objs ) -DIRS = $(shell find . -mindepth 1 -maxdepth 1 -type d -not -iname .svn ) - -CXXFLAGS += -DDEBUG_LEVEL=$(DEBUG_LEVEL) - -build: compile $(RUN) - - -compile: $(OBJS) - @for dir in $(DIRS) ; do \ - cd $$dir ; \ - $(MAKE) $(TARGET) ; \ - cd .. ; \ - done - -link: compile - $(CXX) $(CXXFLAGS) -o $(RUN) $(OBJS) $(LDLIBS) - -$(RUN): link - - -run: $(RUN) - $(RUN) $(HOST) $(PROTOCOL) - - -%.o : %.c - $(CC) $(CFLAGS) -o $@ -c $< - -%.o : %.cpp - $(CXX) $(CXXFLAGS) -o $@ -c $< - -clean : - rm -f $(OBJS) $(RUN)
--- a/src/core/Makefile.objs Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -../core/trade.o -../core/world.o -../core/objectfactory.o -../core/objectloader.o -../core/itemlist.o -../core/gridunit.o -../core/servernetwork.o -../core/clientnetwork.o -../core/worldobject.o -../core/networkstruct.o -../core/projectile.o -../core/party.o -../core/debug.o -../core/item.o -../core/dropitem.o -../core/dmgprojectile.o -../core/creature.o -../core/pathfind.o -../core/fixedobject.o -../core/serverwobject.o -../core/player.o -../core/warrior.o -../core/monster.o -../core/mage.o -../core/archer.o -../core/priest.o -../core/itemfactory.o -../core/itemloader.o -../core/damage.o -../core/random.o -../core/region.o -../core/spawnpoint.o -../core/document.o -../core/network.o -../core/action.o -../core/command.o - -../tinyxml/tinyxml.o -../tinyxml/tinyxmlparser.o -../tinyxml/tinyxmlerror.o -../tinyxml/tinystr.o
--- a/src/core/document.cpp Fri Oct 03 18:00:25 2008 +0000 +++ b/src/core/document.cpp Fri Oct 03 21:08:58 2008 +0000 @@ -40,8 +40,8 @@ { ERRORMSG("config nicht gefunden"); } - } - */ + } + */ strcpy(m_server_ip,"127.0.0.1"); m_world =0; @@ -220,7 +220,8 @@ } else { - ERRORMSG("konnte Savegame nicht oeffnen"); + ERRORMSG("konnte Savegame nicht oeffnen: %s",fname.c_str()); + m_state =SHUTDOWN; } DEBUG5("done"); }
--- a/src/core/main.cpp Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - Ein kleines Rollenspiel - Copyright (C) 2007 Alexander Boehm - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "server.h" - - - -int main( int argc, char** argv ) -{ - - Server * server = new Server(); - - server->init(8); - - server->run(); - - // debugging - char c; - while (true) - { - cin >> c; - if (c=='x') - { - break; - } - } - server->stop(); - return 0; - - -}
--- a/src/core/main_test.cpp Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,613 +0,0 @@ -/* - Ein kleines Rollenspiel - Copyright (C) 2007 Hans Wulf - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "world.h" -#include "serverwobject.h" -#include "creature.h" -#include "fixedobject.h" -#include "warrior.h" -#include "goblin.h" - -#include <iostream> - -#define hex(a) ((a)>=10) ? (a)-10+'a' : (a)+'0' - -using namespace std; - -const short nlayers[9] = {WorldObject::Geometry::LAYER_DEAD , - WorldObject::Geometry::LAYER_FIXED & WorldObject::Geometry::LAYER_BASE, - WorldObject::Geometry::LAYER_FIXED & WorldObject::Geometry::LAYER_BASE & WorldObject::Geometry::LAYER_AIR, - WorldObject::Geometry::LAYER_CREATURE & WorldObject::Geometry::LAYER_AIR , - WorldObject::Geometry::LAYER_CREATURE & WorldObject::Geometry::LAYER_BASE, - WorldObject::Geometry::LAYER_CREATURE & WorldObject::Geometry::LAYER_BASE & WorldObject::Geometry::LAYER_AIR, - WorldObject::Geometry::LAYER_PLAYER & WorldObject::Geometry::LAYER_BASE & WorldObject::Geometry::LAYER_AIR, - WorldObject::Geometry::LAYER_MONSTER & WorldObject::Geometry::LAYER_AIR, - WorldObject::Geometry::LAYER_MONSTER & WorldObject::Geometry::LAYER_AIR & WorldObject::Geometry::LAYER_BASE}; - -const short slayers[10] = { - WorldObject::Geometry::LAYER_DEAD, - WorldObject::Geometry::LAYER_BASE, - WorldObject::Geometry::LAYER_AIR, - WorldObject::Geometry::LAYER_AIR | WorldObject::Geometry::LAYER_BASE, - WorldObject::Geometry::LAYER_FIXED , - WorldObject::Geometry::LAYER_CREATURE, - WorldObject::Geometry::LAYER_FIXED & WorldObject::Geometry::LAYER_AIR, - WorldObject::Geometry::LAYER_MONSTER & WorldObject::Geometry::LAYER_AIR, - WorldObject::Geometry::LAYER_MONSTER & WorldObject::Geometry::LAYER_BASE, - (WorldObject::Geometry::LAYER_MONSTER | WorldObject::Geometry::LAYER_PLAYER) & (WorldObject::Geometry::LAYER_BASE | WorldObject::Geometry::LAYER_AIR) -}; - - -int main(int argc, char *argv[]) -{ - char c,c2; - - World* g_world=new World(); - float x,y, radius,x1,y1, x2, y2,x_path,y_path, pathlength; - Action::ActionType act = Action::ATTACK; - int i,j,key; - unsigned int id; - ServerWObject* wo=0,*wo2=0; - Creature* cr=0; - Player* pl =0; - CreatureBaseAttr* basm =0; - - WorldObject::Geometry* wob; - Shape sho,shs,shall; - sho.m_type = Shape::CIRCLE; - sho.m_radius =1; - shall.m_type = Shape::RECT; - shall.m_coordinate_x = 16; - shall.m_coordinate_y = 16; - shall.m_extent_x = 16; - shall.m_extent_y = 16; - - shs.m_coordinate_x = 5.5; - shs.m_coordinate_y = 5.3; - shs.m_type = Shape::RECT; - shs.m_extent_x =1.1; - shs.m_extent_y = 1.9; - - short layer = WorldObject::Geometry::LAYER_ALL; - Shape* sp; - Gridunit* gu; - - Region* reg = new Region(8,8); - short rid = g_world->insertRegion(reg); - - // Elemente die von Anfang an eingefügt werden - - //////////// - // der Spieler - - //wo2 = wo = cr= new Warrior(g_world,1); - //g_world->insertSWObject(wo, 11,5,rid); - - - wo = new FixedObject(g_world,32); - wob = wo->getGeometry(); - sp = &(wob->m_shape); - wob->m_layer = (WorldObject::Geometry::LAYER_FIXED & WorldObject::Geometry::LAYER_BASE & WorldObject::Geometry::LAYER_AIR); - sp->m_type = Shape::RECT; - sp->m_extent_x = 1.0; - sp->m_extent_y = 2; - g_world->insertSWObject(wo, 4,6,rid); - - - wo = new FixedObject(g_world,100); - wob = wo->getGeometry(); - sp = &(wob->m_shape); - wob->m_layer = (WorldObject::Geometry::LAYER_FIXED & WorldObject::Geometry::LAYER_BASE & WorldObject::Geometry::LAYER_AIR); - sp->m_type = Shape::CIRCLE; - sp->m_extent_x = 1.51; - sp->m_extent_y = 2.51; - sp->m_radius = 2.8; - g_world->insertSWObject(wo, 9,13,rid); - - wo = new Goblin(g_world,20); - g_world->insertSWObject(wo, 13,8,rid); - - wo = cr=new Goblin(g_world,21); - basm = cr->getBaseAttrMod(); - basm->m_max_health = 300; - cr->getDynAttr()->m_health = 300; - g_world->insertSWObject(wo, 14.2,8.2,rid); - - wo = cr=new Goblin(g_world,22); - basm = cr->getBaseAttrMod(); - basm->m_strength = 200; - g_world->insertSWObject(wo, 14.5,6.7,rid); - - wo = cr=new Goblin(g_world,23); - basm = cr->getBaseAttrMod(); - basm->m_dexterity = 200; - g_world->insertSWObject(wo, 14.8,5.7,rid); - - wo =cr= new Goblin(g_world,24); - basm = cr->getBaseAttrMod(); - basm->m_magic_power = 200; - g_world->insertSWObject(wo, 14,10.9,rid); - - wo = cr=new Goblin(g_world,25); - basm = cr->getBaseAttrMod(); - basm->m_willpower = 200; - g_world->insertSWObject(wo, 17,8.2,rid); - - wo = cr=new Goblin(g_world,26); - basm = cr->getBaseAttrMod(); - // blocken - //basm->m_abilities[1]=0x0100; - // Turm in der Schlacht - //basm->m_abilities[1]=0x0200; - basm->m_block = 44; - basm->m_armor = 50; - g_world->insertSWObject(wo, 7,5,rid); - - wo = cr=new Goblin(g_world,27); - basm = cr->getBaseAttrMod(); - basm->m_block = 200; - g_world->insertSWObject(wo, 18.5,7,rid); - - wo = cr=new Goblin(g_world,28); - basm = cr->getBaseAttrMod(); - basm->m_armor = 200; - g_world->insertSWObject(wo, 17.2,6.6,rid); - - wo = cr=new Goblin(g_world,29); - basm = cr->getBaseAttrMod(); - basm->m_resistances[Damage::PHYSICAL] = 50; - g_world->insertSWObject(wo, 19.9,6.9,rid); - - - wo = cr=new Goblin(g_world,30); - basm = cr->getBaseAttrMod(); - basm->m_resistances[Damage::FIRE] = 50; - g_world->insertSWObject(wo, 16.2,3,rid); - - wo = cr=new Goblin(g_world,31); - basm = cr->getBaseAttrMod(); - basm->m_resistances[Damage::AIR] = 50; - g_world->insertSWObject(wo, 19.2,3.1,rid); - - wo = cr=new Goblin(g_world,32); - basm = cr->getBaseAttrMod(); - basm->m_resistances[Damage::ICE] = 50; - g_world->insertSWObject(wo, 21,5,rid); - - - - // Zeiger auf Liste von WorldObject - Anfragen welche Objekte in einem Gebiet sind werden in dieser Form ausgegeben - list<ServerWObject*>* res= new list<ServerWObject*>; - - // Iterator zum durchmustern einer solchen Liste - list<ServerWObject*>::iterator iter; - - - bool result; - //wo =wo2; - - /* - cr = (Creature*) wo; - Command* com = cr->getCommand(); - com->m_type = Action::WALK; - com->m_goal_object_id=0; - com->m_goal_coordinate_x = 8; - com->m_goal_coordinate_y = 4; - */ - - - c='0'; - while (c !='x' ) - { - if (wo!=0) - { - wob = wo->getGeometry(); - printf("\n aktuelles WorldObject:\n"); - printf("WO: x: %f y: %f ID: %i layer: %x\n", wob->m_shape.m_coordinate_x,wob->m_shape.m_coordinate_y, wo->getId(),wob->m_layer); - - }; - printf("\n1: WorldObject einfügen \n2: Grid anzeigen \n3: update \n4: alle Elemente anzeigen \n5: Element nach key suchen \n6: ElementInShape \n7: WorldObject bewegen\n8: ObjectShape aendern \n9: SuchShape aendern\n0: aktuelles Element löschen \na: Aktion auswaehlen \nc: Kommando erteilen\ni: intersect \nl: ElementOnLine \n \nx: beenden \n"); - - cin >> c; - if (c=='1') - { - cout << "x\n"; - cin >> x; - cout << "y\n"; - cin >> y; - cout << "ID \n"; - cin >> id; - wo = new ServerWObject(g_world,id); - wob = wo->getGeometry(); - sp = &(wob->m_shape); - sp->m_type = sho.m_type; - sp->m_radius = sho.m_radius; - sp->m_extent_x = sho.m_extent_x; - sp->m_extent_y = sho.m_extent_y; - printf("0: WorldObject::Geometry::LAYER_DEAD \ - \n1: WorldObject::Geometry::LAYER_FIXED & WorldObject::Geometry::LAYER_BASE \ - \n2: WorldObject::Geometry::LAYER_FIXED & WorldObject::Geometry::LAYER_BASE & WorldObject::Geometry::LAYER_AIR \ - \n3. WorldObject::Geometry::LAYER_CREATURE & WorldObject::Geometry::LAYER_AIR \ - \n4. WorldObject::Geometry::LAYER_CREATURE & WorldObject::Geometry::LAYER_BASE \ - \n5. WorldObject::Geometry::LAYER_CREATURE & WorldObject::Geometry::LAYER_BASE & WorldObject::Geometry::LAYER_AIR\ - \n6. WorldObject::Geometry::LAYER_PLAYER & WorldObject::Geometry::LAYER_BASE & WorldObject::Geometry::LAYER_AIR \ - \n7. WorldObject::Geometry::LAYER_MONSTER & WorldObject::Geometry::LAYER_AIR \ - \n8. WorldObject::Geometry::LAYER_MONSTER &WorldObject::Geometry::LAYER_AIR & WorldObject::Geometry::LAYER_BASE\n"); - int l; - cin >> l; - wob->m_layer = nlayers[l]; - g_world->insertSWObject(wo, x,y,rid); - - - } - else if (c=='2') - { - cout << "i\n"; - cin >> i; - cout << "j\n"; - cin >> j; - - gu = reg->m_data_grid->ind(i,j); - cout << "Objekte in WorldObject::Geometry::LAYER_DEAD: \n"; - for (i=0;i<gu->getObjectNr(WorldObject::Geometry::LAYER_DEAD);i++) - { - wo = gu->getObjects(WorldObject::Geometry::LAYER_DEAD)[i]; - wob = wo->getGeometry(); - printf("WO: x: %f y: %f ID: %i layer: %x\n", wob->m_shape.m_coordinate_x,wob->m_shape.m_coordinate_y, wo->getId(),wob->m_layer); - } - printf("\n"); - cout << "Objekte in WorldObject::Geometry::LAYER_FIXED:\n"; - for (i=0;i<gu->getObjectNr(WorldObject::Geometry::LAYER_FIXED);i++) - { - wo = gu->getObjects(WorldObject::Geometry::LAYER_FIXED)[i]; - wob = wo->getGeometry(); - printf("WO: x: %f y: %f ID: %i layer: %x\n", wob->m_shape.m_coordinate_x,wob->m_shape.m_coordinate_y, wo->getId(),wob->m_layer); - } - printf("\n"); - cout << "Objekte in WorldObject::Geometry::LAYER_CREATURE:\n"; - for (i=0;i<gu->getObjectNr(WorldObject::Geometry::LAYER_CREATURE);i++) - { - wo = gu->getObjects(WorldObject::Geometry::LAYER_CREATURE)[i]; - wob = wo->getGeometry(); - printf("WO: x: %f y: %f ID: %i layer: %x\n", wob->m_shape.m_coordinate_x,wob->m_shape.m_coordinate_y, wo->getId(),wob->m_layer); - } - printf("\n"); - - - } - else if (c=='3') - { - // update aufrufen - - float time; - int i,n; - cout << "Zeitdifferenz\n"; - cin >> time; - n=1; - //cout << "Anzahl der Updates\n"; - //cin >> n; - - for(i=0;i<n;i++) - { - g_world->update(time); - } - } - else if (c=='4') - { - // Alle Objekte anzeigen - - // Suche nach allen Objecten wird einfach über Suche in einem Kreis mit riesigem Umkreis gemacht - brauchen wir so eine Funktion (ausserhalb der g_world, die ihre Objekte über den Binärbaum durchmustern kann) - - WorldObject* wo2; - // Löschen der Ergebnisliste - res->clear(); - - // Aufruf mit x=0, y=0, Radius= riesig, selector= NULL (keine Selektierung) - result= g_world->getSWObjectsInShape(&shall,WorldObject::Geometry::LAYER_ALL,rid,res); - - if (result== false) - { - cout << "\n Es ist ein Fehler aufgetreten"; - } - else - { - // Durchmustern der STL Liste - for (iter =res->begin(); iter!=res->end(); iter ++) - { - // WorldObjectpointer aus dem Iterator holen - // die leicht sonderbare Schreibweise entsteht durch den überladenen * Operator für den Iterator - wo2 = *iter; - wob = wo2->getGeometry(); - - printf("Objekt: %f %f ID: %i layer: %x\n",wob->m_shape.m_coordinate_x,wob->m_shape.m_coordinate_y,wo2->getId() - , wob->m_layer); - - if (wo2->getTypeInfo()->m_type!=WorldObject::TypeInfo::TYPE_FIXED_OBJECT) - { - Creature* cr2 = (Creature*) wo2; - CreatureBaseAttr* cba = cr2->getBaseAttrMod(); - CreatureDynAttr* cda = cr2->getDynAttr(); - /*printf(" HP: %i / %i\n", pl2->getHealth(), pl2->getMaxHealth()); - printf(" LVL: %i\n", pl2->getLevel()); - printf(" EXP: %i / %i\n", pl2->getExperience(), pl2->getMaxExperience()); - printf(" ATT: %i DEF: %i ARMOR %i \n",pl2->getAttack(),pl2->getDefense(), pl2->getArmor()); - */ - } - - } - } - - } - else if (c=='5') - { - // Suchen eines WorldObjects anhand seines Keys - cout << "id: "; - cin >> key; - wo=g_world->getSWObject(key) ; - - // nach solchen Abfragen immer auf NULL prüfen - if (wo == 0) - cout << "\nObjekt nicht gefunden\n"; - } - else if (c=='6') - { - // Element in Shape - ServerWObject* wo2; - // Löschen der Ergebnisliste - res->clear(); - - printf(" \ - \n0: WorldObject::Geometry::LAYER_DEAD, \ - \n1: WorldObject::Geometry::LAYER_BASE, \ - \n2: WorldObject::Geometry::LAYER_AIR, \ - \n3:WorldObject::Geometry::LAYER_AIR | WorldObject::Geometry::LAYER_BASE, \ - \n4: WorldObject::Geometry::LAYER_FIXED , \ - \n5: WorldObject::Geometry::LAYER_CREATURE, \ - \n6: WorldObject::Geometry::LAYER_FIXED & WorldObject::Geometry::LAYER_AIR, \ - \n7: WorldObject::Geometry::LAYER_MONSTER & WorldObject::Geometry::LAYER_AIR, \ - \n8: WorldObject::Geometry::LAYER_MONSTER & WorldObject::Geometry::LAYER_BASE \ - \n9: (WorldObject::Geometry::LAYER_MONSTER | WorldObject::Geometry::LAYER_PLAYER) & (WorldObject::Geometry::LAYER_BASE | WorldObject::Geometry::LAYER_AIR) \n"); - - int l; - cin >> l; - - // Aufruf mit x=0, y=0, Radius= riesig, selector= NULL (keine Selektierung) - result= g_world->getSWObjectsInShape(&shs,slayers[l],rid,res); - - if (result== false) - { - cout << "\n Es ist ein Fehler aufgetreten"; - } - else - { - // Durchmustern der STL Liste - for (iter =res->begin(); iter!=res->end(); iter ++) - { - // WorldObjectpointer aus dem Iterator holen - // die leicht sonderbare Schreibweise entsteht durch den überladenen * Operator für den Iterator - wo2 = *iter; - wob = wo2->getGeometry(); - - printf("Objekt: %f %f key: %i layer: %x\n",wob->m_shape.m_coordinate_x,wob->m_shape.m_coordinate_y,wo->getId(),wob->m_layer); - /* - if (wo2->getObjectType().getObjectType()!=OBJECTTYPE_FIXED_OBJECT) - { - Player* pl2 = (Player*) wo2; - printf(" HP: %i / %i\n", pl2->getHealth(), pl2->getMaxHealth()); - printf(" LVL: %i\n", pl2->getLevel()); - printf(" EXP: %i / %i\n", pl2->getExperience(), pl2->getMaxExperience()); - printf(" ATT: %i DEF: %i ARMOR %i \n",pl2->getAttack(),pl2->getDefense(), pl2->getArmor()); - } - */ - } - } - } - else if (c=='7') - { - // WorldObject modifizieren - if (wo !=0) - { - - // Koordinaten neu setzen, die alten vorher sichern - x1=wob->m_shape.m_coordinate_x; - y1=wob->m_shape.m_coordinate_y; - printf("\nx (aktuell %f): ", wob->m_shape.m_coordinate_x); - cin >> x; - printf("y (aktuell %f): ",wob->m_shape.m_coordinate_y) ; - cin >> y; - - wo->moveTo(x,y); - - } - else - { - cout << "\n kein WorldObject ausgewählt \n"; - } - } - else if (c=='8') - { - printf("1: Kreis 2: Rechteck\n"); - cin >> c2; - if (c2=='1') - { - sho.m_type = Shape::CIRCLE; - printf("radius:\n"); - cin >> sho.m_radius; - } - else - { - sho.m_type = Shape::RECT; - printf("Ausdehnung x:\n"); - cin >> sho.m_extent_x; - printf("Ausdehnung y:\n"); - cin >> sho.m_extent_y; - - } - - - - - } - else if (c=='9') - { - printf("\nx: "); - cin >> x; - printf("y: ") ; - cin >> y; - shs.m_coordinate_x =x; - shs.m_coordinate_y =y; - printf("1: Kreis 2: Rechteck\n"); - cin >> c2; - if (c2=='1') - { - shs.m_type = Shape::CIRCLE; - printf("radius:\n"); - cin >> shs.m_radius; - } - else - { - shs.m_type = Shape::RECT; - printf("Ausdehnung x:\n"); - cin >> shs.m_extent_x; - printf("Ausdehnung y:\n"); - cin >> shs.m_extent_y; - - } - - } - else if (c=='0') - { - - // Testen der Element Löschen Funktion - - result= g_world->deleteSWObject(wo); - - // Testen des Resultats noch weniger vergessen als bei den obigen Fällen ;) - if (result==true) - { - cout << "\n Löschen erfolgreich\n"; - wo=0; - } - else - { - cout << "\nLöschen nicht erfolgreich\n"; - } - - } - - else if (c=='c') - { - if (wo!=0 & wo->getTypeInfo()->m_type == WorldObject::TypeInfo::TYPE_PLAYER) - { - pl = (Player*) wo; - cout << "x\n"; - cin >> x; - cout << "y\n"; - cin >> y; - wo2 = g_world->getSWObjectAt(x, y, WorldObject::Geometry::LAYER_ALL, rid); - ClientCommand com; - com.m_coordinate_x = x; - com.m_coordinate_y = y; - com.m_action = act; - com.m_button = LEFT_MOUSE_BUTTON; - if (wo2!=0) - { - com.m_id = wo2->getId(); - com.m_action = act; - } - else - { - com.m_id = 0; - com.m_action = Action::WALK; - } - - pl->onClientCommand(&com); - - /* - Command* com = cr->getCommand(); - - if (wo2!=0) - { - com->m_type = Action::ATTACK; - com->m_goal_object_id = wo2->getId(); - cout << "Zielobject "<<wo2->getId() << "\n"; - } - else - { - com->m_type = Action::WALK; - //DEBUG("goal : %f %f",x,y); - com->m_goal_coordinate_x = x; - com->m_goal_coordinate_y = y; - } - */ - - } - } - else if (c=='i') - { - if (g_world->intersect(&(wo->getGeometry()->m_shape), &shs)) - printf("ueberschneiden sich\n"); - } - else if (c=='a') - { - cout << "Aktionsnummer angeben\n"; - int a; - cin >> a; - act = (Action::ActionType) a; - } - else if (c=='l') - { - float xs,xe,ys,ye; - res->clear(); - cout << "x start\n"; - cin>> xs; - cout << "y start\n"; - cin>> ys; - cout << "x end\n"; - cin>> xe; - cout << "y end\n"; - cin>> ye; - - g_world->getSWObjectsOnLine(xs,ys,xe,ye,WorldObject::Geometry::LAYER_AIR,rid,res); - - for (iter =res->begin(); iter!=res->end(); iter ++) - { - wo2 = *iter; - wob = wo2->getGeometry(); - - printf("Objekt: %f %f key: %i layer: %x\n",wob->m_shape.m_coordinate_x,wob->m_shape.m_coordinate_y,wo2->getId(),wob->m_layer); - } - - } - else if (c=='x') - { - //Beenden - } - else - { - //Typo - printf("Sie haben sich vertippt! x eingeben zum Beenden, andere Eingabe zum Fortfahren!\n"); - cin >> c; - } - } - - return 1; -} - -
--- a/src/core/trader.cpp Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,273 +0,0 @@ -/* - Ein kleines Rollenspiel - Copyright (C) 2007 Hans Wulf - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "trader.h" - -//Constructors -Trader::Trader(World* world, unsigned int id) : Player( world,id) -{ - bool tmp=Trader::init(); - if (!tmp) - { - DEBUG("Initialisierung des Händlers fehlgeschlagen!"); - } -} - -Trader::Trader(World* world, float coordinate_x, float coordinate_y, unsigned int id) : Player(world, coordinate_x, coordinate_y, id) -{ - getObjectType().setObjectSubtype(SUBTYPE_UNIVERSAL_TRADER); - bool tmp=Trader::init(); - if (!tmp) - { - DEBUG("Initialisierung des Händlers fehlgeschlagen!"); - } -} - -Trader::Trader(World* world, float coordinate_x, float coordinate_y, unsigned int id, int object_subtype) : Player(world, coordinate_x, coordinate_y, id) -{ - getObjectType().setObjectSubtype(object_subtype); - bool tmp=Trader::init(); - if (!tmp) - { - DEBUG("Initialisierung des Händlers fehlgeschlagen!"); - } -} - -Trader::~Trader() -{ - // allokierten Speicher freigeben -} -//Methods -bool Trader::init() -{ - //eigene Initialisierung - getObjectType().setObjectType(OBJECTTYPE_TRADER); - - setHealth(10); - setMaxHealth(10); - - Item * item = new Item(ITEM_GOLD,1); - setMaxBaggage(10000000); - int typ = getObjectType().getObjectSubtype(); - - if (typ == SUBTYPE_UNIVERSAL_TRADER || typ ==SUBTYPE_WEAPON_TRADER) - { - item->init(ITEM_BROADSWORD,10); - getItems()->addItem(item); - - item->init(ITEM_LONGSWORD,10); - getItems()->addItem(item); - - item->init(ITEM_GREATSWORD,10); - getItems()->addItem(item); - - item->init(ITEM_GIANTSWORD,10); - getItems()->addItem(item); - } - - if (typ == SUBTYPE_UNIVERSAL_TRADER || typ ==SUBTYPE_ARMOR_TRADER) - { - item->init(ITEM_RINGMAIL,10); - getItems()->addItem(item); - item->init(ITEM_PLATEARMOR,10); - getItems()->addItem(item); - item->init(ITEM_ELVENMAIL,10); - getItems()->addItem(item); - item->init(ITEM_MITHRILMAIL,10); - getItems()->addItem(item); - - item->init(ITEM_IRONSHIELD,10); - getItems()->addItem(item); - item->init(ITEM_STEELSHIELD,10); - getItems()->addItem(item); - item->init(ITEM_ELVENSHIELD,10); - getItems()->addItem(item); - item->init(ITEM_MITHRILSHIELD,10); - getItems()->addItem(item); - - } - - if (typ == SUBTYPE_UNIVERSAL_TRADER || typ == SUBTYPE_POTION_TRADER) - { - item->init(ITEM_HEALINGPOTION,100); - getItems()->addItem(item); - item->init(ITEM_BIGHEALINGPOTION,100); - getItems()->addItem(item); - item->init(ITEM_FULLHEALINGPOTION,100); - getItems()->addItem(item); - - } - delete item; - strcpy(getName(),"Haendler"); - - return true; -} - -bool Trader::update(float time) -{ - // Trade spezifisches Update - DEBUG5("Update des Händlerobjekts [%i] wird gestartet", getId()); - // Wenn ein Handel existiert - if (getTradeId() !=0) - { - DEBUG5("Suche Handelsobjekt des Händlers"); - Trade* trade = getWorld()->getTrade(getTradeId()); - DEBUG5("Ergebnis: %p",trade); - - // Wenn der Handel nicht existiert Fehler ausgeben - if (trade == 0) - { - setTradeId(0); - return false; - - } - else - { - // eigene Position bei dem Handel bestimmen - int idx = trade->getPlayerIndex(getId()); - - DEBUG5("Händlerobjekt [%i] hat Handelsobjekt [%i] als seinen Handel erkannt", getId(), getTradeId()); - // Abfragen ob der Handel bereits abgeschlossen ist. - if (idx == -1) - { - setTradeId(0); - } - else if (trade->getFinished()==true) - { - // Abfragen ob der Handel erfolgreich war - if (trade->getSuccessful()==true) - { - - // Items auf erhalten setzen, aber NICHT austauschen - trade->setGotItems(true, idx); - } - - // Handel ist erledigt, id auf 0 setzen - setTradeId(0); - } - else - { - // Handel ist noch nicht abgeschlossen - - // Testen Handel aktuell akzeptiert wird - if (trade->getAccept(idx)==false) - { - // Handel steht aktuell auf nicht akzeptierend - // Prüfen ob Handel akzeptiert werden könnte - - int value_own=0, value_pl=0; - - map< int, Item >::iterator iter; - map< int, Item >* itemmap = trade->getOffer(idx)->getItems(); - Item* item; - - // Wert des eigenen Angebots aufsummieren - for (iter = itemmap->begin(); iter != itemmap->end(); iter++) - { - item = &(iter->second); - value_own += item->getNumber()* item-> getPrice(); - } - DEBUG5("Haendlerangebot ist Wert: %i", value_own); - // Wert des fremden Angebots aufsummieren - itemmap = trade->getOffer(1-idx)->getItems(); - - for (iter = itemmap->begin(); iter != itemmap->end(); iter++) - { - item = &(iter->second); - value_pl += item->getNumber()* item-> getPrice(); - } - DEBUG5("Spielerangebot ist Wert: %i", value_pl); - if (value_own == value_pl) - { - // Handel geht genau auf, akzeptieren - DEBUG5("Haendler ist einverstanden so wie es ist."); - trade->setAccept(true,idx); - } - - if (value_own < value_pl) - { - // Haendler bietet weniger als der Spieler, mit Gold auffüllen - - item = new Item(ITEM_GOLD,value_pl-value_own); - trade->getOffer(idx)->addItem(item); - - // Handel akzeptieren - DEBUG5("Haendler ist einverstanden, gibt %i Gold mehr an Wechselgeld", value_pl-value_own); - trade->setAccept(true,idx); - // Item Objekt löschen - delete item; - - } - - if (value_own > value_pl) - { - // Haendler bietet mehr als der Spieler - - // testen ob der Haendler Gold im Angebot hat - item = trade->getOffer(idx)->getItem(ITEM_GOLD); - - // Wenn ja - if (item !=0) - { - // Wenn mehr Gold im Angebot ist als zum Ausgleichen nötig - if (item->getNumber() >= value_own- value_pl) - { - // Gold aus dem Angebot entfernen - item->setNumber(value_own- value_pl); - trade->getOffer(idx)->removeItem(item); - - // Handel akzeptieren - DEBUG5("Haendler gibt %i Gold weniger an Wechselgeld ist aber einverstanden\n", value_own-value_pl); - trade->setAccept(true,idx); - - } - else - { - // alles Gold aus dem Angebot entfernen - DEBUG5("Haendler entfernt das gesamte Wechselgeld"); - trade->getOffer(idx)->removeItem(item); - } - - } - if (item!=0) - delete item; - } - } - else - { - //Haendler akzeptierte bereits vorher, lag wohl am Spieler... - //printf("Haendler akzeptierte bereits vor diesem Update\n"); - //trade->acceptTrade(); - } - } - } - - if (getCommand()->getType() == COMMAND_TRADE && getTradeId()==0) - { - getCommand()->setType(COMMAND_NONE); - getObjectType().setActionType(ACTION_NONE); - getAction()->setType(ACTION_NONE); - - } - - } - - // Update von Player aufrufen - Player::update(time); -}
--- a/src/core/trader.h Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* - Ein kleines Rollenspiel - Copyright (C) 2007 Hans Wulf - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -/** - * \file trader.h - * \defgroup Trader \ Händler - * \ingroup Player - * \brief Steuerung des Händlerverhalten - * \author Hans Wulf - * \version 1.0 - * \date 2007/05/28 - * \note Beinhaltet die Klasse Trader - */ -#ifndef TRADER_H -#define TRADER_H -#include <string> -#include "player.h" -#include "world.h" - -/** - * \class Trader - * \brief Dieses Objekt stellt einen Händler dar. Der Händler wird unter andrem durch NichtAngreifbarkeit charakterisiert. - */ -class Trader : public Player { -//Public stuff -public: - //Fields - //Constructors - /** - * \fn Trader(World* world, unsigned int id) - * \brief Konstruktor - * \param world - * \param id - * - * Legt ein neues Trader Objekt an. - */ - Trader(World* world, unsigned int id); - /** - * \fn Trader(World* world, float coordinate_x, float coordinate_y, unsigned int id) - * \brief Konstruktor - * \param world - * \param coordinate_x - * \param coordinate_y - * \param id - * - * Legt ein neues User Objekt an und initialisiert es mit den eingegebenen Werte. - */ - Trader(World* world, float coordinate_x, float coordinate_y, unsigned int id); - /** - * \fn Trader(World* world, float coordinate_x, float coordinate_y, unsigned int id, int object_subtype) - * \brief Konstruktor - * \param world Zeiger auf die Welt - * \param coordinate_x x-Koordinate des Objekts - * \param coordinate_y y-Koordinate des Objekts - * \param id ID des Objekts - * \param object_subtype Gibt Subtyp des Haendlers an - * - * Legt ein neues User Objekt an und initialisiert es mit den eingegebenen Werte. - */ - Trader(World* world, float coordinate_x, float coordinate_y, unsigned int id, int object_subtype); - /** - * \fn ~Trader() - * \brief Destruktor - * - * Gibt den Allokierten Speicher wieder frei - */ - ~Trader(); - - //Operations - /** - * \fn virtual bool init() - * \brief Initialisierung des Händlers - * \return bool Gibt an ob die Initialisierung erfolgreich war - */ - virtual bool init(); - /** - * \fn virtual bool update (float time) - * \brief Updatefunktion des Händlers - * \param time Verstrichene Zeit - * \return bool, Erfolgreiches Update? - * - * Die Updatefunktion des Händlers wird in regelmässigen Abständen von der World aufgerufen und benötigt die Angabe, wie viel Zeit für das Update zur Verfügung gestellt wird. Der Rückgabewert gibt an ob die Funktion erfolgreich ausgeführt wurde. Da die Funktion hier virtuell definiert wird, wird sie erst in den abgeleiteten Klassen implementiert. - */ - virtual bool update(float time); -}; -#endif //TRADER_H
--- a/src/gl_gui/config Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -127.0.0.1 -134.109.114.56 \ No newline at end of file
--- a/src/gui/Makefile Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -# Debug level in build time -# -1 deactivate all log messages -# 0 allow only error messages -# 1 allow also warnings -# 2 allow info messages -# 3 allow debug messages -DEBUG_LEVEL = 5 - -# executable file for project -RUN = client_app - -LDFLAGS = -LOADLIBES = -LIBS = OGRE OIS CEGUI CEGUI-OGRE RakNet -LDLIBS = `pkg-config $(LIBS) --libs` -LDLIBS += -lm -lrt -lGL -lglut -#LDLIBS += -L../../server/trunk - -CFLAGS = -m32 -g -CXXFLAGS = $(CFLAGS) -CXXFLAGS += `pkg-config $(LIBS) --cflags` -CXXFLAGS += -I../core -CXXFLAGS += -DDEBUG_LEVEL=$(DEBUG_LEVEL) - - -OBJS = $(shell cat ./Makefile.objs ) $(shell cat ../core/Makefile.objs ) -DIRS = $(shell find . -mindepth 1 -maxdepth 1 -type d -not -iname .svn ) - -build: compile $(RUN) - -compile: $(OBJS) -# @for dir in $(DIRS) ; do \ -# cd $$dir ; \ -# $(MAKE) $(TARGET) ; \ -# cd .. ; \ -# done - -link: compile - $(CXX) $(CXXFLAGS) -o $(RUN) $(OBJS) $(LDLIBS) - - -$(RUN): link - - -run: $(RUN) - ./$(RUN) - -%.o : %.c - $(CC) $(CFLAGS) -o $@ -c $< - -%.o : %.cpp - $(CXX) $(CXXFLAGS) -o $@ -c $< - -clean: - rm -f $(OBJS) $(RUN) -
--- a/src/gui/Makefile.objs Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -main_gui.o -mainwindow.o -scene.o -application.o
--- a/src/gui/config Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -127.0.0.1 -134.109.114.56 \ No newline at end of file
--- a/src/gui/ogre.cfg Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -Render System=OpenGL Rendering Subsystem - -[OpenGL Rendering Subsystem] -FSAA=0 -Full Screen=No -RTT Preferred Mode=PBuffer -Video Mode=940 x 705
--- a/src/gui/plugins.cfg Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -# Defines plugins to load - -# Define plugin folder -PluginFolder=/usr/lib/OGRE - -# Define D3D rendering implementation plugin -Plugin=RenderSystem_GL.so -Plugin=Plugin_ParticleFX.so -Plugin=Plugin_BSPSceneManager.so -Plugin=Plugin_OctreeSceneManager.so -
--- a/src/gui/plugins_win.cfg Fri Oct 03 18:00:25 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -# Defines plugins to load - -# Define plugin folder -PluginFolder=.\obj\Debug - -# Define plugins -Plugin=RenderSystem_Direct3D9_d -Plugin=RenderSystem_GL_d -Plugin=Plugin_ParticleFX_d -Plugin=Plugin_BSPSceneManager_d -Plugin=Plugin_OctreeSceneManager_d -Plugin=Plugin_CgProgramManager_d - -
--- a/src/gui/scene.cpp Fri Oct 03 18:00:25 2008 +0000 +++ b/src/gui/scene.cpp Fri Oct 03 21:08:58 2008 +0000 @@ -62,7 +62,7 @@ objectloader = new ObjectLoader; list<MonsterMeshData*>* monster_mesh_list; - monster_mesh_list = objectloader->loadMonsterMeshData("../../data/monsters.xml"); + monster_mesh_list = objectloader->loadMonsterMeshData("../data/monsters.xml"); if (monster_mesh_list != 0) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/plugins.cfg Fri Oct 03 21:08:58 2008 +0000 @@ -0,0 +1,11 @@ +# Defines plugins to load + +# Define plugin folder +PluginFolder=/usr/lib/OGRE + +# Define D3D rendering implementation plugin +Plugin=RenderSystem_GL.so +Plugin=Plugin_ParticleFX.so +Plugin=Plugin_BSPSceneManager.so +Plugin=Plugin_OctreeSceneManager.so +