From 61f01493374891083da5c412ef4e988bda9ffa97 Mon Sep 17 00:00:00 2001 From: rustushki Date: Fri, 7 Sep 2007 00:11:17 +0000 Subject: [PATCH] Lots of changes; notes coming soon. --- CircHardpoint.cpp | 2 +- Container.h | 1 + Database.cpp | 61 ++++++++++++++++++++++++++++++++++++- Database.h | 8 +++-- DatabaseColumnMap.h | 19 ++++++------ GameEngine.cpp | 3 +- GameEngine.h | 1 - MapObject.h | 1 + MapObjectFactory.cpp | 33 ++++++++++++++++++-- MapObjectFactory.h | 3 +- QueryGenerator.cpp | 2 +- QueryGenerator.h | 3 +- packages/gnu/Makefile | 5 +++ packages/gnu/README | 30 ++++++++++++++++++ packages/gnu/asgard/AUTHORS | 0 packages/gnu/asgard/Makefile.am | 1 + packages/gnu/asgard/NEWS | 0 packages/gnu/asgard/README | 0 packages/gnu/asgard/configure.ac | 31 +++++++++++++++++++ packages/gnu/asgard/src/Makefile.am | 40 ++++++++++++++++++++++++ 20 files changed, 222 insertions(+), 22 deletions(-) create mode 100644 packages/gnu/Makefile create mode 100644 packages/gnu/README create mode 100644 packages/gnu/asgard/AUTHORS create mode 100644 packages/gnu/asgard/Makefile.am create mode 100644 packages/gnu/asgard/NEWS create mode 100644 packages/gnu/asgard/README create mode 100644 packages/gnu/asgard/configure.ac create mode 100644 packages/gnu/asgard/src/Makefile.am diff --git a/CircHardpoint.cpp b/CircHardpoint.cpp index e597629..eb39204 100644 --- a/CircHardpoint.cpp +++ b/CircHardpoint.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2006 Russ Adams, Sean Eubanks, Asgard Contributors + * Copyright (c) 2007 Russ Adams, Sean Eubanks, Asgard Contributors * This file is part of Asgard. * * Asgard is free software; you can redistribute it and/or modify diff --git a/Container.h b/Container.h index 95ce99b..32105c5 100644 --- a/Container.h +++ b/Container.h @@ -21,6 +21,7 @@ #define CONTAINER_H #include +#include #include "StaticMapObject.h" #include "Item.h" diff --git a/Database.cpp b/Database.cpp index 759ea80..fc80194 100644 --- a/Database.cpp +++ b/Database.cpp @@ -1,7 +1,31 @@ +/***************************************************************************** + * Copyright (c) 2007 Russ Adams, Sean Eubanks, Asgard Contributors + * This file is part of Asgard. + * + * Asgard 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. + * + * Asgard 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 Asgard; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + ****************************************************************************/ + +#include #include "Database.h" #include "MapObjectFactory.h" #include "MapObjectType.h" #include "QueryGenerator.h" +#include "DatabaseColumnMap.h" +#include "GameEngine.h" + +Database* Database::instance = NULL; Database::Database() { @@ -20,8 +44,15 @@ Database::~Database() sqlite3_close(this->asgardDb); } +Database* Database::getInstance() +{ + if(instance == NULL) instance = new Database(); + return instance; +} + void Database::determineVisibleBoxes(Coordinate currentPosition, int *visibleBoxes, int numVisibleBoxes) { + } bool Database::loadBoundingBox(int boxId) @@ -34,4 +65,32 @@ bool Database::loadBoundingBox(int boxId) sqlite3_exec(this->asgardDb, QueryGenerator::tile(boxId), MapObjectFactory::processRow, (void*)MAP_OBJECT_TYPE_TILE, sqliteErrorCode); return true; -} \ No newline at end of file +} + +char*** Database::loadHardpoints(int smoId) +{ + char*** table = NULL; + int* numRows; + int* numColumns; + char** sqliteErrorCode; + + sqlite3_get_table(this->asgardDb, QueryGenerator::hardpoint(smoId), table, numRows, numColumns, sqliteErrorCode); + + assert(*numColumns == CONTAINER_COLUMN_COUNT); + + return table; +} + +char*** Database::loadNonPlayerCharacterPath(int npcId) +{ + char*** table = NULL; + int* numRows; + int* numColumns; + char** sqliteErrorCode; + + sqlite3_get_table(this->asgardDb, QueryGenerator::nonPlayerCharacterPath(npcId), table, numRows, numColumns, sqliteErrorCode); + + assert(*numColumns == HARDPOINT_COLUMN_COUNT); + + return table; +} diff --git a/Database.h b/Database.h index 3ba1669..2039beb 100644 --- a/Database.h +++ b/Database.h @@ -28,13 +28,17 @@ class Database { private: + Database(); + ~Database(); sqlite3 *asgardDb; + static Database* instance; public: - Database(); - ~Database(); + static Database* getInstance(); void determineVisibleBoxes(Coordinate currentPosition, int *visibleBoxes, int numVisibleBoxes); bool loadBoundingBox(int boxId); + char*** loadHardpoints(int smoId); + char*** loadNonPlayerCharacterPath(int npcId); }; diff --git a/DatabaseColumnMap.h b/DatabaseColumnMap.h index 4ec19ed..918dcdd 100644 --- a/DatabaseColumnMap.h +++ b/DatabaseColumnMap.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2006 Russ Adams, Sean Eubanks, Asgard Contributors + * Copyright (c) 2007 Russ Adams, Sean Eubanks, Asgard Contributors * This file is part of Asgard. * * Asgard is free software; you can redistribute it and/or modify @@ -100,14 +100,13 @@ enum TileColumn enum HardpointColumn { - HARDPOUNT_COLUMN_MAP_OBJECT_ID, - HARDPOUNT_COLUMN_RELATIVE_X, - HARDPOUNT_COLUMN_RELATIVE_Y, - HARDPOUNT_COLUMN_HARDPOINT_TYPE, - HARDPOUNT_COLUMN_WIDTH, - HARDPOUNT_COLUMN_HEIGHT, - HARDPOUNT_COLUMN_RADIUS, - HARDPOUNT_COLUMN_COUNT + HARDPOINT_COLUMN_MAP_OBJECT_ID, + HARDPOINT_COLUMN_RELATIVE_X, + HARDPOINT_COLUMN_RELATIVE_Y, + HARDPOINT_COLUMN_HARDPOINT_TYPE, + HARDPOINT_COLUMN_WIDTH, + HARDPOINT_COLUMN_HEIGHT, + HARDPOINT_COLUMN_RADIUS, + HARDPOINT_COLUMN_COUNT }; - diff --git a/GameEngine.cpp b/GameEngine.cpp index 628a967..45a9cae 100644 --- a/GameEngine.cpp +++ b/GameEngine.cpp @@ -18,7 +18,8 @@ void GameEngine::loadGame() void GameEngine::loadVisibleBoxes() { - this->database.determineVisibleBoxes(this->currentPosition,this->visibleBoxes,VISIBLE_BOUNDING_BOXES); + Database* db = Database::getInstance(); + db->determineVisibleBoxes(this->currentPosition,this->visibleBoxes,VISIBLE_BOUNDING_BOXES); } void GameEngine::addMapObject(MapObject* object) diff --git a/GameEngine.h b/GameEngine.h index 0b4daf2..fcee323 100644 --- a/GameEngine.h +++ b/GameEngine.h @@ -42,7 +42,6 @@ class GameEngine std::vector objects; int visibleBoxes[VISIBLE_BOUNDING_BOXES]; Coordinate currentPosition; - Database database; }; #endif //GAME_ENGINE_H diff --git a/MapObject.h b/MapObject.h index 48193af..9e8c4df 100644 --- a/MapObject.h +++ b/MapObject.h @@ -21,6 +21,7 @@ #define MAP_OBJECT_H #include +#include #include "Coordinate.h" #define MAP_OBJECT_HEIGHT_DEFAULT 10 diff --git a/MapObjectFactory.cpp b/MapObjectFactory.cpp index a6d335a..f60ac56 100644 --- a/MapObjectFactory.cpp +++ b/MapObjectFactory.cpp @@ -1,3 +1,22 @@ +/***************************************************************************** + * Copyright (c) 2007 Russ Adams, Sean Eubanks, Asgard Contributors + * This file is part of Asgard. + * + * Asgard 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. + * + * Asgard 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 Asgard; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + ****************************************************************************/ + #include "MapObjectFactory.h" #include "GameEngine.h" #include "Tile.h" @@ -9,6 +28,7 @@ #include "NonPlayerCharacter.h" #include "MapObjectType.h" #include "DatabaseColumnMap.h" +#include "Database.h" int MapObjectFactory::processRow(void *mapObjectType, int columnCount, char **columnValue, char **columnName) { @@ -58,9 +78,16 @@ void MapObjectFactory::createTile(char **columnValue) void MapObjectFactory::createContainer(char **columnValue) { - Container *container = new Container(); - - // TODO: Add all columnValue data to Container object + Database* db = Database::getInstance(); + char*** table; + + // Objects to Create + Container* container = new Container(); + Hardpoint* hardpoint; + + // + table = db->loadHardpoints(atoi(columnValue[CONTAINER_COLUMN_MAP_OBJECT_ID])); + // Get reference to GameEngine GameEngine *gameEngine = GameEngine::getInstance(); diff --git a/MapObjectFactory.h b/MapObjectFactory.h index 8413663..c4192bb 100644 --- a/MapObjectFactory.h +++ b/MapObjectFactory.h @@ -33,4 +33,5 @@ class MapObjectFactory }; -#endif //MAP_OBJECT_FACTORY_H \ No newline at end of file +#endif //MAP_OBJECT_FACTORY_H + diff --git a/QueryGenerator.cpp b/QueryGenerator.cpp index 31ad5fd..0fb359e 100644 --- a/QueryGenerator.cpp +++ b/QueryGenerator.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2006 Russ Adams, Sean Eubanks, Asgard Contributors + * Copyright (c) 2007 Russ Adams, Sean Eubanks, Asgard Contributors * This file is part of Asgard. * * Asgard is free software; you can redistribute it and/or modify diff --git a/QueryGenerator.h b/QueryGenerator.h index 0423280..a8b233c 100644 --- a/QueryGenerator.h +++ b/QueryGenerator.h @@ -37,4 +37,5 @@ class QueryGenerator static char* hardpoint(int mapObjectId); }; -#endif // QUERY_GENERATOR_H \ No newline at end of file +#endif // QUERY_GENERATOR_H + diff --git a/packages/gnu/Makefile b/packages/gnu/Makefile new file mode 100644 index 0000000..f0d376a --- /dev/null +++ b/packages/gnu/Makefile @@ -0,0 +1,5 @@ +all: + rm ./asgard/src/*.cpp + rm ./asgard/src/*.h + cp ../../*.cpp ./asgard/src/ + cp ../../*.h ./asgard/src/ diff --git a/packages/gnu/README b/packages/gnu/README new file mode 100644 index 0000000..eeb7bb8 --- /dev/null +++ b/packages/gnu/README @@ -0,0 +1,30 @@ +Short Guide for Making GNU-style Package: +09/03/2007 +Written by Russ Adams + + +[only if necessary] + 1. Change trunk/packages/gnu/asgard/configure.ac + 2. Change trunk/packages/gnu/asgard/Makefile.am + 3. Change trunk/packages/gnu/asgard/src/Makefile.am + 4. Add any other necessary Makefile.am's + * at this point, be sure to add any new Makefile.am's or changes to + configure.ac to source control + +[required] + 5. cd trunk/packages/gnu + 6. make + 7. cd asgard + 8. aclocal + 9. autoheader +10. autoconf +11. automake --add-missing + +[test-compile] +12. ./configure +13. make + +[making a tar.gz] +14. make dist + +The created package should appear in trunk/packages/gnu/asgard/asgard-version.tar.gz. diff --git a/packages/gnu/asgard/AUTHORS b/packages/gnu/asgard/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/packages/gnu/asgard/Makefile.am b/packages/gnu/asgard/Makefile.am new file mode 100644 index 0000000..af437a6 --- /dev/null +++ b/packages/gnu/asgard/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/packages/gnu/asgard/NEWS b/packages/gnu/asgard/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/packages/gnu/asgard/README b/packages/gnu/asgard/README new file mode 100644 index 0000000..e69de29 diff --git a/packages/gnu/asgard/configure.ac b/packages/gnu/asgard/configure.ac new file mode 100644 index 0000000..90a5e30 --- /dev/null +++ b/packages/gnu/asgard/configure.ac @@ -0,0 +1,31 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT([FULL-PACKAGE-NAME],[VERSION],[BUG-REPORT-ADDRESS]) +AM_INIT_AUTOMAKE(asgard, 0.3.0) +AC_CONFIG_SRCDIR([src/QueryGenerator.cpp]) +AC_CONFIG_HEADER([config.h]) + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC +AC_PROG_MAKE_SET + +# Checks for libraries. +# FIXME: Replace `main' with a function in `-lsqlite3': +AC_CHECK_LIB([sqlite3], [main]) + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_CONST + +# Checks for library functions. +AC_CHECK_FUNCS([pow sqrt assert]) + +AC_CONFIG_FILES([Makefile + src/Makefile]) + +AC_OUTPUT diff --git a/packages/gnu/asgard/src/Makefile.am b/packages/gnu/asgard/src/Makefile.am new file mode 100644 index 0000000..0daacb0 --- /dev/null +++ b/packages/gnu/asgard/src/Makefile.am @@ -0,0 +1,40 @@ +bin_PROGRAMS = asgard +asgard_SOURCES = \ +CircHardpoint.cpp \ +Container.cpp \ +Coordinate.cpp \ +Database.cpp \ +DesertTile.cpp \ +GameEngine.cpp \ +GrassTile.cpp \ +Item.cpp \ +MapObject.cpp \ +MapObjectFactory.cpp \ +NonPlayerCharacter.cpp \ +QueryGenerator.cpp \ +RectHardpoint.cpp \ +StaticMapObject.cpp \ +WaterTile.cpp \ +main.cpp + +noinst_HEADERS = \ +CircHardpoint.h \ +Container.h \ +Coordinate.h \ +Database.h \ +DatabaseColumnMap.h \ +DesertTile.h \ +GameEngine.h \ +GrassTile.h \ +Hardpoint.h \ +Item.h \ +MapObject.h \ +MapObjectFactory.h \ +MapObjectType.h \ +NonPlayerCharacter.h \ +QueryGenerator.h \ +RectHardpoint.h \ +StaticMapObject.h \ +Tile.h \ +TileType.h \ +WaterTile.h -- 2.11.4.GIT